Thierry Reding | f142d3b | 2012-11-21 15:29:29 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 Avionic Design GmbH |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 as |
| 6 | * published by the Free Software Foundation. |
| 7 | */ |
| 8 | |
| 9 | #ifndef __LINUX_HDMI_H_ |
| 10 | #define __LINUX_HDMI_H_ |
| 11 | |
| 12 | #include <linux/types.h> |
| 13 | |
| 14 | enum hdmi_infoframe_type { |
| 15 | HDMI_INFOFRAME_TYPE_VENDOR = 0x81, |
| 16 | HDMI_INFOFRAME_TYPE_AVI = 0x82, |
| 17 | HDMI_INFOFRAME_TYPE_SPD = 0x83, |
| 18 | HDMI_INFOFRAME_TYPE_AUDIO = 0x84, |
| 19 | }; |
| 20 | |
Lespiau, Damien | 6cb3b7f | 2013-08-19 16:59:05 +0100 | [diff] [blame] | 21 | #define HDMI_IEEE_OUI 0x000c03 |
Thierry Reding | f142d3b | 2012-11-21 15:29:29 +0100 | [diff] [blame] | 22 | #define HDMI_INFOFRAME_HEADER_SIZE 4 |
| 23 | #define HDMI_AVI_INFOFRAME_SIZE 13 |
| 24 | #define HDMI_SPD_INFOFRAME_SIZE 25 |
| 25 | #define HDMI_AUDIO_INFOFRAME_SIZE 10 |
| 26 | |
Damien Lespiau | 61177b0 | 2013-08-06 20:32:15 +0100 | [diff] [blame] | 27 | #define HDMI_INFOFRAME_SIZE(type) \ |
| 28 | (HDMI_INFOFRAME_HEADER_SIZE + HDMI_ ## type ## _INFOFRAME_SIZE) |
| 29 | |
Damien Lespiau | 72b0989 | 2013-08-06 20:32:14 +0100 | [diff] [blame] | 30 | struct hdmi_any_infoframe { |
| 31 | enum hdmi_infoframe_type type; |
| 32 | unsigned char version; |
| 33 | unsigned char length; |
| 34 | }; |
| 35 | |
Thierry Reding | f142d3b | 2012-11-21 15:29:29 +0100 | [diff] [blame] | 36 | enum hdmi_colorspace { |
| 37 | HDMI_COLORSPACE_RGB, |
| 38 | HDMI_COLORSPACE_YUV422, |
| 39 | HDMI_COLORSPACE_YUV444, |
| 40 | }; |
| 41 | |
| 42 | enum hdmi_scan_mode { |
| 43 | HDMI_SCAN_MODE_NONE, |
| 44 | HDMI_SCAN_MODE_OVERSCAN, |
| 45 | HDMI_SCAN_MODE_UNDERSCAN, |
| 46 | }; |
| 47 | |
| 48 | enum hdmi_colorimetry { |
| 49 | HDMI_COLORIMETRY_NONE, |
| 50 | HDMI_COLORIMETRY_ITU_601, |
| 51 | HDMI_COLORIMETRY_ITU_709, |
| 52 | HDMI_COLORIMETRY_EXTENDED, |
| 53 | }; |
| 54 | |
| 55 | enum hdmi_picture_aspect { |
| 56 | HDMI_PICTURE_ASPECT_NONE, |
| 57 | HDMI_PICTURE_ASPECT_4_3, |
| 58 | HDMI_PICTURE_ASPECT_16_9, |
| 59 | }; |
| 60 | |
| 61 | enum hdmi_active_aspect { |
| 62 | HDMI_ACTIVE_ASPECT_16_9_TOP = 2, |
| 63 | HDMI_ACTIVE_ASPECT_14_9_TOP = 3, |
| 64 | HDMI_ACTIVE_ASPECT_16_9_CENTER = 4, |
| 65 | HDMI_ACTIVE_ASPECT_PICTURE = 8, |
| 66 | HDMI_ACTIVE_ASPECT_4_3 = 9, |
| 67 | HDMI_ACTIVE_ASPECT_16_9 = 10, |
| 68 | HDMI_ACTIVE_ASPECT_14_9 = 11, |
| 69 | HDMI_ACTIVE_ASPECT_4_3_SP_14_9 = 13, |
| 70 | HDMI_ACTIVE_ASPECT_16_9_SP_14_9 = 14, |
| 71 | HDMI_ACTIVE_ASPECT_16_9_SP_4_3 = 15, |
| 72 | }; |
| 73 | |
| 74 | enum hdmi_extended_colorimetry { |
| 75 | HDMI_EXTENDED_COLORIMETRY_XV_YCC_601, |
| 76 | HDMI_EXTENDED_COLORIMETRY_XV_YCC_709, |
| 77 | HDMI_EXTENDED_COLORIMETRY_S_YCC_601, |
| 78 | HDMI_EXTENDED_COLORIMETRY_ADOBE_YCC_601, |
| 79 | HDMI_EXTENDED_COLORIMETRY_ADOBE_RGB, |
| 80 | }; |
| 81 | |
| 82 | enum hdmi_quantization_range { |
| 83 | HDMI_QUANTIZATION_RANGE_DEFAULT, |
| 84 | HDMI_QUANTIZATION_RANGE_LIMITED, |
| 85 | HDMI_QUANTIZATION_RANGE_FULL, |
| 86 | }; |
| 87 | |
| 88 | /* non-uniform picture scaling */ |
| 89 | enum hdmi_nups { |
| 90 | HDMI_NUPS_UNKNOWN, |
| 91 | HDMI_NUPS_HORIZONTAL, |
| 92 | HDMI_NUPS_VERTICAL, |
| 93 | HDMI_NUPS_BOTH, |
| 94 | }; |
| 95 | |
| 96 | enum hdmi_ycc_quantization_range { |
| 97 | HDMI_YCC_QUANTIZATION_RANGE_LIMITED, |
| 98 | HDMI_YCC_QUANTIZATION_RANGE_FULL, |
| 99 | }; |
| 100 | |
| 101 | enum hdmi_content_type { |
| 102 | HDMI_CONTENT_TYPE_NONE, |
| 103 | HDMI_CONTENT_TYPE_PHOTO, |
| 104 | HDMI_CONTENT_TYPE_CINEMA, |
| 105 | HDMI_CONTENT_TYPE_GAME, |
| 106 | }; |
| 107 | |
| 108 | struct hdmi_avi_infoframe { |
| 109 | enum hdmi_infoframe_type type; |
| 110 | unsigned char version; |
| 111 | unsigned char length; |
| 112 | enum hdmi_colorspace colorspace; |
Thierry Reding | f142d3b | 2012-11-21 15:29:29 +0100 | [diff] [blame] | 113 | enum hdmi_scan_mode scan_mode; |
| 114 | enum hdmi_colorimetry colorimetry; |
| 115 | enum hdmi_picture_aspect picture_aspect; |
| 116 | enum hdmi_active_aspect active_aspect; |
| 117 | bool itc; |
| 118 | enum hdmi_extended_colorimetry extended_colorimetry; |
| 119 | enum hdmi_quantization_range quantization_range; |
| 120 | enum hdmi_nups nups; |
| 121 | unsigned char video_code; |
| 122 | enum hdmi_ycc_quantization_range ycc_quantization_range; |
| 123 | enum hdmi_content_type content_type; |
| 124 | unsigned char pixel_repeat; |
| 125 | unsigned short top_bar; |
| 126 | unsigned short bottom_bar; |
| 127 | unsigned short left_bar; |
| 128 | unsigned short right_bar; |
| 129 | }; |
| 130 | |
| 131 | int hdmi_avi_infoframe_init(struct hdmi_avi_infoframe *frame); |
| 132 | ssize_t hdmi_avi_infoframe_pack(struct hdmi_avi_infoframe *frame, void *buffer, |
| 133 | size_t size); |
| 134 | |
| 135 | enum hdmi_spd_sdi { |
| 136 | HDMI_SPD_SDI_UNKNOWN, |
| 137 | HDMI_SPD_SDI_DSTB, |
| 138 | HDMI_SPD_SDI_DVDP, |
| 139 | HDMI_SPD_SDI_DVHS, |
| 140 | HDMI_SPD_SDI_HDDVR, |
| 141 | HDMI_SPD_SDI_DVC, |
| 142 | HDMI_SPD_SDI_DSC, |
| 143 | HDMI_SPD_SDI_VCD, |
| 144 | HDMI_SPD_SDI_GAME, |
| 145 | HDMI_SPD_SDI_PC, |
| 146 | HDMI_SPD_SDI_BD, |
| 147 | HDMI_SPD_SDI_SACD, |
| 148 | HDMI_SPD_SDI_HDDVD, |
| 149 | HDMI_SPD_SDI_PMP, |
| 150 | }; |
| 151 | |
| 152 | struct hdmi_spd_infoframe { |
| 153 | enum hdmi_infoframe_type type; |
| 154 | unsigned char version; |
| 155 | unsigned char length; |
| 156 | char vendor[8]; |
| 157 | char product[16]; |
| 158 | enum hdmi_spd_sdi sdi; |
| 159 | }; |
| 160 | |
| 161 | int hdmi_spd_infoframe_init(struct hdmi_spd_infoframe *frame, |
| 162 | const char *vendor, const char *product); |
| 163 | ssize_t hdmi_spd_infoframe_pack(struct hdmi_spd_infoframe *frame, void *buffer, |
| 164 | size_t size); |
| 165 | |
| 166 | enum hdmi_audio_coding_type { |
| 167 | HDMI_AUDIO_CODING_TYPE_STREAM, |
| 168 | HDMI_AUDIO_CODING_TYPE_PCM, |
| 169 | HDMI_AUDIO_CODING_TYPE_AC3, |
| 170 | HDMI_AUDIO_CODING_TYPE_MPEG1, |
| 171 | HDMI_AUDIO_CODING_TYPE_MP3, |
| 172 | HDMI_AUDIO_CODING_TYPE_MPEG2, |
| 173 | HDMI_AUDIO_CODING_TYPE_AAC_LC, |
| 174 | HDMI_AUDIO_CODING_TYPE_DTS, |
| 175 | HDMI_AUDIO_CODING_TYPE_ATRAC, |
| 176 | HDMI_AUDIO_CODING_TYPE_DSD, |
| 177 | HDMI_AUDIO_CODING_TYPE_EAC3, |
| 178 | HDMI_AUDIO_CODING_TYPE_DTS_HD, |
| 179 | HDMI_AUDIO_CODING_TYPE_MLP, |
| 180 | HDMI_AUDIO_CODING_TYPE_DST, |
| 181 | HDMI_AUDIO_CODING_TYPE_WMA_PRO, |
| 182 | }; |
| 183 | |
| 184 | enum hdmi_audio_sample_size { |
| 185 | HDMI_AUDIO_SAMPLE_SIZE_STREAM, |
| 186 | HDMI_AUDIO_SAMPLE_SIZE_16, |
| 187 | HDMI_AUDIO_SAMPLE_SIZE_20, |
| 188 | HDMI_AUDIO_SAMPLE_SIZE_24, |
| 189 | }; |
| 190 | |
| 191 | enum hdmi_audio_sample_frequency { |
| 192 | HDMI_AUDIO_SAMPLE_FREQUENCY_STREAM, |
| 193 | HDMI_AUDIO_SAMPLE_FREQUENCY_32000, |
| 194 | HDMI_AUDIO_SAMPLE_FREQUENCY_44100, |
| 195 | HDMI_AUDIO_SAMPLE_FREQUENCY_48000, |
| 196 | HDMI_AUDIO_SAMPLE_FREQUENCY_88200, |
| 197 | HDMI_AUDIO_SAMPLE_FREQUENCY_96000, |
| 198 | HDMI_AUDIO_SAMPLE_FREQUENCY_176400, |
| 199 | HDMI_AUDIO_SAMPLE_FREQUENCY_192000, |
| 200 | }; |
| 201 | |
| 202 | enum hdmi_audio_coding_type_ext { |
| 203 | HDMI_AUDIO_CODING_TYPE_EXT_STREAM, |
| 204 | HDMI_AUDIO_CODING_TYPE_EXT_HE_AAC, |
| 205 | HDMI_AUDIO_CODING_TYPE_EXT_HE_AAC_V2, |
| 206 | HDMI_AUDIO_CODING_TYPE_EXT_MPEG_SURROUND, |
| 207 | }; |
| 208 | |
| 209 | struct hdmi_audio_infoframe { |
| 210 | enum hdmi_infoframe_type type; |
| 211 | unsigned char version; |
| 212 | unsigned char length; |
| 213 | unsigned char channels; |
| 214 | enum hdmi_audio_coding_type coding_type; |
| 215 | enum hdmi_audio_sample_size sample_size; |
| 216 | enum hdmi_audio_sample_frequency sample_frequency; |
| 217 | enum hdmi_audio_coding_type_ext coding_type_ext; |
| 218 | unsigned char channel_allocation; |
| 219 | unsigned char level_shift_value; |
| 220 | bool downmix_inhibit; |
| 221 | |
| 222 | }; |
| 223 | |
| 224 | int hdmi_audio_infoframe_init(struct hdmi_audio_infoframe *frame); |
| 225 | ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame, |
| 226 | void *buffer, size_t size); |
| 227 | |
Lespiau, Damien | 7d27bec | 2013-08-19 16:58:58 +0100 | [diff] [blame] | 228 | enum hdmi_3d_structure { |
| 229 | HDMI_3D_STRUCTURE_INVALID = -1, |
| 230 | HDMI_3D_STRUCTURE_FRAME_PACKING = 0, |
| 231 | HDMI_3D_STRUCTURE_FIELD_ALTERNATIVE, |
| 232 | HDMI_3D_STRUCTURE_LINE_ALTERNATIVE, |
| 233 | HDMI_3D_STRUCTURE_SIDE_BY_SIDE_FULL, |
| 234 | HDMI_3D_STRUCTURE_L_DEPTH, |
| 235 | HDMI_3D_STRUCTURE_L_DEPTH_GFX_GFX_DEPTH, |
| 236 | HDMI_3D_STRUCTURE_TOP_AND_BOTTOM, |
| 237 | HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF = 8, |
| 238 | }; |
| 239 | |
Lespiau, Damien | ae84b90 | 2013-08-19 16:59:02 +0100 | [diff] [blame] | 240 | |
| 241 | struct hdmi_vendor_infoframe { |
Lespiau, Damien | 7d27bec | 2013-08-19 16:58:58 +0100 | [diff] [blame] | 242 | enum hdmi_infoframe_type type; |
| 243 | unsigned char version; |
| 244 | unsigned char length; |
Lespiau, Damien | af3e95b | 2013-08-19 16:59:01 +0100 | [diff] [blame] | 245 | unsigned int oui; |
Lespiau, Damien | 7d27bec | 2013-08-19 16:58:58 +0100 | [diff] [blame] | 246 | u8 vic; |
| 247 | enum hdmi_3d_structure s3d_struct; |
| 248 | unsigned int s3d_ext_data; |
| 249 | }; |
| 250 | |
Lespiau, Damien | ae84b90 | 2013-08-19 16:59:02 +0100 | [diff] [blame] | 251 | int hdmi_vendor_infoframe_init(struct hdmi_vendor_infoframe *frame); |
| 252 | ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame, |
| 253 | void *buffer, size_t size); |
Lespiau, Damien | 7d27bec | 2013-08-19 16:58:58 +0100 | [diff] [blame] | 254 | |
Lespiau, Damien | ae84b90 | 2013-08-19 16:59:02 +0100 | [diff] [blame] | 255 | union hdmi_vendor_any_infoframe { |
Lespiau, Damien | af3e95b | 2013-08-19 16:59:01 +0100 | [diff] [blame] | 256 | struct { |
| 257 | enum hdmi_infoframe_type type; |
| 258 | unsigned char version; |
| 259 | unsigned char length; |
| 260 | unsigned int oui; |
| 261 | } any; |
Lespiau, Damien | ae84b90 | 2013-08-19 16:59:02 +0100 | [diff] [blame] | 262 | struct hdmi_vendor_infoframe hdmi; |
Lespiau, Damien | af3e95b | 2013-08-19 16:59:01 +0100 | [diff] [blame] | 263 | }; |
| 264 | |
Damien Lespiau | 72b0989 | 2013-08-06 20:32:14 +0100 | [diff] [blame] | 265 | union hdmi_infoframe { |
| 266 | struct hdmi_any_infoframe any; |
| 267 | struct hdmi_avi_infoframe avi; |
| 268 | struct hdmi_spd_infoframe spd; |
Lespiau, Damien | ae84b90 | 2013-08-19 16:59:02 +0100 | [diff] [blame] | 269 | union hdmi_vendor_any_infoframe vendor; |
Damien Lespiau | 72b0989 | 2013-08-06 20:32:14 +0100 | [diff] [blame] | 270 | struct hdmi_audio_infoframe audio; |
| 271 | }; |
| 272 | |
| 273 | ssize_t |
| 274 | hdmi_infoframe_pack(union hdmi_infoframe *frame, void *buffer, size_t size); |
| 275 | |
Thierry Reding | f142d3b | 2012-11-21 15:29:29 +0100 | [diff] [blame] | 276 | #endif /* _DRM_HDMI_H */ |