blob: 21c71db8748f9e2b9287655c2fb9d57341d447a0 [file] [log] [blame]
wangxl1ddbd092015-02-03 20:31:24 +08001/* Copyright (c) 2013-2014, 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_sharp_qhd_video.h"
45#include "include/panel_jdi_1080p_video.h"
46#include "include/panel_generic_720p_cmd.h"
47#include "include/panel_jdi_qhd_dualdsi_video.h"
48#include "include/panel_jdi_qhd_dualdsi_cmd.h"
liuyan8c8b2c02015-01-26 15:27:19 +080049#include "include/panel_otm1902b_1080p_cmd.h"
wangxl1ddbd092015-02-03 20:31:24 +080050
51#define DISPLAY_MAX_PANEL_DETECTION 3
52
53/*---------------------------------------------------------------------------*/
54/* static panel selection variable */
55/*---------------------------------------------------------------------------*/
56enum {
57JDI_1080P_VIDEO_PANEL,
58TOSHIBA_720P_VIDEO_PANEL,
59SHARP_QHD_VIDEO_PANEL,
60GENERIC_720P_CMD_PANEL,
61JDI_QHD_DUALDSI_VIDEO_PANEL,
62JDI_QHD_DUALDSI_CMD_PANEL,
liuyan8c8b2c02015-01-26 15:27:19 +080063OTM1902B_1080P_CMD_PANEL,
wangxl1ddbd092015-02-03 20:31:24 +080064UNKNOWN_PANEL
65};
66
67/*
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
80static 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
104static void init_panel_data(struct panel_struct *panelstruct,
105 struct msm_panel_info *pinfo,
106 struct mdss_dsi_phy_ctrl *phy_db)
107{
108 switch (panel_id) {
109 case TOSHIBA_720P_VIDEO_PANEL:
110 panelstruct->paneldata = &toshiba_720p_video_panel_data;
111 panelstruct->panelres = &toshiba_720p_video_panel_res;
112 panelstruct->color = &toshiba_720p_video_color;
113 panelstruct->videopanel = &toshiba_720p_video_video_panel;
114 panelstruct->commandpanel = &toshiba_720p_video_command_panel;
115 panelstruct->state = &toshiba_720p_video_state;
116 panelstruct->laneconfig = &toshiba_720p_video_lane_config;
117 panelstruct->paneltiminginfo
118 = &toshiba_720p_video_timing_info;
119 panelstruct->panelresetseq
120 = &toshiba_720p_video_panel_reset_seq;
121 panelstruct->backlightinfo = &toshiba_720p_video_backlight;
122 pinfo->mipi.panel_cmds
123 = toshiba_720p_video_on_command;
124 pinfo->mipi.num_of_panel_cmds
125 = TOSHIBA_720P_VIDEO_ON_COMMAND;
126 memcpy(phy_db->timing,
127 toshiba_720p_video_timings, TIMING_SIZE);
128 pinfo->mipi.signature = TOSHIBA_720P_VIDEO_SIGNATURE;
129 break;
130 case SHARP_QHD_VIDEO_PANEL:
131 panelstruct->paneldata = &sharp_qhd_video_panel_data;
132 panelstruct->panelres = &sharp_qhd_video_panel_res;
133 panelstruct->color = &sharp_qhd_video_color;
134 panelstruct->videopanel = &sharp_qhd_video_video_panel;
135 panelstruct->commandpanel = &sharp_qhd_video_command_panel;
136 panelstruct->state = &sharp_qhd_video_state;
137 panelstruct->laneconfig = &sharp_qhd_video_lane_config;
138 panelstruct->paneltiminginfo
139 = &sharp_qhd_video_timing_info;
140 panelstruct->panelresetseq
141 = &sharp_qhd_video_panel_reset_seq;
142 panelstruct->backlightinfo = &sharp_qhd_video_backlight;
143 pinfo->mipi.panel_cmds
144 = sharp_qhd_video_on_command;
145 pinfo->mipi.num_of_panel_cmds
146 = SHARP_QHD_VIDEO_ON_COMMAND;
147 memcpy(phy_db->timing,
148 sharp_qhd_video_timings, TIMING_SIZE);
149 break;
150 case JDI_1080P_VIDEO_PANEL:
151 panelstruct->paneldata = &jdi_1080p_video_panel_data;
152 panelstruct->panelres = &jdi_1080p_video_panel_res;
153 panelstruct->color = &jdi_1080p_video_color;
154 panelstruct->videopanel = &jdi_1080p_video_video_panel;
155 panelstruct->commandpanel = &jdi_1080p_video_command_panel;
156 panelstruct->state = &jdi_1080p_video_state;
157 panelstruct->laneconfig = &jdi_1080p_video_lane_config;
158 panelstruct->paneltiminginfo
159 = &jdi_1080p_video_timing_info;
160 panelstruct->panelresetseq
161 = &jdi_1080p_video_panel_reset_seq;
162 panelstruct->backlightinfo = &jdi_1080p_video_backlight;
163 pinfo->mipi.panel_cmds
164 = jdi_1080p_video_on_command;
165 pinfo->mipi.num_of_panel_cmds
166 = JDI_1080P_VIDEO_ON_COMMAND;
167 memcpy(phy_db->timing,
168 jdi_1080p_video_timings, TIMING_SIZE);
169 pinfo->mipi.signature = JDI_1080P_VIDEO_SIGNATURE;
170 break;
171 case GENERIC_720P_CMD_PANEL:
172 panelstruct->paneldata = &generic_720p_cmd_panel_data;
173 panelstruct->panelres = &generic_720p_cmd_panel_res;
174 panelstruct->color = &generic_720p_cmd_color;
175 panelstruct->videopanel = &generic_720p_cmd_video_panel;
176 panelstruct->commandpanel = &generic_720p_cmd_command_panel;
177 panelstruct->state = &generic_720p_cmd_state;
178 panelstruct->laneconfig = &generic_720p_cmd_lane_config;
179 panelstruct->paneltiminginfo
180 = &generic_720p_cmd_timing_info;
181 panelstruct->panelresetseq
182 = &generic_720p_cmd_reset_seq;
183 panelstruct->backlightinfo = &generic_720p_cmd_backlight;
184 pinfo->mipi.panel_cmds
185 = generic_720p_cmd_on_command;
186 pinfo->mipi.num_of_panel_cmds
187 = GENERIC_720P_CMD_ON_COMMAND;
188 memcpy(phy_db->timing,
189 generic_720p_cmd_timings, TIMING_SIZE);
190 pinfo->mipi.signature = GENERIC_720P_CMD_SIGNATURE;
191 break;
192 case JDI_QHD_DUALDSI_VIDEO_PANEL:
193 panelstruct->paneldata = &jdi_qhd_dualdsi_video_panel_data;
194 panelstruct->panelres = &jdi_qhd_dualdsi_video_panel_res;
195 panelstruct->color = &jdi_qhd_dualdsi_video_color;
196 panelstruct->videopanel = &jdi_qhd_dualdsi_video_video_panel;
197 panelstruct->commandpanel = &jdi_qhd_dualdsi_video_command_panel;
198 panelstruct->state = &jdi_qhd_dualdsi_video_state;
199 panelstruct->laneconfig = &jdi_qhd_dualdsi_video_lane_config;
200 panelstruct->paneltiminginfo
201 = &jdi_qhd_dualdsi_video_timing_info;
202 panelstruct->panelresetseq
203 = &jdi_qhd_dualdsi_video_reset_seq;
204 panelstruct->backlightinfo = &jdi_qhd_dualdsi_video_backlight;
205 pinfo->mipi.panel_cmds
206 = jdi_qhd_dualdsi_video_on_command;
207 pinfo->mipi.num_of_panel_cmds
208 = JDI_QHD_DUALDSI_VIDEO_ON_COMMAND;
209 memcpy(phy_db->timing,
210 jdi_qhd_dualdsi_video_timings, TIMING_SIZE);
211 break;
212 case JDI_QHD_DUALDSI_CMD_PANEL:
213 panelstruct->paneldata = &jdi_qhd_dualdsi_cmd_panel_data;
214 panelstruct->panelres = &jdi_qhd_dualdsi_cmd_panel_res;
215 panelstruct->color = &jdi_qhd_dualdsi_cmd_color;
216 panelstruct->videopanel = &jdi_qhd_dualdsi_cmd_video_panel;
217 panelstruct->commandpanel = &jdi_qhd_dualdsi_cmd_command_panel;
218 panelstruct->state = &jdi_qhd_dualdsi_cmd_state;
219 panelstruct->laneconfig = &jdi_qhd_dualdsi_cmd_lane_config;
220 panelstruct->paneltiminginfo
221 = &jdi_qhd_dualdsi_cmd_timing_info;
222 panelstruct->panelresetseq
223 = &jdi_qhd_dualdsi_cmd_reset_seq;
224 panelstruct->backlightinfo = &jdi_qhd_dualdsi_cmd_backlight;
225 pinfo->mipi.panel_cmds
226 = jdi_qhd_dualdsi_cmd_on_command;
227 pinfo->mipi.num_of_panel_cmds
228 = JDI_QHD_DUALDSI_CMD_ON_COMMAND;
229 memcpy(phy_db->timing,
230 jdi_qhd_dualdsi_cmd_timings, TIMING_SIZE);
231 break;
liuyan8c8b2c02015-01-26 15:27:19 +0800232 case OTM1902B_1080P_CMD_PANEL:
233 panelstruct->paneldata = &otm1902b_1080p_cmd_panel_data;
234 panelstruct->panelres = &otm1902b_1080p_cmd_panel_res;
235 panelstruct->color = &otm1902b_1080p_cmd_color;
236 panelstruct->videopanel = &otm1902b_1080p_cmd_video_panel;
237 panelstruct->commandpanel = &otm1902b_1080p_cmd_command_panel;
238 panelstruct->state = &otm1902b_1080p_cmd_state;
239 panelstruct->laneconfig = &otm1902b_1080p_cmd_lane_config;
240 panelstruct->paneltiminginfo
241 = &otm1902b_1080p_cmd_timing_info;
242 panelstruct->panelresetseq
243 = &otm1902b_1080p_cmd_panel_reset_seq;
244 panelstruct->backlightinfo = &otm1902b_1080p_cmd_backlight;
245 pinfo->mipi.panel_cmds
246 = otm1902b_1080p_cmd_on_command;
247 pinfo->mipi.num_of_panel_cmds
248 = JDI_QHD_DUALDSI_CMD_ON_COMMAND;
249 memcpy(phy_db->timing,
250 otm1902b_1080p_cmd_timings, TIMING_SIZE);
251 break;
wangxl1ddbd092015-02-03 20:31:24 +0800252 case UNKNOWN_PANEL:
253 memset(panelstruct, 0, sizeof(struct panel_struct));
254 memset(pinfo->mipi.panel_cmds, 0, sizeof(struct mipi_dsi_cmd));
255 pinfo->mipi.num_of_panel_cmds = 0;
256 memset(phy_db->timing, 0, TIMING_SIZE);
257 pinfo->mipi.signature = 0;
258 break;
259 }
260}
261
262uint32_t oem_panel_max_auto_detect_panels()
263{
264 return target_panel_auto_detect_enabled() ?
265 DISPLAY_MAX_PANEL_DETECTION : 0;
266}
267
268static uint32_t auto_pan_loop = 0;
269
270bool oem_panel_select(const char *panel_name, struct panel_struct *panelstruct,
271 struct msm_panel_info *pinfo,
272 struct mdss_dsi_phy_ctrl *phy_db)
273{
274 uint32_t hw_id = board_hardware_id();
275 uint32_t target_id = board_target_id();
276 bool ret = true;
277 int32_t panel_override_id;
278
279 if (panel_name) {
280 panel_override_id = panel_name_to_id(supp_panels,
281 ARRAY_SIZE(supp_panels), panel_name);
282
283 if (panel_override_id < 0) {
284 dprintf(CRITICAL, "Not able to search the panel:%s\n",
285 panel_name + strspn(panel_name, " "));
286 } else if (panel_override_id < UNKNOWN_PANEL) {
287 /* panel override using fastboot oem command */
288 panel_id = panel_override_id;
289
290 dprintf(INFO, "OEM panel override:%s\n",
291 panel_name + strspn(panel_name, " "));
292 goto panel_init;
293 }
294 }
295
296 switch (hw_id) {
297 case HW_PLATFORM_MTP:
298 case HW_PLATFORM_FLUID:
299 case HW_PLATFORM_SURF:
300 switch (auto_pan_loop) {
301 case 0:
302 panel_id = JDI_1080P_VIDEO_PANEL;
303 break;
304 case 1:
305 panel_id = TOSHIBA_720P_VIDEO_PANEL;
306 break;
307 case 2:
308 panel_id = GENERIC_720P_CMD_PANEL;
309 break;
310 default:
311 panel_id = UNKNOWN_PANEL;
312 ret = false;
313 break;
314 }
315 auto_pan_loop++;
316 break;
317 case HW_PLATFORM_DRAGON:
318 panel_id = SHARP_QHD_VIDEO_PANEL;
319 break;
320 default:
321 dprintf(CRITICAL, "Display not enabled for %d HW type\n"
322 , hw_id);
323 return false;
324 }
liuyan8c8b2c02015-01-26 15:27:19 +0800325 panel_id = OTM1902B_1080P_CMD_PANEL;
wangxl1ddbd092015-02-03 20:31:24 +0800326panel_init:
327 init_panel_data(panelstruct, pinfo, phy_db);
328
329 return ret;
330}