blob: a0fcc4177d37b3ff2e45530fab655adb27f51448 [file] [log] [blame]
Aravind Venkateswaranbece4382014-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 Zhangbe678552013-09-03 19:17:07 +080049#include "include/panel_ssd2080m_720p_video.h"
Aravind Venkateswarand0398502013-11-04 16:46:46 -080050#include "include/panel_jdi_1080p_video.h"
Arpita Banerjee841fa062013-05-24 14:59:51 -070051
Pradeep Jilagamcd51b522013-10-29 13:08:51 +053052#define DISPLAY_MAX_PANEL_DETECTION 2
53
Arpita Banerjee841fa062013-05-24 14:59:51 -070054/*---------------------------------------------------------------------------*/
55/* static panel selection variable */
56/*---------------------------------------------------------------------------*/
57enum {
58TOSHIBA_720P_VIDEO_PANEL,
59NT35590_720P_CMD_PANEL,
Arpita Banerjeef04ae4b2013-06-14 11:32:20 -070060NT35590_720P_VIDEO_PANEL,
Ray Zhang70abc542013-07-08 15:48:19 +080061NT35596_1080P_VIDEO_PANEL,
Ray Zhang53b0dce2013-07-08 19:35:48 +080062HX8394A_720P_VIDEO_PANEL,
Ray Zhangbe678552013-09-03 19:17:07 +080063NT35521_720P_VIDEO_PANEL,
Aravind Venkateswarand0398502013-11-04 16:46:46 -080064SSD2080M_720P_VIDEO_PANEL,
Pradeep Jilagamcd51b522013-10-29 13:08:51 +053065JDI_1080P_VIDEO_PANEL,
66UNKNOWN_PANEL
Aravind Venkateswarand0398502013-11-04 16:46:46 -080067};
68
69enum target_subtype {
70 HW_PLATFORM_SUBTYPE_720P = 0,
71 HW_PLATFORM_SUBTYPE_SKUAA = 1,
72 HW_PLATFORM_SUBTYPE_SKUF = 2,
73 HW_PLATFORM_SUBTYPE_1080P = 2,
74 HW_PLATFORM_SUBTYPE_SKUAB = 3,
Aravind Venkateswaranbece4382014-01-23 11:43:02 -080075 HW_PLATFORM_SUBTYPE_1080P_EXT_BUCK = 3,
Aravind Venkateswarand0398502013-11-04 16:46:46 -080076 HW_PLATFORM_SUBTYPE_SKUG = 5,
Arpita Banerjee841fa062013-05-24 14:59:51 -070077};
78
79static uint32_t panel_id;
80
81int oem_panel_rotation()
82{
83 int ret = NO_ERROR;
84 switch (panel_id) {
85 case TOSHIBA_720P_VIDEO_PANEL:
86 ret = mipi_dsi_cmds_tx(toshiba_720p_video_rotation,
87 TOSHIBA_720P_VIDEO_ROTATION);
88 break;
89 case NT35590_720P_CMD_PANEL:
90 ret = mipi_dsi_cmds_tx(nt35590_720p_cmd_rotation,
91 NT35590_720P_CMD_ROTATION);
92 break;
93 case NT35590_720P_VIDEO_PANEL:
94 ret = mipi_dsi_cmds_tx(nt35590_720p_video_rotation,
95 NT35590_720P_VIDEO_ROTATION);
96 break;
97 }
98
99 return ret;
100}
101
102
103int oem_panel_on()
104{
105 /* OEM can keep there panel spefic on instructions in this
106 function */
107 return NO_ERROR;
108}
109
110int oem_panel_off()
111{
112 /* OEM can keep there panel spefic off instructions in this
113 function */
114 return NO_ERROR;
115}
116
117static void init_panel_data(struct panel_struct *panelstruct,
118 struct msm_panel_info *pinfo,
119 struct mdss_dsi_phy_ctrl *phy_db)
120{
121 switch (panel_id) {
122 case TOSHIBA_720P_VIDEO_PANEL:
123 panelstruct->paneldata = &toshiba_720p_video_panel_data;
124 panelstruct->panelres = &toshiba_720p_video_panel_res;
125 panelstruct->color = &toshiba_720p_video_color;
126 panelstruct->videopanel = &toshiba_720p_video_video_panel;
127 panelstruct->commandpanel = &toshiba_720p_video_command_panel;
128 panelstruct->state = &toshiba_720p_video_state;
129 panelstruct->laneconfig = &toshiba_720p_video_lane_config;
130 panelstruct->paneltiminginfo
131 = &toshiba_720p_video_timing_info;
Casey Piper5197f932013-08-14 17:27:29 -0700132 panelstruct->panelresetseq
133 = &toshiba_720p_video_panel_reset_seq;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700134 panelstruct->backlightinfo = &toshiba_720p_video_backlight;
135 pinfo->mipi.panel_cmds
136 = toshiba_720p_video_on_command;
137 pinfo->mipi.num_of_panel_cmds
138 = TOSHIBA_720P_VIDEO_ON_COMMAND;
139 memcpy(phy_db->timing,
140 toshiba_720p_video_timings, TIMING_SIZE);
141 break;
142 case NT35590_720P_VIDEO_PANEL:
143 panelstruct->paneldata = &nt35590_720p_video_panel_data;
144 panelstruct->panelres = &nt35590_720p_video_panel_res;
145 panelstruct->color = &nt35590_720p_video_color;
146 panelstruct->videopanel = &nt35590_720p_video_video_panel;
147 panelstruct->commandpanel = &nt35590_720p_video_command_panel;
148 panelstruct->state = &nt35590_720p_video_state;
149 panelstruct->laneconfig = &nt35590_720p_video_lane_config;
150 panelstruct->paneltiminginfo
151 = &nt35590_720p_video_timing_info;
Casey Piper5197f932013-08-14 17:27:29 -0700152 panelstruct->panelresetseq
153 = &nt35590_720p_video_panel_reset_seq;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700154 panelstruct->backlightinfo = &nt35590_720p_video_backlight;
155 pinfo->mipi.panel_cmds
156 = nt35590_720p_video_on_command;
157 pinfo->mipi.num_of_panel_cmds
158 = NT35590_720P_VIDEO_ON_COMMAND;
159 memcpy(phy_db->timing,
160 nt35590_720p_video_timings, TIMING_SIZE);
161 break;
Ray Zhang53b0dce2013-07-08 19:35:48 +0800162 case NT35521_720P_VIDEO_PANEL:
163 panelstruct->paneldata = &nt35521_720p_video_panel_data;
164 panelstruct->panelres = &nt35521_720p_video_panel_res;
165 panelstruct->color = &nt35521_720p_video_color;
166 panelstruct->videopanel = &nt35521_720p_video_video_panel;
167 panelstruct->commandpanel = &nt35521_720p_video_command_panel;
168 panelstruct->state = &nt35521_720p_video_state;
169 panelstruct->laneconfig = &nt35521_720p_video_lane_config;
170 panelstruct->paneltiminginfo
171 = &nt35521_720p_video_timing_info;
Casey Piper5197f932013-08-14 17:27:29 -0700172 panelstruct->panelresetseq
173 = &nt35521_720p_video_panel_reset_seq;
Ray Zhang53b0dce2013-07-08 19:35:48 +0800174 panelstruct->backlightinfo = &nt35521_720p_video_backlight;
175 pinfo->mipi.panel_cmds
176 = nt35521_720p_video_on_command;
177 pinfo->mipi.num_of_panel_cmds
178 = NT35521_720P_VIDEO_ON_COMMAND;
179 memcpy(phy_db->timing,
180 nt35521_720p_video_timings, TIMING_SIZE);
181 break;
Ray Zhangbe678552013-09-03 19:17:07 +0800182 case SSD2080M_720P_VIDEO_PANEL:
183 panelstruct->paneldata = &ssd2080m_720p_video_panel_data;
184 panelstruct->panelres = &ssd2080m_720p_video_panel_res;
185 panelstruct->color = &ssd2080m_720p_video_color;
186 panelstruct->videopanel = &ssd2080m_720p_video_video_panel;
187 panelstruct->commandpanel = &ssd2080m_720p_video_command_panel;
188 panelstruct->state = &ssd2080m_720p_video_state;
189 panelstruct->laneconfig = &ssd2080m_720p_video_lane_config;
190 panelstruct->paneltiminginfo
191 = &ssd2080m_720p_video_timing_info;
192 panelstruct->panelresetseq
193 = &ssd2080m_720p_video_panel_reset_seq;
194 panelstruct->backlightinfo = &ssd2080m_720p_video_backlight;
195 pinfo->mipi.panel_cmds
196 = ssd2080m_720p_video_on_command;
197 pinfo->mipi.num_of_panel_cmds
198 = SSD2080M_720P_VIDEO_ON_COMMAND;
199 memcpy(phy_db->timing,
200 ssd2080m_720p_video_timings, TIMING_SIZE);
201 break;
Ray Zhang70abc542013-07-08 15:48:19 +0800202 case HX8394A_720P_VIDEO_PANEL:
203 panelstruct->paneldata = &hx8394a_720p_video_panel_data;
204 panelstruct->panelres = &hx8394a_720p_video_panel_res;
205 panelstruct->color = &hx8394a_720p_video_color;
206 panelstruct->videopanel = &hx8394a_720p_video_video_panel;
207 panelstruct->commandpanel = &hx8394a_720p_video_command_panel;
208 panelstruct->state = &hx8394a_720p_video_state;
209 panelstruct->laneconfig = &hx8394a_720p_video_lane_config;
210 panelstruct->paneltiminginfo
211 = &hx8394a_720p_video_timing_info;
Casey Piper5197f932013-08-14 17:27:29 -0700212 panelstruct->panelresetseq
213 = &hx8394a_720p_video_panel_reset_seq;
Ray Zhang70abc542013-07-08 15:48:19 +0800214 panelstruct->backlightinfo = &hx8394a_720p_video_backlight;
215 pinfo->mipi.panel_cmds
216 = hx8394a_720p_video_on_command;
217 pinfo->mipi.num_of_panel_cmds
218 = HX8394A_720P_VIDEO_ON_COMMAND;
219 memcpy(phy_db->timing,
220 hx8394a_720p_video_timings, TIMING_SIZE);
Pradeep Jilagamcd51b522013-10-29 13:08:51 +0530221 pinfo->mipi.signature = HX8394A_720P_VIDEO_SIGNATURE;
Ray Zhang70abc542013-07-08 15:48:19 +0800222 break;
223
Arpita Banerjee841fa062013-05-24 14:59:51 -0700224 case NT35590_720P_CMD_PANEL:
225 panelstruct->paneldata = &nt35590_720p_cmd_panel_data;
226 panelstruct->panelres = &nt35590_720p_cmd_panel_res;
227 panelstruct->color = &nt35590_720p_cmd_color;
228 panelstruct->videopanel = &nt35590_720p_cmd_video_panel;
229 panelstruct->commandpanel = &nt35590_720p_cmd_command_panel;
230 panelstruct->state = &nt35590_720p_cmd_state;
231 panelstruct->laneconfig = &nt35590_720p_cmd_lane_config;
232 panelstruct->paneltiminginfo = &nt35590_720p_cmd_timing_info;
Casey Piper5197f932013-08-14 17:27:29 -0700233 panelstruct->panelresetseq
234 = &nt35590_720p_cmd_panel_reset_seq;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700235 panelstruct->backlightinfo = &nt35590_720p_cmd_backlight;
236 pinfo->mipi.panel_cmds
237 = nt35590_720p_cmd_on_command;
238 pinfo->mipi.num_of_panel_cmds
239 = NT35590_720P_CMD_ON_COMMAND;
240 memcpy(phy_db->timing,
241 nt35590_720p_cmd_timings, TIMING_SIZE);
242 break;
Arpita Banerjeef04ae4b2013-06-14 11:32:20 -0700243 case NT35596_1080P_VIDEO_PANEL:
244 panelstruct->paneldata = &nt35596_1080p_video_panel_data;
245 panelstruct->panelres = &nt35596_1080p_video_panel_res;
246 panelstruct->color = &nt35596_1080p_video_color;
247 panelstruct->videopanel = &nt35596_1080p_video_video_panel;
248 panelstruct->commandpanel = &nt35596_1080p_video_command_panel;
249 panelstruct->state = &nt35596_1080p_video_state;
250 panelstruct->laneconfig = &nt35596_1080p_video_lane_config;
251 panelstruct->paneltiminginfo
252 = &nt35596_1080p_video_timing_info;
Casey Piper5197f932013-08-14 17:27:29 -0700253 panelstruct->panelresetseq
254 = &nt35596_1080p_video_panel_reset_seq;
Arpita Banerjeef04ae4b2013-06-14 11:32:20 -0700255 panelstruct->backlightinfo
256 = &nt35596_1080p_video_backlight;
257 pinfo->mipi.panel_cmds
258 = nt35596_1080p_video_on_command;
259 pinfo->mipi.num_of_panel_cmds
260 = NT35596_1080P_VIDEO_ON_COMMAND;
261 memcpy(phy_db->timing,
262 nt35596_1080p_video_timings, TIMING_SIZE);
Pradeep Jilagamcd51b522013-10-29 13:08:51 +0530263 pinfo->mipi.signature = NT35596_1080P_VIDEO_SIGNATURE;
Jayant Shekhar93b17802013-11-18 19:59:50 +0530264 break;
Aravind Venkateswarand0398502013-11-04 16:46:46 -0800265 case JDI_1080P_VIDEO_PANEL:
266 panelstruct->paneldata = &jdi_1080p_video_panel_data;
267 panelstruct->paneldata->panel_with_enable_gpio = 1;
268 panelstruct->panelres = &jdi_1080p_video_panel_res;
269 panelstruct->color = &jdi_1080p_video_color;
270 panelstruct->videopanel = &jdi_1080p_video_video_panel;
271 panelstruct->commandpanel = &jdi_1080p_video_command_panel;
272 panelstruct->state = &jdi_1080p_video_state;
273 panelstruct->laneconfig = &jdi_1080p_video_lane_config;
274 panelstruct->paneltiminginfo
275 = &jdi_1080p_video_timing_info;
276 panelstruct->panelresetseq
277 = &jdi_1080p_video_panel_reset_seq;
278 panelstruct->backlightinfo = &jdi_1080p_video_backlight;
279 pinfo->mipi.panel_cmds
280 = jdi_1080p_video_on_command;
281 pinfo->mipi.num_of_panel_cmds
282 = JDI_1080P_VIDEO_ON_COMMAND;
283 memcpy(phy_db->timing,
284 jdi_1080p_video_timings, TIMING_SIZE);
Arpita Banerjeef04ae4b2013-06-14 11:32:20 -0700285 break;
Pradeep Jilagamcd51b522013-10-29 13:08:51 +0530286 case UNKNOWN_PANEL:
287 memset(panelstruct, 0, sizeof(struct panel_struct));
288 memset(pinfo->mipi.panel_cmds, 0, sizeof(struct mipi_dsi_cmd));
289 pinfo->mipi.num_of_panel_cmds = 0;
290 memset(phy_db->timing, 0, TIMING_SIZE);
291 pinfo->mipi.signature = 0;
292 break;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700293 }
294}
295
Pradeep Jilagamcd51b522013-10-29 13:08:51 +0530296uint32_t oem_panel_max_auto_detect_panels()
297{
298 return target_panel_auto_detect_enabled() ?
299 DISPLAY_MAX_PANEL_DETECTION : 0;
300}
301
302static uint32_t auto_pan_loop = 0;
303
Arpita Banerjee841fa062013-05-24 14:59:51 -0700304bool oem_panel_select(struct panel_struct *panelstruct,
305 struct msm_panel_info *pinfo,
306 struct mdss_dsi_phy_ctrl *phy_db)
307{
308 uint32_t hw_id = board_hardware_id();
Ray Zhang70abc542013-07-08 15:48:19 +0800309 uint32_t target_id = board_target_id();
Aravind Venkateswaran9ae369b2013-07-23 22:57:47 -0700310 uint32_t nt35590_panel_id = NT35590_720P_VIDEO_PANEL;
Aravind Venkateswarand0398502013-11-04 16:46:46 -0800311 uint32_t hw_subtype = board_hardware_subtype();
Pradeep Jilagamcd51b522013-10-29 13:08:51 +0530312 bool ret = true;
Aravind Venkateswaran9ae369b2013-07-23 22:57:47 -0700313
314#if DISPLAY_TYPE_CMD_MODE
315 nt35590_panel_id = NT35590_720P_CMD_PANEL;
316#endif
Arpita Banerjee841fa062013-05-24 14:59:51 -0700317
Dhaval Patelfa5d5872013-08-08 10:52:16 -0700318 switch (hw_id) {
319 case HW_PLATFORM_QRD:
Aravind Venkateswarand0398502013-11-04 16:46:46 -0800320 if (hw_subtype == HW_PLATFORM_SUBTYPE_SKUF) {
Dhaval Patelfa5d5872013-08-08 10:52:16 -0700321 panel_id = NT35521_720P_VIDEO_PANEL;
Aravind Venkateswarand0398502013-11-04 16:46:46 -0800322 } else if (hw_subtype == HW_PLATFORM_SUBTYPE_SKUG) {
Ray Zhangbe678552013-09-03 19:17:07 +0800323 panel_id = SSD2080M_720P_VIDEO_PANEL;
Dhaval Patelfa5d5872013-08-08 10:52:16 -0700324 } else {
Kun Liang12945ab2013-09-29 18:27:23 +0800325 if (((target_id >> 16) & 0xFF) == 0x1 || ((target_id >> 16) & 0xFF) == 0x3) //EVT || PVT
Dhaval Patelfa5d5872013-08-08 10:52:16 -0700326 panel_id = nt35590_panel_id;
Pradeep Jilagamcd51b522013-10-29 13:08:51 +0530327 else if (((target_id >> 16) & 0xFF) == 0x2) { //DVT
Dhaval Patelfa5d5872013-08-08 10:52:16 -0700328 panel_id = HX8394A_720P_VIDEO_PANEL;
Pradeep Jilagamcd51b522013-10-29 13:08:51 +0530329 switch (auto_pan_loop) {
330 case 0:
331 panel_id = HX8394A_720P_VIDEO_PANEL;
332 break;
333 case 1:
334 panel_id = NT35596_1080P_VIDEO_PANEL;
335 break;
336 default:
337 panel_id = UNKNOWN_PANEL;
338 ret = false;
339 dprintf(CRITICAL, "Unknown panel\n");
340 return ret;
341 }
342 auto_pan_loop++;
343 }
Dhaval Patelfa5d5872013-08-08 10:52:16 -0700344 else {
345 dprintf(CRITICAL, "Not supported device, target_id=%x\n"
346 , target_id);
347 return false;
348 }
Arpita Banerjee841fa062013-05-24 14:59:51 -0700349 }
350 break;
Dhaval Patelfa5d5872013-08-08 10:52:16 -0700351 case HW_PLATFORM_MTP:
352 case HW_PLATFORM_SURF:
Aravind Venkateswaranbece4382014-01-23 11:43:02 -0800353 if ((hw_subtype == HW_PLATFORM_SUBTYPE_1080P) ||
354 (hw_subtype == HW_PLATFORM_SUBTYPE_1080P_EXT_BUCK))
Aravind Venkateswarand0398502013-11-04 16:46:46 -0800355 panel_id = JDI_1080P_VIDEO_PANEL;
Aravind Venkateswaranbece4382014-01-23 11:43:02 -0800356 else
Jayant Shekharcd300eb2013-12-23 22:39:35 +0530357 panel_id = nt35590_panel_id;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700358 break;
Dhaval Patele4ef9442013-07-16 12:35:56 -0700359 default:
Dhaval Patelfa5d5872013-08-08 10:52:16 -0700360 dprintf(CRITICAL, "Display not enabled for %d HW type\n"
361 , hw_id);
Dhaval Patele4ef9442013-07-16 12:35:56 -0700362 return false;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700363 }
364
365 init_panel_data(panelstruct, pinfo, phy_db);
366
Pradeep Jilagamcd51b522013-10-29 13:08:51 +0530367 return ret;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700368}