blob: 8544a24c7044265e78159a91fecb233f7acf744c [file] [log] [blame]
Padmanabhan Komandurubccbcdc2015-06-30 16:19:24 +05301/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
Casey Piper98e94f12013-09-09 20:42:15 -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>
vijay kumar32856d52014-08-06 16:18:03 +053036#include <string.h>
37#include <target/display.h>
Casey Piper98e94f12013-09-09 20:42:15 -070038
39#include "include/panel.h"
40#include "panel_display.h"
41
42/*---------------------------------------------------------------------------*/
43/* GCDB Panel Database */
44/*---------------------------------------------------------------------------*/
45#include "include/panel_toshiba_720p_video.h"
46#include "include/panel_sharp_qhd_video.h"
Casey Piperce3a4b12013-08-28 14:31:46 -070047#include "include/panel_jdi_1080p_video.h"
Casey Piper78a9ad52013-11-14 13:27:48 -080048#include "include/panel_generic_720p_cmd.h"
Kuogee Hsieh54b452b2013-12-18 14:58:41 -080049#include "include/panel_jdi_qhd_dualdsi_video.h"
50#include "include/panel_jdi_qhd_dualdsi_cmd.h"
Casey Piper98e94f12013-09-09 20:42:15 -070051
Casey Piper78a9ad52013-11-14 13:27:48 -080052#define DISPLAY_MAX_PANEL_DETECTION 3
Casey Piper74f8e5c2013-09-05 15:00:30 -070053
Casey Piper98e94f12013-09-09 20:42:15 -070054/*---------------------------------------------------------------------------*/
55/* static panel selection variable */
56/*---------------------------------------------------------------------------*/
57enum {
Casey Piper74f8e5c2013-09-05 15:00:30 -070058JDI_1080P_VIDEO_PANEL,
Casey Piper98e94f12013-09-09 20:42:15 -070059TOSHIBA_720P_VIDEO_PANEL,
Casey Piperce3a4b12013-08-28 14:31:46 -070060SHARP_QHD_VIDEO_PANEL,
Casey Piper78a9ad52013-11-14 13:27:48 -080061GENERIC_720P_CMD_PANEL,
Kuogee Hsieh54b452b2013-12-18 14:58:41 -080062JDI_QHD_DUALDSI_VIDEO_PANEL,
63JDI_QHD_DUALDSI_CMD_PANEL,
Casey Piper74f8e5c2013-09-05 15:00:30 -070064UNKNOWN_PANEL
Casey Piper98e94f12013-09-09 20:42:15 -070065};
66
Dhaval Patel61819232014-05-23 12:32:39 -070067/*
68 * The list of panels that are supported on this target.
69 * Any panel in this list can be selected using fastboot oem command.
70 */
71static struct panel_list supp_panels[] = {
72 {"jdi_1080p_video", JDI_1080P_VIDEO_PANEL},
73 {"toshiba_720p_video", TOSHIBA_720P_VIDEO_PANEL},
74 {"sharp_qhd_video", SHARP_QHD_VIDEO_PANEL},
75 {"generic_720p_cmd", GENERIC_720P_CMD_PANEL},
76 {"jdi_qhd_dualdsi_video", JDI_QHD_DUALDSI_VIDEO_PANEL},
77 {"jdi_qhd_dualdsi_cmd", JDI_QHD_DUALDSI_CMD_PANEL},
78};
79
Casey Piper98e94f12013-09-09 20:42:15 -070080static uint32_t panel_id;
81
82int oem_panel_rotation()
83{
84 /* OEM can keep there panel spefic on instructions in this
85 function */
86 return NO_ERROR;
87}
88
89
90int oem_panel_on()
91{
92 /* OEM can keep there panel spefic on instructions in this
93 function */
94 return NO_ERROR;
95}
96
97int oem_panel_off()
98{
99 /* OEM can keep there panel spefic off instructions in this
100 function */
101 return NO_ERROR;
102}
103
Kuogee Hsieh80b8a6c2014-06-09 17:25:38 -0700104static int init_panel_data(struct panel_struct *panelstruct,
Casey Piper98e94f12013-09-09 20:42:15 -0700105 struct msm_panel_info *pinfo,
106 struct mdss_dsi_phy_ctrl *phy_db)
107{
Kuogee Hsieh80b8a6c2014-06-09 17:25:38 -0700108 int pan_type = PANEL_TYPE_DSI;
109
Casey Piper98e94f12013-09-09 20:42:15 -0700110 switch (panel_id) {
111 case TOSHIBA_720P_VIDEO_PANEL:
112 panelstruct->paneldata = &toshiba_720p_video_panel_data;
113 panelstruct->panelres = &toshiba_720p_video_panel_res;
114 panelstruct->color = &toshiba_720p_video_color;
115 panelstruct->videopanel = &toshiba_720p_video_video_panel;
116 panelstruct->commandpanel = &toshiba_720p_video_command_panel;
117 panelstruct->state = &toshiba_720p_video_state;
118 panelstruct->laneconfig = &toshiba_720p_video_lane_config;
119 panelstruct->paneltiminginfo
120 = &toshiba_720p_video_timing_info;
121 panelstruct->panelresetseq
122 = &toshiba_720p_video_panel_reset_seq;
123 panelstruct->backlightinfo = &toshiba_720p_video_backlight;
Padmanabhan Komandurub3d31842014-11-04 15:47:53 +0530124 pinfo->mipi.panel_on_cmds
Casey Piper98e94f12013-09-09 20:42:15 -0700125 = toshiba_720p_video_on_command;
Padmanabhan Komandurub3d31842014-11-04 15:47:53 +0530126 pinfo->mipi.num_of_panel_on_cmds
Casey Piper98e94f12013-09-09 20:42:15 -0700127 = TOSHIBA_720P_VIDEO_ON_COMMAND;
Padmanabhan Komandurub3d31842014-11-04 15:47:53 +0530128 pinfo->mipi.panel_off_cmds
129 = toshiba_720p_video_off_command;
130 pinfo->mipi.num_of_panel_off_cmds
131 = TOSHIBA_720P_VIDEO_OFF_COMMAND;
Casey Piper98e94f12013-09-09 20:42:15 -0700132 memcpy(phy_db->timing,
133 toshiba_720p_video_timings, TIMING_SIZE);
Casey Piper74f8e5c2013-09-05 15:00:30 -0700134 pinfo->mipi.signature = TOSHIBA_720P_VIDEO_SIGNATURE;
Casey Piper98e94f12013-09-09 20:42:15 -0700135 break;
136 case SHARP_QHD_VIDEO_PANEL:
137 panelstruct->paneldata = &sharp_qhd_video_panel_data;
138 panelstruct->panelres = &sharp_qhd_video_panel_res;
139 panelstruct->color = &sharp_qhd_video_color;
140 panelstruct->videopanel = &sharp_qhd_video_video_panel;
141 panelstruct->commandpanel = &sharp_qhd_video_command_panel;
142 panelstruct->state = &sharp_qhd_video_state;
143 panelstruct->laneconfig = &sharp_qhd_video_lane_config;
144 panelstruct->paneltiminginfo
145 = &sharp_qhd_video_timing_info;
146 panelstruct->panelresetseq
147 = &sharp_qhd_video_panel_reset_seq;
148 panelstruct->backlightinfo = &sharp_qhd_video_backlight;
Padmanabhan Komandurub3d31842014-11-04 15:47:53 +0530149 pinfo->mipi.panel_on_cmds
Casey Piper98e94f12013-09-09 20:42:15 -0700150 = sharp_qhd_video_on_command;
Padmanabhan Komandurub3d31842014-11-04 15:47:53 +0530151 pinfo->mipi.num_of_panel_on_cmds
Casey Piper98e94f12013-09-09 20:42:15 -0700152 = SHARP_QHD_VIDEO_ON_COMMAND;
Padmanabhan Komandurub3d31842014-11-04 15:47:53 +0530153 pinfo->mipi.panel_off_cmds
154 = sharp_qhd_video_off_command;
155 pinfo->mipi.num_of_panel_off_cmds
156 = SHARP_QHD_VIDEO_OFF_COMMAND;
Casey Piper98e94f12013-09-09 20:42:15 -0700157 memcpy(phy_db->timing,
158 sharp_qhd_video_timings, TIMING_SIZE);
159 break;
Casey Piperce3a4b12013-08-28 14:31:46 -0700160 case JDI_1080P_VIDEO_PANEL:
161 panelstruct->paneldata = &jdi_1080p_video_panel_data;
162 panelstruct->panelres = &jdi_1080p_video_panel_res;
163 panelstruct->color = &jdi_1080p_video_color;
164 panelstruct->videopanel = &jdi_1080p_video_video_panel;
165 panelstruct->commandpanel = &jdi_1080p_video_command_panel;
166 panelstruct->state = &jdi_1080p_video_state;
167 panelstruct->laneconfig = &jdi_1080p_video_lane_config;
168 panelstruct->paneltiminginfo
169 = &jdi_1080p_video_timing_info;
170 panelstruct->panelresetseq
171 = &jdi_1080p_video_panel_reset_seq;
172 panelstruct->backlightinfo = &jdi_1080p_video_backlight;
Padmanabhan Komandurub3d31842014-11-04 15:47:53 +0530173 pinfo->mipi.panel_on_cmds
Casey Piperce3a4b12013-08-28 14:31:46 -0700174 = jdi_1080p_video_on_command;
Padmanabhan Komandurub3d31842014-11-04 15:47:53 +0530175 pinfo->mipi.num_of_panel_on_cmds
Casey Piperce3a4b12013-08-28 14:31:46 -0700176 = JDI_1080P_VIDEO_ON_COMMAND;
Padmanabhan Komandurub3d31842014-11-04 15:47:53 +0530177 pinfo->mipi.panel_off_cmds
178 = jdi_1080p_video_off_command;
179 pinfo->mipi.num_of_panel_off_cmds
180 = JDI_1080P_VIDEO_OFF_COMMAND;
Casey Piperce3a4b12013-08-28 14:31:46 -0700181 memcpy(phy_db->timing,
182 jdi_1080p_video_timings, TIMING_SIZE);
Casey Piper74f8e5c2013-09-05 15:00:30 -0700183 pinfo->mipi.signature = JDI_1080P_VIDEO_SIGNATURE;
184 break;
Casey Piper78a9ad52013-11-14 13:27:48 -0800185 case GENERIC_720P_CMD_PANEL:
186 panelstruct->paneldata = &generic_720p_cmd_panel_data;
187 panelstruct->panelres = &generic_720p_cmd_panel_res;
188 panelstruct->color = &generic_720p_cmd_color;
189 panelstruct->videopanel = &generic_720p_cmd_video_panel;
190 panelstruct->commandpanel = &generic_720p_cmd_command_panel;
191 panelstruct->state = &generic_720p_cmd_state;
192 panelstruct->laneconfig = &generic_720p_cmd_lane_config;
193 panelstruct->paneltiminginfo
194 = &generic_720p_cmd_timing_info;
195 panelstruct->panelresetseq
196 = &generic_720p_cmd_reset_seq;
197 panelstruct->backlightinfo = &generic_720p_cmd_backlight;
Padmanabhan Komandurub3d31842014-11-04 15:47:53 +0530198 pinfo->mipi.panel_on_cmds
Casey Piper78a9ad52013-11-14 13:27:48 -0800199 = generic_720p_cmd_on_command;
Padmanabhan Komandurub3d31842014-11-04 15:47:53 +0530200 pinfo->mipi.num_of_panel_on_cmds
Casey Piper78a9ad52013-11-14 13:27:48 -0800201 = GENERIC_720P_CMD_ON_COMMAND;
Padmanabhan Komandurub3d31842014-11-04 15:47:53 +0530202 pinfo->mipi.panel_off_cmds
203 = generic_720p_cmd_off_command;
204 pinfo->mipi.num_of_panel_off_cmds
205 = GENERIC_720P_CMD_OFF_COMMAND;
Casey Piper78a9ad52013-11-14 13:27:48 -0800206 memcpy(phy_db->timing,
207 generic_720p_cmd_timings, TIMING_SIZE);
208 pinfo->mipi.signature = GENERIC_720P_CMD_SIGNATURE;
209 break;
Kuogee Hsieh54b452b2013-12-18 14:58:41 -0800210 case JDI_QHD_DUALDSI_VIDEO_PANEL:
211 panelstruct->paneldata = &jdi_qhd_dualdsi_video_panel_data;
212 panelstruct->panelres = &jdi_qhd_dualdsi_video_panel_res;
213 panelstruct->color = &jdi_qhd_dualdsi_video_color;
214 panelstruct->videopanel = &jdi_qhd_dualdsi_video_video_panel;
215 panelstruct->commandpanel = &jdi_qhd_dualdsi_video_command_panel;
216 panelstruct->state = &jdi_qhd_dualdsi_video_state;
217 panelstruct->laneconfig = &jdi_qhd_dualdsi_video_lane_config;
218 panelstruct->paneltiminginfo
219 = &jdi_qhd_dualdsi_video_timing_info;
220 panelstruct->panelresetseq
221 = &jdi_qhd_dualdsi_video_reset_seq;
222 panelstruct->backlightinfo = &jdi_qhd_dualdsi_video_backlight;
Padmanabhan Komandurub3d31842014-11-04 15:47:53 +0530223 pinfo->mipi.panel_on_cmds
Kuogee Hsieh54b452b2013-12-18 14:58:41 -0800224 = jdi_qhd_dualdsi_video_on_command;
Padmanabhan Komandurub3d31842014-11-04 15:47:53 +0530225 pinfo->mipi.num_of_panel_on_cmds
Kuogee Hsieh54b452b2013-12-18 14:58:41 -0800226 = JDI_QHD_DUALDSI_VIDEO_ON_COMMAND;
Padmanabhan Komandurub3d31842014-11-04 15:47:53 +0530227 pinfo->mipi.panel_off_cmds
228 = jdi_qhd_dualdsi_video_off_command;
229 pinfo->mipi.num_of_panel_off_cmds
230 = JDI_QHD_DUALDSI_VIDEO_OFF_COMMAND;
Kuogee Hsieh54b452b2013-12-18 14:58:41 -0800231 memcpy(phy_db->timing,
232 jdi_qhd_dualdsi_video_timings, TIMING_SIZE);
233 break;
234 case JDI_QHD_DUALDSI_CMD_PANEL:
235 panelstruct->paneldata = &jdi_qhd_dualdsi_cmd_panel_data;
236 panelstruct->panelres = &jdi_qhd_dualdsi_cmd_panel_res;
237 panelstruct->color = &jdi_qhd_dualdsi_cmd_color;
238 panelstruct->videopanel = &jdi_qhd_dualdsi_cmd_video_panel;
239 panelstruct->commandpanel = &jdi_qhd_dualdsi_cmd_command_panel;
240 panelstruct->state = &jdi_qhd_dualdsi_cmd_state;
241 panelstruct->laneconfig = &jdi_qhd_dualdsi_cmd_lane_config;
242 panelstruct->paneltiminginfo
243 = &jdi_qhd_dualdsi_cmd_timing_info;
244 panelstruct->panelresetseq
245 = &jdi_qhd_dualdsi_cmd_reset_seq;
246 panelstruct->backlightinfo = &jdi_qhd_dualdsi_cmd_backlight;
Padmanabhan Komandurub3d31842014-11-04 15:47:53 +0530247 pinfo->mipi.panel_on_cmds
Kuogee Hsieh54b452b2013-12-18 14:58:41 -0800248 = jdi_qhd_dualdsi_cmd_on_command;
Padmanabhan Komandurub3d31842014-11-04 15:47:53 +0530249 pinfo->mipi.num_of_panel_on_cmds
Kuogee Hsieh54b452b2013-12-18 14:58:41 -0800250 = JDI_QHD_DUALDSI_CMD_ON_COMMAND;
Padmanabhan Komandurub3d31842014-11-04 15:47:53 +0530251 pinfo->mipi.panel_off_cmds
252 = jdi_qhd_dualdsi_cmd_off_command;
253 pinfo->mipi.num_of_panel_off_cmds
254 = JDI_QHD_DUALDSI_CMD_OFF_COMMAND;
Kuogee Hsieh54b452b2013-12-18 14:58:41 -0800255 memcpy(phy_db->timing,
256 jdi_qhd_dualdsi_cmd_timings, TIMING_SIZE);
257 break;
Casey Piper74f8e5c2013-09-05 15:00:30 -0700258 case UNKNOWN_PANEL:
259 memset(panelstruct, 0, sizeof(struct panel_struct));
Padmanabhan Komandurub3d31842014-11-04 15:47:53 +0530260 memset(pinfo->mipi.panel_on_cmds, 0,
261 sizeof(struct mipi_dsi_cmd));
262 pinfo->mipi.num_of_panel_on_cmds = 0;
263 memset(pinfo->mipi.panel_off_cmds, 0,
264 sizeof(struct mipi_dsi_cmd));
265 pinfo->mipi.num_of_panel_off_cmds = 0;
Casey Piper74f8e5c2013-09-05 15:00:30 -0700266 memset(phy_db->timing, 0, TIMING_SIZE);
267 pinfo->mipi.signature = 0;
Kuogee Hsieh80b8a6c2014-06-09 17:25:38 -0700268 pan_type = PANEL_TYPE_UNKNOWN;
Casey Piperce3a4b12013-08-28 14:31:46 -0700269 break;
Casey Piper98e94f12013-09-09 20:42:15 -0700270 }
Kuogee Hsieh80b8a6c2014-06-09 17:25:38 -0700271
272 return pan_type;
Casey Piper98e94f12013-09-09 20:42:15 -0700273}
274
Casey Piper74f8e5c2013-09-05 15:00:30 -0700275uint32_t oem_panel_max_auto_detect_panels()
276{
277 return target_panel_auto_detect_enabled() ?
278 DISPLAY_MAX_PANEL_DETECTION : 0;
279}
280
281static uint32_t auto_pan_loop = 0;
282
Kuogee Hsieh80b8a6c2014-06-09 17:25:38 -0700283int oem_panel_select(const char *panel_name, struct panel_struct *panelstruct,
Casey Piper98e94f12013-09-09 20:42:15 -0700284 struct msm_panel_info *pinfo,
285 struct mdss_dsi_phy_ctrl *phy_db)
286{
287 uint32_t hw_id = board_hardware_id();
Dhaval Patel61819232014-05-23 12:32:39 -0700288 int32_t panel_override_id;
289
290 if (panel_name) {
291 panel_override_id = panel_name_to_id(supp_panels,
292 ARRAY_SIZE(supp_panels), panel_name);
293
294 if (panel_override_id < 0) {
295 dprintf(CRITICAL, "Not able to search the panel:%s\n",
Padmanabhan Komandurubccbcdc2015-06-30 16:19:24 +0530296 panel_name);
Dhaval Patel61819232014-05-23 12:32:39 -0700297 } else if (panel_override_id < UNKNOWN_PANEL) {
298 /* panel override using fastboot oem command */
299 panel_id = panel_override_id;
300
301 dprintf(INFO, "OEM panel override:%s\n",
Padmanabhan Komandurubccbcdc2015-06-30 16:19:24 +0530302 panel_name);
Dhaval Patel61819232014-05-23 12:32:39 -0700303 goto panel_init;
304 }
305 }
Casey Piper98e94f12013-09-09 20:42:15 -0700306
307 switch (hw_id) {
308 case HW_PLATFORM_MTP:
309 case HW_PLATFORM_FLUID:
310 case HW_PLATFORM_SURF:
Casey Piper74f8e5c2013-09-05 15:00:30 -0700311 switch (auto_pan_loop) {
312 case 0:
313 panel_id = JDI_1080P_VIDEO_PANEL;
314 break;
315 case 1:
316 panel_id = TOSHIBA_720P_VIDEO_PANEL;
317 break;
Casey Piper78a9ad52013-11-14 13:27:48 -0800318 case 2:
319 panel_id = GENERIC_720P_CMD_PANEL;
320 break;
Casey Piper74f8e5c2013-09-05 15:00:30 -0700321 default:
322 panel_id = UNKNOWN_PANEL;
Casey Piper74f8e5c2013-09-05 15:00:30 -0700323 break;
324 }
325 auto_pan_loop++;
Casey Piper98e94f12013-09-09 20:42:15 -0700326 break;
327 case HW_PLATFORM_DRAGON:
328 panel_id = SHARP_QHD_VIDEO_PANEL;
329 break;
330 default:
331 dprintf(CRITICAL, "Display not enabled for %d HW type\n"
332 , hw_id);
Kuogee Hsieh80b8a6c2014-06-09 17:25:38 -0700333 return PANEL_TYPE_UNKNOWN;
Casey Piper98e94f12013-09-09 20:42:15 -0700334 }
335
Dhaval Patel61819232014-05-23 12:32:39 -0700336panel_init:
Kuogee Hsieh80b8a6c2014-06-09 17:25:38 -0700337 return init_panel_data(panelstruct, pinfo, phy_db);
Casey Piper98e94f12013-09-09 20:42:15 -0700338}