hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/video/hdmi.c
....@@ -53,18 +53,14 @@
5353 /**
5454 * hdmi_avi_infoframe_init() - initialize an HDMI AVI infoframe
5555 * @frame: HDMI AVI infoframe
56
- *
57
- * Returns 0 on success or a negative error code on failure.
5856 */
59
-int hdmi_avi_infoframe_init(struct hdmi_avi_infoframe *frame)
57
+void hdmi_avi_infoframe_init(struct hdmi_avi_infoframe *frame)
6058 {
6159 memset(frame, 0, sizeof(*frame));
6260
6361 frame->type = HDMI_INFOFRAME_TYPE_AVI;
6462 frame->version = 2;
6563 frame->length = HDMI_AVI_INFOFRAME_SIZE;
66
-
67
- return 0;
6864 }
6965 EXPORT_SYMBOL(hdmi_avi_infoframe_init);
7066
....@@ -499,7 +495,7 @@
499495 * value
500496 */
501497 frame->s3d_struct = HDMI_3D_STRUCTURE_INVALID;
502
- frame->length = 4;
498
+ frame->length = HDMI_VENDOR_INFOFRAME_SIZE;
503499
504500 return 0;
505501 }
....@@ -997,7 +993,7 @@
997993
998994 static void hdmi_infoframe_log_header(const char *level,
999995 struct device *dev,
1000
- struct hdmi_any_infoframe *frame)
996
+ const struct hdmi_any_infoframe *frame)
1001997 {
1002998 hdmi_log("HDMI infoframe: %s, version %u, length %u\n",
1003999 hdmi_infoframe_type_get_name(frame->type),
....@@ -1191,18 +1187,12 @@
11911187 return "Invalid";
11921188 }
11931189
1194
-/**
1195
- * hdmi_avi_infoframe_log() - log info of HDMI AVI infoframe
1196
- * @level: logging level
1197
- * @dev: device
1198
- * @frame: HDMI AVI infoframe
1199
- */
12001190 static void hdmi_avi_infoframe_log(const char *level,
12011191 struct device *dev,
1202
- struct hdmi_avi_infoframe *frame)
1192
+ const struct hdmi_avi_infoframe *frame)
12031193 {
12041194 hdmi_infoframe_log_header(level, dev,
1205
- (struct hdmi_any_infoframe *)frame);
1195
+ (const struct hdmi_any_infoframe *)frame);
12061196
12071197 hdmi_log(" colorspace: %s\n",
12081198 hdmi_colorspace_get_name(frame->colorspace));
....@@ -1268,20 +1258,14 @@
12681258 return "Reserved";
12691259 }
12701260
1271
-/**
1272
- * hdmi_spd_infoframe_log() - log info of HDMI SPD infoframe
1273
- * @level: logging level
1274
- * @dev: device
1275
- * @frame: HDMI SPD infoframe
1276
- */
12771261 static void hdmi_spd_infoframe_log(const char *level,
12781262 struct device *dev,
1279
- struct hdmi_spd_infoframe *frame)
1263
+ const struct hdmi_spd_infoframe *frame)
12801264 {
12811265 u8 buf[17];
12821266
12831267 hdmi_infoframe_log_header(level, dev,
1284
- (struct hdmi_any_infoframe *)frame);
1268
+ (const struct hdmi_any_infoframe *)frame);
12851269
12861270 memset(buf, 0, sizeof(buf));
12871271
....@@ -1404,18 +1388,12 @@
14041388 return "Reserved";
14051389 }
14061390
1407
-/**
1408
- * hdmi_audio_infoframe_log() - log info of HDMI AUDIO infoframe
1409
- * @level: logging level
1410
- * @dev: device
1411
- * @frame: HDMI AUDIO infoframe
1412
- */
14131391 static void hdmi_audio_infoframe_log(const char *level,
14141392 struct device *dev,
1415
- struct hdmi_audio_infoframe *frame)
1393
+ const struct hdmi_audio_infoframe *frame)
14161394 {
14171395 hdmi_infoframe_log_header(level, dev,
1418
- (struct hdmi_any_infoframe *)frame);
1396
+ (const struct hdmi_any_infoframe *)frame);
14191397
14201398 if (frame->channels)
14211399 hdmi_log(" channels: %u\n", frame->channels - 1);
....@@ -1437,12 +1415,6 @@
14371415 frame->downmix_inhibit ? "Yes" : "No");
14381416 }
14391417
1440
-/**
1441
- * hdmi_drm_infoframe_log() - log info of HDMI DRM infoframe
1442
- * @level: logging level
1443
- * @dev: device
1444
- * @frame: HDMI DRM infoframe
1445
- */
14461418 static void hdmi_drm_infoframe_log(const char *level,
14471419 struct device *dev,
14481420 const struct hdmi_drm_infoframe *frame)
....@@ -1500,21 +1472,15 @@
15001472 return "Reserved";
15011473 }
15021474
1503
-/**
1504
- * hdmi_vendor_infoframe_log() - log info of HDMI VENDOR infoframe
1505
- * @level: logging level
1506
- * @dev: device
1507
- * @frame: HDMI VENDOR infoframe
1508
- */
15091475 static void
15101476 hdmi_vendor_any_infoframe_log(const char *level,
15111477 struct device *dev,
1512
- union hdmi_vendor_any_infoframe *frame)
1478
+ const union hdmi_vendor_any_infoframe *frame)
15131479 {
1514
- struct hdmi_vendor_infoframe *hvf = &frame->hdmi;
1480
+ const struct hdmi_vendor_infoframe *hvf = &frame->hdmi;
15151481
15161482 hdmi_infoframe_log_header(level, dev,
1517
- (struct hdmi_any_infoframe *)frame);
1483
+ (const struct hdmi_any_infoframe *)frame);
15181484
15191485 if (frame->any.oui != HDMI_IEEE_OUI) {
15201486 hdmi_log(" not a HDMI vendor infoframe\n");
....@@ -1544,7 +1510,7 @@
15441510 */
15451511 void hdmi_infoframe_log(const char *level,
15461512 struct device *dev,
1547
- union hdmi_infoframe *frame)
1513
+ const union hdmi_infoframe *frame)
15481514 {
15491515 switch (frame->any.type) {
15501516 case HDMI_INFOFRAME_TYPE_AVI:
....@@ -1583,7 +1549,6 @@
15831549 const void *buffer, size_t size)
15841550 {
15851551 const u8 *ptr = buffer;
1586
- int ret;
15871552
15881553 if (size < HDMI_INFOFRAME_SIZE(AVI))
15891554 return -EINVAL;
....@@ -1596,9 +1561,7 @@
15961561 if (hdmi_infoframe_checksum(buffer, HDMI_INFOFRAME_SIZE(AVI)) != 0)
15971562 return -EINVAL;
15981563
1599
- ret = hdmi_avi_infoframe_init(frame);
1600
- if (ret)
1601
- return ret;
1564
+ hdmi_avi_infoframe_init(frame);
16021565
16031566 ptr += HDMI_INFOFRAME_HEADER_SIZE;
16041567
....@@ -1805,20 +1768,21 @@
18051768 }
18061769
18071770 /**
1808
- * hdmi_drm_infoframe_unpack() - unpack binary buffer to a HDMI DRM infoframe
1771
+ * hdmi_drm_infoframe_unpack_only() - unpack binary buffer of CTA-861-G DRM
1772
+ * infoframe DataBytes to a HDMI DRM
1773
+ * infoframe
18091774 * @frame: HDMI DRM infoframe
18101775 * @buffer: source buffer
18111776 * @size: size of buffer
18121777 *
1813
- * Unpacks the information contained in binary @buffer into a structured
1814
- * @frame of the HDMI Dynamic Range and Mastering (DRM) information frame.
1815
- * Also verifies the checksum as required by section 5.3.5 of the HDMI 1.4
1816
- * specification.
1778
+ * Unpacks CTA-861-G DRM infoframe DataBytes contained in the binary @buffer
1779
+ * into a structured @frame of the HDMI Dynamic Range and Mastering (DRM)
1780
+ * infoframe.
18171781 *
18181782 * Returns 0 on success or a negative error code on failure.
18191783 */
1820
-static int hdmi_drm_infoframe_unpack(struct hdmi_drm_infoframe *frame,
1821
- const void *buffer, size_t size)
1784
+int hdmi_drm_infoframe_unpack_only(struct hdmi_drm_infoframe *frame,
1785
+ const void *buffer, size_t size)
18221786 {
18231787 const u8 *ptr = buffer;
18241788 const u8 *temp;
....@@ -1827,22 +1791,12 @@
18271791 int ret;
18281792 int i;
18291793
1830
- if (size < HDMI_INFOFRAME_SIZE(DRM))
1831
- return -EINVAL;
1832
-
1833
- if (ptr[0] != HDMI_INFOFRAME_TYPE_DRM ||
1834
- ptr[1] != 1 ||
1835
- ptr[2] != HDMI_DRM_INFOFRAME_SIZE)
1836
- return -EINVAL;
1837
-
1838
- if (hdmi_infoframe_checksum(buffer, HDMI_INFOFRAME_SIZE(DRM)) != 0)
1794
+ if (size < HDMI_DRM_INFOFRAME_SIZE)
18391795 return -EINVAL;
18401796
18411797 ret = hdmi_drm_infoframe_init(frame);
18421798 if (ret)
18431799 return ret;
1844
-
1845
- ptr += HDMI_INFOFRAME_HEADER_SIZE;
18461800
18471801 frame->eotf = ptr[0] & 0x7;
18481802 frame->metadata_type = ptr[1] & 0x7;
....@@ -1851,7 +1805,7 @@
18511805 for (i = 0; i < 3; i++) {
18521806 x_lsb = *temp++;
18531807 x_msb = *temp++;
1854
- frame->display_primaries[i].x = (x_msb << 8) | x_lsb;
1808
+ frame->display_primaries[i].x = (x_msb << 8) | x_lsb;
18551809 y_lsb = *temp++;
18561810 y_msb = *temp++;
18571811 frame->display_primaries[i].y = (y_msb << 8) | y_lsb;
....@@ -1867,6 +1821,42 @@
18671821
18681822 return 0;
18691823 }
1824
+EXPORT_SYMBOL(hdmi_drm_infoframe_unpack_only);
1825
+
1826
+/**
1827
+ * hdmi_drm_infoframe_unpack() - unpack binary buffer to a HDMI DRM infoframe
1828
+ * @frame: HDMI DRM infoframe
1829
+ * @buffer: source buffer
1830
+ * @size: size of buffer
1831
+ *
1832
+ * Unpacks the CTA-861-G DRM infoframe contained in the binary @buffer into
1833
+ * a structured @frame of the HDMI Dynamic Range and Mastering (DRM)
1834
+ * infoframe. It also verifies the checksum as required by section 5.3.5 of
1835
+ * the HDMI 1.4 specification.
1836
+ *
1837
+ * Returns 0 on success or a negative error code on failure.
1838
+ */
1839
+static int hdmi_drm_infoframe_unpack(struct hdmi_drm_infoframe *frame,
1840
+ const void *buffer, size_t size)
1841
+{
1842
+ const u8 *ptr = buffer;
1843
+ int ret;
1844
+
1845
+ if (size < HDMI_INFOFRAME_SIZE(DRM))
1846
+ return -EINVAL;
1847
+
1848
+ if (ptr[0] != HDMI_INFOFRAME_TYPE_DRM ||
1849
+ ptr[1] != 1 ||
1850
+ ptr[2] != HDMI_DRM_INFOFRAME_SIZE)
1851
+ return -EINVAL;
1852
+
1853
+ if (hdmi_infoframe_checksum(buffer, HDMI_INFOFRAME_SIZE(DRM)) != 0)
1854
+ return -EINVAL;
1855
+
1856
+ ret = hdmi_drm_infoframe_unpack_only(frame, ptr + HDMI_INFOFRAME_HEADER_SIZE,
1857
+ size - HDMI_INFOFRAME_HEADER_SIZE);
1858
+ return ret;
1859
+}
18701860
18711861 /**
18721862 * hdmi_infoframe_unpack() - unpack binary buffer to a HDMI infoframe