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 | |
| 21 | #define HDMI_INFOFRAME_HEADER_SIZE 4 |
| 22 | #define HDMI_AVI_INFOFRAME_SIZE 13 |
| 23 | #define HDMI_SPD_INFOFRAME_SIZE 25 |
| 24 | #define HDMI_AUDIO_INFOFRAME_SIZE 10 |
| 25 | |
| 26 | enum hdmi_colorspace { |
| 27 | HDMI_COLORSPACE_RGB, |
| 28 | HDMI_COLORSPACE_YUV422, |
| 29 | HDMI_COLORSPACE_YUV444, |
| 30 | }; |
| 31 | |
| 32 | enum hdmi_scan_mode { |
| 33 | HDMI_SCAN_MODE_NONE, |
| 34 | HDMI_SCAN_MODE_OVERSCAN, |
| 35 | HDMI_SCAN_MODE_UNDERSCAN, |
| 36 | }; |
| 37 | |
| 38 | enum hdmi_colorimetry { |
| 39 | HDMI_COLORIMETRY_NONE, |
| 40 | HDMI_COLORIMETRY_ITU_601, |
| 41 | HDMI_COLORIMETRY_ITU_709, |
| 42 | HDMI_COLORIMETRY_EXTENDED, |
| 43 | }; |
| 44 | |
| 45 | enum hdmi_picture_aspect { |
| 46 | HDMI_PICTURE_ASPECT_NONE, |
| 47 | HDMI_PICTURE_ASPECT_4_3, |
| 48 | HDMI_PICTURE_ASPECT_16_9, |
| 49 | }; |
| 50 | |
| 51 | enum hdmi_active_aspect { |
| 52 | HDMI_ACTIVE_ASPECT_16_9_TOP = 2, |
| 53 | HDMI_ACTIVE_ASPECT_14_9_TOP = 3, |
| 54 | HDMI_ACTIVE_ASPECT_16_9_CENTER = 4, |
| 55 | HDMI_ACTIVE_ASPECT_PICTURE = 8, |
| 56 | HDMI_ACTIVE_ASPECT_4_3 = 9, |
| 57 | HDMI_ACTIVE_ASPECT_16_9 = 10, |
| 58 | HDMI_ACTIVE_ASPECT_14_9 = 11, |
| 59 | HDMI_ACTIVE_ASPECT_4_3_SP_14_9 = 13, |
| 60 | HDMI_ACTIVE_ASPECT_16_9_SP_14_9 = 14, |
| 61 | HDMI_ACTIVE_ASPECT_16_9_SP_4_3 = 15, |
| 62 | }; |
| 63 | |
| 64 | enum hdmi_extended_colorimetry { |
| 65 | HDMI_EXTENDED_COLORIMETRY_XV_YCC_601, |
| 66 | HDMI_EXTENDED_COLORIMETRY_XV_YCC_709, |
| 67 | HDMI_EXTENDED_COLORIMETRY_S_YCC_601, |
| 68 | HDMI_EXTENDED_COLORIMETRY_ADOBE_YCC_601, |
| 69 | HDMI_EXTENDED_COLORIMETRY_ADOBE_RGB, |
| 70 | }; |
| 71 | |
| 72 | enum hdmi_quantization_range { |
| 73 | HDMI_QUANTIZATION_RANGE_DEFAULT, |
| 74 | HDMI_QUANTIZATION_RANGE_LIMITED, |
| 75 | HDMI_QUANTIZATION_RANGE_FULL, |
| 76 | }; |
| 77 | |
| 78 | /* non-uniform picture scaling */ |
| 79 | enum hdmi_nups { |
| 80 | HDMI_NUPS_UNKNOWN, |
| 81 | HDMI_NUPS_HORIZONTAL, |
| 82 | HDMI_NUPS_VERTICAL, |
| 83 | HDMI_NUPS_BOTH, |
| 84 | }; |
| 85 | |
| 86 | enum hdmi_ycc_quantization_range { |
| 87 | HDMI_YCC_QUANTIZATION_RANGE_LIMITED, |
| 88 | HDMI_YCC_QUANTIZATION_RANGE_FULL, |
| 89 | }; |
| 90 | |
| 91 | enum hdmi_content_type { |
| 92 | HDMI_CONTENT_TYPE_NONE, |
| 93 | HDMI_CONTENT_TYPE_PHOTO, |
| 94 | HDMI_CONTENT_TYPE_CINEMA, |
| 95 | HDMI_CONTENT_TYPE_GAME, |
| 96 | }; |
| 97 | |
| 98 | struct hdmi_avi_infoframe { |
| 99 | enum hdmi_infoframe_type type; |
| 100 | unsigned char version; |
| 101 | unsigned char length; |
| 102 | enum hdmi_colorspace colorspace; |
| 103 | bool active_info_valid; |
| 104 | bool horizontal_bar_valid; |
| 105 | bool vertical_bar_valid; |
| 106 | enum hdmi_scan_mode scan_mode; |
| 107 | enum hdmi_colorimetry colorimetry; |
| 108 | enum hdmi_picture_aspect picture_aspect; |
| 109 | enum hdmi_active_aspect active_aspect; |
| 110 | bool itc; |
| 111 | enum hdmi_extended_colorimetry extended_colorimetry; |
| 112 | enum hdmi_quantization_range quantization_range; |
| 113 | enum hdmi_nups nups; |
| 114 | unsigned char video_code; |
| 115 | enum hdmi_ycc_quantization_range ycc_quantization_range; |
| 116 | enum hdmi_content_type content_type; |
| 117 | unsigned char pixel_repeat; |
| 118 | unsigned short top_bar; |
| 119 | unsigned short bottom_bar; |
| 120 | unsigned short left_bar; |
| 121 | unsigned short right_bar; |
| 122 | }; |
| 123 | |
| 124 | int hdmi_avi_infoframe_init(struct hdmi_avi_infoframe *frame); |
| 125 | ssize_t hdmi_avi_infoframe_pack(struct hdmi_avi_infoframe *frame, void *buffer, |
| 126 | size_t size); |
| 127 | |
| 128 | enum hdmi_spd_sdi { |
| 129 | HDMI_SPD_SDI_UNKNOWN, |
| 130 | HDMI_SPD_SDI_DSTB, |
| 131 | HDMI_SPD_SDI_DVDP, |
| 132 | HDMI_SPD_SDI_DVHS, |
| 133 | HDMI_SPD_SDI_HDDVR, |
| 134 | HDMI_SPD_SDI_DVC, |
| 135 | HDMI_SPD_SDI_DSC, |
| 136 | HDMI_SPD_SDI_VCD, |
| 137 | HDMI_SPD_SDI_GAME, |
| 138 | HDMI_SPD_SDI_PC, |
| 139 | HDMI_SPD_SDI_BD, |
| 140 | HDMI_SPD_SDI_SACD, |
| 141 | HDMI_SPD_SDI_HDDVD, |
| 142 | HDMI_SPD_SDI_PMP, |
| 143 | }; |
| 144 | |
| 145 | struct hdmi_spd_infoframe { |
| 146 | enum hdmi_infoframe_type type; |
| 147 | unsigned char version; |
| 148 | unsigned char length; |
| 149 | char vendor[8]; |
| 150 | char product[16]; |
| 151 | enum hdmi_spd_sdi sdi; |
| 152 | }; |
| 153 | |
| 154 | int hdmi_spd_infoframe_init(struct hdmi_spd_infoframe *frame, |
| 155 | const char *vendor, const char *product); |
| 156 | ssize_t hdmi_spd_infoframe_pack(struct hdmi_spd_infoframe *frame, void *buffer, |
| 157 | size_t size); |
| 158 | |
| 159 | enum hdmi_audio_coding_type { |
| 160 | HDMI_AUDIO_CODING_TYPE_STREAM, |
| 161 | HDMI_AUDIO_CODING_TYPE_PCM, |
| 162 | HDMI_AUDIO_CODING_TYPE_AC3, |
| 163 | HDMI_AUDIO_CODING_TYPE_MPEG1, |
| 164 | HDMI_AUDIO_CODING_TYPE_MP3, |
| 165 | HDMI_AUDIO_CODING_TYPE_MPEG2, |
| 166 | HDMI_AUDIO_CODING_TYPE_AAC_LC, |
| 167 | HDMI_AUDIO_CODING_TYPE_DTS, |
| 168 | HDMI_AUDIO_CODING_TYPE_ATRAC, |
| 169 | HDMI_AUDIO_CODING_TYPE_DSD, |
| 170 | HDMI_AUDIO_CODING_TYPE_EAC3, |
| 171 | HDMI_AUDIO_CODING_TYPE_DTS_HD, |
| 172 | HDMI_AUDIO_CODING_TYPE_MLP, |
| 173 | HDMI_AUDIO_CODING_TYPE_DST, |
| 174 | HDMI_AUDIO_CODING_TYPE_WMA_PRO, |
| 175 | }; |
| 176 | |
| 177 | enum hdmi_audio_sample_size { |
| 178 | HDMI_AUDIO_SAMPLE_SIZE_STREAM, |
| 179 | HDMI_AUDIO_SAMPLE_SIZE_16, |
| 180 | HDMI_AUDIO_SAMPLE_SIZE_20, |
| 181 | HDMI_AUDIO_SAMPLE_SIZE_24, |
| 182 | }; |
| 183 | |
| 184 | enum hdmi_audio_sample_frequency { |
| 185 | HDMI_AUDIO_SAMPLE_FREQUENCY_STREAM, |
| 186 | HDMI_AUDIO_SAMPLE_FREQUENCY_32000, |
| 187 | HDMI_AUDIO_SAMPLE_FREQUENCY_44100, |
| 188 | HDMI_AUDIO_SAMPLE_FREQUENCY_48000, |
| 189 | HDMI_AUDIO_SAMPLE_FREQUENCY_88200, |
| 190 | HDMI_AUDIO_SAMPLE_FREQUENCY_96000, |
| 191 | HDMI_AUDIO_SAMPLE_FREQUENCY_176400, |
| 192 | HDMI_AUDIO_SAMPLE_FREQUENCY_192000, |
| 193 | }; |
| 194 | |
| 195 | enum hdmi_audio_coding_type_ext { |
| 196 | HDMI_AUDIO_CODING_TYPE_EXT_STREAM, |
| 197 | HDMI_AUDIO_CODING_TYPE_EXT_HE_AAC, |
| 198 | HDMI_AUDIO_CODING_TYPE_EXT_HE_AAC_V2, |
| 199 | HDMI_AUDIO_CODING_TYPE_EXT_MPEG_SURROUND, |
| 200 | }; |
| 201 | |
| 202 | struct hdmi_audio_infoframe { |
| 203 | enum hdmi_infoframe_type type; |
| 204 | unsigned char version; |
| 205 | unsigned char length; |
| 206 | unsigned char channels; |
| 207 | enum hdmi_audio_coding_type coding_type; |
| 208 | enum hdmi_audio_sample_size sample_size; |
| 209 | enum hdmi_audio_sample_frequency sample_frequency; |
| 210 | enum hdmi_audio_coding_type_ext coding_type_ext; |
| 211 | unsigned char channel_allocation; |
| 212 | unsigned char level_shift_value; |
| 213 | bool downmix_inhibit; |
| 214 | |
| 215 | }; |
| 216 | |
| 217 | int hdmi_audio_infoframe_init(struct hdmi_audio_infoframe *frame); |
| 218 | ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame, |
| 219 | void *buffer, size_t size); |
| 220 | |
| 221 | struct hdmi_vendor_infoframe { |
| 222 | enum hdmi_infoframe_type type; |
| 223 | unsigned char version; |
| 224 | unsigned char length; |
| 225 | u8 data[27]; |
| 226 | }; |
| 227 | |
| 228 | ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame, |
| 229 | void *buffer, size_t size); |
| 230 | |
| 231 | #endif /* _DRM_HDMI_H */ |