blob: c9ab88e9900bf4a923d7883684e392e9a384281a [file] [log] [blame]
Aravind Venkateswaranca82bd62012-01-10 15:57:53 -08001/* Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 */
13#ifndef __EXTERNAL_COMMON_H__
14#define __EXTERNAL_COMMON_H__
Saurabh Shah79d05a62012-01-09 15:18:33 -080015#include <linux/switch.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070016
17#ifdef DEBUG
18#ifndef DEV_DBG_PREFIX
19#define DEV_DBG_PREFIX "EXT_INTERFACE: "
20#endif
21#define DEV_DBG(args...) pr_debug(DEV_DBG_PREFIX args)
22#else
23#define DEV_DBG(args...) (void)0
24#endif /* DEBUG */
25#define DEV_INFO(args...) dev_info(external_common_state->dev, args)
26#define DEV_WARN(args...) dev_warn(external_common_state->dev, args)
27#define DEV_ERR(args...) dev_err(external_common_state->dev, args)
28
29#ifdef CONFIG_FB_MSM_TVOUT
30#define TVOUT_VFRMT_NTSC_M_720x480i 0
31#define TVOUT_VFRMT_NTSC_J_720x480i 1
32#define TVOUT_VFRMT_PAL_BDGHIN_720x576i 2
33#define TVOUT_VFRMT_PAL_M_720x480i 3
34#define TVOUT_VFRMT_PAL_N_720x480i 4
35#elif defined(CONFIG_FB_MSM_HDMI_COMMON)
36/* all video formats defined by EIA CEA 861D */
37#define HDMI_VFRMT_640x480p60_4_3 0
38#define HDMI_VFRMT_720x480p60_4_3 1
39#define HDMI_VFRMT_720x480p60_16_9 2
40#define HDMI_VFRMT_1280x720p60_16_9 3
41#define HDMI_VFRMT_1920x1080i60_16_9 4
42#define HDMI_VFRMT_720x480i60_4_3 5
43#define HDMI_VFRMT_1440x480i60_4_3 HDMI_VFRMT_720x480i60_4_3
44#define HDMI_VFRMT_720x480i60_16_9 6
45#define HDMI_VFRMT_1440x480i60_16_9 HDMI_VFRMT_720x480i60_16_9
46#define HDMI_VFRMT_720x240p60_4_3 7
47#define HDMI_VFRMT_1440x240p60_4_3 HDMI_VFRMT_720x240p60_4_3
48#define HDMI_VFRMT_720x240p60_16_9 8
49#define HDMI_VFRMT_1440x240p60_16_9 HDMI_VFRMT_720x240p60_16_9
50#define HDMI_VFRMT_2880x480i60_4_3 9
51#define HDMI_VFRMT_2880x480i60_16_9 10
52#define HDMI_VFRMT_2880x240p60_4_3 11
53#define HDMI_VFRMT_2880x240p60_16_9 12
54#define HDMI_VFRMT_1440x480p60_4_3 13
55#define HDMI_VFRMT_1440x480p60_16_9 14
56#define HDMI_VFRMT_1920x1080p60_16_9 15
57#define HDMI_VFRMT_720x576p50_4_3 16
58#define HDMI_VFRMT_720x576p50_16_9 17
59#define HDMI_VFRMT_1280x720p50_16_9 18
60#define HDMI_VFRMT_1920x1080i50_16_9 19
61#define HDMI_VFRMT_720x576i50_4_3 20
62#define HDMI_VFRMT_1440x576i50_4_3 HDMI_VFRMT_720x576i50_4_3
63#define HDMI_VFRMT_720x576i50_16_9 21
64#define HDMI_VFRMT_1440x576i50_16_9 HDMI_VFRMT_720x576i50_16_9
65#define HDMI_VFRMT_720x288p50_4_3 22
66#define HDMI_VFRMT_1440x288p50_4_3 HDMI_VFRMT_720x288p50_4_3
67#define HDMI_VFRMT_720x288p50_16_9 23
68#define HDMI_VFRMT_1440x288p50_16_9 HDMI_VFRMT_720x288p50_16_9
69#define HDMI_VFRMT_2880x576i50_4_3 24
70#define HDMI_VFRMT_2880x576i50_16_9 25
71#define HDMI_VFRMT_2880x288p50_4_3 26
72#define HDMI_VFRMT_2880x288p50_16_9 27
73#define HDMI_VFRMT_1440x576p50_4_3 28
74#define HDMI_VFRMT_1440x576p50_16_9 29
75#define HDMI_VFRMT_1920x1080p50_16_9 30
76#define HDMI_VFRMT_1920x1080p24_16_9 31
77#define HDMI_VFRMT_1920x1080p25_16_9 32
78#define HDMI_VFRMT_1920x1080p30_16_9 33
79#define HDMI_VFRMT_2880x480p60_4_3 34
80#define HDMI_VFRMT_2880x480p60_16_9 35
81#define HDMI_VFRMT_2880x576p50_4_3 36
82#define HDMI_VFRMT_2880x576p50_16_9 37
83#define HDMI_VFRMT_1920x1250i50_16_9 38
84#define HDMI_VFRMT_1920x1080i100_16_9 39
85#define HDMI_VFRMT_1280x720p100_16_9 40
86#define HDMI_VFRMT_720x576p100_4_3 41
87#define HDMI_VFRMT_720x576p100_16_9 42
88#define HDMI_VFRMT_720x576i100_4_3 43
89#define HDMI_VFRMT_1440x576i100_4_3 HDMI_VFRMT_720x576i100_4_3
90#define HDMI_VFRMT_720x576i100_16_9 44
91#define HDMI_VFRMT_1440x576i100_16_9 HDMI_VFRMT_720x576i100_16_9
92#define HDMI_VFRMT_1920x1080i120_16_9 45
93#define HDMI_VFRMT_1280x720p120_16_9 46
94#define HDMI_VFRMT_720x480p120_4_3 47
95#define HDMI_VFRMT_720x480p120_16_9 48
96#define HDMI_VFRMT_720x480i120_4_3 49
97#define HDMI_VFRMT_1440x480i120_4_3 HDMI_VFRMT_720x480i120_4_3
98#define HDMI_VFRMT_720x480i120_16_9 50
99#define HDMI_VFRMT_1440x480i120_16_9 HDMI_VFRMT_720x480i120_16_9
100#define HDMI_VFRMT_720x576p200_4_3 51
101#define HDMI_VFRMT_720x576p200_16_9 52
102#define HDMI_VFRMT_720x576i200_4_3 53
103#define HDMI_VFRMT_1440x576i200_4_3 HDMI_VFRMT_720x576i200_4_3
104#define HDMI_VFRMT_720x576i200_16_9 54
105#define HDMI_VFRMT_1440x576i200_16_9 HDMI_VFRMT_720x576i200_16_9
106#define HDMI_VFRMT_720x480p240_4_3 55
107#define HDMI_VFRMT_720x480p240_16_9 56
108#define HDMI_VFRMT_720x480i240_4_3 57
109#define HDMI_VFRMT_1440x480i240_4_3 HDMI_VFRMT_720x480i240_4_3
110#define HDMI_VFRMT_720x480i240_16_9 58
111#define HDMI_VFRMT_1440x480i240_16_9 HDMI_VFRMT_720x480i240_16_9
112#define HDMI_VFRMT_MAX 59
113#define HDMI_VFRMT_FORCE_32BIT 0x7FFFFFFF
114
115struct hdmi_disp_mode_timing_type {
116 uint32 video_format;
117 uint32 active_h;
118 uint32 front_porch_h;
119 uint32 pulse_width_h;
120 uint32 back_porch_h;
121 boolean active_low_h;
122 uint32 active_v;
123 uint32 front_porch_v;
124 uint32 pulse_width_v;
125 uint32 back_porch_v;
126 boolean active_low_v;
127 /* Must divide by 1000 to get the actual frequency in MHZ */
128 uint32 pixel_freq;
129 /* Must divide by 1000 to get the actual frequency in HZ */
130 uint32 refresh_rate;
131 boolean interlaced;
132 boolean supported;
133};
134
135#define HDMI_SETTINGS_640x480p60_4_3 \
136 {HDMI_VFRMT_640x480p60_4_3, 640, 16, 96, 48, TRUE, \
137 480, 10, 2, 33, TRUE, 25200, 60000, FALSE, TRUE}
138#define HDMI_SETTINGS_720x480p60_4_3 \
139 {HDMI_VFRMT_720x480p60_4_3, 720, 16, 62, 60, TRUE, \
Aravind Venkateswaranca82bd62012-01-10 15:57:53 -0800140 480, 9, 6, 30, TRUE, 27030, 60000, FALSE, TRUE}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700141#define HDMI_SETTINGS_720x480p60_16_9 \
142 {HDMI_VFRMT_720x480p60_16_9, 720, 16, 62, 60, TRUE, \
Aravind Venkateswaranca82bd62012-01-10 15:57:53 -0800143 480, 9, 6, 30, TRUE, 27030, 60000, FALSE, TRUE}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700144#define HDMI_SETTINGS_1280x720p60_16_9 \
145 {HDMI_VFRMT_1280x720p60_16_9, 1280, 110, 40, 220, FALSE, \
146 720, 5, 5, 20, FALSE, 74250, 60000, FALSE, TRUE}
147#define HDMI_SETTINGS_1920x1080i60_16_9 \
148 {HDMI_VFRMT_1920x1080i60_16_9, 1920, 88, 44, 148, FALSE, \
149 540, 2, 5, 5, FALSE, 74250, 60000, FALSE, TRUE}
150#define HDMI_SETTINGS_1440x480i60_4_3 \
151 {HDMI_VFRMT_1440x480i60_4_3, 1440, 38, 124, 114, TRUE, \
152 240, 4, 3, 15, TRUE, 27000, 60000, TRUE, TRUE}
153#define HDMI_SETTINGS_1440x480i60_16_9 \
154 {HDMI_VFRMT_1440x480i60_16_9, 1440, 38, 124, 114, TRUE, \
155 240, 4, 3, 15, TRUE, 27000, 60000, TRUE, TRUE}
156#define HDMI_SETTINGS_1920x1080p60_16_9 \
157 {HDMI_VFRMT_1920x1080p60_16_9, 1920, 88, 44, 148, FALSE, \
158 1080, 4, 5, 36, FALSE, 148500, 60000, FALSE, TRUE}
159#define HDMI_SETTINGS_720x576p50_4_3 \
160 {HDMI_VFRMT_720x576p50_4_3, 720, 12, 64, 68, TRUE, \
161 576, 5, 5, 39, TRUE, 27000, 50000, FALSE, TRUE}
162#define HDMI_SETTINGS_720x576p50_16_9 \
163 {HDMI_VFRMT_720x576p50_16_9, 720, 12, 64, 68, TRUE, \
164 576, 5, 5, 39, TRUE, 27000, 50000, FALSE, TRUE}
165#define HDMI_SETTINGS_1280x720p50_16_9 \
166 {HDMI_VFRMT_1280x720p50_16_9, 1280, 440, 40, 220, FALSE, \
167 720, 5, 5, 20, FALSE, 74250, 50000, FALSE, TRUE}
168#define HDMI_SETTINGS_1440x576i50_4_3 \
169 {HDMI_VFRMT_1440x576i50_4_3, 1440, 24, 126, 138, TRUE, \
170 288, 2, 3, 19, TRUE, 27000, 50000, TRUE, TRUE}
171#define HDMI_SETTINGS_1440x576i50_16_9 \
172 {HDMI_VFRMT_1440x576i50_16_9, 1440, 24, 126, 138, TRUE, \
173 288, 2, 3, 19, TRUE, 27000, 50000, TRUE, TRUE}
174#define HDMI_SETTINGS_1920x1080p50_16_9 \
175 {HDMI_VFRMT_1920x1080p50_16_9, 1920, 528, 44, 148, FALSE, \
176 1080, 4, 5, 36, FALSE, 148500, 50000, FALSE, TRUE}
177#define HDMI_SETTINGS_1920x1080p24_16_9 \
178 {HDMI_VFRMT_1920x1080p24_16_9, 1920, 638, 44, 148, FALSE, \
179 1080, 4, 5, 36, FALSE, 74250, 24000, FALSE, TRUE}
180#define HDMI_SETTINGS_1920x1080p25_16_9 \
181 {HDMI_VFRMT_1920x1080p25_16_9, 1920, 528, 44, 148, FALSE, \
182 1080, 4, 5, 36, FALSE, 74250, 25000, FALSE, TRUE}
183#define HDMI_SETTINGS_1920x1080p30_16_9 \
184 {HDMI_VFRMT_1920x1080p30_16_9, 1920, 88, 44, 148, FALSE, \
185 1080, 4, 5, 36, FALSE, 74250, 30000, FALSE, TRUE}
186
187/* A lookup table for all the supported display modes by the HDMI
188 * hardware and driver. Use HDMI_SETUP_LUT in the module init to
189 * setup the LUT with the supported modes. */
190extern struct hdmi_disp_mode_timing_type
191 hdmi_common_supported_video_mode_lut[HDMI_VFRMT_MAX];
192
193/* Structure that encapsulates all the supported display modes by the HDMI sink
194 * device */
195struct hdmi_disp_mode_list_type {
196 uint32 disp_mode_list[HDMI_VFRMT_MAX];
197 uint32 num_of_elements;
198};
199#endif
200
201struct external_common_state_type {
202 boolean hpd_state;
203 struct kobject *uevent_kobj;
204 uint32 video_resolution;
205 struct device *dev;
Saurabh Shah79d05a62012-01-09 15:18:33 -0800206 struct switch_dev sdev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700207#ifdef CONFIG_FB_MSM_HDMI_3D
208 boolean format_3d;
209 void (*switch_3d)(boolean on);
210#endif
211#ifdef CONFIG_FB_MSM_HDMI_COMMON
212 boolean hdcp_active;
213 boolean hpd_feature_on;
214 boolean hdmi_sink;
215 struct hdmi_disp_mode_list_type disp_mode_list;
216 uint8 speaker_allocation_block;
217 uint16 video_latency, audio_latency;
218 uint8 audio_data_block_cnt;
219 boolean present_3d;
220 boolean present_hdcp;
221 uint32 audio_data_blocks[16];
222 int (*read_edid_block)(int block, uint8 *edid_buf);
223 int (*hpd_feature)(int on);
224#endif
225};
226
227/* The external interface driver needs to initialize the common state. */
228extern struct external_common_state_type *external_common_state;
229extern struct mutex external_common_state_hpd_mutex;
Manoj Raoa2c27672011-08-30 17:19:39 -0700230extern struct mutex hdmi_msm_state_mutex;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700231
232#ifdef CONFIG_FB_MSM_HDMI_COMMON
233#define VFRMT_NOT_SUPPORTED(VFRMT) \
234 {VFRMT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, FALSE}
235#define HDMI_SETUP_LUT(MODE) do { \
236 struct hdmi_disp_mode_timing_type mode \
237 = HDMI_SETTINGS_ ## MODE; \
238 hdmi_common_supported_video_mode_lut[mode.video_format] \
239 = mode; \
240 } while (0)
241
242int hdmi_common_read_edid(void);
243const char *video_format_2string(uint32 format);
244bool hdmi_common_get_video_format_from_drv_data(struct msm_fb_data_type *mfd);
245const struct hdmi_disp_mode_timing_type *hdmi_common_get_mode(uint32 mode);
246const struct hdmi_disp_mode_timing_type *hdmi_common_get_supported_mode(
247 uint32 mode);
Eugene Yasmand0de5f92011-12-20 13:57:28 +0200248const struct hdmi_disp_mode_timing_type *hdmi_mhl_get_mode(uint32 mode);
249const struct hdmi_disp_mode_timing_type *hdmi_mhl_get_supported_mode(
250 uint32 mode);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700251void hdmi_common_init_panel_info(struct msm_panel_info *pinfo);
252#endif
253
254int external_common_state_create(struct platform_device *pdev);
255void external_common_state_remove(void);
256
257#endif /* __EXTERNAL_COMMON_H__ */