| Jeevan Shriram | 0137932 | 2015-01-07 17:41:26 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2013-2015, 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 |  | 
| Dhaval Patel | ee8675a | 2013-10-25 10:07:57 -0700 | [diff] [blame] | 151 | 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 Bajaj | 4effb13 | 2014-07-24 16:55:41 +0530 | [diff] [blame] | 157 | if (pstruct->paneldata->panel_operating_mode & DST_SPLIT_FLAG) | 
|  | 158 | pinfo->lcdc.dst_split = 1; | 
| Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 159 |  | 
|  | 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 Shriram | 2dd40cf | 2014-05-12 16:59:13 -0700 | [diff] [blame] | 164 | pinfo->bpp = pstruct->color->color_format; | 
| Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 165 | 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 Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 190 | pinfo->clk_rate = pstruct->paneldata->panel_clockrate; | 
| Prashant Nukala | 64eeff9 | 2014-07-11 07:35:34 +0530 | [diff] [blame] | 191 | pinfo->orientation = pstruct->paneldata->panel_orientation; | 
| Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 192 | pinfo->mipi.interleave_mode = pstruct->paneldata->interleave_mode; | 
| Dhaval Patel | ee8675a | 2013-10-25 10:07:57 -0700 | [diff] [blame] | 193 | pinfo->mipi.broadcast = pstruct->paneldata->panel_broadcast_mode; | 
| Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 194 | 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 Patel | ee8675a | 2013-10-25 10:07:57 -0700 | [diff] [blame] | 197 | if (pstruct->paneldata->panel_operating_mode & DUAL_DSI_FLAG) | 
|  | 198 | pinfo->mipi.dual_dsi = 1; | 
| Padmanabhan Komanduru | c0766c8 | 2015-04-27 16:39:15 -0700 | [diff] [blame] | 199 | if (pstruct->paneldata->panel_operating_mode & USE_DSI1_PLL_FLAG) | 
|  | 200 | pinfo->mipi.use_dsi1_pll = 1; | 
| Dhaval Patel | 29f2449 | 2013-08-08 20:45:42 -0700 | [diff] [blame] | 201 | pinfo->mipi.mode_gpio_state = pstruct->paneldata->mode_gpio_state; | 
| Arpita Banerjee | da0c39a | 2013-05-24 16:12:45 -0700 | [diff] [blame] | 202 | pinfo->mipi.bitclock = pstruct->paneldata->panel_bitclock_freq; | 
| Aravind Venkateswaran | 3111984 | 2015-01-13 14:46:04 -0800 | [diff] [blame] | 203 | if (pinfo->mipi.bitclock) { | 
|  | 204 | /* panel_clockrate is depcrated in favor of bitclock_freq */ | 
|  | 205 | pinfo->clk_rate = pinfo->mipi.bitclock; | 
|  | 206 | } | 
| Aravind Venkateswaran | 1e31c78 | 2013-11-04 17:32:14 -0800 | [diff] [blame] | 207 | pinfo->mipi.use_enable_gpio = | 
|  | 208 | pstruct->paneldata->panel_with_enable_gpio; | 
| Aravind Venkateswaran | fec354c | 2014-12-04 18:10:14 -0800 | [diff] [blame] | 209 | ret = dsi_panel_ctl_base_setup(pinfo, | 
|  | 210 | pstruct->paneldata->panel_destination); | 
|  | 211 | if (ret) | 
|  | 212 | return ret; | 
| Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 213 |  | 
|  | 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 Zhang | 0d303af | 2015-01-21 10:17:02 +0800 | [diff] [blame] | 240 | pinfo->mipi.force_clk_lane_hs = pstruct->laneconfig->force_clk_lane_hs; | 
| Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 241 |  | 
|  | 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 Agrawal | fe64dcb | 2014-10-07 12:41:01 -0700 | [diff] [blame] | 247 | 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 Shriram | 1b07e37 | 2014-11-30 22:03:50 -0800 | [diff] [blame] | 264 | 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 Agrawal | fe64dcb | 2014-10-07 12:41:01 -0700 | [diff] [blame] | 268 | } else { | 
|  | 269 | pinfo->fbc.comp_ratio = 1; | 
|  | 270 | } | 
|  | 271 |  | 
| Dhaval Patel | b22f1bc | 2013-10-25 13:56:26 -0700 | [diff] [blame] | 272 | 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 Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 276 | 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 Patel | b22f1bc | 2013-10-25 13:56:26 -0700 | [diff] [blame] | 286 | int dsi_panel_pre_on() | 
| Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 287 | { | 
| Dhaval Patel | b22f1bc | 2013-10-25 13:56:26 -0700 | [diff] [blame] | 288 | return target_display_pre_on(); | 
|  | 289 | } | 
|  | 290 |  | 
|  | 291 | int dsi_panel_pre_off() | 
|  | 292 | { | 
|  | 293 | return target_display_pre_off(); | 
|  | 294 | } | 
|  | 295 |  | 
|  | 296 | int 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 Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 304 | return oem_panel_on(); | 
|  | 305 | } | 
|  | 306 |  | 
| Dhaval Patel | b22f1bc | 2013-10-25 13:56:26 -0700 | [diff] [blame] | 307 | int dsi_panel_post_off() | 
| Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 308 | { | 
| Dhaval Patel | b22f1bc | 2013-10-25 13:56:26 -0700 | [diff] [blame] | 309 | int ret = NO_ERROR; | 
|  | 310 |  | 
|  | 311 | ret = target_display_post_off(); | 
|  | 312 | if (ret) | 
|  | 313 | return ret; | 
|  | 314 |  | 
| Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 315 | return oem_panel_off(); | 
|  | 316 | } | 
|  | 317 |  | 
|  | 318 | int dsi_panel_rotation() | 
|  | 319 | { | 
|  | 320 | return oem_panel_rotation(); | 
|  | 321 | } | 
|  | 322 |  | 
|  | 323 | int 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 Agrawal | fe64dcb | 2014-10-07 12:41:01 -0700 | [diff] [blame] | 330 | uint32_t final_xres, final_yres, final_width; | 
|  | 331 | uint32_t final_height, final_hbp, final_hfp,final_vbp; | 
| Padmanabhan Komanduru | e320987 | 2015-01-12 16:33:16 +0530 | [diff] [blame] | 332 | uint32_t final_vfp, final_hpw, final_vpw, low_pwr_stop; | 
| Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 333 |  | 
|  | 334 | if (pinfo->mipi.dual_dsi) | 
|  | 335 | panel_width = panel_width / 2; | 
|  | 336 |  | 
| Xiaoming Zhou | 7e0b1e6 | 2013-07-29 15:49:39 -0400 | [diff] [blame] | 337 | 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 Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 345 |  | 
| Siddhartha Agrawal | fe64dcb | 2014-10-07 12:41:01 -0700 | [diff] [blame] | 346 | 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 Komanduru | e320987 | 2015-01-12 16:33:16 +0530 | [diff] [blame] | 363 | low_pwr_stop = (pinfo->mipi.hfp_power_stop << 8) | | 
|  | 364 | (pinfo->mipi.hbp_power_stop << 4) | | 
|  | 365 | pinfo->mipi.hsa_power_stop; | 
| Siddhartha Agrawal | fe64dcb | 2014-10-07 12:41:01 -0700 | [diff] [blame] | 366 |  | 
|  | 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 Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 372 | pinfo->mipi.dst_format, | 
|  | 373 | pinfo->mipi.traffic_mode, | 
|  | 374 | lane_enable, | 
| Padmanabhan Komanduru | e320987 | 2015-01-12 16:33:16 +0530 | [diff] [blame] | 375 | pinfo->mipi.pulse_mode_hsa_he, | 
|  | 376 | low_pwr_stop, | 
| Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 377 | pinfo->mipi.eof_bllp_power, | 
|  | 378 | pinfo->mipi.interleave_mode, | 
| Aravind Venkateswaran | fec354c | 2014-12-04 18:10:14 -0800 | [diff] [blame] | 379 | pinfo->mipi.ctl_base); | 
| Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 380 |  | 
|  | 381 | if (pinfo->mipi.dual_dsi) | 
| Siddhartha Agrawal | fe64dcb | 2014-10-07 12:41:01 -0700 | [diff] [blame] | 382 | 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 Komanduru | e320987 | 2015-01-12 16:33:16 +0530 | [diff] [blame] | 390 | pinfo->mipi.pulse_mode_hsa_he, | 
|  | 391 | low_pwr_stop, | 
| Siddhartha Agrawal | fe64dcb | 2014-10-07 12:41:01 -0700 | [diff] [blame] | 392 | pinfo->mipi.eof_bllp_power, | 
|  | 393 | pinfo->mipi.interleave_mode, | 
| Aravind Venkateswaran | fec354c | 2014-12-04 18:10:14 -0800 | [diff] [blame] | 394 | pinfo->mipi.sctl_base); | 
| Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 395 |  | 
|  | 396 | return ret; | 
|  | 397 | } | 
|  | 398 |  | 
|  | 399 | int dsi_cmd_panel_config (struct msm_panel_info *pinfo, | 
|  | 400 | struct lcdc_panel_info *plcdc) | 
|  | 401 | { | 
|  | 402 | int ret = NO_ERROR; | 
| Xiaoming Zhou | 7e0b1e6 | 2013-07-29 15:49:39 -0400 | [diff] [blame] | 403 | uint8_t lane_en = 0; | 
|  | 404 | uint8_t ystride = pinfo->bpp / 8; | 
| Dhaval Patel | ea19a1e | 2014-01-02 16:17:26 -0800 | [diff] [blame] | 405 | uint32_t panel_width = pinfo->xres; | 
| Aravind Venkateswaran | 5cfdbc7 | 2014-12-03 16:06:45 -0800 | [diff] [blame] | 406 | uint32_t final_xres, final_yres, final_width; | 
|  | 407 | uint32_t final_height; | 
| Dhaval Patel | ea19a1e | 2014-01-02 16:17:26 -0800 | [diff] [blame] | 408 |  | 
|  | 409 | if (pinfo->mipi.dual_dsi) | 
|  | 410 | panel_width = panel_width / 2; | 
| Xiaoming Zhou | 7e0b1e6 | 2013-07-29 15:49:39 -0400 | [diff] [blame] | 411 |  | 
|  | 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 Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 420 |  | 
| Aravind Venkateswaran | 5cfdbc7 | 2014-12-03 16:06:45 -0800 | [diff] [blame] | 421 | 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 Zhou | 7e0b1e6 | 2013-07-29 15:49:39 -0400 | [diff] [blame] | 435 | pinfo->mipi.dst_format, | 
|  | 436 | ystride, lane_en, | 
| Dhaval Patel | ea19a1e | 2014-01-02 16:17:26 -0800 | [diff] [blame] | 437 | pinfo->mipi.interleave_mode, | 
| Aravind Venkateswaran | fec354c | 2014-12-04 18:10:14 -0800 | [diff] [blame] | 438 | pinfo->mipi.ctl_base); | 
| Dhaval Patel | ea19a1e | 2014-01-02 16:17:26 -0800 | [diff] [blame] | 439 |  | 
|  | 440 | if (pinfo->mipi.dual_dsi) | 
| Aravind Venkateswaran | 5cfdbc7 | 2014-12-03 16:06:45 -0800 | [diff] [blame] | 441 | 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 Venkateswaran | fec354c | 2014-12-04 18:10:14 -0800 | [diff] [blame] | 446 | pinfo->mipi.sctl_base); | 
| Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 447 |  | 
|  | 448 | return ret; | 
|  | 449 | } | 
|  | 450 |  | 
|  | 451 |  | 
|  | 452 | int 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 Patel | 551f7f6 | 2014-02-18 17:13:00 -0800 | [diff] [blame] | 474 |  | 
|  | 475 | int32_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 | } |