Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. |
| 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> |
| 33 | #include <msm_panel.h> |
| 34 | #include <board.h> |
| 35 | #include <mipi_dsi.h> |
Mao Flynn | 8140947 | 2014-04-10 15:01:30 +0800 | [diff] [blame] | 36 | #include <target/display.h> |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 37 | |
| 38 | #include "include/panel.h" |
| 39 | #include "panel_display.h" |
| 40 | |
| 41 | /*---------------------------------------------------------------------------*/ |
| 42 | /* GCDB Panel Database */ |
| 43 | /*---------------------------------------------------------------------------*/ |
| 44 | #include "include/panel_jdi_1080p_video.h" |
Padmanabhan Komanduru | 1869a76 | 2014-04-01 20:12:05 +0530 | [diff] [blame] | 45 | #include "include/panel_nt35590_720p_video.h" |
| 46 | #include "include/panel_nt35590_720p_cmd.h" |
Mao Flynn | 8140947 | 2014-04-10 15:01:30 +0800 | [diff] [blame] | 47 | #include "include/panel_innolux_720p_video.h" |
Shuo Yan | 40c660c | 2014-04-24 15:58:43 +0800 | [diff] [blame] | 48 | #include "include/panel_otm8019a_fwvga_video.h" |
Padmanabhan Komanduru | 1869a76 | 2014-04-01 20:12:05 +0530 | [diff] [blame] | 49 | |
| 50 | #define DISPLAY_MAX_PANEL_DETECTION 2 |
Shuo Yan | 4f57eb2 | 2014-05-27 10:57:17 +0800 | [diff] [blame] | 51 | #define OTM8019A_FWVGA_VIDEO_PANEL_ON_DELAY 50 |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 52 | |
| 53 | /*---------------------------------------------------------------------------*/ |
| 54 | /* static panel selection variable */ |
| 55 | /*---------------------------------------------------------------------------*/ |
Padmanabhan Komanduru | 1869a76 | 2014-04-01 20:12:05 +0530 | [diff] [blame] | 56 | static uint32_t auto_pan_loop = 0; |
| 57 | |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 58 | enum { |
| 59 | JDI_1080P_VIDEO_PANEL, |
Padmanabhan Komanduru | 1869a76 | 2014-04-01 20:12:05 +0530 | [diff] [blame] | 60 | NT35590_720P_VIDEO_PANEL, |
| 61 | NT35590_720P_CMD_PANEL, |
Mao Flynn | 8140947 | 2014-04-10 15:01:30 +0800 | [diff] [blame] | 62 | INNOLUX_720P_VIDEO_PANEL, |
Shuo Yan | 40c660c | 2014-04-24 15:58:43 +0800 | [diff] [blame] | 63 | OTM8019A_FWVGA_VIDEO_PANEL, |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 64 | UNKNOWN_PANEL |
| 65 | }; |
| 66 | |
| 67 | /* |
| 68 | * The list of panels that are supported on this target. |
| 69 | * Any panel in this list can be selected using fastboot oem command. |
| 70 | */ |
| 71 | static struct panel_list supp_panels[] = { |
| 72 | {"jdi_1080p_video", JDI_1080P_VIDEO_PANEL}, |
Padmanabhan Komanduru | 1869a76 | 2014-04-01 20:12:05 +0530 | [diff] [blame] | 73 | {"nt35590_720p_video", NT35590_720P_VIDEO_PANEL}, |
| 74 | {"nt35590_720p_cmd", NT35590_720P_CMD_PANEL}, |
Mao Flynn | 8140947 | 2014-04-10 15:01:30 +0800 | [diff] [blame] | 75 | {"innolux_720p_video", INNOLUX_720P_VIDEO_PANEL}, |
Shuo Yan | 40c660c | 2014-04-24 15:58:43 +0800 | [diff] [blame] | 76 | {"otm8019a_fwvga_video", OTM8019A_FWVGA_VIDEO_PANEL}, |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | static uint32_t panel_id; |
| 80 | |
| 81 | int oem_panel_rotation() |
| 82 | { |
| 83 | return NO_ERROR; |
| 84 | } |
| 85 | |
| 86 | int oem_panel_on() |
| 87 | { |
Shuo Yan | 4f57eb2 | 2014-05-27 10:57:17 +0800 | [diff] [blame] | 88 | /* |
| 89 | *OEM can keep there panel specific on instructions in this |
| 90 | *function |
| 91 | */ |
| 92 | if (panel_id == OTM8019A_FWVGA_VIDEO_PANEL) { |
| 93 | /* needs extra delay to avoid unexpected artifacts */ |
| 94 | mdelay(OTM8019A_FWVGA_VIDEO_PANEL_ON_DELAY); |
| 95 | } |
| 96 | |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 97 | return NO_ERROR; |
| 98 | } |
| 99 | |
| 100 | int oem_panel_off() |
| 101 | { |
| 102 | /* OEM can keep their panel specific off instructions |
| 103 | * in this function |
| 104 | */ |
| 105 | return NO_ERROR; |
| 106 | } |
| 107 | |
| 108 | static bool init_panel_data(struct panel_struct *panelstruct, |
| 109 | struct msm_panel_info *pinfo, |
| 110 | struct mdss_dsi_phy_ctrl *phy_db) |
| 111 | { |
| 112 | bool ret = true; |
| 113 | |
| 114 | switch (panel_id) { |
| 115 | case JDI_1080P_VIDEO_PANEL: |
| 116 | panelstruct->paneldata = &jdi_1080p_video_panel_data; |
| 117 | panelstruct->paneldata->panel_with_enable_gpio = 1; |
| 118 | panelstruct->panelres = &jdi_1080p_video_panel_res; |
| 119 | panelstruct->color = &jdi_1080p_video_color; |
| 120 | panelstruct->videopanel = &jdi_1080p_video_video_panel; |
| 121 | panelstruct->commandpanel = &jdi_1080p_video_command_panel; |
| 122 | panelstruct->state = &jdi_1080p_video_state; |
| 123 | panelstruct->laneconfig = &jdi_1080p_video_lane_config; |
| 124 | panelstruct->paneltiminginfo |
| 125 | = &jdi_1080p_video_timing_info; |
| 126 | panelstruct->panelresetseq |
| 127 | = &jdi_1080p_video_panel_reset_seq; |
| 128 | panelstruct->backlightinfo = &jdi_1080p_video_backlight; |
| 129 | pinfo->mipi.panel_cmds |
| 130 | = jdi_1080p_video_on_command; |
| 131 | pinfo->mipi.num_of_panel_cmds |
| 132 | = JDI_1080P_VIDEO_ON_COMMAND; |
| 133 | memcpy(phy_db->timing, |
| 134 | jdi_1080p_video_timings, TIMING_SIZE); |
Padmanabhan Komanduru | 1869a76 | 2014-04-01 20:12:05 +0530 | [diff] [blame] | 135 | pinfo->mipi.signature = JDI_1080P_VIDEO_SIGNATURE; |
| 136 | break; |
| 137 | case NT35590_720P_VIDEO_PANEL: |
| 138 | panelstruct->paneldata = &nt35590_720p_video_panel_data; |
| 139 | panelstruct->panelres = &nt35590_720p_video_panel_res; |
| 140 | panelstruct->color = &nt35590_720p_video_color; |
| 141 | panelstruct->videopanel = &nt35590_720p_video_video_panel; |
| 142 | panelstruct->commandpanel = &nt35590_720p_video_command_panel; |
| 143 | panelstruct->state = &nt35590_720p_video_state; |
| 144 | panelstruct->laneconfig = &nt35590_720p_video_lane_config; |
| 145 | panelstruct->paneltiminginfo |
| 146 | = &nt35590_720p_video_timing_info; |
| 147 | panelstruct->panelresetseq |
| 148 | = &nt35590_720p_video_panel_reset_seq; |
| 149 | panelstruct->backlightinfo = &nt35590_720p_video_backlight; |
| 150 | pinfo->mipi.panel_cmds |
| 151 | = nt35590_720p_video_on_command; |
| 152 | pinfo->mipi.num_of_panel_cmds |
| 153 | = NT35590_720P_VIDEO_ON_COMMAND; |
| 154 | memcpy(phy_db->timing, |
| 155 | nt35590_720p_video_timings, TIMING_SIZE); |
| 156 | pinfo->mipi.signature = NT35590_720P_VIDEO_SIGNATURE; |
| 157 | break; |
| 158 | case NT35590_720P_CMD_PANEL: |
| 159 | panelstruct->paneldata = &nt35590_720p_cmd_panel_data; |
| 160 | panelstruct->panelres = &nt35590_720p_cmd_panel_res; |
| 161 | panelstruct->color = &nt35590_720p_cmd_color; |
| 162 | panelstruct->videopanel = &nt35590_720p_cmd_video_panel; |
| 163 | panelstruct->commandpanel = &nt35590_720p_cmd_command_panel; |
| 164 | panelstruct->state = &nt35590_720p_cmd_state; |
| 165 | panelstruct->laneconfig = &nt35590_720p_cmd_lane_config; |
| 166 | panelstruct->paneltiminginfo = &nt35590_720p_cmd_timing_info; |
| 167 | panelstruct->panelresetseq |
| 168 | = &nt35590_720p_cmd_panel_reset_seq; |
| 169 | panelstruct->backlightinfo = &nt35590_720p_cmd_backlight; |
| 170 | pinfo->mipi.panel_cmds |
| 171 | = nt35590_720p_cmd_on_command; |
| 172 | pinfo->mipi.num_of_panel_cmds |
| 173 | = NT35590_720P_CMD_ON_COMMAND; |
| 174 | memcpy(phy_db->timing, |
| 175 | nt35590_720p_cmd_timings, TIMING_SIZE); |
| 176 | pinfo->mipi.signature = NT35590_720P_CMD_SIGNATURE; |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 177 | break; |
Mao Flynn | 8140947 | 2014-04-10 15:01:30 +0800 | [diff] [blame] | 178 | case INNOLUX_720P_VIDEO_PANEL: |
| 179 | panelstruct->paneldata = &innolux_720p_video_panel_data; |
| 180 | panelstruct->panelres = &innolux_720p_video_panel_res; |
| 181 | panelstruct->color = &innolux_720p_video_color; |
| 182 | panelstruct->videopanel = &innolux_720p_video_video_panel; |
| 183 | panelstruct->commandpanel = &innolux_720p_video_command_panel; |
| 184 | panelstruct->state = &innolux_720p_video_state; |
| 185 | panelstruct->laneconfig = &innolux_720p_video_lane_config; |
| 186 | panelstruct->paneltiminginfo |
| 187 | = &innolux_720p_video_timing_info; |
| 188 | panelstruct->panelresetseq |
| 189 | = &innolux_720p_video_reset_seq; |
| 190 | panelstruct->backlightinfo = &innolux_720p_video_backlight; |
| 191 | pinfo->mipi.panel_cmds |
| 192 | = innolux_720p_video_on_command; |
| 193 | pinfo->mipi.num_of_panel_cmds |
| 194 | = INNOLUX_720P_VIDEO_ON_COMMAND; |
| 195 | memcpy(phy_db->timing, |
| 196 | innolux_720p_video_timings, TIMING_SIZE); |
| 197 | break; |
Shuo Yan | 40c660c | 2014-04-24 15:58:43 +0800 | [diff] [blame] | 198 | case OTM8019A_FWVGA_VIDEO_PANEL: |
| 199 | panelstruct->paneldata = &otm8019a_fwvga_video_panel_data; |
| 200 | panelstruct->panelres = &otm8019a_fwvga_video_panel_res; |
| 201 | panelstruct->color = &otm8019a_fwvga_video_color; |
| 202 | panelstruct->videopanel = &otm8019a_fwvga_video_video_panel; |
| 203 | panelstruct->commandpanel = &otm8019a_fwvga_video_command_panel; |
| 204 | panelstruct->state = &otm8019a_fwvga_video_state; |
| 205 | panelstruct->laneconfig = &otm8019a_fwvga_video_lane_config; |
| 206 | panelstruct->paneltiminginfo |
| 207 | = &otm8019a_fwvga_video_timing_info; |
| 208 | panelstruct->panelresetseq |
| 209 | = &otm8019a_fwvga_video_reset_seq; |
| 210 | panelstruct->backlightinfo = &otm8019a_fwvga_video_backlight; |
| 211 | pinfo->mipi.panel_cmds |
| 212 | = otm8019a_fwvga_video_on_command; |
| 213 | pinfo->mipi.num_of_panel_cmds |
| 214 | = OTM8019A_FWVGA_VIDEO_ON_COMMAND; |
| 215 | memcpy(phy_db->timing, |
| 216 | otm8019a_fwvga_video_timings, TIMING_SIZE); |
| 217 | break; |
| 218 | |
Mao Flynn | 8140947 | 2014-04-10 15:01:30 +0800 | [diff] [blame] | 219 | case UNKNOWN_PANEL: |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 220 | default: |
Mao Flynn | 8140947 | 2014-04-10 15:01:30 +0800 | [diff] [blame] | 221 | memset(panelstruct, 0, sizeof(struct panel_struct)); |
| 222 | memset(pinfo->mipi.panel_cmds, 0, sizeof(struct mipi_dsi_cmd)); |
| 223 | pinfo->mipi.num_of_panel_cmds = 0; |
| 224 | memset(phy_db->timing, 0, TIMING_SIZE); |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 225 | ret = false; |
Mao Flynn | 8140947 | 2014-04-10 15:01:30 +0800 | [diff] [blame] | 226 | break; |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 227 | } |
| 228 | return ret; |
| 229 | } |
| 230 | |
Padmanabhan Komanduru | 1869a76 | 2014-04-01 20:12:05 +0530 | [diff] [blame] | 231 | uint32_t oem_panel_max_auto_detect_panels() |
| 232 | { |
| 233 | return target_panel_auto_detect_enabled() ? |
| 234 | DISPLAY_MAX_PANEL_DETECTION : 0; |
| 235 | } |
| 236 | |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 237 | bool oem_panel_select(const char *panel_name, struct panel_struct *panelstruct, |
| 238 | struct msm_panel_info *pinfo, |
| 239 | struct mdss_dsi_phy_ctrl *phy_db) |
| 240 | { |
| 241 | uint32_t hw_id = board_hardware_id(); |
Mao Flynn | 8140947 | 2014-04-10 15:01:30 +0800 | [diff] [blame] | 242 | uint32_t hw_subtype = board_hardware_subtype(); |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 243 | int32_t panel_override_id; |
Padmanabhan Komanduru | 1869a76 | 2014-04-01 20:12:05 +0530 | [diff] [blame] | 244 | bool ret = true; |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 245 | |
| 246 | if (panel_name) { |
| 247 | panel_override_id = panel_name_to_id(supp_panels, |
| 248 | ARRAY_SIZE(supp_panels), panel_name); |
| 249 | |
| 250 | if (panel_override_id < 0) { |
| 251 | dprintf(CRITICAL, "Not able to search the panel:%s\n", |
| 252 | panel_name + strspn(panel_name, " ")); |
| 253 | } else if (panel_override_id < UNKNOWN_PANEL) { |
| 254 | /* panel override using fastboot oem command */ |
| 255 | panel_id = panel_override_id; |
| 256 | |
| 257 | dprintf(INFO, "OEM panel override:%s\n", |
| 258 | panel_name + strspn(panel_name, " ")); |
| 259 | goto panel_init; |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | switch (hw_id) { |
| 264 | case HW_PLATFORM_MTP: |
Padmanabhan Komanduru | 1869a76 | 2014-04-01 20:12:05 +0530 | [diff] [blame] | 265 | panel_id = JDI_1080P_VIDEO_PANEL; |
| 266 | break; |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 267 | case HW_PLATFORM_SURF: |
| 268 | panel_id = JDI_1080P_VIDEO_PANEL; |
Padmanabhan Komanduru | 1869a76 | 2014-04-01 20:12:05 +0530 | [diff] [blame] | 269 | switch (auto_pan_loop) { |
| 270 | case 0: |
| 271 | panel_id = JDI_1080P_VIDEO_PANEL; |
| 272 | break; |
| 273 | case 1: |
| 274 | panel_id = NT35590_720P_VIDEO_PANEL; |
| 275 | break; |
| 276 | default: |
| 277 | panel_id = UNKNOWN_PANEL; |
| 278 | ret = false; |
| 279 | dprintf(CRITICAL, "Unknown panel\n"); |
| 280 | return ret; |
| 281 | } |
| 282 | auto_pan_loop++; |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 283 | break; |
Mao Flynn | 8140947 | 2014-04-10 15:01:30 +0800 | [diff] [blame] | 284 | case HW_PLATFORM_QRD: |
Shuo Yan | 40c660c | 2014-04-24 15:58:43 +0800 | [diff] [blame] | 285 | switch (hw_subtype) { |
| 286 | case HW_PLATFORM_SUBTYPE_SKUH: |
Mao Flynn | 8140947 | 2014-04-10 15:01:30 +0800 | [diff] [blame] | 287 | panel_id = INNOLUX_720P_VIDEO_PANEL; |
Shuo Yan | 40c660c | 2014-04-24 15:58:43 +0800 | [diff] [blame] | 288 | break; |
| 289 | case HW_PLATFORM_SUBTYPE_SKUI: |
| 290 | panel_id = OTM8019A_FWVGA_VIDEO_PANEL; |
| 291 | break; |
| 292 | default: |
Mao Flynn | 8140947 | 2014-04-10 15:01:30 +0800 | [diff] [blame] | 293 | dprintf(CRITICAL, "Invalid subtype id %d for QRD HW\n", |
| 294 | hw_subtype); |
| 295 | return false; |
| 296 | } |
| 297 | break; |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 298 | default: |
| 299 | dprintf(CRITICAL, "Display not enabled for %d HW type\n", |
| 300 | hw_id); |
| 301 | return false; |
| 302 | } |
| 303 | |
| 304 | panel_init: |
Radhika Ranjan Soni | 7ea9855 | 2014-06-11 17:01:12 +0530 | [diff] [blame^] | 305 | /* Set LDO mode */ |
| 306 | if (platform_is_msm8939() || (hw_id == HW_PLATFORM_QRD)) |
| 307 | phy_db->regulator_mode = DSI_PHY_REGULATOR_LDO_MODE; |
| 308 | |
Jayant Shekhar | b130da2 | 2014-05-29 12:47:51 +0530 | [diff] [blame] | 309 | pinfo->pipe_type = MDSS_MDP_PIPE_TYPE_RGB; |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 310 | return init_panel_data(panelstruct, pinfo, phy_db); |
| 311 | } |