Huaibin Yang | cbec39b | 2014-11-07 13:54:38 -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 |
| 5 | * are 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 copyright |
| 9 | * notice, this list of conditions and the following disclaimer in |
| 10 | * the documentation and/or other materials provided with the |
| 11 | * 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 19 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 20 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
| 23 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
| 24 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 25 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| 26 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 27 | * SUCH DAMAGE. |
| 28 | */ |
| 29 | |
| 30 | #include <debug.h> |
| 31 | #include <err.h> |
| 32 | #include <smem.h> |
Veera Sundaram Sankaran | 824e6fa | 2014-12-09 11:32:58 -0800 | [diff] [blame] | 33 | #include <clock.h> |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 34 | #include <msm_panel.h> |
Dhaval Patel | 9f61f13 | 2013-07-18 14:45:11 -0700 | [diff] [blame] | 35 | #include <string.h> |
| 36 | #include <stdlib.h> |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 37 | #include <board.h> |
| 38 | #include <mdp5.h> |
Veera Sundaram Sankaran | 824e6fa | 2014-12-09 11:32:58 -0800 | [diff] [blame] | 39 | #include <qtimer.h> |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 40 | #include <platform/gpio.h> |
| 41 | #include <mipi_dsi.h> |
Huaibin Yang | b6fa92b | 2015-01-28 16:21:37 -0800 | [diff] [blame^] | 42 | #include <partition_parser.h> |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 43 | |
| 44 | #include "include/display_resource.h" |
| 45 | #include "include/panel.h" |
| 46 | #include "panel_display.h" |
| 47 | #include "gcdb_display.h" |
| 48 | #include "target/display.h" |
Arpita Banerjee | da0c39a | 2013-05-24 16:12:45 -0700 | [diff] [blame] | 49 | #include "gcdb_autopll.h" |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 50 | |
| 51 | /*---------------------------------------------------------------------------*/ |
| 52 | /* static */ |
| 53 | /*---------------------------------------------------------------------------*/ |
| 54 | static struct msm_fb_panel_data panel; |
| 55 | struct panel_struct panelstruct; |
| 56 | static uint8_t display_enable; |
| 57 | static struct mdss_dsi_phy_ctrl dsi_video_mode_phy_db; |
| 58 | |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 59 | /*---------------------------------------------------------------------------*/ |
| 60 | /* Extern */ |
| 61 | /*---------------------------------------------------------------------------*/ |
| 62 | extern int msm_display_init(struct msm_fb_panel_data *pdata); |
| 63 | extern int msm_display_off(); |
| 64 | |
| 65 | static uint32_t panel_backlight_ctrl(uint8_t enable) |
| 66 | { |
Kuogee Hsieh | 5accef1 | 2013-12-18 14:12:09 -0800 | [diff] [blame] | 67 | return target_backlight_ctrl(panelstruct.backlightinfo, enable); |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | static uint32_t mdss_dsi_panel_reset(uint8_t enable) |
| 71 | { |
| 72 | uint32_t ret = NO_ERROR; |
| 73 | |
Dhaval Patel | 29f2449 | 2013-08-08 20:45:42 -0700 | [diff] [blame] | 74 | ret = target_panel_reset(enable, panelstruct.panelresetseq, |
| 75 | &panel.panel_info); |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 76 | |
| 77 | return ret; |
| 78 | } |
| 79 | |
Arpita Banerjee | da0c39a | 2013-05-24 16:12:45 -0700 | [diff] [blame] | 80 | static uint32_t mdss_dsi_panel_clock(uint8_t enable, |
| 81 | struct msm_panel_info *pinfo) |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 82 | { |
| 83 | uint32_t ret = NO_ERROR; |
| 84 | |
Arpita Banerjee | da0c39a | 2013-05-24 16:12:45 -0700 | [diff] [blame] | 85 | ret = calculate_clock_config(pinfo); |
Huaibin Yang | cbec39b | 2014-11-07 13:54:38 -0800 | [diff] [blame] | 86 | if (ret) |
| 87 | dprintf(CRITICAL, "Clock calculation failed\n"); |
| 88 | else |
| 89 | ret = target_panel_clock(enable, pinfo); |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 90 | |
| 91 | return ret; |
| 92 | } |
| 93 | |
Kuogee Hsieh | 93bcff6 | 2014-08-22 14:02:08 -0700 | [diff] [blame] | 94 | static int mdss_dsi_panel_power(uint8_t enable, |
| 95 | struct msm_panel_info *pinfo) |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 96 | { |
| 97 | int ret = NO_ERROR; |
| 98 | |
| 99 | if (enable) { |
Kuogee Hsieh | 93bcff6 | 2014-08-22 14:02:08 -0700 | [diff] [blame] | 100 | ret = target_ldo_ctrl(enable, pinfo); |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 101 | if (ret) { |
Jayant Shekhar | c9611a9 | 2013-11-20 16:59:27 +0530 | [diff] [blame] | 102 | dprintf(CRITICAL, "LDO control enable failed\n"); |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 103 | return ret; |
| 104 | } |
| 105 | |
| 106 | /* Panel Reset */ |
Jayant Shekhar | c9611a9 | 2013-11-20 16:59:27 +0530 | [diff] [blame] | 107 | if (!panelstruct.paneldata->panel_lp11_init) { |
| 108 | ret = mdss_dsi_panel_reset(enable); |
| 109 | if (ret) { |
| 110 | dprintf(CRITICAL, "panel reset failed\n"); |
| 111 | return ret; |
| 112 | } |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 113 | } |
| 114 | dprintf(SPEW, "Panel power on done\n"); |
| 115 | } else { |
Casey Piper | 1bbd157 | 2013-09-11 16:23:18 -0700 | [diff] [blame] | 116 | /* Disable panel and ldo */ |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 117 | ret = mdss_dsi_panel_reset(enable); |
| 118 | if (ret) { |
Jayant Shekhar | c9611a9 | 2013-11-20 16:59:27 +0530 | [diff] [blame] | 119 | dprintf(CRITICAL, "panel reset disable failed\n"); |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 120 | return ret; |
| 121 | } |
| 122 | |
Kuogee Hsieh | 93bcff6 | 2014-08-22 14:02:08 -0700 | [diff] [blame] | 123 | ret = target_ldo_ctrl(enable, pinfo); |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 124 | if (ret) { |
Jayant Shekhar | c9611a9 | 2013-11-20 16:59:27 +0530 | [diff] [blame] | 125 | dprintf(CRITICAL, "ldo control disable failed\n"); |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 126 | return ret; |
| 127 | } |
| 128 | dprintf(SPEW, "Panel power off done\n"); |
| 129 | } |
| 130 | |
| 131 | return ret; |
| 132 | } |
| 133 | |
Ray Zhang | eb462f6 | 2013-12-03 17:16:08 +0800 | [diff] [blame] | 134 | static int mdss_dsi_panel_pre_init(void) |
Jayant Shekhar | c9611a9 | 2013-11-20 16:59:27 +0530 | [diff] [blame] | 135 | { |
| 136 | int ret = NO_ERROR; |
| 137 | |
Ray Zhang | eb462f6 | 2013-12-03 17:16:08 +0800 | [diff] [blame] | 138 | if (panelstruct.paneldata->panel_lp11_init) { |
| 139 | ret = mdss_dsi_panel_reset(1); |
| 140 | if (ret) { |
| 141 | dprintf(CRITICAL, "panel reset failed\n"); |
| 142 | return ret; |
Jayant Shekhar | c9611a9 | 2013-11-20 16:59:27 +0530 | [diff] [blame] | 143 | } |
Jayant Shekhar | c9611a9 | 2013-11-20 16:59:27 +0530 | [diff] [blame] | 144 | } |
| 145 | |
Ray Zhang | eb462f6 | 2013-12-03 17:16:08 +0800 | [diff] [blame] | 146 | if(panelstruct.paneldata->panel_init_delay) |
| 147 | udelay(panelstruct.paneldata->panel_init_delay); |
| 148 | |
| 149 | dprintf(SPEW, "Panel pre init done\n"); |
Jayant Shekhar | c9611a9 | 2013-11-20 16:59:27 +0530 | [diff] [blame] | 150 | return ret; |
| 151 | } |
| 152 | |
Huaibin Yang | b6fa92b | 2015-01-28 16:21:37 -0800 | [diff] [blame^] | 153 | static int mdss_dsi_dfps_get_pll_codes_cal(struct msm_panel_info *pinfo) |
Huaibin Yang | cbec39b | 2014-11-07 13:54:38 -0800 | [diff] [blame] | 154 | { |
| 155 | int ret = NO_ERROR; |
| 156 | uint32_t fps_bak; |
| 157 | uint32_t i; |
| 158 | |
| 159 | fps_bak = pinfo->mipi.frame_rate; |
| 160 | |
| 161 | for (i = 0; i < pinfo->dfps.panel_dfps.frame_rate_cnt; i++) { |
| 162 | int err; |
| 163 | pinfo->mipi.frame_rate = pinfo->dfps.panel_dfps.frame_rate[i]; |
| 164 | |
| 165 | err = mdss_dsi_panel_clock(1, pinfo); |
| 166 | if (!err) { |
| 167 | pinfo->dfps.codes_dfps[i].is_valid = 1; |
| 168 | pinfo->dfps.codes_dfps[i].frame_rate = |
| 169 | pinfo->mipi.frame_rate; |
| 170 | pinfo->dfps.codes_dfps[i].frame_rate = |
| 171 | pinfo->mipi.frame_rate; |
| 172 | pinfo->dfps.codes_dfps[i].clk_rate = |
| 173 | pinfo->mipi.dsi_pll_config->vco_clock; |
| 174 | pinfo->dfps.codes_dfps[i].pll_codes = |
| 175 | pinfo->mipi.pll_codes; |
| 176 | |
| 177 | mdss_dsi_panel_clock(0, pinfo); |
| 178 | } else { |
| 179 | ret = err; |
| 180 | pinfo->dfps.codes_dfps[i].is_valid = 0; |
| 181 | dprintf(CRITICAL, "frame_rate=%d failed!\n", |
| 182 | pinfo->mipi.frame_rate); |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | pinfo->mipi.frame_rate = fps_bak; |
| 187 | |
| 188 | return ret; |
| 189 | } |
| 190 | |
Huaibin Yang | b6fa92b | 2015-01-28 16:21:37 -0800 | [diff] [blame^] | 191 | static int mdss_dsi_dfps_get_stored_pll_codes(struct msm_panel_info *pinfo) |
| 192 | { |
| 193 | int ret = NO_ERROR; |
| 194 | int index; |
| 195 | unsigned long long ptn; |
| 196 | uint32_t blocksize; |
| 197 | struct dfps_info *dfps; |
| 198 | |
| 199 | index = partition_get_index("splash"); |
| 200 | if (index == 0) { |
| 201 | dprintf(CRITICAL, "ERROR: splash Partition table not found\n"); |
| 202 | ret = ERROR; |
| 203 | goto splash_err; |
| 204 | } |
| 205 | |
| 206 | ptn = partition_get_offset(index); |
| 207 | if (ptn == 0) { |
| 208 | dprintf(CRITICAL, "ERROR: splash Partition invalid offset\n"); |
| 209 | ret = ERROR; |
| 210 | goto splash_err; |
| 211 | } |
| 212 | |
| 213 | blocksize = mmc_get_device_blocksize(); |
| 214 | if (blocksize == 0) { |
| 215 | dprintf(CRITICAL, "ERROR:splash Partition invalid blocksize\n"); |
| 216 | ret = ERROR; |
| 217 | goto splash_err; |
| 218 | } |
| 219 | |
| 220 | dfps = (struct dfps_info *)memalign(CACHE_LINE, ROUNDUP(PAGE_SIZE, |
| 221 | CACHE_LINE)); |
| 222 | if (!dfps) { |
| 223 | dprintf(CRITICAL, "ERROR:splash Partition invalid memory\n"); |
| 224 | ret = ERROR; |
| 225 | goto splash_err; |
| 226 | } |
| 227 | |
| 228 | if (mmc_read(ptn, (uint32_t *) dfps, blocksize)) { |
| 229 | dprintf(CRITICAL, "mmc read splash failure%d\n", PAGE_SIZE); |
| 230 | ret = ERROR; |
| 231 | free(dfps); |
| 232 | goto splash_err; |
| 233 | } |
| 234 | |
| 235 | dprintf(SPEW, "enable=%d cnt=%d\n", dfps->panel_dfps.enabled, |
| 236 | dfps->panel_dfps.frame_rate_cnt); |
| 237 | |
| 238 | if (!dfps->panel_dfps.enabled || dfps->panel_dfps.frame_rate_cnt > |
| 239 | DFPS_MAX_FRAME_RATE) { |
| 240 | ret = ERROR; |
| 241 | free(dfps); |
| 242 | goto splash_err; |
| 243 | } |
| 244 | |
| 245 | pinfo->dfps = *dfps; |
| 246 | free(dfps); |
| 247 | |
| 248 | splash_err: |
| 249 | return ret; |
| 250 | } |
| 251 | |
| 252 | static int mdss_dsi_dfps_store_pll_codes(struct msm_panel_info *pinfo) |
| 253 | { |
| 254 | int ret = NO_ERROR; |
| 255 | int index; |
| 256 | unsigned long long ptn; |
| 257 | |
| 258 | index = partition_get_index("splash"); |
| 259 | if (index == 0) { |
| 260 | dprintf(CRITICAL, "ERROR: splash Partition table not found\n"); |
| 261 | ret = ERROR; |
| 262 | goto store_err; |
| 263 | } |
| 264 | |
| 265 | ptn = partition_get_offset(index); |
| 266 | if (ptn == 0) { |
| 267 | dprintf(CRITICAL, "ERROR: splash Partition invalid offset\n"); |
| 268 | ret = ERROR; |
| 269 | goto store_err; |
| 270 | } |
| 271 | |
| 272 | ret = mmc_write(ptn, sizeof(uint32_t), &pinfo->dfps); |
| 273 | if (ret) |
| 274 | dprintf(CRITICAL, "mmc write failed!\n"); |
| 275 | |
| 276 | store_err: |
| 277 | return ret; |
| 278 | } |
| 279 | |
Huaibin Yang | cbec39b | 2014-11-07 13:54:38 -0800 | [diff] [blame] | 280 | static int mdss_dsi_mipi_dfps_config(struct msm_panel_info *pinfo) |
| 281 | { |
| 282 | int ret = NO_ERROR; |
| 283 | |
| 284 | if (!pinfo) |
| 285 | return ERROR; |
| 286 | |
| 287 | if (!pinfo->dfps.panel_dfps.enabled) |
| 288 | goto dfps_done; |
| 289 | |
Huaibin Yang | b6fa92b | 2015-01-28 16:21:37 -0800 | [diff] [blame^] | 290 | if (!mdss_dsi_dfps_get_stored_pll_codes(pinfo)) { |
| 291 | dprintf(SPEW, "Found stored PLL codes!\n"); |
| 292 | goto dfps_cal_done; |
| 293 | } |
Huaibin Yang | cbec39b | 2014-11-07 13:54:38 -0800 | [diff] [blame] | 294 | |
Huaibin Yang | b6fa92b | 2015-01-28 16:21:37 -0800 | [diff] [blame^] | 295 | ret = mdss_dsi_dfps_get_pll_codes_cal(pinfo); |
| 296 | if (ret) { |
| 297 | dprintf(CRITICAL, "Cannot cal pll codes!\n"); |
| 298 | goto dfps_done; |
| 299 | } else { |
| 300 | dprintf(SPEW, "Calibrate all pll codes!\n"); |
| 301 | } |
| 302 | |
| 303 | ret = mdss_dsi_dfps_store_pll_codes(pinfo); |
| 304 | if (ret) |
| 305 | dprintf(CRITICAL, "Cannot store pll codes!\n"); |
| 306 | |
| 307 | dfps_cal_done: |
Huaibin Yang | b9f15e5 | 2015-01-22 10:34:47 -0800 | [diff] [blame] | 308 | if (pinfo->dfps.dfps_fb_base) |
| 309 | memcpy(pinfo->dfps.dfps_fb_base, &pinfo->dfps, |
| 310 | sizeof(struct dfps_info)); |
Huaibin Yang | cbec39b | 2014-11-07 13:54:38 -0800 | [diff] [blame] | 311 | dfps_done: |
| 312 | return ret; |
| 313 | } |
| 314 | |
Casey Piper | 1bbd157 | 2013-09-11 16:23:18 -0700 | [diff] [blame] | 315 | static int mdss_dsi_bl_enable(uint8_t enable) |
| 316 | { |
| 317 | int ret = NO_ERROR; |
| 318 | |
| 319 | ret = panel_backlight_ctrl(enable); |
| 320 | if (ret) |
| 321 | dprintf(CRITICAL, "Backlight %s failed\n", enable ? "enable" : |
| 322 | "disable"); |
| 323 | return ret; |
| 324 | } |
| 325 | |
Veera Sundaram Sankaran | d9a868a | 2014-10-17 12:11:01 -0700 | [diff] [blame] | 326 | static bool mdss_dsi_set_panel_node(char *panel_name, char **dsi_id, |
| 327 | char **panel_node, char **slave_panel_node, int *panel_mode) |
| 328 | { |
| 329 | if (!strcmp(panel_name, SIM_VIDEO_PANEL)) { |
| 330 | *dsi_id = SIM_DSI_ID; |
| 331 | *panel_node = SIM_VIDEO_PANEL_NODE; |
| 332 | *panel_mode = 0; |
| 333 | } else if (!strcmp(panel_name, SIM_DUALDSI_VIDEO_PANEL)) { |
| 334 | *dsi_id = SIM_DSI_ID; |
| 335 | *panel_node = SIM_DUALDSI_VIDEO_PANEL_NODE; |
| 336 | *slave_panel_node = SIM_DUALDSI_VIDEO_SLAVE_PANEL_NODE; |
| 337 | *panel_mode = 1; |
| 338 | } else if (!strcmp(panel_name, SIM_CMD_PANEL)) { |
| 339 | *dsi_id = SIM_DSI_ID; |
| 340 | *panel_node = SIM_CMD_PANEL_NODE; |
| 341 | *panel_mode = 0; |
| 342 | } else if (!strcmp(panel_name, SIM_DUALDSI_CMD_PANEL)) { |
| 343 | *dsi_id = SIM_DSI_ID; |
| 344 | *panel_node = SIM_DUALDSI_CMD_PANEL_NODE; |
| 345 | *slave_panel_node = SIM_DUALDSI_CMD_SLAVE_PANEL_NODE; |
| 346 | *panel_mode = 1; |
| 347 | } else { |
| 348 | return false; |
| 349 | } |
| 350 | return true; |
| 351 | } |
| 352 | |
Veera Sundaram Sankaran | c95d675 | 2014-07-31 11:49:52 -0700 | [diff] [blame] | 353 | bool gcdb_display_cmdline_arg(char *panel_name, char *pbuf, uint16_t buf_size) |
Dhaval Patel | 9f61f13 | 2013-07-18 14:45:11 -0700 | [diff] [blame] | 354 | { |
Channagoud Kadabi | 4767b47 | 2013-09-26 20:45:34 -0700 | [diff] [blame] | 355 | char *dsi_id = NULL; |
| 356 | char *panel_node = NULL; |
Dhaval Patel | 7b9d678 | 2014-01-03 13:31:09 -0800 | [diff] [blame] | 357 | char *slave_panel_node = NULL; |
| 358 | uint16_t dsi_id_len = 0, panel_node_len = 0, slave_panel_node_len = 0; |
| 359 | uint32_t arg_size = 0; |
Dhaval Patel | 9f61f13 | 2013-07-18 14:45:11 -0700 | [diff] [blame] | 360 | bool ret = true; |
Veera Sundaram Sankaran | d9a868a | 2014-10-17 12:11:01 -0700 | [diff] [blame] | 361 | bool rc; |
Casey Piper | a078d49 | 2013-11-15 12:26:17 -0800 | [diff] [blame] | 362 | char *default_str; |
Vineet Bajaj | 4effb13 | 2014-07-24 16:55:41 +0530 | [diff] [blame] | 363 | int panel_mode = SPLIT_DISPLAY_FLAG | DUAL_PIPE_FLAG | DST_SPLIT_FLAG; |
Dhaval Patel | 31feb29 | 2013-10-10 19:30:04 -0700 | [diff] [blame] | 364 | int prefix_string_len = strlen(DISPLAY_CMDLINE_PREFIX); |
Aravind Venkateswaran | f21253e | 2014-12-08 17:15:57 -0800 | [diff] [blame] | 365 | char *sctl_string; |
Dhaval Patel | 9f61f13 | 2013-07-18 14:45:11 -0700 | [diff] [blame] | 366 | |
Veera Sundaram Sankaran | d9a868a | 2014-10-17 12:11:01 -0700 | [diff] [blame] | 367 | panel_name += strspn(panel_name, " "); |
Dhaval Patel | 31feb29 | 2013-10-10 19:30:04 -0700 | [diff] [blame] | 368 | |
Veera Sundaram Sankaran | d9a868a | 2014-10-17 12:11:01 -0700 | [diff] [blame] | 369 | rc = mdss_dsi_set_panel_node(panel_name, &dsi_id, &panel_node, |
| 370 | &slave_panel_node, &panel_mode); |
| 371 | if (!rc) { |
| 372 | if (panelstruct.paneldata && target_cont_splash_screen()) { |
| 373 | dsi_id = panelstruct.paneldata->panel_controller; |
| 374 | panel_node = panelstruct.paneldata->panel_node_id; |
| 375 | panel_mode = |
| 376 | panelstruct.paneldata->panel_operating_mode & |
| 377 | panel_mode; |
| 378 | slave_panel_node = |
| 379 | panelstruct.paneldata->slave_panel_node_id; |
| 380 | } else { |
| 381 | if (target_is_edp()) |
| 382 | default_str = "0:edp:"; |
| 383 | else |
| 384 | default_str = "0:dsi:0:"; |
| 385 | |
| 386 | arg_size = prefix_string_len + strlen(default_str); |
| 387 | if (buf_size < arg_size) { |
| 388 | dprintf(CRITICAL, "display command line buffer is small\n"); |
| 389 | return false; |
| 390 | } |
| 391 | |
| 392 | strlcpy(pbuf, DISPLAY_CMDLINE_PREFIX, buf_size); |
| 393 | pbuf += prefix_string_len; |
| 394 | buf_size -= prefix_string_len; |
| 395 | |
| 396 | strlcpy(pbuf, default_str, buf_size); |
| 397 | return true; |
Dhaval Patel | 31feb29 | 2013-10-10 19:30:04 -0700 | [diff] [blame] | 398 | } |
Casey Piper | a078d49 | 2013-11-15 12:26:17 -0800 | [diff] [blame] | 399 | } |
Channagoud Kadabi | 4767b47 | 2013-09-26 20:45:34 -0700 | [diff] [blame] | 400 | |
Dhaval Patel | 7b9d678 | 2014-01-03 13:31:09 -0800 | [diff] [blame] | 401 | if (dsi_id == NULL || panel_node == NULL) { |
| 402 | dprintf(CRITICAL, "panel node or dsi ctrl not present\n"); |
Dhaval Patel | bc7fa21 | 2013-08-28 10:46:42 -0700 | [diff] [blame] | 403 | return false; |
Dhaval Patel | 7b9d678 | 2014-01-03 13:31:09 -0800 | [diff] [blame] | 404 | } |
| 405 | |
Ujwal Patel | 36fab7d | 2014-11-06 14:11:26 -0800 | [diff] [blame] | 406 | if (((panel_mode & SPLIT_DISPLAY_FLAG) || |
| 407 | (panel_mode & DST_SPLIT_FLAG)) && slave_panel_node == NULL) { |
Dhaval Patel | 7b9d678 | 2014-01-03 13:31:09 -0800 | [diff] [blame] | 408 | dprintf(CRITICAL, "slave node not present in dual dsi case\n"); |
| 409 | return false; |
| 410 | } |
Dhaval Patel | bc7fa21 | 2013-08-28 10:46:42 -0700 | [diff] [blame] | 411 | |
| 412 | dsi_id_len = strlen(dsi_id); |
Dhaval Patel | 7b9d678 | 2014-01-03 13:31:09 -0800 | [diff] [blame] | 413 | panel_node_len = strlen(panel_node); |
Veera Sundaram Sankaran | 58da7cf | 2014-10-03 18:05:24 -0700 | [diff] [blame] | 414 | if (!slave_panel_node) |
| 415 | slave_panel_node = NO_PANEL_CONFIG; |
| 416 | slave_panel_node_len = strlen(slave_panel_node); |
Dhaval Patel | bc7fa21 | 2013-08-28 10:46:42 -0700 | [diff] [blame] | 417 | |
Dhaval Patel | 31feb29 | 2013-10-10 19:30:04 -0700 | [diff] [blame] | 418 | arg_size = prefix_string_len + dsi_id_len + panel_node_len + |
| 419 | LK_OVERRIDE_PANEL_LEN + 1; |
Dhaval Patel | 7b9d678 | 2014-01-03 13:31:09 -0800 | [diff] [blame] | 420 | |
Aravind Venkateswaran | f21253e | 2014-12-08 17:15:57 -0800 | [diff] [blame] | 421 | if (!strcmp(panelstruct.paneldata->panel_destination, "DISPLAY_2")) |
| 422 | sctl_string = DSI_0_STRING; |
| 423 | else |
| 424 | sctl_string = DSI_1_STRING; |
| 425 | |
| 426 | arg_size += strlen(sctl_string) + slave_panel_node_len; |
Dhaval Patel | 7b9d678 | 2014-01-03 13:31:09 -0800 | [diff] [blame] | 427 | |
Veera Sundaram Sankaran | c95d675 | 2014-07-31 11:49:52 -0700 | [diff] [blame] | 428 | if (buf_size < arg_size) { |
Dhaval Patel | 7b9d678 | 2014-01-03 13:31:09 -0800 | [diff] [blame] | 429 | dprintf(CRITICAL, "display command line buffer is small\n"); |
Dhaval Patel | 9f61f13 | 2013-07-18 14:45:11 -0700 | [diff] [blame] | 430 | ret = false; |
Veera Sundaram Sankaran | c95d675 | 2014-07-31 11:49:52 -0700 | [diff] [blame] | 431 | } else { |
Dhaval Patel | 31feb29 | 2013-10-10 19:30:04 -0700 | [diff] [blame] | 432 | strlcpy(pbuf, DISPLAY_CMDLINE_PREFIX, buf_size); |
| 433 | pbuf += prefix_string_len; |
| 434 | buf_size -= prefix_string_len; |
| 435 | |
Dhaval Patel | 7b9d678 | 2014-01-03 13:31:09 -0800 | [diff] [blame] | 436 | strlcpy(pbuf, LK_OVERRIDE_PANEL, buf_size); |
| 437 | pbuf += LK_OVERRIDE_PANEL_LEN; |
| 438 | buf_size -= LK_OVERRIDE_PANEL_LEN; |
Dhaval Patel | 9f61f13 | 2013-07-18 14:45:11 -0700 | [diff] [blame] | 439 | |
| 440 | strlcpy(pbuf, dsi_id, buf_size); |
Dhaval Patel | bc7fa21 | 2013-08-28 10:46:42 -0700 | [diff] [blame] | 441 | pbuf += dsi_id_len; |
| 442 | buf_size -= dsi_id_len; |
Dhaval Patel | 9f61f13 | 2013-07-18 14:45:11 -0700 | [diff] [blame] | 443 | |
| 444 | strlcpy(pbuf, panel_node, buf_size); |
Dhaval Patel | 7b9d678 | 2014-01-03 13:31:09 -0800 | [diff] [blame] | 445 | |
Dhaval Patel | 7b9d678 | 2014-01-03 13:31:09 -0800 | [diff] [blame] | 446 | pbuf += panel_node_len; |
| 447 | buf_size -= panel_node_len; |
| 448 | |
Aravind Venkateswaran | f21253e | 2014-12-08 17:15:57 -0800 | [diff] [blame] | 449 | strlcpy(pbuf, sctl_string, buf_size); |
| 450 | pbuf += strlen(sctl_string); |
| 451 | buf_size -= strlen(sctl_string); |
Veera Sundaram Sankaran | 58da7cf | 2014-10-03 18:05:24 -0700 | [diff] [blame] | 452 | strlcpy(pbuf, slave_panel_node, buf_size); |
Dhaval Patel | 9f61f13 | 2013-07-18 14:45:11 -0700 | [diff] [blame] | 453 | } |
| 454 | return ret; |
| 455 | } |
| 456 | |
| 457 | |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 458 | static void init_platform_data() |
| 459 | { |
| 460 | memcpy(dsi_video_mode_phy_db.regulator, panel_regulator_settings, |
| 461 | REGULATOR_SIZE); |
| 462 | memcpy(dsi_video_mode_phy_db.ctrl, panel_physical_ctrl, |
| 463 | PHYSICAL_SIZE); |
| 464 | memcpy(dsi_video_mode_phy_db.strength, panel_strength_ctrl, |
| 465 | STRENGTH_SIZE); |
| 466 | memcpy(dsi_video_mode_phy_db.bistCtrl, panel_bist_ctrl, BIST_SIZE); |
| 467 | memcpy(dsi_video_mode_phy_db.laneCfg, panel_lane_config, LANE_SIZE); |
| 468 | } |
| 469 | |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 470 | static void mdss_edp_panel_init(struct msm_panel_info *pinfo) |
| 471 | { |
| 472 | return target_edp_panel_init(pinfo); |
| 473 | } |
| 474 | |
| 475 | static uint32_t mdss_edp_panel_clock(uint8_t enable, |
| 476 | struct msm_panel_info *pinfo) |
| 477 | { |
| 478 | return target_edp_panel_clock(enable, pinfo); |
| 479 | } |
| 480 | |
| 481 | static uint32_t mdss_edp_panel_enable(void) |
| 482 | { |
| 483 | return target_edp_panel_enable(); |
| 484 | } |
| 485 | |
| 486 | static uint32_t mdss_edp_panel_disable(void) |
| 487 | { |
| 488 | return target_edp_panel_disable(); |
| 489 | } |
| 490 | |
Kuogee Hsieh | 93bcff6 | 2014-08-22 14:02:08 -0700 | [diff] [blame] | 491 | static int mdss_edp_panel_power(uint8_t enable, |
| 492 | struct msm_panel_info *pinfo) |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 493 | { |
Casey Piper | c574e08 | 2013-09-05 14:54:42 -0700 | [diff] [blame] | 494 | int ret = NO_ERROR; |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 495 | |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 496 | if (enable) { |
Kuogee Hsieh | 93bcff6 | 2014-08-22 14:02:08 -0700 | [diff] [blame] | 497 | ret = target_ldo_ctrl(enable, pinfo); |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 498 | if (ret) { |
| 499 | dprintf(CRITICAL, "LDO control enable failed\n"); |
| 500 | return ret; |
| 501 | } |
| 502 | |
| 503 | ret = mdss_edp_panel_enable(); |
| 504 | if (ret) { |
| 505 | dprintf(CRITICAL, "%s: panel enable failed\n", __func__); |
| 506 | return ret; |
| 507 | } |
| 508 | dprintf(SPEW, "EDP Panel power on done\n"); |
| 509 | } else { |
| 510 | /* Disable panel and ldo */ |
| 511 | ret = mdss_edp_panel_disable(); |
| 512 | if (ret) { |
| 513 | dprintf(CRITICAL, "%s: panel disable failed\n", __func__); |
| 514 | return ret; |
| 515 | } |
| 516 | |
Kuogee Hsieh | 93bcff6 | 2014-08-22 14:02:08 -0700 | [diff] [blame] | 517 | ret = target_ldo_ctrl(enable, pinfo); |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 518 | if (ret) { |
| 519 | dprintf(CRITICAL, "%s: ldo control disable failed\n", __func__); |
| 520 | return ret; |
| 521 | } |
| 522 | dprintf(SPEW, "EDP Panel power off done\n"); |
| 523 | } |
| 524 | |
| 525 | return ret; |
| 526 | } |
| 527 | |
| 528 | static int mdss_edp_bl_enable(uint8_t enable) |
| 529 | { |
| 530 | int ret = NO_ERROR; |
| 531 | |
| 532 | ret = target_edp_bl_ctrl(enable); |
| 533 | if (ret) |
| 534 | dprintf(CRITICAL, "Backlight %s failed\n", enable ? "enable" : |
| 535 | "disable"); |
| 536 | return ret; |
| 537 | } |
| 538 | |
| 539 | int gcdb_display_init(const char *panel_name, uint32_t rev, void *base) |
| 540 | { |
| 541 | int ret = NO_ERROR; |
| 542 | int pan_type; |
| 543 | |
| 544 | pan_type = oem_panel_select(panel_name, &panelstruct, &(panel.panel_info), |
| 545 | &dsi_video_mode_phy_db); |
| 546 | |
| 547 | if (pan_type == PANEL_TYPE_DSI) { |
| 548 | init_platform_data(); |
| 549 | if (dsi_panel_init(&(panel.panel_info), &panelstruct)) { |
| 550 | dprintf(CRITICAL, "DSI panel init failed!\n"); |
| 551 | ret = ERROR; |
| 552 | goto error_gcdb_display_init; |
| 553 | } |
| 554 | |
| 555 | panel.panel_info.mipi.mdss_dsi_phy_db = &dsi_video_mode_phy_db; |
| 556 | panel.pll_clk_func = mdss_dsi_panel_clock; |
Huaibin Yang | cbec39b | 2014-11-07 13:54:38 -0800 | [diff] [blame] | 557 | panel.dfps_func = mdss_dsi_mipi_dfps_config; |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 558 | panel.power_func = mdss_dsi_panel_power; |
| 559 | panel.pre_init_func = mdss_dsi_panel_pre_init; |
| 560 | panel.bl_func = mdss_dsi_bl_enable; |
Huaibin Yang | b9f15e5 | 2015-01-22 10:34:47 -0800 | [diff] [blame] | 561 | /* |
| 562 | * If dfps enabled, reserve fb memory to store pll |
| 563 | * codes and pass pll codes values to kernel. |
| 564 | */ |
| 565 | if (panel.panel_info.dfps.panel_dfps.enabled) { |
| 566 | panel.panel_info.dfps.dfps_fb_base = base; |
| 567 | base += DFPS_PLL_CODES_SIZE; |
| 568 | dprintf(SPEW, "fb_base=0x%p!\n", base); |
| 569 | } |
| 570 | |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 571 | panel.fb.base = base; |
| 572 | panel.fb.width = panel.panel_info.xres; |
| 573 | panel.fb.height = panel.panel_info.yres; |
| 574 | panel.fb.stride = panel.panel_info.xres; |
| 575 | panel.fb.bpp = panel.panel_info.bpp; |
| 576 | panel.fb.format = panel.panel_info.mipi.dst_format; |
| 577 | } else if (pan_type == PANEL_TYPE_EDP) { |
| 578 | mdss_edp_panel_init(&(panel.panel_info)); |
| 579 | /* prepare func is set up at edp_panel_init */ |
| 580 | panel.clk_func = mdss_edp_panel_clock; |
| 581 | panel.power_func = mdss_edp_panel_power; |
| 582 | panel.bl_func = mdss_edp_bl_enable; |
| 583 | panel.fb.format = FB_FORMAT_RGB888; |
| 584 | } else { |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 585 | dprintf(CRITICAL, "Target panel init not found!\n"); |
Casey Piper | c574e08 | 2013-09-05 14:54:42 -0700 | [diff] [blame] | 586 | ret = ERR_NOT_SUPPORTED; |
| 587 | goto error_gcdb_display_init; |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 588 | |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 589 | } |
| 590 | |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 591 | panel.fb.base = base; |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 592 | panel.mdp_rev = rev; |
| 593 | |
Casey Piper | c574e08 | 2013-09-05 14:54:42 -0700 | [diff] [blame] | 594 | ret = msm_display_init(&panel); |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 595 | |
Casey Piper | c574e08 | 2013-09-05 14:54:42 -0700 | [diff] [blame] | 596 | error_gcdb_display_init: |
| 597 | display_enable = ret ? 0 : 1; |
| 598 | return ret; |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 599 | } |
| 600 | |
| 601 | void gcdb_display_shutdown(void) |
| 602 | { |
| 603 | if (display_enable) |
| 604 | msm_display_off(); |
| 605 | } |