blob: c9b87c2c265bc820d3b9421e18fae636d529a5fa [file] [log] [blame]
Casey Piper98e94f12013-09-09 20:42:15 -07001/* Copyright (c) 2013, 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"
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"
Casey Piper98e94f12013-09-09 20:42:15 -070047
Casey Piper78a9ad52013-11-14 13:27:48 -080048#define DISPLAY_MAX_PANEL_DETECTION 3
Casey Piper74f8e5c2013-09-05 15:00:30 -070049
Casey Piper98e94f12013-09-09 20:42:15 -070050/*---------------------------------------------------------------------------*/
51/* static panel selection variable */
52/*---------------------------------------------------------------------------*/
53enum {
Casey Piper74f8e5c2013-09-05 15:00:30 -070054JDI_1080P_VIDEO_PANEL,
Casey Piper98e94f12013-09-09 20:42:15 -070055TOSHIBA_720P_VIDEO_PANEL,
Casey Piperce3a4b12013-08-28 14:31:46 -070056SHARP_QHD_VIDEO_PANEL,
Casey Piper78a9ad52013-11-14 13:27:48 -080057GENERIC_720P_CMD_PANEL,
Casey Piper74f8e5c2013-09-05 15:00:30 -070058UNKNOWN_PANEL
Casey Piper98e94f12013-09-09 20:42:15 -070059};
60
61static uint32_t panel_id;
62
63int oem_panel_rotation()
64{
65 /* OEM can keep there panel spefic on instructions in this
66 function */
67 return NO_ERROR;
68}
69
70
71int oem_panel_on()
72{
73 /* OEM can keep there panel spefic on instructions in this
74 function */
75 return NO_ERROR;
76}
77
78int oem_panel_off()
79{
80 /* OEM can keep there panel spefic off instructions in this
81 function */
82 return NO_ERROR;
83}
84
85static void init_panel_data(struct panel_struct *panelstruct,
86 struct msm_panel_info *pinfo,
87 struct mdss_dsi_phy_ctrl *phy_db)
88{
89 switch (panel_id) {
90 case TOSHIBA_720P_VIDEO_PANEL:
91 panelstruct->paneldata = &toshiba_720p_video_panel_data;
92 panelstruct->panelres = &toshiba_720p_video_panel_res;
93 panelstruct->color = &toshiba_720p_video_color;
94 panelstruct->videopanel = &toshiba_720p_video_video_panel;
95 panelstruct->commandpanel = &toshiba_720p_video_command_panel;
96 panelstruct->state = &toshiba_720p_video_state;
97 panelstruct->laneconfig = &toshiba_720p_video_lane_config;
98 panelstruct->paneltiminginfo
99 = &toshiba_720p_video_timing_info;
100 panelstruct->panelresetseq
101 = &toshiba_720p_video_panel_reset_seq;
102 panelstruct->backlightinfo = &toshiba_720p_video_backlight;
103 pinfo->mipi.panel_cmds
104 = toshiba_720p_video_on_command;
105 pinfo->mipi.num_of_panel_cmds
106 = TOSHIBA_720P_VIDEO_ON_COMMAND;
107 memcpy(phy_db->timing,
108 toshiba_720p_video_timings, TIMING_SIZE);
Casey Piper74f8e5c2013-09-05 15:00:30 -0700109 pinfo->mipi.signature = TOSHIBA_720P_VIDEO_SIGNATURE;
Casey Piper98e94f12013-09-09 20:42:15 -0700110 break;
111 case SHARP_QHD_VIDEO_PANEL:
112 panelstruct->paneldata = &sharp_qhd_video_panel_data;
113 panelstruct->panelres = &sharp_qhd_video_panel_res;
114 panelstruct->color = &sharp_qhd_video_color;
115 panelstruct->videopanel = &sharp_qhd_video_video_panel;
116 panelstruct->commandpanel = &sharp_qhd_video_command_panel;
117 panelstruct->state = &sharp_qhd_video_state;
118 panelstruct->laneconfig = &sharp_qhd_video_lane_config;
119 panelstruct->paneltiminginfo
120 = &sharp_qhd_video_timing_info;
121 panelstruct->panelresetseq
122 = &sharp_qhd_video_panel_reset_seq;
123 panelstruct->backlightinfo = &sharp_qhd_video_backlight;
124 pinfo->mipi.panel_cmds
125 = sharp_qhd_video_on_command;
126 pinfo->mipi.num_of_panel_cmds
127 = SHARP_QHD_VIDEO_ON_COMMAND;
128 memcpy(phy_db->timing,
129 sharp_qhd_video_timings, TIMING_SIZE);
130 break;
Casey Piperce3a4b12013-08-28 14:31:46 -0700131 case JDI_1080P_VIDEO_PANEL:
132 panelstruct->paneldata = &jdi_1080p_video_panel_data;
133 panelstruct->panelres = &jdi_1080p_video_panel_res;
134 panelstruct->color = &jdi_1080p_video_color;
135 panelstruct->videopanel = &jdi_1080p_video_video_panel;
136 panelstruct->commandpanel = &jdi_1080p_video_command_panel;
137 panelstruct->state = &jdi_1080p_video_state;
138 panelstruct->laneconfig = &jdi_1080p_video_lane_config;
139 panelstruct->paneltiminginfo
140 = &jdi_1080p_video_timing_info;
141 panelstruct->panelresetseq
142 = &jdi_1080p_video_panel_reset_seq;
143 panelstruct->backlightinfo = &jdi_1080p_video_backlight;
144 pinfo->mipi.panel_cmds
145 = jdi_1080p_video_on_command;
146 pinfo->mipi.num_of_panel_cmds
147 = JDI_1080P_VIDEO_ON_COMMAND;
148 memcpy(phy_db->timing,
149 jdi_1080p_video_timings, TIMING_SIZE);
Casey Piper74f8e5c2013-09-05 15:00:30 -0700150 pinfo->mipi.signature = JDI_1080P_VIDEO_SIGNATURE;
151 break;
Casey Piper78a9ad52013-11-14 13:27:48 -0800152 case GENERIC_720P_CMD_PANEL:
153 panelstruct->paneldata = &generic_720p_cmd_panel_data;
154 panelstruct->panelres = &generic_720p_cmd_panel_res;
155 panelstruct->color = &generic_720p_cmd_color;
156 panelstruct->videopanel = &generic_720p_cmd_video_panel;
157 panelstruct->commandpanel = &generic_720p_cmd_command_panel;
158 panelstruct->state = &generic_720p_cmd_state;
159 panelstruct->laneconfig = &generic_720p_cmd_lane_config;
160 panelstruct->paneltiminginfo
161 = &generic_720p_cmd_timing_info;
162 panelstruct->panelresetseq
163 = &generic_720p_cmd_reset_seq;
164 panelstruct->backlightinfo = &generic_720p_cmd_backlight;
165 pinfo->mipi.panel_cmds
166 = generic_720p_cmd_on_command;
167 pinfo->mipi.num_of_panel_cmds
168 = GENERIC_720P_CMD_ON_COMMAND;
169 memcpy(phy_db->timing,
170 generic_720p_cmd_timings, TIMING_SIZE);
171 pinfo->mipi.signature = GENERIC_720P_CMD_SIGNATURE;
172 break;
Casey Piper74f8e5c2013-09-05 15:00:30 -0700173 case UNKNOWN_PANEL:
174 memset(panelstruct, 0, sizeof(struct panel_struct));
175 memset(pinfo->mipi.panel_cmds, 0, sizeof(struct mipi_dsi_cmd));
176 pinfo->mipi.num_of_panel_cmds = 0;
177 memset(phy_db->timing, 0, TIMING_SIZE);
178 pinfo->mipi.signature = 0;
Casey Piperce3a4b12013-08-28 14:31:46 -0700179 break;
Casey Piper98e94f12013-09-09 20:42:15 -0700180 }
181}
182
Casey Piper74f8e5c2013-09-05 15:00:30 -0700183uint32_t oem_panel_max_auto_detect_panels()
184{
185 return target_panel_auto_detect_enabled() ?
186 DISPLAY_MAX_PANEL_DETECTION : 0;
187}
188
189static uint32_t auto_pan_loop = 0;
190
Casey Piper98e94f12013-09-09 20:42:15 -0700191bool oem_panel_select(struct panel_struct *panelstruct,
192 struct msm_panel_info *pinfo,
193 struct mdss_dsi_phy_ctrl *phy_db)
194{
195 uint32_t hw_id = board_hardware_id();
196 uint32_t target_id = board_target_id();
Casey Piper74f8e5c2013-09-05 15:00:30 -0700197 bool ret = true;
Casey Piper98e94f12013-09-09 20:42:15 -0700198
199 switch (hw_id) {
200 case HW_PLATFORM_MTP:
201 case HW_PLATFORM_FLUID:
202 case HW_PLATFORM_SURF:
Casey Piper74f8e5c2013-09-05 15:00:30 -0700203 switch (auto_pan_loop) {
204 case 0:
205 panel_id = JDI_1080P_VIDEO_PANEL;
206 break;
207 case 1:
208 panel_id = TOSHIBA_720P_VIDEO_PANEL;
209 break;
Casey Piper78a9ad52013-11-14 13:27:48 -0800210 case 2:
211 panel_id = GENERIC_720P_CMD_PANEL;
212 break;
Casey Piper74f8e5c2013-09-05 15:00:30 -0700213 default:
214 panel_id = UNKNOWN_PANEL;
215 ret = false;
216 break;
217 }
218 auto_pan_loop++;
Casey Piper98e94f12013-09-09 20:42:15 -0700219 break;
220 case HW_PLATFORM_DRAGON:
221 panel_id = SHARP_QHD_VIDEO_PANEL;
222 break;
223 default:
224 dprintf(CRITICAL, "Display not enabled for %d HW type\n"
225 , hw_id);
226 return false;
227 }
228
229 init_panel_data(panelstruct, pinfo, phy_db);
230
Casey Piper74f8e5c2013-09-05 15:00:30 -0700231 return ret;
Casey Piper98e94f12013-09-09 20:42:15 -0700232}