blob: 4ec74a40e1dbc6308992d8395beeefc22ed0f8d7 [file] [log] [blame]
Dhaval Patelaee7e542014-01-06 16:08:16 -08001/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
Dhaval Patelf9986272013-10-18 19:06:05 -07002 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions
5 * are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in
10 * the documentation and/or other materials provided with the
11 * distribution.
12 * * Neither the name of The Linux Foundation nor the names of its
13 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
19 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
20 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
23 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <debug.h>
31#include <err.h>
32#include <smem.h>
33#include <msm_panel.h>
34#include <board.h>
35#include <mipi_dsi.h>
36
37#include "include/panel.h"
38#include "panel_display.h"
39
40/*---------------------------------------------------------------------------*/
41/* GCDB Panel Database */
42/*---------------------------------------------------------------------------*/
43#include "include/panel_jdi_1080p_video.h"
Dhaval Pateld0a09e22013-10-25 10:15:21 -070044#include "include/panel_jdi_qhd_dualdsi_video.h"
Dhaval Patelaee7e542014-01-06 16:08:16 -080045#include "include/panel_jdi_qhd_dualdsi_cmd.h"
Dhaval Patelf9986272013-10-18 19:06:05 -070046
47/*---------------------------------------------------------------------------*/
48/* static panel selection variable */
49/*---------------------------------------------------------------------------*/
50enum {
51JDI_1080P_VIDEO_PANEL,
Dhaval Pateld0a09e22013-10-25 10:15:21 -070052JDI_QHD_DUALDSI_VIDEO_PANEL,
Dhaval Patelaee7e542014-01-06 16:08:16 -080053JDI_QHD_DUALDSI_CMD_PANEL,
Dhaval Patelf9986272013-10-18 19:06:05 -070054UNKNOWN_PANEL
55};
56
Dhaval Patelbae49882014-02-18 17:16:53 -080057/*
58 * The list of panels that are supported on this target.
59 * Any panel in this list can be selected using fastboot oem command.
60 */
61static struct panel_list supp_panels[] = {
62 {"jdi_1080p_video", JDI_1080P_VIDEO_PANEL},
63 {"jdi_qhd_dualdsi_video", JDI_QHD_DUALDSI_VIDEO_PANEL},
64 {"jdi_qhd_dualdsi_cmd", JDI_QHD_DUALDSI_CMD_PANEL},
65};
66
Dhaval Patelf9986272013-10-18 19:06:05 -070067static uint32_t panel_id;
68
69int oem_panel_rotation()
70{
Dhaval Patelfc7c6092014-03-31 17:15:24 -070071 /* OEM can keep there panel specific on instructions in this
Dhaval Patelf9986272013-10-18 19:06:05 -070072 function */
73 return NO_ERROR;
74}
75
Dhaval Patelf9986272013-10-18 19:06:05 -070076int oem_panel_on()
77{
Dhaval Patelfc7c6092014-03-31 17:15:24 -070078 /* OEM can keep there panel specific on instructions in this
Dhaval Patelf9986272013-10-18 19:06:05 -070079 function */
Dhaval Patelfc7c6092014-03-31 17:15:24 -070080 if (panel_id == JDI_QHD_DUALDSI_CMD_PANEL) {
81 /* needs extra delay to avoid unexpected artifacts */
82 mdelay(JDI_QHD_DUALDSI_CMD_PANEL_ON_DELAY);
83 }
Dhaval Patelf9986272013-10-18 19:06:05 -070084 return NO_ERROR;
85}
86
87int oem_panel_off()
88{
Dhaval Patelfc7c6092014-03-31 17:15:24 -070089 /* OEM can keep there panel specific off instructions in this
Dhaval Patelf9986272013-10-18 19:06:05 -070090 function */
91 return NO_ERROR;
92}
93
94static bool init_panel_data(struct panel_struct *panelstruct,
95 struct msm_panel_info *pinfo,
96 struct mdss_dsi_phy_ctrl *phy_db)
97{
98 bool ret = true;
99
100 switch (panel_id) {
101 case JDI_1080P_VIDEO_PANEL:
102 panelstruct->paneldata = &jdi_1080p_video_panel_data;
103 panelstruct->panelres = &jdi_1080p_video_panel_res;
104 panelstruct->color = &jdi_1080p_video_color;
105 panelstruct->videopanel = &jdi_1080p_video_video_panel;
106 panelstruct->commandpanel = &jdi_1080p_video_command_panel;
107 panelstruct->state = &jdi_1080p_video_state;
108 panelstruct->laneconfig = &jdi_1080p_video_lane_config;
109 panelstruct->paneltiminginfo
110 = &jdi_1080p_video_timing_info;
111 panelstruct->panelresetseq
112 = &jdi_1080p_video_panel_reset_seq;
113 panelstruct->backlightinfo = &jdi_1080p_video_backlight;
114 pinfo->mipi.panel_cmds
115 = jdi_1080p_video_on_command;
116 pinfo->mipi.num_of_panel_cmds
117 = JDI_1080P_VIDEO_ON_COMMAND;
118 memcpy(phy_db->timing,
119 jdi_1080p_video_timings, TIMING_SIZE);
120 break;
Dhaval Pateld0a09e22013-10-25 10:15:21 -0700121 case JDI_QHD_DUALDSI_VIDEO_PANEL:
122 panelstruct->paneldata = &jdi_qhd_dualdsi_video_panel_data;
123 panelstruct->panelres = &jdi_qhd_dualdsi_video_panel_res;
124 panelstruct->color = &jdi_qhd_dualdsi_video_color;
125 panelstruct->videopanel = &jdi_qhd_dualdsi_video_video_panel;
126 panelstruct->commandpanel = &jdi_qhd_dualdsi_video_command_panel;
127 panelstruct->state = &jdi_qhd_dualdsi_video_state;
128 panelstruct->laneconfig = &jdi_qhd_dualdsi_video_lane_config;
129 panelstruct->paneltiminginfo
130 = &jdi_qhd_dualdsi_video_timing_info;
131 panelstruct->panelresetseq
132 = &jdi_qhd_dualdsi_video_reset_seq;
133 panelstruct->backlightinfo = &jdi_qhd_dualdsi_video_backlight;
134 pinfo->mipi.panel_cmds
135 = jdi_qhd_dualdsi_video_on_command;
136 pinfo->mipi.num_of_panel_cmds
137 = JDI_QHD_DUALDSI_VIDEO_ON_COMMAND;
138 memcpy(phy_db->timing,
139 jdi_qhd_dualdsi_video_timings, TIMING_SIZE);
140 break;
Dhaval Patelaee7e542014-01-06 16:08:16 -0800141 case JDI_QHD_DUALDSI_CMD_PANEL:
142 panelstruct->paneldata = &jdi_qhd_dualdsi_cmd_panel_data;
143 panelstruct->panelres = &jdi_qhd_dualdsi_cmd_panel_res;
144 panelstruct->color = &jdi_qhd_dualdsi_cmd_color;
145 panelstruct->videopanel = &jdi_qhd_dualdsi_cmd_video_panel;
146 panelstruct->commandpanel = &jdi_qhd_dualdsi_cmd_command_panel;
147 panelstruct->state = &jdi_qhd_dualdsi_cmd_state;
148 panelstruct->laneconfig = &jdi_qhd_dualdsi_cmd_lane_config;
149 panelstruct->paneltiminginfo
150 = &jdi_qhd_dualdsi_cmd_timing_info;
151 panelstruct->panelresetseq
152 = &jdi_qhd_dualdsi_cmd_reset_seq;
153 panelstruct->backlightinfo = &jdi_qhd_dualdsi_cmd_backlight;
154 pinfo->mipi.panel_cmds
155 = jdi_qhd_dualdsi_cmd_on_command;
156 pinfo->mipi.num_of_panel_cmds
157 = JDI_QHD_DUALDSI_CMD_ON_COMMAND;
158 memcpy(phy_db->timing,
159 jdi_qhd_dualdsi_cmd_timings, TIMING_SIZE);
160 break;
Dhaval Patelf9986272013-10-18 19:06:05 -0700161 default:
162 case UNKNOWN_PANEL:
163 ret = false;
164 break;
165 }
166 return ret;
167}
168
Aravind Venkateswarand494f962014-02-25 17:16:49 -0800169bool oem_panel_select(const char *panel_name, struct panel_struct *panelstruct,
Dhaval Patelf9986272013-10-18 19:06:05 -0700170 struct msm_panel_info *pinfo,
171 struct mdss_dsi_phy_ctrl *phy_db)
172{
173 uint32_t hw_id = board_hardware_id();
Dhaval Patelbae49882014-02-18 17:16:53 -0800174 int32_t panel_override_id;
175
176 if (panel_name) {
177 panel_override_id = panel_name_to_id(supp_panels,
178 ARRAY_SIZE(supp_panels), panel_name);
179
180 if (panel_override_id < 0) {
181 dprintf(CRITICAL, "Not able to search the panel:%s\n",
182 panel_name + strspn(panel_name, " "));
183 } else if (panel_override_id < UNKNOWN_PANEL) {
184 /* panel override using fastboot oem command */
185 panel_id = panel_override_id;
186
187 dprintf(INFO, "OEM panel override:%s\n",
188 panel_name + strspn(panel_name, " "));
189 goto panel_init;
190 }
191 }
Dhaval Patelf9986272013-10-18 19:06:05 -0700192
193 switch (hw_id) {
194 case HW_PLATFORM_MTP:
195 case HW_PLATFORM_FLUID:
196 case HW_PLATFORM_SURF:
197 panel_id = JDI_1080P_VIDEO_PANEL;
198 break;
Dhaval Pateld0a09e22013-10-25 10:15:21 -0700199 case HW_PLATFORM_LIQUID:
200 panel_id = JDI_QHD_DUALDSI_VIDEO_PANEL;
201 break;
Dhaval Patelf9986272013-10-18 19:06:05 -0700202 default:
203 dprintf(CRITICAL, "Display not enabled for %d HW type\n"
204 , hw_id);
205 return false;
206 }
207
Dhaval Patelbae49882014-02-18 17:16:53 -0800208panel_init:
Dhaval Patelf9986272013-10-18 19:06:05 -0700209 return init_panel_data(panelstruct, pinfo, phy_db);
210}