blob: 45bcdeff52c5062a2e31cd52ed0d145f4f7abd80 [file] [log] [blame]
Kuogee Hsieh54b452b2013-12-18 14:58:41 -08001/* Copyright (c) 2013-2014, 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>
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"
Casey Piperce3a4b12013-08-28 14:31:46 -070045#include "include/panel_jdi_1080p_video.h"
Casey Piper78a9ad52013-11-14 13:27:48 -080046#include "include/panel_generic_720p_cmd.h"
Kuogee Hsieh54b452b2013-12-18 14:58:41 -080047#include "include/panel_jdi_qhd_dualdsi_video.h"
48#include "include/panel_jdi_qhd_dualdsi_cmd.h"
Casey Piper98e94f12013-09-09 20:42:15 -070049
Casey Piper78a9ad52013-11-14 13:27:48 -080050#define DISPLAY_MAX_PANEL_DETECTION 3
Casey Piper74f8e5c2013-09-05 15:00:30 -070051
Casey Piper98e94f12013-09-09 20:42:15 -070052/*---------------------------------------------------------------------------*/
53/* static panel selection variable */
54/*---------------------------------------------------------------------------*/
55enum {
Casey Piper74f8e5c2013-09-05 15:00:30 -070056JDI_1080P_VIDEO_PANEL,
Casey Piper98e94f12013-09-09 20:42:15 -070057TOSHIBA_720P_VIDEO_PANEL,
Casey Piperce3a4b12013-08-28 14:31:46 -070058SHARP_QHD_VIDEO_PANEL,
Casey Piper78a9ad52013-11-14 13:27:48 -080059GENERIC_720P_CMD_PANEL,
Kuogee Hsieh54b452b2013-12-18 14:58:41 -080060JDI_QHD_DUALDSI_VIDEO_PANEL,
61JDI_QHD_DUALDSI_CMD_PANEL,
Casey Piper74f8e5c2013-09-05 15:00:30 -070062UNKNOWN_PANEL
Casey Piper98e94f12013-09-09 20:42:15 -070063};
64
Dhaval Patel61819232014-05-23 12:32:39 -070065/*
66 * The list of panels that are supported on this target.
67 * Any panel in this list can be selected using fastboot oem command.
68 */
69static struct panel_list supp_panels[] = {
70 {"jdi_1080p_video", JDI_1080P_VIDEO_PANEL},
71 {"toshiba_720p_video", TOSHIBA_720P_VIDEO_PANEL},
72 {"sharp_qhd_video", SHARP_QHD_VIDEO_PANEL},
73 {"generic_720p_cmd", GENERIC_720P_CMD_PANEL},
74 {"jdi_qhd_dualdsi_video", JDI_QHD_DUALDSI_VIDEO_PANEL},
75 {"jdi_qhd_dualdsi_cmd", JDI_QHD_DUALDSI_CMD_PANEL},
76};
77
Casey Piper98e94f12013-09-09 20:42:15 -070078static uint32_t panel_id;
79
80int oem_panel_rotation()
81{
82 /* OEM can keep there panel spefic on instructions in this
83 function */
84 return NO_ERROR;
85}
86
87
88int oem_panel_on()
89{
90 /* OEM can keep there panel spefic on instructions in this
91 function */
92 return NO_ERROR;
93}
94
95int oem_panel_off()
96{
97 /* OEM can keep there panel spefic off instructions in this
98 function */
99 return NO_ERROR;
100}
101
Kuogee Hsieh80b8a6c2014-06-09 17:25:38 -0700102static int init_panel_data(struct panel_struct *panelstruct,
Casey Piper98e94f12013-09-09 20:42:15 -0700103 struct msm_panel_info *pinfo,
104 struct mdss_dsi_phy_ctrl *phy_db)
105{
Kuogee Hsieh80b8a6c2014-06-09 17:25:38 -0700106 int pan_type = PANEL_TYPE_DSI;
107
Casey Piper98e94f12013-09-09 20:42:15 -0700108 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);
Casey Piper74f8e5c2013-09-05 15:00:30 -0700128 pinfo->mipi.signature = TOSHIBA_720P_VIDEO_SIGNATURE;
Casey Piper98e94f12013-09-09 20:42:15 -0700129 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;
Casey Piperce3a4b12013-08-28 14:31:46 -0700150 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);
Casey Piper74f8e5c2013-09-05 15:00:30 -0700169 pinfo->mipi.signature = JDI_1080P_VIDEO_SIGNATURE;
170 break;
Casey Piper78a9ad52013-11-14 13:27:48 -0800171 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;
Kuogee Hsieh54b452b2013-12-18 14:58:41 -0800192 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;
Casey Piper74f8e5c2013-09-05 15:00:30 -0700232 case UNKNOWN_PANEL:
233 memset(panelstruct, 0, sizeof(struct panel_struct));
234 memset(pinfo->mipi.panel_cmds, 0, sizeof(struct mipi_dsi_cmd));
235 pinfo->mipi.num_of_panel_cmds = 0;
236 memset(phy_db->timing, 0, TIMING_SIZE);
237 pinfo->mipi.signature = 0;
Kuogee Hsieh80b8a6c2014-06-09 17:25:38 -0700238 pan_type = PANEL_TYPE_UNKNOWN;
Casey Piperce3a4b12013-08-28 14:31:46 -0700239 break;
Casey Piper98e94f12013-09-09 20:42:15 -0700240 }
Kuogee Hsieh80b8a6c2014-06-09 17:25:38 -0700241
242 return pan_type;
Casey Piper98e94f12013-09-09 20:42:15 -0700243}
244
Casey Piper74f8e5c2013-09-05 15:00:30 -0700245uint32_t oem_panel_max_auto_detect_panels()
246{
247 return target_panel_auto_detect_enabled() ?
248 DISPLAY_MAX_PANEL_DETECTION : 0;
249}
250
251static uint32_t auto_pan_loop = 0;
252
Kuogee Hsieh80b8a6c2014-06-09 17:25:38 -0700253int oem_panel_select(const char *panel_name, struct panel_struct *panelstruct,
Casey Piper98e94f12013-09-09 20:42:15 -0700254 struct msm_panel_info *pinfo,
255 struct mdss_dsi_phy_ctrl *phy_db)
256{
257 uint32_t hw_id = board_hardware_id();
258 uint32_t target_id = board_target_id();
Dhaval Patel61819232014-05-23 12:32:39 -0700259 int32_t panel_override_id;
260
261 if (panel_name) {
262 panel_override_id = panel_name_to_id(supp_panels,
263 ARRAY_SIZE(supp_panels), panel_name);
264
265 if (panel_override_id < 0) {
266 dprintf(CRITICAL, "Not able to search the panel:%s\n",
267 panel_name + strspn(panel_name, " "));
268 } else if (panel_override_id < UNKNOWN_PANEL) {
269 /* panel override using fastboot oem command */
270 panel_id = panel_override_id;
271
272 dprintf(INFO, "OEM panel override:%s\n",
273 panel_name + strspn(panel_name, " "));
274 goto panel_init;
275 }
276 }
Casey Piper98e94f12013-09-09 20:42:15 -0700277
278 switch (hw_id) {
279 case HW_PLATFORM_MTP:
280 case HW_PLATFORM_FLUID:
281 case HW_PLATFORM_SURF:
Casey Piper74f8e5c2013-09-05 15:00:30 -0700282 switch (auto_pan_loop) {
283 case 0:
284 panel_id = JDI_1080P_VIDEO_PANEL;
285 break;
286 case 1:
287 panel_id = TOSHIBA_720P_VIDEO_PANEL;
288 break;
Casey Piper78a9ad52013-11-14 13:27:48 -0800289 case 2:
290 panel_id = GENERIC_720P_CMD_PANEL;
291 break;
Casey Piper74f8e5c2013-09-05 15:00:30 -0700292 default:
293 panel_id = UNKNOWN_PANEL;
Casey Piper74f8e5c2013-09-05 15:00:30 -0700294 break;
295 }
296 auto_pan_loop++;
Casey Piper98e94f12013-09-09 20:42:15 -0700297 break;
298 case HW_PLATFORM_DRAGON:
299 panel_id = SHARP_QHD_VIDEO_PANEL;
300 break;
301 default:
302 dprintf(CRITICAL, "Display not enabled for %d HW type\n"
303 , hw_id);
Kuogee Hsieh80b8a6c2014-06-09 17:25:38 -0700304 return PANEL_TYPE_UNKNOWN;
Casey Piper98e94f12013-09-09 20:42:15 -0700305 }
306
Dhaval Patel61819232014-05-23 12:32:39 -0700307panel_init:
Kuogee Hsieh80b8a6c2014-06-09 17:25:38 -0700308 return init_panel_data(panelstruct, pinfo, phy_db);
Casey Piper98e94f12013-09-09 20:42:15 -0700309}