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/linux linux/hdmi.h: Split out logic in...
details: https://anonhg.NetBSD.org/src/rev/93fd98801c7e
branches: trunk
changeset: 368399:93fd98801c7e
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sat Jul 09 17:59:27 2022 +0000
description:
linux/hdmi.h: Split out logic into .c file.
Shoulda done this ages ago.
diffstat:
sys/external/bsd/drm2/include/linux/hdmi.h | 740 ++----------------------
sys/external/bsd/drm2/linux/files.drmkms_linux | 3 +-
sys/external/bsd/drm2/linux/linux_hdmi.c | 729 ++++++++++++++++++++++++
3 files changed, 799 insertions(+), 673 deletions(-)
diffs (truncated from 1557 to 300 lines):
diff -r 25a81894c733 -r 93fd98801c7e sys/external/bsd/drm2/include/linux/hdmi.h
--- a/sys/external/bsd/drm2/include/linux/hdmi.h Sat Jul 09 17:13:04 2022 +0000
+++ b/sys/external/bsd/drm2/include/linux/hdmi.h Sat Jul 09 17:59:27 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hdmi.h,v 1.16 2022/07/09 17:13:04 riastradh Exp $ */
+/* $NetBSD: hdmi.h,v 1.17 2022/07/09 17:59:27 riastradh Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -33,11 +33,36 @@
#define _LINUX_HDMI_H_
#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/errno.h>
-#include <sys/systm.h>
+
+struct device;
-#include <lib/libkern/libkern.h>
+/* namespace */
+#define hdmi_audio_infoframe_init linux_hdmi_audio_infoframe_init
+#define hdmi_audio_infoframe_pack linux_hdmi_audio_infoframe_pack
+#define hdmi_audio_infoframe_unpack linux_hdmi_audio_infoframe_unpack
+#define hdmi_avi_infoframe_check linux_hdmi_avi_infoframe_check
+#define hdmi_avi_infoframe_pack linux_hdmi_avi_infoframe_pack
+#define hdmi_avi_infoframe_unpack linux_hdmi_avi_infoframe_unpack
+#define hdmi_drm_infoframe_check linux_hdmi_drm_infoframe_check
+#define hdmi_drm_infoframe_init linux_hdmi_drm_infoframe_init
+#define hdmi_drm_infoframe_pack linux_hdmi_drm_infoframe_pack
+#define hdmi_drm_infoframe_pack_only linux_hdmi_drm_infoframe_pack_only
+#define hdmi_drm_infoframe_unpack linux_hdmi_drm_infoframe_unpack
+#define hdmi_infoframe_checksum linux_hdmi_infoframe_checksum
+#define hdmi_infoframe_log linux_hdmi_infoframe_log
+#define hdmi_infoframe_pack linux_hdmi_infoframe_pack
+#define hdmi_infoframe_pack_only linux_hdmi_infoframe_pack_only
+#define hdmi_infoframe_set_checksum linux_hdmi_infoframe_set_checksum
+#define hdmi_infoframe_unpack linux_hdmi_infoframe_unpack
+#define hdmi_spd_infoframe_check linux_hdmi_spd_infoframe_check
+#define hdmi_spd_infoframe_init linux_hdmi_spd_infoframe_init
+#define hdmi_spd_infoframe_pack linux_hdmi_spd_infoframe_pack
+#define hdmi_spd_infoframe_unpack linux_hdmi_spd_infoframe_unpack
+#define hdmi_vendor_infoframe_check linux_hdmi_vendor_infoframe_check
+#define hdmi_vendor_infoframe_init linux_hdmi_vendor_infoframe_init
+#define hdmi_vendor_infoframe_length linux_hdmi_vendor_infoframe_length
+#define hdmi_vendor_infoframe_pack linux_hdmi_vendor_infoframe_pack
+#define hdmi_vendor_infoframe_unpack linux_hdmi_vendor_infoframe_unpack
enum hdmi_3d_structure {
HDMI_3D_STRUCTURE_INVALID = -1,
@@ -227,84 +252,6 @@
/* checksum */
};
-static inline void
-hdmi_infoframe_header_init(struct hdmi_infoframe_header *header,
- enum hdmi_infoframe_type type, uint8_t vers, uint8_t length)
-{
-
- header->type = type;
- header->version = vers;
- header->length = length;
-}
-
-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)
-{
- uint8_t *const p = buf;
-
- if (length < HDMI_INFOFRAME_HEADER_SIZE)
- return -ENOSPC;
- if (size < length)
- return -ENOSPC;
-
- p[0] = header->type;
- p[1] = header->version;
- p[2] = (length - HDMI_INFOFRAME_HEADER_SIZE);
- p[3] = 0; /* checksum */
-
- return HDMI_INFOFRAME_HEADER_SIZE;
-}
-
-static inline uint8_t
-hdmi_infoframe_checksum(const void *buf, size_t length)
-{
- const uint8_t *p = buf;
- uint8_t checksum = 0;
-
- while (length--)
- checksum += *p++;
-
- 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
struct hdmi_audio_infoframe {
struct hdmi_infoframe_header header;
@@ -318,99 +265,6 @@
bool downmix_inhibit;
};
-static inline int
-hdmi_audio_infoframe_init(struct hdmi_audio_infoframe *frame)
-{
- static const struct hdmi_audio_infoframe zero_frame;
-
- *frame = zero_frame;
-
- hdmi_infoframe_header_init(&frame->header, HDMI_INFOFRAME_TYPE_AUDIO,
- 1, HDMI_AUDIO_INFOFRAME_SIZE);
-
- return 0;
-}
-
-static inline ssize_t
-hdmi_audio_infoframe_pack(const struct hdmi_audio_infoframe *frame, void *buf,
- size_t size)
-{
- const size_t length = HDMI_INFOFRAME_HEADER_SIZE +
- HDMI_AUDIO_INFOFRAME_SIZE;
- uint8_t channels = 0;
- uint8_t *p = buf;
- int ret;
-
- KASSERT(frame->header.length == HDMI_AUDIO_INFOFRAME_SIZE);
-
- ret = hdmi_infoframe_header_pack(&frame->header, length, p, size);
- if (ret < 0)
- return ret;
- KASSERT(ret == HDMI_INFOFRAME_HEADER_SIZE);
- p += HDMI_INFOFRAME_HEADER_SIZE;
- size -= HDMI_INFOFRAME_HEADER_SIZE;
-
- if (frame->channels >= 2)
- channels = frame->channels - 1;
-
- p[0] = __SHIFTIN(frame->coding_type, __BITS(7,4));
- p[0] |= __SHIFTIN(channels, __BITS(2,0));
-
- p[1] = __SHIFTIN(frame->sample_frequency, __BITS(4,2));
- p[1] |= __SHIFTIN(frame->sample_size, __BITS(1,0));
-
- p[2] = __SHIFTIN(frame->coding_type_ext, __BITS(5,0));
-
- p[3] = __SHIFTIN(frame->level_shift_value, __BITS(6,3));
-
- p[4] = __SHIFTIN(frame->downmix_inhibit? 1 : 0, __BIT(7));
-
- /* PB6 to PB10 are reserved */
- p[5] = 0;
- p[6] = 0;
- p[7] = 0;
- p[8] = 0;
- p[9] = 0;
-
- CTASSERT(HDMI_AUDIO_INFOFRAME_SIZE == 10);
-
- 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;
@@ -433,130 +287,6 @@
uint16_t right_bar;
};
-static inline int
-hdmi_avi_infoframe_init(struct hdmi_avi_infoframe *frame)
-{
- static const struct hdmi_avi_infoframe zero_frame;
-
- *frame = zero_frame;
-
- hdmi_infoframe_header_init(&frame->header, HDMI_INFOFRAME_TYPE_AVI, 2,
- HDMI_AVI_INFOFRAME_SIZE);
-
- 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)
-{
- const size_t length = HDMI_INFOFRAME_HEADER_SIZE +
- HDMI_AVI_INFOFRAME_SIZE;
- uint8_t *p = buf;
- int ret;
-
- KASSERT(frame->header.length == HDMI_AVI_INFOFRAME_SIZE);
-
- ret = hdmi_infoframe_header_pack(&frame->header, length, p, size);
- if (ret < 0)
- return ret;
- KASSERT(ret == HDMI_INFOFRAME_HEADER_SIZE);
- p += HDMI_INFOFRAME_HEADER_SIZE;
- size -= HDMI_INFOFRAME_HEADER_SIZE;
-
- p[0] = __SHIFTIN(frame->colorspace, __BITS(6,5));
- p[0] |= __SHIFTIN(frame->active_aspect & 0xf? 1 : 0, __BIT(4));
- p[0] |= __SHIFTIN(frame->top_bar || frame->bottom_bar, __BIT(3));
- p[0] |= __SHIFTIN(frame->left_bar || frame->right_bar, __BIT(2));
- p[0] |= __SHIFTIN(frame->scan_mode, __BITS(1,0));
-
- p[1] = __SHIFTIN(frame->colorimetry, __BITS(7,6));
- p[1] |= __SHIFTIN(frame->picture_aspect, __BITS(5,4));
- p[1] |= __SHIFTIN(frame->active_aspect, __BITS(3,0));
-
- p[2] = __SHIFTIN(frame->itc? 1 : 0, __BIT(7));
- p[2] |= __SHIFTIN(frame->extended_colorimetry, __BITS(6,4));
- p[2] |= __SHIFTIN(frame->quantization_range, __BITS(3,2));
- p[2] |= __SHIFTIN(frame->nups, __BITS(1,0));
-
- p[3] = frame->video_code;
-
Home |
Main Index |
Thread Index |
Old Index