blob: d258db2f09363607cdc99c477898a4a0cb64ce99 [file] [log] [blame]
Jeevan Shriram01379322015-01-07 17:41:26 -08001/* Copyright (c) 2013-2015, 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{
Jeevan Shriram04c15b62015-01-08 13:16:18 -080058 int base_offset = 0, base1_offset = 0;
59
60 /*
61 * Base offsets may vary for few platforms. Add the difference to get
62 * proper base offset for the respective platform.
63 */
64 base_offset = dsi_platform_base_offset_adjust(MIPI_DSI0_BASE);
65 base1_offset = dsi_platform_base_offset_adjust(MIPI_DSI1_BASE);
66 dprintf(SPEW, "base offset = %d, %x\n", base_offset, base_offset);
67
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -080068 if (!strcmp(panel_destination, "DISPLAY_1")) {
69 pinfo->dest = DISPLAY_1;
Jeevan Shriram04c15b62015-01-08 13:16:18 -080070 pinfo->mipi.ctl_base = MIPI_DSI0_BASE + base_offset;
71 pinfo->mipi.phy_base = DSI0_PHY_BASE + base_offset;
72 pinfo->mipi.sctl_base = MIPI_DSI1_BASE + base1_offset;
73 pinfo->mipi.sphy_base = DSI1_PHY_BASE + base1_offset;
Padmanabhan Komanduruc0766c82015-04-27 16:39:15 -070074 if (pinfo->mipi.use_dsi1_pll) {
75 dprintf(CRITICAL, "%s: Invalid combination: DSI0 controller + DSI1 PLL, using DSI0 PLL\n",
76 __func__);
77 pinfo->mipi.use_dsi1_pll = 0;
78 }
79 pinfo->mipi.pll_base = DSI0_PLL_BASE + base_offset;
80 pinfo->mipi.spll_base = DSI1_PLL_BASE + base1_offset;
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -080081 } else if (!strcmp(panel_destination, "DISPLAY_2")) {
82 pinfo->dest = DISPLAY_2;
Jeevan Shriram04c15b62015-01-08 13:16:18 -080083 pinfo->mipi.ctl_base = MIPI_DSI1_BASE + base1_offset;
84 pinfo->mipi.phy_base = DSI1_PHY_BASE + base1_offset;
85 pinfo->mipi.sctl_base = MIPI_DSI0_BASE + base_offset;
86 pinfo->mipi.sphy_base = DSI0_PHY_BASE + base_offset;
Padmanabhan Komanduruc0766c82015-04-27 16:39:15 -070087 if (pinfo->mipi.use_dsi1_pll) {
88 pinfo->mipi.pll_base = DSI1_PLL_BASE + base1_offset;
89 pinfo->mipi.spll_base = DSI0_PLL_BASE + base_offset;
90 } else {
91 pinfo->mipi.pll_base = DSI0_PLL_BASE + base_offset;
92 pinfo->mipi.spll_base = DSI1_PLL_BASE + base1_offset;
93 }
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -080094 } else {
95 pinfo->dest = DISPLAY_UNKNOWN;
96 dprintf(CRITICAL, "%s: Unkown panel destination: %d\n",
97 __func__, pinfo->dest);
98 return ERROR;
99 }
100
Jeevan Shriram01379322015-01-07 17:41:26 -0800101 /* Both DSI0 and DSI1 use the same regulator */
Jeevan Shriram04c15b62015-01-08 13:16:18 -0800102 pinfo->mipi.reg_base = DSI0_REGULATOR_BASE + base_offset;
103 pinfo->mipi.sreg_base = DSI0_REGULATOR_BASE + base_offset;
Jeevan Shriram01379322015-01-07 17:41:26 -0800104
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -0800105 dprintf(SPEW, "%s: panel dest=%s, ctl_base=0x%08x, phy_base=0x%08x\n",
106 __func__, panel_destination, pinfo->mipi.ctl_base,
107 pinfo->mipi.phy_base);
Padmanabhan Komanduruc0766c82015-04-27 16:39:15 -0700108 dprintf(SPEW, "pll_base=%08x, spll_base=0x%08x, reg_base=0x%08x, sreg_base=%08x\n",
109 pinfo->mipi.pll_base, pinfo->mipi.spll_base,
Jeevan Shriram01379322015-01-07 17:41:26 -0800110 pinfo->mipi.reg_base, pinfo->mipi.sreg_base);
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -0800111 return NO_ERROR;
112}
113
Arpita Banerjee841fa062013-05-24 14:59:51 -0700114/*---------------------------------------------------------------------------*/
115/* Panel Init */
116/*---------------------------------------------------------------------------*/
117int dsi_panel_init(struct msm_panel_info *pinfo,
118 struct panel_struct *pstruct)
119{
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -0800120 int ret = NO_ERROR;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700121 /* Resolution setting*/
122 pinfo->xres = pstruct->panelres->panel_width;
123 pinfo->yres = pstruct->panelres->panel_height;
124 pinfo->lcdc.h_back_porch = pstruct->panelres->hback_porch;
125 pinfo->lcdc.h_front_porch = pstruct->panelres->hfront_porch;
126 pinfo->lcdc.h_pulse_width = pstruct->panelres->hpulse_width;
127 pinfo->lcdc.v_back_porch = pstruct->panelres->vback_porch;
128 pinfo->lcdc.v_front_porch = pstruct->panelres->vfront_porch;
129 pinfo->lcdc.v_pulse_width = pstruct->panelres->vpulse_width;
130 pinfo->lcdc.hsync_skew = pstruct->panelres->hsync_skew;
Kuogee Hsieh31b4ff92014-10-22 14:55:42 -0700131
132 pinfo->border_top = pstruct->panelres->vtop_border;
133 pinfo->border_bottom = pstruct->panelres->vbottom_border;
134 pinfo->border_left = pstruct->panelres->hleft_border;
135 pinfo->border_right = pstruct->panelres->hright_border;
136
137 dprintf(SPEW, "%s: left=%d right=%d top=%d bottom=%d\n", __func__,
138 pinfo->border_left, pinfo->border_right,
139 pinfo->border_top, pinfo->border_bottom);
140
141 pinfo->xres += (pinfo->border_left + pinfo->border_right);
142 pinfo->yres += (pinfo->border_top + pinfo->border_bottom);
Arpita Banerjee841fa062013-05-24 14:59:51 -0700143
Dhaval Patelee8675a2013-10-25 10:07:57 -0700144 if (pstruct->paneldata->panel_operating_mode & DUAL_PIPE_FLAG)
145 pinfo->lcdc.dual_pipe = 1;
146 if (pstruct->paneldata->panel_operating_mode & PIPE_SWAP_FLAG)
147 pinfo->lcdc.pipe_swap = 1;
148 if (pstruct->paneldata->panel_operating_mode & SPLIT_DISPLAY_FLAG)
149 pinfo->lcdc.split_display = 1;
Vineet Bajaj4effb132014-07-24 16:55:41 +0530150 if (pstruct->paneldata->panel_operating_mode & DST_SPLIT_FLAG)
151 pinfo->lcdc.dst_split = 1;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700152
153 /* Color setting*/
154 pinfo->lcdc.border_clr = pstruct->color->border_color;
155 pinfo->lcdc.underflow_clr = pstruct->color->underflow_color;
156 pinfo->mipi.rgb_swap = pstruct->color->color_order;
Jeevan Shriram2dd40cf2014-05-12 16:59:13 -0700157 pinfo->bpp = pstruct->color->color_format;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700158 switch (pinfo->bpp) {
159 case BPP_16:
160 pinfo->mipi.dst_format = DSI_VIDEO_DST_FORMAT_RGB565;
161 break;
162 case BPP_18:
163 if (pstruct->color->pixel_packing)
164 pinfo->mipi.dst_format
165 = DSI_VIDEO_DST_FORMAT_RGB666_LOOSE;
166 else
167 pinfo->mipi.dst_format
168 = DSI_VIDEO_DST_FORMAT_RGB666;
169 break;
170 case BPP_24:
171 default:
172 pinfo->mipi.dst_format = DSI_VIDEO_DST_FORMAT_RGB888;
173 break;
174 }
175
176 /* Panel generic info */
177 pinfo->mipi.mode = pstruct->paneldata->panel_type;
178 if (pinfo->mipi.mode) {
179 pinfo->type = MIPI_CMD_PANEL;
180 } else {
181 pinfo->type = MIPI_VIDEO_PANEL;
182 }
Arpita Banerjee841fa062013-05-24 14:59:51 -0700183 pinfo->clk_rate = pstruct->paneldata->panel_clockrate;
Prashant Nukala64eeff92014-07-11 07:35:34 +0530184 pinfo->orientation = pstruct->paneldata->panel_orientation;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700185 pinfo->mipi.interleave_mode = pstruct->paneldata->interleave_mode;
Dhaval Patelee8675a2013-10-25 10:07:57 -0700186 pinfo->mipi.broadcast = pstruct->paneldata->panel_broadcast_mode;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700187 pinfo->mipi.vc = pstruct->paneldata->dsi_virtualchannel_id;
188 pinfo->mipi.frame_rate = pstruct->paneldata->panel_framerate;
189 pinfo->mipi.stream = pstruct->paneldata->dsi_stream;
Dhaval Patelee8675a2013-10-25 10:07:57 -0700190 if (pstruct->paneldata->panel_operating_mode & DUAL_DSI_FLAG)
191 pinfo->mipi.dual_dsi = 1;
Padmanabhan Komanduruc0766c82015-04-27 16:39:15 -0700192 if (pstruct->paneldata->panel_operating_mode & USE_DSI1_PLL_FLAG)
193 pinfo->mipi.use_dsi1_pll = 1;
Dhaval Patel29f24492013-08-08 20:45:42 -0700194 pinfo->mipi.mode_gpio_state = pstruct->paneldata->mode_gpio_state;
Arpita Banerjeeda0c39a2013-05-24 16:12:45 -0700195 pinfo->mipi.bitclock = pstruct->paneldata->panel_bitclock_freq;
Aravind Venkateswaran31119842015-01-13 14:46:04 -0800196 if (pinfo->mipi.bitclock) {
197 /* panel_clockrate is depcrated in favor of bitclock_freq */
198 pinfo->clk_rate = pinfo->mipi.bitclock;
199 }
Aravind Venkateswaran1e31c782013-11-04 17:32:14 -0800200 pinfo->mipi.use_enable_gpio =
201 pstruct->paneldata->panel_with_enable_gpio;
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -0800202 ret = dsi_panel_ctl_base_setup(pinfo,
203 pstruct->paneldata->panel_destination);
204 if (ret)
205 return ret;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700206
207 /* Video Panel configuration */
208 pinfo->mipi.pulse_mode_hsa_he = pstruct->videopanel->hsync_pulse;
209 pinfo->mipi.hfp_power_stop = pstruct->videopanel->hfp_power_mode;
210 pinfo->mipi.hbp_power_stop = pstruct->videopanel->hbp_power_mode;
211 pinfo->mipi.hsa_power_stop = pstruct->videopanel->hsa_power_mode;
212 pinfo->mipi.eof_bllp_power_stop
213 = pstruct->videopanel->bllp_eof_power_mode;
214 pinfo->mipi.bllp_power_stop = pstruct->videopanel->bllp_power_mode;
215 pinfo->mipi.traffic_mode = pstruct->videopanel->traffic_mode;
216 pinfo->mipi.eof_bllp_power = pstruct->videopanel->bllp_eof_power;
217
218 /* Command Panel configuratoin */
219 pinfo->mipi.insert_dcs_cmd = pstruct->commandpanel->tedcs_command;
220 pinfo->mipi.wr_mem_continue
221 = pstruct->commandpanel->tevsync_continue_lines;
222 pinfo->mipi.wr_mem_start
223 = pstruct->commandpanel->tevsync_rdptr_irqline;
224 pinfo->mipi.te_sel = pstruct->commandpanel->tepin_select;
225
226 /* Data lane configuraiton */
227 pinfo->mipi.num_of_lanes = pstruct->laneconfig->dsi_lanes;
228 pinfo->mipi.data_lane0 = pstruct->laneconfig->lane0_state;
229 pinfo->mipi.data_lane1 = pstruct->laneconfig->lane1_state;
230 pinfo->mipi.data_lane2 = pstruct->laneconfig->lane2_state;
231 pinfo->mipi.data_lane3 = pstruct->laneconfig->lane3_state;
232 pinfo->mipi.lane_swap = pstruct->laneconfig->dsi_lanemap;
Ray Zhang0d303af2015-01-21 10:17:02 +0800233 pinfo->mipi.force_clk_lane_hs = pstruct->laneconfig->force_clk_lane_hs;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700234
235 pinfo->mipi.t_clk_post = pstruct->paneltiminginfo->tclk_post;
236 pinfo->mipi.t_clk_pre = pstruct->paneltiminginfo->tclk_pre;
237 pinfo->mipi.mdp_trigger = pstruct->paneltiminginfo->dsi_mdp_trigger;
238 pinfo->mipi.dma_trigger = pstruct->paneltiminginfo->dsi_dma_trigger;
239
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700240 pinfo->fbc.enabled = pstruct->fbcinfo.enabled;
241 if (pinfo->fbc.enabled) {
242 pinfo->fbc.enabled = pstruct->fbcinfo.enabled;
243 pinfo->fbc.comp_ratio= pstruct->fbcinfo.comp_ratio;
244 pinfo->fbc.comp_mode = pstruct->fbcinfo.comp_mode;
245 pinfo->fbc.qerr_enable = pstruct->fbcinfo.qerr_enable;
246 pinfo->fbc.cd_bias = pstruct->fbcinfo.cd_bias;
247 pinfo->fbc.pat_enable = pstruct->fbcinfo.pat_enable;
248 pinfo->fbc.vlc_enable = pstruct->fbcinfo.vlc_enable;
249 pinfo->fbc.bflc_enable = pstruct->fbcinfo.bflc_enable;
250 pinfo->fbc.line_x_budget = pstruct->fbcinfo.line_x_budget;
251 pinfo->fbc.block_x_budget = pstruct->fbcinfo.block_x_budget;
252 pinfo->fbc.block_budget = pstruct->fbcinfo.block_budget;
253 pinfo->fbc.lossless_mode_thd = pstruct->fbcinfo.lossless_mode_thd;
254 pinfo->fbc.lossy_mode_thd = pstruct->fbcinfo.lossy_mode_thd;
255 pinfo->fbc.lossy_rgb_thd = pstruct->fbcinfo.lossy_rgb_thd;
256 pinfo->fbc.lossy_mode_idx = pstruct->fbcinfo.lossy_mode_idx;
Jeevan Shriram1b07e372014-11-30 22:03:50 -0800257 pinfo->fbc.slice_height = pstruct->fbcinfo.slice_height;
258 pinfo->fbc.pred_mode = pstruct->fbcinfo.pred_mode;
259 pinfo->fbc.max_pred_err = pstruct->fbcinfo.max_pred_err;
260
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700261 } else {
262 pinfo->fbc.comp_ratio = 1;
263 }
264
Dhaval Patelb22f1bc2013-10-25 13:56:26 -0700265 pinfo->pre_on = dsi_panel_pre_on;
266 pinfo->pre_off = dsi_panel_pre_off;
267 pinfo->on = dsi_panel_post_on;
268 pinfo->off = dsi_panel_post_off;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700269 pinfo->rotate = dsi_panel_rotation;
270 pinfo->config = dsi_panel_config;
271
272 return NO_ERROR;
273}
274
275/*---------------------------------------------------------------------------*/
276/* Panel Callbacks */
277/*---------------------------------------------------------------------------*/
278
Dhaval Patelb22f1bc2013-10-25 13:56:26 -0700279int dsi_panel_pre_on()
Arpita Banerjee841fa062013-05-24 14:59:51 -0700280{
Dhaval Patelb22f1bc2013-10-25 13:56:26 -0700281 return target_display_pre_on();
282}
283
284int dsi_panel_pre_off()
285{
286 return target_display_pre_off();
287}
288
289int dsi_panel_post_on()
290{
291 int ret = NO_ERROR;
292
293 ret = target_display_post_on();
294 if (ret)
295 return ret;
296
Arpita Banerjee841fa062013-05-24 14:59:51 -0700297 return oem_panel_on();
298}
299
Dhaval Patelb22f1bc2013-10-25 13:56:26 -0700300int dsi_panel_post_off()
Arpita Banerjee841fa062013-05-24 14:59:51 -0700301{
Dhaval Patelb22f1bc2013-10-25 13:56:26 -0700302 int ret = NO_ERROR;
303
304 ret = target_display_post_off();
305 if (ret)
306 return ret;
307
Arpita Banerjee841fa062013-05-24 14:59:51 -0700308 return oem_panel_off();
309}
310
311int dsi_panel_rotation()
312{
313 return oem_panel_rotation();
314}
315
316int dsi_video_panel_config(struct msm_panel_info *pinfo,
317 struct lcdc_panel_info *plcdc
318 )
319{
320 int ret = NO_ERROR;
321 uint8_t lane_enable = 0;
322 uint32_t panel_width = pinfo->xres;
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700323 uint32_t final_xres, final_yres, final_width;
324 uint32_t final_height, final_hbp, final_hfp,final_vbp;
Padmanabhan Komandurue3209872015-01-12 16:33:16 +0530325 uint32_t final_vfp, final_hpw, final_vpw, low_pwr_stop;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700326
327 if (pinfo->mipi.dual_dsi)
328 panel_width = panel_width / 2;
329
Xiaoming Zhou7e0b1e62013-07-29 15:49:39 -0400330 if (pinfo->mipi.data_lane0)
331 lane_enable |= (1 << 0);
332 if (pinfo->mipi.data_lane1)
333 lane_enable |= (1 << 1);
334 if (pinfo->mipi.data_lane2)
335 lane_enable |= (1 << 2);
336 if (pinfo->mipi.data_lane3)
337 lane_enable |= (1 << 3);
Arpita Banerjee841fa062013-05-24 14:59:51 -0700338
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700339 final_xres = panel_width;
340 final_width = panel_width + pinfo->lcdc.xres_pad;
341
342 if (pinfo->fbc.enabled && pinfo->fbc.comp_ratio) {
343 final_xres /= pinfo->fbc.comp_ratio;
344 final_width /= pinfo->fbc.comp_ratio;
345 dprintf(SPEW, "DSI xres =%d final_width=%d\n", final_xres,
346 final_width);
347 }
348 final_yres = pinfo->yres;
349 final_height = pinfo->yres + pinfo->lcdc.yres_pad;
350 final_hbp = pinfo->lcdc.h_back_porch;
351 final_hfp = pinfo->lcdc.h_front_porch;
352 final_vbp = pinfo->lcdc.v_back_porch;
353 final_vfp = pinfo->lcdc.v_front_porch;
354 final_hpw = pinfo->lcdc.h_pulse_width;
355 final_vpw = pinfo->lcdc.v_pulse_width;
Padmanabhan Komandurue3209872015-01-12 16:33:16 +0530356 low_pwr_stop = (pinfo->mipi.hfp_power_stop << 8) |
357 (pinfo->mipi.hbp_power_stop << 4) |
358 pinfo->mipi.hsa_power_stop;
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700359
360 ret = mdss_dsi_video_mode_config(final_width, final_height,
361 final_xres, final_yres,
362 final_hfp, final_hbp + final_hpw,
363 final_vfp, final_vbp + final_vpw,
364 final_hpw, final_vpw,
Arpita Banerjee841fa062013-05-24 14:59:51 -0700365 pinfo->mipi.dst_format,
366 pinfo->mipi.traffic_mode,
367 lane_enable,
Padmanabhan Komandurue3209872015-01-12 16:33:16 +0530368 pinfo->mipi.pulse_mode_hsa_he,
369 low_pwr_stop,
Arpita Banerjee841fa062013-05-24 14:59:51 -0700370 pinfo->mipi.eof_bllp_power,
371 pinfo->mipi.interleave_mode,
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -0800372 pinfo->mipi.ctl_base);
Arpita Banerjee841fa062013-05-24 14:59:51 -0700373
374 if (pinfo->mipi.dual_dsi)
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700375 ret = mdss_dsi_video_mode_config(final_width, final_height,
376 final_xres, final_yres,
377 final_hfp, final_hbp + final_hpw,
378 final_vfp, final_vbp + final_vpw,
379 final_hpw, final_vpw,
380 pinfo->mipi.dst_format,
381 pinfo->mipi.traffic_mode,
382 lane_enable,
Padmanabhan Komandurue3209872015-01-12 16:33:16 +0530383 pinfo->mipi.pulse_mode_hsa_he,
384 low_pwr_stop,
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700385 pinfo->mipi.eof_bllp_power,
386 pinfo->mipi.interleave_mode,
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -0800387 pinfo->mipi.sctl_base);
Arpita Banerjee841fa062013-05-24 14:59:51 -0700388
389 return ret;
390}
391
392int dsi_cmd_panel_config (struct msm_panel_info *pinfo,
393 struct lcdc_panel_info *plcdc)
394{
395 int ret = NO_ERROR;
Xiaoming Zhou7e0b1e62013-07-29 15:49:39 -0400396 uint8_t lane_en = 0;
397 uint8_t ystride = pinfo->bpp / 8;
Dhaval Patelea19a1e2014-01-02 16:17:26 -0800398 uint32_t panel_width = pinfo->xres;
Aravind Venkateswaran5cfdbc72014-12-03 16:06:45 -0800399 uint32_t final_xres, final_yres, final_width;
400 uint32_t final_height;
Dhaval Patelea19a1e2014-01-02 16:17:26 -0800401
402 if (pinfo->mipi.dual_dsi)
403 panel_width = panel_width / 2;
Xiaoming Zhou7e0b1e62013-07-29 15:49:39 -0400404
405 if (pinfo->mipi.data_lane0)
406 lane_en |= (1 << 0);
407 if (pinfo->mipi.data_lane1)
408 lane_en |= (1 << 1);
409 if (pinfo->mipi.data_lane2)
410 lane_en |= (1 << 2);
411 if (pinfo->mipi.data_lane3)
412 lane_en |= (1 << 3);
Arpita Banerjee841fa062013-05-24 14:59:51 -0700413
Aravind Venkateswaran5cfdbc72014-12-03 16:06:45 -0800414 final_xres = panel_width;
415 final_width = panel_width + pinfo->lcdc.xres_pad;
416
417 if (pinfo->fbc.enabled && pinfo->fbc.comp_ratio) {
418 final_xres /= pinfo->fbc.comp_ratio;
419 final_width /= pinfo->fbc.comp_ratio;
420 dprintf(SPEW, "DSI xres =%d final_width=%d\n", final_xres,
421 final_width);
422 }
423 final_yres = pinfo->yres;
424 final_height = pinfo->yres + pinfo->lcdc.yres_pad;
425
426 ret = mdss_dsi_cmd_mode_config(final_width, final_height,
427 final_xres, final_yres,
Xiaoming Zhou7e0b1e62013-07-29 15:49:39 -0400428 pinfo->mipi.dst_format,
429 ystride, lane_en,
Dhaval Patelea19a1e2014-01-02 16:17:26 -0800430 pinfo->mipi.interleave_mode,
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -0800431 pinfo->mipi.ctl_base);
Dhaval Patelea19a1e2014-01-02 16:17:26 -0800432
433 if (pinfo->mipi.dual_dsi)
Aravind Venkateswaran5cfdbc72014-12-03 16:06:45 -0800434 ret = mdss_dsi_cmd_mode_config(final_width, final_height,
435 final_xres, final_yres,
436 pinfo->mipi.dst_format,
437 ystride, lane_en,
438 pinfo->mipi.interleave_mode,
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -0800439 pinfo->mipi.sctl_base);
Arpita Banerjee841fa062013-05-24 14:59:51 -0700440
441 return ret;
442}
443
444
445int dsi_panel_config(void *pdata)
446{
447 int ret = NO_ERROR;
448 struct msm_panel_info *pinfo = (struct msm_panel_info *)pdata;
449 struct lcdc_panel_info *plcdc = NULL;
450
451 if (pinfo == NULL)
452 return ERR_INVALID_ARGS;
453
454 plcdc = &(pinfo->lcdc);
455 if (plcdc == NULL)
456 return ERR_INVALID_ARGS;
457
458
459 if (pinfo->mipi.mode == DSI_VIDEO_MODE) {
460 ret = dsi_video_panel_config(pinfo, plcdc);
461 } else {
462 ret = dsi_cmd_panel_config(pinfo, plcdc);
463 }
464
465 return ret;
466}
Dhaval Patel551f7f62014-02-18 17:13:00 -0800467
468int32_t panel_name_to_id(struct panel_list supp_panels[],
469 uint32_t supp_panels_size,
470 const char *panel_name)
471{
472 uint32_t i;
473 int32_t panel_id = ERR_NOT_FOUND;
474
475 if (!panel_name) {
476 dprintf(CRITICAL, "Invalid panel name\n");
477 return panel_id;
478 }
479
480 /* Remove any leading whitespaces */
481 panel_name += strspn(panel_name, " ");
482 for (i = 0; i < supp_panels_size; i++) {
483 if (!strncmp(panel_name, supp_panels[i].name,
484 MAX_PANEL_ID_LEN)) {
485 panel_id = supp_panels[i].id;
486 break;
487 }
488 }
489
490 return panel_id;
491}