Padmanabhan Komanduru | bccbcdc | 2015-06-30 16:19:24 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. |
Dhaval Patel | f998627 | 2013-10-18 19:06:05 -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_jdi_1080p_video.h" |
Dhaval Patel | d0a09e2 | 2013-10-25 10:15:21 -0700 | [diff] [blame] | 44 | #include "include/panel_jdi_qhd_dualdsi_video.h" |
Dhaval Patel | aee7e54 | 2014-01-06 16:08:16 -0800 | [diff] [blame] | 45 | #include "include/panel_jdi_qhd_dualdsi_cmd.h" |
Dhaval Patel | f998627 | 2013-10-18 19:06:05 -0700 | [diff] [blame] | 46 | |
| 47 | /*---------------------------------------------------------------------------*/ |
| 48 | /* static panel selection variable */ |
| 49 | /*---------------------------------------------------------------------------*/ |
| 50 | enum { |
| 51 | JDI_1080P_VIDEO_PANEL, |
Dhaval Patel | d0a09e2 | 2013-10-25 10:15:21 -0700 | [diff] [blame] | 52 | JDI_QHD_DUALDSI_VIDEO_PANEL, |
Dhaval Patel | aee7e54 | 2014-01-06 16:08:16 -0800 | [diff] [blame] | 53 | JDI_QHD_DUALDSI_CMD_PANEL, |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 54 | EDP_OEM_PANEL, |
| 55 | UNKNOWN_PANEL, |
Dhaval Patel | f998627 | 2013-10-18 19:06:05 -0700 | [diff] [blame] | 56 | }; |
| 57 | |
Dhaval Patel | bae4988 | 2014-02-18 17:16:53 -0800 | [diff] [blame] | 58 | /* |
| 59 | * The list of panels that are supported on this target. |
| 60 | * Any panel in this list can be selected using fastboot oem command. |
| 61 | */ |
| 62 | static struct panel_list supp_panels[] = { |
| 63 | {"jdi_1080p_video", JDI_1080P_VIDEO_PANEL}, |
| 64 | {"jdi_qhd_dualdsi_video", JDI_QHD_DUALDSI_VIDEO_PANEL}, |
| 65 | {"jdi_qhd_dualdsi_cmd", JDI_QHD_DUALDSI_CMD_PANEL}, |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 66 | {"edp", EDP_OEM_PANEL}, |
Dhaval Patel | bae4988 | 2014-02-18 17:16:53 -0800 | [diff] [blame] | 67 | }; |
| 68 | |
Dhaval Patel | f998627 | 2013-10-18 19:06:05 -0700 | [diff] [blame] | 69 | static uint32_t panel_id; |
| 70 | |
| 71 | int oem_panel_rotation() |
| 72 | { |
Dhaval Patel | fc7c609 | 2014-03-31 17:15:24 -0700 | [diff] [blame] | 73 | /* OEM can keep there panel specific on instructions in this |
Dhaval Patel | f998627 | 2013-10-18 19:06:05 -0700 | [diff] [blame] | 74 | function */ |
| 75 | return NO_ERROR; |
| 76 | } |
| 77 | |
Dhaval Patel | f998627 | 2013-10-18 19:06:05 -0700 | [diff] [blame] | 78 | int oem_panel_on() |
| 79 | { |
Dhaval Patel | fc7c609 | 2014-03-31 17:15:24 -0700 | [diff] [blame] | 80 | /* OEM can keep there panel specific on instructions in this |
Dhaval Patel | f998627 | 2013-10-18 19:06:05 -0700 | [diff] [blame] | 81 | function */ |
Dhaval Patel | fc7c609 | 2014-03-31 17:15:24 -0700 | [diff] [blame] | 82 | if (panel_id == JDI_QHD_DUALDSI_CMD_PANEL) { |
| 83 | /* needs extra delay to avoid unexpected artifacts */ |
| 84 | mdelay(JDI_QHD_DUALDSI_CMD_PANEL_ON_DELAY); |
| 85 | } |
Dhaval Patel | f998627 | 2013-10-18 19:06:05 -0700 | [diff] [blame] | 86 | return NO_ERROR; |
| 87 | } |
| 88 | |
| 89 | int oem_panel_off() |
| 90 | { |
Dhaval Patel | fc7c609 | 2014-03-31 17:15:24 -0700 | [diff] [blame] | 91 | /* OEM can keep there panel specific off instructions in this |
Dhaval Patel | f998627 | 2013-10-18 19:06:05 -0700 | [diff] [blame] | 92 | function */ |
| 93 | return NO_ERROR; |
| 94 | } |
| 95 | |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 96 | static int init_panel_data(struct panel_struct *panelstruct, |
Dhaval Patel | f998627 | 2013-10-18 19:06:05 -0700 | [diff] [blame] | 97 | struct msm_panel_info *pinfo, |
| 98 | struct mdss_dsi_phy_ctrl *phy_db) |
| 99 | { |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 100 | int pan_type; |
Dhaval Patel | f998627 | 2013-10-18 19:06:05 -0700 | [diff] [blame] | 101 | |
| 102 | switch (panel_id) { |
| 103 | case JDI_1080P_VIDEO_PANEL: |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 104 | pan_type = PANEL_TYPE_DSI; |
Dhaval Patel | f998627 | 2013-10-18 19:06:05 -0700 | [diff] [blame] | 105 | panelstruct->paneldata = &jdi_1080p_video_panel_data; |
| 106 | panelstruct->panelres = &jdi_1080p_video_panel_res; |
| 107 | panelstruct->color = &jdi_1080p_video_color; |
| 108 | panelstruct->videopanel = &jdi_1080p_video_video_panel; |
| 109 | panelstruct->commandpanel = &jdi_1080p_video_command_panel; |
| 110 | panelstruct->state = &jdi_1080p_video_state; |
| 111 | panelstruct->laneconfig = &jdi_1080p_video_lane_config; |
| 112 | panelstruct->paneltiminginfo |
| 113 | = &jdi_1080p_video_timing_info; |
| 114 | panelstruct->panelresetseq |
| 115 | = &jdi_1080p_video_panel_reset_seq; |
| 116 | panelstruct->backlightinfo = &jdi_1080p_video_backlight; |
Padmanabhan Komanduru | b3d3184 | 2014-11-04 15:47:53 +0530 | [diff] [blame] | 117 | pinfo->mipi.panel_on_cmds |
Dhaval Patel | f998627 | 2013-10-18 19:06:05 -0700 | [diff] [blame] | 118 | = jdi_1080p_video_on_command; |
Padmanabhan Komanduru | b3d3184 | 2014-11-04 15:47:53 +0530 | [diff] [blame] | 119 | pinfo->mipi.num_of_panel_on_cmds |
Dhaval Patel | f998627 | 2013-10-18 19:06:05 -0700 | [diff] [blame] | 120 | = JDI_1080P_VIDEO_ON_COMMAND; |
Padmanabhan Komanduru | b3d3184 | 2014-11-04 15:47:53 +0530 | [diff] [blame] | 121 | pinfo->mipi.panel_off_cmds |
| 122 | = jdi_1080p_video_off_command; |
| 123 | pinfo->mipi.num_of_panel_off_cmds |
| 124 | = JDI_1080P_VIDEO_OFF_COMMAND; |
Dhaval Patel | f998627 | 2013-10-18 19:06:05 -0700 | [diff] [blame] | 125 | memcpy(phy_db->timing, |
| 126 | jdi_1080p_video_timings, TIMING_SIZE); |
| 127 | break; |
Dhaval Patel | d0a09e2 | 2013-10-25 10:15:21 -0700 | [diff] [blame] | 128 | case JDI_QHD_DUALDSI_VIDEO_PANEL: |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 129 | pan_type = PANEL_TYPE_DSI; |
Dhaval Patel | d0a09e2 | 2013-10-25 10:15:21 -0700 | [diff] [blame] | 130 | panelstruct->paneldata = &jdi_qhd_dualdsi_video_panel_data; |
| 131 | panelstruct->panelres = &jdi_qhd_dualdsi_video_panel_res; |
| 132 | panelstruct->color = &jdi_qhd_dualdsi_video_color; |
| 133 | panelstruct->videopanel = &jdi_qhd_dualdsi_video_video_panel; |
| 134 | panelstruct->commandpanel = &jdi_qhd_dualdsi_video_command_panel; |
| 135 | panelstruct->state = &jdi_qhd_dualdsi_video_state; |
| 136 | panelstruct->laneconfig = &jdi_qhd_dualdsi_video_lane_config; |
| 137 | panelstruct->paneltiminginfo |
| 138 | = &jdi_qhd_dualdsi_video_timing_info; |
| 139 | panelstruct->panelresetseq |
| 140 | = &jdi_qhd_dualdsi_video_reset_seq; |
| 141 | panelstruct->backlightinfo = &jdi_qhd_dualdsi_video_backlight; |
Padmanabhan Komanduru | b3d3184 | 2014-11-04 15:47:53 +0530 | [diff] [blame] | 142 | pinfo->mipi.panel_on_cmds |
Dhaval Patel | d0a09e2 | 2013-10-25 10:15:21 -0700 | [diff] [blame] | 143 | = jdi_qhd_dualdsi_video_on_command; |
Padmanabhan Komanduru | b3d3184 | 2014-11-04 15:47:53 +0530 | [diff] [blame] | 144 | pinfo->mipi.num_of_panel_on_cmds |
Dhaval Patel | d0a09e2 | 2013-10-25 10:15:21 -0700 | [diff] [blame] | 145 | = JDI_QHD_DUALDSI_VIDEO_ON_COMMAND; |
Padmanabhan Komanduru | b3d3184 | 2014-11-04 15:47:53 +0530 | [diff] [blame] | 146 | pinfo->mipi.panel_off_cmds |
| 147 | = jdi_qhd_dualdsi_video_off_command; |
| 148 | pinfo->mipi.num_of_panel_off_cmds |
| 149 | = JDI_QHD_DUALDSI_VIDEO_OFF_COMMAND; |
Dhaval Patel | d0a09e2 | 2013-10-25 10:15:21 -0700 | [diff] [blame] | 150 | memcpy(phy_db->timing, |
| 151 | jdi_qhd_dualdsi_video_timings, TIMING_SIZE); |
| 152 | break; |
Dhaval Patel | aee7e54 | 2014-01-06 16:08:16 -0800 | [diff] [blame] | 153 | case JDI_QHD_DUALDSI_CMD_PANEL: |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 154 | pan_type = PANEL_TYPE_DSI; |
Dhaval Patel | aee7e54 | 2014-01-06 16:08:16 -0800 | [diff] [blame] | 155 | panelstruct->paneldata = &jdi_qhd_dualdsi_cmd_panel_data; |
| 156 | panelstruct->panelres = &jdi_qhd_dualdsi_cmd_panel_res; |
| 157 | panelstruct->color = &jdi_qhd_dualdsi_cmd_color; |
| 158 | panelstruct->videopanel = &jdi_qhd_dualdsi_cmd_video_panel; |
| 159 | panelstruct->commandpanel = &jdi_qhd_dualdsi_cmd_command_panel; |
| 160 | panelstruct->state = &jdi_qhd_dualdsi_cmd_state; |
| 161 | panelstruct->laneconfig = &jdi_qhd_dualdsi_cmd_lane_config; |
| 162 | panelstruct->paneltiminginfo |
| 163 | = &jdi_qhd_dualdsi_cmd_timing_info; |
| 164 | panelstruct->panelresetseq |
| 165 | = &jdi_qhd_dualdsi_cmd_reset_seq; |
| 166 | panelstruct->backlightinfo = &jdi_qhd_dualdsi_cmd_backlight; |
Padmanabhan Komanduru | b3d3184 | 2014-11-04 15:47:53 +0530 | [diff] [blame] | 167 | pinfo->mipi.panel_on_cmds |
Dhaval Patel | aee7e54 | 2014-01-06 16:08:16 -0800 | [diff] [blame] | 168 | = jdi_qhd_dualdsi_cmd_on_command; |
Padmanabhan Komanduru | b3d3184 | 2014-11-04 15:47:53 +0530 | [diff] [blame] | 169 | pinfo->mipi.num_of_panel_on_cmds |
Dhaval Patel | aee7e54 | 2014-01-06 16:08:16 -0800 | [diff] [blame] | 170 | = JDI_QHD_DUALDSI_CMD_ON_COMMAND; |
Padmanabhan Komanduru | b3d3184 | 2014-11-04 15:47:53 +0530 | [diff] [blame] | 171 | pinfo->mipi.panel_off_cmds |
| 172 | = jdi_qhd_dualdsi_cmd_off_command; |
| 173 | pinfo->mipi.num_of_panel_off_cmds |
| 174 | = JDI_QHD_DUALDSI_CMD_OFF_COMMAND; |
Dhaval Patel | aee7e54 | 2014-01-06 16:08:16 -0800 | [diff] [blame] | 175 | memcpy(phy_db->timing, |
| 176 | jdi_qhd_dualdsi_cmd_timings, TIMING_SIZE); |
| 177 | break; |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 178 | case EDP_OEM_PANEL: |
| 179 | pan_type = PANEL_TYPE_EDP; |
| 180 | /* edp panel init base on edid */ |
| 181 | break; |
Dhaval Patel | f998627 | 2013-10-18 19:06:05 -0700 | [diff] [blame] | 182 | default: |
| 183 | case UNKNOWN_PANEL: |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 184 | pan_type = PANEL_TYPE_UNKNOWN; |
Dhaval Patel | f998627 | 2013-10-18 19:06:05 -0700 | [diff] [blame] | 185 | break; |
| 186 | } |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 187 | |
| 188 | return pan_type; |
Dhaval Patel | f998627 | 2013-10-18 19:06:05 -0700 | [diff] [blame] | 189 | } |
| 190 | |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 191 | int oem_panel_select(const char *panel_name, struct panel_struct *panelstruct, |
Dhaval Patel | f998627 | 2013-10-18 19:06:05 -0700 | [diff] [blame] | 192 | struct msm_panel_info *pinfo, |
| 193 | struct mdss_dsi_phy_ctrl *phy_db) |
| 194 | { |
| 195 | uint32_t hw_id = board_hardware_id(); |
Dhaval Patel | bae4988 | 2014-02-18 17:16:53 -0800 | [diff] [blame] | 196 | int32_t panel_override_id; |
| 197 | |
| 198 | if (panel_name) { |
| 199 | panel_override_id = panel_name_to_id(supp_panels, |
| 200 | ARRAY_SIZE(supp_panels), panel_name); |
| 201 | |
| 202 | if (panel_override_id < 0) { |
| 203 | dprintf(CRITICAL, "Not able to search the panel:%s\n", |
Padmanabhan Komanduru | bccbcdc | 2015-06-30 16:19:24 +0530 | [diff] [blame] | 204 | panel_name); |
Dhaval Patel | bae4988 | 2014-02-18 17:16:53 -0800 | [diff] [blame] | 205 | } else if (panel_override_id < UNKNOWN_PANEL) { |
| 206 | /* panel override using fastboot oem command */ |
| 207 | panel_id = panel_override_id; |
| 208 | |
| 209 | dprintf(INFO, "OEM panel override:%s\n", |
Padmanabhan Komanduru | bccbcdc | 2015-06-30 16:19:24 +0530 | [diff] [blame] | 210 | panel_name); |
Dhaval Patel | bae4988 | 2014-02-18 17:16:53 -0800 | [diff] [blame] | 211 | goto panel_init; |
| 212 | } |
| 213 | } |
Dhaval Patel | f998627 | 2013-10-18 19:06:05 -0700 | [diff] [blame] | 214 | |
| 215 | switch (hw_id) { |
| 216 | case HW_PLATFORM_MTP: |
| 217 | case HW_PLATFORM_FLUID: |
| 218 | case HW_PLATFORM_SURF: |
| 219 | panel_id = JDI_1080P_VIDEO_PANEL; |
| 220 | break; |
Dhaval Patel | d0a09e2 | 2013-10-25 10:15:21 -0700 | [diff] [blame] | 221 | case HW_PLATFORM_LIQUID: |
| 222 | panel_id = JDI_QHD_DUALDSI_VIDEO_PANEL; |
| 223 | break; |
Dhaval Patel | f998627 | 2013-10-18 19:06:05 -0700 | [diff] [blame] | 224 | default: |
| 225 | dprintf(CRITICAL, "Display not enabled for %d HW type\n" |
| 226 | , hw_id); |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 227 | return PANEL_TYPE_UNKNOWN; |
Dhaval Patel | f998627 | 2013-10-18 19:06:05 -0700 | [diff] [blame] | 228 | } |
| 229 | |
Dhaval Patel | bae4988 | 2014-02-18 17:16:53 -0800 | [diff] [blame] | 230 | panel_init: |
Dhaval Patel | f998627 | 2013-10-18 19:06:05 -0700 | [diff] [blame] | 231 | return init_panel_data(panelstruct, pinfo, phy_db); |
| 232 | } |