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