Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/drm2/include/linux linux/hdmi: Update. Add...



details:   https://anonhg.NetBSD.org/src/rev/893fd7f23de2
branches:  trunk
changeset: 1028684:893fd7f23de2
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 11:45:35 2021 +0000

description:
linux/hdmi: Update.  Add unpack.

diffstat:

 sys/external/bsd/drm2/include/linux/hdmi.h |  539 +++++++++++++++++++++++-----
 1 files changed, 432 insertions(+), 107 deletions(-)

diffs (truncated from 718 to 300 lines):

diff -r 8b9957292b25 -r 893fd7f23de2 sys/external/bsd/drm2/include/linux/hdmi.h
--- a/sys/external/bsd/drm2/include/linux/hdmi.h        Sun Dec 19 11:45:27 2021 +0000
+++ b/sys/external/bsd/drm2/include/linux/hdmi.h        Sun Dec 19 11:45:35 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hdmi.h,v 1.13 2021/12/19 11:45:27 riastradh Exp $      */
+/*     $NetBSD: hdmi.h,v 1.14 2021/12/19 11:45:35 riastradh Exp $      */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -38,28 +38,29 @@
 #include <sys/systm.h>
 
 enum hdmi_3d_structure {
-        HDMI_3D_STRUCTURE_INVALID              = -1,
-        HDMI_3D_STRUCTURE_FRAME_PACKING                = 0,
-        HDMI_3D_STRUCTURE_FIELD_ALTERNATIVE    = 1,
-        HDMI_3D_STRUCTURE_LINE_ALTERNATIVE     = 2,
-        HDMI_3D_STRUCTURE_SIDE_BY_SIDE_FULL    = 3,
-        HDMI_3D_STRUCTURE_L_DEPTH              = 4,
-        HDMI_3D_STRUCTURE_L_DEPTH_GFX_GFX_DEPTH        = 5,
-        HDMI_3D_STRUCTURE_TOP_AND_BOTTOM       = 6,
-        HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF    = 8,
+       HDMI_3D_STRUCTURE_INVALID               = -1,
+       HDMI_3D_STRUCTURE_FRAME_PACKING         = 0,
+       HDMI_3D_STRUCTURE_FIELD_ALTERNATIVE     = 1,
+       HDMI_3D_STRUCTURE_LINE_ALTERNATIVE      = 2,
+       HDMI_3D_STRUCTURE_SIDE_BY_SIDE_FULL     = 3,
+       HDMI_3D_STRUCTURE_L_DEPTH               = 4,
+       HDMI_3D_STRUCTURE_L_DEPTH_GFX_GFX_DEPTH = 5,
+       HDMI_3D_STRUCTURE_TOP_AND_BOTTOM        = 6,
+       HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF     = 8,
 };
 
 enum hdmi_active_aspect {
-        HDMI_ACTIVE_ASPECT_16_9_TOP            = 2,
-        HDMI_ACTIVE_ASPECT_14_9_TOP            = 3,
-        HDMI_ACTIVE_ASPECT_16_9_CENTER         = 4,
-        HDMI_ACTIVE_ASPECT_PICTURE             = 8,
-        HDMI_ACTIVE_ASPECT_4_3                 = 9,
-        HDMI_ACTIVE_ASPECT_16_9                        = 10,
-        HDMI_ACTIVE_ASPECT_14_9                        = 11,
-        HDMI_ACTIVE_ASPECT_4_3_SP_14_9         = 13,
-        HDMI_ACTIVE_ASPECT_16_9_SP_14_9                = 14,
-        HDMI_ACTIVE_ASPECT_16_9_SP_4_3         = 15,
+       HDMI_ACTIVE_ASPECT_NONE                 = 0,
+       HDMI_ACTIVE_ASPECT_16_9_TOP             = 2,
+       HDMI_ACTIVE_ASPECT_14_9_TOP             = 3,
+       HDMI_ACTIVE_ASPECT_16_9_CENTER          = 4,
+       HDMI_ACTIVE_ASPECT_PICTURE              = 8,
+       HDMI_ACTIVE_ASPECT_4_3                  = 9,
+       HDMI_ACTIVE_ASPECT_16_9                 = 10,
+       HDMI_ACTIVE_ASPECT_14_9                 = 11,
+       HDMI_ACTIVE_ASPECT_4_3_SP_14_9          = 13,
+       HDMI_ACTIVE_ASPECT_16_9_SP_14_9         = 14,
+       HDMI_ACTIVE_ASPECT_16_9_SP_4_3          = 15,
 };
 
 enum hdmi_audio_coding_type {
@@ -116,6 +117,8 @@
        HDMI_COLORSPACE_RGB                     = 0,
        HDMI_COLORSPACE_YUV422                  = 1,
        HDMI_COLORSPACE_YUV444                  = 2,
+       HDMI_COLORSPACE_YUV420                  = 3,
+       HDMI_COLORSPACE_IDO_DEFINED             = 7,
 };
 
 enum hdmi_content_type {
@@ -129,8 +132,8 @@
        HDMI_EXTENDED_COLORIMETRY_XV_YCC_601    = 0,
        HDMI_EXTENDED_COLORIMETRY_XV_YCC_709    = 1,
        HDMI_EXTENDED_COLORIMETRY_S_YCC_601     = 2,
-       HDMI_EXTENDED_COLORIMETRY_ADOBE_YCC_601 = 3,
-       HDMI_EXTENDED_COLORIMETRY_ADOBE_RGB     = 4,
+       HDMI_EXTENDED_COLORIMETRY_OPYCC_601     = 3,
+       HDMI_EXTENDED_COLORIMETRY_OPRGB         = 4,
 };
 
 enum hdmi_nups {
@@ -189,14 +192,14 @@
 };
 
 enum hdmi_eotf {
-       HDMI_EOTF_TRADITIONAL_GAMMA_SDR,
-       HDMI_EOTF_TRADITIONAL_GAMMA_HDR,
-       HDMI_EOTF_SMPTE_ST2084,
-       HDMI_EOTF_BT_2100_HLG,
+       HDMI_EOTF_TRADITIONAL_GAMMA_SDR         = 0,
+       HDMI_EOTF_TRADITIONAL_GAMMA_HDR         = 1,
+       HDMI_EOTF_SMPTE_ST2084                  = 2,
+       HDMI_EOTF_BT_2100_HLG                   = 3,
 };
 
 enum hdmi_metadata_type {
-       HDMI_STATIC_METADATA_TYPE1 = 1,
+       HDMI_STATIC_METADATA_TYPE1              = 1,
 };
 
 struct hdmi_type1 {
@@ -233,6 +236,18 @@
 }
 
 static inline int
+hdmi_infoframe_header_check(const struct hdmi_infoframe_header *header,
+    enum hdmi_infoframe_type type, uint8_t vers, uint8_t length)
+{
+
+       if (header->type != type ||
+           header->version != vers ||
+           header->length != length)
+               return -EINVAL;
+       return 0;
+}
+
+static inline int
 hdmi_infoframe_header_pack(const struct hdmi_infoframe_header *header,
     uint8_t length, void *buf, size_t size)
 {
@@ -251,17 +266,41 @@
        return HDMI_INFOFRAME_HEADER_SIZE;
 }
 
-static inline void
-hdmi_infoframe_checksum(void *buf, size_t length)
+static inline uint8_t
+hdmi_infoframe_checksum(const void *buf, size_t length)
 {
-       uint8_t *p = buf;
+       const uint8_t *p = buf;
        uint8_t checksum = 0;
 
        while (length--)
                checksum += *p++;
 
-       p = buf;
-       p[3] = (256 - checksum);
+       return 256 - checksum;
+}
+
+static inline int
+hdmi_infoframe_header_unpack(struct hdmi_infoframe_header *header,
+    const void *buf, size_t size)
+{
+       const uint8_t *const p = buf;
+
+       if (size < HDMI_INFOFRAME_HEADER_SIZE)
+               return -EINVAL;
+       if (p[2] > size - HDMI_INFOFRAME_HEADER_SIZE)
+               return -EINVAL;
+       if (hdmi_infoframe_checksum(buf, p[2] + HDMI_INFOFRAME_HEADER_SIZE))
+               return -EINVAL;
+
+       hdmi_infoframe_header_init(header, p[0], p[1], p[2]);
+       return HDMI_INFOFRAME_HEADER_SIZE;
+}
+
+static inline void
+hdmi_infoframe_set_checksum(void *buf, size_t length)
+{
+       uint8_t *p = buf;
+
+       p[3] = hdmi_infoframe_checksum(buf, length);
 }
 
 #define        HDMI_AUDIO_INFOFRAME_SIZE       10
@@ -320,7 +359,7 @@
 
        p[2] = __SHIFTIN(frame->coding_type_ext, __BITS(5,0));
 
-       p[3] = __SHIFTIN(frame->level_shift_value, __BITS(6, 3));
+       p[3] = __SHIFTIN(frame->level_shift_value, __BITS(6,3));
 
        p[4] = __SHIFTIN(frame->downmix_inhibit? 1 : 0, __BIT(7));
 
@@ -333,11 +372,43 @@
 
        CTASSERT(HDMI_AUDIO_INFOFRAME_SIZE == 10);
 
-       hdmi_infoframe_checksum(buf, length);
+       hdmi_infoframe_set_checksum(buf, length);
 
        return length;
 }
 
+static inline int
+hdmi_audio_infoframe_unpack(struct hdmi_audio_infoframe *frame,
+    const void *buf, size_t size)
+{
+       const uint8_t *p = buf;
+       int ret;
+
+       memset(frame, 0, sizeof(*frame));
+
+       ret = hdmi_infoframe_header_unpack(&frame->header, p, size);
+       if (ret)
+               return ret;
+       if (frame->header.length != HDMI_AUDIO_INFOFRAME_SIZE)
+               return -EINVAL;
+       p += HDMI_INFOFRAME_HEADER_SIZE;
+       size -= HDMI_INFOFRAME_HEADER_SIZE;
+
+       frame->coding_type = __SHIFTOUT(p[0], __BITS(7,4));
+       frame->channels = __SHIFTOUT(p[0], __BITS(2,0));
+
+       frame->sample_frequency = __SHIFTOUT(p[1], __BITS(4,2));
+       frame->sample_size = __SHIFTOUT(p[1], __BITS(1,0));
+
+       frame->coding_type_ext = __SHIFTOUT(p[2], __BITS(5,0));
+
+       frame->level_shift_value = __SHIFTOUT(p[3], __BITS(6,3));
+
+       frame->downmix_inhibit = __SHIFTOUT(p[4], __BIT(7));
+
+       return 0;
+}
+
 #define        HDMI_AVI_INFOFRAME_SIZE         13
 struct hdmi_avi_infoframe {
        struct hdmi_infoframe_header    header;
@@ -373,6 +444,19 @@
        return 0;
 }
 
+static inline int
+hdmi_avi_infoframe_check(const struct hdmi_avi_infoframe *frame)
+{
+       int ret;
+
+       ret = hdmi_infoframe_header_check(&frame->header,
+           HDMI_INFOFRAME_TYPE_AVI, 2, HDMI_AVI_INFOFRAME_SIZE);
+       if (ret)
+               return ret;
+
+       return 0;
+}
+
 static inline ssize_t
 hdmi_avi_infoframe_pack(const struct hdmi_avi_infoframe *frame, void *buf,
     size_t size)
@@ -418,11 +502,176 @@
        le16enc(&p[11], frame->right_bar);
        CTASSERT(HDMI_AVI_INFOFRAME_SIZE == 13);
 
-       hdmi_infoframe_checksum(buf, length);
+       hdmi_infoframe_set_checksum(buf, length);
 
        return length;
 }
 
+static inline int
+hdmi_avi_infoframe_unpack(struct hdmi_avi_infoframe *frame, const void *buf,
+    size_t size)
+{
+       const uint8_t *p = buf;
+       int ret;
+
+       memset(frame, 0, sizeof(*frame));
+
+       ret = hdmi_infoframe_header_unpack(&frame->header, p, size);
+       if (ret)
+               return ret;
+       if (frame->header.length != HDMI_AVI_INFOFRAME_SIZE)
+               return -EINVAL;
+       p += HDMI_INFOFRAME_HEADER_SIZE;
+       size -= HDMI_INFOFRAME_HEADER_SIZE;
+
+       frame->colorspace = __SHIFTOUT(p[0], __BITS(6,5));
+       frame->scan_mode = __SHIFTOUT(p[0], __BITS(1,0));
+
+       frame->colorimetry = __SHIFTOUT(p[1], __BITS(7,6));
+       frame->picture_aspect = __SHIFTOUT(p[1], __BITS(5,4));
+       if (p[0] & __BIT(4))
+               frame->active_aspect = __SHIFTOUT(p[1], __BITS(3,0));
+
+       frame->itc = __SHIFTOUT(p[2], __BIT(7));
+       frame->extended_colorimetry = __SHIFTOUT(p[2], __BITS(6,4));
+       frame->quantization_range = __SHIFTOUT(p[2], __BITS(3,2));
+       frame->nups = __SHIFTOUT(p[2], __BITS(1,0));
+
+       frame->video_code = p[3];
+
+       frame->ycc_quantization_range = __SHIFTOUT(p[4], __BITS(7,6));
+       frame->content_type = __SHIFTOUT(p[4], __BITS(5,4));
+       frame->pixel_repeat = __SHIFTOUT(p[4], __BITS(3,0));
+
+       if (p[0] & __BIT(3)) {
+               frame->top_bar = le16dec(&p[5]);
+               frame->bottom_bar = le16dec(&p[7]);
+       }
+       if (p[0] & __BIT(2)) {
+               frame->left_bar = le16dec(&p[9]);
+               frame->right_bar = le16dec(&p[11]);
+       }
+
+       return 0;
+}
+
+#define        HDMI_DRM_INFOFRAME_SIZE         26
+struct hdmi_drm_infoframe {
+       struct hdmi_infoframe_header    header;
+       enum hdmi_eotf                  eotf;



Home | Main Index | Thread Index | Old Index