blob: e9744202fa292c9f49e926b7534abf6235753db3 [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
Thierry Redingf142d3b2012-11-21 15:29:29 +010038#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
42
Damien Lespiau61177b02013-08-06 20:32:15 +010043#define HDMI_INFOFRAME_SIZE(type) \
44 (HDMI_INFOFRAME_HEADER_SIZE + HDMI_ ## type ## _INFOFRAME_SIZE)
45
Damien Lespiau72b09892013-08-06 20:32:14 +010046struct hdmi_any_infoframe {
47 enum hdmi_infoframe_type type;
48 unsigned char version;
49 unsigned char length;
50};
51
Thierry Redingf142d3b2012-11-21 15:29:29 +010052enum hdmi_colorspace {
53 HDMI_COLORSPACE_RGB,
54 HDMI_COLORSPACE_YUV422,
55 HDMI_COLORSPACE_YUV444,
Hans Verkuil05c80d72014-12-19 09:14:20 -030056 HDMI_COLORSPACE_YUV420,
57 HDMI_COLORSPACE_RESERVED4,
58 HDMI_COLORSPACE_RESERVED5,
59 HDMI_COLORSPACE_RESERVED6,
60 HDMI_COLORSPACE_IDO_DEFINED,
Thierry Redingf142d3b2012-11-21 15:29:29 +010061};
62
63enum hdmi_scan_mode {
64 HDMI_SCAN_MODE_NONE,
65 HDMI_SCAN_MODE_OVERSCAN,
66 HDMI_SCAN_MODE_UNDERSCAN,
Hans Verkuil05c80d72014-12-19 09:14:20 -030067 HDMI_SCAN_MODE_RESERVED,
Thierry Redingf142d3b2012-11-21 15:29:29 +010068};
69
70enum hdmi_colorimetry {
71 HDMI_COLORIMETRY_NONE,
72 HDMI_COLORIMETRY_ITU_601,
73 HDMI_COLORIMETRY_ITU_709,
74 HDMI_COLORIMETRY_EXTENDED,
75};
76
77enum hdmi_picture_aspect {
78 HDMI_PICTURE_ASPECT_NONE,
79 HDMI_PICTURE_ASPECT_4_3,
80 HDMI_PICTURE_ASPECT_16_9,
Hans Verkuil05c80d72014-12-19 09:14:20 -030081 HDMI_PICTURE_ASPECT_RESERVED,
Thierry Redingf142d3b2012-11-21 15:29:29 +010082};
83
84enum hdmi_active_aspect {
85 HDMI_ACTIVE_ASPECT_16_9_TOP = 2,
86 HDMI_ACTIVE_ASPECT_14_9_TOP = 3,
87 HDMI_ACTIVE_ASPECT_16_9_CENTER = 4,
88 HDMI_ACTIVE_ASPECT_PICTURE = 8,
89 HDMI_ACTIVE_ASPECT_4_3 = 9,
90 HDMI_ACTIVE_ASPECT_16_9 = 10,
91 HDMI_ACTIVE_ASPECT_14_9 = 11,
92 HDMI_ACTIVE_ASPECT_4_3_SP_14_9 = 13,
93 HDMI_ACTIVE_ASPECT_16_9_SP_14_9 = 14,
94 HDMI_ACTIVE_ASPECT_16_9_SP_4_3 = 15,
95};
96
97enum hdmi_extended_colorimetry {
98 HDMI_EXTENDED_COLORIMETRY_XV_YCC_601,
99 HDMI_EXTENDED_COLORIMETRY_XV_YCC_709,
100 HDMI_EXTENDED_COLORIMETRY_S_YCC_601,
101 HDMI_EXTENDED_COLORIMETRY_ADOBE_YCC_601,
102 HDMI_EXTENDED_COLORIMETRY_ADOBE_RGB,
Hans Verkuil05c80d72014-12-19 09:14:20 -0300103
104 /* The following EC values are only defined in CEA-861-F. */
105 HDMI_EXTENDED_COLORIMETRY_BT2020_CONST_LUM,
106 HDMI_EXTENDED_COLORIMETRY_BT2020,
107 HDMI_EXTENDED_COLORIMETRY_RESERVED,
Thierry Redingf142d3b2012-11-21 15:29:29 +0100108};
109
110enum hdmi_quantization_range {
111 HDMI_QUANTIZATION_RANGE_DEFAULT,
112 HDMI_QUANTIZATION_RANGE_LIMITED,
113 HDMI_QUANTIZATION_RANGE_FULL,
Hans Verkuil05c80d72014-12-19 09:14:20 -0300114 HDMI_QUANTIZATION_RANGE_RESERVED,
Thierry Redingf142d3b2012-11-21 15:29:29 +0100115};
116
117/* non-uniform picture scaling */
118enum hdmi_nups {
119 HDMI_NUPS_UNKNOWN,
120 HDMI_NUPS_HORIZONTAL,
121 HDMI_NUPS_VERTICAL,
122 HDMI_NUPS_BOTH,
123};
124
125enum hdmi_ycc_quantization_range {
126 HDMI_YCC_QUANTIZATION_RANGE_LIMITED,
127 HDMI_YCC_QUANTIZATION_RANGE_FULL,
128};
129
130enum hdmi_content_type {
Hans Verkuil05c80d72014-12-19 09:14:20 -0300131 HDMI_CONTENT_TYPE_GRAPHICS,
Thierry Redingf142d3b2012-11-21 15:29:29 +0100132 HDMI_CONTENT_TYPE_PHOTO,
133 HDMI_CONTENT_TYPE_CINEMA,
134 HDMI_CONTENT_TYPE_GAME,
135};
136
137struct hdmi_avi_infoframe {
138 enum hdmi_infoframe_type type;
139 unsigned char version;
140 unsigned char length;
141 enum hdmi_colorspace colorspace;
Thierry Redingf142d3b2012-11-21 15:29:29 +0100142 enum hdmi_scan_mode scan_mode;
143 enum hdmi_colorimetry colorimetry;
144 enum hdmi_picture_aspect picture_aspect;
145 enum hdmi_active_aspect active_aspect;
146 bool itc;
147 enum hdmi_extended_colorimetry extended_colorimetry;
148 enum hdmi_quantization_range quantization_range;
149 enum hdmi_nups nups;
150 unsigned char video_code;
151 enum hdmi_ycc_quantization_range ycc_quantization_range;
152 enum hdmi_content_type content_type;
153 unsigned char pixel_repeat;
154 unsigned short top_bar;
155 unsigned short bottom_bar;
156 unsigned short left_bar;
157 unsigned short right_bar;
158};
159
160int hdmi_avi_infoframe_init(struct hdmi_avi_infoframe *frame);
161ssize_t hdmi_avi_infoframe_pack(struct hdmi_avi_infoframe *frame, void *buffer,
162 size_t size);
163
164enum hdmi_spd_sdi {
165 HDMI_SPD_SDI_UNKNOWN,
166 HDMI_SPD_SDI_DSTB,
167 HDMI_SPD_SDI_DVDP,
168 HDMI_SPD_SDI_DVHS,
169 HDMI_SPD_SDI_HDDVR,
170 HDMI_SPD_SDI_DVC,
171 HDMI_SPD_SDI_DSC,
172 HDMI_SPD_SDI_VCD,
173 HDMI_SPD_SDI_GAME,
174 HDMI_SPD_SDI_PC,
175 HDMI_SPD_SDI_BD,
176 HDMI_SPD_SDI_SACD,
177 HDMI_SPD_SDI_HDDVD,
178 HDMI_SPD_SDI_PMP,
179};
180
181struct hdmi_spd_infoframe {
182 enum hdmi_infoframe_type type;
183 unsigned char version;
184 unsigned char length;
185 char vendor[8];
186 char product[16];
187 enum hdmi_spd_sdi sdi;
188};
189
190int hdmi_spd_infoframe_init(struct hdmi_spd_infoframe *frame,
191 const char *vendor, const char *product);
192ssize_t hdmi_spd_infoframe_pack(struct hdmi_spd_infoframe *frame, void *buffer,
193 size_t size);
194
195enum hdmi_audio_coding_type {
196 HDMI_AUDIO_CODING_TYPE_STREAM,
197 HDMI_AUDIO_CODING_TYPE_PCM,
198 HDMI_AUDIO_CODING_TYPE_AC3,
199 HDMI_AUDIO_CODING_TYPE_MPEG1,
200 HDMI_AUDIO_CODING_TYPE_MP3,
201 HDMI_AUDIO_CODING_TYPE_MPEG2,
202 HDMI_AUDIO_CODING_TYPE_AAC_LC,
203 HDMI_AUDIO_CODING_TYPE_DTS,
204 HDMI_AUDIO_CODING_TYPE_ATRAC,
205 HDMI_AUDIO_CODING_TYPE_DSD,
206 HDMI_AUDIO_CODING_TYPE_EAC3,
207 HDMI_AUDIO_CODING_TYPE_DTS_HD,
208 HDMI_AUDIO_CODING_TYPE_MLP,
209 HDMI_AUDIO_CODING_TYPE_DST,
210 HDMI_AUDIO_CODING_TYPE_WMA_PRO,
Hans Verkuil05c80d72014-12-19 09:14:20 -0300211 HDMI_AUDIO_CODING_TYPE_CXT,
Thierry Redingf142d3b2012-11-21 15:29:29 +0100212};
213
214enum hdmi_audio_sample_size {
215 HDMI_AUDIO_SAMPLE_SIZE_STREAM,
216 HDMI_AUDIO_SAMPLE_SIZE_16,
217 HDMI_AUDIO_SAMPLE_SIZE_20,
218 HDMI_AUDIO_SAMPLE_SIZE_24,
219};
220
221enum hdmi_audio_sample_frequency {
222 HDMI_AUDIO_SAMPLE_FREQUENCY_STREAM,
223 HDMI_AUDIO_SAMPLE_FREQUENCY_32000,
224 HDMI_AUDIO_SAMPLE_FREQUENCY_44100,
225 HDMI_AUDIO_SAMPLE_FREQUENCY_48000,
226 HDMI_AUDIO_SAMPLE_FREQUENCY_88200,
227 HDMI_AUDIO_SAMPLE_FREQUENCY_96000,
228 HDMI_AUDIO_SAMPLE_FREQUENCY_176400,
229 HDMI_AUDIO_SAMPLE_FREQUENCY_192000,
230};
231
232enum hdmi_audio_coding_type_ext {
Hans Verkuildc189052014-12-19 09:14:22 -0300233 /* Refer to Audio Coding Type (CT) field in Data Byte 1 */
234 HDMI_AUDIO_CODING_TYPE_EXT_CT,
Hans Verkuil05c80d72014-12-19 09:14:20 -0300235
236 /*
237 * The next three CXT values are defined in CEA-861-E only.
238 * They do not exist in older versions, and in CEA-861-F they are
239 * defined as 'Not in use'.
240 */
Thierry Redingf142d3b2012-11-21 15:29:29 +0100241 HDMI_AUDIO_CODING_TYPE_EXT_HE_AAC,
242 HDMI_AUDIO_CODING_TYPE_EXT_HE_AAC_V2,
243 HDMI_AUDIO_CODING_TYPE_EXT_MPEG_SURROUND,
Hans Verkuil05c80d72014-12-19 09:14:20 -0300244
245 /* The following CXT values are only defined in CEA-861-F. */
246 HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_HE_AAC,
247 HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_HE_AAC_V2,
248 HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_AAC_LC,
249 HDMI_AUDIO_CODING_TYPE_EXT_DRA,
250 HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_HE_AAC_SURROUND,
251 HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_AAC_LC_SURROUND = 10,
Thierry Redingf142d3b2012-11-21 15:29:29 +0100252};
253
254struct hdmi_audio_infoframe {
255 enum hdmi_infoframe_type type;
256 unsigned char version;
257 unsigned char length;
258 unsigned char channels;
259 enum hdmi_audio_coding_type coding_type;
260 enum hdmi_audio_sample_size sample_size;
261 enum hdmi_audio_sample_frequency sample_frequency;
262 enum hdmi_audio_coding_type_ext coding_type_ext;
263 unsigned char channel_allocation;
264 unsigned char level_shift_value;
265 bool downmix_inhibit;
266
267};
268
269int hdmi_audio_infoframe_init(struct hdmi_audio_infoframe *frame);
270ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame,
271 void *buffer, size_t size);
272
Lespiau, Damien7d27bec2013-08-19 16:58:58 +0100273enum hdmi_3d_structure {
274 HDMI_3D_STRUCTURE_INVALID = -1,
275 HDMI_3D_STRUCTURE_FRAME_PACKING = 0,
276 HDMI_3D_STRUCTURE_FIELD_ALTERNATIVE,
277 HDMI_3D_STRUCTURE_LINE_ALTERNATIVE,
278 HDMI_3D_STRUCTURE_SIDE_BY_SIDE_FULL,
279 HDMI_3D_STRUCTURE_L_DEPTH,
280 HDMI_3D_STRUCTURE_L_DEPTH_GFX_GFX_DEPTH,
281 HDMI_3D_STRUCTURE_TOP_AND_BOTTOM,
282 HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF = 8,
283};
284
Lespiau, Damienae84b902013-08-19 16:59:02 +0100285
286struct hdmi_vendor_infoframe {
Lespiau, Damien7d27bec2013-08-19 16:58:58 +0100287 enum hdmi_infoframe_type type;
288 unsigned char version;
289 unsigned char length;
Lespiau, Damienaf3e95b2013-08-19 16:59:01 +0100290 unsigned int oui;
Lespiau, Damien7d27bec2013-08-19 16:58:58 +0100291 u8 vic;
292 enum hdmi_3d_structure s3d_struct;
293 unsigned int s3d_ext_data;
294};
295
Lespiau, Damienae84b902013-08-19 16:59:02 +0100296int hdmi_vendor_infoframe_init(struct hdmi_vendor_infoframe *frame);
297ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame,
298 void *buffer, size_t size);
Lespiau, Damien7d27bec2013-08-19 16:58:58 +0100299
Lespiau, Damienae84b902013-08-19 16:59:02 +0100300union hdmi_vendor_any_infoframe {
Lespiau, Damienaf3e95b2013-08-19 16:59:01 +0100301 struct {
302 enum hdmi_infoframe_type type;
303 unsigned char version;
304 unsigned char length;
305 unsigned int oui;
306 } any;
Lespiau, Damienae84b902013-08-19 16:59:02 +0100307 struct hdmi_vendor_infoframe hdmi;
Lespiau, Damienaf3e95b2013-08-19 16:59:01 +0100308};
309
Daniel Vetter2d123f42014-01-22 18:26:16 +0100310/**
311 * union hdmi_infoframe - overall union of all abstract infoframe representations
312 * @any: generic infoframe
313 * @avi: avi infoframe
314 * @spd: spd infoframe
315 * @vendor: union of all vendor infoframes
316 * @audio: audio infoframe
317 *
318 * This is used by the generic pack function. This works since all infoframes
319 * have the same header which also indicates which type of infoframe should be
320 * packed.
321 */
Damien Lespiau72b09892013-08-06 20:32:14 +0100322union hdmi_infoframe {
323 struct hdmi_any_infoframe any;
324 struct hdmi_avi_infoframe avi;
325 struct hdmi_spd_infoframe spd;
Lespiau, Damienae84b902013-08-19 16:59:02 +0100326 union hdmi_vendor_any_infoframe vendor;
Damien Lespiau72b09892013-08-06 20:32:14 +0100327 struct hdmi_audio_infoframe audio;
328};
329
330ssize_t
331hdmi_infoframe_pack(union hdmi_infoframe *frame, void *buffer, size_t size);
Martin Bugge2c676f32014-12-19 09:14:21 -0300332int hdmi_infoframe_unpack(union hdmi_infoframe *frame, void *buffer);
333void hdmi_infoframe_log(const char *level, struct device *dev,
334 union hdmi_infoframe *frame);
Damien Lespiau72b09892013-08-06 20:32:14 +0100335
Thierry Redingf142d3b2012-11-21 15:29:29 +0100336#endif /* _DRM_HDMI_H */