1f1d7ae31SEmmanuel Vadot /* 2f1d7ae31SEmmanuel Vadot * Copyright (C) 2012 Avionic Design GmbH 3f1d7ae31SEmmanuel Vadot * 4f1d7ae31SEmmanuel Vadot * Permission is hereby granted, free of charge, to any person obtaining a 5f1d7ae31SEmmanuel Vadot * copy of this software and associated documentation files (the "Software"), 6f1d7ae31SEmmanuel Vadot * to deal in the Software without restriction, including without limitation 7f1d7ae31SEmmanuel Vadot * the rights to use, copy, modify, merge, publish, distribute, sub license, 8f1d7ae31SEmmanuel Vadot * and/or sell copies of the Software, and to permit persons to whom the 9f1d7ae31SEmmanuel Vadot * Software is furnished to do so, subject to the following conditions: 10f1d7ae31SEmmanuel Vadot * 11f1d7ae31SEmmanuel Vadot * The above copyright notice and this permission notice (including the 12f1d7ae31SEmmanuel Vadot * next paragraph) shall be included in all copies or substantial portions 13f1d7ae31SEmmanuel Vadot * of the Software. 14f1d7ae31SEmmanuel Vadot * 15f1d7ae31SEmmanuel Vadot * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16f1d7ae31SEmmanuel Vadot * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17f1d7ae31SEmmanuel Vadot * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 18f1d7ae31SEmmanuel Vadot * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19f1d7ae31SEmmanuel Vadot * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20f1d7ae31SEmmanuel Vadot * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21f1d7ae31SEmmanuel Vadot * DEALINGS IN THE SOFTWARE. 22f1d7ae31SEmmanuel Vadot */ 23f1d7ae31SEmmanuel Vadot 24f1d7ae31SEmmanuel Vadot #ifndef __LINUX_HDMI_H_ 25f1d7ae31SEmmanuel Vadot #define __LINUX_HDMI_H_ 26f1d7ae31SEmmanuel Vadot 27f1d7ae31SEmmanuel Vadot #include <linux/types.h> 28f1d7ae31SEmmanuel Vadot #include <linux/device.h> 29f1d7ae31SEmmanuel Vadot 30f1d7ae31SEmmanuel Vadot enum hdmi_packet_type { 31f1d7ae31SEmmanuel Vadot HDMI_PACKET_TYPE_NULL = 0x00, 32f1d7ae31SEmmanuel Vadot HDMI_PACKET_TYPE_AUDIO_CLOCK_REGEN = 0x01, 33f1d7ae31SEmmanuel Vadot HDMI_PACKET_TYPE_AUDIO_SAMPLE = 0x02, 34f1d7ae31SEmmanuel Vadot HDMI_PACKET_TYPE_GENERAL_CONTROL = 0x03, 35f1d7ae31SEmmanuel Vadot HDMI_PACKET_TYPE_ACP = 0x04, 36f1d7ae31SEmmanuel Vadot HDMI_PACKET_TYPE_ISRC1 = 0x05, 37f1d7ae31SEmmanuel Vadot HDMI_PACKET_TYPE_ISRC2 = 0x06, 38f1d7ae31SEmmanuel Vadot HDMI_PACKET_TYPE_ONE_BIT_AUDIO_SAMPLE = 0x07, 39f1d7ae31SEmmanuel Vadot HDMI_PACKET_TYPE_DST_AUDIO = 0x08, 40f1d7ae31SEmmanuel Vadot HDMI_PACKET_TYPE_HBR_AUDIO_STREAM = 0x09, 41f1d7ae31SEmmanuel Vadot HDMI_PACKET_TYPE_GAMUT_METADATA = 0x0a, 42f1d7ae31SEmmanuel Vadot /* + enum hdmi_infoframe_type */ 43f1d7ae31SEmmanuel Vadot }; 44f1d7ae31SEmmanuel Vadot 45f1d7ae31SEmmanuel Vadot enum hdmi_infoframe_type { 46f1d7ae31SEmmanuel Vadot HDMI_INFOFRAME_TYPE_VENDOR = 0x81, 47f1d7ae31SEmmanuel Vadot HDMI_INFOFRAME_TYPE_AVI = 0x82, 48f1d7ae31SEmmanuel Vadot HDMI_INFOFRAME_TYPE_SPD = 0x83, 49f1d7ae31SEmmanuel Vadot HDMI_INFOFRAME_TYPE_AUDIO = 0x84, 50f1d7ae31SEmmanuel Vadot HDMI_INFOFRAME_TYPE_DRM = 0x87, 51f1d7ae31SEmmanuel Vadot }; 52f1d7ae31SEmmanuel Vadot 53f1d7ae31SEmmanuel Vadot #define HDMI_IEEE_OUI 0x000c03 54f1d7ae31SEmmanuel Vadot #define HDMI_FORUM_IEEE_OUI 0xc45dd8 55f1d7ae31SEmmanuel Vadot #define HDMI_INFOFRAME_HEADER_SIZE 4 56f1d7ae31SEmmanuel Vadot #define HDMI_AVI_INFOFRAME_SIZE 13 57f1d7ae31SEmmanuel Vadot #define HDMI_SPD_INFOFRAME_SIZE 25 58f1d7ae31SEmmanuel Vadot #define HDMI_AUDIO_INFOFRAME_SIZE 10 59f1d7ae31SEmmanuel Vadot #define HDMI_DRM_INFOFRAME_SIZE 26 60f1d7ae31SEmmanuel Vadot #define HDMI_VENDOR_INFOFRAME_SIZE 4 61f1d7ae31SEmmanuel Vadot 62f1d7ae31SEmmanuel Vadot #define HDMI_INFOFRAME_SIZE(type) \ 63f1d7ae31SEmmanuel Vadot (HDMI_INFOFRAME_HEADER_SIZE + HDMI_ ## type ## _INFOFRAME_SIZE) 64f1d7ae31SEmmanuel Vadot 65f1d7ae31SEmmanuel Vadot struct hdmi_any_infoframe { 66f1d7ae31SEmmanuel Vadot enum hdmi_infoframe_type type; 67f1d7ae31SEmmanuel Vadot unsigned char version; 68f1d7ae31SEmmanuel Vadot unsigned char length; 69f1d7ae31SEmmanuel Vadot }; 70f1d7ae31SEmmanuel Vadot 71f1d7ae31SEmmanuel Vadot enum hdmi_colorspace { 72f1d7ae31SEmmanuel Vadot HDMI_COLORSPACE_RGB, 73f1d7ae31SEmmanuel Vadot HDMI_COLORSPACE_YUV422, 74f1d7ae31SEmmanuel Vadot HDMI_COLORSPACE_YUV444, 75f1d7ae31SEmmanuel Vadot HDMI_COLORSPACE_YUV420, 76f1d7ae31SEmmanuel Vadot HDMI_COLORSPACE_RESERVED4, 77f1d7ae31SEmmanuel Vadot HDMI_COLORSPACE_RESERVED5, 78f1d7ae31SEmmanuel Vadot HDMI_COLORSPACE_RESERVED6, 79f1d7ae31SEmmanuel Vadot HDMI_COLORSPACE_IDO_DEFINED, 80f1d7ae31SEmmanuel Vadot }; 81f1d7ae31SEmmanuel Vadot 82f1d7ae31SEmmanuel Vadot enum hdmi_scan_mode { 83f1d7ae31SEmmanuel Vadot HDMI_SCAN_MODE_NONE, 84f1d7ae31SEmmanuel Vadot HDMI_SCAN_MODE_OVERSCAN, 85f1d7ae31SEmmanuel Vadot HDMI_SCAN_MODE_UNDERSCAN, 86f1d7ae31SEmmanuel Vadot HDMI_SCAN_MODE_RESERVED, 87f1d7ae31SEmmanuel Vadot }; 88f1d7ae31SEmmanuel Vadot 89f1d7ae31SEmmanuel Vadot enum hdmi_colorimetry { 90f1d7ae31SEmmanuel Vadot HDMI_COLORIMETRY_NONE, 91f1d7ae31SEmmanuel Vadot HDMI_COLORIMETRY_ITU_601, 92f1d7ae31SEmmanuel Vadot HDMI_COLORIMETRY_ITU_709, 93f1d7ae31SEmmanuel Vadot HDMI_COLORIMETRY_EXTENDED, 94f1d7ae31SEmmanuel Vadot }; 95f1d7ae31SEmmanuel Vadot 96f1d7ae31SEmmanuel Vadot enum hdmi_picture_aspect { 97f1d7ae31SEmmanuel Vadot HDMI_PICTURE_ASPECT_NONE, 98f1d7ae31SEmmanuel Vadot HDMI_PICTURE_ASPECT_4_3, 99f1d7ae31SEmmanuel Vadot HDMI_PICTURE_ASPECT_16_9, 100f1d7ae31SEmmanuel Vadot HDMI_PICTURE_ASPECT_64_27, 101f1d7ae31SEmmanuel Vadot HDMI_PICTURE_ASPECT_256_135, 102f1d7ae31SEmmanuel Vadot HDMI_PICTURE_ASPECT_RESERVED, 103f1d7ae31SEmmanuel Vadot }; 104f1d7ae31SEmmanuel Vadot 105f1d7ae31SEmmanuel Vadot enum hdmi_active_aspect { 106f1d7ae31SEmmanuel Vadot HDMI_ACTIVE_ASPECT_16_9_TOP = 2, 107f1d7ae31SEmmanuel Vadot HDMI_ACTIVE_ASPECT_14_9_TOP = 3, 108f1d7ae31SEmmanuel Vadot HDMI_ACTIVE_ASPECT_16_9_CENTER = 4, 109f1d7ae31SEmmanuel Vadot HDMI_ACTIVE_ASPECT_PICTURE = 8, 110f1d7ae31SEmmanuel Vadot HDMI_ACTIVE_ASPECT_4_3 = 9, 111f1d7ae31SEmmanuel Vadot HDMI_ACTIVE_ASPECT_16_9 = 10, 112f1d7ae31SEmmanuel Vadot HDMI_ACTIVE_ASPECT_14_9 = 11, 113f1d7ae31SEmmanuel Vadot HDMI_ACTIVE_ASPECT_4_3_SP_14_9 = 13, 114f1d7ae31SEmmanuel Vadot HDMI_ACTIVE_ASPECT_16_9_SP_14_9 = 14, 115f1d7ae31SEmmanuel Vadot HDMI_ACTIVE_ASPECT_16_9_SP_4_3 = 15, 116f1d7ae31SEmmanuel Vadot }; 117f1d7ae31SEmmanuel Vadot 118f1d7ae31SEmmanuel Vadot enum hdmi_extended_colorimetry { 119f1d7ae31SEmmanuel Vadot HDMI_EXTENDED_COLORIMETRY_XV_YCC_601, 120f1d7ae31SEmmanuel Vadot HDMI_EXTENDED_COLORIMETRY_XV_YCC_709, 121f1d7ae31SEmmanuel Vadot HDMI_EXTENDED_COLORIMETRY_S_YCC_601, 122f1d7ae31SEmmanuel Vadot HDMI_EXTENDED_COLORIMETRY_OPYCC_601, 123f1d7ae31SEmmanuel Vadot HDMI_EXTENDED_COLORIMETRY_OPRGB, 124f1d7ae31SEmmanuel Vadot 125f1d7ae31SEmmanuel Vadot /* The following EC values are only defined in CEA-861-F. */ 126f1d7ae31SEmmanuel Vadot HDMI_EXTENDED_COLORIMETRY_BT2020_CONST_LUM, 127f1d7ae31SEmmanuel Vadot HDMI_EXTENDED_COLORIMETRY_BT2020, 128f1d7ae31SEmmanuel Vadot HDMI_EXTENDED_COLORIMETRY_RESERVED, 129f1d7ae31SEmmanuel Vadot }; 130f1d7ae31SEmmanuel Vadot 131f1d7ae31SEmmanuel Vadot enum hdmi_quantization_range { 132f1d7ae31SEmmanuel Vadot HDMI_QUANTIZATION_RANGE_DEFAULT, 133f1d7ae31SEmmanuel Vadot HDMI_QUANTIZATION_RANGE_LIMITED, 134f1d7ae31SEmmanuel Vadot HDMI_QUANTIZATION_RANGE_FULL, 135f1d7ae31SEmmanuel Vadot HDMI_QUANTIZATION_RANGE_RESERVED, 136f1d7ae31SEmmanuel Vadot }; 137f1d7ae31SEmmanuel Vadot 138f1d7ae31SEmmanuel Vadot /* non-uniform picture scaling */ 139f1d7ae31SEmmanuel Vadot enum hdmi_nups { 140f1d7ae31SEmmanuel Vadot HDMI_NUPS_UNKNOWN, 141f1d7ae31SEmmanuel Vadot HDMI_NUPS_HORIZONTAL, 142f1d7ae31SEmmanuel Vadot HDMI_NUPS_VERTICAL, 143f1d7ae31SEmmanuel Vadot HDMI_NUPS_BOTH, 144f1d7ae31SEmmanuel Vadot }; 145f1d7ae31SEmmanuel Vadot 146f1d7ae31SEmmanuel Vadot enum hdmi_ycc_quantization_range { 147f1d7ae31SEmmanuel Vadot HDMI_YCC_QUANTIZATION_RANGE_LIMITED, 148f1d7ae31SEmmanuel Vadot HDMI_YCC_QUANTIZATION_RANGE_FULL, 149f1d7ae31SEmmanuel Vadot }; 150f1d7ae31SEmmanuel Vadot 151f1d7ae31SEmmanuel Vadot enum hdmi_content_type { 152f1d7ae31SEmmanuel Vadot HDMI_CONTENT_TYPE_GRAPHICS, 153f1d7ae31SEmmanuel Vadot HDMI_CONTENT_TYPE_PHOTO, 154f1d7ae31SEmmanuel Vadot HDMI_CONTENT_TYPE_CINEMA, 155f1d7ae31SEmmanuel Vadot HDMI_CONTENT_TYPE_GAME, 156f1d7ae31SEmmanuel Vadot }; 157f1d7ae31SEmmanuel Vadot 158f1d7ae31SEmmanuel Vadot enum hdmi_metadata_type { 159f1d7ae31SEmmanuel Vadot HDMI_STATIC_METADATA_TYPE1 = 0, 160f1d7ae31SEmmanuel Vadot }; 161f1d7ae31SEmmanuel Vadot 162f1d7ae31SEmmanuel Vadot enum hdmi_eotf { 163f1d7ae31SEmmanuel Vadot HDMI_EOTF_TRADITIONAL_GAMMA_SDR, 164f1d7ae31SEmmanuel Vadot HDMI_EOTF_TRADITIONAL_GAMMA_HDR, 165f1d7ae31SEmmanuel Vadot HDMI_EOTF_SMPTE_ST2084, 166f1d7ae31SEmmanuel Vadot HDMI_EOTF_BT_2100_HLG, 167f1d7ae31SEmmanuel Vadot }; 168f1d7ae31SEmmanuel Vadot 169f1d7ae31SEmmanuel Vadot struct hdmi_avi_infoframe { 170f1d7ae31SEmmanuel Vadot enum hdmi_infoframe_type type; 171f1d7ae31SEmmanuel Vadot unsigned char version; 172f1d7ae31SEmmanuel Vadot unsigned char length; 173*c89d94adSVladimir Kondratyev bool itc; 174*c89d94adSVladimir Kondratyev unsigned char pixel_repeat; 175f1d7ae31SEmmanuel Vadot enum hdmi_colorspace colorspace; 176f1d7ae31SEmmanuel Vadot enum hdmi_scan_mode scan_mode; 177f1d7ae31SEmmanuel Vadot enum hdmi_colorimetry colorimetry; 178f1d7ae31SEmmanuel Vadot enum hdmi_picture_aspect picture_aspect; 179f1d7ae31SEmmanuel Vadot enum hdmi_active_aspect active_aspect; 180f1d7ae31SEmmanuel Vadot enum hdmi_extended_colorimetry extended_colorimetry; 181f1d7ae31SEmmanuel Vadot enum hdmi_quantization_range quantization_range; 182f1d7ae31SEmmanuel Vadot enum hdmi_nups nups; 183f1d7ae31SEmmanuel Vadot unsigned char video_code; 184f1d7ae31SEmmanuel Vadot enum hdmi_ycc_quantization_range ycc_quantization_range; 185f1d7ae31SEmmanuel Vadot enum hdmi_content_type content_type; 186f1d7ae31SEmmanuel Vadot unsigned short top_bar; 187f1d7ae31SEmmanuel Vadot unsigned short bottom_bar; 188f1d7ae31SEmmanuel Vadot unsigned short left_bar; 189f1d7ae31SEmmanuel Vadot unsigned short right_bar; 190f1d7ae31SEmmanuel Vadot }; 191f1d7ae31SEmmanuel Vadot 192f1d7ae31SEmmanuel Vadot /* DRM Infoframe as per CTA 861.G spec */ 193f1d7ae31SEmmanuel Vadot struct hdmi_drm_infoframe { 194f1d7ae31SEmmanuel Vadot enum hdmi_infoframe_type type; 195f1d7ae31SEmmanuel Vadot unsigned char version; 196f1d7ae31SEmmanuel Vadot unsigned char length; 197f1d7ae31SEmmanuel Vadot enum hdmi_eotf eotf; 198f1d7ae31SEmmanuel Vadot enum hdmi_metadata_type metadata_type; 199f1d7ae31SEmmanuel Vadot struct { 200f1d7ae31SEmmanuel Vadot u16 x, y; 201f1d7ae31SEmmanuel Vadot } display_primaries[3]; 202f1d7ae31SEmmanuel Vadot struct { 203f1d7ae31SEmmanuel Vadot u16 x, y; 204f1d7ae31SEmmanuel Vadot } white_point; 205f1d7ae31SEmmanuel Vadot u16 max_display_mastering_luminance; 206f1d7ae31SEmmanuel Vadot u16 min_display_mastering_luminance; 207f1d7ae31SEmmanuel Vadot u16 max_cll; 208f1d7ae31SEmmanuel Vadot u16 max_fall; 209f1d7ae31SEmmanuel Vadot }; 210f1d7ae31SEmmanuel Vadot 211f1d7ae31SEmmanuel Vadot void hdmi_avi_infoframe_init(struct hdmi_avi_infoframe *frame); 212f1d7ae31SEmmanuel Vadot ssize_t hdmi_avi_infoframe_pack(struct hdmi_avi_infoframe *frame, void *buffer, 213f1d7ae31SEmmanuel Vadot size_t size); 214f1d7ae31SEmmanuel Vadot ssize_t hdmi_avi_infoframe_pack_only(const struct hdmi_avi_infoframe *frame, 215f1d7ae31SEmmanuel Vadot void *buffer, size_t size); 216f1d7ae31SEmmanuel Vadot int hdmi_avi_infoframe_check(struct hdmi_avi_infoframe *frame); 217f1d7ae31SEmmanuel Vadot int hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame); 218f1d7ae31SEmmanuel Vadot ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame, void *buffer, 219f1d7ae31SEmmanuel Vadot size_t size); 220f1d7ae31SEmmanuel Vadot ssize_t hdmi_drm_infoframe_pack_only(const struct hdmi_drm_infoframe *frame, 221f1d7ae31SEmmanuel Vadot void *buffer, size_t size); 222f1d7ae31SEmmanuel Vadot int hdmi_drm_infoframe_check(struct hdmi_drm_infoframe *frame); 223f1d7ae31SEmmanuel Vadot int hdmi_drm_infoframe_unpack_only(struct hdmi_drm_infoframe *frame, 224f1d7ae31SEmmanuel Vadot const void *buffer, size_t size); 225f1d7ae31SEmmanuel Vadot 226f1d7ae31SEmmanuel Vadot enum hdmi_spd_sdi { 227f1d7ae31SEmmanuel Vadot HDMI_SPD_SDI_UNKNOWN, 228f1d7ae31SEmmanuel Vadot HDMI_SPD_SDI_DSTB, 229f1d7ae31SEmmanuel Vadot HDMI_SPD_SDI_DVDP, 230f1d7ae31SEmmanuel Vadot HDMI_SPD_SDI_DVHS, 231f1d7ae31SEmmanuel Vadot HDMI_SPD_SDI_HDDVR, 232f1d7ae31SEmmanuel Vadot HDMI_SPD_SDI_DVC, 233f1d7ae31SEmmanuel Vadot HDMI_SPD_SDI_DSC, 234f1d7ae31SEmmanuel Vadot HDMI_SPD_SDI_VCD, 235f1d7ae31SEmmanuel Vadot HDMI_SPD_SDI_GAME, 236f1d7ae31SEmmanuel Vadot HDMI_SPD_SDI_PC, 237f1d7ae31SEmmanuel Vadot HDMI_SPD_SDI_BD, 238f1d7ae31SEmmanuel Vadot HDMI_SPD_SDI_SACD, 239f1d7ae31SEmmanuel Vadot HDMI_SPD_SDI_HDDVD, 240f1d7ae31SEmmanuel Vadot HDMI_SPD_SDI_PMP, 241f1d7ae31SEmmanuel Vadot }; 242f1d7ae31SEmmanuel Vadot 243f1d7ae31SEmmanuel Vadot struct hdmi_spd_infoframe { 244f1d7ae31SEmmanuel Vadot enum hdmi_infoframe_type type; 245f1d7ae31SEmmanuel Vadot unsigned char version; 246f1d7ae31SEmmanuel Vadot unsigned char length; 247f1d7ae31SEmmanuel Vadot char vendor[8]; 248f1d7ae31SEmmanuel Vadot char product[16]; 249f1d7ae31SEmmanuel Vadot enum hdmi_spd_sdi sdi; 250f1d7ae31SEmmanuel Vadot }; 251f1d7ae31SEmmanuel Vadot 252f1d7ae31SEmmanuel Vadot int hdmi_spd_infoframe_init(struct hdmi_spd_infoframe *frame, 253f1d7ae31SEmmanuel Vadot const char *vendor, const char *product); 254f1d7ae31SEmmanuel Vadot ssize_t hdmi_spd_infoframe_pack(struct hdmi_spd_infoframe *frame, void *buffer, 255f1d7ae31SEmmanuel Vadot size_t size); 256f1d7ae31SEmmanuel Vadot ssize_t hdmi_spd_infoframe_pack_only(const struct hdmi_spd_infoframe *frame, 257f1d7ae31SEmmanuel Vadot void *buffer, size_t size); 258f1d7ae31SEmmanuel Vadot int hdmi_spd_infoframe_check(struct hdmi_spd_infoframe *frame); 259f1d7ae31SEmmanuel Vadot 260f1d7ae31SEmmanuel Vadot enum hdmi_audio_coding_type { 261f1d7ae31SEmmanuel Vadot HDMI_AUDIO_CODING_TYPE_STREAM, 262f1d7ae31SEmmanuel Vadot HDMI_AUDIO_CODING_TYPE_PCM, 263f1d7ae31SEmmanuel Vadot HDMI_AUDIO_CODING_TYPE_AC3, 264f1d7ae31SEmmanuel Vadot HDMI_AUDIO_CODING_TYPE_MPEG1, 265f1d7ae31SEmmanuel Vadot HDMI_AUDIO_CODING_TYPE_MP3, 266f1d7ae31SEmmanuel Vadot HDMI_AUDIO_CODING_TYPE_MPEG2, 267f1d7ae31SEmmanuel Vadot HDMI_AUDIO_CODING_TYPE_AAC_LC, 268f1d7ae31SEmmanuel Vadot HDMI_AUDIO_CODING_TYPE_DTS, 269f1d7ae31SEmmanuel Vadot HDMI_AUDIO_CODING_TYPE_ATRAC, 270f1d7ae31SEmmanuel Vadot HDMI_AUDIO_CODING_TYPE_DSD, 271f1d7ae31SEmmanuel Vadot HDMI_AUDIO_CODING_TYPE_EAC3, 272f1d7ae31SEmmanuel Vadot HDMI_AUDIO_CODING_TYPE_DTS_HD, 273f1d7ae31SEmmanuel Vadot HDMI_AUDIO_CODING_TYPE_MLP, 274f1d7ae31SEmmanuel Vadot HDMI_AUDIO_CODING_TYPE_DST, 275f1d7ae31SEmmanuel Vadot HDMI_AUDIO_CODING_TYPE_WMA_PRO, 276f1d7ae31SEmmanuel Vadot HDMI_AUDIO_CODING_TYPE_CXT, 277f1d7ae31SEmmanuel Vadot }; 278f1d7ae31SEmmanuel Vadot 279f1d7ae31SEmmanuel Vadot enum hdmi_audio_sample_size { 280f1d7ae31SEmmanuel Vadot HDMI_AUDIO_SAMPLE_SIZE_STREAM, 281f1d7ae31SEmmanuel Vadot HDMI_AUDIO_SAMPLE_SIZE_16, 282f1d7ae31SEmmanuel Vadot HDMI_AUDIO_SAMPLE_SIZE_20, 283f1d7ae31SEmmanuel Vadot HDMI_AUDIO_SAMPLE_SIZE_24, 284f1d7ae31SEmmanuel Vadot }; 285f1d7ae31SEmmanuel Vadot 286f1d7ae31SEmmanuel Vadot enum hdmi_audio_sample_frequency { 287f1d7ae31SEmmanuel Vadot HDMI_AUDIO_SAMPLE_FREQUENCY_STREAM, 288f1d7ae31SEmmanuel Vadot HDMI_AUDIO_SAMPLE_FREQUENCY_32000, 289f1d7ae31SEmmanuel Vadot HDMI_AUDIO_SAMPLE_FREQUENCY_44100, 290f1d7ae31SEmmanuel Vadot HDMI_AUDIO_SAMPLE_FREQUENCY_48000, 291f1d7ae31SEmmanuel Vadot HDMI_AUDIO_SAMPLE_FREQUENCY_88200, 292f1d7ae31SEmmanuel Vadot HDMI_AUDIO_SAMPLE_FREQUENCY_96000, 293f1d7ae31SEmmanuel Vadot HDMI_AUDIO_SAMPLE_FREQUENCY_176400, 294f1d7ae31SEmmanuel Vadot HDMI_AUDIO_SAMPLE_FREQUENCY_192000, 295f1d7ae31SEmmanuel Vadot }; 296f1d7ae31SEmmanuel Vadot 297f1d7ae31SEmmanuel Vadot enum hdmi_audio_coding_type_ext { 298f1d7ae31SEmmanuel Vadot /* Refer to Audio Coding Type (CT) field in Data Byte 1 */ 299f1d7ae31SEmmanuel Vadot HDMI_AUDIO_CODING_TYPE_EXT_CT, 300f1d7ae31SEmmanuel Vadot 301f1d7ae31SEmmanuel Vadot /* 302f1d7ae31SEmmanuel Vadot * The next three CXT values are defined in CEA-861-E only. 303f1d7ae31SEmmanuel Vadot * They do not exist in older versions, and in CEA-861-F they are 304f1d7ae31SEmmanuel Vadot * defined as 'Not in use'. 305f1d7ae31SEmmanuel Vadot */ 306f1d7ae31SEmmanuel Vadot HDMI_AUDIO_CODING_TYPE_EXT_HE_AAC, 307f1d7ae31SEmmanuel Vadot HDMI_AUDIO_CODING_TYPE_EXT_HE_AAC_V2, 308f1d7ae31SEmmanuel Vadot HDMI_AUDIO_CODING_TYPE_EXT_MPEG_SURROUND, 309f1d7ae31SEmmanuel Vadot 310f1d7ae31SEmmanuel Vadot /* The following CXT values are only defined in CEA-861-F. */ 311f1d7ae31SEmmanuel Vadot HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_HE_AAC, 312f1d7ae31SEmmanuel Vadot HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_HE_AAC_V2, 313f1d7ae31SEmmanuel Vadot HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_AAC_LC, 314f1d7ae31SEmmanuel Vadot HDMI_AUDIO_CODING_TYPE_EXT_DRA, 315f1d7ae31SEmmanuel Vadot HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_HE_AAC_SURROUND, 316f1d7ae31SEmmanuel Vadot HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_AAC_LC_SURROUND = 10, 317f1d7ae31SEmmanuel Vadot }; 318f1d7ae31SEmmanuel Vadot 319f1d7ae31SEmmanuel Vadot struct hdmi_audio_infoframe { 320f1d7ae31SEmmanuel Vadot enum hdmi_infoframe_type type; 321f1d7ae31SEmmanuel Vadot unsigned char version; 322f1d7ae31SEmmanuel Vadot unsigned char length; 323f1d7ae31SEmmanuel Vadot unsigned char channels; 324f1d7ae31SEmmanuel Vadot enum hdmi_audio_coding_type coding_type; 325f1d7ae31SEmmanuel Vadot enum hdmi_audio_sample_size sample_size; 326f1d7ae31SEmmanuel Vadot enum hdmi_audio_sample_frequency sample_frequency; 327f1d7ae31SEmmanuel Vadot enum hdmi_audio_coding_type_ext coding_type_ext; 328f1d7ae31SEmmanuel Vadot unsigned char channel_allocation; 329f1d7ae31SEmmanuel Vadot unsigned char level_shift_value; 330f1d7ae31SEmmanuel Vadot bool downmix_inhibit; 331f1d7ae31SEmmanuel Vadot 332f1d7ae31SEmmanuel Vadot }; 333f1d7ae31SEmmanuel Vadot 334f1d7ae31SEmmanuel Vadot int hdmi_audio_infoframe_init(struct hdmi_audio_infoframe *frame); 335f1d7ae31SEmmanuel Vadot ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame, 336f1d7ae31SEmmanuel Vadot void *buffer, size_t size); 337f1d7ae31SEmmanuel Vadot ssize_t hdmi_audio_infoframe_pack_only(const struct hdmi_audio_infoframe *frame, 338f1d7ae31SEmmanuel Vadot void *buffer, size_t size); 339*c89d94adSVladimir Kondratyev int hdmi_audio_infoframe_check(const struct hdmi_audio_infoframe *frame); 340*c89d94adSVladimir Kondratyev 341*c89d94adSVladimir Kondratyev #ifdef __linux__ 342*c89d94adSVladimir Kondratyev struct dp_sdp; 343*c89d94adSVladimir Kondratyev ssize_t 344*c89d94adSVladimir Kondratyev hdmi_audio_infoframe_pack_for_dp(const struct hdmi_audio_infoframe *frame, 345*c89d94adSVladimir Kondratyev struct dp_sdp *sdp, u8 dp_version); 346*c89d94adSVladimir Kondratyev #endif 347f1d7ae31SEmmanuel Vadot 348f1d7ae31SEmmanuel Vadot enum hdmi_3d_structure { 349f1d7ae31SEmmanuel Vadot HDMI_3D_STRUCTURE_INVALID = -1, 350f1d7ae31SEmmanuel Vadot HDMI_3D_STRUCTURE_FRAME_PACKING = 0, 351f1d7ae31SEmmanuel Vadot HDMI_3D_STRUCTURE_FIELD_ALTERNATIVE, 352f1d7ae31SEmmanuel Vadot HDMI_3D_STRUCTURE_LINE_ALTERNATIVE, 353f1d7ae31SEmmanuel Vadot HDMI_3D_STRUCTURE_SIDE_BY_SIDE_FULL, 354f1d7ae31SEmmanuel Vadot HDMI_3D_STRUCTURE_L_DEPTH, 355f1d7ae31SEmmanuel Vadot HDMI_3D_STRUCTURE_L_DEPTH_GFX_GFX_DEPTH, 356f1d7ae31SEmmanuel Vadot HDMI_3D_STRUCTURE_TOP_AND_BOTTOM, 357f1d7ae31SEmmanuel Vadot HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF = 8, 358f1d7ae31SEmmanuel Vadot }; 359f1d7ae31SEmmanuel Vadot 360f1d7ae31SEmmanuel Vadot 361f1d7ae31SEmmanuel Vadot struct hdmi_vendor_infoframe { 362f1d7ae31SEmmanuel Vadot enum hdmi_infoframe_type type; 363f1d7ae31SEmmanuel Vadot unsigned char version; 364f1d7ae31SEmmanuel Vadot unsigned char length; 365f1d7ae31SEmmanuel Vadot unsigned int oui; 366f1d7ae31SEmmanuel Vadot u8 vic; 367f1d7ae31SEmmanuel Vadot enum hdmi_3d_structure s3d_struct; 368f1d7ae31SEmmanuel Vadot unsigned int s3d_ext_data; 369f1d7ae31SEmmanuel Vadot }; 370f1d7ae31SEmmanuel Vadot 371f1d7ae31SEmmanuel Vadot /* HDR Metadata as per 861.G spec */ 372f1d7ae31SEmmanuel Vadot struct hdr_static_metadata { 373f1d7ae31SEmmanuel Vadot __u8 eotf; 374f1d7ae31SEmmanuel Vadot __u8 metadata_type; 375f1d7ae31SEmmanuel Vadot __u16 max_cll; 376f1d7ae31SEmmanuel Vadot __u16 max_fall; 377f1d7ae31SEmmanuel Vadot __u16 min_cll; 378f1d7ae31SEmmanuel Vadot }; 379f1d7ae31SEmmanuel Vadot 380f1d7ae31SEmmanuel Vadot /** 381f1d7ae31SEmmanuel Vadot * struct hdr_sink_metadata - HDR sink metadata 382f1d7ae31SEmmanuel Vadot * 383f1d7ae31SEmmanuel Vadot * Metadata Information read from Sink's EDID 384f1d7ae31SEmmanuel Vadot */ 385f1d7ae31SEmmanuel Vadot struct hdr_sink_metadata { 386f1d7ae31SEmmanuel Vadot /** 387f1d7ae31SEmmanuel Vadot * @metadata_type: Static_Metadata_Descriptor_ID. 388f1d7ae31SEmmanuel Vadot */ 389f1d7ae31SEmmanuel Vadot __u32 metadata_type; 390f1d7ae31SEmmanuel Vadot /** 391f1d7ae31SEmmanuel Vadot * @hdmi_type1: HDR Metadata Infoframe. 392f1d7ae31SEmmanuel Vadot */ 393f1d7ae31SEmmanuel Vadot union { 394f1d7ae31SEmmanuel Vadot struct hdr_static_metadata hdmi_type1; 395f1d7ae31SEmmanuel Vadot }; 396f1d7ae31SEmmanuel Vadot }; 397f1d7ae31SEmmanuel Vadot 398f1d7ae31SEmmanuel Vadot int hdmi_vendor_infoframe_init(struct hdmi_vendor_infoframe *frame); 399f1d7ae31SEmmanuel Vadot ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame, 400f1d7ae31SEmmanuel Vadot void *buffer, size_t size); 401f1d7ae31SEmmanuel Vadot ssize_t hdmi_vendor_infoframe_pack_only(const struct hdmi_vendor_infoframe *frame, 402f1d7ae31SEmmanuel Vadot void *buffer, size_t size); 403f1d7ae31SEmmanuel Vadot int hdmi_vendor_infoframe_check(struct hdmi_vendor_infoframe *frame); 404f1d7ae31SEmmanuel Vadot 405f1d7ae31SEmmanuel Vadot union hdmi_vendor_any_infoframe { 406f1d7ae31SEmmanuel Vadot struct { 407f1d7ae31SEmmanuel Vadot enum hdmi_infoframe_type type; 408f1d7ae31SEmmanuel Vadot unsigned char version; 409f1d7ae31SEmmanuel Vadot unsigned char length; 410f1d7ae31SEmmanuel Vadot unsigned int oui; 411f1d7ae31SEmmanuel Vadot } any; 412f1d7ae31SEmmanuel Vadot struct hdmi_vendor_infoframe hdmi; 413f1d7ae31SEmmanuel Vadot }; 414f1d7ae31SEmmanuel Vadot 415f1d7ae31SEmmanuel Vadot /** 416f1d7ae31SEmmanuel Vadot * union hdmi_infoframe - overall union of all abstract infoframe representations 417f1d7ae31SEmmanuel Vadot * @any: generic infoframe 418f1d7ae31SEmmanuel Vadot * @avi: avi infoframe 419f1d7ae31SEmmanuel Vadot * @spd: spd infoframe 420f1d7ae31SEmmanuel Vadot * @vendor: union of all vendor infoframes 421f1d7ae31SEmmanuel Vadot * @audio: audio infoframe 422f1d7ae31SEmmanuel Vadot * @drm: Dynamic Range and Mastering infoframe 423f1d7ae31SEmmanuel Vadot * 424f1d7ae31SEmmanuel Vadot * This is used by the generic pack function. This works since all infoframes 425f1d7ae31SEmmanuel Vadot * have the same header which also indicates which type of infoframe should be 426f1d7ae31SEmmanuel Vadot * packed. 427f1d7ae31SEmmanuel Vadot */ 428f1d7ae31SEmmanuel Vadot union hdmi_infoframe { 429f1d7ae31SEmmanuel Vadot struct hdmi_any_infoframe any; 430f1d7ae31SEmmanuel Vadot struct hdmi_avi_infoframe avi; 431f1d7ae31SEmmanuel Vadot struct hdmi_spd_infoframe spd; 432f1d7ae31SEmmanuel Vadot union hdmi_vendor_any_infoframe vendor; 433f1d7ae31SEmmanuel Vadot struct hdmi_audio_infoframe audio; 434f1d7ae31SEmmanuel Vadot struct hdmi_drm_infoframe drm; 435f1d7ae31SEmmanuel Vadot }; 436f1d7ae31SEmmanuel Vadot 437f1d7ae31SEmmanuel Vadot ssize_t hdmi_infoframe_pack(union hdmi_infoframe *frame, void *buffer, 438f1d7ae31SEmmanuel Vadot size_t size); 439f1d7ae31SEmmanuel Vadot ssize_t hdmi_infoframe_pack_only(const union hdmi_infoframe *frame, 440f1d7ae31SEmmanuel Vadot void *buffer, size_t size); 441f1d7ae31SEmmanuel Vadot int hdmi_infoframe_check(union hdmi_infoframe *frame); 442f1d7ae31SEmmanuel Vadot int hdmi_infoframe_unpack(union hdmi_infoframe *frame, 443f1d7ae31SEmmanuel Vadot const void *buffer, size_t size); 444f1d7ae31SEmmanuel Vadot void hdmi_infoframe_log(const char *level, struct device *dev, 445f1d7ae31SEmmanuel Vadot const union hdmi_infoframe *frame); 446f1d7ae31SEmmanuel Vadot 447f1d7ae31SEmmanuel Vadot #endif /* _DRM_HDMI_H */ 448