blob: 2f38db60584f0011a2e5c99830f4028bfe2a2975 [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));
Padmanabhan Komanduru6f0b6322016-01-22 16:37:53 +0530126 pinfo->dfps.panel_dfps = truly_1080p_video_dfps;
Padmanabhan Komanduru0104a892016-01-22 16:58:10 +0530127 pinfo->mipi.signature = TRULY_1080P_VIDEO_SIGNATURE;
128 break;
129 case TRULY_1080P_CMD_PANEL:
130 panelstruct->paneldata = &truly_1080p_cmd_panel_data;
131 panelstruct->paneldata->panel_with_enable_gpio = 1;
132 panelstruct->panelres = &truly_1080p_cmd_panel_res;
133 panelstruct->color = &truly_1080p_cmd_color;
134 panelstruct->videopanel = &truly_1080p_cmd_video_panel;
135 panelstruct->commandpanel = &truly_1080p_cmd_command_panel;
136 panelstruct->state = &truly_1080p_cmd_state;
137 panelstruct->laneconfig = &truly_1080p_cmd_lane_config;
138 panelstruct->paneltiminginfo
139 = &truly_1080p_cmd_timing_info;
140 panelstruct->panelresetseq
141 = &truly_1080p_cmd_panel_reset_seq;
142 panelstruct->backlightinfo = &truly_1080p_cmd_backlight;
143 pinfo->mipi.panel_on_cmds
144 = truly_1080p_cmd_on_command;
145 pinfo->mipi.num_of_panel_on_cmds
146 = TRULY_1080P_CMD_ON_COMMAND;
147 pinfo->mipi.panel_off_cmds
148 = truly_1080p_cmd_off_command;
149 pinfo->mipi.num_of_panel_off_cmds
150 = TRULY_1080P_CMD_OFF_COMMAND;
151 memcpy(phy_db->timing,
152 truly_1080p_14nm_cmd_timings,
153 MAX_TIMING_CONFIG * sizeof(uint32_t));
154 pinfo->mipi.signature = TRULY_1080P_CMD_SIGNATURE;
155 break;
156 case UNKNOWN_PANEL:
157 default:
158 memset(panelstruct, 0, sizeof(struct panel_struct));
159 memset(pinfo->mipi.panel_on_cmds, 0,
160 sizeof(struct mipi_dsi_cmd));
161 pinfo->mipi.num_of_panel_on_cmds = 0;
162 memset(pinfo->mipi.panel_off_cmds, 0,
163 sizeof(struct mipi_dsi_cmd));
164 pinfo->mipi.num_of_panel_off_cmds = 0;
165 memset(phy_db->timing, 0, TIMING_SIZE);
166 pan_type = PANEL_TYPE_UNKNOWN;
167 break;
168 }
169 return pan_type;
170}
171
172#define DISPLAY_MAX_PANEL_DETECTION 2
173
174uint32_t oem_panel_max_auto_detect_panels()
175{
176 return target_panel_auto_detect_enabled() ?
177 DISPLAY_MAX_PANEL_DETECTION : 0;
178}
179
180int oem_panel_select(const char *panel_name, struct panel_struct *panelstruct,
181 struct msm_panel_info *pinfo,
182 struct mdss_dsi_phy_ctrl *phy_db)
183{
184 uint32_t hw_id = board_hardware_id();
185 int32_t panel_override_id;
186 phy_db->pll_type = DSI_PLL_TYPE_THULIUM;
187
188 if (panel_name) {
189 panel_override_id = panel_name_to_id(supp_panels,
190 ARRAY_SIZE(supp_panels), panel_name);
191
192 if (panel_override_id < 0) {
193 dprintf(CRITICAL, "Not able to search the panel:%s\n",
194 panel_name + strspn(panel_name, " "));
195 } else if (panel_override_id < UNKNOWN_PANEL) {
196 /* panel override using fastboot oem command */
197 panel_id = panel_override_id;
198
199 dprintf(INFO, "OEM panel override:%s\n",
200 panel_name + strspn(panel_name, " "));
201 goto panel_init;
202 }
203 }
204
205 switch (hw_id) {
206 case HW_PLATFORM_MTP:
207 case HW_PLATFORM_SURF:
208 case HW_PLATFORM_RCM:
209 panel_id = TRULY_1080P_VIDEO_PANEL;
210 break;
211 default:
212 dprintf(CRITICAL, "Display not enabled for %d HW type\n",
213 hw_id);
214 return PANEL_TYPE_UNKNOWN;
215 }
216
217panel_init:
218 /*
219 * Update all data structures after 'panel_init' label. Only panel
220 * selection is supposed to happen before that.
221 */
222 pinfo->pipe_type = MDSS_MDP_PIPE_TYPE_RGB;
223 return init_panel_data(panelstruct, pinfo, phy_db);
224}