Dhaval Patel | b95039c | 2015-03-16 11:14:06 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2013-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> |
| 36 | #include <mipi_dsi.h> |
| 37 | #include <qtimer.h> |
| 38 | #include <platform.h> |
| 39 | |
| 40 | #include "include/panel.h" |
| 41 | #include "target/display.h" |
| 42 | #include "panel_display.h" |
| 43 | #include <mipi_dsi.h> |
| 44 | |
| 45 | /*---------------------------------------------------------------------------*/ |
| 46 | /* GCDB Panel Database */ |
| 47 | /*---------------------------------------------------------------------------*/ |
Dhaval Patel | 989d4fc | 2015-04-01 19:04:46 -0700 | [diff] [blame] | 48 | #include "include/panel_nt35597_wqxga_dualdsi_video.h" |
Kuogee Hsieh | 9d7e714 | 2015-06-16 10:36:19 -0700 | [diff] [blame] | 49 | #include "include/panel_nt35597_wqxga_dualdsi_cmd.h" |
Dhaval Patel | b95039c | 2015-03-16 11:14:06 -0700 | [diff] [blame] | 50 | #include "include/panel_sharp_wqxga_dualdsi_video.h" |
| 51 | #include "include/panel_jdi_qhd_dualdsi_video.h" |
| 52 | #include "include/panel_jdi_qhd_dualdsi_cmd.h" |
| 53 | |
| 54 | /*---------------------------------------------------------------------------*/ |
| 55 | /* static panel selection variable */ |
| 56 | /*---------------------------------------------------------------------------*/ |
| 57 | enum { |
Dhaval Patel | 989d4fc | 2015-04-01 19:04:46 -0700 | [diff] [blame] | 58 | NT35597_WQXGA_DUALDSI_VIDEO_PANEL, |
Kuogee Hsieh | 9d7e714 | 2015-06-16 10:36:19 -0700 | [diff] [blame] | 59 | NT35597_WQXGA_DUALDSI_CMD_PANEL, |
Dhaval Patel | b95039c | 2015-03-16 11:14:06 -0700 | [diff] [blame] | 60 | SHARP_WQXGA_DUALDSI_VIDEO_PANEL, |
| 61 | JDI_QHD_DUALDSI_VIDEO_PANEL, |
| 62 | JDI_QHD_DUALDSI_CMD_PANEL, |
| 63 | UNKNOWN_PANEL |
| 64 | }; |
| 65 | |
| 66 | /* |
| 67 | * The list of panels that are supported on this target. |
| 68 | * Any panel in this list can be selected using fastboot oem command. |
| 69 | */ |
| 70 | static struct panel_list supp_panels[] = { |
Dhaval Patel | 989d4fc | 2015-04-01 19:04:46 -0700 | [diff] [blame] | 71 | {"nt35597_wqxga_dualdsi_video", NT35597_WQXGA_DUALDSI_VIDEO_PANEL}, |
Kuogee Hsieh | 9d7e714 | 2015-06-16 10:36:19 -0700 | [diff] [blame] | 72 | {"nt35597_wqxga_dualdsi_cmd", NT35597_WQXGA_DUALDSI_CMD_PANEL}, |
Dhaval Patel | b95039c | 2015-03-16 11:14:06 -0700 | [diff] [blame] | 73 | {"sharp_wqxga_dualdsi_video", SHARP_WQXGA_DUALDSI_VIDEO_PANEL}, |
| 74 | {"jdi_qhd_dualdsi_video", JDI_QHD_DUALDSI_VIDEO_PANEL}, |
| 75 | {"jdi_qhd_dualdsi_cmd", JDI_QHD_DUALDSI_CMD_PANEL}, |
| 76 | }; |
| 77 | |
| 78 | static uint32_t panel_id; |
| 79 | |
| 80 | int oem_panel_rotation() |
| 81 | { |
| 82 | return NO_ERROR; |
| 83 | } |
| 84 | |
| 85 | int oem_panel_on() |
| 86 | { |
| 87 | if (panel_id == JDI_QHD_DUALDSI_CMD_PANEL) { |
| 88 | /* needs extra delay to avoid unexpected artifacts */ |
| 89 | mdelay(JDI_QHD_DUALDSI_CMD_PANEL_ON_DELAY); |
| 90 | |
| 91 | } |
| 92 | return NO_ERROR; |
| 93 | } |
| 94 | |
| 95 | int oem_panel_off() |
| 96 | { |
| 97 | return NO_ERROR; |
| 98 | } |
| 99 | |
| 100 | static bool init_panel_data(struct panel_struct *panelstruct, |
| 101 | struct msm_panel_info *pinfo, |
| 102 | struct mdss_dsi_phy_ctrl *phy_db) |
| 103 | { |
| 104 | int pan_type; |
| 105 | |
| 106 | switch (panel_id) { |
| 107 | case SHARP_WQXGA_DUALDSI_VIDEO_PANEL: |
| 108 | pan_type = PANEL_TYPE_DSI; |
| 109 | pinfo->lcd_reg_en = 0; |
| 110 | panelstruct->paneldata = &sharp_wqxga_dualdsi_video_panel_data; |
Dhaval Patel | b95039c | 2015-03-16 11:14:06 -0700 | [diff] [blame] | 111 | panelstruct->paneldata->panel_operating_mode = 11; |
| 112 | panelstruct->paneldata->panel_with_enable_gpio = 0; |
| 113 | |
| 114 | panelstruct->panelres = &sharp_wqxga_dualdsi_video_panel_res; |
| 115 | panelstruct->color = &sharp_wqxga_dualdsi_video_color; |
| 116 | panelstruct->videopanel = &sharp_wqxga_dualdsi_video_video_panel; |
| 117 | panelstruct->commandpanel = &sharp_wqxga_dualdsi_video_command_panel; |
| 118 | panelstruct->state = &sharp_wqxga_dualdsi_video_state; |
| 119 | panelstruct->laneconfig = &sharp_wqxga_dualdsi_video_lane_config; |
| 120 | panelstruct->paneltiminginfo |
| 121 | = &sharp_wqxga_dualdsi_video_timing_info; |
| 122 | panelstruct->panelresetseq |
| 123 | = &sharp_wqxga_dualdsi_video_reset_seq; |
| 124 | panelstruct->backlightinfo = &sharp_wqxga_dualdsi_video_backlight; |
| 125 | |
| 126 | pinfo->labibb = &sharp_wqxga_dualdsi_video_labibb; |
| 127 | |
| 128 | pinfo->mipi.panel_on_cmds |
| 129 | = sharp_wqxga_dualdsi_video_on_command; |
| 130 | pinfo->mipi.num_of_panel_on_cmds |
| 131 | = SHARP_WQXGA_DUALDSI_VIDEO_ON_COMMAND; |
| 132 | pinfo->mipi.panel_off_cmds |
| 133 | = sharp_wqxga_dualdsi_video_off_command; |
| 134 | pinfo->mipi.num_of_panel_off_cmds |
| 135 | = SHARP_WQXGA_DUALDSI_VIDEO_OFF_COMMAND; |
| 136 | memcpy(phy_db->timing, |
| 137 | sharp_wqxga_dualdsi_thulium_video_timings, |
| 138 | MAX_TIMING_CONFIG * sizeof(uint32_t)); |
| 139 | pinfo->mipi.tx_eot_append = true; |
| 140 | break; |
Dhaval Patel | 989d4fc | 2015-04-01 19:04:46 -0700 | [diff] [blame] | 141 | case NT35597_WQXGA_DUALDSI_VIDEO_PANEL: |
| 142 | pan_type = PANEL_TYPE_DSI; |
| 143 | pinfo->lcd_reg_en = 0; |
| 144 | panelstruct->paneldata = &nt35597_wqxga_dualdsi_video_panel_data; |
Dhaval Patel | 989d4fc | 2015-04-01 19:04:46 -0700 | [diff] [blame] | 145 | panelstruct->panelres = &nt35597_wqxga_dualdsi_video_panel_res; |
| 146 | panelstruct->color = &nt35597_wqxga_dualdsi_video_color; |
| 147 | panelstruct->videopanel = &nt35597_wqxga_dualdsi_video_video_panel; |
| 148 | panelstruct->commandpanel = &nt35597_wqxga_dualdsi_video_command_panel; |
| 149 | panelstruct->state = &nt35597_wqxga_dualdsi_video_state; |
| 150 | panelstruct->laneconfig = &nt35597_wqxga_dualdsi_video_lane_config; |
| 151 | panelstruct->paneltiminginfo |
| 152 | = &nt35597_wqxga_dualdsi_video_timing_info; |
| 153 | panelstruct->panelresetseq |
| 154 | = &nt35597_wqxga_dualdsi_video_reset_seq; |
| 155 | panelstruct->backlightinfo = &nt35597_wqxga_dualdsi_video_backlight; |
| 156 | |
| 157 | pinfo->labibb = &nt35597_wqxga_dualdsi_video_labibb; |
| 158 | |
| 159 | pinfo->mipi.panel_on_cmds |
| 160 | = nt35597_wqxga_dualdsi_video_on_command; |
| 161 | pinfo->mipi.num_of_panel_on_cmds |
| 162 | = NT35597_WQXGA_DUALDSI_VIDEO_ON_COMMAND; |
| 163 | pinfo->mipi.panel_off_cmds |
| 164 | = nt35597_wqxga_dualdsi_video_off_command; |
| 165 | pinfo->mipi.num_of_panel_off_cmds |
| 166 | = NT35597_WQXGA_DUALDSI_VIDEO_OFF_COMMAND; |
| 167 | memcpy(phy_db->timing, |
| 168 | nt35597_wqxga_dualdsi_thulium_video_timings, |
| 169 | MAX_TIMING_CONFIG * sizeof(uint32_t)); |
| 170 | pinfo->mipi.tx_eot_append = true; |
| 171 | break; |
Kuogee Hsieh | 9d7e714 | 2015-06-16 10:36:19 -0700 | [diff] [blame] | 172 | case NT35597_WQXGA_DUALDSI_CMD_PANEL: |
| 173 | pan_type = PANEL_TYPE_DSI; |
| 174 | pinfo->lcd_reg_en = 0; |
| 175 | panelstruct->paneldata = &nt35597_wqxga_dualdsi_cmd_panel_data; |
| 176 | panelstruct->panelres = &nt35597_wqxga_dualdsi_cmd_panel_res; |
| 177 | panelstruct->color = &nt35597_wqxga_dualdsi_cmd_color; |
| 178 | panelstruct->videopanel = &nt35597_wqxga_dualdsi_cmd_video_panel; |
| 179 | panelstruct->commandpanel = &nt35597_wqxga_dualdsi_cmd_command_panel; |
| 180 | panelstruct->state = &nt35597_wqxga_dualdsi_cmd_state; |
| 181 | panelstruct->laneconfig = &nt35597_wqxga_dualdsi_cmd_lane_config; |
| 182 | panelstruct->paneltiminginfo |
| 183 | = &nt35597_wqxga_dualdsi_cmd_timing_info; |
| 184 | panelstruct->panelresetseq |
| 185 | = &nt35597_wqxga_dualdsi_cmd_reset_seq; |
| 186 | panelstruct->backlightinfo = &nt35597_wqxga_dualdsi_cmd_backlight; |
| 187 | |
| 188 | pinfo->labibb = &nt35597_wqxga_dualdsi_cmd_labibb; |
| 189 | |
| 190 | pinfo->mipi.panel_on_cmds |
| 191 | = nt35597_wqxga_dualdsi_cmd_on_command; |
| 192 | pinfo->mipi.num_of_panel_on_cmds |
| 193 | = NT35597_WQXGA_DUALDSI_CMD_ON_COMMAND; |
| 194 | pinfo->mipi.panel_off_cmds |
| 195 | = nt35597_wqxga_dualdsi_cmd_off_command; |
| 196 | pinfo->mipi.num_of_panel_off_cmds |
| 197 | = NT35597_WQXGA_DUALDSI_CMD_OFF_COMMAND; |
| 198 | memcpy(phy_db->timing, |
| 199 | nt35597_wqxga_dualdsi_thulium_cmd_timings, |
| 200 | MAX_TIMING_CONFIG * sizeof(uint32_t)); |
| 201 | pinfo->mipi.tx_eot_append = true; |
| 202 | break; |
Dhaval Patel | b95039c | 2015-03-16 11:14:06 -0700 | [diff] [blame] | 203 | case JDI_QHD_DUALDSI_VIDEO_PANEL: |
| 204 | pan_type = PANEL_TYPE_DSI; |
| 205 | pinfo->lcd_reg_en = 1; |
Dhaval Patel | b95039c | 2015-03-16 11:14:06 -0700 | [diff] [blame] | 206 | panelstruct->paneldata = &jdi_qhd_dualdsi_video_panel_data; |
| 207 | |
| 208 | panelstruct->panelres = &jdi_qhd_dualdsi_video_panel_res; |
| 209 | panelstruct->color = &jdi_qhd_dualdsi_video_color; |
| 210 | panelstruct->videopanel = &jdi_qhd_dualdsi_video_video_panel; |
| 211 | panelstruct->commandpanel = &jdi_qhd_dualdsi_video_command_panel; |
| 212 | panelstruct->state = &jdi_qhd_dualdsi_video_state; |
| 213 | panelstruct->laneconfig = &jdi_qhd_dualdsi_video_lane_config; |
| 214 | panelstruct->paneltiminginfo |
| 215 | = &jdi_qhd_dualdsi_video_timing_info; |
| 216 | panelstruct->panelresetseq |
| 217 | = &jdi_qhd_dualdsi_video_reset_seq; |
| 218 | panelstruct->backlightinfo = &jdi_qhd_dualdsi_video_backlight; |
| 219 | pinfo->mipi.panel_on_cmds |
| 220 | = jdi_qhd_dualdsi_video_on_command; |
| 221 | pinfo->mipi.num_of_panel_on_cmds |
| 222 | = JDI_QHD_DUALDSI_VIDEO_ON_COMMAND; |
| 223 | pinfo->mipi.panel_off_cmds |
| 224 | = jdi_qhd_dualdsi_video_off_command; |
| 225 | pinfo->mipi.num_of_panel_off_cmds |
| 226 | = JDI_QHD_DUALDSI_VIDEO_OFF_COMMAND; |
| 227 | memcpy(phy_db->timing, |
| 228 | jdi_qhd_dualdsi_thulium_cmd_timings, |
| 229 | MAX_TIMING_CONFIG * sizeof(uint32_t)); |
| 230 | break; |
| 231 | case JDI_QHD_DUALDSI_CMD_PANEL: |
| 232 | pan_type = PANEL_TYPE_DSI; |
| 233 | pinfo->lcd_reg_en = 1; |
| 234 | panelstruct->paneldata = &jdi_qhd_dualdsi_cmd_panel_data; |
Dhaval Patel | b95039c | 2015-03-16 11:14:06 -0700 | [diff] [blame] | 235 | |
| 236 | panelstruct->panelres = &jdi_qhd_dualdsi_cmd_panel_res; |
| 237 | panelstruct->color = &jdi_qhd_dualdsi_cmd_color; |
| 238 | panelstruct->videopanel = &jdi_qhd_dualdsi_cmd_video_panel; |
| 239 | panelstruct->commandpanel = &jdi_qhd_dualdsi_cmd_command_panel; |
| 240 | panelstruct->state = &jdi_qhd_dualdsi_cmd_state; |
| 241 | panelstruct->laneconfig = &jdi_qhd_dualdsi_cmd_lane_config; |
| 242 | panelstruct->paneltiminginfo |
| 243 | = &jdi_qhd_dualdsi_cmd_timing_info; |
| 244 | panelstruct->panelresetseq |
| 245 | = &jdi_qhd_dualdsi_cmd_reset_seq; |
| 246 | panelstruct->backlightinfo = &jdi_qhd_dualdsi_cmd_backlight; |
| 247 | pinfo->mipi.panel_on_cmds |
| 248 | = jdi_qhd_dualdsi_cmd_on_command; |
| 249 | pinfo->mipi.num_of_panel_on_cmds |
| 250 | = JDI_QHD_DUALDSI_CMD_ON_COMMAND; |
| 251 | pinfo->mipi.panel_off_cmds |
| 252 | = jdi_qhd_dualdsi_cmd_off_command; |
| 253 | pinfo->mipi.num_of_panel_off_cmds |
| 254 | = JDI_QHD_DUALDSI_CMD_OFF_COMMAND; |
| 255 | memcpy(phy_db->timing, |
| 256 | jdi_qhd_dualdsi_thulium_video_timings, |
| 257 | MAX_TIMING_CONFIG * sizeof(uint32_t)); |
| 258 | break; |
| 259 | default: |
| 260 | case UNKNOWN_PANEL: |
| 261 | pan_type = PANEL_TYPE_UNKNOWN; |
| 262 | break; |
| 263 | } |
| 264 | return pan_type; |
| 265 | } |
| 266 | |
| 267 | int oem_panel_select(const char *panel_name, struct panel_struct *panelstruct, |
| 268 | struct msm_panel_info *pinfo, |
| 269 | struct mdss_dsi_phy_ctrl *phy_db) |
| 270 | { |
| 271 | uint32_t hw_id = board_hardware_id(); |
| 272 | int32_t panel_override_id; |
| 273 | |
| 274 | phy_db->pll_type = DSI_PLL_TYPE_THULIUM; |
| 275 | |
| 276 | if (panel_name) { |
| 277 | panel_override_id = panel_name_to_id(supp_panels, |
| 278 | ARRAY_SIZE(supp_panels), panel_name); |
| 279 | |
| 280 | if (panel_override_id < 0) { |
| 281 | dprintf(CRITICAL, "Not able to search the panel:%s\n", |
Padmanabhan Komanduru | bccbcdc | 2015-06-30 16:19:24 +0530 | [diff] [blame] | 282 | panel_name); |
Dhaval Patel | b95039c | 2015-03-16 11:14:06 -0700 | [diff] [blame] | 283 | } else if (panel_override_id < UNKNOWN_PANEL) { |
| 284 | /* panel override using fastboot oem command */ |
| 285 | panel_id = panel_override_id; |
| 286 | |
| 287 | dprintf(INFO, "OEM panel override:%s\n", |
Padmanabhan Komanduru | bccbcdc | 2015-06-30 16:19:24 +0530 | [diff] [blame] | 288 | panel_name); |
Dhaval Patel | b95039c | 2015-03-16 11:14:06 -0700 | [diff] [blame] | 289 | goto panel_init; |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | switch (hw_id) { |
| 294 | case HW_PLATFORM_MTP: |
| 295 | case HW_PLATFORM_FLUID: |
| 296 | case HW_PLATFORM_SURF: |
| 297 | panel_id = SHARP_WQXGA_DUALDSI_VIDEO_PANEL; |
| 298 | break; |
| 299 | default: |
| 300 | dprintf(CRITICAL, "Display not enabled for %d HW type\n" |
| 301 | , hw_id); |
| 302 | return PANEL_TYPE_UNKNOWN; |
| 303 | } |
| 304 | |
| 305 | panel_init: |
| 306 | return init_panel_data(panelstruct, pinfo, phy_db); |
| 307 | } |