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