blob: 2973de879259204fd631362ee9768e1826f18eb6 [file] [log] [blame]
Dhaval Patelc4135d82016-03-30 17:40:53 -07001/* Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
Arpita Banerjee841fa062013-05-24 14:59:51 -07002 *
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/*---------------------------------------------------------------------------*/
31/* HEADER files */
32/*---------------------------------------------------------------------------*/
33#include <stdint.h>
34#include <msm_panel.h>
35#include <mipi_dsi.h>
Veera Sundaram Sankaran602d95a2014-12-09 17:55:04 -080036#include <mdp5.h>
Arpita Banerjee841fa062013-05-24 14:59:51 -070037#include <sys/types.h>
38#include <platform/iomap.h>
39#include <err.h>
40#include <reg.h>
Dhaval Patel551f7f62014-02-18 17:13:00 -080041#include <string.h>
Arpita Banerjee841fa062013-05-24 14:59:51 -070042
Arpita Banerjee841fa062013-05-24 14:59:51 -070043/*---------------------------------------------------------------------------*/
44/* Panel Header */
45/*---------------------------------------------------------------------------*/
46#include "panel_display.h"
47#include "include/panel.h"
Veera Sundaram Sankaran824e6fa2014-12-09 11:32:58 -080048#include "target/display.h"
Arpita Banerjee841fa062013-05-24 14:59:51 -070049
Jeevan Shriram04c15b62015-01-08 13:16:18 -080050static int dsi_platform_base_offset_adjust(uint32_t base)
51{
52 return target_display_get_base_offset(base);
53}
54
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -080055static int dsi_panel_ctl_base_setup(struct msm_panel_info *pinfo,
56 char *panel_destination)
57{
Padmanabhan Komanduru876c1cf2015-06-08 14:06:57 +053058 int base_offset = 0, base1_offset = 0, base_phy_offset = 0,
59 base1_phy_offset = 0, base_phy_pll_offset = 0,
60 base1_phy_pll_offset = 0, base_phy_reg_offset = 0;
Jeevan Shriram04c15b62015-01-08 13:16:18 -080061
62 /*
63 * Base offsets may vary for few platforms. Add the difference to get
64 * proper base offset for the respective platform.
65 */
66 base_offset = dsi_platform_base_offset_adjust(MIPI_DSI0_BASE);
67 base1_offset = dsi_platform_base_offset_adjust(MIPI_DSI1_BASE);
Padmanabhan Komanduru876c1cf2015-06-08 14:06:57 +053068 base_phy_offset = dsi_platform_base_offset_adjust(DSI0_PHY_BASE);
69 base1_phy_offset = dsi_platform_base_offset_adjust(DSI1_PHY_BASE);
70 base_phy_pll_offset = dsi_platform_base_offset_adjust(DSI0_PLL_BASE);
71 base1_phy_pll_offset = dsi_platform_base_offset_adjust(DSI1_PLL_BASE);
72 base_phy_reg_offset = dsi_platform_base_offset_adjust(DSI0_REGULATOR_BASE);
Jeevan Shriram04c15b62015-01-08 13:16:18 -080073 dprintf(SPEW, "base offset = %d, %x\n", base_offset, base_offset);
74
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -080075 if (!strcmp(panel_destination, "DISPLAY_1")) {
76 pinfo->dest = DISPLAY_1;
Jeevan Shriram04c15b62015-01-08 13:16:18 -080077 pinfo->mipi.ctl_base = MIPI_DSI0_BASE + base_offset;
Padmanabhan Komanduru876c1cf2015-06-08 14:06:57 +053078 pinfo->mipi.phy_base = DSI0_PHY_BASE + base_phy_offset;
Jeevan Shriram04c15b62015-01-08 13:16:18 -080079 pinfo->mipi.sctl_base = MIPI_DSI1_BASE + base1_offset;
Padmanabhan Komanduru876c1cf2015-06-08 14:06:57 +053080 pinfo->mipi.sphy_base = DSI1_PHY_BASE + base1_phy_offset;
Padmanabhan Komanduruc0766c82015-04-27 16:39:15 -070081 if (pinfo->mipi.use_dsi1_pll) {
82 dprintf(CRITICAL, "%s: Invalid combination: DSI0 controller + DSI1 PLL, using DSI0 PLL\n",
83 __func__);
84 pinfo->mipi.use_dsi1_pll = 0;
85 }
Padmanabhan Komanduru876c1cf2015-06-08 14:06:57 +053086 pinfo->mipi.pll_base = DSI0_PLL_BASE + base_phy_pll_offset;
87 pinfo->mipi.spll_base = DSI1_PLL_BASE + base1_phy_pll_offset;
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -080088 } else if (!strcmp(panel_destination, "DISPLAY_2")) {
89 pinfo->dest = DISPLAY_2;
Jeevan Shriram04c15b62015-01-08 13:16:18 -080090 pinfo->mipi.ctl_base = MIPI_DSI1_BASE + base1_offset;
Padmanabhan Komanduru876c1cf2015-06-08 14:06:57 +053091 pinfo->mipi.phy_base = DSI1_PHY_BASE + base1_phy_offset;
Jeevan Shriram04c15b62015-01-08 13:16:18 -080092 pinfo->mipi.sctl_base = MIPI_DSI0_BASE + base_offset;
Padmanabhan Komanduru876c1cf2015-06-08 14:06:57 +053093 pinfo->mipi.sphy_base = DSI0_PHY_BASE + base_phy_offset;
Padmanabhan Komanduruc0766c82015-04-27 16:39:15 -070094 if (pinfo->mipi.use_dsi1_pll) {
Padmanabhan Komanduru876c1cf2015-06-08 14:06:57 +053095 pinfo->mipi.pll_base = DSI1_PLL_BASE + base1_phy_pll_offset;
96 pinfo->mipi.spll_base = DSI0_PLL_BASE + base_phy_pll_offset;
Padmanabhan Komanduruc0766c82015-04-27 16:39:15 -070097 } else {
Padmanabhan Komanduru876c1cf2015-06-08 14:06:57 +053098 pinfo->mipi.pll_base = DSI0_PLL_BASE + base_phy_pll_offset;
99 pinfo->mipi.spll_base = DSI1_PLL_BASE + base1_phy_pll_offset;
Padmanabhan Komanduruc0766c82015-04-27 16:39:15 -0700100 }
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -0800101 } else {
102 pinfo->dest = DISPLAY_UNKNOWN;
103 dprintf(CRITICAL, "%s: Unkown panel destination: %d\n",
104 __func__, pinfo->dest);
105 return ERROR;
106 }
107
Jeevan Shriram01379322015-01-07 17:41:26 -0800108 /* Both DSI0 and DSI1 use the same regulator */
Padmanabhan Komanduru876c1cf2015-06-08 14:06:57 +0530109 pinfo->mipi.reg_base = DSI0_REGULATOR_BASE + base_phy_reg_offset;
110 pinfo->mipi.sreg_base = DSI0_REGULATOR_BASE + base_phy_reg_offset;
Jeevan Shriram01379322015-01-07 17:41:26 -0800111
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -0800112 dprintf(SPEW, "%s: panel dest=%s, ctl_base=0x%08x, phy_base=0x%08x\n",
113 __func__, panel_destination, pinfo->mipi.ctl_base,
114 pinfo->mipi.phy_base);
Padmanabhan Komanduruc0766c82015-04-27 16:39:15 -0700115 dprintf(SPEW, "pll_base=%08x, spll_base=0x%08x, reg_base=0x%08x, sreg_base=%08x\n",
116 pinfo->mipi.pll_base, pinfo->mipi.spll_base,
Jeevan Shriram01379322015-01-07 17:41:26 -0800117 pinfo->mipi.reg_base, pinfo->mipi.sreg_base);
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -0800118 return NO_ERROR;
119}
120
Arpita Banerjee841fa062013-05-24 14:59:51 -0700121/*---------------------------------------------------------------------------*/
122/* Panel Init */
123/*---------------------------------------------------------------------------*/
124int dsi_panel_init(struct msm_panel_info *pinfo,
125 struct panel_struct *pstruct)
126{
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -0800127 int ret = NO_ERROR;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700128 /* Resolution setting*/
129 pinfo->xres = pstruct->panelres->panel_width;
130 pinfo->yres = pstruct->panelres->panel_height;
131 pinfo->lcdc.h_back_porch = pstruct->panelres->hback_porch;
132 pinfo->lcdc.h_front_porch = pstruct->panelres->hfront_porch;
133 pinfo->lcdc.h_pulse_width = pstruct->panelres->hpulse_width;
134 pinfo->lcdc.v_back_porch = pstruct->panelres->vback_porch;
135 pinfo->lcdc.v_front_porch = pstruct->panelres->vfront_porch;
136 pinfo->lcdc.v_pulse_width = pstruct->panelres->vpulse_width;
137 pinfo->lcdc.hsync_skew = pstruct->panelres->hsync_skew;
Kuogee Hsieh31b4ff92014-10-22 14:55:42 -0700138
139 pinfo->border_top = pstruct->panelres->vtop_border;
140 pinfo->border_bottom = pstruct->panelres->vbottom_border;
141 pinfo->border_left = pstruct->panelres->hleft_border;
142 pinfo->border_right = pstruct->panelres->hright_border;
143
144 dprintf(SPEW, "%s: left=%d right=%d top=%d bottom=%d\n", __func__,
145 pinfo->border_left, pinfo->border_right,
146 pinfo->border_top, pinfo->border_bottom);
147
148 pinfo->xres += (pinfo->border_left + pinfo->border_right);
149 pinfo->yres += (pinfo->border_top + pinfo->border_bottom);
Arpita Banerjee841fa062013-05-24 14:59:51 -0700150
Ujwal Patel41a665a2015-07-17 13:51:30 -0700151 dprintf(INFO, "panel_operating_mode=0x%x\n",
152 pstruct->paneldata->panel_operating_mode);
Dhaval Patelee8675a2013-10-25 10:07:57 -0700153 if (pstruct->paneldata->panel_operating_mode & DUAL_PIPE_FLAG)
154 pinfo->lcdc.dual_pipe = 1;
155 if (pstruct->paneldata->panel_operating_mode & PIPE_SWAP_FLAG)
156 pinfo->lcdc.pipe_swap = 1;
157 if (pstruct->paneldata->panel_operating_mode & SPLIT_DISPLAY_FLAG)
158 pinfo->lcdc.split_display = 1;
Vineet Bajaj4effb132014-07-24 16:55:41 +0530159 if (pstruct->paneldata->panel_operating_mode & DST_SPLIT_FLAG)
160 pinfo->lcdc.dst_split = 1;
Ujwal Patel41a665a2015-07-17 13:51:30 -0700161 if (pstruct->paneldata->panel_operating_mode & DUAL_DSI_FLAG)
162 pinfo->mipi.dual_dsi = 1;
163 if (pstruct->paneldata->panel_operating_mode & USE_DSI1_PLL_FLAG)
164 pinfo->mipi.use_dsi1_pll = 1;
165
166 dprintf(SPEW, "dual_pipe=%d pipe_swap=%d split_display=%d dst_split=%d\n",
167 pinfo->lcdc.dual_pipe, pinfo->lcdc.pipe_swap,
168 pinfo->lcdc.split_display, pinfo->lcdc.dst_split);
Arpita Banerjee841fa062013-05-24 14:59:51 -0700169
170 /* Color setting*/
171 pinfo->lcdc.border_clr = pstruct->color->border_color;
172 pinfo->lcdc.underflow_clr = pstruct->color->underflow_color;
173 pinfo->mipi.rgb_swap = pstruct->color->color_order;
Jeevan Shriram2dd40cf2014-05-12 16:59:13 -0700174 pinfo->bpp = pstruct->color->color_format;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700175 switch (pinfo->bpp) {
176 case BPP_16:
177 pinfo->mipi.dst_format = DSI_VIDEO_DST_FORMAT_RGB565;
178 break;
179 case BPP_18:
180 if (pstruct->color->pixel_packing)
181 pinfo->mipi.dst_format
182 = DSI_VIDEO_DST_FORMAT_RGB666_LOOSE;
183 else
184 pinfo->mipi.dst_format
185 = DSI_VIDEO_DST_FORMAT_RGB666;
186 break;
187 case BPP_24:
188 default:
189 pinfo->mipi.dst_format = DSI_VIDEO_DST_FORMAT_RGB888;
190 break;
191 }
192
193 /* Panel generic info */
194 pinfo->mipi.mode = pstruct->paneldata->panel_type;
195 if (pinfo->mipi.mode) {
196 pinfo->type = MIPI_CMD_PANEL;
197 } else {
198 pinfo->type = MIPI_VIDEO_PANEL;
199 }
Arpita Banerjee841fa062013-05-24 14:59:51 -0700200 pinfo->clk_rate = pstruct->paneldata->panel_clockrate;
Prashant Nukala64eeff92014-07-11 07:35:34 +0530201 pinfo->orientation = pstruct->paneldata->panel_orientation;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700202 pinfo->mipi.interleave_mode = pstruct->paneldata->interleave_mode;
Dhaval Patelee8675a2013-10-25 10:07:57 -0700203 pinfo->mipi.broadcast = pstruct->paneldata->panel_broadcast_mode;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700204 pinfo->mipi.vc = pstruct->paneldata->dsi_virtualchannel_id;
205 pinfo->mipi.frame_rate = pstruct->paneldata->panel_framerate;
206 pinfo->mipi.stream = pstruct->paneldata->dsi_stream;
Dhaval Patel29f24492013-08-08 20:45:42 -0700207 pinfo->mipi.mode_gpio_state = pstruct->paneldata->mode_gpio_state;
Arpita Banerjeeda0c39a2013-05-24 16:12:45 -0700208 pinfo->mipi.bitclock = pstruct->paneldata->panel_bitclock_freq;
Aravind Venkateswaran31119842015-01-13 14:46:04 -0800209 if (pinfo->mipi.bitclock) {
210 /* panel_clockrate is depcrated in favor of bitclock_freq */
211 pinfo->clk_rate = pinfo->mipi.bitclock;
212 }
Aravind Venkateswaran1e31c782013-11-04 17:32:14 -0800213 pinfo->mipi.use_enable_gpio =
214 pstruct->paneldata->panel_with_enable_gpio;
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -0800215 ret = dsi_panel_ctl_base_setup(pinfo,
216 pstruct->paneldata->panel_destination);
217 if (ret)
218 return ret;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700219
220 /* Video Panel configuration */
221 pinfo->mipi.pulse_mode_hsa_he = pstruct->videopanel->hsync_pulse;
222 pinfo->mipi.hfp_power_stop = pstruct->videopanel->hfp_power_mode;
223 pinfo->mipi.hbp_power_stop = pstruct->videopanel->hbp_power_mode;
224 pinfo->mipi.hsa_power_stop = pstruct->videopanel->hsa_power_mode;
225 pinfo->mipi.eof_bllp_power_stop
226 = pstruct->videopanel->bllp_eof_power_mode;
227 pinfo->mipi.bllp_power_stop = pstruct->videopanel->bllp_power_mode;
228 pinfo->mipi.traffic_mode = pstruct->videopanel->traffic_mode;
229 pinfo->mipi.eof_bllp_power = pstruct->videopanel->bllp_eof_power;
230
231 /* Command Panel configuratoin */
232 pinfo->mipi.insert_dcs_cmd = pstruct->commandpanel->tedcs_command;
233 pinfo->mipi.wr_mem_continue
234 = pstruct->commandpanel->tevsync_continue_lines;
235 pinfo->mipi.wr_mem_start
236 = pstruct->commandpanel->tevsync_rdptr_irqline;
237 pinfo->mipi.te_sel = pstruct->commandpanel->tepin_select;
Sandeep Panda79764b52015-12-23 15:38:54 +0530238 pinfo->autorefresh_enable = pstruct->commandpanel->autorefresh_enable;
239 pinfo->autorefresh_framenum =
240 pstruct->commandpanel->autorefresh_framenumdiv;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700241
242 /* Data lane configuraiton */
243 pinfo->mipi.num_of_lanes = pstruct->laneconfig->dsi_lanes;
244 pinfo->mipi.data_lane0 = pstruct->laneconfig->lane0_state;
245 pinfo->mipi.data_lane1 = pstruct->laneconfig->lane1_state;
246 pinfo->mipi.data_lane2 = pstruct->laneconfig->lane2_state;
247 pinfo->mipi.data_lane3 = pstruct->laneconfig->lane3_state;
248 pinfo->mipi.lane_swap = pstruct->laneconfig->dsi_lanemap;
Ray Zhang0d303af2015-01-21 10:17:02 +0800249 pinfo->mipi.force_clk_lane_hs = pstruct->laneconfig->force_clk_lane_hs;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700250
251 pinfo->mipi.t_clk_post = pstruct->paneltiminginfo->tclk_post;
252 pinfo->mipi.t_clk_pre = pstruct->paneltiminginfo->tclk_pre;
253 pinfo->mipi.mdp_trigger = pstruct->paneltiminginfo->dsi_mdp_trigger;
254 pinfo->mipi.dma_trigger = pstruct->paneltiminginfo->dsi_dma_trigger;
Kuogee Hsiehe0fbc022015-07-07 10:26:58 -0700255 pinfo->fbc.comp_ratio = 1;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700256
Kuogee Hsiehe0fbc022015-07-07 10:26:58 -0700257 if (pinfo->compression_mode == COMPRESSION_DSC) {
Ujwal Patel41a665a2015-07-17 13:51:30 -0700258 struct dsc_desc *dsc = &pinfo->dsc;
259 struct dsc_parameters *dsc_params = NULL;
Kuogee Hsiehe0fbc022015-07-07 10:26:58 -0700260
Ujwal Patel41a665a2015-07-17 13:51:30 -0700261 if (!pstruct->config) {
262 dprintf(CRITICAL, "ERROR: DSC cannot be used without topology_config\n");
263 return ERR_NOT_ALLOWED;
264 }
265 dsc_params = pstruct->config->dsc;
266 if (!dsc_params) {
267 dprintf(CRITICAL, "ERROR: DSC params are NULL\n");
268 return ERR_INVALID_ARGS;
269 }
Kuogee Hsiehe0fbc022015-07-07 10:26:58 -0700270
Ujwal Patel41a665a2015-07-17 13:51:30 -0700271 dsc->major = dsc_params->major;
272 dsc->minor = dsc_params->minor;
Dhaval Patelc4135d82016-03-30 17:40:53 -0700273 dsc->scr_rev = dsc_params->scr_rev;
Ujwal Patel41a665a2015-07-17 13:51:30 -0700274 dsc->pps_id = dsc_params->pps_id;
275 dsc->slice_height = dsc_params->slice_height;
276 dsc->slice_width = dsc_params->slice_width;
277 dsc->bpp = dsc_params->bpp;
278 dsc->bpc = dsc_params->bpc;
279 dsc->slice_per_pkt = dsc_params->slice_per_pkt;
Ujwal Patel41a665a2015-07-17 13:51:30 -0700280 dsc->block_pred_enable = dsc_params->block_prediction;
281 dsc->enable_422 = 0;
282 dsc->convert_rgb = 1;
283 dsc->vbr_enable = 0;
284
285 if (dsc->parameter_calc)
286 dsc->parameter_calc(pinfo);
Kuogee Hsiehe0fbc022015-07-07 10:26:58 -0700287 } else if (pinfo->compression_mode == COMPRESSION_FBC) {
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700288 pinfo->fbc.enabled = pstruct->fbcinfo.enabled;
Kuogee Hsiehe0fbc022015-07-07 10:26:58 -0700289 if (pinfo->fbc.enabled) {
290 pinfo->fbc.comp_ratio= pstruct->fbcinfo.comp_ratio;
291 pinfo->fbc.comp_mode = pstruct->fbcinfo.comp_mode;
292 pinfo->fbc.qerr_enable = pstruct->fbcinfo.qerr_enable;
293 pinfo->fbc.cd_bias = pstruct->fbcinfo.cd_bias;
294 pinfo->fbc.pat_enable = pstruct->fbcinfo.pat_enable;
295 pinfo->fbc.vlc_enable = pstruct->fbcinfo.vlc_enable;
296 pinfo->fbc.bflc_enable = pstruct->fbcinfo.bflc_enable;
297 pinfo->fbc.line_x_budget = pstruct->fbcinfo.line_x_budget;
298 pinfo->fbc.block_x_budget = pstruct->fbcinfo.block_x_budget;
299 pinfo->fbc.block_budget = pstruct->fbcinfo.block_budget;
300 pinfo->fbc.lossless_mode_thd = pstruct->fbcinfo.lossless_mode_thd;
301 pinfo->fbc.lossy_mode_thd = pstruct->fbcinfo.lossy_mode_thd;
302 pinfo->fbc.lossy_rgb_thd = pstruct->fbcinfo.lossy_rgb_thd;
303 pinfo->fbc.lossy_mode_idx = pstruct->fbcinfo.lossy_mode_idx;
304 pinfo->fbc.slice_height = pstruct->fbcinfo.slice_height;
305 pinfo->fbc.pred_mode = pstruct->fbcinfo.pred_mode;
306 pinfo->fbc.max_pred_err = pstruct->fbcinfo.max_pred_err;
307 }
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700308 }
309
Dhaval Patelb22f1bc2013-10-25 13:56:26 -0700310 pinfo->pre_on = dsi_panel_pre_on;
311 pinfo->pre_off = dsi_panel_pre_off;
312 pinfo->on = dsi_panel_post_on;
313 pinfo->off = dsi_panel_post_off;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700314 pinfo->rotate = dsi_panel_rotation;
315 pinfo->config = dsi_panel_config;
316
317 return NO_ERROR;
318}
319
320/*---------------------------------------------------------------------------*/
321/* Panel Callbacks */
322/*---------------------------------------------------------------------------*/
323
Dhaval Patelb22f1bc2013-10-25 13:56:26 -0700324int dsi_panel_pre_on()
Arpita Banerjee841fa062013-05-24 14:59:51 -0700325{
Dhaval Patelb22f1bc2013-10-25 13:56:26 -0700326 return target_display_pre_on();
327}
328
329int dsi_panel_pre_off()
330{
331 return target_display_pre_off();
332}
333
334int dsi_panel_post_on()
335{
336 int ret = NO_ERROR;
337
338 ret = target_display_post_on();
339 if (ret)
340 return ret;
341
Arpita Banerjee841fa062013-05-24 14:59:51 -0700342 return oem_panel_on();
343}
344
Dhaval Patelb22f1bc2013-10-25 13:56:26 -0700345int dsi_panel_post_off()
Arpita Banerjee841fa062013-05-24 14:59:51 -0700346{
Dhaval Patelb22f1bc2013-10-25 13:56:26 -0700347 int ret = NO_ERROR;
348
349 ret = target_display_post_off();
350 if (ret)
351 return ret;
352
Arpita Banerjee841fa062013-05-24 14:59:51 -0700353 return oem_panel_off();
354}
355
356int dsi_panel_rotation()
357{
358 return oem_panel_rotation();
359}
360
361int dsi_video_panel_config(struct msm_panel_info *pinfo,
362 struct lcdc_panel_info *plcdc
363 )
364{
365 int ret = NO_ERROR;
366 uint8_t lane_enable = 0;
367 uint32_t panel_width = pinfo->xres;
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700368 uint32_t final_xres, final_yres, final_width;
369 uint32_t final_height, final_hbp, final_hfp,final_vbp;
Padmanabhan Komandurue3209872015-01-12 16:33:16 +0530370 uint32_t final_vfp, final_hpw, final_vpw, low_pwr_stop;
Kuogee Hsiehe0fbc022015-07-07 10:26:58 -0700371 struct dsc_desc *dsc = NULL;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700372
373 if (pinfo->mipi.dual_dsi)
374 panel_width = panel_width / 2;
375
Xiaoming Zhou7e0b1e62013-07-29 15:49:39 -0400376 if (pinfo->mipi.data_lane0)
377 lane_enable |= (1 << 0);
378 if (pinfo->mipi.data_lane1)
379 lane_enable |= (1 << 1);
380 if (pinfo->mipi.data_lane2)
381 lane_enable |= (1 << 2);
382 if (pinfo->mipi.data_lane3)
383 lane_enable |= (1 << 3);
Arpita Banerjee841fa062013-05-24 14:59:51 -0700384
Kuogee Hsiehe0fbc022015-07-07 10:26:58 -0700385 if (pinfo->compression_mode == COMPRESSION_DSC) {
386 dsc = &pinfo->dsc;
387 panel_width = dsc->pclk_per_line;
388 }
389
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700390 final_xres = panel_width;
391 final_width = panel_width + pinfo->lcdc.xres_pad;
392
393 if (pinfo->fbc.enabled && pinfo->fbc.comp_ratio) {
394 final_xres /= pinfo->fbc.comp_ratio;
395 final_width /= pinfo->fbc.comp_ratio;
Kuogee Hsiehe0fbc022015-07-07 10:26:58 -0700396 dprintf(SPEW, "DSI xres =%d final_width=%d\n",
397 final_xres, final_width);
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700398 }
399 final_yres = pinfo->yres;
400 final_height = pinfo->yres + pinfo->lcdc.yres_pad;
401 final_hbp = pinfo->lcdc.h_back_porch;
402 final_hfp = pinfo->lcdc.h_front_porch;
403 final_vbp = pinfo->lcdc.v_back_porch;
404 final_vfp = pinfo->lcdc.v_front_porch;
405 final_hpw = pinfo->lcdc.h_pulse_width;
406 final_vpw = pinfo->lcdc.v_pulse_width;
Padmanabhan Komandurue3209872015-01-12 16:33:16 +0530407 low_pwr_stop = (pinfo->mipi.hfp_power_stop << 8) |
408 (pinfo->mipi.hbp_power_stop << 4) |
409 pinfo->mipi.hsa_power_stop;
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700410
Kuogee Hsiehe0fbc022015-07-07 10:26:58 -0700411 ret = mdss_dsi_video_mode_config(pinfo,
412 final_width, final_height,
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700413 final_xres, final_yres,
414 final_hfp, final_hbp + final_hpw,
415 final_vfp, final_vbp + final_vpw,
416 final_hpw, final_vpw,
Arpita Banerjee841fa062013-05-24 14:59:51 -0700417 pinfo->mipi.dst_format,
418 pinfo->mipi.traffic_mode,
419 lane_enable,
Padmanabhan Komandurue3209872015-01-12 16:33:16 +0530420 pinfo->mipi.pulse_mode_hsa_he,
421 low_pwr_stop,
Arpita Banerjee841fa062013-05-24 14:59:51 -0700422 pinfo->mipi.eof_bllp_power,
423 pinfo->mipi.interleave_mode,
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -0800424 pinfo->mipi.ctl_base);
Arpita Banerjee841fa062013-05-24 14:59:51 -0700425
426 if (pinfo->mipi.dual_dsi)
Kuogee Hsiehe0fbc022015-07-07 10:26:58 -0700427 ret = mdss_dsi_video_mode_config(pinfo,
428 final_width, final_height,
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700429 final_xres, final_yres,
430 final_hfp, final_hbp + final_hpw,
431 final_vfp, final_vbp + final_vpw,
432 final_hpw, final_vpw,
433 pinfo->mipi.dst_format,
434 pinfo->mipi.traffic_mode,
435 lane_enable,
Padmanabhan Komandurue3209872015-01-12 16:33:16 +0530436 pinfo->mipi.pulse_mode_hsa_he,
437 low_pwr_stop,
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700438 pinfo->mipi.eof_bllp_power,
439 pinfo->mipi.interleave_mode,
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -0800440 pinfo->mipi.sctl_base);
Arpita Banerjee841fa062013-05-24 14:59:51 -0700441
442 return ret;
443}
444
445int dsi_cmd_panel_config (struct msm_panel_info *pinfo,
446 struct lcdc_panel_info *plcdc)
447{
448 int ret = NO_ERROR;
Xiaoming Zhou7e0b1e62013-07-29 15:49:39 -0400449 uint8_t lane_en = 0;
450 uint8_t ystride = pinfo->bpp / 8;
Dhaval Patelea19a1e2014-01-02 16:17:26 -0800451 uint32_t panel_width = pinfo->xres;
Aravind Venkateswaran5cfdbc72014-12-03 16:06:45 -0800452 uint32_t final_xres, final_yres, final_width;
453 uint32_t final_height;
Kuogee Hsiehe0fbc022015-07-07 10:26:58 -0700454 struct dsc_desc *dsc = NULL;
Dhaval Patelea19a1e2014-01-02 16:17:26 -0800455
456 if (pinfo->mipi.dual_dsi)
457 panel_width = panel_width / 2;
Xiaoming Zhou7e0b1e62013-07-29 15:49:39 -0400458
459 if (pinfo->mipi.data_lane0)
460 lane_en |= (1 << 0);
461 if (pinfo->mipi.data_lane1)
462 lane_en |= (1 << 1);
463 if (pinfo->mipi.data_lane2)
464 lane_en |= (1 << 2);
465 if (pinfo->mipi.data_lane3)
466 lane_en |= (1 << 3);
Arpita Banerjee841fa062013-05-24 14:59:51 -0700467
Kuogee Hsiehe0fbc022015-07-07 10:26:58 -0700468 if (pinfo->compression_mode == COMPRESSION_DSC) {
469 dsc = &pinfo->dsc;
470 panel_width = dsc->pclk_per_line;
471 }
472
Aravind Venkateswaran5cfdbc72014-12-03 16:06:45 -0800473 final_xres = panel_width;
474 final_width = panel_width + pinfo->lcdc.xres_pad;
475
Kuogee Hsiehe0fbc022015-07-07 10:26:58 -0700476 if (pinfo->compression_mode == COMPRESSION_FBC) {
477 if (pinfo->fbc.enabled && pinfo->fbc.comp_ratio) {
478 final_xres /= pinfo->fbc.comp_ratio;
479 final_width /= pinfo->fbc.comp_ratio;
480 dprintf(SPEW, "DSI xres =%d final_width=%d\n",
481 final_xres, final_width);
482 }
Aravind Venkateswaran5cfdbc72014-12-03 16:06:45 -0800483 }
484 final_yres = pinfo->yres;
485 final_height = pinfo->yres + pinfo->lcdc.yres_pad;
486
Kuogee Hsiehd58c8092015-07-07 10:31:34 -0700487 ret = mdss_dsi_cmd_mode_config(pinfo, final_width, final_height,
Aravind Venkateswaran5cfdbc72014-12-03 16:06:45 -0800488 final_xres, final_yres,
Xiaoming Zhou7e0b1e62013-07-29 15:49:39 -0400489 pinfo->mipi.dst_format,
490 ystride, lane_en,
Dhaval Patelea19a1e2014-01-02 16:17:26 -0800491 pinfo->mipi.interleave_mode,
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -0800492 pinfo->mipi.ctl_base);
Dhaval Patelea19a1e2014-01-02 16:17:26 -0800493
494 if (pinfo->mipi.dual_dsi)
Kuogee Hsiehd58c8092015-07-07 10:31:34 -0700495 ret = mdss_dsi_cmd_mode_config(pinfo, final_width, final_height,
Aravind Venkateswaran5cfdbc72014-12-03 16:06:45 -0800496 final_xres, final_yres,
497 pinfo->mipi.dst_format,
498 ystride, lane_en,
499 pinfo->mipi.interleave_mode,
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -0800500 pinfo->mipi.sctl_base);
Arpita Banerjee841fa062013-05-24 14:59:51 -0700501
502 return ret;
503}
504
505
506int dsi_panel_config(void *pdata)
507{
508 int ret = NO_ERROR;
509 struct msm_panel_info *pinfo = (struct msm_panel_info *)pdata;
510 struct lcdc_panel_info *plcdc = NULL;
511
512 if (pinfo == NULL)
513 return ERR_INVALID_ARGS;
514
515 plcdc = &(pinfo->lcdc);
516 if (plcdc == NULL)
517 return ERR_INVALID_ARGS;
518
519
520 if (pinfo->mipi.mode == DSI_VIDEO_MODE) {
521 ret = dsi_video_panel_config(pinfo, plcdc);
522 } else {
523 ret = dsi_cmd_panel_config(pinfo, plcdc);
524 }
525
526 return ret;
527}
Dhaval Patel551f7f62014-02-18 17:13:00 -0800528
529int32_t panel_name_to_id(struct panel_list supp_panels[],
530 uint32_t supp_panels_size,
531 const char *panel_name)
532{
533 uint32_t i;
534 int32_t panel_id = ERR_NOT_FOUND;
535
536 if (!panel_name) {
537 dprintf(CRITICAL, "Invalid panel name\n");
538 return panel_id;
539 }
540
Dhaval Patel551f7f62014-02-18 17:13:00 -0800541 for (i = 0; i < supp_panels_size; i++) {
542 if (!strncmp(panel_name, supp_panels[i].name,
543 MAX_PANEL_ID_LEN)) {
544 panel_id = supp_panels[i].id;
545 break;
546 }
547 }
548
549 return panel_id;
550}