blob: d6f053717f1e77e11078454aa2efa375c679afeb [file] [log] [blame]
Shivaraj Shetty25b0aa02013-10-30 20:55:49 +05301/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -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_truly_wvga_cmd.h"
44#include "include/panel_truly_wvga_video.h"
shuoybca66752013-09-03 18:17:21 +080045#include "include/panel_hx8379a_wvga_video.h"
shuoyec420a72013-10-22 09:38:06 +080046#include "include/panel_hx8389b_qhd_video.h"
shuoybca66752013-09-03 18:17:21 +080047#include "include/panel_otm8018b_fwvga_video.h"
48#include "include/panel_nt35590_720p_video.h"
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -070049
Shivaraj Shetty25b0aa02013-10-30 20:55:49 +053050/* Number of dectectable panels */
51#define DISPLAY_MAX_PANEL_DETECTION 2
52
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -070053/*---------------------------------------------------------------------------*/
54/* static panel selection variable */
55/*---------------------------------------------------------------------------*/
56enum {
57TRULY_WVGA_CMD_PANEL,
58TRULY_WVGA_VIDEO_PANEL,
shuoybca66752013-09-03 18:17:21 +080059HX8379A_WVGA_VIDEO_PANEL,
shuoybca66752013-09-03 18:17:21 +080060NT35590_720P_VIDEO_PANEL,
shuoyec420a72013-10-22 09:38:06 +080061HX8389B_QHD_VIDEO_PANEL,
Shivaraj Shetty25b0aa02013-10-30 20:55:49 +053062OTM8018B_FWVGA_VIDEO_PANEL,
63UNKNOWN_PANEL
shuoyec420a72013-10-22 09:38:06 +080064};
65
66enum {
67QRD_DEF,
68QRD_SKUAA,
69QRD_SKUAB = 3,
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -070070};
71
72static uint32_t panel_id;
73
74int oem_panel_rotation()
75{
76 /* OEM can keep there panel spefic on instructions in this
77 function */
78 return NO_ERROR;
79}
80
81
82int oem_panel_on()
83{
84 /* OEM can keep there panel spefic on instructions in this
85 function */
86 return NO_ERROR;
87}
88
89int oem_panel_off()
90{
91 /* OEM can keep there panel spefic off instructions in this
92 function */
93 return NO_ERROR;
94}
95
96static bool init_panel_data(struct panel_struct *panelstruct,
97 struct msm_panel_info *pinfo,
98 struct mdss_dsi_phy_ctrl *phy_db)
99{
100 switch (panel_id) {
101 case TRULY_WVGA_CMD_PANEL:
102 panelstruct->paneldata = &truly_wvga_cmd_panel_data;
103 panelstruct->panelres = &truly_wvga_cmd_panel_res;
104 panelstruct->color = &truly_wvga_cmd_color;
105 panelstruct->videopanel = &truly_wvga_cmd_video_panel;
106 panelstruct->commandpanel = &truly_wvga_cmd_command_panel;
107 panelstruct->state = &truly_wvga_cmd_state;
108 panelstruct->laneconfig = &truly_wvga_cmd_lane_config;
109 panelstruct->paneltiminginfo
110 = &truly_wvga_cmd_timing_info;
shuoybca66752013-09-03 18:17:21 +0800111 panelstruct->panelresetseq
112 = &truly_wvga_cmd_reset_seq;
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -0700113 panelstruct->backlightinfo = &truly_wvga_cmd_backlight;
114 pinfo->mipi.panel_cmds
115 = truly_wvga_cmd_on_command;
116 pinfo->mipi.num_of_panel_cmds
117 = TRULY_WVGA_CMD_ON_COMMAND;
118 memcpy(phy_db->timing,
119 truly_wvga_cmd_timings, TIMING_SIZE);
120 break;
121 case TRULY_WVGA_VIDEO_PANEL:
122 panelstruct->paneldata = &truly_wvga_video_panel_data;
123 panelstruct->panelres = &truly_wvga_video_panel_res;
124 panelstruct->color = &truly_wvga_video_color;
125 panelstruct->videopanel = &truly_wvga_video_video_panel;
126 panelstruct->commandpanel = &truly_wvga_video_command_panel;
127 panelstruct->state = &truly_wvga_video_state;
128 panelstruct->laneconfig = &truly_wvga_video_lane_config;
129 panelstruct->paneltiminginfo
130 = &truly_wvga_video_timing_info;
shuoybca66752013-09-03 18:17:21 +0800131 panelstruct->panelresetseq
132 = &truly_wvga_video_reset_seq;
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -0700133 panelstruct->backlightinfo = &truly_wvga_video_backlight;
134 pinfo->mipi.panel_cmds
135 = truly_wvga_video_on_command;
136 pinfo->mipi.num_of_panel_cmds
137 = TRULY_WVGA_VIDEO_ON_COMMAND;
138 memcpy(phy_db->timing,
139 truly_wvga_video_timings, TIMING_SIZE);
140 break;
shuoybca66752013-09-03 18:17:21 +0800141 case HX8379A_WVGA_VIDEO_PANEL:
142 panelstruct->paneldata = &hx8379a_wvga_video_panel_data;
143 panelstruct->panelres = &hx8379a_wvga_video_panel_res;
144 panelstruct->color = &hx8379a_wvga_video_color;
145 panelstruct->videopanel = &hx8379a_wvga_video_video_panel;
146 panelstruct->commandpanel = &hx8379a_wvga_video_command_panel;
147 panelstruct->state = &hx8379a_wvga_video_state;
148 panelstruct->laneconfig = &hx8379a_wvga_video_lane_config;
149 panelstruct->paneltiminginfo
150 = &hx8379a_wvga_video_timing_info;
151 panelstruct->panelresetseq
152 = &hx8379a_wvga_video_reset_seq;
153 panelstruct->backlightinfo = &hx8379a_wvga_video_backlight;
154 pinfo->mipi.panel_cmds
155 = hx8379a_wvga_video_on_command;
156 pinfo->mipi.num_of_panel_cmds
157 = HX8379A_WVGA_VIDEO_ON_COMMAND;
158 memcpy(phy_db->timing,
159 hx8379a_wvga_video_timings, TIMING_SIZE);
160 break;
161 case OTM8018B_FWVGA_VIDEO_PANEL:
162 panelstruct->paneldata = &otm8018b_fwvga_video_panel_data;
163 panelstruct->panelres = &otm8018b_fwvga_video_panel_res;
164 panelstruct->color = &otm8018b_fwvga_video_color;
165 panelstruct->videopanel = &otm8018b_fwvga_video_video_panel;
166 panelstruct->commandpanel = &otm8018b_fwvga_video_command_panel;
167 panelstruct->state = &otm8018b_fwvga_video_state;
168 panelstruct->laneconfig = &otm8018b_fwvga_video_lane_config;
169 panelstruct->paneltiminginfo
170 = &otm8018b_fwvga_video_timing_info;
171 panelstruct->panelresetseq
172 = &otm8018b_fwvga_video_reset_seq;
173 panelstruct->backlightinfo = &otm8018b_fwvga_video_backlight;
174 pinfo->mipi.panel_cmds
175 = otm8018b_fwvga_video_on_command;
176 pinfo->mipi.num_of_panel_cmds
177 = OTM8018B_FWVGA_VIDEO_ON_COMMAND;
178 memcpy(phy_db->timing,
179 otm8018b_fwvga_video_timings, TIMING_SIZE);
180 break;
181 case NT35590_720P_VIDEO_PANEL:
182 panelstruct->paneldata = &nt35590_720p_video_panel_data;
183 panelstruct->panelres = &nt35590_720p_video_panel_res;
184 panelstruct->color = &nt35590_720p_video_color;
185 panelstruct->videopanel = &nt35590_720p_video_video_panel;
186 panelstruct->commandpanel = &nt35590_720p_video_command_panel;
187 panelstruct->state = &nt35590_720p_video_state;
188 panelstruct->laneconfig = &nt35590_720p_video_lane_config;
189 panelstruct->paneltiminginfo
190 = &nt35590_720p_video_timing_info;
191 panelstruct->panelresetseq
192 = &nt35590_720p_video_panel_reset_seq;
193 panelstruct->backlightinfo = &nt35590_720p_video_backlight;
194 pinfo->mipi.panel_cmds
195 = nt35590_720p_video_on_command;
196 pinfo->mipi.num_of_panel_cmds
197 = NT35590_720P_VIDEO_ON_COMMAND;
198 memcpy(phy_db->timing,
199 nt35590_720p_video_timings, TIMING_SIZE);
200 break;
shuoyec420a72013-10-22 09:38:06 +0800201 case HX8389B_QHD_VIDEO_PANEL:
202 panelstruct->paneldata = &hx8389b_qhd_video_panel_data;
203 panelstruct->panelres = &hx8389b_qhd_video_panel_res;
204 panelstruct->color = &hx8389b_qhd_video_color;
205 panelstruct->videopanel = &hx8389b_qhd_video_video_panel;
206 panelstruct->commandpanel = &hx8389b_qhd_video_command_panel;
207 panelstruct->state = &hx8389b_qhd_video_state;
208 panelstruct->laneconfig = &hx8389b_qhd_video_lane_config;
209 panelstruct->paneltiminginfo
210 = &hx8389b_qhd_video_timing_info;
211 panelstruct->panelresetseq
212 = &hx8389b_qhd_video_reset_seq;
213 panelstruct->backlightinfo = &hx8389b_qhd_video_backlight;
214 pinfo->mipi.panel_cmds
215 = hx8389b_qhd_video_on_command;
216 pinfo->mipi.num_of_panel_cmds
217 = HX8389B_QHD_VIDEO_ON_COMMAND;
218 memcpy(phy_db->timing,
219 hx8389b_qhd_video_timings, TIMING_SIZE);
220 break;
Shivaraj Shetty25b0aa02013-10-30 20:55:49 +0530221 case UNKNOWN_PANEL:
222 memset(panelstruct, 0, sizeof(struct panel_struct));
223 memset(pinfo->mipi.panel_cmds, 0, sizeof(struct mipi_dsi_cmd));
224 pinfo->mipi.num_of_panel_cmds = 0;
225 memset(phy_db->timing, 0, TIMING_SIZE);
226 pinfo->mipi.signature = 0;
227 dprintf(CRITICAL, "Unknown Panel");
228 return false;
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -0700229 default:
230 dprintf(CRITICAL, "Panel ID not detected %d\n", panel_id);
231 return false;
232 }
233 return true;
234}
235
Shivaraj Shetty25b0aa02013-10-30 20:55:49 +0530236uint32_t oem_panel_max_auto_detect_panels()
237{
238 return target_panel_auto_detect_enabled() ?
239 DISPLAY_MAX_PANEL_DETECTION : 0;
240}
241
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -0700242bool oem_panel_select(struct panel_struct *panelstruct,
243 struct msm_panel_info *pinfo,
244 struct mdss_dsi_phy_ctrl *phy_db)
245{
246 uint32_t hw_id = board_hardware_id();
shuoybca66752013-09-03 18:17:21 +0800247 uint32_t platform_subtype = board_hardware_subtype();
shuoyec420a72013-10-22 09:38:06 +0800248 uint32_t target_id = board_target_id();
249
250 target_id = (target_id >> 16) & 0xFF;
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -0700251
252 switch (hw_id) {
253 case HW_PLATFORM_QRD:
shuoyec420a72013-10-22 09:38:06 +0800254 switch (platform_subtype) {
255 case QRD_DEF:
256 case QRD_SKUAA:
257 panel_id = HX8379A_WVGA_VIDEO_PANEL;
258 break;
259 case QRD_SKUAB:
260 if (target_id == 0x1) // 1st HW version
261 panel_id = OTM8018B_FWVGA_VIDEO_PANEL;
262 else if (target_id == 0x2) //2nd HW version
263 panel_id = HX8389B_QHD_VIDEO_PANEL;
264 else
265 dprintf(CRITICAL, "SKUAB Display not enabled for %d type\n",
266 target_id);
267 break;
268 default:
269 dprintf(CRITICAL, "QRD Display not enabled for %d type\n",
270 platform_subtype);
271 return false;
272 }
shuoybca66752013-09-03 18:17:21 +0800273 break;
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -0700274 case HW_PLATFORM_MTP:
shuoybca66752013-09-03 18:17:21 +0800275 if (0 == platform_subtype)
276 panel_id = TRULY_WVGA_VIDEO_PANEL;
277 else
278 panel_id = NT35590_720P_VIDEO_PANEL;
279 break;
280
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -0700281 case HW_PLATFORM_SURF:
282 panel_id = TRULY_WVGA_VIDEO_PANEL;
283 break;
284 default:
285 dprintf(CRITICAL, "Display not enabled for %d HW type\n", hw_id);
286 return false;
287 }
288
289 return init_panel_data(panelstruct, pinfo, phy_db);
290}