blob: f23aded53f77125bbff5ad6285d4d4e24e1a61b4 [file] [log] [blame]
Aravind Venkateswaranc26bb602014-01-23 11:43:02 -08001/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
Arpita Banerjee841fa062013-05-24 14:59:51 -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_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,
Aravind Venkateswaranc26bb602014-01-23 11:43:02 -080077 HW_PLATFORM_SUBTYPE_1080P_EXT_BUCK = 3,
Aravind Venkateswaranaf241212013-11-04 16:46:46 -080078 HW_PLATFORM_SUBTYPE_SKUG = 5,
Arpita Banerjee841fa062013-05-24 14:59:51 -070079};
80
81static uint32_t panel_id;
82
83int oem_panel_rotation()
84{
85 int ret = NO_ERROR;
86 switch (panel_id) {
87 case TOSHIBA_720P_VIDEO_PANEL:
88 ret = mipi_dsi_cmds_tx(toshiba_720p_video_rotation,
89 TOSHIBA_720P_VIDEO_ROTATION);
90 break;
91 case NT35590_720P_CMD_PANEL:
92 ret = mipi_dsi_cmds_tx(nt35590_720p_cmd_rotation,
93 NT35590_720P_CMD_ROTATION);
94 break;
95 case NT35590_720P_VIDEO_PANEL:
96 ret = mipi_dsi_cmds_tx(nt35590_720p_video_rotation,
97 NT35590_720P_VIDEO_ROTATION);
98 break;
99 }
100
101 return ret;
102}
103
Arpita Banerjee841fa062013-05-24 14:59:51 -0700104int oem_panel_on()
105{
106 /* OEM can keep there panel spefic on instructions in this
107 function */
Ray Zhanga6df18c2013-12-04 16:21:50 +0800108 if (panel_id == SSD2080M_720P_VIDEO_PANEL) {
109 /* SSD2080M needs extra delay to avoid unexpected artifacts */
110 mdelay(SSD2080M_720P_VIDEO_PANEL_ON_DELAY);
111 }
Arpita Banerjee841fa062013-05-24 14:59:51 -0700112 return NO_ERROR;
113}
114
115int oem_panel_off()
116{
117 /* OEM can keep there panel spefic off instructions in this
118 function */
119 return NO_ERROR;
120}
121
122static void init_panel_data(struct panel_struct *panelstruct,
123 struct msm_panel_info *pinfo,
124 struct mdss_dsi_phy_ctrl *phy_db)
125{
126 switch (panel_id) {
127 case TOSHIBA_720P_VIDEO_PANEL:
128 panelstruct->paneldata = &toshiba_720p_video_panel_data;
129 panelstruct->panelres = &toshiba_720p_video_panel_res;
130 panelstruct->color = &toshiba_720p_video_color;
131 panelstruct->videopanel = &toshiba_720p_video_video_panel;
132 panelstruct->commandpanel = &toshiba_720p_video_command_panel;
133 panelstruct->state = &toshiba_720p_video_state;
134 panelstruct->laneconfig = &toshiba_720p_video_lane_config;
135 panelstruct->paneltiminginfo
136 = &toshiba_720p_video_timing_info;
Casey Piper5197f932013-08-14 17:27:29 -0700137 panelstruct->panelresetseq
138 = &toshiba_720p_video_panel_reset_seq;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700139 panelstruct->backlightinfo = &toshiba_720p_video_backlight;
140 pinfo->mipi.panel_cmds
141 = toshiba_720p_video_on_command;
142 pinfo->mipi.num_of_panel_cmds
143 = TOSHIBA_720P_VIDEO_ON_COMMAND;
144 memcpy(phy_db->timing,
145 toshiba_720p_video_timings, TIMING_SIZE);
146 break;
147 case NT35590_720P_VIDEO_PANEL:
148 panelstruct->paneldata = &nt35590_720p_video_panel_data;
149 panelstruct->panelres = &nt35590_720p_video_panel_res;
150 panelstruct->color = &nt35590_720p_video_color;
151 panelstruct->videopanel = &nt35590_720p_video_video_panel;
152 panelstruct->commandpanel = &nt35590_720p_video_command_panel;
153 panelstruct->state = &nt35590_720p_video_state;
154 panelstruct->laneconfig = &nt35590_720p_video_lane_config;
155 panelstruct->paneltiminginfo
156 = &nt35590_720p_video_timing_info;
Casey Piper5197f932013-08-14 17:27:29 -0700157 panelstruct->panelresetseq
158 = &nt35590_720p_video_panel_reset_seq;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700159 panelstruct->backlightinfo = &nt35590_720p_video_backlight;
160 pinfo->mipi.panel_cmds
161 = nt35590_720p_video_on_command;
162 pinfo->mipi.num_of_panel_cmds
163 = NT35590_720P_VIDEO_ON_COMMAND;
164 memcpy(phy_db->timing,
165 nt35590_720p_video_timings, TIMING_SIZE);
166 break;
Ray Zhang53b0dce2013-07-08 19:35:48 +0800167 case NT35521_720P_VIDEO_PANEL:
168 panelstruct->paneldata = &nt35521_720p_video_panel_data;
169 panelstruct->panelres = &nt35521_720p_video_panel_res;
170 panelstruct->color = &nt35521_720p_video_color;
171 panelstruct->videopanel = &nt35521_720p_video_video_panel;
172 panelstruct->commandpanel = &nt35521_720p_video_command_panel;
173 panelstruct->state = &nt35521_720p_video_state;
174 panelstruct->laneconfig = &nt35521_720p_video_lane_config;
175 panelstruct->paneltiminginfo
176 = &nt35521_720p_video_timing_info;
Casey Piper5197f932013-08-14 17:27:29 -0700177 panelstruct->panelresetseq
178 = &nt35521_720p_video_panel_reset_seq;
Ray Zhang53b0dce2013-07-08 19:35:48 +0800179 panelstruct->backlightinfo = &nt35521_720p_video_backlight;
180 pinfo->mipi.panel_cmds
181 = nt35521_720p_video_on_command;
182 pinfo->mipi.num_of_panel_cmds
183 = NT35521_720P_VIDEO_ON_COMMAND;
184 memcpy(phy_db->timing,
185 nt35521_720p_video_timings, TIMING_SIZE);
186 break;
Ray Zhange100ab62013-09-03 19:17:07 +0800187 case SSD2080M_720P_VIDEO_PANEL:
188 panelstruct->paneldata = &ssd2080m_720p_video_panel_data;
189 panelstruct->panelres = &ssd2080m_720p_video_panel_res;
190 panelstruct->color = &ssd2080m_720p_video_color;
191 panelstruct->videopanel = &ssd2080m_720p_video_video_panel;
192 panelstruct->commandpanel = &ssd2080m_720p_video_command_panel;
193 panelstruct->state = &ssd2080m_720p_video_state;
194 panelstruct->laneconfig = &ssd2080m_720p_video_lane_config;
195 panelstruct->paneltiminginfo
196 = &ssd2080m_720p_video_timing_info;
197 panelstruct->panelresetseq
198 = &ssd2080m_720p_video_panel_reset_seq;
199 panelstruct->backlightinfo = &ssd2080m_720p_video_backlight;
200 pinfo->mipi.panel_cmds
201 = ssd2080m_720p_video_on_command;
202 pinfo->mipi.num_of_panel_cmds
203 = SSD2080M_720P_VIDEO_ON_COMMAND;
204 memcpy(phy_db->timing,
205 ssd2080m_720p_video_timings, TIMING_SIZE);
206 break;
Ray Zhang70abc542013-07-08 15:48:19 +0800207 case HX8394A_720P_VIDEO_PANEL:
208 panelstruct->paneldata = &hx8394a_720p_video_panel_data;
209 panelstruct->panelres = &hx8394a_720p_video_panel_res;
210 panelstruct->color = &hx8394a_720p_video_color;
211 panelstruct->videopanel = &hx8394a_720p_video_video_panel;
212 panelstruct->commandpanel = &hx8394a_720p_video_command_panel;
213 panelstruct->state = &hx8394a_720p_video_state;
214 panelstruct->laneconfig = &hx8394a_720p_video_lane_config;
215 panelstruct->paneltiminginfo
216 = &hx8394a_720p_video_timing_info;
Casey Piper5197f932013-08-14 17:27:29 -0700217 panelstruct->panelresetseq
218 = &hx8394a_720p_video_panel_reset_seq;
Ray Zhang70abc542013-07-08 15:48:19 +0800219 panelstruct->backlightinfo = &hx8394a_720p_video_backlight;
220 pinfo->mipi.panel_cmds
221 = hx8394a_720p_video_on_command;
222 pinfo->mipi.num_of_panel_cmds
223 = HX8394A_720P_VIDEO_ON_COMMAND;
224 memcpy(phy_db->timing,
225 hx8394a_720p_video_timings, TIMING_SIZE);
Pradeep Jilagamfeb15982013-10-29 13:08:51 +0530226 pinfo->mipi.signature = HX8394A_720P_VIDEO_SIGNATURE;
Ray Zhang70abc542013-07-08 15:48:19 +0800227 break;
228
Arpita Banerjee841fa062013-05-24 14:59:51 -0700229 case NT35590_720P_CMD_PANEL:
230 panelstruct->paneldata = &nt35590_720p_cmd_panel_data;
231 panelstruct->panelres = &nt35590_720p_cmd_panel_res;
232 panelstruct->color = &nt35590_720p_cmd_color;
233 panelstruct->videopanel = &nt35590_720p_cmd_video_panel;
234 panelstruct->commandpanel = &nt35590_720p_cmd_command_panel;
235 panelstruct->state = &nt35590_720p_cmd_state;
236 panelstruct->laneconfig = &nt35590_720p_cmd_lane_config;
237 panelstruct->paneltiminginfo = &nt35590_720p_cmd_timing_info;
Casey Piper5197f932013-08-14 17:27:29 -0700238 panelstruct->panelresetseq
239 = &nt35590_720p_cmd_panel_reset_seq;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700240 panelstruct->backlightinfo = &nt35590_720p_cmd_backlight;
241 pinfo->mipi.panel_cmds
242 = nt35590_720p_cmd_on_command;
243 pinfo->mipi.num_of_panel_cmds
244 = NT35590_720P_CMD_ON_COMMAND;
245 memcpy(phy_db->timing,
246 nt35590_720p_cmd_timings, TIMING_SIZE);
247 break;
Arpita Banerjeef04ae4b2013-06-14 11:32:20 -0700248 case NT35596_1080P_VIDEO_PANEL:
249 panelstruct->paneldata = &nt35596_1080p_video_panel_data;
250 panelstruct->panelres = &nt35596_1080p_video_panel_res;
251 panelstruct->color = &nt35596_1080p_video_color;
252 panelstruct->videopanel = &nt35596_1080p_video_video_panel;
253 panelstruct->commandpanel = &nt35596_1080p_video_command_panel;
254 panelstruct->state = &nt35596_1080p_video_state;
255 panelstruct->laneconfig = &nt35596_1080p_video_lane_config;
256 panelstruct->paneltiminginfo
257 = &nt35596_1080p_video_timing_info;
Casey Piper5197f932013-08-14 17:27:29 -0700258 panelstruct->panelresetseq
259 = &nt35596_1080p_video_panel_reset_seq;
Arpita Banerjeef04ae4b2013-06-14 11:32:20 -0700260 panelstruct->backlightinfo
261 = &nt35596_1080p_video_backlight;
262 pinfo->mipi.panel_cmds
263 = nt35596_1080p_video_on_command;
264 pinfo->mipi.num_of_panel_cmds
265 = NT35596_1080P_VIDEO_ON_COMMAND;
266 memcpy(phy_db->timing,
267 nt35596_1080p_video_timings, TIMING_SIZE);
Pradeep Jilagamfeb15982013-10-29 13:08:51 +0530268 pinfo->mipi.signature = NT35596_1080P_VIDEO_SIGNATURE;
Jayant Shekhar24be5e62013-11-18 19:59:50 +0530269 break;
Aravind Venkateswaranaf241212013-11-04 16:46:46 -0800270 case JDI_1080P_VIDEO_PANEL:
271 panelstruct->paneldata = &jdi_1080p_video_panel_data;
272 panelstruct->paneldata->panel_with_enable_gpio = 1;
273 panelstruct->panelres = &jdi_1080p_video_panel_res;
274 panelstruct->color = &jdi_1080p_video_color;
275 panelstruct->videopanel = &jdi_1080p_video_video_panel;
276 panelstruct->commandpanel = &jdi_1080p_video_command_panel;
277 panelstruct->state = &jdi_1080p_video_state;
278 panelstruct->laneconfig = &jdi_1080p_video_lane_config;
279 panelstruct->paneltiminginfo
280 = &jdi_1080p_video_timing_info;
281 panelstruct->panelresetseq
282 = &jdi_1080p_video_panel_reset_seq;
283 panelstruct->backlightinfo = &jdi_1080p_video_backlight;
284 pinfo->mipi.panel_cmds
285 = jdi_1080p_video_on_command;
286 pinfo->mipi.num_of_panel_cmds
287 = JDI_1080P_VIDEO_ON_COMMAND;
288 memcpy(phy_db->timing,
289 jdi_1080p_video_timings, TIMING_SIZE);
Arpita Banerjeef04ae4b2013-06-14 11:32:20 -0700290 break;
Pradeep Jilagamfeb15982013-10-29 13:08:51 +0530291 case UNKNOWN_PANEL:
292 memset(panelstruct, 0, sizeof(struct panel_struct));
293 memset(pinfo->mipi.panel_cmds, 0, sizeof(struct mipi_dsi_cmd));
294 pinfo->mipi.num_of_panel_cmds = 0;
295 memset(phy_db->timing, 0, TIMING_SIZE);
296 pinfo->mipi.signature = 0;
297 break;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700298 }
299}
300
Pradeep Jilagamfeb15982013-10-29 13:08:51 +0530301uint32_t oem_panel_max_auto_detect_panels()
302{
303 return target_panel_auto_detect_enabled() ?
304 DISPLAY_MAX_PANEL_DETECTION : 0;
305}
306
307static uint32_t auto_pan_loop = 0;
308
Arpita Banerjee841fa062013-05-24 14:59:51 -0700309bool oem_panel_select(struct panel_struct *panelstruct,
310 struct msm_panel_info *pinfo,
311 struct mdss_dsi_phy_ctrl *phy_db)
312{
313 uint32_t hw_id = board_hardware_id();
Ray Zhang70abc542013-07-08 15:48:19 +0800314 uint32_t target_id = board_target_id();
Aravind Venkateswaran9ae369b2013-07-23 22:57:47 -0700315 uint32_t nt35590_panel_id = NT35590_720P_VIDEO_PANEL;
Aravind Venkateswaranaf241212013-11-04 16:46:46 -0800316 uint32_t hw_subtype = board_hardware_subtype();
Pradeep Jilagamfeb15982013-10-29 13:08:51 +0530317 bool ret = true;
Aravind Venkateswaran9ae369b2013-07-23 22:57:47 -0700318
319#if DISPLAY_TYPE_CMD_MODE
320 nt35590_panel_id = NT35590_720P_CMD_PANEL;
321#endif
Arpita Banerjee841fa062013-05-24 14:59:51 -0700322
Dhaval Patelfa5d5872013-08-08 10:52:16 -0700323 switch (hw_id) {
324 case HW_PLATFORM_QRD:
Aravind Venkateswaranaf241212013-11-04 16:46:46 -0800325 if (hw_subtype == HW_PLATFORM_SUBTYPE_SKUF) {
Dhaval Patelfa5d5872013-08-08 10:52:16 -0700326 panel_id = NT35521_720P_VIDEO_PANEL;
Aravind Venkateswaranaf241212013-11-04 16:46:46 -0800327 } else if (hw_subtype == HW_PLATFORM_SUBTYPE_SKUG) {
Ray Zhange100ab62013-09-03 19:17:07 +0800328 panel_id = SSD2080M_720P_VIDEO_PANEL;
Dhaval Patelfa5d5872013-08-08 10:52:16 -0700329 } else {
Kun Liang6bff57d2013-09-29 18:27:23 +0800330 if (((target_id >> 16) & 0xFF) == 0x1 || ((target_id >> 16) & 0xFF) == 0x3) //EVT || PVT
Dhaval Patelfa5d5872013-08-08 10:52:16 -0700331 panel_id = nt35590_panel_id;
Pradeep Jilagamfeb15982013-10-29 13:08:51 +0530332 else if (((target_id >> 16) & 0xFF) == 0x2) { //DVT
Dhaval Patelfa5d5872013-08-08 10:52:16 -0700333 panel_id = HX8394A_720P_VIDEO_PANEL;
Pradeep Jilagamfeb15982013-10-29 13:08:51 +0530334 switch (auto_pan_loop) {
335 case 0:
336 panel_id = HX8394A_720P_VIDEO_PANEL;
337 break;
338 case 1:
339 panel_id = NT35596_1080P_VIDEO_PANEL;
340 break;
341 default:
342 panel_id = UNKNOWN_PANEL;
343 ret = false;
344 dprintf(CRITICAL, "Unknown panel\n");
345 return ret;
346 }
347 auto_pan_loop++;
348 }
Dhaval Patelfa5d5872013-08-08 10:52:16 -0700349 else {
350 dprintf(CRITICAL, "Not supported device, target_id=%x\n"
351 , target_id);
352 return false;
353 }
Arpita Banerjee841fa062013-05-24 14:59:51 -0700354 }
355 break;
Dhaval Patelfa5d5872013-08-08 10:52:16 -0700356 case HW_PLATFORM_MTP:
357 case HW_PLATFORM_SURF:
Aravind Venkateswaranc26bb602014-01-23 11:43:02 -0800358 if ((hw_subtype == HW_PLATFORM_SUBTYPE_1080P) ||
359 (hw_subtype == HW_PLATFORM_SUBTYPE_1080P_EXT_BUCK))
Aravind Venkateswaranaf241212013-11-04 16:46:46 -0800360 panel_id = JDI_1080P_VIDEO_PANEL;
Aravind Venkateswaranc26bb602014-01-23 11:43:02 -0800361 else
Jayant Shekhareb6e0872013-12-23 22:39:35 +0530362 panel_id = nt35590_panel_id;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700363 break;
Dhaval Patele4ef9442013-07-16 12:35:56 -0700364 default:
Dhaval Patelfa5d5872013-08-08 10:52:16 -0700365 dprintf(CRITICAL, "Display not enabled for %d HW type\n"
366 , hw_id);
Dhaval Patele4ef9442013-07-16 12:35:56 -0700367 return false;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700368 }
369
370 init_panel_data(panelstruct, pinfo, phy_db);
371
Pradeep Jilagamfeb15982013-10-29 13:08:51 +0530372 return ret;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700373}