blob: 56dcc0650796d7bbdd506307a3cf0073f8e96922 [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
52/*---------------------------------------------------------------------------*/
53/* static panel selection variable */
54/*---------------------------------------------------------------------------*/
55enum {
56TOSHIBA_720P_VIDEO_PANEL,
57NT35590_720P_CMD_PANEL,
Arpita Banerjeef04ae4b2013-06-14 11:32:20 -070058NT35590_720P_VIDEO_PANEL,
Ray Zhang70abc542013-07-08 15:48:19 +080059NT35596_1080P_VIDEO_PANEL,
Ray Zhang53b0dce2013-07-08 19:35:48 +080060HX8394A_720P_VIDEO_PANEL,
Ray Zhange100ab62013-09-03 19:17:07 +080061NT35521_720P_VIDEO_PANEL,
Aravind Venkateswaranaf241212013-11-04 16:46:46 -080062SSD2080M_720P_VIDEO_PANEL,
63JDI_1080P_VIDEO_PANEL
64};
65
66enum target_subtype {
67 HW_PLATFORM_SUBTYPE_720P = 0,
68 HW_PLATFORM_SUBTYPE_SKUAA = 1,
69 HW_PLATFORM_SUBTYPE_SKUF = 2,
70 HW_PLATFORM_SUBTYPE_1080P = 2,
71 HW_PLATFORM_SUBTYPE_SKUAB = 3,
72 HW_PLATFORM_SUBTYPE_SKUG = 5,
Arpita Banerjee841fa062013-05-24 14:59:51 -070073};
74
75static uint32_t panel_id;
76
77int oem_panel_rotation()
78{
79 int ret = NO_ERROR;
80 switch (panel_id) {
81 case TOSHIBA_720P_VIDEO_PANEL:
82 ret = mipi_dsi_cmds_tx(toshiba_720p_video_rotation,
83 TOSHIBA_720P_VIDEO_ROTATION);
84 break;
85 case NT35590_720P_CMD_PANEL:
86 ret = mipi_dsi_cmds_tx(nt35590_720p_cmd_rotation,
87 NT35590_720P_CMD_ROTATION);
88 break;
89 case NT35590_720P_VIDEO_PANEL:
90 ret = mipi_dsi_cmds_tx(nt35590_720p_video_rotation,
91 NT35590_720P_VIDEO_ROTATION);
92 break;
93 }
94
95 return ret;
96}
97
98
99int oem_panel_on()
100{
101 /* OEM can keep there panel spefic on instructions in this
102 function */
103 return NO_ERROR;
104}
105
106int oem_panel_off()
107{
108 /* OEM can keep there panel spefic off instructions in this
109 function */
110 return NO_ERROR;
111}
112
113static void init_panel_data(struct panel_struct *panelstruct,
114 struct msm_panel_info *pinfo,
115 struct mdss_dsi_phy_ctrl *phy_db)
116{
117 switch (panel_id) {
118 case TOSHIBA_720P_VIDEO_PANEL:
119 panelstruct->paneldata = &toshiba_720p_video_panel_data;
120 panelstruct->panelres = &toshiba_720p_video_panel_res;
121 panelstruct->color = &toshiba_720p_video_color;
122 panelstruct->videopanel = &toshiba_720p_video_video_panel;
123 panelstruct->commandpanel = &toshiba_720p_video_command_panel;
124 panelstruct->state = &toshiba_720p_video_state;
125 panelstruct->laneconfig = &toshiba_720p_video_lane_config;
126 panelstruct->paneltiminginfo
127 = &toshiba_720p_video_timing_info;
Casey Piper5197f932013-08-14 17:27:29 -0700128 panelstruct->panelresetseq
129 = &toshiba_720p_video_panel_reset_seq;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700130 panelstruct->backlightinfo = &toshiba_720p_video_backlight;
131 pinfo->mipi.panel_cmds
132 = toshiba_720p_video_on_command;
133 pinfo->mipi.num_of_panel_cmds
134 = TOSHIBA_720P_VIDEO_ON_COMMAND;
135 memcpy(phy_db->timing,
136 toshiba_720p_video_timings, TIMING_SIZE);
137 break;
138 case NT35590_720P_VIDEO_PANEL:
139 panelstruct->paneldata = &nt35590_720p_video_panel_data;
140 panelstruct->panelres = &nt35590_720p_video_panel_res;
141 panelstruct->color = &nt35590_720p_video_color;
142 panelstruct->videopanel = &nt35590_720p_video_video_panel;
143 panelstruct->commandpanel = &nt35590_720p_video_command_panel;
144 panelstruct->state = &nt35590_720p_video_state;
145 panelstruct->laneconfig = &nt35590_720p_video_lane_config;
146 panelstruct->paneltiminginfo
147 = &nt35590_720p_video_timing_info;
Casey Piper5197f932013-08-14 17:27:29 -0700148 panelstruct->panelresetseq
149 = &nt35590_720p_video_panel_reset_seq;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700150 panelstruct->backlightinfo = &nt35590_720p_video_backlight;
151 pinfo->mipi.panel_cmds
152 = nt35590_720p_video_on_command;
153 pinfo->mipi.num_of_panel_cmds
154 = NT35590_720P_VIDEO_ON_COMMAND;
155 memcpy(phy_db->timing,
156 nt35590_720p_video_timings, TIMING_SIZE);
157 break;
Ray Zhang53b0dce2013-07-08 19:35:48 +0800158 case NT35521_720P_VIDEO_PANEL:
159 panelstruct->paneldata = &nt35521_720p_video_panel_data;
160 panelstruct->panelres = &nt35521_720p_video_panel_res;
161 panelstruct->color = &nt35521_720p_video_color;
162 panelstruct->videopanel = &nt35521_720p_video_video_panel;
163 panelstruct->commandpanel = &nt35521_720p_video_command_panel;
164 panelstruct->state = &nt35521_720p_video_state;
165 panelstruct->laneconfig = &nt35521_720p_video_lane_config;
166 panelstruct->paneltiminginfo
167 = &nt35521_720p_video_timing_info;
Casey Piper5197f932013-08-14 17:27:29 -0700168 panelstruct->panelresetseq
169 = &nt35521_720p_video_panel_reset_seq;
Ray Zhang53b0dce2013-07-08 19:35:48 +0800170 panelstruct->backlightinfo = &nt35521_720p_video_backlight;
171 pinfo->mipi.panel_cmds
172 = nt35521_720p_video_on_command;
173 pinfo->mipi.num_of_panel_cmds
174 = NT35521_720P_VIDEO_ON_COMMAND;
175 memcpy(phy_db->timing,
176 nt35521_720p_video_timings, TIMING_SIZE);
177 break;
Ray Zhange100ab62013-09-03 19:17:07 +0800178 case SSD2080M_720P_VIDEO_PANEL:
179 panelstruct->paneldata = &ssd2080m_720p_video_panel_data;
180 panelstruct->panelres = &ssd2080m_720p_video_panel_res;
181 panelstruct->color = &ssd2080m_720p_video_color;
182 panelstruct->videopanel = &ssd2080m_720p_video_video_panel;
183 panelstruct->commandpanel = &ssd2080m_720p_video_command_panel;
184 panelstruct->state = &ssd2080m_720p_video_state;
185 panelstruct->laneconfig = &ssd2080m_720p_video_lane_config;
186 panelstruct->paneltiminginfo
187 = &ssd2080m_720p_video_timing_info;
188 panelstruct->panelresetseq
189 = &ssd2080m_720p_video_panel_reset_seq;
190 panelstruct->backlightinfo = &ssd2080m_720p_video_backlight;
191 pinfo->mipi.panel_cmds
192 = ssd2080m_720p_video_on_command;
193 pinfo->mipi.num_of_panel_cmds
194 = SSD2080M_720P_VIDEO_ON_COMMAND;
195 memcpy(phy_db->timing,
196 ssd2080m_720p_video_timings, TIMING_SIZE);
197 break;
Ray Zhang70abc542013-07-08 15:48:19 +0800198 case HX8394A_720P_VIDEO_PANEL:
199 panelstruct->paneldata = &hx8394a_720p_video_panel_data;
200 panelstruct->panelres = &hx8394a_720p_video_panel_res;
201 panelstruct->color = &hx8394a_720p_video_color;
202 panelstruct->videopanel = &hx8394a_720p_video_video_panel;
203 panelstruct->commandpanel = &hx8394a_720p_video_command_panel;
204 panelstruct->state = &hx8394a_720p_video_state;
205 panelstruct->laneconfig = &hx8394a_720p_video_lane_config;
206 panelstruct->paneltiminginfo
207 = &hx8394a_720p_video_timing_info;
Casey Piper5197f932013-08-14 17:27:29 -0700208 panelstruct->panelresetseq
209 = &hx8394a_720p_video_panel_reset_seq;
Ray Zhang70abc542013-07-08 15:48:19 +0800210 panelstruct->backlightinfo = &hx8394a_720p_video_backlight;
211 pinfo->mipi.panel_cmds
212 = hx8394a_720p_video_on_command;
213 pinfo->mipi.num_of_panel_cmds
214 = HX8394A_720P_VIDEO_ON_COMMAND;
215 memcpy(phy_db->timing,
216 hx8394a_720p_video_timings, TIMING_SIZE);
217 break;
218
Arpita Banerjee841fa062013-05-24 14:59:51 -0700219 case NT35590_720P_CMD_PANEL:
220 panelstruct->paneldata = &nt35590_720p_cmd_panel_data;
221 panelstruct->panelres = &nt35590_720p_cmd_panel_res;
222 panelstruct->color = &nt35590_720p_cmd_color;
223 panelstruct->videopanel = &nt35590_720p_cmd_video_panel;
224 panelstruct->commandpanel = &nt35590_720p_cmd_command_panel;
225 panelstruct->state = &nt35590_720p_cmd_state;
226 panelstruct->laneconfig = &nt35590_720p_cmd_lane_config;
227 panelstruct->paneltiminginfo = &nt35590_720p_cmd_timing_info;
Casey Piper5197f932013-08-14 17:27:29 -0700228 panelstruct->panelresetseq
229 = &nt35590_720p_cmd_panel_reset_seq;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700230 panelstruct->backlightinfo = &nt35590_720p_cmd_backlight;
231 pinfo->mipi.panel_cmds
232 = nt35590_720p_cmd_on_command;
233 pinfo->mipi.num_of_panel_cmds
234 = NT35590_720P_CMD_ON_COMMAND;
235 memcpy(phy_db->timing,
236 nt35590_720p_cmd_timings, TIMING_SIZE);
237 break;
Arpita Banerjeef04ae4b2013-06-14 11:32:20 -0700238 case NT35596_1080P_VIDEO_PANEL:
239 panelstruct->paneldata = &nt35596_1080p_video_panel_data;
240 panelstruct->panelres = &nt35596_1080p_video_panel_res;
241 panelstruct->color = &nt35596_1080p_video_color;
242 panelstruct->videopanel = &nt35596_1080p_video_video_panel;
243 panelstruct->commandpanel = &nt35596_1080p_video_command_panel;
244 panelstruct->state = &nt35596_1080p_video_state;
245 panelstruct->laneconfig = &nt35596_1080p_video_lane_config;
246 panelstruct->paneltiminginfo
247 = &nt35596_1080p_video_timing_info;
Casey Piper5197f932013-08-14 17:27:29 -0700248 panelstruct->panelresetseq
249 = &nt35596_1080p_video_panel_reset_seq;
Arpita Banerjeef04ae4b2013-06-14 11:32:20 -0700250 panelstruct->backlightinfo
251 = &nt35596_1080p_video_backlight;
252 pinfo->mipi.panel_cmds
253 = nt35596_1080p_video_on_command;
254 pinfo->mipi.num_of_panel_cmds
255 = NT35596_1080P_VIDEO_ON_COMMAND;
256 memcpy(phy_db->timing,
257 nt35596_1080p_video_timings, TIMING_SIZE);
Aravind Venkateswaranaf241212013-11-04 16:46:46 -0800258 case JDI_1080P_VIDEO_PANEL:
259 panelstruct->paneldata = &jdi_1080p_video_panel_data;
260 panelstruct->paneldata->panel_with_enable_gpio = 1;
261 panelstruct->panelres = &jdi_1080p_video_panel_res;
262 panelstruct->color = &jdi_1080p_video_color;
263 panelstruct->videopanel = &jdi_1080p_video_video_panel;
264 panelstruct->commandpanel = &jdi_1080p_video_command_panel;
265 panelstruct->state = &jdi_1080p_video_state;
266 panelstruct->laneconfig = &jdi_1080p_video_lane_config;
267 panelstruct->paneltiminginfo
268 = &jdi_1080p_video_timing_info;
269 panelstruct->panelresetseq
270 = &jdi_1080p_video_panel_reset_seq;
271 panelstruct->backlightinfo = &jdi_1080p_video_backlight;
272 pinfo->mipi.panel_cmds
273 = jdi_1080p_video_on_command;
274 pinfo->mipi.num_of_panel_cmds
275 = JDI_1080P_VIDEO_ON_COMMAND;
276 memcpy(phy_db->timing,
277 jdi_1080p_video_timings, TIMING_SIZE);
Arpita Banerjeef04ae4b2013-06-14 11:32:20 -0700278 break;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700279 }
280}
281
282bool oem_panel_select(struct panel_struct *panelstruct,
283 struct msm_panel_info *pinfo,
284 struct mdss_dsi_phy_ctrl *phy_db)
285{
286 uint32_t hw_id = board_hardware_id();
Ray Zhang70abc542013-07-08 15:48:19 +0800287 uint32_t target_id = board_target_id();
Aravind Venkateswaran9ae369b2013-07-23 22:57:47 -0700288 uint32_t nt35590_panel_id = NT35590_720P_VIDEO_PANEL;
Aravind Venkateswaranaf241212013-11-04 16:46:46 -0800289 uint32_t hw_subtype = board_hardware_subtype();
Aravind Venkateswaran9ae369b2013-07-23 22:57:47 -0700290
291#if DISPLAY_TYPE_CMD_MODE
292 nt35590_panel_id = NT35590_720P_CMD_PANEL;
293#endif
Arpita Banerjee841fa062013-05-24 14:59:51 -0700294
Dhaval Patelfa5d5872013-08-08 10:52:16 -0700295 switch (hw_id) {
296 case HW_PLATFORM_QRD:
Aravind Venkateswaranaf241212013-11-04 16:46:46 -0800297 if (hw_subtype == HW_PLATFORM_SUBTYPE_SKUF) {
Dhaval Patelfa5d5872013-08-08 10:52:16 -0700298 panel_id = NT35521_720P_VIDEO_PANEL;
Aravind Venkateswaranaf241212013-11-04 16:46:46 -0800299 } else if (hw_subtype == HW_PLATFORM_SUBTYPE_SKUG) {
Ray Zhange100ab62013-09-03 19:17:07 +0800300 panel_id = SSD2080M_720P_VIDEO_PANEL;
Dhaval Patelfa5d5872013-08-08 10:52:16 -0700301 } else {
Kun Liang6bff57d2013-09-29 18:27:23 +0800302 if (((target_id >> 16) & 0xFF) == 0x1 || ((target_id >> 16) & 0xFF) == 0x3) //EVT || PVT
Dhaval Patelfa5d5872013-08-08 10:52:16 -0700303 panel_id = nt35590_panel_id;
304 else if (((target_id >> 16) & 0xFF) == 0x2) //DVT
305 panel_id = HX8394A_720P_VIDEO_PANEL;
306 else {
307 dprintf(CRITICAL, "Not supported device, target_id=%x\n"
308 , target_id);
309 return false;
310 }
Arpita Banerjee841fa062013-05-24 14:59:51 -0700311 }
312 break;
Dhaval Patelfa5d5872013-08-08 10:52:16 -0700313 case HW_PLATFORM_MTP:
314 case HW_PLATFORM_SURF:
Aravind Venkateswaranaf241212013-11-04 16:46:46 -0800315 if (hw_subtype == HW_PLATFORM_SUBTYPE_720P) {
316 panel_id = nt35590_panel_id;
317 } else if (hw_subtype == HW_PLATFORM_SUBTYPE_1080P) {
318 panel_id = JDI_1080P_VIDEO_PANEL;
319 } else {
320 dprintf(CRITICAL, "Unsupported target_id=%d hw_subtype=%d\n"
321 , target_id, hw_subtype);
322 return false;
323 }
Arpita Banerjee841fa062013-05-24 14:59:51 -0700324 break;
Dhaval Patele4ef9442013-07-16 12:35:56 -0700325 default:
Dhaval Patelfa5d5872013-08-08 10:52:16 -0700326 dprintf(CRITICAL, "Display not enabled for %d HW type\n"
327 , hw_id);
Dhaval Patele4ef9442013-07-16 12:35:56 -0700328 return false;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700329 }
330
331 init_panel_data(panelstruct, pinfo, phy_db);
332
333 return true;
334}