blob: 1f876d745c0b4b51410315c8ea7baabafff0e862 [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 Piper98e94f12013-09-09 20:42:15 -070046
Casey Piper74f8e5c2013-09-05 15:00:30 -070047#define DISPLAY_MAX_PANEL_DETECTION 2
48
Casey Piper98e94f12013-09-09 20:42:15 -070049/*---------------------------------------------------------------------------*/
50/* static panel selection variable */
51/*---------------------------------------------------------------------------*/
52enum {
Casey Piper74f8e5c2013-09-05 15:00:30 -070053JDI_1080P_VIDEO_PANEL,
Casey Piper98e94f12013-09-09 20:42:15 -070054TOSHIBA_720P_VIDEO_PANEL,
Casey Piperce3a4b12013-08-28 14:31:46 -070055SHARP_QHD_VIDEO_PANEL,
Casey Piper74f8e5c2013-09-05 15:00:30 -070056UNKNOWN_PANEL
Casey Piper98e94f12013-09-09 20:42:15 -070057};
58
59static uint32_t panel_id;
60
61int oem_panel_rotation()
62{
63 /* OEM can keep there panel spefic on instructions in this
64 function */
65 return NO_ERROR;
66}
67
68
69int oem_panel_on()
70{
71 /* OEM can keep there panel spefic on instructions in this
72 function */
73 return NO_ERROR;
74}
75
76int oem_panel_off()
77{
78 /* OEM can keep there panel spefic off instructions in this
79 function */
80 return NO_ERROR;
81}
82
83static void init_panel_data(struct panel_struct *panelstruct,
84 struct msm_panel_info *pinfo,
85 struct mdss_dsi_phy_ctrl *phy_db)
86{
87 switch (panel_id) {
88 case TOSHIBA_720P_VIDEO_PANEL:
89 panelstruct->paneldata = &toshiba_720p_video_panel_data;
90 panelstruct->panelres = &toshiba_720p_video_panel_res;
91 panelstruct->color = &toshiba_720p_video_color;
92 panelstruct->videopanel = &toshiba_720p_video_video_panel;
93 panelstruct->commandpanel = &toshiba_720p_video_command_panel;
94 panelstruct->state = &toshiba_720p_video_state;
95 panelstruct->laneconfig = &toshiba_720p_video_lane_config;
96 panelstruct->paneltiminginfo
97 = &toshiba_720p_video_timing_info;
98 panelstruct->panelresetseq
99 = &toshiba_720p_video_panel_reset_seq;
100 panelstruct->backlightinfo = &toshiba_720p_video_backlight;
101 pinfo->mipi.panel_cmds
102 = toshiba_720p_video_on_command;
103 pinfo->mipi.num_of_panel_cmds
104 = TOSHIBA_720P_VIDEO_ON_COMMAND;
105 memcpy(phy_db->timing,
106 toshiba_720p_video_timings, TIMING_SIZE);
Casey Piper74f8e5c2013-09-05 15:00:30 -0700107 pinfo->mipi.signature = TOSHIBA_720P_VIDEO_SIGNATURE;
Casey Piper98e94f12013-09-09 20:42:15 -0700108 break;
109 case SHARP_QHD_VIDEO_PANEL:
110 panelstruct->paneldata = &sharp_qhd_video_panel_data;
111 panelstruct->panelres = &sharp_qhd_video_panel_res;
112 panelstruct->color = &sharp_qhd_video_color;
113 panelstruct->videopanel = &sharp_qhd_video_video_panel;
114 panelstruct->commandpanel = &sharp_qhd_video_command_panel;
115 panelstruct->state = &sharp_qhd_video_state;
116 panelstruct->laneconfig = &sharp_qhd_video_lane_config;
117 panelstruct->paneltiminginfo
118 = &sharp_qhd_video_timing_info;
119 panelstruct->panelresetseq
120 = &sharp_qhd_video_panel_reset_seq;
121 panelstruct->backlightinfo = &sharp_qhd_video_backlight;
122 pinfo->mipi.panel_cmds
123 = sharp_qhd_video_on_command;
124 pinfo->mipi.num_of_panel_cmds
125 = SHARP_QHD_VIDEO_ON_COMMAND;
126 memcpy(phy_db->timing,
127 sharp_qhd_video_timings, TIMING_SIZE);
128 break;
Casey Piperce3a4b12013-08-28 14:31:46 -0700129 case JDI_1080P_VIDEO_PANEL:
130 panelstruct->paneldata = &jdi_1080p_video_panel_data;
131 panelstruct->panelres = &jdi_1080p_video_panel_res;
132 panelstruct->color = &jdi_1080p_video_color;
133 panelstruct->videopanel = &jdi_1080p_video_video_panel;
134 panelstruct->commandpanel = &jdi_1080p_video_command_panel;
135 panelstruct->state = &jdi_1080p_video_state;
136 panelstruct->laneconfig = &jdi_1080p_video_lane_config;
137 panelstruct->paneltiminginfo
138 = &jdi_1080p_video_timing_info;
139 panelstruct->panelresetseq
140 = &jdi_1080p_video_panel_reset_seq;
141 panelstruct->backlightinfo = &jdi_1080p_video_backlight;
142 pinfo->mipi.panel_cmds
143 = jdi_1080p_video_on_command;
144 pinfo->mipi.num_of_panel_cmds
145 = JDI_1080P_VIDEO_ON_COMMAND;
146 memcpy(phy_db->timing,
147 jdi_1080p_video_timings, TIMING_SIZE);
Casey Piper74f8e5c2013-09-05 15:00:30 -0700148 pinfo->mipi.signature = JDI_1080P_VIDEO_SIGNATURE;
149 break;
150 case UNKNOWN_PANEL:
151 memset(panelstruct, 0, sizeof(struct panel_struct));
152 memset(pinfo->mipi.panel_cmds, 0, sizeof(struct mipi_dsi_cmd));
153 pinfo->mipi.num_of_panel_cmds = 0;
154 memset(phy_db->timing, 0, TIMING_SIZE);
155 pinfo->mipi.signature = 0;
Casey Piperce3a4b12013-08-28 14:31:46 -0700156 break;
Casey Piper98e94f12013-09-09 20:42:15 -0700157 }
158}
159
Casey Piper74f8e5c2013-09-05 15:00:30 -0700160uint32_t oem_panel_max_auto_detect_panels()
161{
162 return target_panel_auto_detect_enabled() ?
163 DISPLAY_MAX_PANEL_DETECTION : 0;
164}
165
166static uint32_t auto_pan_loop = 0;
167
Casey Piper98e94f12013-09-09 20:42:15 -0700168bool oem_panel_select(struct panel_struct *panelstruct,
169 struct msm_panel_info *pinfo,
170 struct mdss_dsi_phy_ctrl *phy_db)
171{
172 uint32_t hw_id = board_hardware_id();
173 uint32_t target_id = board_target_id();
Casey Piper74f8e5c2013-09-05 15:00:30 -0700174 bool ret = true;
Casey Piper98e94f12013-09-09 20:42:15 -0700175
176 switch (hw_id) {
177 case HW_PLATFORM_MTP:
178 case HW_PLATFORM_FLUID:
179 case HW_PLATFORM_SURF:
Casey Piper74f8e5c2013-09-05 15:00:30 -0700180 switch (auto_pan_loop) {
181 case 0:
182 panel_id = JDI_1080P_VIDEO_PANEL;
183 break;
184 case 1:
185 panel_id = TOSHIBA_720P_VIDEO_PANEL;
186 break;
187 default:
188 panel_id = UNKNOWN_PANEL;
189 ret = false;
190 break;
191 }
192 auto_pan_loop++;
Casey Piper98e94f12013-09-09 20:42:15 -0700193 break;
194 case HW_PLATFORM_DRAGON:
195 panel_id = SHARP_QHD_VIDEO_PANEL;
196 break;
197 default:
198 dprintf(CRITICAL, "Display not enabled for %d HW type\n"
199 , hw_id);
200 return false;
201 }
202
203 init_panel_data(panelstruct, pinfo, phy_db);
204
Casey Piper74f8e5c2013-09-05 15:00:30 -0700205 return ret;
Casey Piper98e94f12013-09-09 20:42:15 -0700206}