blob: b18c74af8bdd1a7bd5bec4915e2b323f85c611a4 [file] [log] [blame]
Shivaraj Shettyf9e10c42014-09-17 04:21:15 +05301/* Copyright (c) 2014, 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#include <target/display.h>
37#include "include/panel.h"
38#include "panel_display.h"
39
40#include "include/panel_hx8394d_720p_video.h"
41
42#define DISPLAY_MAX_PANEL_DETECTION 0
43
44/*---------------------------------------------------------------------------*/
45/* static panel selection variable */
46/*---------------------------------------------------------------------------*/
47static uint32_t auto_pan_loop = 0;
48
49enum {
50 HX8394D_720P_VIDEO_PANEL,
51 UNKNOWN_PANEL
52};
53
54/*
55 * The list of panels that are supported on this target.
56 * Any panel in this list can be selected using fastboot oem command.
57 */
58static struct panel_list supp_panels[] = {
59 {"hx8394d_720p_video", HX8394D_720P_VIDEO_PANEL}
60};
61
62static uint32_t panel_id;
63
64int oem_panel_rotation()
65{
66 return NO_ERROR;
67}
68
69int oem_panel_on()
70{
71 /*
72 * OEM can keep there panel specific on instructions in this
73 * function
74 */
75 return NO_ERROR;
76}
77
78int oem_panel_off()
79{
80 /*
81 * OEM can keep their panel specific off instructions
82 * in this function
83 */
84 return NO_ERROR;
85}
86
87static int init_panel_data(struct panel_struct *panelstruct,
88 struct msm_panel_info *pinfo,
89 struct mdss_dsi_phy_ctrl *phy_db)
90{
91 int pan_type = PANEL_TYPE_DSI;
92
93 switch (panel_id) {
94 case HX8394D_720P_VIDEO_PANEL:
95 panelstruct->paneldata = &hx8394d_720p_video_panel_data;
96 panelstruct->panelres = &hx8394d_720p_video_panel_res;
97 panelstruct->color = &hx8394d_720p_video_color;
98 panelstruct->videopanel = &hx8394d_720p_video_video_panel;
99 panelstruct->commandpanel = &hx8394d_720p_video_command_panel;
100 panelstruct->state = &hx8394d_720p_video_state;
101 panelstruct->laneconfig = &hx8394d_720p_video_lane_config;
102 panelstruct->paneltiminginfo
103 = &hx8394d_720p_video_timing_info;
104 panelstruct->panelresetseq
105 = &hx8394d_720p_video_panel_reset_seq;
106 panelstruct->backlightinfo = &hx8394d_720p_video_backlight;
107 pinfo->mipi.panel_cmds
108 = hx8394d_720p_video_on_command;
109 pinfo->mipi.num_of_panel_cmds
110 = HX8394D_720P_VIDEO_ON_COMMAND;
111 memcpy(phy_db->timing,
112 hx8394d_720p_video_timings, TIMING_SIZE);
113 pinfo->mipi.signature = HX8394D_720P_VIDEO_SIGNATURE;
114 break;
115 case UNKNOWN_PANEL:
116 default:
117 memset(panelstruct, 0, sizeof(struct panel_struct));
118 memset(pinfo->mipi.panel_cmds, 0, sizeof(struct mipi_dsi_cmd));
119 pinfo->mipi.num_of_panel_cmds = 0;
120 memset(phy_db->timing, 0, TIMING_SIZE);
121 pan_type = PANEL_TYPE_UNKNOWN;
122 break;
123 }
124 return pan_type;
125}
126
127uint32_t oem_panel_max_auto_detect_panels()
128{
129 return target_panel_auto_detect_enabled() ?
130 DISPLAY_MAX_PANEL_DETECTION : 0;
131}
132
133int oem_panel_select(const char *panel_name, struct panel_struct *panelstruct,
134 struct msm_panel_info *pinfo,
135 struct mdss_dsi_phy_ctrl *phy_db)
136{
137 uint32_t hw_id = board_hardware_id();
138 int32_t panel_override_id;
139
140 if (panel_name) {
141 panel_override_id = panel_name_to_id(supp_panels,
142 ARRAY_SIZE(supp_panels), panel_name);
143
144 if (panel_override_id < 0) {
145 dprintf(CRITICAL, "Not able to search the panel:%s\n",
146 panel_name + strspn(panel_name, " "));
147 } else if (panel_override_id < UNKNOWN_PANEL) {
148 /* panel override using fastboot oem command */
149 panel_id = panel_override_id;
150
151 dprintf(INFO, "OEM panel override:%s\n",
152 panel_name + strspn(panel_name, " "));
153 goto panel_init;
154 }
155 }
156 switch (hw_id) {
157 case HW_PLATFORM_SURF:
158 panel_id = HX8394D_720P_VIDEO_PANEL;
159 break;
160 default:
161 dprintf(CRITICAL, "Display not enabled for %d HW type\n",
162 hw_id);
163 return PANEL_TYPE_UNKNOWN;
164 }
165
166panel_init:
167 return init_panel_data(panelstruct, pinfo, phy_db);
168}