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