blob: afbe07b1a1979a71c30636c9aa17f48ce64fee4d [file] [log] [blame]
Dhaval Patel019057a2014-08-12 13:52:25 -07001/* 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_sharp_wqxga_dualdsi_video.h"
44#include "include/panel_jdi_qhd_dualdsi_video.h"
45#include "include/panel_jdi_qhd_dualdsi_cmd.h"
Siddhartha Agrawalcddb0b82014-10-14 15:07:18 -070046#include "include/panel_jdi_4k_dualdsi_video.h"
Dhaval Patel019057a2014-08-12 13:52:25 -070047
48/*---------------------------------------------------------------------------*/
49/* static panel selection variable */
50/*---------------------------------------------------------------------------*/
51enum {
52SHARP_WQXGA_DUALDSI_VIDEO_PANEL,
53JDI_QHD_DUALDSI_VIDEO_PANEL,
54JDI_QHD_DUALDSI_CMD_PANEL,
Siddhartha Agrawalcddb0b82014-10-14 15:07:18 -070055JDI_4K_DUALDSI_VIDEO_PANEL,
Dhaval Patel019057a2014-08-12 13:52:25 -070056UNKNOWN_PANEL
57};
58
59/*
60 * The list of panels that are supported on this target.
61 * Any panel in this list can be selected using fastboot oem command.
62 */
63static struct panel_list supp_panels[] = {
64 {"sharp_wqxga_dualdsi_video", SHARP_WQXGA_DUALDSI_VIDEO_PANEL},
65 {"jdi_qhd_dualdsi_video", JDI_QHD_DUALDSI_VIDEO_PANEL},
66 {"jdi_qhd_dualdsi_cmd", JDI_QHD_DUALDSI_CMD_PANEL},
Siddhartha Agrawalcddb0b82014-10-14 15:07:18 -070067 {"jdi_4k_dualdsi_video", JDI_4K_DUALDSI_VIDEO_PANEL},
Dhaval Patel019057a2014-08-12 13:52:25 -070068};
69
70static uint32_t panel_id;
71
72int oem_panel_rotation()
73{
74 /* OEM can keep there panel specific on instructions in this
75 function */
76 return NO_ERROR;
77}
78
79int oem_panel_on()
80{
81 /* OEM can keep there panel specific on instructions in this
82 function */
83 if (panel_id == JDI_QHD_DUALDSI_CMD_PANEL) {
84 /* needs extra delay to avoid unexpected artifacts */
85 mdelay(JDI_QHD_DUALDSI_CMD_PANEL_ON_DELAY);
86
87 }
88 return NO_ERROR;
89}
90
91int oem_panel_off()
92{
93 /* OEM can keep there panel specific off instructions in this
94 function */
95 return NO_ERROR;
96}
97
98static bool init_panel_data(struct panel_struct *panelstruct,
99 struct msm_panel_info *pinfo,
100 struct mdss_dsi_phy_ctrl *phy_db)
101{
102 int pan_type;
103
104 phy_db->is_pll_20nm = 1;
105
106 switch (panel_id) {
107 case SHARP_WQXGA_DUALDSI_VIDEO_PANEL:
108 pan_type = PANEL_TYPE_DSI;
Kuogee Hsieh208736d2014-08-22 14:16:55 -0700109 pinfo->lcd_reg_en = 0;
Dhaval Patel019057a2014-08-12 13:52:25 -0700110 panelstruct->paneldata = &sharp_wqxga_dualdsi_video_panel_data;
111 panelstruct->paneldata->panel_operating_mode = 11;
112 panelstruct->paneldata->panel_with_enable_gpio = 0;
113 panelstruct->panelres = &sharp_wqxga_dualdsi_video_panel_res;
114 panelstruct->color = &sharp_wqxga_dualdsi_video_color;
115 panelstruct->videopanel = &sharp_wqxga_dualdsi_video_video_panel;
116 panelstruct->commandpanel = &sharp_wqxga_dualdsi_video_command_panel;
117 panelstruct->state = &sharp_wqxga_dualdsi_video_state;
118 panelstruct->laneconfig = &sharp_wqxga_dualdsi_video_lane_config;
119 panelstruct->paneltiminginfo
120 = &sharp_wqxga_dualdsi_video_timing_info;
121 panelstruct->panelresetseq
122 = &sharp_wqxga_dualdsi_video_reset_seq;
123 panelstruct->backlightinfo = &sharp_wqxga_dualdsi_video_backlight;
124 pinfo->mipi.panel_cmds
125 = sharp_wqxga_dualdsi_video_on_command;
126 pinfo->mipi.num_of_panel_cmds
127 = SHARP_WQXGA_DUALDSI_VIDEO_ON_COMMAND;
128 memcpy(phy_db->timing,
129 sharp_wqxga_dualdsi_video_timings, TIMING_SIZE);
130 break;
131 case JDI_QHD_DUALDSI_VIDEO_PANEL:
132 pan_type = PANEL_TYPE_DSI;
Kuogee Hsieh208736d2014-08-22 14:16:55 -0700133 pinfo->lcd_reg_en = 1;
Dhaval Patel019057a2014-08-12 13:52:25 -0700134 panelstruct->paneldata = &jdi_qhd_dualdsi_video_panel_data;
135 panelstruct->panelres = &jdi_qhd_dualdsi_video_panel_res;
136 panelstruct->color = &jdi_qhd_dualdsi_video_color;
137 panelstruct->videopanel = &jdi_qhd_dualdsi_video_video_panel;
138 panelstruct->commandpanel = &jdi_qhd_dualdsi_video_command_panel;
139 panelstruct->state = &jdi_qhd_dualdsi_video_state;
140 panelstruct->laneconfig = &jdi_qhd_dualdsi_video_lane_config;
141 panelstruct->paneltiminginfo
142 = &jdi_qhd_dualdsi_video_timing_info;
143 panelstruct->panelresetseq
144 = &jdi_qhd_dualdsi_video_reset_seq;
Dhaval Patel019057a2014-08-12 13:52:25 -0700145 panelstruct->backlightinfo = &jdi_qhd_dualdsi_video_backlight;
Dhaval Patel019057a2014-08-12 13:52:25 -0700146 pinfo->mipi.panel_cmds
147 = jdi_qhd_dualdsi_video_on_command;
148 pinfo->mipi.num_of_panel_cmds
149 = JDI_QHD_DUALDSI_VIDEO_ON_COMMAND;
150 memcpy(phy_db->timing,
151 jdi_qhd_dualdsi_video_timings, TIMING_SIZE);
152 break;
153 case JDI_QHD_DUALDSI_CMD_PANEL:
154 pan_type = PANEL_TYPE_DSI;
Kuogee Hsieh208736d2014-08-22 14:16:55 -0700155 pinfo->lcd_reg_en = 1;
Dhaval Patel019057a2014-08-12 13:52:25 -0700156 panelstruct->paneldata = &jdi_qhd_dualdsi_cmd_panel_data;
157 panelstruct->panelres = &jdi_qhd_dualdsi_cmd_panel_res;
158 panelstruct->color = &jdi_qhd_dualdsi_cmd_color;
159 panelstruct->videopanel = &jdi_qhd_dualdsi_cmd_video_panel;
160 panelstruct->commandpanel = &jdi_qhd_dualdsi_cmd_command_panel;
161 panelstruct->state = &jdi_qhd_dualdsi_cmd_state;
162 panelstruct->laneconfig = &jdi_qhd_dualdsi_cmd_lane_config;
163 panelstruct->paneltiminginfo
164 = &jdi_qhd_dualdsi_cmd_timing_info;
165 panelstruct->panelresetseq
166 = &jdi_qhd_dualdsi_cmd_reset_seq;
Dhaval Patel019057a2014-08-12 13:52:25 -0700167 panelstruct->backlightinfo = &jdi_qhd_dualdsi_cmd_backlight;
Dhaval Patel019057a2014-08-12 13:52:25 -0700168 pinfo->mipi.panel_cmds
169 = jdi_qhd_dualdsi_cmd_on_command;
170 pinfo->mipi.num_of_panel_cmds
171 = JDI_QHD_DUALDSI_CMD_ON_COMMAND;
172 memcpy(phy_db->timing,
173 jdi_qhd_dualdsi_cmd_timings, TIMING_SIZE);
174 break;
Siddhartha Agrawalcddb0b82014-10-14 15:07:18 -0700175 case JDI_4K_DUALDSI_VIDEO_PANEL:
176 pan_type = PANEL_TYPE_DSI;
177 pinfo->lcd_reg_en = 1;
178 pinfo->mipi.cmds_post_tg = 1;
179 panelstruct->paneldata = &jdi_4k_dualdsi_video_panel_data;
180 panelstruct->panelres = &jdi_4k_dualdsi_video_panel_res;
181 panelstruct->color = &jdi_4k_dualdsi_video_color;
182 panelstruct->videopanel = &jdi_4k_dualdsi_video_video_panel;
183 panelstruct->commandpanel = &jdi_4k_dualdsi_video_command_panel;
184 panelstruct->state = &jdi_4k_dualdsi_video_state;
185 panelstruct->laneconfig = &jdi_4k_dualdsi_video_lane_config;
186 panelstruct->paneltiminginfo
187 = &jdi_4k_dualdsi_video_timing_info;
188 panelstruct->panelresetseq
189 = &jdi_4k_dualdsi_video_reset_seq;
190 panelstruct->backlightinfo = &jdi_4k_dualdsi_video_backlight;
191 pinfo->mipi.panel_cmds
192 = jdi_4k_dualdsi_video_on_command;
193 pinfo->mipi.num_of_panel_cmds
194 = JDI_4K_DUALDSI_VIDEO_ON_COMMAND;
195 memcpy(phy_db->timing,
196 jdi_4k_dualdsi_video_timings, TIMING_SIZE);
197 memcpy(&panelstruct->fbcinfo, &jdi_4k_dualdsi_video_fbc,
198 sizeof(struct fb_compression));
199 break;
Dhaval Patel019057a2014-08-12 13:52:25 -0700200 default:
201 case UNKNOWN_PANEL:
202 pan_type = PANEL_TYPE_UNKNOWN;
203 break;
204 }
205 return pan_type;
206}
207
208bool oem_panel_select(const char *panel_name, struct panel_struct *panelstruct,
209 struct msm_panel_info *pinfo,
210 struct mdss_dsi_phy_ctrl *phy_db)
211{
212 uint32_t hw_id = board_hardware_id();
213 int32_t panel_override_id;
214
215 if (panel_name) {
216 panel_override_id = panel_name_to_id(supp_panels,
217 ARRAY_SIZE(supp_panels), panel_name);
218
219 if (panel_override_id < 0) {
220 dprintf(CRITICAL, "Not able to search the panel:%s\n",
221 panel_name + strspn(panel_name, " "));
222 } else if (panel_override_id < UNKNOWN_PANEL) {
223 /* panel override using fastboot oem command */
224 panel_id = panel_override_id;
225
226 dprintf(INFO, "OEM panel override:%s\n",
227 panel_name + strspn(panel_name, " "));
228 goto panel_init;
229 }
230 }
231
232 switch (hw_id) {
233 case HW_PLATFORM_MTP:
234 case HW_PLATFORM_FLUID:
235 case HW_PLATFORM_SURF:
236 panel_id = SHARP_WQXGA_DUALDSI_VIDEO_PANEL;
237 break;
Siddhartha Agrawalcddb0b82014-10-14 15:07:18 -0700238 case HW_PLATFORM_LIQUID:
239 panel_id = JDI_4K_DUALDSI_VIDEO_PANEL;
240 break;
Dhaval Patel019057a2014-08-12 13:52:25 -0700241 default:
242 dprintf(CRITICAL, "Display not enabled for %d HW type\n"
243 , hw_id);
244 return PANEL_TYPE_UNKNOWN;
245 }
246
247panel_init:
Siddhartha Agrawalcddb0b82014-10-14 15:07:18 -0700248 if (panel_id == JDI_4K_DUALDSI_VIDEO_PANEL)
249 phy_db->regulator_mode = DSI_PHY_REGULATOR_LDO_MODE;
Dhaval Patel019057a2014-08-12 13:52:25 -0700250 return init_panel_data(panelstruct, pinfo, phy_db);
251}