2 * Copyright (C) 2012 Avionic Design GmbH
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sub license,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the
12 * next paragraph) shall be included in all copies or substantial portions
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
24 #ifndef __LINUX_HDMI_H_
25 #define __LINUX_HDMI_H_
27 #include <linux/types.h>
28 #include <linux/device.h>
30 enum hdmi_packet_type
{
31 HDMI_PACKET_TYPE_NULL
= 0x00,
32 HDMI_PACKET_TYPE_AUDIO_CLOCK_REGEN
= 0x01,
33 HDMI_PACKET_TYPE_AUDIO_SAMPLE
= 0x02,
34 HDMI_PACKET_TYPE_GENERAL_CONTROL
= 0x03,
35 HDMI_PACKET_TYPE_ACP
= 0x04,
36 HDMI_PACKET_TYPE_ISRC1
= 0x05,
37 HDMI_PACKET_TYPE_ISRC2
= 0x06,
38 HDMI_PACKET_TYPE_ONE_BIT_AUDIO_SAMPLE
= 0x07,
39 HDMI_PACKET_TYPE_DST_AUDIO
= 0x08,
40 HDMI_PACKET_TYPE_HBR_AUDIO_STREAM
= 0x09,
41 HDMI_PACKET_TYPE_GAMUT_METADATA
= 0x0a,
42 /* + enum hdmi_infoframe_type */
45 enum hdmi_infoframe_type
{
46 HDMI_INFOFRAME_TYPE_VENDOR
= 0x81,
47 HDMI_INFOFRAME_TYPE_AVI
= 0x82,
48 HDMI_INFOFRAME_TYPE_SPD
= 0x83,
49 HDMI_INFOFRAME_TYPE_AUDIO
= 0x84,
52 #define HDMI_IEEE_OUI 0x000c03
53 #define HDMI_FORUM_IEEE_OUI 0xc45dd8
54 #define HDMI_INFOFRAME_HEADER_SIZE 4
55 #define HDMI_AVI_INFOFRAME_SIZE 13
56 #define HDMI_SPD_INFOFRAME_SIZE 25
57 #define HDMI_AUDIO_INFOFRAME_SIZE 10
59 #define HDMI_INFOFRAME_SIZE(type) \
60 (HDMI_INFOFRAME_HEADER_SIZE + HDMI_ ## type ## _INFOFRAME_SIZE)
62 struct hdmi_any_infoframe
{
63 enum hdmi_infoframe_type type
;
64 unsigned char version
;
68 enum hdmi_colorspace
{
70 HDMI_COLORSPACE_YUV422
,
71 HDMI_COLORSPACE_YUV444
,
72 HDMI_COLORSPACE_YUV420
,
73 HDMI_COLORSPACE_RESERVED4
,
74 HDMI_COLORSPACE_RESERVED5
,
75 HDMI_COLORSPACE_RESERVED6
,
76 HDMI_COLORSPACE_IDO_DEFINED
,
81 HDMI_SCAN_MODE_OVERSCAN
,
82 HDMI_SCAN_MODE_UNDERSCAN
,
83 HDMI_SCAN_MODE_RESERVED
,
86 enum hdmi_colorimetry
{
87 HDMI_COLORIMETRY_NONE
,
88 HDMI_COLORIMETRY_ITU_601
,
89 HDMI_COLORIMETRY_ITU_709
,
90 HDMI_COLORIMETRY_EXTENDED
,
93 enum hdmi_picture_aspect
{
94 HDMI_PICTURE_ASPECT_NONE
,
95 HDMI_PICTURE_ASPECT_4_3
,
96 HDMI_PICTURE_ASPECT_16_9
,
97 HDMI_PICTURE_ASPECT_64_27
,
98 HDMI_PICTURE_ASPECT_256_135
,
99 HDMI_PICTURE_ASPECT_RESERVED
,
102 enum hdmi_active_aspect
{
103 HDMI_ACTIVE_ASPECT_16_9_TOP
= 2,
104 HDMI_ACTIVE_ASPECT_14_9_TOP
= 3,
105 HDMI_ACTIVE_ASPECT_16_9_CENTER
= 4,
106 HDMI_ACTIVE_ASPECT_PICTURE
= 8,
107 HDMI_ACTIVE_ASPECT_4_3
= 9,
108 HDMI_ACTIVE_ASPECT_16_9
= 10,
109 HDMI_ACTIVE_ASPECT_14_9
= 11,
110 HDMI_ACTIVE_ASPECT_4_3_SP_14_9
= 13,
111 HDMI_ACTIVE_ASPECT_16_9_SP_14_9
= 14,
112 HDMI_ACTIVE_ASPECT_16_9_SP_4_3
= 15,
115 enum hdmi_extended_colorimetry
{
116 HDMI_EXTENDED_COLORIMETRY_XV_YCC_601
,
117 HDMI_EXTENDED_COLORIMETRY_XV_YCC_709
,
118 HDMI_EXTENDED_COLORIMETRY_S_YCC_601
,
119 HDMI_EXTENDED_COLORIMETRY_OPYCC_601
,
120 HDMI_EXTENDED_COLORIMETRY_OPRGB
,
122 /* The following EC values are only defined in CEA-861-F. */
123 HDMI_EXTENDED_COLORIMETRY_BT2020_CONST_LUM
,
124 HDMI_EXTENDED_COLORIMETRY_BT2020
,
125 HDMI_EXTENDED_COLORIMETRY_RESERVED
,
128 enum hdmi_quantization_range
{
129 HDMI_QUANTIZATION_RANGE_DEFAULT
,
130 HDMI_QUANTIZATION_RANGE_LIMITED
,
131 HDMI_QUANTIZATION_RANGE_FULL
,
132 HDMI_QUANTIZATION_RANGE_RESERVED
,
135 /* non-uniform picture scaling */
138 HDMI_NUPS_HORIZONTAL
,
143 enum hdmi_ycc_quantization_range
{
144 HDMI_YCC_QUANTIZATION_RANGE_LIMITED
,
145 HDMI_YCC_QUANTIZATION_RANGE_FULL
,
148 enum hdmi_content_type
{
149 HDMI_CONTENT_TYPE_GRAPHICS
,
150 HDMI_CONTENT_TYPE_PHOTO
,
151 HDMI_CONTENT_TYPE_CINEMA
,
152 HDMI_CONTENT_TYPE_GAME
,
155 struct hdmi_avi_infoframe
{
156 enum hdmi_infoframe_type type
;
157 unsigned char version
;
158 unsigned char length
;
159 enum hdmi_colorspace colorspace
;
160 enum hdmi_scan_mode scan_mode
;
161 enum hdmi_colorimetry colorimetry
;
162 enum hdmi_picture_aspect picture_aspect
;
163 enum hdmi_active_aspect active_aspect
;
165 enum hdmi_extended_colorimetry extended_colorimetry
;
166 enum hdmi_quantization_range quantization_range
;
168 unsigned char video_code
;
169 enum hdmi_ycc_quantization_range ycc_quantization_range
;
170 enum hdmi_content_type content_type
;
171 unsigned char pixel_repeat
;
172 unsigned short top_bar
;
173 unsigned short bottom_bar
;
174 unsigned short left_bar
;
175 unsigned short right_bar
;
178 int hdmi_avi_infoframe_init(struct hdmi_avi_infoframe
*frame
);
179 ssize_t
hdmi_avi_infoframe_pack(struct hdmi_avi_infoframe
*frame
, void *buffer
,
181 ssize_t
hdmi_avi_infoframe_pack_only(const struct hdmi_avi_infoframe
*frame
,
182 void *buffer
, size_t size
);
183 int hdmi_avi_infoframe_check(struct hdmi_avi_infoframe
*frame
);
186 HDMI_SPD_SDI_UNKNOWN
,
202 struct hdmi_spd_infoframe
{
203 enum hdmi_infoframe_type type
;
204 unsigned char version
;
205 unsigned char length
;
208 enum hdmi_spd_sdi sdi
;
211 int hdmi_spd_infoframe_init(struct hdmi_spd_infoframe
*frame
,
212 const char *vendor
, const char *product
);
213 ssize_t
hdmi_spd_infoframe_pack(struct hdmi_spd_infoframe
*frame
, void *buffer
,
215 ssize_t
hdmi_spd_infoframe_pack_only(const struct hdmi_spd_infoframe
*frame
,
216 void *buffer
, size_t size
);
217 int hdmi_spd_infoframe_check(struct hdmi_spd_infoframe
*frame
);
219 enum hdmi_audio_coding_type
{
220 HDMI_AUDIO_CODING_TYPE_STREAM
,
221 HDMI_AUDIO_CODING_TYPE_PCM
,
222 HDMI_AUDIO_CODING_TYPE_AC3
,
223 HDMI_AUDIO_CODING_TYPE_MPEG1
,
224 HDMI_AUDIO_CODING_TYPE_MP3
,
225 HDMI_AUDIO_CODING_TYPE_MPEG2
,
226 HDMI_AUDIO_CODING_TYPE_AAC_LC
,
227 HDMI_AUDIO_CODING_TYPE_DTS
,
228 HDMI_AUDIO_CODING_TYPE_ATRAC
,
229 HDMI_AUDIO_CODING_TYPE_DSD
,
230 HDMI_AUDIO_CODING_TYPE_EAC3
,
231 HDMI_AUDIO_CODING_TYPE_DTS_HD
,
232 HDMI_AUDIO_CODING_TYPE_MLP
,
233 HDMI_AUDIO_CODING_TYPE_DST
,
234 HDMI_AUDIO_CODING_TYPE_WMA_PRO
,
235 HDMI_AUDIO_CODING_TYPE_CXT
,
238 enum hdmi_audio_sample_size
{
239 HDMI_AUDIO_SAMPLE_SIZE_STREAM
,
240 HDMI_AUDIO_SAMPLE_SIZE_16
,
241 HDMI_AUDIO_SAMPLE_SIZE_20
,
242 HDMI_AUDIO_SAMPLE_SIZE_24
,
245 enum hdmi_audio_sample_frequency
{
246 HDMI_AUDIO_SAMPLE_FREQUENCY_STREAM
,
247 HDMI_AUDIO_SAMPLE_FREQUENCY_32000
,
248 HDMI_AUDIO_SAMPLE_FREQUENCY_44100
,
249 HDMI_AUDIO_SAMPLE_FREQUENCY_48000
,
250 HDMI_AUDIO_SAMPLE_FREQUENCY_88200
,
251 HDMI_AUDIO_SAMPLE_FREQUENCY_96000
,
252 HDMI_AUDIO_SAMPLE_FREQUENCY_176400
,
253 HDMI_AUDIO_SAMPLE_FREQUENCY_192000
,
256 enum hdmi_audio_coding_type_ext
{
257 /* Refer to Audio Coding Type (CT) field in Data Byte 1 */
258 HDMI_AUDIO_CODING_TYPE_EXT_CT
,
261 * The next three CXT values are defined in CEA-861-E only.
262 * They do not exist in older versions, and in CEA-861-F they are
263 * defined as 'Not in use'.
265 HDMI_AUDIO_CODING_TYPE_EXT_HE_AAC
,
266 HDMI_AUDIO_CODING_TYPE_EXT_HE_AAC_V2
,
267 HDMI_AUDIO_CODING_TYPE_EXT_MPEG_SURROUND
,
269 /* The following CXT values are only defined in CEA-861-F. */
270 HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_HE_AAC
,
271 HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_HE_AAC_V2
,
272 HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_AAC_LC
,
273 HDMI_AUDIO_CODING_TYPE_EXT_DRA
,
274 HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_HE_AAC_SURROUND
,
275 HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_AAC_LC_SURROUND
= 10,
278 struct hdmi_audio_infoframe
{
279 enum hdmi_infoframe_type type
;
280 unsigned char version
;
281 unsigned char length
;
282 unsigned char channels
;
283 enum hdmi_audio_coding_type coding_type
;
284 enum hdmi_audio_sample_size sample_size
;
285 enum hdmi_audio_sample_frequency sample_frequency
;
286 enum hdmi_audio_coding_type_ext coding_type_ext
;
287 unsigned char channel_allocation
;
288 unsigned char level_shift_value
;
289 bool downmix_inhibit
;
293 int hdmi_audio_infoframe_init(struct hdmi_audio_infoframe
*frame
);
294 ssize_t
hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe
*frame
,
295 void *buffer
, size_t size
);
296 ssize_t
hdmi_audio_infoframe_pack_only(const struct hdmi_audio_infoframe
*frame
,
297 void *buffer
, size_t size
);
298 int hdmi_audio_infoframe_check(struct hdmi_audio_infoframe
*frame
);
300 enum hdmi_3d_structure
{
301 HDMI_3D_STRUCTURE_INVALID
= -1,
302 HDMI_3D_STRUCTURE_FRAME_PACKING
= 0,
303 HDMI_3D_STRUCTURE_FIELD_ALTERNATIVE
,
304 HDMI_3D_STRUCTURE_LINE_ALTERNATIVE
,
305 HDMI_3D_STRUCTURE_SIDE_BY_SIDE_FULL
,
306 HDMI_3D_STRUCTURE_L_DEPTH
,
307 HDMI_3D_STRUCTURE_L_DEPTH_GFX_GFX_DEPTH
,
308 HDMI_3D_STRUCTURE_TOP_AND_BOTTOM
,
309 HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF
= 8,
313 struct hdmi_vendor_infoframe
{
314 enum hdmi_infoframe_type type
;
315 unsigned char version
;
316 unsigned char length
;
319 enum hdmi_3d_structure s3d_struct
;
320 unsigned int s3d_ext_data
;
323 int hdmi_vendor_infoframe_init(struct hdmi_vendor_infoframe
*frame
);
324 ssize_t
hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe
*frame
,
325 void *buffer
, size_t size
);
326 ssize_t
hdmi_vendor_infoframe_pack_only(const struct hdmi_vendor_infoframe
*frame
,
327 void *buffer
, size_t size
);
328 int hdmi_vendor_infoframe_check(struct hdmi_vendor_infoframe
*frame
);
330 union hdmi_vendor_any_infoframe
{
332 enum hdmi_infoframe_type type
;
333 unsigned char version
;
334 unsigned char length
;
337 struct hdmi_vendor_infoframe hdmi
;
341 * union hdmi_infoframe - overall union of all abstract infoframe representations
342 * @any: generic infoframe
343 * @avi: avi infoframe
344 * @spd: spd infoframe
345 * @vendor: union of all vendor infoframes
346 * @audio: audio infoframe
348 * This is used by the generic pack function. This works since all infoframes
349 * have the same header which also indicates which type of infoframe should be
352 union hdmi_infoframe
{
353 struct hdmi_any_infoframe any
;
354 struct hdmi_avi_infoframe avi
;
355 struct hdmi_spd_infoframe spd
;
356 union hdmi_vendor_any_infoframe vendor
;
357 struct hdmi_audio_infoframe audio
;
360 ssize_t
hdmi_infoframe_pack(union hdmi_infoframe
*frame
, void *buffer
,
362 ssize_t
hdmi_infoframe_pack_only(const union hdmi_infoframe
*frame
,
363 void *buffer
, size_t size
);
364 int hdmi_infoframe_check(union hdmi_infoframe
*frame
);
365 int hdmi_infoframe_unpack(union hdmi_infoframe
*frame
,
366 const void *buffer
, size_t size
);
367 void hdmi_infoframe_log(const char *level
, struct device
*dev
,
368 const union hdmi_infoframe
*frame
);
370 #endif /* _DRM_HDMI_H */