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> |
| 42 | |
| 43 | #include "include/display_resource.h" |
| 44 | #include "include/panel.h" |
| 45 | #include "panel_display.h" |
| 46 | #include "gcdb_display.h" |
| 47 | #include "target/display.h" |
Arpita Banerjee | da0c39a | 2013-05-24 16:12:45 -0700 | [diff] [blame] | 48 | #include "gcdb_autopll.h" |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 49 | |
| 50 | /*---------------------------------------------------------------------------*/ |
| 51 | /* static */ |
| 52 | /*---------------------------------------------------------------------------*/ |
| 53 | static struct msm_fb_panel_data panel; |
| 54 | struct panel_struct panelstruct; |
| 55 | static uint8_t display_enable; |
| 56 | static struct mdss_dsi_phy_ctrl dsi_video_mode_phy_db; |
| 57 | |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 58 | /*---------------------------------------------------------------------------*/ |
| 59 | /* Extern */ |
| 60 | /*---------------------------------------------------------------------------*/ |
| 61 | extern int msm_display_init(struct msm_fb_panel_data *pdata); |
| 62 | extern int msm_display_off(); |
| 63 | |
| 64 | static uint32_t panel_backlight_ctrl(uint8_t enable) |
| 65 | { |
Kuogee Hsieh | 5accef1 | 2013-12-18 14:12:09 -0800 | [diff] [blame] | 66 | return target_backlight_ctrl(panelstruct.backlightinfo, enable); |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | static uint32_t mdss_dsi_panel_reset(uint8_t enable) |
| 70 | { |
| 71 | uint32_t ret = NO_ERROR; |
| 72 | |
Dhaval Patel | 29f2449 | 2013-08-08 20:45:42 -0700 | [diff] [blame] | 73 | ret = target_panel_reset(enable, panelstruct.panelresetseq, |
| 74 | &panel.panel_info); |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 75 | |
| 76 | return ret; |
| 77 | } |
| 78 | |
Arpita Banerjee | da0c39a | 2013-05-24 16:12:45 -0700 | [diff] [blame] | 79 | static uint32_t mdss_dsi_panel_clock(uint8_t enable, |
| 80 | struct msm_panel_info *pinfo) |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 81 | { |
| 82 | uint32_t ret = NO_ERROR; |
| 83 | |
Arpita Banerjee | da0c39a | 2013-05-24 16:12:45 -0700 | [diff] [blame] | 84 | ret = calculate_clock_config(pinfo); |
Huaibin Yang | cbec39b | 2014-11-07 13:54:38 -0800 | [diff] [blame^] | 85 | if (ret) |
| 86 | dprintf(CRITICAL, "Clock calculation failed\n"); |
| 87 | else |
| 88 | ret = target_panel_clock(enable, pinfo); |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 89 | |
| 90 | return ret; |
| 91 | } |
| 92 | |
Kuogee Hsieh | 93bcff6 | 2014-08-22 14:02:08 -0700 | [diff] [blame] | 93 | static int mdss_dsi_panel_power(uint8_t enable, |
| 94 | struct msm_panel_info *pinfo) |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 95 | { |
| 96 | int ret = NO_ERROR; |
| 97 | |
| 98 | if (enable) { |
Kuogee Hsieh | 93bcff6 | 2014-08-22 14:02:08 -0700 | [diff] [blame] | 99 | ret = target_ldo_ctrl(enable, pinfo); |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 100 | if (ret) { |
Jayant Shekhar | c9611a9 | 2013-11-20 16:59:27 +0530 | [diff] [blame] | 101 | dprintf(CRITICAL, "LDO control enable failed\n"); |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 102 | return ret; |
| 103 | } |
| 104 | |
| 105 | /* Panel Reset */ |
Jayant Shekhar | c9611a9 | 2013-11-20 16:59:27 +0530 | [diff] [blame] | 106 | if (!panelstruct.paneldata->panel_lp11_init) { |
| 107 | ret = mdss_dsi_panel_reset(enable); |
| 108 | if (ret) { |
| 109 | dprintf(CRITICAL, "panel reset failed\n"); |
| 110 | return ret; |
| 111 | } |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 112 | } |
| 113 | dprintf(SPEW, "Panel power on done\n"); |
| 114 | } else { |
Casey Piper | 1bbd157 | 2013-09-11 16:23:18 -0700 | [diff] [blame] | 115 | /* Disable panel and ldo */ |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 116 | ret = mdss_dsi_panel_reset(enable); |
| 117 | if (ret) { |
Jayant Shekhar | c9611a9 | 2013-11-20 16:59:27 +0530 | [diff] [blame] | 118 | dprintf(CRITICAL, "panel reset disable failed\n"); |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 119 | return ret; |
| 120 | } |
| 121 | |
Kuogee Hsieh | 93bcff6 | 2014-08-22 14:02:08 -0700 | [diff] [blame] | 122 | ret = target_ldo_ctrl(enable, pinfo); |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 123 | if (ret) { |
Jayant Shekhar | c9611a9 | 2013-11-20 16:59:27 +0530 | [diff] [blame] | 124 | dprintf(CRITICAL, "ldo control disable failed\n"); |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 125 | return ret; |
| 126 | } |
| 127 | dprintf(SPEW, "Panel power off done\n"); |
| 128 | } |
| 129 | |
| 130 | return ret; |
| 131 | } |
| 132 | |
Ray Zhang | eb462f6 | 2013-12-03 17:16:08 +0800 | [diff] [blame] | 133 | static int mdss_dsi_panel_pre_init(void) |
Jayant Shekhar | c9611a9 | 2013-11-20 16:59:27 +0530 | [diff] [blame] | 134 | { |
| 135 | int ret = NO_ERROR; |
| 136 | |
Ray Zhang | eb462f6 | 2013-12-03 17:16:08 +0800 | [diff] [blame] | 137 | if (panelstruct.paneldata->panel_lp11_init) { |
| 138 | ret = mdss_dsi_panel_reset(1); |
| 139 | if (ret) { |
| 140 | dprintf(CRITICAL, "panel reset failed\n"); |
| 141 | return ret; |
Jayant Shekhar | c9611a9 | 2013-11-20 16:59:27 +0530 | [diff] [blame] | 142 | } |
Jayant Shekhar | c9611a9 | 2013-11-20 16:59:27 +0530 | [diff] [blame] | 143 | } |
| 144 | |
Ray Zhang | eb462f6 | 2013-12-03 17:16:08 +0800 | [diff] [blame] | 145 | if(panelstruct.paneldata->panel_init_delay) |
| 146 | udelay(panelstruct.paneldata->panel_init_delay); |
| 147 | |
| 148 | dprintf(SPEW, "Panel pre init done\n"); |
Jayant Shekhar | c9611a9 | 2013-11-20 16:59:27 +0530 | [diff] [blame] | 149 | return ret; |
| 150 | } |
| 151 | |
Huaibin Yang | cbec39b | 2014-11-07 13:54:38 -0800 | [diff] [blame^] | 152 | static int mdss_dsi_dfps_get_pll_codes(struct msm_panel_info *pinfo) |
| 153 | { |
| 154 | int ret = NO_ERROR; |
| 155 | uint32_t fps_bak; |
| 156 | uint32_t i; |
| 157 | |
| 158 | fps_bak = pinfo->mipi.frame_rate; |
| 159 | |
| 160 | for (i = 0; i < pinfo->dfps.panel_dfps.frame_rate_cnt; i++) { |
| 161 | int err; |
| 162 | pinfo->mipi.frame_rate = pinfo->dfps.panel_dfps.frame_rate[i]; |
| 163 | |
| 164 | err = mdss_dsi_panel_clock(1, pinfo); |
| 165 | if (!err) { |
| 166 | pinfo->dfps.codes_dfps[i].is_valid = 1; |
| 167 | pinfo->dfps.codes_dfps[i].frame_rate = |
| 168 | pinfo->mipi.frame_rate; |
| 169 | pinfo->dfps.codes_dfps[i].frame_rate = |
| 170 | pinfo->mipi.frame_rate; |
| 171 | pinfo->dfps.codes_dfps[i].clk_rate = |
| 172 | pinfo->mipi.dsi_pll_config->vco_clock; |
| 173 | pinfo->dfps.codes_dfps[i].pll_codes = |
| 174 | pinfo->mipi.pll_codes; |
| 175 | |
| 176 | mdss_dsi_panel_clock(0, pinfo); |
| 177 | } else { |
| 178 | ret = err; |
| 179 | pinfo->dfps.codes_dfps[i].is_valid = 0; |
| 180 | dprintf(CRITICAL, "frame_rate=%d failed!\n", |
| 181 | pinfo->mipi.frame_rate); |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | pinfo->mipi.frame_rate = fps_bak; |
| 186 | |
| 187 | return ret; |
| 188 | } |
| 189 | |
| 190 | static int mdss_dsi_mipi_dfps_config(struct msm_panel_info *pinfo) |
| 191 | { |
| 192 | int ret = NO_ERROR; |
| 193 | |
| 194 | if (!pinfo) |
| 195 | return ERROR; |
| 196 | |
| 197 | if (!pinfo->dfps.panel_dfps.enabled) |
| 198 | goto dfps_done; |
| 199 | |
| 200 | ret = mdss_dsi_dfps_get_pll_codes(pinfo); |
| 201 | |
| 202 | dfps_done: |
| 203 | return ret; |
| 204 | } |
| 205 | |
Casey Piper | 1bbd157 | 2013-09-11 16:23:18 -0700 | [diff] [blame] | 206 | static int mdss_dsi_bl_enable(uint8_t enable) |
| 207 | { |
| 208 | int ret = NO_ERROR; |
| 209 | |
| 210 | ret = panel_backlight_ctrl(enable); |
| 211 | if (ret) |
| 212 | dprintf(CRITICAL, "Backlight %s failed\n", enable ? "enable" : |
| 213 | "disable"); |
| 214 | return ret; |
| 215 | } |
| 216 | |
Veera Sundaram Sankaran | d9a868a | 2014-10-17 12:11:01 -0700 | [diff] [blame] | 217 | static bool mdss_dsi_set_panel_node(char *panel_name, char **dsi_id, |
| 218 | char **panel_node, char **slave_panel_node, int *panel_mode) |
| 219 | { |
| 220 | if (!strcmp(panel_name, SIM_VIDEO_PANEL)) { |
| 221 | *dsi_id = SIM_DSI_ID; |
| 222 | *panel_node = SIM_VIDEO_PANEL_NODE; |
| 223 | *panel_mode = 0; |
| 224 | } else if (!strcmp(panel_name, SIM_DUALDSI_VIDEO_PANEL)) { |
| 225 | *dsi_id = SIM_DSI_ID; |
| 226 | *panel_node = SIM_DUALDSI_VIDEO_PANEL_NODE; |
| 227 | *slave_panel_node = SIM_DUALDSI_VIDEO_SLAVE_PANEL_NODE; |
| 228 | *panel_mode = 1; |
| 229 | } else if (!strcmp(panel_name, SIM_CMD_PANEL)) { |
| 230 | *dsi_id = SIM_DSI_ID; |
| 231 | *panel_node = SIM_CMD_PANEL_NODE; |
| 232 | *panel_mode = 0; |
| 233 | } else if (!strcmp(panel_name, SIM_DUALDSI_CMD_PANEL)) { |
| 234 | *dsi_id = SIM_DSI_ID; |
| 235 | *panel_node = SIM_DUALDSI_CMD_PANEL_NODE; |
| 236 | *slave_panel_node = SIM_DUALDSI_CMD_SLAVE_PANEL_NODE; |
| 237 | *panel_mode = 1; |
| 238 | } else { |
| 239 | return false; |
| 240 | } |
| 241 | return true; |
| 242 | } |
| 243 | |
Veera Sundaram Sankaran | c95d675 | 2014-07-31 11:49:52 -0700 | [diff] [blame] | 244 | 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] | 245 | { |
Channagoud Kadabi | 4767b47 | 2013-09-26 20:45:34 -0700 | [diff] [blame] | 246 | char *dsi_id = NULL; |
| 247 | char *panel_node = NULL; |
Dhaval Patel | 7b9d678 | 2014-01-03 13:31:09 -0800 | [diff] [blame] | 248 | char *slave_panel_node = NULL; |
| 249 | uint16_t dsi_id_len = 0, panel_node_len = 0, slave_panel_node_len = 0; |
| 250 | uint32_t arg_size = 0; |
Dhaval Patel | 9f61f13 | 2013-07-18 14:45:11 -0700 | [diff] [blame] | 251 | bool ret = true; |
Veera Sundaram Sankaran | d9a868a | 2014-10-17 12:11:01 -0700 | [diff] [blame] | 252 | bool rc; |
Casey Piper | a078d49 | 2013-11-15 12:26:17 -0800 | [diff] [blame] | 253 | char *default_str; |
Vineet Bajaj | 4effb13 | 2014-07-24 16:55:41 +0530 | [diff] [blame] | 254 | int panel_mode = SPLIT_DISPLAY_FLAG | DUAL_PIPE_FLAG | DST_SPLIT_FLAG; |
Dhaval Patel | 31feb29 | 2013-10-10 19:30:04 -0700 | [diff] [blame] | 255 | int prefix_string_len = strlen(DISPLAY_CMDLINE_PREFIX); |
Aravind Venkateswaran | f21253e | 2014-12-08 17:15:57 -0800 | [diff] [blame] | 256 | char *sctl_string; |
Dhaval Patel | 9f61f13 | 2013-07-18 14:45:11 -0700 | [diff] [blame] | 257 | |
Veera Sundaram Sankaran | d9a868a | 2014-10-17 12:11:01 -0700 | [diff] [blame] | 258 | panel_name += strspn(panel_name, " "); |
Dhaval Patel | 31feb29 | 2013-10-10 19:30:04 -0700 | [diff] [blame] | 259 | |
Veera Sundaram Sankaran | d9a868a | 2014-10-17 12:11:01 -0700 | [diff] [blame] | 260 | rc = mdss_dsi_set_panel_node(panel_name, &dsi_id, &panel_node, |
| 261 | &slave_panel_node, &panel_mode); |
| 262 | if (!rc) { |
| 263 | if (panelstruct.paneldata && target_cont_splash_screen()) { |
| 264 | dsi_id = panelstruct.paneldata->panel_controller; |
| 265 | panel_node = panelstruct.paneldata->panel_node_id; |
| 266 | panel_mode = |
| 267 | panelstruct.paneldata->panel_operating_mode & |
| 268 | panel_mode; |
| 269 | slave_panel_node = |
| 270 | panelstruct.paneldata->slave_panel_node_id; |
| 271 | } else { |
| 272 | if (target_is_edp()) |
| 273 | default_str = "0:edp:"; |
| 274 | else |
| 275 | default_str = "0:dsi:0:"; |
| 276 | |
| 277 | arg_size = prefix_string_len + strlen(default_str); |
| 278 | if (buf_size < arg_size) { |
| 279 | dprintf(CRITICAL, "display command line buffer is small\n"); |
| 280 | return false; |
| 281 | } |
| 282 | |
| 283 | strlcpy(pbuf, DISPLAY_CMDLINE_PREFIX, buf_size); |
| 284 | pbuf += prefix_string_len; |
| 285 | buf_size -= prefix_string_len; |
| 286 | |
| 287 | strlcpy(pbuf, default_str, buf_size); |
| 288 | return true; |
Dhaval Patel | 31feb29 | 2013-10-10 19:30:04 -0700 | [diff] [blame] | 289 | } |
Casey Piper | a078d49 | 2013-11-15 12:26:17 -0800 | [diff] [blame] | 290 | } |
Channagoud Kadabi | 4767b47 | 2013-09-26 20:45:34 -0700 | [diff] [blame] | 291 | |
Dhaval Patel | 7b9d678 | 2014-01-03 13:31:09 -0800 | [diff] [blame] | 292 | if (dsi_id == NULL || panel_node == NULL) { |
| 293 | dprintf(CRITICAL, "panel node or dsi ctrl not present\n"); |
Dhaval Patel | bc7fa21 | 2013-08-28 10:46:42 -0700 | [diff] [blame] | 294 | return false; |
Dhaval Patel | 7b9d678 | 2014-01-03 13:31:09 -0800 | [diff] [blame] | 295 | } |
| 296 | |
Ujwal Patel | 36fab7d | 2014-11-06 14:11:26 -0800 | [diff] [blame] | 297 | if (((panel_mode & SPLIT_DISPLAY_FLAG) || |
| 298 | (panel_mode & DST_SPLIT_FLAG)) && slave_panel_node == NULL) { |
Dhaval Patel | 7b9d678 | 2014-01-03 13:31:09 -0800 | [diff] [blame] | 299 | dprintf(CRITICAL, "slave node not present in dual dsi case\n"); |
| 300 | return false; |
| 301 | } |
Dhaval Patel | bc7fa21 | 2013-08-28 10:46:42 -0700 | [diff] [blame] | 302 | |
| 303 | dsi_id_len = strlen(dsi_id); |
Dhaval Patel | 7b9d678 | 2014-01-03 13:31:09 -0800 | [diff] [blame] | 304 | panel_node_len = strlen(panel_node); |
Veera Sundaram Sankaran | 58da7cf | 2014-10-03 18:05:24 -0700 | [diff] [blame] | 305 | if (!slave_panel_node) |
| 306 | slave_panel_node = NO_PANEL_CONFIG; |
| 307 | slave_panel_node_len = strlen(slave_panel_node); |
Dhaval Patel | bc7fa21 | 2013-08-28 10:46:42 -0700 | [diff] [blame] | 308 | |
Dhaval Patel | 31feb29 | 2013-10-10 19:30:04 -0700 | [diff] [blame] | 309 | arg_size = prefix_string_len + dsi_id_len + panel_node_len + |
| 310 | LK_OVERRIDE_PANEL_LEN + 1; |
Dhaval Patel | 7b9d678 | 2014-01-03 13:31:09 -0800 | [diff] [blame] | 311 | |
Aravind Venkateswaran | f21253e | 2014-12-08 17:15:57 -0800 | [diff] [blame] | 312 | if (!strcmp(panelstruct.paneldata->panel_destination, "DISPLAY_2")) |
| 313 | sctl_string = DSI_0_STRING; |
| 314 | else |
| 315 | sctl_string = DSI_1_STRING; |
| 316 | |
| 317 | arg_size += strlen(sctl_string) + slave_panel_node_len; |
Dhaval Patel | 7b9d678 | 2014-01-03 13:31:09 -0800 | [diff] [blame] | 318 | |
Veera Sundaram Sankaran | c95d675 | 2014-07-31 11:49:52 -0700 | [diff] [blame] | 319 | if (buf_size < arg_size) { |
Dhaval Patel | 7b9d678 | 2014-01-03 13:31:09 -0800 | [diff] [blame] | 320 | dprintf(CRITICAL, "display command line buffer is small\n"); |
Dhaval Patel | 9f61f13 | 2013-07-18 14:45:11 -0700 | [diff] [blame] | 321 | ret = false; |
Veera Sundaram Sankaran | c95d675 | 2014-07-31 11:49:52 -0700 | [diff] [blame] | 322 | } else { |
Dhaval Patel | 31feb29 | 2013-10-10 19:30:04 -0700 | [diff] [blame] | 323 | strlcpy(pbuf, DISPLAY_CMDLINE_PREFIX, buf_size); |
| 324 | pbuf += prefix_string_len; |
| 325 | buf_size -= prefix_string_len; |
| 326 | |
Dhaval Patel | 7b9d678 | 2014-01-03 13:31:09 -0800 | [diff] [blame] | 327 | strlcpy(pbuf, LK_OVERRIDE_PANEL, buf_size); |
| 328 | pbuf += LK_OVERRIDE_PANEL_LEN; |
| 329 | buf_size -= LK_OVERRIDE_PANEL_LEN; |
Dhaval Patel | 9f61f13 | 2013-07-18 14:45:11 -0700 | [diff] [blame] | 330 | |
| 331 | strlcpy(pbuf, dsi_id, buf_size); |
Dhaval Patel | bc7fa21 | 2013-08-28 10:46:42 -0700 | [diff] [blame] | 332 | pbuf += dsi_id_len; |
| 333 | buf_size -= dsi_id_len; |
Dhaval Patel | 9f61f13 | 2013-07-18 14:45:11 -0700 | [diff] [blame] | 334 | |
| 335 | strlcpy(pbuf, panel_node, buf_size); |
Dhaval Patel | 7b9d678 | 2014-01-03 13:31:09 -0800 | [diff] [blame] | 336 | |
Dhaval Patel | 7b9d678 | 2014-01-03 13:31:09 -0800 | [diff] [blame] | 337 | pbuf += panel_node_len; |
| 338 | buf_size -= panel_node_len; |
| 339 | |
Aravind Venkateswaran | f21253e | 2014-12-08 17:15:57 -0800 | [diff] [blame] | 340 | strlcpy(pbuf, sctl_string, buf_size); |
| 341 | pbuf += strlen(sctl_string); |
| 342 | buf_size -= strlen(sctl_string); |
Veera Sundaram Sankaran | 58da7cf | 2014-10-03 18:05:24 -0700 | [diff] [blame] | 343 | strlcpy(pbuf, slave_panel_node, buf_size); |
Dhaval Patel | 9f61f13 | 2013-07-18 14:45:11 -0700 | [diff] [blame] | 344 | } |
| 345 | return ret; |
| 346 | } |
| 347 | |
| 348 | |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 349 | static void init_platform_data() |
| 350 | { |
| 351 | memcpy(dsi_video_mode_phy_db.regulator, panel_regulator_settings, |
| 352 | REGULATOR_SIZE); |
| 353 | memcpy(dsi_video_mode_phy_db.ctrl, panel_physical_ctrl, |
| 354 | PHYSICAL_SIZE); |
| 355 | memcpy(dsi_video_mode_phy_db.strength, panel_strength_ctrl, |
| 356 | STRENGTH_SIZE); |
| 357 | memcpy(dsi_video_mode_phy_db.bistCtrl, panel_bist_ctrl, BIST_SIZE); |
| 358 | memcpy(dsi_video_mode_phy_db.laneCfg, panel_lane_config, LANE_SIZE); |
| 359 | } |
| 360 | |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 361 | static void mdss_edp_panel_init(struct msm_panel_info *pinfo) |
| 362 | { |
| 363 | return target_edp_panel_init(pinfo); |
| 364 | } |
| 365 | |
| 366 | static uint32_t mdss_edp_panel_clock(uint8_t enable, |
| 367 | struct msm_panel_info *pinfo) |
| 368 | { |
| 369 | return target_edp_panel_clock(enable, pinfo); |
| 370 | } |
| 371 | |
| 372 | static uint32_t mdss_edp_panel_enable(void) |
| 373 | { |
| 374 | return target_edp_panel_enable(); |
| 375 | } |
| 376 | |
| 377 | static uint32_t mdss_edp_panel_disable(void) |
| 378 | { |
| 379 | return target_edp_panel_disable(); |
| 380 | } |
| 381 | |
Kuogee Hsieh | 93bcff6 | 2014-08-22 14:02:08 -0700 | [diff] [blame] | 382 | static int mdss_edp_panel_power(uint8_t enable, |
| 383 | struct msm_panel_info *pinfo) |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 384 | { |
Casey Piper | c574e08 | 2013-09-05 14:54:42 -0700 | [diff] [blame] | 385 | int ret = NO_ERROR; |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 386 | |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 387 | if (enable) { |
Kuogee Hsieh | 93bcff6 | 2014-08-22 14:02:08 -0700 | [diff] [blame] | 388 | ret = target_ldo_ctrl(enable, pinfo); |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 389 | if (ret) { |
| 390 | dprintf(CRITICAL, "LDO control enable failed\n"); |
| 391 | return ret; |
| 392 | } |
| 393 | |
| 394 | ret = mdss_edp_panel_enable(); |
| 395 | if (ret) { |
| 396 | dprintf(CRITICAL, "%s: panel enable failed\n", __func__); |
| 397 | return ret; |
| 398 | } |
| 399 | dprintf(SPEW, "EDP Panel power on done\n"); |
| 400 | } else { |
| 401 | /* Disable panel and ldo */ |
| 402 | ret = mdss_edp_panel_disable(); |
| 403 | if (ret) { |
| 404 | dprintf(CRITICAL, "%s: panel disable failed\n", __func__); |
| 405 | return ret; |
| 406 | } |
| 407 | |
Kuogee Hsieh | 93bcff6 | 2014-08-22 14:02:08 -0700 | [diff] [blame] | 408 | ret = target_ldo_ctrl(enable, pinfo); |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 409 | if (ret) { |
| 410 | dprintf(CRITICAL, "%s: ldo control disable failed\n", __func__); |
| 411 | return ret; |
| 412 | } |
| 413 | dprintf(SPEW, "EDP Panel power off done\n"); |
| 414 | } |
| 415 | |
| 416 | return ret; |
| 417 | } |
| 418 | |
| 419 | static int mdss_edp_bl_enable(uint8_t enable) |
| 420 | { |
| 421 | int ret = NO_ERROR; |
| 422 | |
| 423 | ret = target_edp_bl_ctrl(enable); |
| 424 | if (ret) |
| 425 | dprintf(CRITICAL, "Backlight %s failed\n", enable ? "enable" : |
| 426 | "disable"); |
| 427 | return ret; |
| 428 | } |
| 429 | |
| 430 | int gcdb_display_init(const char *panel_name, uint32_t rev, void *base) |
| 431 | { |
| 432 | int ret = NO_ERROR; |
| 433 | int pan_type; |
| 434 | |
| 435 | pan_type = oem_panel_select(panel_name, &panelstruct, &(panel.panel_info), |
| 436 | &dsi_video_mode_phy_db); |
| 437 | |
| 438 | if (pan_type == PANEL_TYPE_DSI) { |
| 439 | init_platform_data(); |
| 440 | if (dsi_panel_init(&(panel.panel_info), &panelstruct)) { |
| 441 | dprintf(CRITICAL, "DSI panel init failed!\n"); |
| 442 | ret = ERROR; |
| 443 | goto error_gcdb_display_init; |
| 444 | } |
| 445 | |
| 446 | panel.panel_info.mipi.mdss_dsi_phy_db = &dsi_video_mode_phy_db; |
| 447 | panel.pll_clk_func = mdss_dsi_panel_clock; |
Huaibin Yang | cbec39b | 2014-11-07 13:54:38 -0800 | [diff] [blame^] | 448 | panel.dfps_func = mdss_dsi_mipi_dfps_config; |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 449 | panel.power_func = mdss_dsi_panel_power; |
| 450 | panel.pre_init_func = mdss_dsi_panel_pre_init; |
| 451 | panel.bl_func = mdss_dsi_bl_enable; |
| 452 | panel.fb.base = base; |
| 453 | panel.fb.width = panel.panel_info.xres; |
| 454 | panel.fb.height = panel.panel_info.yres; |
| 455 | panel.fb.stride = panel.panel_info.xres; |
| 456 | panel.fb.bpp = panel.panel_info.bpp; |
| 457 | panel.fb.format = panel.panel_info.mipi.dst_format; |
| 458 | } else if (pan_type == PANEL_TYPE_EDP) { |
| 459 | mdss_edp_panel_init(&(panel.panel_info)); |
| 460 | /* prepare func is set up at edp_panel_init */ |
| 461 | panel.clk_func = mdss_edp_panel_clock; |
| 462 | panel.power_func = mdss_edp_panel_power; |
| 463 | panel.bl_func = mdss_edp_bl_enable; |
| 464 | panel.fb.format = FB_FORMAT_RGB888; |
| 465 | } else { |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 466 | dprintf(CRITICAL, "Target panel init not found!\n"); |
Casey Piper | c574e08 | 2013-09-05 14:54:42 -0700 | [diff] [blame] | 467 | ret = ERR_NOT_SUPPORTED; |
| 468 | goto error_gcdb_display_init; |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 469 | |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 470 | } |
| 471 | |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 472 | panel.fb.base = base; |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 473 | panel.mdp_rev = rev; |
| 474 | |
Casey Piper | c574e08 | 2013-09-05 14:54:42 -0700 | [diff] [blame] | 475 | ret = msm_display_init(&panel); |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 476 | |
Casey Piper | c574e08 | 2013-09-05 14:54:42 -0700 | [diff] [blame] | 477 | error_gcdb_display_init: |
| 478 | display_enable = ret ? 0 : 1; |
| 479 | return ret; |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 480 | } |
| 481 | |
| 482 | void gcdb_display_shutdown(void) |
| 483 | { |
| 484 | if (display_enable) |
| 485 | msm_display_off(); |
| 486 | } |