blob: 14fd1792184e92d48994682df673b17a1d5791ae [file] [log] [blame]
Arpita Banerjee841fa062013-05-24 14:59:51 -07001/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
2 *
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_toshiba_720p_video.h"
44#include "include/panel_nt35590_720p_video.h"
45#include "include/panel_nt35590_720p_cmd.h"
Ray Zhang70abc542013-07-08 15:48:19 +080046#include "include/panel_hx8394a_720p_video.h"
Arpita Banerjeef04ae4b2013-06-14 11:32:20 -070047#include "include/panel_nt35596_1080p_video.h"
Ray Zhang53b0dce2013-07-08 19:35:48 +080048#include "include/panel_nt35521_720p_video.h"
Ray Zhange100ab62013-09-03 19:17:07 +080049#include "include/panel_ssd2080m_720p_video.h"
Aravind Venkateswaranaf241212013-11-04 16:46:46 -080050#include "include/panel_jdi_1080p_video.h"
Arpita Banerjee841fa062013-05-24 14:59:51 -070051
Pradeep Jilagamfeb15982013-10-29 13:08:51 +053052#define DISPLAY_MAX_PANEL_DETECTION 2
53
Ray Zhanga6df18c2013-12-04 16:21:50 +080054#define SSD2080M_720P_VIDEO_PANEL_ON_DELAY 200
55
Arpita Banerjee841fa062013-05-24 14:59:51 -070056/*---------------------------------------------------------------------------*/
57/* static panel selection variable */
58/*---------------------------------------------------------------------------*/
59enum {
60TOSHIBA_720P_VIDEO_PANEL,
61NT35590_720P_CMD_PANEL,
Arpita Banerjeef04ae4b2013-06-14 11:32:20 -070062NT35590_720P_VIDEO_PANEL,
Ray Zhang70abc542013-07-08 15:48:19 +080063NT35596_1080P_VIDEO_PANEL,
Ray Zhang53b0dce2013-07-08 19:35:48 +080064HX8394A_720P_VIDEO_PANEL,
Ray Zhange100ab62013-09-03 19:17:07 +080065NT35521_720P_VIDEO_PANEL,
Aravind Venkateswaranaf241212013-11-04 16:46:46 -080066SSD2080M_720P_VIDEO_PANEL,
Pradeep Jilagamfeb15982013-10-29 13:08:51 +053067JDI_1080P_VIDEO_PANEL,
68UNKNOWN_PANEL
Aravind Venkateswaranaf241212013-11-04 16:46:46 -080069};
70
71enum target_subtype {
72 HW_PLATFORM_SUBTYPE_720P = 0,
73 HW_PLATFORM_SUBTYPE_SKUAA = 1,
74 HW_PLATFORM_SUBTYPE_SKUF = 2,
75 HW_PLATFORM_SUBTYPE_1080P = 2,
76 HW_PLATFORM_SUBTYPE_SKUAB = 3,
77 HW_PLATFORM_SUBTYPE_SKUG = 5,
Arpita Banerjee841fa062013-05-24 14:59:51 -070078};
79
80static uint32_t panel_id;
81
82int oem_panel_rotation()
83{
84 int ret = NO_ERROR;
85 switch (panel_id) {
86 case TOSHIBA_720P_VIDEO_PANEL:
87 ret = mipi_dsi_cmds_tx(toshiba_720p_video_rotation,
88 TOSHIBA_720P_VIDEO_ROTATION);
89 break;
90 case NT35590_720P_CMD_PANEL:
91 ret = mipi_dsi_cmds_tx(nt35590_720p_cmd_rotation,
92 NT35590_720P_CMD_ROTATION);
93 break;
94 case NT35590_720P_VIDEO_PANEL:
95 ret = mipi_dsi_cmds_tx(nt35590_720p_video_rotation,
96 NT35590_720P_VIDEO_ROTATION);
97 break;
98 }
99
100 return ret;
101}
102
Arpita Banerjee841fa062013-05-24 14:59:51 -0700103int oem_panel_on()
104{
105 /* OEM can keep there panel spefic on instructions in this
106 function */
Ray Zhanga6df18c2013-12-04 16:21:50 +0800107 if (panel_id == SSD2080M_720P_VIDEO_PANEL) {
108 /* SSD2080M needs extra delay to avoid unexpected artifacts */
109 mdelay(SSD2080M_720P_VIDEO_PANEL_ON_DELAY);
110 }
Arpita Banerjee841fa062013-05-24 14:59:51 -0700111 return NO_ERROR;
112}
113
114int oem_panel_off()
115{
116 /* OEM can keep there panel spefic off instructions in this
117 function */
118 return NO_ERROR;
119}
120
121static void init_panel_data(struct panel_struct *panelstruct,
122 struct msm_panel_info *pinfo,
123 struct mdss_dsi_phy_ctrl *phy_db)
124{
125 switch (panel_id) {
126 case TOSHIBA_720P_VIDEO_PANEL:
127 panelstruct->paneldata = &toshiba_720p_video_panel_data;
128 panelstruct->panelres = &toshiba_720p_video_panel_res;
129 panelstruct->color = &toshiba_720p_video_color;
130 panelstruct->videopanel = &toshiba_720p_video_video_panel;
131 panelstruct->commandpanel = &toshiba_720p_video_command_panel;
132 panelstruct->state = &toshiba_720p_video_state;
133 panelstruct->laneconfig = &toshiba_720p_video_lane_config;
134 panelstruct->paneltiminginfo
135 = &toshiba_720p_video_timing_info;
Casey Piper5197f932013-08-14 17:27:29 -0700136 panelstruct->panelresetseq
137 = &toshiba_720p_video_panel_reset_seq;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700138 panelstruct->backlightinfo = &toshiba_720p_video_backlight;
139 pinfo->mipi.panel_cmds
140 = toshiba_720p_video_on_command;
141 pinfo->mipi.num_of_panel_cmds
142 = TOSHIBA_720P_VIDEO_ON_COMMAND;
143 memcpy(phy_db->timing,
144 toshiba_720p_video_timings, TIMING_SIZE);
145 break;
146 case NT35590_720P_VIDEO_PANEL:
147 panelstruct->paneldata = &nt35590_720p_video_panel_data;
148 panelstruct->panelres = &nt35590_720p_video_panel_res;
149 panelstruct->color = &nt35590_720p_video_color;
150 panelstruct->videopanel = &nt35590_720p_video_video_panel;
151 panelstruct->commandpanel = &nt35590_720p_video_command_panel;
152 panelstruct->state = &nt35590_720p_video_state;
153 panelstruct->laneconfig = &nt35590_720p_video_lane_config;
154 panelstruct->paneltiminginfo
155 = &nt35590_720p_video_timing_info;
Casey Piper5197f932013-08-14 17:27:29 -0700156 panelstruct->panelresetseq
157 = &nt35590_720p_video_panel_reset_seq;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700158 panelstruct->backlightinfo = &nt35590_720p_video_backlight;
159 pinfo->mipi.panel_cmds
160 = nt35590_720p_video_on_command;
161 pinfo->mipi.num_of_panel_cmds
162 = NT35590_720P_VIDEO_ON_COMMAND;
163 memcpy(phy_db->timing,
164 nt35590_720p_video_timings, TIMING_SIZE);
165 break;
Ray Zhang53b0dce2013-07-08 19:35:48 +0800166 case NT35521_720P_VIDEO_PANEL:
167 panelstruct->paneldata = &nt35521_720p_video_panel_data;
168 panelstruct->panelres = &nt35521_720p_video_panel_res;
169 panelstruct->color = &nt35521_720p_video_color;
170 panelstruct->videopanel = &nt35521_720p_video_video_panel;
171 panelstruct->commandpanel = &nt35521_720p_video_command_panel;
172 panelstruct->state = &nt35521_720p_video_state;
173 panelstruct->laneconfig = &nt35521_720p_video_lane_config;
174 panelstruct->paneltiminginfo
175 = &nt35521_720p_video_timing_info;
Casey Piper5197f932013-08-14 17:27:29 -0700176 panelstruct->panelresetseq
177 = &nt35521_720p_video_panel_reset_seq;
Ray Zhang53b0dce2013-07-08 19:35:48 +0800178 panelstruct->backlightinfo = &nt35521_720p_video_backlight;
179 pinfo->mipi.panel_cmds
180 = nt35521_720p_video_on_command;
181 pinfo->mipi.num_of_panel_cmds
182 = NT35521_720P_VIDEO_ON_COMMAND;
183 memcpy(phy_db->timing,
184 nt35521_720p_video_timings, TIMING_SIZE);
185 break;
Ray Zhange100ab62013-09-03 19:17:07 +0800186 case SSD2080M_720P_VIDEO_PANEL:
187 panelstruct->paneldata = &ssd2080m_720p_video_panel_data;
188 panelstruct->panelres = &ssd2080m_720p_video_panel_res;
189 panelstruct->color = &ssd2080m_720p_video_color;
190 panelstruct->videopanel = &ssd2080m_720p_video_video_panel;
191 panelstruct->commandpanel = &ssd2080m_720p_video_command_panel;
192 panelstruct->state = &ssd2080m_720p_video_state;
193 panelstruct->laneconfig = &ssd2080m_720p_video_lane_config;
194 panelstruct->paneltiminginfo
195 = &ssd2080m_720p_video_timing_info;
196 panelstruct->panelresetseq
197 = &ssd2080m_720p_video_panel_reset_seq;
198 panelstruct->backlightinfo = &ssd2080m_720p_video_backlight;
199 pinfo->mipi.panel_cmds
200 = ssd2080m_720p_video_on_command;
201 pinfo->mipi.num_of_panel_cmds
202 = SSD2080M_720P_VIDEO_ON_COMMAND;
203 memcpy(phy_db->timing,
204 ssd2080m_720p_video_timings, TIMING_SIZE);
205 break;
Ray Zhang70abc542013-07-08 15:48:19 +0800206 case HX8394A_720P_VIDEO_PANEL:
207 panelstruct->paneldata = &hx8394a_720p_video_panel_data;
208 panelstruct->panelres = &hx8394a_720p_video_panel_res;
209 panelstruct->color = &hx8394a_720p_video_color;
210 panelstruct->videopanel = &hx8394a_720p_video_video_panel;
211 panelstruct->commandpanel = &hx8394a_720p_video_command_panel;
212 panelstruct->state = &hx8394a_720p_video_state;
213 panelstruct->laneconfig = &hx8394a_720p_video_lane_config;
214 panelstruct->paneltiminginfo
215 = &hx8394a_720p_video_timing_info;
Casey Piper5197f932013-08-14 17:27:29 -0700216 panelstruct->panelresetseq
217 = &hx8394a_720p_video_panel_reset_seq;
Ray Zhang70abc542013-07-08 15:48:19 +0800218 panelstruct->backlightinfo = &hx8394a_720p_video_backlight;
219 pinfo->mipi.panel_cmds
220 = hx8394a_720p_video_on_command;
221 pinfo->mipi.num_of_panel_cmds
222 = HX8394A_720P_VIDEO_ON_COMMAND;
223 memcpy(phy_db->timing,
224 hx8394a_720p_video_timings, TIMING_SIZE);
Pradeep Jilagamfeb15982013-10-29 13:08:51 +0530225 pinfo->mipi.signature = HX8394A_720P_VIDEO_SIGNATURE;
Ray Zhang70abc542013-07-08 15:48:19 +0800226 break;
227
Arpita Banerjee841fa062013-05-24 14:59:51 -0700228 case NT35590_720P_CMD_PANEL:
229 panelstruct->paneldata = &nt35590_720p_cmd_panel_data;
230 panelstruct->panelres = &nt35590_720p_cmd_panel_res;
231 panelstruct->color = &nt35590_720p_cmd_color;
232 panelstruct->videopanel = &nt35590_720p_cmd_video_panel;
233 panelstruct->commandpanel = &nt35590_720p_cmd_command_panel;
234 panelstruct->state = &nt35590_720p_cmd_state;
235 panelstruct->laneconfig = &nt35590_720p_cmd_lane_config;
236 panelstruct->paneltiminginfo = &nt35590_720p_cmd_timing_info;
Casey Piper5197f932013-08-14 17:27:29 -0700237 panelstruct->panelresetseq
238 = &nt35590_720p_cmd_panel_reset_seq;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700239 panelstruct->backlightinfo = &nt35590_720p_cmd_backlight;
240 pinfo->mipi.panel_cmds
241 = nt35590_720p_cmd_on_command;
242 pinfo->mipi.num_of_panel_cmds
243 = NT35590_720P_CMD_ON_COMMAND;
244 memcpy(phy_db->timing,
245 nt35590_720p_cmd_timings, TIMING_SIZE);
246 break;
Arpita Banerjeef04ae4b2013-06-14 11:32:20 -0700247 case NT35596_1080P_VIDEO_PANEL:
248 panelstruct->paneldata = &nt35596_1080p_video_panel_data;
249 panelstruct->panelres = &nt35596_1080p_video_panel_res;
250 panelstruct->color = &nt35596_1080p_video_color;
251 panelstruct->videopanel = &nt35596_1080p_video_video_panel;
252 panelstruct->commandpanel = &nt35596_1080p_video_command_panel;
253 panelstruct->state = &nt35596_1080p_video_state;
254 panelstruct->laneconfig = &nt35596_1080p_video_lane_config;
255 panelstruct->paneltiminginfo
256 = &nt35596_1080p_video_timing_info;
Casey Piper5197f932013-08-14 17:27:29 -0700257 panelstruct->panelresetseq
258 = &nt35596_1080p_video_panel_reset_seq;
Arpita Banerjeef04ae4b2013-06-14 11:32:20 -0700259 panelstruct->backlightinfo
260 = &nt35596_1080p_video_backlight;
261 pinfo->mipi.panel_cmds
262 = nt35596_1080p_video_on_command;
263 pinfo->mipi.num_of_panel_cmds
264 = NT35596_1080P_VIDEO_ON_COMMAND;
265 memcpy(phy_db->timing,
266 nt35596_1080p_video_timings, TIMING_SIZE);
Pradeep Jilagamfeb15982013-10-29 13:08:51 +0530267 pinfo->mipi.signature = NT35596_1080P_VIDEO_SIGNATURE;
Jayant Shekhar24be5e62013-11-18 19:59:50 +0530268 break;
Aravind Venkateswaranaf241212013-11-04 16:46:46 -0800269 case JDI_1080P_VIDEO_PANEL:
270 panelstruct->paneldata = &jdi_1080p_video_panel_data;
271 panelstruct->paneldata->panel_with_enable_gpio = 1;
272 panelstruct->panelres = &jdi_1080p_video_panel_res;
273 panelstruct->color = &jdi_1080p_video_color;
274 panelstruct->videopanel = &jdi_1080p_video_video_panel;
275 panelstruct->commandpanel = &jdi_1080p_video_command_panel;
276 panelstruct->state = &jdi_1080p_video_state;
277 panelstruct->laneconfig = &jdi_1080p_video_lane_config;
278 panelstruct->paneltiminginfo
279 = &jdi_1080p_video_timing_info;
280 panelstruct->panelresetseq
281 = &jdi_1080p_video_panel_reset_seq;
282 panelstruct->backlightinfo = &jdi_1080p_video_backlight;
283 pinfo->mipi.panel_cmds
284 = jdi_1080p_video_on_command;
285 pinfo->mipi.num_of_panel_cmds
286 = JDI_1080P_VIDEO_ON_COMMAND;
287 memcpy(phy_db->timing,
288 jdi_1080p_video_timings, TIMING_SIZE);
Arpita Banerjeef04ae4b2013-06-14 11:32:20 -0700289 break;
Pradeep Jilagamfeb15982013-10-29 13:08:51 +0530290 case UNKNOWN_PANEL:
291 memset(panelstruct, 0, sizeof(struct panel_struct));
292 memset(pinfo->mipi.panel_cmds, 0, sizeof(struct mipi_dsi_cmd));
293 pinfo->mipi.num_of_panel_cmds = 0;
294 memset(phy_db->timing, 0, TIMING_SIZE);
295 pinfo->mipi.signature = 0;
296 break;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700297 }
298}
299
Pradeep Jilagamfeb15982013-10-29 13:08:51 +0530300uint32_t oem_panel_max_auto_detect_panels()
301{
302 return target_panel_auto_detect_enabled() ?
303 DISPLAY_MAX_PANEL_DETECTION : 0;
304}
305
306static uint32_t auto_pan_loop = 0;
307
Arpita Banerjee841fa062013-05-24 14:59:51 -0700308bool oem_panel_select(struct panel_struct *panelstruct,
309 struct msm_panel_info *pinfo,
310 struct mdss_dsi_phy_ctrl *phy_db)
311{
312 uint32_t hw_id = board_hardware_id();
Ray Zhang70abc542013-07-08 15:48:19 +0800313 uint32_t target_id = board_target_id();
Aravind Venkateswaran9ae369b2013-07-23 22:57:47 -0700314 uint32_t nt35590_panel_id = NT35590_720P_VIDEO_PANEL;
Aravind Venkateswaranaf241212013-11-04 16:46:46 -0800315 uint32_t hw_subtype = board_hardware_subtype();
Pradeep Jilagamfeb15982013-10-29 13:08:51 +0530316 bool ret = true;
Aravind Venkateswaran9ae369b2013-07-23 22:57:47 -0700317
318#if DISPLAY_TYPE_CMD_MODE
319 nt35590_panel_id = NT35590_720P_CMD_PANEL;
320#endif
Arpita Banerjee841fa062013-05-24 14:59:51 -0700321
Dhaval Patelfa5d5872013-08-08 10:52:16 -0700322 switch (hw_id) {
323 case HW_PLATFORM_QRD:
Aravind Venkateswaranaf241212013-11-04 16:46:46 -0800324 if (hw_subtype == HW_PLATFORM_SUBTYPE_SKUF) {
Dhaval Patelfa5d5872013-08-08 10:52:16 -0700325 panel_id = NT35521_720P_VIDEO_PANEL;
Aravind Venkateswaranaf241212013-11-04 16:46:46 -0800326 } else if (hw_subtype == HW_PLATFORM_SUBTYPE_SKUG) {
Ray Zhange100ab62013-09-03 19:17:07 +0800327 panel_id = SSD2080M_720P_VIDEO_PANEL;
Dhaval Patelfa5d5872013-08-08 10:52:16 -0700328 } else {
Kun Liang6bff57d2013-09-29 18:27:23 +0800329 if (((target_id >> 16) & 0xFF) == 0x1 || ((target_id >> 16) & 0xFF) == 0x3) //EVT || PVT
Dhaval Patelfa5d5872013-08-08 10:52:16 -0700330 panel_id = nt35590_panel_id;
Pradeep Jilagamfeb15982013-10-29 13:08:51 +0530331 else if (((target_id >> 16) & 0xFF) == 0x2) { //DVT
Dhaval Patelfa5d5872013-08-08 10:52:16 -0700332 panel_id = HX8394A_720P_VIDEO_PANEL;
Pradeep Jilagamfeb15982013-10-29 13:08:51 +0530333 switch (auto_pan_loop) {
334 case 0:
335 panel_id = HX8394A_720P_VIDEO_PANEL;
336 break;
337 case 1:
338 panel_id = NT35596_1080P_VIDEO_PANEL;
339 break;
340 default:
341 panel_id = UNKNOWN_PANEL;
342 ret = false;
343 dprintf(CRITICAL, "Unknown panel\n");
344 return ret;
345 }
346 auto_pan_loop++;
347 }
Dhaval Patelfa5d5872013-08-08 10:52:16 -0700348 else {
349 dprintf(CRITICAL, "Not supported device, target_id=%x\n"
350 , target_id);
351 return false;
352 }
Arpita Banerjee841fa062013-05-24 14:59:51 -0700353 }
354 break;
Dhaval Patelfa5d5872013-08-08 10:52:16 -0700355 case HW_PLATFORM_MTP:
356 case HW_PLATFORM_SURF:
Aravind Venkateswaranaf241212013-11-04 16:46:46 -0800357 if (hw_subtype == HW_PLATFORM_SUBTYPE_720P) {
358 panel_id = nt35590_panel_id;
359 } else if (hw_subtype == HW_PLATFORM_SUBTYPE_1080P) {
360 panel_id = JDI_1080P_VIDEO_PANEL;
361 } else {
362 dprintf(CRITICAL, "Unsupported target_id=%d hw_subtype=%d\n"
363 , target_id, hw_subtype);
364 return false;
365 }
Arpita Banerjee841fa062013-05-24 14:59:51 -0700366 break;
Dhaval Patele4ef9442013-07-16 12:35:56 -0700367 default:
Dhaval Patelfa5d5872013-08-08 10:52:16 -0700368 dprintf(CRITICAL, "Display not enabled for %d HW type\n"
369 , hw_id);
Dhaval Patele4ef9442013-07-16 12:35:56 -0700370 return false;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700371 }
372
373 init_panel_data(panelstruct, pinfo, phy_db);
374
Pradeep Jilagamfeb15982013-10-29 13:08:51 +0530375 return ret;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700376}