Shivaraj Shetty | 25b0aa0 | 2013-10-30 20:55:49 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -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> |
| 33 | #include <msm_panel.h> |
| 34 | #include <board.h> |
| 35 | #include <mipi_dsi.h> |
| 36 | |
| 37 | #include "include/panel.h" |
| 38 | #include "panel_display.h" |
| 39 | |
| 40 | /*---------------------------------------------------------------------------*/ |
| 41 | /* GCDB Panel Database */ |
| 42 | /*---------------------------------------------------------------------------*/ |
| 43 | #include "include/panel_truly_wvga_cmd.h" |
| 44 | #include "include/panel_truly_wvga_video.h" |
shuoy | bca6675 | 2013-09-03 18:17:21 +0800 | [diff] [blame] | 45 | #include "include/panel_hx8379a_wvga_video.h" |
shuoy | ec420a7 | 2013-10-22 09:38:06 +0800 | [diff] [blame] | 46 | #include "include/panel_hx8389b_qhd_video.h" |
shuoy | bca6675 | 2013-09-03 18:17:21 +0800 | [diff] [blame] | 47 | #include "include/panel_otm8018b_fwvga_video.h" |
| 48 | #include "include/panel_nt35590_720p_video.h" |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 49 | |
Shivaraj Shetty | 25b0aa0 | 2013-10-30 20:55:49 +0530 | [diff] [blame] | 50 | /* Number of dectectable panels */ |
| 51 | #define DISPLAY_MAX_PANEL_DETECTION 2 |
| 52 | |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 53 | /*---------------------------------------------------------------------------*/ |
| 54 | /* static panel selection variable */ |
| 55 | /*---------------------------------------------------------------------------*/ |
| 56 | enum { |
| 57 | TRULY_WVGA_CMD_PANEL, |
| 58 | TRULY_WVGA_VIDEO_PANEL, |
shuoy | bca6675 | 2013-09-03 18:17:21 +0800 | [diff] [blame] | 59 | HX8379A_WVGA_VIDEO_PANEL, |
shuoy | bca6675 | 2013-09-03 18:17:21 +0800 | [diff] [blame] | 60 | NT35590_720P_VIDEO_PANEL, |
shuoy | ec420a7 | 2013-10-22 09:38:06 +0800 | [diff] [blame] | 61 | HX8389B_QHD_VIDEO_PANEL, |
Shivaraj Shetty | 25b0aa0 | 2013-10-30 20:55:49 +0530 | [diff] [blame] | 62 | OTM8018B_FWVGA_VIDEO_PANEL, |
| 63 | UNKNOWN_PANEL |
shuoy | ec420a7 | 2013-10-22 09:38:06 +0800 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | enum { |
| 67 | QRD_DEF, |
| 68 | QRD_SKUAA, |
| 69 | QRD_SKUAB = 3, |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | static uint32_t panel_id; |
| 73 | |
| 74 | int oem_panel_rotation() |
| 75 | { |
| 76 | /* OEM can keep there panel spefic on instructions in this |
| 77 | function */ |
| 78 | return NO_ERROR; |
| 79 | } |
| 80 | |
| 81 | |
| 82 | int oem_panel_on() |
| 83 | { |
| 84 | /* OEM can keep there panel spefic on instructions in this |
| 85 | function */ |
| 86 | return NO_ERROR; |
| 87 | } |
| 88 | |
| 89 | int oem_panel_off() |
| 90 | { |
| 91 | /* OEM can keep there panel spefic off instructions in this |
| 92 | function */ |
| 93 | return NO_ERROR; |
| 94 | } |
| 95 | |
| 96 | static bool init_panel_data(struct panel_struct *panelstruct, |
| 97 | struct msm_panel_info *pinfo, |
| 98 | struct mdss_dsi_phy_ctrl *phy_db) |
| 99 | { |
| 100 | switch (panel_id) { |
| 101 | case TRULY_WVGA_CMD_PANEL: |
| 102 | panelstruct->paneldata = &truly_wvga_cmd_panel_data; |
| 103 | panelstruct->panelres = &truly_wvga_cmd_panel_res; |
| 104 | panelstruct->color = &truly_wvga_cmd_color; |
| 105 | panelstruct->videopanel = &truly_wvga_cmd_video_panel; |
| 106 | panelstruct->commandpanel = &truly_wvga_cmd_command_panel; |
| 107 | panelstruct->state = &truly_wvga_cmd_state; |
| 108 | panelstruct->laneconfig = &truly_wvga_cmd_lane_config; |
| 109 | panelstruct->paneltiminginfo |
| 110 | = &truly_wvga_cmd_timing_info; |
shuoy | bca6675 | 2013-09-03 18:17:21 +0800 | [diff] [blame] | 111 | panelstruct->panelresetseq |
| 112 | = &truly_wvga_cmd_reset_seq; |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 113 | panelstruct->backlightinfo = &truly_wvga_cmd_backlight; |
| 114 | pinfo->mipi.panel_cmds |
| 115 | = truly_wvga_cmd_on_command; |
| 116 | pinfo->mipi.num_of_panel_cmds |
| 117 | = TRULY_WVGA_CMD_ON_COMMAND; |
| 118 | memcpy(phy_db->timing, |
| 119 | truly_wvga_cmd_timings, TIMING_SIZE); |
| 120 | break; |
| 121 | case TRULY_WVGA_VIDEO_PANEL: |
| 122 | panelstruct->paneldata = &truly_wvga_video_panel_data; |
| 123 | panelstruct->panelres = &truly_wvga_video_panel_res; |
| 124 | panelstruct->color = &truly_wvga_video_color; |
| 125 | panelstruct->videopanel = &truly_wvga_video_video_panel; |
| 126 | panelstruct->commandpanel = &truly_wvga_video_command_panel; |
| 127 | panelstruct->state = &truly_wvga_video_state; |
| 128 | panelstruct->laneconfig = &truly_wvga_video_lane_config; |
| 129 | panelstruct->paneltiminginfo |
| 130 | = &truly_wvga_video_timing_info; |
shuoy | bca6675 | 2013-09-03 18:17:21 +0800 | [diff] [blame] | 131 | panelstruct->panelresetseq |
| 132 | = &truly_wvga_video_reset_seq; |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 133 | panelstruct->backlightinfo = &truly_wvga_video_backlight; |
| 134 | pinfo->mipi.panel_cmds |
| 135 | = truly_wvga_video_on_command; |
| 136 | pinfo->mipi.num_of_panel_cmds |
| 137 | = TRULY_WVGA_VIDEO_ON_COMMAND; |
| 138 | memcpy(phy_db->timing, |
| 139 | truly_wvga_video_timings, TIMING_SIZE); |
| 140 | break; |
shuoy | bca6675 | 2013-09-03 18:17:21 +0800 | [diff] [blame] | 141 | case HX8379A_WVGA_VIDEO_PANEL: |
| 142 | panelstruct->paneldata = &hx8379a_wvga_video_panel_data; |
| 143 | panelstruct->panelres = &hx8379a_wvga_video_panel_res; |
| 144 | panelstruct->color = &hx8379a_wvga_video_color; |
| 145 | panelstruct->videopanel = &hx8379a_wvga_video_video_panel; |
| 146 | panelstruct->commandpanel = &hx8379a_wvga_video_command_panel; |
| 147 | panelstruct->state = &hx8379a_wvga_video_state; |
| 148 | panelstruct->laneconfig = &hx8379a_wvga_video_lane_config; |
| 149 | panelstruct->paneltiminginfo |
| 150 | = &hx8379a_wvga_video_timing_info; |
| 151 | panelstruct->panelresetseq |
| 152 | = &hx8379a_wvga_video_reset_seq; |
| 153 | panelstruct->backlightinfo = &hx8379a_wvga_video_backlight; |
| 154 | pinfo->mipi.panel_cmds |
| 155 | = hx8379a_wvga_video_on_command; |
| 156 | pinfo->mipi.num_of_panel_cmds |
| 157 | = HX8379A_WVGA_VIDEO_ON_COMMAND; |
| 158 | memcpy(phy_db->timing, |
| 159 | hx8379a_wvga_video_timings, TIMING_SIZE); |
| 160 | break; |
| 161 | case OTM8018B_FWVGA_VIDEO_PANEL: |
| 162 | panelstruct->paneldata = &otm8018b_fwvga_video_panel_data; |
| 163 | panelstruct->panelres = &otm8018b_fwvga_video_panel_res; |
| 164 | panelstruct->color = &otm8018b_fwvga_video_color; |
| 165 | panelstruct->videopanel = &otm8018b_fwvga_video_video_panel; |
| 166 | panelstruct->commandpanel = &otm8018b_fwvga_video_command_panel; |
| 167 | panelstruct->state = &otm8018b_fwvga_video_state; |
| 168 | panelstruct->laneconfig = &otm8018b_fwvga_video_lane_config; |
| 169 | panelstruct->paneltiminginfo |
| 170 | = &otm8018b_fwvga_video_timing_info; |
| 171 | panelstruct->panelresetseq |
| 172 | = &otm8018b_fwvga_video_reset_seq; |
| 173 | panelstruct->backlightinfo = &otm8018b_fwvga_video_backlight; |
| 174 | pinfo->mipi.panel_cmds |
| 175 | = otm8018b_fwvga_video_on_command; |
| 176 | pinfo->mipi.num_of_panel_cmds |
| 177 | = OTM8018B_FWVGA_VIDEO_ON_COMMAND; |
| 178 | memcpy(phy_db->timing, |
| 179 | otm8018b_fwvga_video_timings, TIMING_SIZE); |
| 180 | break; |
| 181 | case NT35590_720P_VIDEO_PANEL: |
| 182 | panelstruct->paneldata = &nt35590_720p_video_panel_data; |
| 183 | panelstruct->panelres = &nt35590_720p_video_panel_res; |
| 184 | panelstruct->color = &nt35590_720p_video_color; |
| 185 | panelstruct->videopanel = &nt35590_720p_video_video_panel; |
| 186 | panelstruct->commandpanel = &nt35590_720p_video_command_panel; |
| 187 | panelstruct->state = &nt35590_720p_video_state; |
| 188 | panelstruct->laneconfig = &nt35590_720p_video_lane_config; |
| 189 | panelstruct->paneltiminginfo |
| 190 | = &nt35590_720p_video_timing_info; |
| 191 | panelstruct->panelresetseq |
| 192 | = &nt35590_720p_video_panel_reset_seq; |
| 193 | panelstruct->backlightinfo = &nt35590_720p_video_backlight; |
| 194 | pinfo->mipi.panel_cmds |
| 195 | = nt35590_720p_video_on_command; |
| 196 | pinfo->mipi.num_of_panel_cmds |
| 197 | = NT35590_720P_VIDEO_ON_COMMAND; |
| 198 | memcpy(phy_db->timing, |
| 199 | nt35590_720p_video_timings, TIMING_SIZE); |
| 200 | break; |
shuoy | ec420a7 | 2013-10-22 09:38:06 +0800 | [diff] [blame] | 201 | case HX8389B_QHD_VIDEO_PANEL: |
| 202 | panelstruct->paneldata = &hx8389b_qhd_video_panel_data; |
| 203 | panelstruct->panelres = &hx8389b_qhd_video_panel_res; |
| 204 | panelstruct->color = &hx8389b_qhd_video_color; |
| 205 | panelstruct->videopanel = &hx8389b_qhd_video_video_panel; |
| 206 | panelstruct->commandpanel = &hx8389b_qhd_video_command_panel; |
| 207 | panelstruct->state = &hx8389b_qhd_video_state; |
| 208 | panelstruct->laneconfig = &hx8389b_qhd_video_lane_config; |
| 209 | panelstruct->paneltiminginfo |
| 210 | = &hx8389b_qhd_video_timing_info; |
| 211 | panelstruct->panelresetseq |
| 212 | = &hx8389b_qhd_video_reset_seq; |
| 213 | panelstruct->backlightinfo = &hx8389b_qhd_video_backlight; |
| 214 | pinfo->mipi.panel_cmds |
| 215 | = hx8389b_qhd_video_on_command; |
| 216 | pinfo->mipi.num_of_panel_cmds |
| 217 | = HX8389B_QHD_VIDEO_ON_COMMAND; |
| 218 | memcpy(phy_db->timing, |
| 219 | hx8389b_qhd_video_timings, TIMING_SIZE); |
| 220 | break; |
Shivaraj Shetty | 25b0aa0 | 2013-10-30 20:55:49 +0530 | [diff] [blame] | 221 | case UNKNOWN_PANEL: |
| 222 | memset(panelstruct, 0, sizeof(struct panel_struct)); |
| 223 | memset(pinfo->mipi.panel_cmds, 0, sizeof(struct mipi_dsi_cmd)); |
| 224 | pinfo->mipi.num_of_panel_cmds = 0; |
| 225 | memset(phy_db->timing, 0, TIMING_SIZE); |
| 226 | pinfo->mipi.signature = 0; |
| 227 | dprintf(CRITICAL, "Unknown Panel"); |
| 228 | return false; |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 229 | default: |
| 230 | dprintf(CRITICAL, "Panel ID not detected %d\n", panel_id); |
| 231 | return false; |
| 232 | } |
| 233 | return true; |
| 234 | } |
| 235 | |
Shivaraj Shetty | 25b0aa0 | 2013-10-30 20:55:49 +0530 | [diff] [blame] | 236 | uint32_t oem_panel_max_auto_detect_panels() |
| 237 | { |
| 238 | return target_panel_auto_detect_enabled() ? |
| 239 | DISPLAY_MAX_PANEL_DETECTION : 0; |
| 240 | } |
| 241 | |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 242 | bool oem_panel_select(struct panel_struct *panelstruct, |
| 243 | struct msm_panel_info *pinfo, |
| 244 | struct mdss_dsi_phy_ctrl *phy_db) |
| 245 | { |
| 246 | uint32_t hw_id = board_hardware_id(); |
shuoy | bca6675 | 2013-09-03 18:17:21 +0800 | [diff] [blame] | 247 | uint32_t platform_subtype = board_hardware_subtype(); |
shuoy | ec420a7 | 2013-10-22 09:38:06 +0800 | [diff] [blame] | 248 | uint32_t target_id = board_target_id(); |
| 249 | |
| 250 | target_id = (target_id >> 16) & 0xFF; |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 251 | |
| 252 | switch (hw_id) { |
| 253 | case HW_PLATFORM_QRD: |
shuoy | ec420a7 | 2013-10-22 09:38:06 +0800 | [diff] [blame] | 254 | switch (platform_subtype) { |
| 255 | case QRD_DEF: |
| 256 | case QRD_SKUAA: |
| 257 | panel_id = HX8379A_WVGA_VIDEO_PANEL; |
| 258 | break; |
| 259 | case QRD_SKUAB: |
| 260 | if (target_id == 0x1) // 1st HW version |
| 261 | panel_id = OTM8018B_FWVGA_VIDEO_PANEL; |
| 262 | else if (target_id == 0x2) //2nd HW version |
| 263 | panel_id = HX8389B_QHD_VIDEO_PANEL; |
| 264 | else |
| 265 | dprintf(CRITICAL, "SKUAB Display not enabled for %d type\n", |
| 266 | target_id); |
| 267 | break; |
| 268 | default: |
| 269 | dprintf(CRITICAL, "QRD Display not enabled for %d type\n", |
| 270 | platform_subtype); |
| 271 | return false; |
| 272 | } |
shuoy | bca6675 | 2013-09-03 18:17:21 +0800 | [diff] [blame] | 273 | break; |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 274 | case HW_PLATFORM_MTP: |
shuoy | bca6675 | 2013-09-03 18:17:21 +0800 | [diff] [blame] | 275 | if (0 == platform_subtype) |
| 276 | panel_id = TRULY_WVGA_VIDEO_PANEL; |
| 277 | else |
| 278 | panel_id = NT35590_720P_VIDEO_PANEL; |
| 279 | break; |
| 280 | |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 281 | case HW_PLATFORM_SURF: |
| 282 | panel_id = TRULY_WVGA_VIDEO_PANEL; |
| 283 | break; |
| 284 | default: |
| 285 | dprintf(CRITICAL, "Display not enabled for %d HW type\n", hw_id); |
| 286 | return false; |
| 287 | } |
| 288 | |
| 289 | return init_panel_data(panelstruct, pinfo, phy_db); |
| 290 | } |