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.
29 enum hdmi_infoframe_type {
30 HDMI_INFOFRAME_TYPE_VENDOR = 0x81,
31 HDMI_INFOFRAME_TYPE_AVI = 0x82,
32 HDMI_INFOFRAME_TYPE_SPD = 0x83,
33 HDMI_INFOFRAME_TYPE_AUDIO = 0x84,
36 #define HDMI_IEEE_OUI 0x000c03
37 #define HDMI_INFOFRAME_HEADER_SIZE 4
38 #define HDMI_AVI_INFOFRAME_SIZE 13
39 #define HDMI_SPD_INFOFRAME_SIZE 25
40 #define HDMI_AUDIO_INFOFRAME_SIZE 10
42 #define HDMI_INFOFRAME_SIZE(type) \
43 (HDMI_INFOFRAME_HEADER_SIZE + HDMI_ ## type ## _INFOFRAME_SIZE)
45 struct hdmi_any_infoframe {
46 enum hdmi_infoframe_type type;
47 unsigned char version;
51 enum hdmi_colorspace {
53 HDMI_COLORSPACE_YUV422,
54 HDMI_COLORSPACE_YUV444,
55 HDMI_COLORSPACE_YUV420,
56 HDMI_COLORSPACE_RESERVED4,
57 HDMI_COLORSPACE_RESERVED5,
58 HDMI_COLORSPACE_RESERVED6,
59 HDMI_COLORSPACE_IDO_DEFINED,
64 HDMI_SCAN_MODE_OVERSCAN,
65 HDMI_SCAN_MODE_UNDERSCAN,
66 HDMI_SCAN_MODE_RESERVED,
69 enum hdmi_colorimetry {
70 HDMI_COLORIMETRY_NONE,
71 HDMI_COLORIMETRY_ITU_601,
72 HDMI_COLORIMETRY_ITU_709,
73 HDMI_COLORIMETRY_EXTENDED,
76 enum hdmi_picture_aspect {
77 HDMI_PICTURE_ASPECT_NONE,
78 HDMI_PICTURE_ASPECT_4_3,
79 HDMI_PICTURE_ASPECT_16_9,
80 HDMI_PICTURE_ASPECT_RESERVED,
83 enum hdmi_active_aspect {
84 HDMI_ACTIVE_ASPECT_16_9_TOP = 2,
85 HDMI_ACTIVE_ASPECT_14_9_TOP = 3,
86 HDMI_ACTIVE_ASPECT_16_9_CENTER = 4,
87 HDMI_ACTIVE_ASPECT_PICTURE = 8,
88 HDMI_ACTIVE_ASPECT_4_3 = 9,
89 HDMI_ACTIVE_ASPECT_16_9 = 10,
90 HDMI_ACTIVE_ASPECT_14_9 = 11,
91 HDMI_ACTIVE_ASPECT_4_3_SP_14_9 = 13,
92 HDMI_ACTIVE_ASPECT_16_9_SP_14_9 = 14,
93 HDMI_ACTIVE_ASPECT_16_9_SP_4_3 = 15,
96 enum hdmi_extended_colorimetry {
97 HDMI_EXTENDED_COLORIMETRY_XV_YCC_601,
98 HDMI_EXTENDED_COLORIMETRY_XV_YCC_709,
99 HDMI_EXTENDED_COLORIMETRY_S_YCC_601,
100 HDMI_EXTENDED_COLORIMETRY_ADOBE_YCC_601,
101 HDMI_EXTENDED_COLORIMETRY_ADOBE_RGB,
103 /* The following EC values are only defined in CEA-861-F. */
104 HDMI_EXTENDED_COLORIMETRY_BT2020_CONST_LUM,
105 HDMI_EXTENDED_COLORIMETRY_BT2020,
106 HDMI_EXTENDED_COLORIMETRY_RESERVED,
109 enum hdmi_quantization_range {
110 HDMI_QUANTIZATION_RANGE_DEFAULT,
111 HDMI_QUANTIZATION_RANGE_LIMITED,
112 HDMI_QUANTIZATION_RANGE_FULL,
113 HDMI_QUANTIZATION_RANGE_RESERVED,
116 /* non-uniform picture scaling */
119 HDMI_NUPS_HORIZONTAL,
124 enum hdmi_ycc_quantization_range {
125 HDMI_YCC_QUANTIZATION_RANGE_LIMITED,
126 HDMI_YCC_QUANTIZATION_RANGE_FULL,
129 enum hdmi_content_type {
130 HDMI_CONTENT_TYPE_GRAPHICS,
131 HDMI_CONTENT_TYPE_PHOTO,
132 HDMI_CONTENT_TYPE_CINEMA,
133 HDMI_CONTENT_TYPE_GAME,
136 struct hdmi_avi_infoframe {
137 enum hdmi_infoframe_type type;
138 unsigned char version;
139 unsigned char length;
140 enum hdmi_colorspace colorspace;
141 enum hdmi_scan_mode scan_mode;
142 enum hdmi_colorimetry colorimetry;
143 enum hdmi_picture_aspect picture_aspect;
144 enum hdmi_active_aspect active_aspect;
146 enum hdmi_extended_colorimetry extended_colorimetry;
147 enum hdmi_quantization_range quantization_range;
149 unsigned char video_code;
150 enum hdmi_ycc_quantization_range ycc_quantization_range;
151 enum hdmi_content_type content_type;
152 unsigned char pixel_repeat;
153 unsigned short top_bar;
154 unsigned short bottom_bar;
155 unsigned short left_bar;
156 unsigned short right_bar;
159 int hdmi_avi_infoframe_init(struct hdmi_avi_infoframe *frame);
160 ssize_t hdmi_avi_infoframe_pack(struct hdmi_avi_infoframe *frame, void *buffer,
164 HDMI_SPD_SDI_UNKNOWN,
180 struct hdmi_spd_infoframe {
181 enum hdmi_infoframe_type type;
182 unsigned char version;
183 unsigned char length;
186 enum hdmi_spd_sdi sdi;
189 int hdmi_spd_infoframe_init(struct hdmi_spd_infoframe *frame,
190 const char *vendor, const char *product);
191 ssize_t hdmi_spd_infoframe_pack(struct hdmi_spd_infoframe *frame, void *buffer,
194 enum hdmi_audio_coding_type {
195 HDMI_AUDIO_CODING_TYPE_STREAM,
196 HDMI_AUDIO_CODING_TYPE_PCM,
197 HDMI_AUDIO_CODING_TYPE_AC3,
198 HDMI_AUDIO_CODING_TYPE_MPEG1,
199 HDMI_AUDIO_CODING_TYPE_MP3,
200 HDMI_AUDIO_CODING_TYPE_MPEG2,
201 HDMI_AUDIO_CODING_TYPE_AAC_LC,
202 HDMI_AUDIO_CODING_TYPE_DTS,
203 HDMI_AUDIO_CODING_TYPE_ATRAC,
204 HDMI_AUDIO_CODING_TYPE_DSD,
205 HDMI_AUDIO_CODING_TYPE_EAC3,
206 HDMI_AUDIO_CODING_TYPE_DTS_HD,
207 HDMI_AUDIO_CODING_TYPE_MLP,
208 HDMI_AUDIO_CODING_TYPE_DST,
209 HDMI_AUDIO_CODING_TYPE_WMA_PRO,
210 HDMI_AUDIO_CODING_TYPE_CXT,
213 enum hdmi_audio_sample_size {
214 HDMI_AUDIO_SAMPLE_SIZE_STREAM,
215 HDMI_AUDIO_SAMPLE_SIZE_16,
216 HDMI_AUDIO_SAMPLE_SIZE_20,
217 HDMI_AUDIO_SAMPLE_SIZE_24,
220 enum hdmi_audio_sample_frequency {
221 HDMI_AUDIO_SAMPLE_FREQUENCY_STREAM,
222 HDMI_AUDIO_SAMPLE_FREQUENCY_32000,
223 HDMI_AUDIO_SAMPLE_FREQUENCY_44100,
224 HDMI_AUDIO_SAMPLE_FREQUENCY_48000,
225 HDMI_AUDIO_SAMPLE_FREQUENCY_88200,
226 HDMI_AUDIO_SAMPLE_FREQUENCY_96000,
227 HDMI_AUDIO_SAMPLE_FREQUENCY_176400,
228 HDMI_AUDIO_SAMPLE_FREQUENCY_192000,
231 enum hdmi_audio_coding_type_ext {
232 /* Refer to Audio Coding Type (CT) field in Data Byte 1 */
233 HDMI_AUDIO_CODING_TYPE_EXT_CT,
236 * The next three CXT values are defined in CEA-861-E only.
237 * They do not exist in older versions, and in CEA-861-F they are
238 * defined as 'Not in use'.
240 HDMI_AUDIO_CODING_TYPE_EXT_HE_AAC,
241 HDMI_AUDIO_CODING_TYPE_EXT_HE_AAC_V2,
242 HDMI_AUDIO_CODING_TYPE_EXT_MPEG_SURROUND,
244 /* The following CXT values are only defined in CEA-861-F. */
245 HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_HE_AAC,
246 HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_HE_AAC_V2,
247 HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_AAC_LC,
248 HDMI_AUDIO_CODING_TYPE_EXT_DRA,
249 HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_HE_AAC_SURROUND,
250 HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_AAC_LC_SURROUND = 10,
253 struct hdmi_audio_infoframe {
254 enum hdmi_infoframe_type type;
255 unsigned char version;
256 unsigned char length;
257 unsigned char channels;
258 enum hdmi_audio_coding_type coding_type;
259 enum hdmi_audio_sample_size sample_size;
260 enum hdmi_audio_sample_frequency sample_frequency;
261 enum hdmi_audio_coding_type_ext coding_type_ext;
262 unsigned char channel_allocation;
263 unsigned char level_shift_value;
264 bool downmix_inhibit;
268 int hdmi_audio_infoframe_init(struct hdmi_audio_infoframe *frame);
269 ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame,
270 void *buffer, size_t size);
272 enum hdmi_3d_structure {
273 HDMI_3D_STRUCTURE_INVALID = -1,
274 HDMI_3D_STRUCTURE_FRAME_PACKING = 0,
275 HDMI_3D_STRUCTURE_FIELD_ALTERNATIVE,
276 HDMI_3D_STRUCTURE_LINE_ALTERNATIVE,
277 HDMI_3D_STRUCTURE_SIDE_BY_SIDE_FULL,
278 HDMI_3D_STRUCTURE_L_DEPTH,
279 HDMI_3D_STRUCTURE_L_DEPTH_GFX_GFX_DEPTH,
280 HDMI_3D_STRUCTURE_TOP_AND_BOTTOM,
281 HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF = 8,
284 struct hdmi_vendor_infoframe {
285 enum hdmi_infoframe_type type;
286 unsigned char version;
287 unsigned char length;
290 enum hdmi_3d_structure s3d_struct;
291 unsigned int s3d_ext_data;
294 int hdmi_vendor_infoframe_init(struct hdmi_vendor_infoframe *frame);
295 ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame,
296 void *buffer, size_t size);
298 union hdmi_vendor_any_infoframe {
300 enum hdmi_infoframe_type type;
301 unsigned char version;
302 unsigned char length;
305 struct hdmi_vendor_infoframe hdmi;
309 * union hdmi_infoframe - overall union of all abstract infoframe representations
310 * @any: generic infoframe
311 * @avi: avi infoframe
312 * @spd: spd infoframe
313 * @vendor: union of all vendor infoframes
314 * @audio: audio infoframe
316 * This is used by the generic pack function. This works since all infoframes
317 * have the same header which also indicates which type of infoframe should be
320 union hdmi_infoframe {
321 struct hdmi_any_infoframe any;
322 struct hdmi_avi_infoframe avi;
323 struct hdmi_spd_infoframe spd;
324 union hdmi_vendor_any_infoframe vendor;
325 struct hdmi_audio_infoframe audio;
329 hdmi_infoframe_pack(union hdmi_infoframe *frame, void *buffer, size_t size);
330 int hdmi_infoframe_unpack(union hdmi_infoframe *frame, void *buffer);
331 void hdmi_infoframe_log(union hdmi_infoframe *frame);