blob: 2555274dca69143019139eb300783a51795c5134 [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{
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
Dhaval Patelee8675a2013-10-25 10:07:57 -0700151 if (pstruct->paneldata->panel_operating_mode & DUAL_PIPE_FLAG)
152 pinfo->lcdc.dual_pipe = 1;
153 if (pstruct->paneldata->panel_operating_mode & PIPE_SWAP_FLAG)
154 pinfo->lcdc.pipe_swap = 1;
155 if (pstruct->paneldata->panel_operating_mode & SPLIT_DISPLAY_FLAG)
156 pinfo->lcdc.split_display = 1;
Vineet Bajaj4effb132014-07-24 16:55:41 +0530157 if (pstruct->paneldata->panel_operating_mode & DST_SPLIT_FLAG)
158 pinfo->lcdc.dst_split = 1;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700159
160 /* Color setting*/
161 pinfo->lcdc.border_clr = pstruct->color->border_color;
162 pinfo->lcdc.underflow_clr = pstruct->color->underflow_color;
163 pinfo->mipi.rgb_swap = pstruct->color->color_order;
Jeevan Shriram2dd40cf2014-05-12 16:59:13 -0700164 pinfo->bpp = pstruct->color->color_format;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700165 switch (pinfo->bpp) {
166 case BPP_16:
167 pinfo->mipi.dst_format = DSI_VIDEO_DST_FORMAT_RGB565;
168 break;
169 case BPP_18:
170 if (pstruct->color->pixel_packing)
171 pinfo->mipi.dst_format
172 = DSI_VIDEO_DST_FORMAT_RGB666_LOOSE;
173 else
174 pinfo->mipi.dst_format
175 = DSI_VIDEO_DST_FORMAT_RGB666;
176 break;
177 case BPP_24:
178 default:
179 pinfo->mipi.dst_format = DSI_VIDEO_DST_FORMAT_RGB888;
180 break;
181 }
182
183 /* Panel generic info */
184 pinfo->mipi.mode = pstruct->paneldata->panel_type;
185 if (pinfo->mipi.mode) {
186 pinfo->type = MIPI_CMD_PANEL;
187 } else {
188 pinfo->type = MIPI_VIDEO_PANEL;
189 }
Arpita Banerjee841fa062013-05-24 14:59:51 -0700190 pinfo->clk_rate = pstruct->paneldata->panel_clockrate;
Prashant Nukala64eeff92014-07-11 07:35:34 +0530191 pinfo->orientation = pstruct->paneldata->panel_orientation;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700192 pinfo->mipi.interleave_mode = pstruct->paneldata->interleave_mode;
Dhaval Patelee8675a2013-10-25 10:07:57 -0700193 pinfo->mipi.broadcast = pstruct->paneldata->panel_broadcast_mode;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700194 pinfo->mipi.vc = pstruct->paneldata->dsi_virtualchannel_id;
195 pinfo->mipi.frame_rate = pstruct->paneldata->panel_framerate;
196 pinfo->mipi.stream = pstruct->paneldata->dsi_stream;
Dhaval Patelee8675a2013-10-25 10:07:57 -0700197 if (pstruct->paneldata->panel_operating_mode & DUAL_DSI_FLAG)
198 pinfo->mipi.dual_dsi = 1;
Padmanabhan Komanduruc0766c82015-04-27 16:39:15 -0700199 if (pstruct->paneldata->panel_operating_mode & USE_DSI1_PLL_FLAG)
200 pinfo->mipi.use_dsi1_pll = 1;
Dhaval Patel29f24492013-08-08 20:45:42 -0700201 pinfo->mipi.mode_gpio_state = pstruct->paneldata->mode_gpio_state;
Arpita Banerjeeda0c39a2013-05-24 16:12:45 -0700202 pinfo->mipi.bitclock = pstruct->paneldata->panel_bitclock_freq;
Aravind Venkateswaran31119842015-01-13 14:46:04 -0800203 if (pinfo->mipi.bitclock) {
204 /* panel_clockrate is depcrated in favor of bitclock_freq */
205 pinfo->clk_rate = pinfo->mipi.bitclock;
206 }
Aravind Venkateswaran1e31c782013-11-04 17:32:14 -0800207 pinfo->mipi.use_enable_gpio =
208 pstruct->paneldata->panel_with_enable_gpio;
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -0800209 ret = dsi_panel_ctl_base_setup(pinfo,
210 pstruct->paneldata->panel_destination);
211 if (ret)
212 return ret;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700213
214 /* Video Panel configuration */
215 pinfo->mipi.pulse_mode_hsa_he = pstruct->videopanel->hsync_pulse;
216 pinfo->mipi.hfp_power_stop = pstruct->videopanel->hfp_power_mode;
217 pinfo->mipi.hbp_power_stop = pstruct->videopanel->hbp_power_mode;
218 pinfo->mipi.hsa_power_stop = pstruct->videopanel->hsa_power_mode;
219 pinfo->mipi.eof_bllp_power_stop
220 = pstruct->videopanel->bllp_eof_power_mode;
221 pinfo->mipi.bllp_power_stop = pstruct->videopanel->bllp_power_mode;
222 pinfo->mipi.traffic_mode = pstruct->videopanel->traffic_mode;
223 pinfo->mipi.eof_bllp_power = pstruct->videopanel->bllp_eof_power;
224
225 /* Command Panel configuratoin */
226 pinfo->mipi.insert_dcs_cmd = pstruct->commandpanel->tedcs_command;
227 pinfo->mipi.wr_mem_continue
228 = pstruct->commandpanel->tevsync_continue_lines;
229 pinfo->mipi.wr_mem_start
230 = pstruct->commandpanel->tevsync_rdptr_irqline;
231 pinfo->mipi.te_sel = pstruct->commandpanel->tepin_select;
232
233 /* Data lane configuraiton */
234 pinfo->mipi.num_of_lanes = pstruct->laneconfig->dsi_lanes;
235 pinfo->mipi.data_lane0 = pstruct->laneconfig->lane0_state;
236 pinfo->mipi.data_lane1 = pstruct->laneconfig->lane1_state;
237 pinfo->mipi.data_lane2 = pstruct->laneconfig->lane2_state;
238 pinfo->mipi.data_lane3 = pstruct->laneconfig->lane3_state;
239 pinfo->mipi.lane_swap = pstruct->laneconfig->dsi_lanemap;
Ray Zhang0d303af2015-01-21 10:17:02 +0800240 pinfo->mipi.force_clk_lane_hs = pstruct->laneconfig->force_clk_lane_hs;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700241
242 pinfo->mipi.t_clk_post = pstruct->paneltiminginfo->tclk_post;
243 pinfo->mipi.t_clk_pre = pstruct->paneltiminginfo->tclk_pre;
244 pinfo->mipi.mdp_trigger = pstruct->paneltiminginfo->dsi_mdp_trigger;
245 pinfo->mipi.dma_trigger = pstruct->paneltiminginfo->dsi_dma_trigger;
246
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700247 pinfo->fbc.enabled = pstruct->fbcinfo.enabled;
248 if (pinfo->fbc.enabled) {
249 pinfo->fbc.enabled = pstruct->fbcinfo.enabled;
250 pinfo->fbc.comp_ratio= pstruct->fbcinfo.comp_ratio;
251 pinfo->fbc.comp_mode = pstruct->fbcinfo.comp_mode;
252 pinfo->fbc.qerr_enable = pstruct->fbcinfo.qerr_enable;
253 pinfo->fbc.cd_bias = pstruct->fbcinfo.cd_bias;
254 pinfo->fbc.pat_enable = pstruct->fbcinfo.pat_enable;
255 pinfo->fbc.vlc_enable = pstruct->fbcinfo.vlc_enable;
256 pinfo->fbc.bflc_enable = pstruct->fbcinfo.bflc_enable;
257 pinfo->fbc.line_x_budget = pstruct->fbcinfo.line_x_budget;
258 pinfo->fbc.block_x_budget = pstruct->fbcinfo.block_x_budget;
259 pinfo->fbc.block_budget = pstruct->fbcinfo.block_budget;
260 pinfo->fbc.lossless_mode_thd = pstruct->fbcinfo.lossless_mode_thd;
261 pinfo->fbc.lossy_mode_thd = pstruct->fbcinfo.lossy_mode_thd;
262 pinfo->fbc.lossy_rgb_thd = pstruct->fbcinfo.lossy_rgb_thd;
263 pinfo->fbc.lossy_mode_idx = pstruct->fbcinfo.lossy_mode_idx;
Jeevan Shriram1b07e372014-11-30 22:03:50 -0800264 pinfo->fbc.slice_height = pstruct->fbcinfo.slice_height;
265 pinfo->fbc.pred_mode = pstruct->fbcinfo.pred_mode;
266 pinfo->fbc.max_pred_err = pstruct->fbcinfo.max_pred_err;
267
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700268 } else {
269 pinfo->fbc.comp_ratio = 1;
270 }
271
Dhaval Patelb22f1bc2013-10-25 13:56:26 -0700272 pinfo->pre_on = dsi_panel_pre_on;
273 pinfo->pre_off = dsi_panel_pre_off;
274 pinfo->on = dsi_panel_post_on;
275 pinfo->off = dsi_panel_post_off;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700276 pinfo->rotate = dsi_panel_rotation;
277 pinfo->config = dsi_panel_config;
278
279 return NO_ERROR;
280}
281
282/*---------------------------------------------------------------------------*/
283/* Panel Callbacks */
284/*---------------------------------------------------------------------------*/
285
Dhaval Patelb22f1bc2013-10-25 13:56:26 -0700286int dsi_panel_pre_on()
Arpita Banerjee841fa062013-05-24 14:59:51 -0700287{
Dhaval Patelb22f1bc2013-10-25 13:56:26 -0700288 return target_display_pre_on();
289}
290
291int dsi_panel_pre_off()
292{
293 return target_display_pre_off();
294}
295
296int dsi_panel_post_on()
297{
298 int ret = NO_ERROR;
299
300 ret = target_display_post_on();
301 if (ret)
302 return ret;
303
Arpita Banerjee841fa062013-05-24 14:59:51 -0700304 return oem_panel_on();
305}
306
Dhaval Patelb22f1bc2013-10-25 13:56:26 -0700307int dsi_panel_post_off()
Arpita Banerjee841fa062013-05-24 14:59:51 -0700308{
Dhaval Patelb22f1bc2013-10-25 13:56:26 -0700309 int ret = NO_ERROR;
310
311 ret = target_display_post_off();
312 if (ret)
313 return ret;
314
Arpita Banerjee841fa062013-05-24 14:59:51 -0700315 return oem_panel_off();
316}
317
318int dsi_panel_rotation()
319{
320 return oem_panel_rotation();
321}
322
323int dsi_video_panel_config(struct msm_panel_info *pinfo,
324 struct lcdc_panel_info *plcdc
325 )
326{
327 int ret = NO_ERROR;
328 uint8_t lane_enable = 0;
329 uint32_t panel_width = pinfo->xres;
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700330 uint32_t final_xres, final_yres, final_width;
331 uint32_t final_height, final_hbp, final_hfp,final_vbp;
Padmanabhan Komandurue3209872015-01-12 16:33:16 +0530332 uint32_t final_vfp, final_hpw, final_vpw, low_pwr_stop;
Arpita Banerjee841fa062013-05-24 14:59:51 -0700333
334 if (pinfo->mipi.dual_dsi)
335 panel_width = panel_width / 2;
336
Xiaoming Zhou7e0b1e62013-07-29 15:49:39 -0400337 if (pinfo->mipi.data_lane0)
338 lane_enable |= (1 << 0);
339 if (pinfo->mipi.data_lane1)
340 lane_enable |= (1 << 1);
341 if (pinfo->mipi.data_lane2)
342 lane_enable |= (1 << 2);
343 if (pinfo->mipi.data_lane3)
344 lane_enable |= (1 << 3);
Arpita Banerjee841fa062013-05-24 14:59:51 -0700345
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700346 final_xres = panel_width;
347 final_width = panel_width + pinfo->lcdc.xres_pad;
348
349 if (pinfo->fbc.enabled && pinfo->fbc.comp_ratio) {
350 final_xres /= pinfo->fbc.comp_ratio;
351 final_width /= pinfo->fbc.comp_ratio;
352 dprintf(SPEW, "DSI xres =%d final_width=%d\n", final_xres,
353 final_width);
354 }
355 final_yres = pinfo->yres;
356 final_height = pinfo->yres + pinfo->lcdc.yres_pad;
357 final_hbp = pinfo->lcdc.h_back_porch;
358 final_hfp = pinfo->lcdc.h_front_porch;
359 final_vbp = pinfo->lcdc.v_back_porch;
360 final_vfp = pinfo->lcdc.v_front_porch;
361 final_hpw = pinfo->lcdc.h_pulse_width;
362 final_vpw = pinfo->lcdc.v_pulse_width;
Padmanabhan Komandurue3209872015-01-12 16:33:16 +0530363 low_pwr_stop = (pinfo->mipi.hfp_power_stop << 8) |
364 (pinfo->mipi.hbp_power_stop << 4) |
365 pinfo->mipi.hsa_power_stop;
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700366
367 ret = mdss_dsi_video_mode_config(final_width, final_height,
368 final_xres, final_yres,
369 final_hfp, final_hbp + final_hpw,
370 final_vfp, final_vbp + final_vpw,
371 final_hpw, final_vpw,
Arpita Banerjee841fa062013-05-24 14:59:51 -0700372 pinfo->mipi.dst_format,
373 pinfo->mipi.traffic_mode,
374 lane_enable,
Padmanabhan Komandurue3209872015-01-12 16:33:16 +0530375 pinfo->mipi.pulse_mode_hsa_he,
376 low_pwr_stop,
Arpita Banerjee841fa062013-05-24 14:59:51 -0700377 pinfo->mipi.eof_bllp_power,
378 pinfo->mipi.interleave_mode,
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -0800379 pinfo->mipi.ctl_base);
Arpita Banerjee841fa062013-05-24 14:59:51 -0700380
381 if (pinfo->mipi.dual_dsi)
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700382 ret = mdss_dsi_video_mode_config(final_width, final_height,
383 final_xres, final_yres,
384 final_hfp, final_hbp + final_hpw,
385 final_vfp, final_vbp + final_vpw,
386 final_hpw, final_vpw,
387 pinfo->mipi.dst_format,
388 pinfo->mipi.traffic_mode,
389 lane_enable,
Padmanabhan Komandurue3209872015-01-12 16:33:16 +0530390 pinfo->mipi.pulse_mode_hsa_he,
391 low_pwr_stop,
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700392 pinfo->mipi.eof_bllp_power,
393 pinfo->mipi.interleave_mode,
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -0800394 pinfo->mipi.sctl_base);
Arpita Banerjee841fa062013-05-24 14:59:51 -0700395
396 return ret;
397}
398
399int dsi_cmd_panel_config (struct msm_panel_info *pinfo,
400 struct lcdc_panel_info *plcdc)
401{
402 int ret = NO_ERROR;
Xiaoming Zhou7e0b1e62013-07-29 15:49:39 -0400403 uint8_t lane_en = 0;
404 uint8_t ystride = pinfo->bpp / 8;
Dhaval Patelea19a1e2014-01-02 16:17:26 -0800405 uint32_t panel_width = pinfo->xres;
Aravind Venkateswaran5cfdbc72014-12-03 16:06:45 -0800406 uint32_t final_xres, final_yres, final_width;
407 uint32_t final_height;
Dhaval Patelea19a1e2014-01-02 16:17:26 -0800408
409 if (pinfo->mipi.dual_dsi)
410 panel_width = panel_width / 2;
Xiaoming Zhou7e0b1e62013-07-29 15:49:39 -0400411
412 if (pinfo->mipi.data_lane0)
413 lane_en |= (1 << 0);
414 if (pinfo->mipi.data_lane1)
415 lane_en |= (1 << 1);
416 if (pinfo->mipi.data_lane2)
417 lane_en |= (1 << 2);
418 if (pinfo->mipi.data_lane3)
419 lane_en |= (1 << 3);
Arpita Banerjee841fa062013-05-24 14:59:51 -0700420
Aravind Venkateswaran5cfdbc72014-12-03 16:06:45 -0800421 final_xres = panel_width;
422 final_width = panel_width + pinfo->lcdc.xres_pad;
423
424 if (pinfo->fbc.enabled && pinfo->fbc.comp_ratio) {
425 final_xres /= pinfo->fbc.comp_ratio;
426 final_width /= pinfo->fbc.comp_ratio;
427 dprintf(SPEW, "DSI xres =%d final_width=%d\n", final_xres,
428 final_width);
429 }
430 final_yres = pinfo->yres;
431 final_height = pinfo->yres + pinfo->lcdc.yres_pad;
432
433 ret = mdss_dsi_cmd_mode_config(final_width, final_height,
434 final_xres, final_yres,
Xiaoming Zhou7e0b1e62013-07-29 15:49:39 -0400435 pinfo->mipi.dst_format,
436 ystride, lane_en,
Dhaval Patelea19a1e2014-01-02 16:17:26 -0800437 pinfo->mipi.interleave_mode,
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -0800438 pinfo->mipi.ctl_base);
Dhaval Patelea19a1e2014-01-02 16:17:26 -0800439
440 if (pinfo->mipi.dual_dsi)
Aravind Venkateswaran5cfdbc72014-12-03 16:06:45 -0800441 ret = mdss_dsi_cmd_mode_config(final_width, final_height,
442 final_xres, final_yres,
443 pinfo->mipi.dst_format,
444 ystride, lane_en,
445 pinfo->mipi.interleave_mode,
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -0800446 pinfo->mipi.sctl_base);
Arpita Banerjee841fa062013-05-24 14:59:51 -0700447
448 return ret;
449}
450
451
452int dsi_panel_config(void *pdata)
453{
454 int ret = NO_ERROR;
455 struct msm_panel_info *pinfo = (struct msm_panel_info *)pdata;
456 struct lcdc_panel_info *plcdc = NULL;
457
458 if (pinfo == NULL)
459 return ERR_INVALID_ARGS;
460
461 plcdc = &(pinfo->lcdc);
462 if (plcdc == NULL)
463 return ERR_INVALID_ARGS;
464
465
466 if (pinfo->mipi.mode == DSI_VIDEO_MODE) {
467 ret = dsi_video_panel_config(pinfo, plcdc);
468 } else {
469 ret = dsi_cmd_panel_config(pinfo, plcdc);
470 }
471
472 return ret;
473}
Dhaval Patel551f7f62014-02-18 17:13:00 -0800474
475int32_t panel_name_to_id(struct panel_list supp_panels[],
476 uint32_t supp_panels_size,
477 const char *panel_name)
478{
479 uint32_t i;
480 int32_t panel_id = ERR_NOT_FOUND;
481
482 if (!panel_name) {
483 dprintf(CRITICAL, "Invalid panel name\n");
484 return panel_id;
485 }
486
487 /* Remove any leading whitespaces */
488 panel_name += strspn(panel_name, " ");
489 for (i = 0; i < supp_panels_size; i++) {
490 if (!strncmp(panel_name, supp_panels[i].name,
491 MAX_PANEL_ID_LEN)) {
492 panel_id = supp_panels[i].id;
493 break;
494 }
495 }
496
497 return panel_id;
498}