blob: 8af511c8875dcc097f7258348b3e783f23950efc [file] [log] [blame]
Padmanabhan Komanduru0104a892016-01-22 16:58:10 +05301/* Copyright (c) 2016, 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 are
5 * 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
9 * copyright notice, this list of conditions and the following
10 * disclaimer in the documentation and/or other materials provided
11 * with the 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 "AS IS" AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 */
29
30#include <debug.h>
31#include <string.h>
32#include <err.h>
33#include <smem.h>
34#include <msm_panel.h>
35#include <board.h>
36#include <qtimer.h>
37#include <mipi_dsi.h>
38#include <mdp5.h>
39#include <target/display.h>
40
41#include "gcdb_display.h"
42#include "include/panel.h"
43#include "panel_display.h"
44
45/*---------------------------------------------------------------------------*/
46/* GCDB Panel Database */
47/*---------------------------------------------------------------------------*/
48#include "include/panel_truly_1080p_video.h"
49#include "include/panel_truly_1080p_cmd.h"
50
51/*---------------------------------------------------------------------------*/
52/* static panel selection variable */
53/*---------------------------------------------------------------------------*/
54enum {
55 TRULY_1080P_VIDEO_PANEL,
56 TRULY_1080P_CMD_PANEL,
57 UNKNOWN_PANEL
58};
59
60/*
61 * The list of panels that are supported on this target.
62 * Any panel in this list can be selected using fastboot oem command.
63 */
64static struct panel_list supp_panels[] = {
65 {"truly_1080p_video", TRULY_1080P_VIDEO_PANEL},
66 {"truly_1080p_cmd", TRULY_1080P_CMD_PANEL},
67};
68
69static uint32_t panel_id;
70
71int oem_panel_rotation()
72{
73 return NO_ERROR;
74}
75
76#define TRULY_1080P_PANEL_ON_DELAY 40
77int oem_panel_on()
78{
79 if (panel_id == TRULY_1080P_CMD_PANEL ||
80 panel_id == TRULY_1080P_VIDEO_PANEL)
81 mdelay(TRULY_1080P_PANEL_ON_DELAY);
82
83 return NO_ERROR;
84}
85
86int oem_panel_off()
87{
88 /* OEM can keep their panel specific off instructions
89 * in this function
90 */
91 return NO_ERROR;
92}
93
94static int init_panel_data(struct panel_struct *panelstruct,
95 struct msm_panel_info *pinfo,
96 struct mdss_dsi_phy_ctrl *phy_db)
97{
98 int pan_type = PANEL_TYPE_DSI;
99
100 switch (panel_id) {
101 case TRULY_1080P_VIDEO_PANEL:
102 panelstruct->paneldata = &truly_1080p_video_panel_data;
103 panelstruct->paneldata->panel_with_enable_gpio = 1;
104 panelstruct->panelres = &truly_1080p_video_panel_res;
105 panelstruct->color = &truly_1080p_video_color;
106 panelstruct->videopanel = &truly_1080p_video_video_panel;
107 panelstruct->commandpanel = &truly_1080p_video_command_panel;
108 panelstruct->state = &truly_1080p_video_state;
109 panelstruct->laneconfig = &truly_1080p_video_lane_config;
110 panelstruct->paneltiminginfo
111 = &truly_1080p_video_timing_info;
112 panelstruct->panelresetseq
113 = &truly_1080p_video_panel_reset_seq;
114 panelstruct->backlightinfo = &truly_1080p_video_backlight;
115 pinfo->mipi.panel_on_cmds
116 = truly_1080p_video_on_command;
117 pinfo->mipi.num_of_panel_on_cmds
118 = TRULY_1080P_VIDEO_ON_COMMAND;
119 pinfo->mipi.panel_off_cmds
120 = truly_1080p_video_off_command;
121 pinfo->mipi.num_of_panel_off_cmds
122 = TRULY_1080P_VIDEO_OFF_COMMAND;
123 memcpy(phy_db->timing,
124 truly_1080p_14nm_video_timings,
125 MAX_TIMING_CONFIG * sizeof(uint32_t));
126 pinfo->mipi.signature = TRULY_1080P_VIDEO_SIGNATURE;
127 break;
128 case TRULY_1080P_CMD_PANEL:
129 panelstruct->paneldata = &truly_1080p_cmd_panel_data;
130 panelstruct->paneldata->panel_with_enable_gpio = 1;
131 panelstruct->panelres = &truly_1080p_cmd_panel_res;
132 panelstruct->color = &truly_1080p_cmd_color;
133 panelstruct->videopanel = &truly_1080p_cmd_video_panel;
134 panelstruct->commandpanel = &truly_1080p_cmd_command_panel;
135 panelstruct->state = &truly_1080p_cmd_state;
136 panelstruct->laneconfig = &truly_1080p_cmd_lane_config;
137 panelstruct->paneltiminginfo
138 = &truly_1080p_cmd_timing_info;
139 panelstruct->panelresetseq
140 = &truly_1080p_cmd_panel_reset_seq;
141 panelstruct->backlightinfo = &truly_1080p_cmd_backlight;
142 pinfo->mipi.panel_on_cmds
143 = truly_1080p_cmd_on_command;
144 pinfo->mipi.num_of_panel_on_cmds
145 = TRULY_1080P_CMD_ON_COMMAND;
146 pinfo->mipi.panel_off_cmds
147 = truly_1080p_cmd_off_command;
148 pinfo->mipi.num_of_panel_off_cmds
149 = TRULY_1080P_CMD_OFF_COMMAND;
150 memcpy(phy_db->timing,
151 truly_1080p_14nm_cmd_timings,
152 MAX_TIMING_CONFIG * sizeof(uint32_t));
153 pinfo->mipi.signature = TRULY_1080P_CMD_SIGNATURE;
154 break;
155 case UNKNOWN_PANEL:
156 default:
157 memset(panelstruct, 0, sizeof(struct panel_struct));
158 memset(pinfo->mipi.panel_on_cmds, 0,
159 sizeof(struct mipi_dsi_cmd));
160 pinfo->mipi.num_of_panel_on_cmds = 0;
161 memset(pinfo->mipi.panel_off_cmds, 0,
162 sizeof(struct mipi_dsi_cmd));
163 pinfo->mipi.num_of_panel_off_cmds = 0;
164 memset(phy_db->timing, 0, TIMING_SIZE);
165 pan_type = PANEL_TYPE_UNKNOWN;
166 break;
167 }
168 return pan_type;
169}
170
171#define DISPLAY_MAX_PANEL_DETECTION 2
172
173uint32_t oem_panel_max_auto_detect_panels()
174{
175 return target_panel_auto_detect_enabled() ?
176 DISPLAY_MAX_PANEL_DETECTION : 0;
177}
178
179int oem_panel_select(const char *panel_name, struct panel_struct *panelstruct,
180 struct msm_panel_info *pinfo,
181 struct mdss_dsi_phy_ctrl *phy_db)
182{
183 uint32_t hw_id = board_hardware_id();
184 int32_t panel_override_id;
185 phy_db->pll_type = DSI_PLL_TYPE_THULIUM;
186
187 if (panel_name) {
188 panel_override_id = panel_name_to_id(supp_panels,
189 ARRAY_SIZE(supp_panels), panel_name);
190
191 if (panel_override_id < 0) {
192 dprintf(CRITICAL, "Not able to search the panel:%s\n",
193 panel_name + strspn(panel_name, " "));
194 } else if (panel_override_id < UNKNOWN_PANEL) {
195 /* panel override using fastboot oem command */
196 panel_id = panel_override_id;
197
198 dprintf(INFO, "OEM panel override:%s\n",
199 panel_name + strspn(panel_name, " "));
200 goto panel_init;
201 }
202 }
203
204 switch (hw_id) {
205 case HW_PLATFORM_MTP:
206 case HW_PLATFORM_SURF:
207 case HW_PLATFORM_RCM:
208 panel_id = TRULY_1080P_VIDEO_PANEL;
209 break;
210 default:
211 dprintf(CRITICAL, "Display not enabled for %d HW type\n",
212 hw_id);
213 return PANEL_TYPE_UNKNOWN;
214 }
215
216panel_init:
217 /*
218 * Update all data structures after 'panel_init' label. Only panel
219 * selection is supposed to happen before that.
220 */
221 pinfo->pipe_type = MDSS_MDP_PIPE_TYPE_RGB;
222 return init_panel_data(panelstruct, pinfo, phy_db);
223}