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> |
| 36 | #include <mipi_dsi.h> |
| 37 | #include <target/display.h> |
| 38 | |
| 39 | #include "include/panel.h" |
| 40 | #include "panel_display.h" |
| 41 | |
| 42 | /*---------------------------------------------------------------------------*/ |
| 43 | /* GCDB Panel Database */ |
| 44 | /*---------------------------------------------------------------------------*/ |
| 45 | #include "include/panel_truly_1080p_video.h" |
Jayant Shekhar | 9ea8dcd | 2015-04-20 15:18:37 +0530 | [diff] [blame] | 46 | #include "include/panel_truly_1080p_cmd.h" |
feifanz | 174c82c | 2015-04-15 18:57:07 +0800 | [diff] [blame^] | 47 | #include "include/panel_otm1906c_1080p_cmd.h" |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 48 | |
| 49 | /*---------------------------------------------------------------------------*/ |
| 50 | /* static panel selection variable */ |
| 51 | /*---------------------------------------------------------------------------*/ |
| 52 | enum { |
| 53 | TRULY_1080P_VIDEO_PANEL, |
Jayant Shekhar | 9ea8dcd | 2015-04-20 15:18:37 +0530 | [diff] [blame] | 54 | TRULY_1080P_CMD_PANEL, |
feifanz | 174c82c | 2015-04-15 18:57:07 +0800 | [diff] [blame^] | 55 | OTM1906C_1080P_CMD_PANEL, |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 56 | UNKNOWN_PANEL |
| 57 | }; |
| 58 | |
| 59 | uint32_t panel_regulator_settings[] = { |
| 60 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 |
| 61 | }; |
| 62 | |
| 63 | /* |
| 64 | * The list of panels that are supported on this target. |
| 65 | * Any panel in this list can be selected using fastboot oem command. |
| 66 | */ |
| 67 | static struct panel_list supp_panels[] = { |
| 68 | {"truly_1080p_video", TRULY_1080P_VIDEO_PANEL}, |
Jayant Shekhar | 9ea8dcd | 2015-04-20 15:18:37 +0530 | [diff] [blame] | 69 | {"truly_1080p_cmd", TRULY_1080P_CMD_PANEL}, |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | static uint32_t panel_id; |
| 73 | |
| 74 | int oem_panel_rotation() |
| 75 | { |
| 76 | return NO_ERROR; |
| 77 | } |
| 78 | |
| 79 | int oem_panel_on() |
| 80 | { |
| 81 | /* |
| 82 | *OEM can keep their panel specific on instructions in this |
| 83 | *function |
| 84 | */ |
| 85 | return NO_ERROR; |
| 86 | } |
| 87 | |
| 88 | int oem_panel_off() |
| 89 | { |
| 90 | /* OEM can keep their panel specific off instructions |
| 91 | * in this function |
| 92 | */ |
| 93 | return NO_ERROR; |
| 94 | } |
| 95 | |
| 96 | static int init_panel_data(struct panel_struct *panelstruct, |
| 97 | struct msm_panel_info *pinfo, |
| 98 | struct mdss_dsi_phy_ctrl *phy_db) |
| 99 | { |
| 100 | int pan_type = PANEL_TYPE_DSI; |
| 101 | |
| 102 | switch (panel_id) { |
| 103 | case TRULY_1080P_VIDEO_PANEL: |
| 104 | panelstruct->paneldata = &truly_1080p_video_panel_data; |
| 105 | panelstruct->paneldata->panel_with_enable_gpio = 1; |
| 106 | panelstruct->panelres = &truly_1080p_video_panel_res; |
| 107 | panelstruct->color = &truly_1080p_video_color; |
| 108 | panelstruct->videopanel = &truly_1080p_video_video_panel; |
| 109 | panelstruct->commandpanel = &truly_1080p_video_command_panel; |
| 110 | panelstruct->state = &truly_1080p_video_state; |
| 111 | panelstruct->laneconfig = &truly_1080p_video_lane_config; |
| 112 | panelstruct->paneltiminginfo |
| 113 | = &truly_1080p_video_timing_info; |
| 114 | panelstruct->panelresetseq |
| 115 | = &truly_1080p_video_panel_reset_seq; |
| 116 | panelstruct->backlightinfo = &truly_1080p_video_backlight; |
| 117 | pinfo->mipi.panel_on_cmds |
| 118 | = truly_1080p_video_on_command; |
| 119 | pinfo->mipi.num_of_panel_on_cmds |
| 120 | = TRULY_1080P_VIDEO_ON_COMMAND; |
| 121 | pinfo->mipi.panel_off_cmds |
| 122 | = truly_1080p_video_off_command; |
| 123 | pinfo->mipi.num_of_panel_off_cmds |
| 124 | = TRULY_1080P_VIDEO_OFF_COMMAND; |
| 125 | memcpy(phy_db->timing, |
| 126 | truly_1080p_video_timings, TIMING_SIZE); |
| 127 | pinfo->mipi.signature = TRULY_1080P_VIDEO_SIGNATURE; |
| 128 | break; |
Jayant Shekhar | 9ea8dcd | 2015-04-20 15:18:37 +0530 | [diff] [blame] | 129 | case TRULY_1080P_CMD_PANEL: |
| 130 | panelstruct->paneldata = &truly_1080p_cmd_panel_data; |
| 131 | panelstruct->paneldata->panel_with_enable_gpio = 1; |
| 132 | panelstruct->panelres = &truly_1080p_cmd_panel_res; |
| 133 | panelstruct->color = &truly_1080p_cmd_color; |
| 134 | panelstruct->videopanel = &truly_1080p_cmd_video_panel; |
| 135 | panelstruct->commandpanel = &truly_1080p_cmd_command_panel; |
| 136 | panelstruct->state = &truly_1080p_cmd_state; |
| 137 | panelstruct->laneconfig = &truly_1080p_cmd_lane_config; |
| 138 | panelstruct->paneltiminginfo |
| 139 | = &truly_1080p_cmd_timing_info; |
| 140 | panelstruct->panelresetseq |
| 141 | = &truly_1080p_cmd_panel_reset_seq; |
| 142 | panelstruct->backlightinfo = &truly_1080p_cmd_backlight; |
| 143 | pinfo->mipi.panel_on_cmds |
| 144 | = truly_1080p_cmd_on_command; |
| 145 | pinfo->mipi.num_of_panel_on_cmds |
| 146 | = TRULY_1080P_CMD_ON_COMMAND; |
| 147 | pinfo->mipi.panel_off_cmds |
| 148 | = truly_1080p_cmd_off_command; |
| 149 | pinfo->mipi.num_of_panel_off_cmds |
| 150 | = TRULY_1080P_CMD_OFF_COMMAND; |
| 151 | memcpy(phy_db->timing, |
| 152 | truly_1080p_cmd_timings, TIMING_SIZE); |
| 153 | pinfo->mipi.signature = TRULY_1080P_CMD_SIGNATURE; |
| 154 | break; |
feifanz | 174c82c | 2015-04-15 18:57:07 +0800 | [diff] [blame^] | 155 | case OTM1906C_1080P_CMD_PANEL: |
| 156 | panelstruct->paneldata = &otm1906c_1080p_cmd_panel_data; |
| 157 | panelstruct->paneldata->panel_with_enable_gpio = 1; |
| 158 | panelstruct->panelres = &otm1906c_1080p_cmd_panel_res; |
| 159 | panelstruct->color = &otm1906c_1080p_cmd_color; |
| 160 | panelstruct->videopanel = &otm1906c_1080p_cmd_video_panel; |
| 161 | panelstruct->commandpanel = &otm1906c_1080p_cmd_command_panel; |
| 162 | panelstruct->state = &otm1906c_1080p_cmd_state; |
| 163 | panelstruct->laneconfig = &otm1906c_1080p_cmd_lane_config; |
| 164 | panelstruct->paneltiminginfo |
| 165 | = &otm1906c_1080p_cmd_timing_info; |
| 166 | panelstruct->panelresetseq |
| 167 | = &otm1906c_1080p_cmd_panel_reset_seq; |
| 168 | panelstruct->backlightinfo = &otm1906c_1080p_cmd_backlight; |
| 169 | pinfo->mipi.panel_on_cmds |
| 170 | = otm1906c_1080p_cmd_on_command; |
| 171 | pinfo->mipi.num_of_panel_on_cmds |
| 172 | = OTM1906C_1080P_CMD_ON_COMMAND; |
| 173 | pinfo->mipi.panel_off_cmds |
| 174 | = otm1906c_1080p_cmd_off_command; |
| 175 | pinfo->mipi.num_of_panel_off_cmds |
| 176 | = OTM1906C_1080P_CMD_OFF_COMMAND; |
| 177 | memcpy(phy_db->timing, |
| 178 | otm1906c_1080p_cmd_timings, TIMING_SIZE); |
| 179 | pinfo->mipi.signature = OTM1906C_1080P_CMD_SIGNATURE; |
| 180 | break; |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 181 | case UNKNOWN_PANEL: |
| 182 | default: |
| 183 | memset(panelstruct, 0, sizeof(struct panel_struct)); |
| 184 | memset(pinfo->mipi.panel_on_cmds, 0, |
| 185 | sizeof(struct mipi_dsi_cmd)); |
| 186 | pinfo->mipi.num_of_panel_on_cmds = 0; |
| 187 | memset(pinfo->mipi.panel_off_cmds, 0, |
| 188 | sizeof(struct mipi_dsi_cmd)); |
| 189 | pinfo->mipi.num_of_panel_off_cmds = 0; |
| 190 | memset(phy_db->timing, 0, TIMING_SIZE); |
| 191 | pan_type = PANEL_TYPE_UNKNOWN; |
| 192 | break; |
| 193 | } |
| 194 | return pan_type; |
| 195 | } |
| 196 | |
| 197 | int oem_panel_select(const char *panel_name, struct panel_struct *panelstruct, |
| 198 | struct msm_panel_info *pinfo, |
| 199 | struct mdss_dsi_phy_ctrl *phy_db) |
| 200 | { |
| 201 | uint32_t hw_id = board_hardware_id(); |
| 202 | int32_t panel_override_id; |
| 203 | |
| 204 | if (panel_name) { |
| 205 | panel_override_id = panel_name_to_id(supp_panels, |
| 206 | ARRAY_SIZE(supp_panels), panel_name); |
| 207 | |
| 208 | if (panel_override_id < 0) { |
| 209 | dprintf(CRITICAL, "Not able to search the panel:%s\n", |
| 210 | panel_name + strspn(panel_name, " ")); |
| 211 | } else if (panel_override_id < UNKNOWN_PANEL) { |
| 212 | /* panel override using fastboot oem command */ |
| 213 | panel_id = panel_override_id; |
| 214 | |
| 215 | dprintf(INFO, "OEM panel override:%s\n", |
| 216 | panel_name + strspn(panel_name, " ")); |
| 217 | goto panel_init; |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | switch (hw_id) { |
| 222 | case HW_PLATFORM_MTP: |
| 223 | panel_id = TRULY_1080P_VIDEO_PANEL; |
| 224 | break; |
| 225 | case HW_PLATFORM_SURF: |
| 226 | panel_id = TRULY_1080P_VIDEO_PANEL; |
| 227 | break; |
feifanz | 174c82c | 2015-04-15 18:57:07 +0800 | [diff] [blame^] | 228 | case HW_PLATFORM_QRD: |
| 229 | panel_id = OTM1906C_1080P_CMD_PANEL; |
| 230 | break; |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 231 | default: |
| 232 | dprintf(CRITICAL, "Display not enabled for %d HW type\n", |
| 233 | hw_id); |
| 234 | return PANEL_TYPE_UNKNOWN; |
| 235 | } |
| 236 | |
| 237 | panel_init: |
| 238 | /* |
| 239 | * Update all data structures after 'panel_init' label. Only panel |
| 240 | * selection is supposed to happen before that. |
| 241 | */ |
| 242 | memcpy(panel_regulator_settings, |
| 243 | dcdc_regulator_settings, REGULATOR_SIZE); |
| 244 | pinfo->pipe_type = MDSS_MDP_PIPE_TYPE_RGB; |
| 245 | return init_panel_data(panelstruct, pinfo, phy_db); |
| 246 | } |