Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2015, 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 <string.h> |
| 32 | #include <err.h> |
| 33 | #include <smem.h> |
| 34 | #include <msm_panel.h> |
| 35 | #include <board.h> |
feifanz | 525046b | 2015-06-01 20:31:06 +0800 | [diff] [blame] | 36 | #include <qtimer.h> |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 37 | #include <mipi_dsi.h> |
| 38 | #include <target/display.h> |
| 39 | |
| 40 | #include "include/panel.h" |
| 41 | #include "panel_display.h" |
| 42 | |
| 43 | /*---------------------------------------------------------------------------*/ |
| 44 | /* GCDB Panel Database */ |
| 45 | /*---------------------------------------------------------------------------*/ |
| 46 | #include "include/panel_truly_1080p_video.h" |
Jayant Shekhar | 9ea8dcd | 2015-04-20 15:18:37 +0530 | [diff] [blame] | 47 | #include "include/panel_truly_1080p_cmd.h" |
feifanz | 174c82c | 2015-04-15 18:57:07 +0800 | [diff] [blame] | 48 | #include "include/panel_otm1906c_1080p_cmd.h" |
Vishnuvardhan Prodduturi | 16eb20f | 2015-06-05 18:03:54 +0530 | [diff] [blame] | 49 | #include "include/panel_sharp_1080p_cmd.h" |
Padmanabhan Komanduru | 49a86cf | 2015-06-08 18:24:30 +0530 | [diff] [blame^] | 50 | #include "include/panel_nt35597_wqxga_dualdsi_video.h" |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 51 | |
| 52 | /*---------------------------------------------------------------------------*/ |
| 53 | /* static panel selection variable */ |
| 54 | /*---------------------------------------------------------------------------*/ |
| 55 | enum { |
| 56 | TRULY_1080P_VIDEO_PANEL, |
Jayant Shekhar | 9ea8dcd | 2015-04-20 15:18:37 +0530 | [diff] [blame] | 57 | TRULY_1080P_CMD_PANEL, |
feifanz | 174c82c | 2015-04-15 18:57:07 +0800 | [diff] [blame] | 58 | OTM1906C_1080P_CMD_PANEL, |
Vishnuvardhan Prodduturi | 16eb20f | 2015-06-05 18:03:54 +0530 | [diff] [blame] | 59 | SHARP_1080P_CMD_PANEL, |
Padmanabhan Komanduru | 49a86cf | 2015-06-08 18:24:30 +0530 | [diff] [blame^] | 60 | NT35597_WQXGA_DUALDSI_VIDEO_PANEL, |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 61 | UNKNOWN_PANEL |
| 62 | }; |
| 63 | |
| 64 | uint32_t panel_regulator_settings[] = { |
| 65 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 |
| 66 | }; |
| 67 | |
| 68 | /* |
| 69 | * The list of panels that are supported on this target. |
| 70 | * Any panel in this list can be selected using fastboot oem command. |
| 71 | */ |
| 72 | static struct panel_list supp_panels[] = { |
| 73 | {"truly_1080p_video", TRULY_1080P_VIDEO_PANEL}, |
Jayant Shekhar | 9ea8dcd | 2015-04-20 15:18:37 +0530 | [diff] [blame] | 74 | {"truly_1080p_cmd", TRULY_1080P_CMD_PANEL}, |
Vishnuvardhan Prodduturi | 16eb20f | 2015-06-05 18:03:54 +0530 | [diff] [blame] | 75 | {"sharp_1080p_cmd", SHARP_1080P_CMD_PANEL}, |
Padmanabhan Komanduru | 49a86cf | 2015-06-08 18:24:30 +0530 | [diff] [blame^] | 76 | {"nt35597_wqxga_dualdsi_video", NT35597_WQXGA_DUALDSI_VIDEO_PANEL}, |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [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 | { |
| 88 | /* |
| 89 | *OEM can keep their panel specific on instructions in this |
| 90 | *function |
feifanz | 525046b | 2015-06-01 20:31:06 +0800 | [diff] [blame] | 91 | */ |
| 92 | if (panel_id == OTM1906C_1080P_CMD_PANEL) { |
| 93 | /* needs extra delay to avoid unexpected artifacts */ |
| 94 | mdelay(OTM1906C_1080P_CMD_PANEL_ON_DELAY); |
| 95 | } |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 96 | return NO_ERROR; |
| 97 | } |
| 98 | |
| 99 | int oem_panel_off() |
| 100 | { |
| 101 | /* OEM can keep their panel specific off instructions |
| 102 | * in this function |
| 103 | */ |
| 104 | return NO_ERROR; |
| 105 | } |
| 106 | |
| 107 | static int init_panel_data(struct panel_struct *panelstruct, |
| 108 | struct msm_panel_info *pinfo, |
| 109 | struct mdss_dsi_phy_ctrl *phy_db) |
| 110 | { |
| 111 | int pan_type = PANEL_TYPE_DSI; |
| 112 | |
| 113 | switch (panel_id) { |
| 114 | case TRULY_1080P_VIDEO_PANEL: |
| 115 | panelstruct->paneldata = &truly_1080p_video_panel_data; |
| 116 | panelstruct->paneldata->panel_with_enable_gpio = 1; |
| 117 | panelstruct->panelres = &truly_1080p_video_panel_res; |
| 118 | panelstruct->color = &truly_1080p_video_color; |
| 119 | panelstruct->videopanel = &truly_1080p_video_video_panel; |
| 120 | panelstruct->commandpanel = &truly_1080p_video_command_panel; |
| 121 | panelstruct->state = &truly_1080p_video_state; |
| 122 | panelstruct->laneconfig = &truly_1080p_video_lane_config; |
| 123 | panelstruct->paneltiminginfo |
| 124 | = &truly_1080p_video_timing_info; |
| 125 | panelstruct->panelresetseq |
| 126 | = &truly_1080p_video_panel_reset_seq; |
| 127 | panelstruct->backlightinfo = &truly_1080p_video_backlight; |
| 128 | pinfo->mipi.panel_on_cmds |
| 129 | = truly_1080p_video_on_command; |
| 130 | pinfo->mipi.num_of_panel_on_cmds |
| 131 | = TRULY_1080P_VIDEO_ON_COMMAND; |
| 132 | pinfo->mipi.panel_off_cmds |
| 133 | = truly_1080p_video_off_command; |
| 134 | pinfo->mipi.num_of_panel_off_cmds |
| 135 | = TRULY_1080P_VIDEO_OFF_COMMAND; |
| 136 | memcpy(phy_db->timing, |
| 137 | truly_1080p_video_timings, TIMING_SIZE); |
| 138 | pinfo->mipi.signature = TRULY_1080P_VIDEO_SIGNATURE; |
| 139 | break; |
Jayant Shekhar | 9ea8dcd | 2015-04-20 15:18:37 +0530 | [diff] [blame] | 140 | case TRULY_1080P_CMD_PANEL: |
| 141 | panelstruct->paneldata = &truly_1080p_cmd_panel_data; |
| 142 | panelstruct->paneldata->panel_with_enable_gpio = 1; |
| 143 | panelstruct->panelres = &truly_1080p_cmd_panel_res; |
| 144 | panelstruct->color = &truly_1080p_cmd_color; |
| 145 | panelstruct->videopanel = &truly_1080p_cmd_video_panel; |
| 146 | panelstruct->commandpanel = &truly_1080p_cmd_command_panel; |
| 147 | panelstruct->state = &truly_1080p_cmd_state; |
| 148 | panelstruct->laneconfig = &truly_1080p_cmd_lane_config; |
| 149 | panelstruct->paneltiminginfo |
| 150 | = &truly_1080p_cmd_timing_info; |
| 151 | panelstruct->panelresetseq |
| 152 | = &truly_1080p_cmd_panel_reset_seq; |
| 153 | panelstruct->backlightinfo = &truly_1080p_cmd_backlight; |
| 154 | pinfo->mipi.panel_on_cmds |
| 155 | = truly_1080p_cmd_on_command; |
| 156 | pinfo->mipi.num_of_panel_on_cmds |
| 157 | = TRULY_1080P_CMD_ON_COMMAND; |
| 158 | pinfo->mipi.panel_off_cmds |
| 159 | = truly_1080p_cmd_off_command; |
| 160 | pinfo->mipi.num_of_panel_off_cmds |
| 161 | = TRULY_1080P_CMD_OFF_COMMAND; |
| 162 | memcpy(phy_db->timing, |
| 163 | truly_1080p_cmd_timings, TIMING_SIZE); |
| 164 | pinfo->mipi.signature = TRULY_1080P_CMD_SIGNATURE; |
| 165 | break; |
feifanz | 174c82c | 2015-04-15 18:57:07 +0800 | [diff] [blame] | 166 | case OTM1906C_1080P_CMD_PANEL: |
| 167 | panelstruct->paneldata = &otm1906c_1080p_cmd_panel_data; |
| 168 | panelstruct->paneldata->panel_with_enable_gpio = 1; |
| 169 | panelstruct->panelres = &otm1906c_1080p_cmd_panel_res; |
| 170 | panelstruct->color = &otm1906c_1080p_cmd_color; |
| 171 | panelstruct->videopanel = &otm1906c_1080p_cmd_video_panel; |
| 172 | panelstruct->commandpanel = &otm1906c_1080p_cmd_command_panel; |
| 173 | panelstruct->state = &otm1906c_1080p_cmd_state; |
| 174 | panelstruct->laneconfig = &otm1906c_1080p_cmd_lane_config; |
| 175 | panelstruct->paneltiminginfo |
| 176 | = &otm1906c_1080p_cmd_timing_info; |
| 177 | panelstruct->panelresetseq |
| 178 | = &otm1906c_1080p_cmd_panel_reset_seq; |
| 179 | panelstruct->backlightinfo = &otm1906c_1080p_cmd_backlight; |
| 180 | pinfo->mipi.panel_on_cmds |
| 181 | = otm1906c_1080p_cmd_on_command; |
| 182 | pinfo->mipi.num_of_panel_on_cmds |
| 183 | = OTM1906C_1080P_CMD_ON_COMMAND; |
| 184 | pinfo->mipi.panel_off_cmds |
| 185 | = otm1906c_1080p_cmd_off_command; |
| 186 | pinfo->mipi.num_of_panel_off_cmds |
| 187 | = OTM1906C_1080P_CMD_OFF_COMMAND; |
| 188 | memcpy(phy_db->timing, |
| 189 | otm1906c_1080p_cmd_timings, TIMING_SIZE); |
| 190 | pinfo->mipi.signature = OTM1906C_1080P_CMD_SIGNATURE; |
| 191 | break; |
Vishnuvardhan Prodduturi | 16eb20f | 2015-06-05 18:03:54 +0530 | [diff] [blame] | 192 | case SHARP_1080P_CMD_PANEL: |
| 193 | panelstruct->paneldata = &sharp_1080p_cmd_panel_data; |
| 194 | panelstruct->panelres = &sharp_1080p_cmd_panel_res; |
| 195 | panelstruct->paneldata->panel_with_enable_gpio = 1; |
| 196 | panelstruct->color = &sharp_1080p_cmd_color; |
| 197 | panelstruct->videopanel = &sharp_1080p_cmd_video_panel; |
| 198 | panelstruct->commandpanel = &sharp_1080p_cmd_command_panel; |
| 199 | panelstruct->state = &sharp_1080p_cmd_state; |
| 200 | panelstruct->laneconfig = &sharp_1080p_cmd_lane_config; |
| 201 | panelstruct->paneltiminginfo |
| 202 | = &sharp_1080p_cmd_timing_info; |
| 203 | panelstruct->panelresetseq |
| 204 | = &sharp_1080p_cmd_panel_reset_seq; |
| 205 | panelstruct->backlightinfo = &sharp_1080p_cmd_backlight; |
| 206 | pinfo->mipi.panel_on_cmds |
| 207 | = sharp_1080p_cmd_on_command; |
| 208 | pinfo->mipi.num_of_panel_on_cmds |
| 209 | = SHARP_1080P_CMD_ON_COMMAND; |
| 210 | pinfo->mipi.panel_off_cmds |
| 211 | = sharp_1080p_cmd_off_command; |
| 212 | pinfo->mipi.num_of_panel_off_cmds |
| 213 | = SHARP_1080P_CMD_OFF_COMMAND; |
| 214 | memcpy(phy_db->timing, |
| 215 | sharp_1080p_cmd_timings, TIMING_SIZE); |
| 216 | break; |
Padmanabhan Komanduru | 49a86cf | 2015-06-08 18:24:30 +0530 | [diff] [blame^] | 217 | case NT35597_WQXGA_DUALDSI_VIDEO_PANEL: |
| 218 | panelstruct->paneldata = &nt35597_wqxga_dualdsi_video_panel_data; |
| 219 | panelstruct->paneldata->panel_operating_mode = DST_SPLIT_FLAG | |
| 220 | SPLIT_DISPLAY_FLAG | DUAL_DSI_FLAG; |
| 221 | panelstruct->paneldata->panel_with_enable_gpio = 0; |
| 222 | |
| 223 | panelstruct->panelres = &nt35597_wqxga_dualdsi_video_panel_res; |
| 224 | panelstruct->color = &nt35597_wqxga_dualdsi_video_color; |
| 225 | panelstruct->videopanel = &nt35597_wqxga_dualdsi_video_video_panel; |
| 226 | panelstruct->commandpanel = &nt35597_wqxga_dualdsi_video_command_panel; |
| 227 | panelstruct->state = &nt35597_wqxga_dualdsi_video_state; |
| 228 | panelstruct->laneconfig = &nt35597_wqxga_dualdsi_video_lane_config; |
| 229 | panelstruct->paneltiminginfo |
| 230 | = &nt35597_wqxga_dualdsi_video_timing_info; |
| 231 | panelstruct->panelresetseq |
| 232 | = &nt35597_wqxga_dualdsi_video_reset_seq; |
| 233 | panelstruct->backlightinfo = &nt35597_wqxga_dualdsi_video_backlight; |
| 234 | pinfo->labibb = &nt35597_wqxga_dualdsi_video_labibb; |
| 235 | |
| 236 | pinfo->mipi.panel_on_cmds |
| 237 | = nt35597_wqxga_dualdsi_video_on_command; |
| 238 | pinfo->mipi.num_of_panel_on_cmds |
| 239 | = NT35597_WQXGA_DUALDSI_VIDEO_ON_COMMAND; |
| 240 | pinfo->mipi.panel_off_cmds |
| 241 | = nt35597_wqxga_dualdsi_video_off_command; |
| 242 | pinfo->mipi.num_of_panel_off_cmds |
| 243 | = NT35597_WQXGA_DUALDSI_VIDEO_OFF_COMMAND; |
| 244 | memcpy(phy_db->timing, nt35597_wqxga_dualdsi_video_timings, |
| 245 | TIMING_SIZE); |
| 246 | pinfo->mipi.tx_eot_append = true; |
| 247 | break; |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 248 | case UNKNOWN_PANEL: |
| 249 | default: |
| 250 | memset(panelstruct, 0, sizeof(struct panel_struct)); |
| 251 | memset(pinfo->mipi.panel_on_cmds, 0, |
| 252 | sizeof(struct mipi_dsi_cmd)); |
| 253 | pinfo->mipi.num_of_panel_on_cmds = 0; |
| 254 | memset(pinfo->mipi.panel_off_cmds, 0, |
| 255 | sizeof(struct mipi_dsi_cmd)); |
| 256 | pinfo->mipi.num_of_panel_off_cmds = 0; |
| 257 | memset(phy_db->timing, 0, TIMING_SIZE); |
| 258 | pan_type = PANEL_TYPE_UNKNOWN; |
| 259 | break; |
| 260 | } |
| 261 | return pan_type; |
| 262 | } |
| 263 | |
| 264 | int oem_panel_select(const char *panel_name, struct panel_struct *panelstruct, |
| 265 | struct msm_panel_info *pinfo, |
| 266 | struct mdss_dsi_phy_ctrl *phy_db) |
| 267 | { |
| 268 | uint32_t hw_id = board_hardware_id(); |
| 269 | int32_t panel_override_id; |
| 270 | |
| 271 | if (panel_name) { |
| 272 | panel_override_id = panel_name_to_id(supp_panels, |
| 273 | ARRAY_SIZE(supp_panels), panel_name); |
| 274 | |
| 275 | if (panel_override_id < 0) { |
| 276 | dprintf(CRITICAL, "Not able to search the panel:%s\n", |
| 277 | panel_name + strspn(panel_name, " ")); |
| 278 | } else if (panel_override_id < UNKNOWN_PANEL) { |
| 279 | /* panel override using fastboot oem command */ |
| 280 | panel_id = panel_override_id; |
| 281 | |
| 282 | dprintf(INFO, "OEM panel override:%s\n", |
| 283 | panel_name + strspn(panel_name, " ")); |
| 284 | goto panel_init; |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | switch (hw_id) { |
| 289 | case HW_PLATFORM_MTP: |
Padmanabhan Komanduru | 49a86cf | 2015-06-08 18:24:30 +0530 | [diff] [blame^] | 290 | if (platform_is_msm8956()) |
| 291 | panel_id = NT35597_WQXGA_DUALDSI_VIDEO_PANEL; |
| 292 | else |
| 293 | panel_id = TRULY_1080P_VIDEO_PANEL; |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 294 | break; |
| 295 | case HW_PLATFORM_SURF: |
Padmanabhan Komanduru | 49a86cf | 2015-06-08 18:24:30 +0530 | [diff] [blame^] | 296 | if (platform_is_msm8956()) |
| 297 | panel_id = NT35597_WQXGA_DUALDSI_VIDEO_PANEL; |
| 298 | else |
| 299 | panel_id = TRULY_1080P_VIDEO_PANEL; |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 300 | break; |
feifanz | 174c82c | 2015-04-15 18:57:07 +0800 | [diff] [blame] | 301 | case HW_PLATFORM_QRD: |
| 302 | panel_id = OTM1906C_1080P_CMD_PANEL; |
| 303 | break; |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 304 | default: |
| 305 | dprintf(CRITICAL, "Display not enabled for %d HW type\n", |
| 306 | hw_id); |
| 307 | return PANEL_TYPE_UNKNOWN; |
| 308 | } |
| 309 | |
| 310 | panel_init: |
| 311 | /* |
| 312 | * Update all data structures after 'panel_init' label. Only panel |
| 313 | * selection is supposed to happen before that. |
| 314 | */ |
| 315 | memcpy(panel_regulator_settings, |
| 316 | dcdc_regulator_settings, REGULATOR_SIZE); |
| 317 | pinfo->pipe_type = MDSS_MDP_PIPE_TYPE_RGB; |
| 318 | return init_panel_data(panelstruct, pinfo, phy_db); |
| 319 | } |