Dhaval Patel | c4135d8 | 2016-03-30 17:40:53 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2013-2016, The Linux Foundation. All rights reserved. |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 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 | /*---------------------------------------------------------------------------*/ |
| 31 | /* HEADER files */ |
| 32 | /*---------------------------------------------------------------------------*/ |
| 33 | #include <stdint.h> |
| 34 | #include <msm_panel.h> |
| 35 | #include <mipi_dsi.h> |
Veera Sundaram Sankaran | 602d95a | 2014-12-09 17:55:04 -0800 | [diff] [blame] | 36 | #include <mdp5.h> |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 37 | #include <sys/types.h> |
| 38 | #include <platform/iomap.h> |
| 39 | #include <err.h> |
| 40 | #include <reg.h> |
Dhaval Patel | 551f7f6 | 2014-02-18 17:13:00 -0800 | [diff] [blame] | 41 | #include <string.h> |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 42 | |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 43 | /*---------------------------------------------------------------------------*/ |
| 44 | /* Panel Header */ |
| 45 | /*---------------------------------------------------------------------------*/ |
| 46 | #include "panel_display.h" |
| 47 | #include "include/panel.h" |
Veera Sundaram Sankaran | 824e6fa | 2014-12-09 11:32:58 -0800 | [diff] [blame] | 48 | #include "target/display.h" |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 49 | |
Jeevan Shriram | 04c15b6 | 2015-01-08 13:16:18 -0800 | [diff] [blame] | 50 | static int dsi_platform_base_offset_adjust(uint32_t base) |
| 51 | { |
| 52 | return target_display_get_base_offset(base); |
| 53 | } |
| 54 | |
Aravind Venkateswaran | fec354c | 2014-12-04 18:10:14 -0800 | [diff] [blame] | 55 | static int dsi_panel_ctl_base_setup(struct msm_panel_info *pinfo, |
| 56 | char *panel_destination) |
| 57 | { |
Padmanabhan Komanduru | 876c1cf | 2015-06-08 14:06:57 +0530 | [diff] [blame] | 58 | 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 Shriram | 04c15b6 | 2015-01-08 13:16:18 -0800 | [diff] [blame] | 61 | |
| 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 Komanduru | 876c1cf | 2015-06-08 14:06:57 +0530 | [diff] [blame] | 68 | 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 Shriram | 04c15b6 | 2015-01-08 13:16:18 -0800 | [diff] [blame] | 73 | dprintf(SPEW, "base offset = %d, %x\n", base_offset, base_offset); |
| 74 | |
Aravind Venkateswaran | fec354c | 2014-12-04 18:10:14 -0800 | [diff] [blame] | 75 | if (!strcmp(panel_destination, "DISPLAY_1")) { |
| 76 | pinfo->dest = DISPLAY_1; |
Jeevan Shriram | 04c15b6 | 2015-01-08 13:16:18 -0800 | [diff] [blame] | 77 | pinfo->mipi.ctl_base = MIPI_DSI0_BASE + base_offset; |
Padmanabhan Komanduru | 876c1cf | 2015-06-08 14:06:57 +0530 | [diff] [blame] | 78 | pinfo->mipi.phy_base = DSI0_PHY_BASE + base_phy_offset; |
Jeevan Shriram | 04c15b6 | 2015-01-08 13:16:18 -0800 | [diff] [blame] | 79 | pinfo->mipi.sctl_base = MIPI_DSI1_BASE + base1_offset; |
Padmanabhan Komanduru | 876c1cf | 2015-06-08 14:06:57 +0530 | [diff] [blame] | 80 | pinfo->mipi.sphy_base = DSI1_PHY_BASE + base1_phy_offset; |
Padmanabhan Komanduru | c0766c8 | 2015-04-27 16:39:15 -0700 | [diff] [blame] | 81 | 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 Komanduru | 876c1cf | 2015-06-08 14:06:57 +0530 | [diff] [blame] | 86 | pinfo->mipi.pll_base = DSI0_PLL_BASE + base_phy_pll_offset; |
| 87 | pinfo->mipi.spll_base = DSI1_PLL_BASE + base1_phy_pll_offset; |
Aravind Venkateswaran | fec354c | 2014-12-04 18:10:14 -0800 | [diff] [blame] | 88 | } else if (!strcmp(panel_destination, "DISPLAY_2")) { |
| 89 | pinfo->dest = DISPLAY_2; |
Jeevan Shriram | 04c15b6 | 2015-01-08 13:16:18 -0800 | [diff] [blame] | 90 | pinfo->mipi.ctl_base = MIPI_DSI1_BASE + base1_offset; |
Padmanabhan Komanduru | 876c1cf | 2015-06-08 14:06:57 +0530 | [diff] [blame] | 91 | pinfo->mipi.phy_base = DSI1_PHY_BASE + base1_phy_offset; |
Jeevan Shriram | 04c15b6 | 2015-01-08 13:16:18 -0800 | [diff] [blame] | 92 | pinfo->mipi.sctl_base = MIPI_DSI0_BASE + base_offset; |
Padmanabhan Komanduru | 876c1cf | 2015-06-08 14:06:57 +0530 | [diff] [blame] | 93 | pinfo->mipi.sphy_base = DSI0_PHY_BASE + base_phy_offset; |
Padmanabhan Komanduru | c0766c8 | 2015-04-27 16:39:15 -0700 | [diff] [blame] | 94 | if (pinfo->mipi.use_dsi1_pll) { |
Padmanabhan Komanduru | 876c1cf | 2015-06-08 14:06:57 +0530 | [diff] [blame] | 95 | pinfo->mipi.pll_base = DSI1_PLL_BASE + base1_phy_pll_offset; |
| 96 | pinfo->mipi.spll_base = DSI0_PLL_BASE + base_phy_pll_offset; |
Padmanabhan Komanduru | c0766c8 | 2015-04-27 16:39:15 -0700 | [diff] [blame] | 97 | } else { |
Padmanabhan Komanduru | 876c1cf | 2015-06-08 14:06:57 +0530 | [diff] [blame] | 98 | pinfo->mipi.pll_base = DSI0_PLL_BASE + base_phy_pll_offset; |
| 99 | pinfo->mipi.spll_base = DSI1_PLL_BASE + base1_phy_pll_offset; |
Padmanabhan Komanduru | c0766c8 | 2015-04-27 16:39:15 -0700 | [diff] [blame] | 100 | } |
Aravind Venkateswaran | fec354c | 2014-12-04 18:10:14 -0800 | [diff] [blame] | 101 | } 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 Shriram | 0137932 | 2015-01-07 17:41:26 -0800 | [diff] [blame] | 108 | /* Both DSI0 and DSI1 use the same regulator */ |
Padmanabhan Komanduru | 876c1cf | 2015-06-08 14:06:57 +0530 | [diff] [blame] | 109 | pinfo->mipi.reg_base = DSI0_REGULATOR_BASE + base_phy_reg_offset; |
| 110 | pinfo->mipi.sreg_base = DSI0_REGULATOR_BASE + base_phy_reg_offset; |
Jeevan Shriram | 0137932 | 2015-01-07 17:41:26 -0800 | [diff] [blame] | 111 | |
Aravind Venkateswaran | fec354c | 2014-12-04 18:10:14 -0800 | [diff] [blame] | 112 | 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 Komanduru | c0766c8 | 2015-04-27 16:39:15 -0700 | [diff] [blame] | 115 | 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 Shriram | 0137932 | 2015-01-07 17:41:26 -0800 | [diff] [blame] | 117 | pinfo->mipi.reg_base, pinfo->mipi.sreg_base); |
Aravind Venkateswaran | fec354c | 2014-12-04 18:10:14 -0800 | [diff] [blame] | 118 | return NO_ERROR; |
| 119 | } |
| 120 | |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 121 | /*---------------------------------------------------------------------------*/ |
| 122 | /* Panel Init */ |
| 123 | /*---------------------------------------------------------------------------*/ |
| 124 | int dsi_panel_init(struct msm_panel_info *pinfo, |
| 125 | struct panel_struct *pstruct) |
| 126 | { |
Aravind Venkateswaran | fec354c | 2014-12-04 18:10:14 -0800 | [diff] [blame] | 127 | int ret = NO_ERROR; |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 128 | /* 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 Hsieh | 31b4ff9 | 2014-10-22 14:55:42 -0700 | [diff] [blame] | 138 | |
| 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 Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 150 | |
Ujwal Patel | 41a665a | 2015-07-17 13:51:30 -0700 | [diff] [blame] | 151 | dprintf(INFO, "panel_operating_mode=0x%x\n", |
| 152 | pstruct->paneldata->panel_operating_mode); |
Dhaval Patel | ee8675a | 2013-10-25 10:07:57 -0700 | [diff] [blame] | 153 | 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 Bajaj | 4effb13 | 2014-07-24 16:55:41 +0530 | [diff] [blame] | 159 | if (pstruct->paneldata->panel_operating_mode & DST_SPLIT_FLAG) |
| 160 | pinfo->lcdc.dst_split = 1; |
Ujwal Patel | 41a665a | 2015-07-17 13:51:30 -0700 | [diff] [blame] | 161 | 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 Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 169 | |
| 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 Shriram | 2dd40cf | 2014-05-12 16:59:13 -0700 | [diff] [blame] | 174 | pinfo->bpp = pstruct->color->color_format; |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 175 | 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 Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 200 | pinfo->clk_rate = pstruct->paneldata->panel_clockrate; |
Prashant Nukala | 64eeff9 | 2014-07-11 07:35:34 +0530 | [diff] [blame] | 201 | pinfo->orientation = pstruct->paneldata->panel_orientation; |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 202 | pinfo->mipi.interleave_mode = pstruct->paneldata->interleave_mode; |
Dhaval Patel | ee8675a | 2013-10-25 10:07:57 -0700 | [diff] [blame] | 203 | pinfo->mipi.broadcast = pstruct->paneldata->panel_broadcast_mode; |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 204 | 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 Patel | 29f2449 | 2013-08-08 20:45:42 -0700 | [diff] [blame] | 207 | pinfo->mipi.mode_gpio_state = pstruct->paneldata->mode_gpio_state; |
Arpita Banerjee | da0c39a | 2013-05-24 16:12:45 -0700 | [diff] [blame] | 208 | pinfo->mipi.bitclock = pstruct->paneldata->panel_bitclock_freq; |
Aravind Venkateswaran | 3111984 | 2015-01-13 14:46:04 -0800 | [diff] [blame] | 209 | if (pinfo->mipi.bitclock) { |
| 210 | /* panel_clockrate is depcrated in favor of bitclock_freq */ |
| 211 | pinfo->clk_rate = pinfo->mipi.bitclock; |
| 212 | } |
Aravind Venkateswaran | 1e31c78 | 2013-11-04 17:32:14 -0800 | [diff] [blame] | 213 | pinfo->mipi.use_enable_gpio = |
| 214 | pstruct->paneldata->panel_with_enable_gpio; |
Aravind Venkateswaran | fec354c | 2014-12-04 18:10:14 -0800 | [diff] [blame] | 215 | ret = dsi_panel_ctl_base_setup(pinfo, |
| 216 | pstruct->paneldata->panel_destination); |
| 217 | if (ret) |
| 218 | return ret; |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 219 | |
| 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 Panda | 79764b5 | 2015-12-23 15:38:54 +0530 | [diff] [blame] | 238 | pinfo->autorefresh_enable = pstruct->commandpanel->autorefresh_enable; |
| 239 | pinfo->autorefresh_framenum = |
| 240 | pstruct->commandpanel->autorefresh_framenumdiv; |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 241 | |
| 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 Zhang | 0d303af | 2015-01-21 10:17:02 +0800 | [diff] [blame] | 249 | pinfo->mipi.force_clk_lane_hs = pstruct->laneconfig->force_clk_lane_hs; |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 250 | |
| 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 Hsieh | e0fbc02 | 2015-07-07 10:26:58 -0700 | [diff] [blame] | 255 | pinfo->fbc.comp_ratio = 1; |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 256 | |
Kuogee Hsieh | e0fbc02 | 2015-07-07 10:26:58 -0700 | [diff] [blame] | 257 | if (pinfo->compression_mode == COMPRESSION_DSC) { |
Ujwal Patel | 41a665a | 2015-07-17 13:51:30 -0700 | [diff] [blame] | 258 | struct dsc_desc *dsc = &pinfo->dsc; |
| 259 | struct dsc_parameters *dsc_params = NULL; |
Kuogee Hsieh | e0fbc02 | 2015-07-07 10:26:58 -0700 | [diff] [blame] | 260 | |
Ujwal Patel | 41a665a | 2015-07-17 13:51:30 -0700 | [diff] [blame] | 261 | 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 Hsieh | e0fbc02 | 2015-07-07 10:26:58 -0700 | [diff] [blame] | 270 | |
Ujwal Patel | 41a665a | 2015-07-17 13:51:30 -0700 | [diff] [blame] | 271 | dsc->major = dsc_params->major; |
| 272 | dsc->minor = dsc_params->minor; |
Dhaval Patel | c4135d8 | 2016-03-30 17:40:53 -0700 | [diff] [blame] | 273 | dsc->scr_rev = dsc_params->scr_rev; |
Ujwal Patel | 41a665a | 2015-07-17 13:51:30 -0700 | [diff] [blame] | 274 | 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 Patel | 41a665a | 2015-07-17 13:51:30 -0700 | [diff] [blame] | 280 | 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 Hsieh | e0fbc02 | 2015-07-07 10:26:58 -0700 | [diff] [blame] | 287 | } else if (pinfo->compression_mode == COMPRESSION_FBC) { |
Siddhartha Agrawal | fe64dcb | 2014-10-07 12:41:01 -0700 | [diff] [blame] | 288 | pinfo->fbc.enabled = pstruct->fbcinfo.enabled; |
Kuogee Hsieh | e0fbc02 | 2015-07-07 10:26:58 -0700 | [diff] [blame] | 289 | 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 Agrawal | fe64dcb | 2014-10-07 12:41:01 -0700 | [diff] [blame] | 308 | } |
| 309 | |
Dhaval Patel | b22f1bc | 2013-10-25 13:56:26 -0700 | [diff] [blame] | 310 | 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 Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 314 | 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 Patel | b22f1bc | 2013-10-25 13:56:26 -0700 | [diff] [blame] | 324 | int dsi_panel_pre_on() |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 325 | { |
Dhaval Patel | b22f1bc | 2013-10-25 13:56:26 -0700 | [diff] [blame] | 326 | return target_display_pre_on(); |
| 327 | } |
| 328 | |
| 329 | int dsi_panel_pre_off() |
| 330 | { |
| 331 | return target_display_pre_off(); |
| 332 | } |
| 333 | |
| 334 | int 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 Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 342 | return oem_panel_on(); |
| 343 | } |
| 344 | |
Dhaval Patel | b22f1bc | 2013-10-25 13:56:26 -0700 | [diff] [blame] | 345 | int dsi_panel_post_off() |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 346 | { |
Dhaval Patel | b22f1bc | 2013-10-25 13:56:26 -0700 | [diff] [blame] | 347 | int ret = NO_ERROR; |
| 348 | |
| 349 | ret = target_display_post_off(); |
| 350 | if (ret) |
| 351 | return ret; |
| 352 | |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 353 | return oem_panel_off(); |
| 354 | } |
| 355 | |
| 356 | int dsi_panel_rotation() |
| 357 | { |
| 358 | return oem_panel_rotation(); |
| 359 | } |
| 360 | |
| 361 | int 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 Agrawal | fe64dcb | 2014-10-07 12:41:01 -0700 | [diff] [blame] | 368 | uint32_t final_xres, final_yres, final_width; |
| 369 | uint32_t final_height, final_hbp, final_hfp,final_vbp; |
Padmanabhan Komanduru | e320987 | 2015-01-12 16:33:16 +0530 | [diff] [blame] | 370 | uint32_t final_vfp, final_hpw, final_vpw, low_pwr_stop; |
Kuogee Hsieh | e0fbc02 | 2015-07-07 10:26:58 -0700 | [diff] [blame] | 371 | struct dsc_desc *dsc = NULL; |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 372 | |
| 373 | if (pinfo->mipi.dual_dsi) |
| 374 | panel_width = panel_width / 2; |
| 375 | |
Xiaoming Zhou | 7e0b1e6 | 2013-07-29 15:49:39 -0400 | [diff] [blame] | 376 | 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 Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 384 | |
Kuogee Hsieh | e0fbc02 | 2015-07-07 10:26:58 -0700 | [diff] [blame] | 385 | if (pinfo->compression_mode == COMPRESSION_DSC) { |
| 386 | dsc = &pinfo->dsc; |
| 387 | panel_width = dsc->pclk_per_line; |
| 388 | } |
| 389 | |
Siddhartha Agrawal | fe64dcb | 2014-10-07 12:41:01 -0700 | [diff] [blame] | 390 | 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 Hsieh | e0fbc02 | 2015-07-07 10:26:58 -0700 | [diff] [blame] | 396 | dprintf(SPEW, "DSI xres =%d final_width=%d\n", |
| 397 | final_xres, final_width); |
Siddhartha Agrawal | fe64dcb | 2014-10-07 12:41:01 -0700 | [diff] [blame] | 398 | } |
| 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 Komanduru | e320987 | 2015-01-12 16:33:16 +0530 | [diff] [blame] | 407 | low_pwr_stop = (pinfo->mipi.hfp_power_stop << 8) | |
| 408 | (pinfo->mipi.hbp_power_stop << 4) | |
| 409 | pinfo->mipi.hsa_power_stop; |
Siddhartha Agrawal | fe64dcb | 2014-10-07 12:41:01 -0700 | [diff] [blame] | 410 | |
Kuogee Hsieh | e0fbc02 | 2015-07-07 10:26:58 -0700 | [diff] [blame] | 411 | ret = mdss_dsi_video_mode_config(pinfo, |
| 412 | final_width, final_height, |
Siddhartha Agrawal | fe64dcb | 2014-10-07 12:41:01 -0700 | [diff] [blame] | 413 | final_xres, final_yres, |
| 414 | final_hfp, final_hbp + final_hpw, |
| 415 | final_vfp, final_vbp + final_vpw, |
| 416 | final_hpw, final_vpw, |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 417 | pinfo->mipi.dst_format, |
| 418 | pinfo->mipi.traffic_mode, |
| 419 | lane_enable, |
Padmanabhan Komanduru | e320987 | 2015-01-12 16:33:16 +0530 | [diff] [blame] | 420 | pinfo->mipi.pulse_mode_hsa_he, |
| 421 | low_pwr_stop, |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 422 | pinfo->mipi.eof_bllp_power, |
| 423 | pinfo->mipi.interleave_mode, |
Aravind Venkateswaran | fec354c | 2014-12-04 18:10:14 -0800 | [diff] [blame] | 424 | pinfo->mipi.ctl_base); |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 425 | |
| 426 | if (pinfo->mipi.dual_dsi) |
Kuogee Hsieh | e0fbc02 | 2015-07-07 10:26:58 -0700 | [diff] [blame] | 427 | ret = mdss_dsi_video_mode_config(pinfo, |
| 428 | final_width, final_height, |
Siddhartha Agrawal | fe64dcb | 2014-10-07 12:41:01 -0700 | [diff] [blame] | 429 | 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 Komanduru | e320987 | 2015-01-12 16:33:16 +0530 | [diff] [blame] | 436 | pinfo->mipi.pulse_mode_hsa_he, |
| 437 | low_pwr_stop, |
Siddhartha Agrawal | fe64dcb | 2014-10-07 12:41:01 -0700 | [diff] [blame] | 438 | pinfo->mipi.eof_bllp_power, |
| 439 | pinfo->mipi.interleave_mode, |
Aravind Venkateswaran | fec354c | 2014-12-04 18:10:14 -0800 | [diff] [blame] | 440 | pinfo->mipi.sctl_base); |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 441 | |
| 442 | return ret; |
| 443 | } |
| 444 | |
| 445 | int dsi_cmd_panel_config (struct msm_panel_info *pinfo, |
| 446 | struct lcdc_panel_info *plcdc) |
| 447 | { |
| 448 | int ret = NO_ERROR; |
Xiaoming Zhou | 7e0b1e6 | 2013-07-29 15:49:39 -0400 | [diff] [blame] | 449 | uint8_t lane_en = 0; |
| 450 | uint8_t ystride = pinfo->bpp / 8; |
Dhaval Patel | ea19a1e | 2014-01-02 16:17:26 -0800 | [diff] [blame] | 451 | uint32_t panel_width = pinfo->xres; |
Aravind Venkateswaran | 5cfdbc7 | 2014-12-03 16:06:45 -0800 | [diff] [blame] | 452 | uint32_t final_xres, final_yres, final_width; |
| 453 | uint32_t final_height; |
Kuogee Hsieh | e0fbc02 | 2015-07-07 10:26:58 -0700 | [diff] [blame] | 454 | struct dsc_desc *dsc = NULL; |
Dhaval Patel | ea19a1e | 2014-01-02 16:17:26 -0800 | [diff] [blame] | 455 | |
| 456 | if (pinfo->mipi.dual_dsi) |
| 457 | panel_width = panel_width / 2; |
Xiaoming Zhou | 7e0b1e6 | 2013-07-29 15:49:39 -0400 | [diff] [blame] | 458 | |
| 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 Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 467 | |
Kuogee Hsieh | e0fbc02 | 2015-07-07 10:26:58 -0700 | [diff] [blame] | 468 | if (pinfo->compression_mode == COMPRESSION_DSC) { |
| 469 | dsc = &pinfo->dsc; |
| 470 | panel_width = dsc->pclk_per_line; |
| 471 | } |
| 472 | |
Aravind Venkateswaran | 5cfdbc7 | 2014-12-03 16:06:45 -0800 | [diff] [blame] | 473 | final_xres = panel_width; |
| 474 | final_width = panel_width + pinfo->lcdc.xres_pad; |
| 475 | |
Kuogee Hsieh | e0fbc02 | 2015-07-07 10:26:58 -0700 | [diff] [blame] | 476 | 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 Venkateswaran | 5cfdbc7 | 2014-12-03 16:06:45 -0800 | [diff] [blame] | 483 | } |
| 484 | final_yres = pinfo->yres; |
| 485 | final_height = pinfo->yres + pinfo->lcdc.yres_pad; |
| 486 | |
Kuogee Hsieh | d58c809 | 2015-07-07 10:31:34 -0700 | [diff] [blame] | 487 | ret = mdss_dsi_cmd_mode_config(pinfo, final_width, final_height, |
Aravind Venkateswaran | 5cfdbc7 | 2014-12-03 16:06:45 -0800 | [diff] [blame] | 488 | final_xres, final_yres, |
Xiaoming Zhou | 7e0b1e6 | 2013-07-29 15:49:39 -0400 | [diff] [blame] | 489 | pinfo->mipi.dst_format, |
| 490 | ystride, lane_en, |
Dhaval Patel | ea19a1e | 2014-01-02 16:17:26 -0800 | [diff] [blame] | 491 | pinfo->mipi.interleave_mode, |
Aravind Venkateswaran | fec354c | 2014-12-04 18:10:14 -0800 | [diff] [blame] | 492 | pinfo->mipi.ctl_base); |
Dhaval Patel | ea19a1e | 2014-01-02 16:17:26 -0800 | [diff] [blame] | 493 | |
| 494 | if (pinfo->mipi.dual_dsi) |
Kuogee Hsieh | d58c809 | 2015-07-07 10:31:34 -0700 | [diff] [blame] | 495 | ret = mdss_dsi_cmd_mode_config(pinfo, final_width, final_height, |
Aravind Venkateswaran | 5cfdbc7 | 2014-12-03 16:06:45 -0800 | [diff] [blame] | 496 | final_xres, final_yres, |
| 497 | pinfo->mipi.dst_format, |
| 498 | ystride, lane_en, |
| 499 | pinfo->mipi.interleave_mode, |
Aravind Venkateswaran | fec354c | 2014-12-04 18:10:14 -0800 | [diff] [blame] | 500 | pinfo->mipi.sctl_base); |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 501 | |
| 502 | return ret; |
| 503 | } |
| 504 | |
| 505 | |
| 506 | int 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 Patel | 551f7f6 | 2014-02-18 17:13:00 -0800 | [diff] [blame] | 528 | |
| 529 | int32_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 Patel | 551f7f6 | 2014-02-18 17:13:00 -0800 | [diff] [blame] | 541 | 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 | } |