blob: bc38b99a9fc9615955749af1ad644ec293313e8c [file] [log] [blame]
Thierry Redingf142d3b2012-11-21 15:29:29 +01001/*
2 * Copyright (C) 2012 Avionic Design GmbH
3 *
Thierry Reding37d74572014-10-08 11:14:34 +02004 * 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:
10 *
11 * The above copyright notice and this permission notice (including the
12 * next paragraph) shall be included in all copies or substantial portions
13 * of the Software.
14 *
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.
Thierry Redingf142d3b2012-11-21 15:29:29 +010022 */
23
24#ifndef __LINUX_HDMI_H_
25#define __LINUX_HDMI_H_
26
27#include <linux/types.h>
Martin Bugge2c676f32014-12-19 09:14:21 -030028#include <linux/device.h>
Thierry Redingf142d3b2012-11-21 15:29:29 +010029
30enum 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,
35};
36
Lespiau, Damien6cb3b7f2013-08-19 16:59:05 +010037#define HDMI_IEEE_OUI 0x000c03
Padmanabhan Komandurucb3b9c02017-05-03 13:21:54 -070038#define HDMI_IEEE_OUI_HF 0xc45dd8
Thierry Redingf142d3b2012-11-21 15:29:29 +010039#define HDMI_INFOFRAME_HEADER_SIZE 4
40#define HDMI_AVI_INFOFRAME_SIZE 13
41#define HDMI_SPD_INFOFRAME_SIZE 25
42#define HDMI_AUDIO_INFOFRAME_SIZE 10
43
Damien Lespiau61177b02013-08-06 20:32:15 +010044#define HDMI_INFOFRAME_SIZE(type) \
45 (HDMI_INFOFRAME_HEADER_SIZE + HDMI_ ## type ## _INFOFRAME_SIZE)
46
Damien Lespiau72b09892013-08-06 20:32:14 +010047struct hdmi_any_infoframe {
48 enum hdmi_infoframe_type type;
49 unsigned char version;
50 unsigned char length;
51};
52
Thierry Redingf142d3b2012-11-21 15:29:29 +010053enum hdmi_colorspace {
54 HDMI_COLORSPACE_RGB,
55 HDMI_COLORSPACE_YUV422,
56 HDMI_COLORSPACE_YUV444,
Hans Verkuil05c80d72014-12-19 09:14:20 -030057 HDMI_COLORSPACE_YUV420,
58 HDMI_COLORSPACE_RESERVED4,
59 HDMI_COLORSPACE_RESERVED5,
60 HDMI_COLORSPACE_RESERVED6,
61 HDMI_COLORSPACE_IDO_DEFINED,
Thierry Redingf142d3b2012-11-21 15:29:29 +010062};
63
64enum hdmi_scan_mode {
65 HDMI_SCAN_MODE_NONE,
66 HDMI_SCAN_MODE_OVERSCAN,
67 HDMI_SCAN_MODE_UNDERSCAN,
Hans Verkuil05c80d72014-12-19 09:14:20 -030068 HDMI_SCAN_MODE_RESERVED,
Thierry Redingf142d3b2012-11-21 15:29:29 +010069};
70
71enum hdmi_colorimetry {
72 HDMI_COLORIMETRY_NONE,
73 HDMI_COLORIMETRY_ITU_601,
74 HDMI_COLORIMETRY_ITU_709,
75 HDMI_COLORIMETRY_EXTENDED,
76};
77
78enum hdmi_picture_aspect {
79 HDMI_PICTURE_ASPECT_NONE,
80 HDMI_PICTURE_ASPECT_4_3,
81 HDMI_PICTURE_ASPECT_16_9,
Shashank Sharmab3528352016-10-17 17:34:39 +053082 HDMI_PICTURE_ASPECT_64_27,
83 HDMI_PICTURE_ASPECT_256_135,
Hans Verkuil05c80d72014-12-19 09:14:20 -030084 HDMI_PICTURE_ASPECT_RESERVED,
Thierry Redingf142d3b2012-11-21 15:29:29 +010085};
86
87enum hdmi_active_aspect {
88 HDMI_ACTIVE_ASPECT_16_9_TOP = 2,
89 HDMI_ACTIVE_ASPECT_14_9_TOP = 3,
90 HDMI_ACTIVE_ASPECT_16_9_CENTER = 4,
91 HDMI_ACTIVE_ASPECT_PICTURE = 8,
92 HDMI_ACTIVE_ASPECT_4_3 = 9,
93 HDMI_ACTIVE_ASPECT_16_9 = 10,
94 HDMI_ACTIVE_ASPECT_14_9 = 11,
95 HDMI_ACTIVE_ASPECT_4_3_SP_14_9 = 13,
96 HDMI_ACTIVE_ASPECT_16_9_SP_14_9 = 14,
97 HDMI_ACTIVE_ASPECT_16_9_SP_4_3 = 15,
98};
99
100enum hdmi_extended_colorimetry {
101 HDMI_EXTENDED_COLORIMETRY_XV_YCC_601,
102 HDMI_EXTENDED_COLORIMETRY_XV_YCC_709,
103 HDMI_EXTENDED_COLORIMETRY_S_YCC_601,
104 HDMI_EXTENDED_COLORIMETRY_ADOBE_YCC_601,
105 HDMI_EXTENDED_COLORIMETRY_ADOBE_RGB,
Hans Verkuil05c80d72014-12-19 09:14:20 -0300106
107 /* The following EC values are only defined in CEA-861-F. */
108 HDMI_EXTENDED_COLORIMETRY_BT2020_CONST_LUM,
109 HDMI_EXTENDED_COLORIMETRY_BT2020,
110 HDMI_EXTENDED_COLORIMETRY_RESERVED,
Thierry Redingf142d3b2012-11-21 15:29:29 +0100111};
112
113enum hdmi_quantization_range {
114 HDMI_QUANTIZATION_RANGE_DEFAULT,
115 HDMI_QUANTIZATION_RANGE_LIMITED,
116 HDMI_QUANTIZATION_RANGE_FULL,
Hans Verkuil05c80d72014-12-19 09:14:20 -0300117 HDMI_QUANTIZATION_RANGE_RESERVED,
Thierry Redingf142d3b2012-11-21 15:29:29 +0100118};
119
120/* non-uniform picture scaling */
121enum hdmi_nups {
122 HDMI_NUPS_UNKNOWN,
123 HDMI_NUPS_HORIZONTAL,
124 HDMI_NUPS_VERTICAL,
125 HDMI_NUPS_BOTH,
126};
127
128enum hdmi_ycc_quantization_range {
129 HDMI_YCC_QUANTIZATION_RANGE_LIMITED,
130 HDMI_YCC_QUANTIZATION_RANGE_FULL,
131};
132
133enum hdmi_content_type {
Hans Verkuil05c80d72014-12-19 09:14:20 -0300134 HDMI_CONTENT_TYPE_GRAPHICS,
Thierry Redingf142d3b2012-11-21 15:29:29 +0100135 HDMI_CONTENT_TYPE_PHOTO,
136 HDMI_CONTENT_TYPE_CINEMA,
137 HDMI_CONTENT_TYPE_GAME,
138};
139
140struct hdmi_avi_infoframe {
141 enum hdmi_infoframe_type type;
142 unsigned char version;
143 unsigned char length;
144 enum hdmi_colorspace colorspace;
Thierry Redingf142d3b2012-11-21 15:29:29 +0100145 enum hdmi_scan_mode scan_mode;
146 enum hdmi_colorimetry colorimetry;
147 enum hdmi_picture_aspect picture_aspect;
148 enum hdmi_active_aspect active_aspect;
149 bool itc;
150 enum hdmi_extended_colorimetry extended_colorimetry;
151 enum hdmi_quantization_range quantization_range;
152 enum hdmi_nups nups;
153 unsigned char video_code;
154 enum hdmi_ycc_quantization_range ycc_quantization_range;
155 enum hdmi_content_type content_type;
156 unsigned char pixel_repeat;
157 unsigned short top_bar;
158 unsigned short bottom_bar;
159 unsigned short left_bar;
160 unsigned short right_bar;
161};
162
163int hdmi_avi_infoframe_init(struct hdmi_avi_infoframe *frame);
164ssize_t hdmi_avi_infoframe_pack(struct hdmi_avi_infoframe *frame, void *buffer,
165 size_t size);
166
167enum hdmi_spd_sdi {
168 HDMI_SPD_SDI_UNKNOWN,
169 HDMI_SPD_SDI_DSTB,
170 HDMI_SPD_SDI_DVDP,
171 HDMI_SPD_SDI_DVHS,
172 HDMI_SPD_SDI_HDDVR,
173 HDMI_SPD_SDI_DVC,
174 HDMI_SPD_SDI_DSC,
175 HDMI_SPD_SDI_VCD,
176 HDMI_SPD_SDI_GAME,
177 HDMI_SPD_SDI_PC,
178 HDMI_SPD_SDI_BD,
179 HDMI_SPD_SDI_SACD,
180 HDMI_SPD_SDI_HDDVD,
181 HDMI_SPD_SDI_PMP,
182};
183
184struct hdmi_spd_infoframe {
185 enum hdmi_infoframe_type type;
186 unsigned char version;
187 unsigned char length;
188 char vendor[8];
189 char product[16];
190 enum hdmi_spd_sdi sdi;
191};
192
193int hdmi_spd_infoframe_init(struct hdmi_spd_infoframe *frame,
194 const char *vendor, const char *product);
195ssize_t hdmi_spd_infoframe_pack(struct hdmi_spd_infoframe *frame, void *buffer,
196 size_t size);
197
198enum hdmi_audio_coding_type {
199 HDMI_AUDIO_CODING_TYPE_STREAM,
200 HDMI_AUDIO_CODING_TYPE_PCM,
201 HDMI_AUDIO_CODING_TYPE_AC3,
202 HDMI_AUDIO_CODING_TYPE_MPEG1,
203 HDMI_AUDIO_CODING_TYPE_MP3,
204 HDMI_AUDIO_CODING_TYPE_MPEG2,
205 HDMI_AUDIO_CODING_TYPE_AAC_LC,
206 HDMI_AUDIO_CODING_TYPE_DTS,
207 HDMI_AUDIO_CODING_TYPE_ATRAC,
208 HDMI_AUDIO_CODING_TYPE_DSD,
209 HDMI_AUDIO_CODING_TYPE_EAC3,
210 HDMI_AUDIO_CODING_TYPE_DTS_HD,
211 HDMI_AUDIO_CODING_TYPE_MLP,
212 HDMI_AUDIO_CODING_TYPE_DST,
213 HDMI_AUDIO_CODING_TYPE_WMA_PRO,
Hans Verkuil05c80d72014-12-19 09:14:20 -0300214 HDMI_AUDIO_CODING_TYPE_CXT,
Thierry Redingf142d3b2012-11-21 15:29:29 +0100215};
216
217enum hdmi_audio_sample_size {
218 HDMI_AUDIO_SAMPLE_SIZE_STREAM,
219 HDMI_AUDIO_SAMPLE_SIZE_16,
220 HDMI_AUDIO_SAMPLE_SIZE_20,
221 HDMI_AUDIO_SAMPLE_SIZE_24,
222};
223
224enum hdmi_audio_sample_frequency {
225 HDMI_AUDIO_SAMPLE_FREQUENCY_STREAM,
226 HDMI_AUDIO_SAMPLE_FREQUENCY_32000,
227 HDMI_AUDIO_SAMPLE_FREQUENCY_44100,
228 HDMI_AUDIO_SAMPLE_FREQUENCY_48000,
229 HDMI_AUDIO_SAMPLE_FREQUENCY_88200,
230 HDMI_AUDIO_SAMPLE_FREQUENCY_96000,
231 HDMI_AUDIO_SAMPLE_FREQUENCY_176400,
232 HDMI_AUDIO_SAMPLE_FREQUENCY_192000,
233};
234
235enum hdmi_audio_coding_type_ext {
Hans Verkuildc189052014-12-19 09:14:22 -0300236 /* Refer to Audio Coding Type (CT) field in Data Byte 1 */
237 HDMI_AUDIO_CODING_TYPE_EXT_CT,
Hans Verkuil05c80d72014-12-19 09:14:20 -0300238
239 /*
240 * The next three CXT values are defined in CEA-861-E only.
241 * They do not exist in older versions, and in CEA-861-F they are
242 * defined as 'Not in use'.
243 */
Thierry Redingf142d3b2012-11-21 15:29:29 +0100244 HDMI_AUDIO_CODING_TYPE_EXT_HE_AAC,
245 HDMI_AUDIO_CODING_TYPE_EXT_HE_AAC_V2,
246 HDMI_AUDIO_CODING_TYPE_EXT_MPEG_SURROUND,
Hans Verkuil05c80d72014-12-19 09:14:20 -0300247
248 /* The following CXT values are only defined in CEA-861-F. */
249 HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_HE_AAC,
250 HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_HE_AAC_V2,
251 HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_AAC_LC,
252 HDMI_AUDIO_CODING_TYPE_EXT_DRA,
253 HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_HE_AAC_SURROUND,
254 HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_AAC_LC_SURROUND = 10,
Thierry Redingf142d3b2012-11-21 15:29:29 +0100255};
256
257struct hdmi_audio_infoframe {
258 enum hdmi_infoframe_type type;
259 unsigned char version;
260 unsigned char length;
261 unsigned char channels;
262 enum hdmi_audio_coding_type coding_type;
263 enum hdmi_audio_sample_size sample_size;
264 enum hdmi_audio_sample_frequency sample_frequency;
265 enum hdmi_audio_coding_type_ext coding_type_ext;
266 unsigned char channel_allocation;
267 unsigned char level_shift_value;
268 bool downmix_inhibit;
269
270};
271
272int hdmi_audio_infoframe_init(struct hdmi_audio_infoframe *frame);
273ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame,
274 void *buffer, size_t size);
275
Lespiau, Damien7d27bec2013-08-19 16:58:58 +0100276enum hdmi_3d_structure {
277 HDMI_3D_STRUCTURE_INVALID = -1,
278 HDMI_3D_STRUCTURE_FRAME_PACKING = 0,
279 HDMI_3D_STRUCTURE_FIELD_ALTERNATIVE,
280 HDMI_3D_STRUCTURE_LINE_ALTERNATIVE,
281 HDMI_3D_STRUCTURE_SIDE_BY_SIDE_FULL,
282 HDMI_3D_STRUCTURE_L_DEPTH,
283 HDMI_3D_STRUCTURE_L_DEPTH_GFX_GFX_DEPTH,
284 HDMI_3D_STRUCTURE_TOP_AND_BOTTOM,
285 HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF = 8,
286};
287
Lespiau, Damienae84b902013-08-19 16:59:02 +0100288
289struct hdmi_vendor_infoframe {
Lespiau, Damien7d27bec2013-08-19 16:58:58 +0100290 enum hdmi_infoframe_type type;
291 unsigned char version;
292 unsigned char length;
Lespiau, Damienaf3e95b2013-08-19 16:59:01 +0100293 unsigned int oui;
Lespiau, Damien7d27bec2013-08-19 16:58:58 +0100294 u8 vic;
295 enum hdmi_3d_structure s3d_struct;
296 unsigned int s3d_ext_data;
297};
298
Lespiau, Damienae84b902013-08-19 16:59:02 +0100299int hdmi_vendor_infoframe_init(struct hdmi_vendor_infoframe *frame);
300ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame,
301 void *buffer, size_t size);
Lespiau, Damien7d27bec2013-08-19 16:58:58 +0100302
Lespiau, Damienae84b902013-08-19 16:59:02 +0100303union hdmi_vendor_any_infoframe {
Lespiau, Damienaf3e95b2013-08-19 16:59:01 +0100304 struct {
305 enum hdmi_infoframe_type type;
306 unsigned char version;
307 unsigned char length;
308 unsigned int oui;
309 } any;
Lespiau, Damienae84b902013-08-19 16:59:02 +0100310 struct hdmi_vendor_infoframe hdmi;
Lespiau, Damienaf3e95b2013-08-19 16:59:01 +0100311};
312
Daniel Vetter2d123f42014-01-22 18:26:16 +0100313/**
314 * union hdmi_infoframe - overall union of all abstract infoframe representations
315 * @any: generic infoframe
316 * @avi: avi infoframe
317 * @spd: spd infoframe
318 * @vendor: union of all vendor infoframes
319 * @audio: audio infoframe
320 *
321 * This is used by the generic pack function. This works since all infoframes
322 * have the same header which also indicates which type of infoframe should be
323 * packed.
324 */
Damien Lespiau72b09892013-08-06 20:32:14 +0100325union hdmi_infoframe {
326 struct hdmi_any_infoframe any;
327 struct hdmi_avi_infoframe avi;
328 struct hdmi_spd_infoframe spd;
Lespiau, Damienae84b902013-08-19 16:59:02 +0100329 union hdmi_vendor_any_infoframe vendor;
Damien Lespiau72b09892013-08-06 20:32:14 +0100330 struct hdmi_audio_infoframe audio;
331};
332
333ssize_t
334hdmi_infoframe_pack(union hdmi_infoframe *frame, void *buffer, size_t size);
Martin Bugge2c676f32014-12-19 09:14:21 -0300335int hdmi_infoframe_unpack(union hdmi_infoframe *frame, void *buffer);
336void hdmi_infoframe_log(const char *level, struct device *dev,
337 union hdmi_infoframe *frame);
Damien Lespiau72b09892013-08-06 20:32:14 +0100338
Thierry Redingf142d3b2012-11-21 15:29:29 +0100339#endif /* _DRM_HDMI_H */