blob: 72f58ecb89b5330ff0931cd13d637094d2ce9209 [file] [log] [blame]
Padmanabhan Komandurubccbcdc2015-06-30 16:19:24 +05301/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
Dhaval Patelf9986272013-10-18 19:06:05 -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_jdi_1080p_video.h"
Dhaval Pateld0a09e22013-10-25 10:15:21 -070044#include "include/panel_jdi_qhd_dualdsi_video.h"
Dhaval Patelaee7e542014-01-06 16:08:16 -080045#include "include/panel_jdi_qhd_dualdsi_cmd.h"
Dhaval Patelf9986272013-10-18 19:06:05 -070046
47/*---------------------------------------------------------------------------*/
48/* static panel selection variable */
49/*---------------------------------------------------------------------------*/
50enum {
51JDI_1080P_VIDEO_PANEL,
Dhaval Pateld0a09e22013-10-25 10:15:21 -070052JDI_QHD_DUALDSI_VIDEO_PANEL,
Dhaval Patelaee7e542014-01-06 16:08:16 -080053JDI_QHD_DUALDSI_CMD_PANEL,
Kuogee Hsieh80b8a6c2014-06-09 17:25:38 -070054EDP_OEM_PANEL,
55UNKNOWN_PANEL,
Dhaval Patelf9986272013-10-18 19:06:05 -070056};
57
Dhaval Patelbae49882014-02-18 17:16:53 -080058/*
59 * The list of panels that are supported on this target.
60 * Any panel in this list can be selected using fastboot oem command.
61 */
62static struct panel_list supp_panels[] = {
63 {"jdi_1080p_video", JDI_1080P_VIDEO_PANEL},
64 {"jdi_qhd_dualdsi_video", JDI_QHD_DUALDSI_VIDEO_PANEL},
65 {"jdi_qhd_dualdsi_cmd", JDI_QHD_DUALDSI_CMD_PANEL},
Kuogee Hsieh80b8a6c2014-06-09 17:25:38 -070066 {"edp", EDP_OEM_PANEL},
Dhaval Patelbae49882014-02-18 17:16:53 -080067};
68
Dhaval Patelf9986272013-10-18 19:06:05 -070069static uint32_t panel_id;
70
71int oem_panel_rotation()
72{
Dhaval Patelfc7c6092014-03-31 17:15:24 -070073 /* OEM can keep there panel specific on instructions in this
Dhaval Patelf9986272013-10-18 19:06:05 -070074 function */
75 return NO_ERROR;
76}
77
Dhaval Patelf9986272013-10-18 19:06:05 -070078int oem_panel_on()
79{
Dhaval Patelfc7c6092014-03-31 17:15:24 -070080 /* OEM can keep there panel specific on instructions in this
Dhaval Patelf9986272013-10-18 19:06:05 -070081 function */
Dhaval Patelfc7c6092014-03-31 17:15:24 -070082 if (panel_id == JDI_QHD_DUALDSI_CMD_PANEL) {
83 /* needs extra delay to avoid unexpected artifacts */
84 mdelay(JDI_QHD_DUALDSI_CMD_PANEL_ON_DELAY);
85 }
Dhaval Patelf9986272013-10-18 19:06:05 -070086 return NO_ERROR;
87}
88
89int oem_panel_off()
90{
Dhaval Patelfc7c6092014-03-31 17:15:24 -070091 /* OEM can keep there panel specific off instructions in this
Dhaval Patelf9986272013-10-18 19:06:05 -070092 function */
93 return NO_ERROR;
94}
95
Kuogee Hsieh80b8a6c2014-06-09 17:25:38 -070096static int init_panel_data(struct panel_struct *panelstruct,
Dhaval Patelf9986272013-10-18 19:06:05 -070097 struct msm_panel_info *pinfo,
98 struct mdss_dsi_phy_ctrl *phy_db)
99{
Kuogee Hsieh80b8a6c2014-06-09 17:25:38 -0700100 int pan_type;
Dhaval Patelf9986272013-10-18 19:06:05 -0700101
102 switch (panel_id) {
103 case JDI_1080P_VIDEO_PANEL:
Kuogee Hsieh80b8a6c2014-06-09 17:25:38 -0700104 pan_type = PANEL_TYPE_DSI;
Dhaval Patelf9986272013-10-18 19:06:05 -0700105 panelstruct->paneldata = &jdi_1080p_video_panel_data;
106 panelstruct->panelres = &jdi_1080p_video_panel_res;
107 panelstruct->color = &jdi_1080p_video_color;
108 panelstruct->videopanel = &jdi_1080p_video_video_panel;
109 panelstruct->commandpanel = &jdi_1080p_video_command_panel;
110 panelstruct->state = &jdi_1080p_video_state;
111 panelstruct->laneconfig = &jdi_1080p_video_lane_config;
112 panelstruct->paneltiminginfo
113 = &jdi_1080p_video_timing_info;
114 panelstruct->panelresetseq
115 = &jdi_1080p_video_panel_reset_seq;
116 panelstruct->backlightinfo = &jdi_1080p_video_backlight;
Padmanabhan Komandurub3d31842014-11-04 15:47:53 +0530117 pinfo->mipi.panel_on_cmds
Dhaval Patelf9986272013-10-18 19:06:05 -0700118 = jdi_1080p_video_on_command;
Padmanabhan Komandurub3d31842014-11-04 15:47:53 +0530119 pinfo->mipi.num_of_panel_on_cmds
Dhaval Patelf9986272013-10-18 19:06:05 -0700120 = JDI_1080P_VIDEO_ON_COMMAND;
Padmanabhan Komandurub3d31842014-11-04 15:47:53 +0530121 pinfo->mipi.panel_off_cmds
122 = jdi_1080p_video_off_command;
123 pinfo->mipi.num_of_panel_off_cmds
124 = JDI_1080P_VIDEO_OFF_COMMAND;
Dhaval Patelf9986272013-10-18 19:06:05 -0700125 memcpy(phy_db->timing,
126 jdi_1080p_video_timings, TIMING_SIZE);
127 break;
Dhaval Pateld0a09e22013-10-25 10:15:21 -0700128 case JDI_QHD_DUALDSI_VIDEO_PANEL:
Kuogee Hsieh80b8a6c2014-06-09 17:25:38 -0700129 pan_type = PANEL_TYPE_DSI;
Dhaval Pateld0a09e22013-10-25 10:15:21 -0700130 panelstruct->paneldata = &jdi_qhd_dualdsi_video_panel_data;
131 panelstruct->panelres = &jdi_qhd_dualdsi_video_panel_res;
132 panelstruct->color = &jdi_qhd_dualdsi_video_color;
133 panelstruct->videopanel = &jdi_qhd_dualdsi_video_video_panel;
134 panelstruct->commandpanel = &jdi_qhd_dualdsi_video_command_panel;
135 panelstruct->state = &jdi_qhd_dualdsi_video_state;
136 panelstruct->laneconfig = &jdi_qhd_dualdsi_video_lane_config;
137 panelstruct->paneltiminginfo
138 = &jdi_qhd_dualdsi_video_timing_info;
139 panelstruct->panelresetseq
140 = &jdi_qhd_dualdsi_video_reset_seq;
141 panelstruct->backlightinfo = &jdi_qhd_dualdsi_video_backlight;
Padmanabhan Komandurub3d31842014-11-04 15:47:53 +0530142 pinfo->mipi.panel_on_cmds
Dhaval Pateld0a09e22013-10-25 10:15:21 -0700143 = jdi_qhd_dualdsi_video_on_command;
Padmanabhan Komandurub3d31842014-11-04 15:47:53 +0530144 pinfo->mipi.num_of_panel_on_cmds
Dhaval Pateld0a09e22013-10-25 10:15:21 -0700145 = JDI_QHD_DUALDSI_VIDEO_ON_COMMAND;
Padmanabhan Komandurub3d31842014-11-04 15:47:53 +0530146 pinfo->mipi.panel_off_cmds
147 = jdi_qhd_dualdsi_video_off_command;
148 pinfo->mipi.num_of_panel_off_cmds
149 = JDI_QHD_DUALDSI_VIDEO_OFF_COMMAND;
Dhaval Pateld0a09e22013-10-25 10:15:21 -0700150 memcpy(phy_db->timing,
151 jdi_qhd_dualdsi_video_timings, TIMING_SIZE);
152 break;
Dhaval Patelaee7e542014-01-06 16:08:16 -0800153 case JDI_QHD_DUALDSI_CMD_PANEL:
Kuogee Hsieh80b8a6c2014-06-09 17:25:38 -0700154 pan_type = PANEL_TYPE_DSI;
Dhaval Patelaee7e542014-01-06 16:08:16 -0800155 panelstruct->paneldata = &jdi_qhd_dualdsi_cmd_panel_data;
156 panelstruct->panelres = &jdi_qhd_dualdsi_cmd_panel_res;
157 panelstruct->color = &jdi_qhd_dualdsi_cmd_color;
158 panelstruct->videopanel = &jdi_qhd_dualdsi_cmd_video_panel;
159 panelstruct->commandpanel = &jdi_qhd_dualdsi_cmd_command_panel;
160 panelstruct->state = &jdi_qhd_dualdsi_cmd_state;
161 panelstruct->laneconfig = &jdi_qhd_dualdsi_cmd_lane_config;
162 panelstruct->paneltiminginfo
163 = &jdi_qhd_dualdsi_cmd_timing_info;
164 panelstruct->panelresetseq
165 = &jdi_qhd_dualdsi_cmd_reset_seq;
166 panelstruct->backlightinfo = &jdi_qhd_dualdsi_cmd_backlight;
Padmanabhan Komandurub3d31842014-11-04 15:47:53 +0530167 pinfo->mipi.panel_on_cmds
Dhaval Patelaee7e542014-01-06 16:08:16 -0800168 = jdi_qhd_dualdsi_cmd_on_command;
Padmanabhan Komandurub3d31842014-11-04 15:47:53 +0530169 pinfo->mipi.num_of_panel_on_cmds
Dhaval Patelaee7e542014-01-06 16:08:16 -0800170 = JDI_QHD_DUALDSI_CMD_ON_COMMAND;
Padmanabhan Komandurub3d31842014-11-04 15:47:53 +0530171 pinfo->mipi.panel_off_cmds
172 = jdi_qhd_dualdsi_cmd_off_command;
173 pinfo->mipi.num_of_panel_off_cmds
174 = JDI_QHD_DUALDSI_CMD_OFF_COMMAND;
Dhaval Patelaee7e542014-01-06 16:08:16 -0800175 memcpy(phy_db->timing,
176 jdi_qhd_dualdsi_cmd_timings, TIMING_SIZE);
177 break;
Kuogee Hsieh80b8a6c2014-06-09 17:25:38 -0700178 case EDP_OEM_PANEL:
179 pan_type = PANEL_TYPE_EDP;
180 /* edp panel init base on edid */
181 break;
Dhaval Patelf9986272013-10-18 19:06:05 -0700182 default:
183 case UNKNOWN_PANEL:
Kuogee Hsieh80b8a6c2014-06-09 17:25:38 -0700184 pan_type = PANEL_TYPE_UNKNOWN;
Dhaval Patelf9986272013-10-18 19:06:05 -0700185 break;
186 }
Kuogee Hsieh80b8a6c2014-06-09 17:25:38 -0700187
188 return pan_type;
Dhaval Patelf9986272013-10-18 19:06:05 -0700189}
190
Kuogee Hsieh80b8a6c2014-06-09 17:25:38 -0700191int oem_panel_select(const char *panel_name, struct panel_struct *panelstruct,
Dhaval Patelf9986272013-10-18 19:06:05 -0700192 struct msm_panel_info *pinfo,
193 struct mdss_dsi_phy_ctrl *phy_db)
194{
195 uint32_t hw_id = board_hardware_id();
Dhaval Patelbae49882014-02-18 17:16:53 -0800196 int32_t panel_override_id;
197
198 if (panel_name) {
199 panel_override_id = panel_name_to_id(supp_panels,
200 ARRAY_SIZE(supp_panels), panel_name);
201
202 if (panel_override_id < 0) {
203 dprintf(CRITICAL, "Not able to search the panel:%s\n",
Padmanabhan Komandurubccbcdc2015-06-30 16:19:24 +0530204 panel_name);
Dhaval Patelbae49882014-02-18 17:16:53 -0800205 } else if (panel_override_id < UNKNOWN_PANEL) {
206 /* panel override using fastboot oem command */
207 panel_id = panel_override_id;
208
209 dprintf(INFO, "OEM panel override:%s\n",
Padmanabhan Komandurubccbcdc2015-06-30 16:19:24 +0530210 panel_name);
Dhaval Patelbae49882014-02-18 17:16:53 -0800211 goto panel_init;
212 }
213 }
Dhaval Patelf9986272013-10-18 19:06:05 -0700214
215 switch (hw_id) {
216 case HW_PLATFORM_MTP:
217 case HW_PLATFORM_FLUID:
218 case HW_PLATFORM_SURF:
219 panel_id = JDI_1080P_VIDEO_PANEL;
220 break;
Dhaval Pateld0a09e22013-10-25 10:15:21 -0700221 case HW_PLATFORM_LIQUID:
222 panel_id = JDI_QHD_DUALDSI_VIDEO_PANEL;
223 break;
Dhaval Patelf9986272013-10-18 19:06:05 -0700224 default:
225 dprintf(CRITICAL, "Display not enabled for %d HW type\n"
226 , hw_id);
Kuogee Hsieh80b8a6c2014-06-09 17:25:38 -0700227 return PANEL_TYPE_UNKNOWN;
Dhaval Patelf9986272013-10-18 19:06:05 -0700228 }
229
Dhaval Patelbae49882014-02-18 17:16:53 -0800230panel_init:
Dhaval Patelf9986272013-10-18 19:06:05 -0700231 return init_panel_data(panelstruct, pinfo, phy_db);
232}