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_infoframe_type {
31 HDMI_INFOFRAME_TYPE_VENDOR = 0x81,
32 HDMI_INFOFRAME_TYPE_AVI = 0x82,
33 HDMI_INFOFRAME_TYPE_SPD = 0x83,
34 HDMI_INFOFRAME_TYPE_AUDIO = 0x84,
37 #define HDMI_IEEE_OUI 0x000c03
38 #define HDMI_INFOFRAME_HEADER_SIZE 4
39 #define HDMI_AVI_INFOFRAME_SIZE 13
40 #define HDMI_SPD_INFOFRAME_SIZE 25
41 #define HDMI_AUDIO_INFOFRAME_SIZE 10
43 #define HDMI_INFOFRAME_SIZE(type) \
44 (HDMI_INFOFRAME_HEADER_SIZE + HDMI_ ## type ## _INFOFRAME_SIZE)
46 struct hdmi_any_infoframe {
47 enum hdmi_infoframe_type type;
48 unsigned char version;
52 enum hdmi_colorspace {
54 HDMI_COLORSPACE_YUV422,
55 HDMI_COLORSPACE_YUV444,
56 HDMI_COLORSPACE_YUV420,
57 HDMI_COLORSPACE_RESERVED4,
58 HDMI_COLORSPACE_RESERVED5,
59 HDMI_COLORSPACE_RESERVED6,
60 HDMI_COLORSPACE_IDO_DEFINED,
65 HDMI_SCAN_MODE_OVERSCAN,
66 HDMI_SCAN_MODE_UNDERSCAN,
67 HDMI_SCAN_MODE_RESERVED,
70 enum hdmi_colorimetry {
71 HDMI_COLORIMETRY_NONE,
72 HDMI_COLORIMETRY_ITU_601,
73 HDMI_COLORIMETRY_ITU_709,
74 HDMI_COLORIMETRY_EXTENDED,
77 enum hdmi_picture_aspect {
78 HDMI_PICTURE_ASPECT_NONE,
79 HDMI_PICTURE_ASPECT_4_3,
80 HDMI_PICTURE_ASPECT_16_9,
81 HDMI_PICTURE_ASPECT_64_27,
82 HDMI_PICTURE_ASPECT_256_135,
83 HDMI_PICTURE_ASPECT_RESERVED,
86 enum hdmi_active_aspect {
87 HDMI_ACTIVE_ASPECT_16_9_TOP = 2,
88 HDMI_ACTIVE_ASPECT_14_9_TOP = 3,
89 HDMI_ACTIVE_ASPECT_16_9_CENTER = 4,
90 HDMI_ACTIVE_ASPECT_PICTURE = 8,
91 HDMI_ACTIVE_ASPECT_4_3 = 9,
92 HDMI_ACTIVE_ASPECT_16_9 = 10,
93 HDMI_ACTIVE_ASPECT_14_9 = 11,
94 HDMI_ACTIVE_ASPECT_4_3_SP_14_9 = 13,
95 HDMI_ACTIVE_ASPECT_16_9_SP_14_9 = 14,
96 HDMI_ACTIVE_ASPECT_16_9_SP_4_3 = 15,
99 enum hdmi_extended_colorimetry {
100 HDMI_EXTENDED_COLORIMETRY_XV_YCC_601,
101 HDMI_EXTENDED_COLORIMETRY_XV_YCC_709,
102 HDMI_EXTENDED_COLORIMETRY_S_YCC_601,
103 HDMI_EXTENDED_COLORIMETRY_ADOBE_YCC_601,
104 HDMI_EXTENDED_COLORIMETRY_ADOBE_RGB,
106 /* The following EC values are only defined in CEA-861-F. */
107 HDMI_EXTENDED_COLORIMETRY_BT2020_CONST_LUM,
108 HDMI_EXTENDED_COLORIMETRY_BT2020,
109 HDMI_EXTENDED_COLORIMETRY_RESERVED,
112 enum hdmi_quantization_range {
113 HDMI_QUANTIZATION_RANGE_DEFAULT,
114 HDMI_QUANTIZATION_RANGE_LIMITED,
115 HDMI_QUANTIZATION_RANGE_FULL,
116 HDMI_QUANTIZATION_RANGE_RESERVED,
119 /* non-uniform picture scaling */
122 HDMI_NUPS_HORIZONTAL,
127 enum hdmi_ycc_quantization_range {
128 HDMI_YCC_QUANTIZATION_RANGE_LIMITED,
129 HDMI_YCC_QUANTIZATION_RANGE_FULL,
132 enum hdmi_content_type {
133 HDMI_CONTENT_TYPE_GRAPHICS,
134 HDMI_CONTENT_TYPE_PHOTO,
135 HDMI_CONTENT_TYPE_CINEMA,
136 HDMI_CONTENT_TYPE_GAME,
139 struct hdmi_avi_infoframe {
140 enum hdmi_infoframe_type type;
141 unsigned char version;
142 unsigned char length;
143 enum hdmi_colorspace colorspace;
144 enum hdmi_scan_mode scan_mode;
145 enum hdmi_colorimetry colorimetry;
146 enum hdmi_picture_aspect picture_aspect;
147 enum hdmi_active_aspect active_aspect;
149 enum hdmi_extended_colorimetry extended_colorimetry;
150 enum hdmi_quantization_range quantization_range;
152 unsigned char video_code;
153 enum hdmi_ycc_quantization_range ycc_quantization_range;
154 enum hdmi_content_type content_type;
155 unsigned char pixel_repeat;
156 unsigned short top_bar;
157 unsigned short bottom_bar;
158 unsigned short left_bar;
159 unsigned short right_bar;
162 int hdmi_avi_infoframe_init(struct hdmi_avi_infoframe *frame);
163 ssize_t hdmi_avi_infoframe_pack(struct hdmi_avi_infoframe *frame, void *buffer,
167 HDMI_SPD_SDI_UNKNOWN,
183 struct hdmi_spd_infoframe {
184 enum hdmi_infoframe_type type;
185 unsigned char version;
186 unsigned char length;
189 enum hdmi_spd_sdi sdi;
192 int hdmi_spd_infoframe_init(struct hdmi_spd_infoframe *frame,
193 const char *vendor, const char *product);
194 ssize_t hdmi_spd_infoframe_pack(struct hdmi_spd_infoframe *frame, void *buffer,
197 enum hdmi_audio_coding_type {
198 HDMI_AUDIO_CODING_TYPE_STREAM,
199 HDMI_AUDIO_CODING_TYPE_PCM,
200 HDMI_AUDIO_CODING_TYPE_AC3,
201 HDMI_AUDIO_CODING_TYPE_MPEG1,
202 HDMI_AUDIO_CODING_TYPE_MP3,
203 HDMI_AUDIO_CODING_TYPE_MPEG2,
204 HDMI_AUDIO_CODING_TYPE_AAC_LC,
205 HDMI_AUDIO_CODING_TYPE_DTS,
206 HDMI_AUDIO_CODING_TYPE_ATRAC,
207 HDMI_AUDIO_CODING_TYPE_DSD,
208 HDMI_AUDIO_CODING_TYPE_EAC3,
209 HDMI_AUDIO_CODING_TYPE_DTS_HD,
210 HDMI_AUDIO_CODING_TYPE_MLP,
211 HDMI_AUDIO_CODING_TYPE_DST,
212 HDMI_AUDIO_CODING_TYPE_WMA_PRO,
213 HDMI_AUDIO_CODING_TYPE_CXT,
216 enum hdmi_audio_sample_size {
217 HDMI_AUDIO_SAMPLE_SIZE_STREAM,
218 HDMI_AUDIO_SAMPLE_SIZE_16,
219 HDMI_AUDIO_SAMPLE_SIZE_20,
220 HDMI_AUDIO_SAMPLE_SIZE_24,
223 enum hdmi_audio_sample_frequency {
224 HDMI_AUDIO_SAMPLE_FREQUENCY_STREAM,
225 HDMI_AUDIO_SAMPLE_FREQUENCY_32000,
226 HDMI_AUDIO_SAMPLE_FREQUENCY_44100,
227 HDMI_AUDIO_SAMPLE_FREQUENCY_48000,
228 HDMI_AUDIO_SAMPLE_FREQUENCY_88200,
229 HDMI_AUDIO_SAMPLE_FREQUENCY_96000,
230 HDMI_AUDIO_SAMPLE_FREQUENCY_176400,
231 HDMI_AUDIO_SAMPLE_FREQUENCY_192000,
234 enum hdmi_audio_coding_type_ext {
235 /* Refer to Audio Coding Type (CT) field in Data Byte 1 */
236 HDMI_AUDIO_CODING_TYPE_EXT_CT,
239 * The next three CXT values are defined in CEA-861-E only.
240 * They do not exist in older versions, and in CEA-861-F they are
241 * defined as 'Not in use'.
243 HDMI_AUDIO_CODING_TYPE_EXT_HE_AAC,
244 HDMI_AUDIO_CODING_TYPE_EXT_HE_AAC_V2,
245 HDMI_AUDIO_CODING_TYPE_EXT_MPEG_SURROUND,
247 /* The following CXT values are only defined in CEA-861-F. */
248 HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_HE_AAC,
249 HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_HE_AAC_V2,
250 HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_AAC_LC,
251 HDMI_AUDIO_CODING_TYPE_EXT_DRA,
252 HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_HE_AAC_SURROUND,
253 HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_AAC_LC_SURROUND = 10,
256 struct hdmi_audio_infoframe {
257 enum hdmi_infoframe_type type;
258 unsigned char version;
259 unsigned char length;
260 unsigned char channels;
261 enum hdmi_audio_coding_type coding_type;
262 enum hdmi_audio_sample_size sample_size;
263 enum hdmi_audio_sample_frequency sample_frequency;
264 enum hdmi_audio_coding_type_ext coding_type_ext;
265 unsigned char channel_allocation;
266 unsigned char level_shift_value;
267 bool downmix_inhibit;
271 int hdmi_audio_infoframe_init(struct hdmi_audio_infoframe *frame);
272 ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame,
273 void *buffer, size_t size);
275 enum hdmi_3d_structure {
276 HDMI_3D_STRUCTURE_INVALID = -1,
277 HDMI_3D_STRUCTURE_FRAME_PACKING = 0,
278 HDMI_3D_STRUCTURE_FIELD_ALTERNATIVE,
279 HDMI_3D_STRUCTURE_LINE_ALTERNATIVE,
280 HDMI_3D_STRUCTURE_SIDE_BY_SIDE_FULL,
281 HDMI_3D_STRUCTURE_L_DEPTH,
282 HDMI_3D_STRUCTURE_L_DEPTH_GFX_GFX_DEPTH,
283 HDMI_3D_STRUCTURE_TOP_AND_BOTTOM,
284 HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF = 8,
288 struct hdmi_vendor_infoframe {
289 enum hdmi_infoframe_type type;
290 unsigned char version;
291 unsigned char length;
294 enum hdmi_3d_structure s3d_struct;
295 unsigned int s3d_ext_data;
298 int hdmi_vendor_infoframe_init(struct hdmi_vendor_infoframe *frame);
299 ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame,
300 void *buffer, size_t size);
302 union hdmi_vendor_any_infoframe {
304 enum hdmi_infoframe_type type;
305 unsigned char version;
306 unsigned char length;
309 struct hdmi_vendor_infoframe hdmi;
313 * union hdmi_infoframe - overall union of all abstract infoframe representations
314 * @any: generic infoframe
315 * @avi: avi infoframe
316 * @spd: spd infoframe
317 * @vendor: union of all vendor infoframes
318 * @audio: audio infoframe
320 * This is used by the generic pack function. This works since all infoframes
321 * have the same header which also indicates which type of infoframe should be
324 union hdmi_infoframe {
325 struct hdmi_any_infoframe any;
326 struct hdmi_avi_infoframe avi;
327 struct hdmi_spd_infoframe spd;
328 union hdmi_vendor_any_infoframe vendor;
329 struct hdmi_audio_infoframe audio;
333 hdmi_infoframe_pack(union hdmi_infoframe *frame, void *buffer, size_t size);
334 int hdmi_infoframe_unpack(union hdmi_infoframe *frame, void *buffer);
335 void hdmi_infoframe_log(const char *level, struct device *dev,
336 union hdmi_infoframe *frame);
338 #endif /* _DRM_HDMI_H */