]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - include/linux/hdmi.h
Merge tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64...
[mirror_ubuntu-bionic-kernel.git] / include / linux / hdmi.h
1 /*
2 * Copyright (C) 2012 Avionic Design GmbH
3 *
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:
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.
22 */
23
24 #ifndef __LINUX_HDMI_H_
25 #define __LINUX_HDMI_H_
26
27 #include <linux/types.h>
28 #include <linux/device.h>
29
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,
35 };
36
37 #define HDMI_IEEE_OUI 0x000c03
38 #define HDMI_FORUM_IEEE_OUI 0xc45dd8
39 #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
44 #define HDMI_INFOFRAME_SIZE(type) \
45 (HDMI_INFOFRAME_HEADER_SIZE + HDMI_ ## type ## _INFOFRAME_SIZE)
46
47 struct hdmi_any_infoframe {
48 enum hdmi_infoframe_type type;
49 unsigned char version;
50 unsigned char length;
51 };
52
53 enum hdmi_colorspace {
54 HDMI_COLORSPACE_RGB,
55 HDMI_COLORSPACE_YUV422,
56 HDMI_COLORSPACE_YUV444,
57 HDMI_COLORSPACE_YUV420,
58 HDMI_COLORSPACE_RESERVED4,
59 HDMI_COLORSPACE_RESERVED5,
60 HDMI_COLORSPACE_RESERVED6,
61 HDMI_COLORSPACE_IDO_DEFINED,
62 };
63
64 enum hdmi_scan_mode {
65 HDMI_SCAN_MODE_NONE,
66 HDMI_SCAN_MODE_OVERSCAN,
67 HDMI_SCAN_MODE_UNDERSCAN,
68 HDMI_SCAN_MODE_RESERVED,
69 };
70
71 enum hdmi_colorimetry {
72 HDMI_COLORIMETRY_NONE,
73 HDMI_COLORIMETRY_ITU_601,
74 HDMI_COLORIMETRY_ITU_709,
75 HDMI_COLORIMETRY_EXTENDED,
76 };
77
78 enum hdmi_picture_aspect {
79 HDMI_PICTURE_ASPECT_NONE,
80 HDMI_PICTURE_ASPECT_4_3,
81 HDMI_PICTURE_ASPECT_16_9,
82 HDMI_PICTURE_ASPECT_64_27,
83 HDMI_PICTURE_ASPECT_256_135,
84 HDMI_PICTURE_ASPECT_RESERVED,
85 };
86
87 enum 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
100 enum 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,
106
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,
111 };
112
113 enum hdmi_quantization_range {
114 HDMI_QUANTIZATION_RANGE_DEFAULT,
115 HDMI_QUANTIZATION_RANGE_LIMITED,
116 HDMI_QUANTIZATION_RANGE_FULL,
117 HDMI_QUANTIZATION_RANGE_RESERVED,
118 };
119
120 /* non-uniform picture scaling */
121 enum hdmi_nups {
122 HDMI_NUPS_UNKNOWN,
123 HDMI_NUPS_HORIZONTAL,
124 HDMI_NUPS_VERTICAL,
125 HDMI_NUPS_BOTH,
126 };
127
128 enum hdmi_ycc_quantization_range {
129 HDMI_YCC_QUANTIZATION_RANGE_LIMITED,
130 HDMI_YCC_QUANTIZATION_RANGE_FULL,
131 };
132
133 enum hdmi_content_type {
134 HDMI_CONTENT_TYPE_GRAPHICS,
135 HDMI_CONTENT_TYPE_PHOTO,
136 HDMI_CONTENT_TYPE_CINEMA,
137 HDMI_CONTENT_TYPE_GAME,
138 };
139
140 struct hdmi_avi_infoframe {
141 enum hdmi_infoframe_type type;
142 unsigned char version;
143 unsigned char length;
144 enum hdmi_colorspace colorspace;
145 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
163 int hdmi_avi_infoframe_init(struct hdmi_avi_infoframe *frame);
164 ssize_t hdmi_avi_infoframe_pack(struct hdmi_avi_infoframe *frame, void *buffer,
165 size_t size);
166
167 enum 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
184 struct 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
193 int hdmi_spd_infoframe_init(struct hdmi_spd_infoframe *frame,
194 const char *vendor, const char *product);
195 ssize_t hdmi_spd_infoframe_pack(struct hdmi_spd_infoframe *frame, void *buffer,
196 size_t size);
197
198 enum 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,
214 HDMI_AUDIO_CODING_TYPE_CXT,
215 };
216
217 enum 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
224 enum 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
235 enum hdmi_audio_coding_type_ext {
236 /* Refer to Audio Coding Type (CT) field in Data Byte 1 */
237 HDMI_AUDIO_CODING_TYPE_EXT_CT,
238
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 */
244 HDMI_AUDIO_CODING_TYPE_EXT_HE_AAC,
245 HDMI_AUDIO_CODING_TYPE_EXT_HE_AAC_V2,
246 HDMI_AUDIO_CODING_TYPE_EXT_MPEG_SURROUND,
247
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,
255 };
256
257 struct 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
272 int hdmi_audio_infoframe_init(struct hdmi_audio_infoframe *frame);
273 ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame,
274 void *buffer, size_t size);
275
276 enum 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
288
289 struct hdmi_vendor_infoframe {
290 enum hdmi_infoframe_type type;
291 unsigned char version;
292 unsigned char length;
293 unsigned int oui;
294 u8 vic;
295 enum hdmi_3d_structure s3d_struct;
296 unsigned int s3d_ext_data;
297 };
298
299 int hdmi_vendor_infoframe_init(struct hdmi_vendor_infoframe *frame);
300 ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame,
301 void *buffer, size_t size);
302
303 union hdmi_vendor_any_infoframe {
304 struct {
305 enum hdmi_infoframe_type type;
306 unsigned char version;
307 unsigned char length;
308 unsigned int oui;
309 } any;
310 struct hdmi_vendor_infoframe hdmi;
311 };
312
313 /**
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 */
325 union hdmi_infoframe {
326 struct hdmi_any_infoframe any;
327 struct hdmi_avi_infoframe avi;
328 struct hdmi_spd_infoframe spd;
329 union hdmi_vendor_any_infoframe vendor;
330 struct hdmi_audio_infoframe audio;
331 };
332
333 ssize_t
334 hdmi_infoframe_pack(union hdmi_infoframe *frame, void *buffer, size_t size);
335 int hdmi_infoframe_unpack(union hdmi_infoframe *frame, void *buffer);
336 void hdmi_infoframe_log(const char *level, struct device *dev,
337 union hdmi_infoframe *frame);
338
339 #endif /* _DRM_HDMI_H */