Skip to contentSkip to conversation

drm/edid: split out drm_eld.[ch], add some SAD helpers

PATCH Superseded Jani Nikula 5 participants 21 messages Sep 7, 2023 – Sep 26, 2023

Subsystems (12)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover drm/edid: split out drm_eld.[ch], add some SAD helpers

Split out drm_eld.[ch] from drm_edid.h, add some helpers to convert and modify SADs.

This should make it easier and more robust to implement things like [1], with ELD parsing details hidden in drm_eld.[ch].

	for (i = 0; i < drm_eld_sad_count(eld); i++) {
		struct cea_sad sad;

		drm_eld_sad_get(eld, i, &sad);
		/* do stuff with sad */
		drm_eld_sad_set(eld, i, &sad);
	}

struct cea_sad provides an easier way to manipulate CTA SADs.

** UNTESTED ***

Cc Mitul Golani <[email protected]>

[1] https://patchwork.freedesktop.org/patch/msgid/[email protected]

Jani Nikula (6):
drm/edid: split out drm_eld.h from drm_edid.h
drm/eld: replace uint8_t with u8
drm/edid: include drm_eld.h only where required drm/edid: use a temp variable for sads to drop one level of
dereferences
drm/edid: add helpers to get/set struct cea_sad from/to 3-byte sad drm/eld: add helpers to modify the SADs of an ELD

 Documentation/gpu/drm-kms-helpers.rst         |   6 +
 drivers/gpu/drm/Makefile                      |   1 +
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |   1 +
 drivers/gpu/drm/drm_edid.c                    |  42 +++--
 drivers/gpu/drm/drm_eld.c                     |  55 ++++++
 drivers/gpu/drm/drm_internal.h                |   6 +
 drivers/gpu/drm/i915/display/intel_audio.c    |   1 +
 .../drm/i915/display/intel_crtc_state_dump.c  |   1 +
 drivers/gpu/drm/i915/display/intel_sdvo.c     |   1 +
 drivers/gpu/drm/nouveau/dispnv50/disp.c       |   1 +
 drivers/gpu/drm/radeon/radeon_audio.c         |   1 +
 drivers/gpu/drm/tegra/hdmi.c                  |   1 +
 drivers/gpu/drm/tegra/sor.c                   |   1 +
 include/drm/drm_edid.h                        | 148 ----------------
 include/drm/drm_eld.h                         | 164 ++++++++++++++++++
 sound/core/pcm_drm_eld.c                      |   1 +
 sound/soc/codecs/hdac_hdmi.c                  |   1 +
 sound/soc/codecs/hdmi-codec.c                 |   1 +
 sound/x86/intel_hdmi_audio.c                  |   1 +
 19 files changed, 274 insertions(+), 160 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_eld.c
 create mode 100644 include/drm/drm_eld.h
Signature · 1 line
2.39.2
#1 lore raw

PATCH 1/6 drm/edid: split out drm_eld.h from drm_edid.h

The drm_edid.[ch] files are starting to be a bit crowded, and with plans to add more ELD related functionality, it's perhaps cleanest to split the ELD code out to a header of its own.

Include drm_eld.h from drm_edid.h for starters, and leave it to follow-up work to only include drm_eld.h where needed.

---
 Documentation/gpu/drm-kms-helpers.rst |   3 +
 include/drm/drm_edid.h                | 149 +-----------------------
 include/drm/drm_eld.h                 | 159 ++++++++++++++++++++++++++
 3 files changed, 163 insertions(+), 148 deletions(-)
 create mode 100644 include/drm/drm_eld.h
Documentation/gpu/drm-kms-helpers.rst +3 -0
index b8ab05e42dbb..f0f93aa62545 100644
@@ -363,6 +363,9 @@ EDID Helper Functions Reference
 .. kernel-doc:: drivers/gpu/drm/drm_edid.c
    :export:
 
+.. kernel-doc:: include/drm/drm_eld.h
+   :internal:
+
 SCDC Helper Functions Reference
 ===============================
 
include/drm/drm_edid.h +1 -148

167 lines not on this page · raw message

include/drm/drm_eld.h new file +159 -0

159 lines not on this page · raw message

Signature · 1 line
2.39.2
Reviewed-by on v1 1/6
#2 lore raw

RE: [PATCH 1/6] drm/edid: split out drm_eld.h from drm_edid.h

Quoted 386 lines

-----Original Message-----
From: Nikula, Jani <[email protected]>
Sent: Thursday, September 7, 2023 2:58 PM
To: [email protected]
Cc: [email protected]; Nikula, Jani <[email protected]>; Golani, Mitulkumar Ajitkumar <[email protected]>
Subject: [PATCH 1/6] drm/edid: split out drm_eld.h from drm_edid.h

The drm_edid.[ch] files are starting to be a bit crowded, and with plans to add more ELD related functionality, it's perhaps cleanest to split the ELD code out to a header of its own.

Include drm_eld.h from drm_edid.h for starters, and leave it to follow-up work to only include drm_eld.h where needed.

---
 Documentation/gpu/drm-kms-helpers.rst |   3 +
 include/drm/drm_edid.h                | 149 +-----------------------
 include/drm/drm_eld.h                 | 159 ++++++++++++++++++++++++++
 3 files changed, 163 insertions(+), 148 deletions(-)  create mode 100644

include/drm/drm_eld.h

Documentation/gpu/drm-kms-helpers.rst +0 -0
index b8ab05e42dbb..f0f93aa62545 100644
@@ -363,6 +363,9 @@ EDID Helper Functions Reference  .. kernel-doc::

drivers/gpu/drm/drm_edid.c
:export:

+.. kernel-doc:: include/drm/drm_eld.h

Documentation/gpu/drm-kms-helpers.rst +2 -0
+   :internal:
+
 SCDC Helper Functions Reference
 ===============================
include/drm/drm_edid.h index renamed from include/drm/drm_edid.h +0 -0

882d2638708e..1ff52f57ab9c 100644

include/drm/drm_edid.h +2 -7
@@ -25,6 +25,7 @@
 
 #include <linux/types.h>
 #include <linux/hdmi.h>
+#include <drm/drm_eld.h> /* FIXME: remove this, include directly where
+needed */
 #include <drm/drm_mode.h>
 
 struct drm_device;
@@ -269,64 +270,6 @@ struct detailed_timing {
 #define DRM_EDID_DSC_MAX_SLICES			0xf
 #define DRM_EDID_DSC_TOTAL_CHUNK_KBYTES		0x3f
 
-/* ELD Header Block */
-#define DRM_ELD_HEADER_BLOCK_SIZE	4
-
-#define DRM_ELD_VER			0
-# define DRM_ELD_VER_SHIFT		3
-# define DRM_ELD_VER_MASK		(0x1f << 3)
-# define DRM_ELD_VER_CEA861D		(2 << 3) /* supports 861D or

below */

include/drm/drm_edid.h +0 -26
-# define DRM_ELD_VER_CANNED		(0x1f << 3)
-
-#define DRM_ELD_BASELINE_ELD_LEN	2	/* in dwords! */
-
-/* ELD Baseline Block for ELD_Ver == 2 */
-#define DRM_ELD_CEA_EDID_VER_MNL	4
-# define DRM_ELD_CEA_EDID_VER_SHIFT	5
-# define DRM_ELD_CEA_EDID_VER_MASK	(7 << 5)
-# define DRM_ELD_CEA_EDID_VER_NONE	(0 << 5)
-# define DRM_ELD_CEA_EDID_VER_CEA861	(1 << 5)
-# define DRM_ELD_CEA_EDID_VER_CEA861A	(2 << 5)
-# define DRM_ELD_CEA_EDID_VER_CEA861BCD	(3 << 5)
-# define DRM_ELD_MNL_SHIFT		0
-# define DRM_ELD_MNL_MASK		(0x1f << 0)
-
-#define DRM_ELD_SAD_COUNT_CONN_TYPE	5
-# define DRM_ELD_SAD_COUNT_SHIFT	4
-# define DRM_ELD_SAD_COUNT_MASK		(0xf << 4)
-# define DRM_ELD_CONN_TYPE_SHIFT	2
-# define DRM_ELD_CONN_TYPE_MASK		(3 << 2)
-# define DRM_ELD_CONN_TYPE_HDMI		(0 << 2)
-# define DRM_ELD_CONN_TYPE_DP		(1 << 2)
-# define DRM_ELD_SUPPORTS_AI		(1 << 1)
-# define DRM_ELD_SUPPORTS_HDCP		(1 << 0)
-
-#define DRM_ELD_AUD_SYNCH_DELAY		6	/* in units of

2 ms */

include/drm/drm_edid.h +0 -13
-# define DRM_ELD_AUD_SYNCH_DELAY_MAX	0xfa	/* 500 ms */
-
-#define DRM_ELD_SPEAKER			7
-# define DRM_ELD_SPEAKER_MASK		0x7f
-# define DRM_ELD_SPEAKER_RLRC		(1 << 6)
-# define DRM_ELD_SPEAKER_FLRC		(1 << 5)
-# define DRM_ELD_SPEAKER_RC		(1 << 4)
-# define DRM_ELD_SPEAKER_RLR		(1 << 3)
-# define DRM_ELD_SPEAKER_FC		(1 << 2)
-# define DRM_ELD_SPEAKER_LFE		(1 << 1)
-# define DRM_ELD_SPEAKER_FLR		(1 << 0)
-
-#define DRM_ELD_PORT_ID			8	/* offsets 8..15

inclusive */

include/drm/drm_edid.h +0 -9
-# define DRM_ELD_PORT_ID_LEN		8
-
-#define DRM_ELD_MANUFACTURER_NAME0	16
-#define DRM_ELD_MANUFACTURER_NAME1	17
-
-#define DRM_ELD_PRODUCT_CODE0		18
-#define DRM_ELD_PRODUCT_CODE1		19
-
-#define DRM_ELD_MONITOR_NAME_STRING	20	/* offsets

20..(20+mnl-1) inclusive */

include/drm/drm_edid.h +0 -19
-
-#define DRM_ELD_CEA_SAD(mnl, sad)	(20 + (mnl) + 3 * (sad))
-
 struct edid {
 	u8 header[8];
 	/* Vendor & product info */
@@ -409,96 +352,6 @@ drm_hdmi_avi_infoframe_quant_range(struct
 hdmi_avi_infoframe *frame,
 				   const struct drm_display_mode *mode,
 				   enum hdmi_quantization_range
 rgb_quant_range);
 
-/**
- * drm_eld_mnl - Get ELD monitor name length in bytes.
- * @eld: pointer to an eld memory structure with mnl set
- */
-static inline int drm_eld_mnl(const uint8_t *eld) -{
-	return (eld[DRM_ELD_CEA_EDID_VER_MNL] &
 DRM_ELD_MNL_MASK) >> DRM_ELD_MNL_SHIFT;
-}
-
-/**
- * drm_eld_sad - Get ELD SAD structures.
- * @eld: pointer to an eld memory structure with sad_count set
- */
-static inline const uint8_t *drm_eld_sad(const uint8_t *eld) -{
-	unsigned int ver, mnl;
-
-	ver = (eld[DRM_ELD_VER] & DRM_ELD_VER_MASK) >>

DRM_ELD_VER_SHIFT;

include/drm/drm_edid.h +0 -16
-	if (ver != 2 && ver != 31)
-		return NULL;
-
-	mnl = drm_eld_mnl(eld);
-	if (mnl > 16)
-		return NULL;
-
-	return eld + DRM_ELD_CEA_SAD(mnl, 0);
-}
-
-/**
- * drm_eld_sad_count - Get ELD SAD count.
- * @eld: pointer to an eld memory structure with sad_count set
- */
-static inline int drm_eld_sad_count(const uint8_t *eld) -{
-	return (eld[DRM_ELD_SAD_COUNT_CONN_TYPE] &

DRM_ELD_SAD_COUNT_MASK) >>

include/drm/drm_edid.h +0 -12
-		DRM_ELD_SAD_COUNT_SHIFT;
-}
-
-/**
- * drm_eld_calc_baseline_block_size - Calculate baseline block size in bytes
- * @eld: pointer to an eld memory structure with mnl and sad_count set
- *
- * This is a helper for determining the payload size of the baseline block, in
- * bytes, for e.g. setting the Baseline_ELD_Len field in the ELD header block.
- */
-static inline int drm_eld_calc_baseline_block_size(const uint8_t *eld) -{
-	return DRM_ELD_MONITOR_NAME_STRING -

DRM_ELD_HEADER_BLOCK_SIZE +

include/drm/drm_edid.h +0 -15
-		drm_eld_mnl(eld) + drm_eld_sad_count(eld) * 3;
-}
-
-/**
- * drm_eld_size - Get ELD size in bytes
- * @eld: pointer to a complete eld memory structure
- *
- * The returned value does not include the vendor block. It's vendor specific,
- * and comprises of the remaining bytes in the ELD memory buffer after
- * drm_eld_size() bytes of header and baseline block.
- *
- * The returned value is guaranteed to be a multiple of 4.
- */
-static inline int drm_eld_size(const uint8_t *eld) -{
-	return DRM_ELD_HEADER_BLOCK_SIZE +

eld[DRM_ELD_BASELINE_ELD_LEN] * 4;

include/drm/drm_edid.h +0 -7
-}
-
-/**
- * drm_eld_get_spk_alloc - Get speaker allocation
- * @eld: pointer to an ELD memory structure
- *
- * The returned value is the speakers mask. User has to use

%DRM_ELD_SPEAKER
- * field definitions to identify speakers.
- */

include/drm/drm_edid.h +0 -9
-static inline u8 drm_eld_get_spk_alloc(const uint8_t *eld) -{
-	return eld[DRM_ELD_SPEAKER] & DRM_ELD_SPEAKER_MASK;
-}
-
-/**
- * drm_eld_get_conn_type - Get device type hdmi/dp connected
- * @eld: pointer to an ELD memory structure
- *
- * The caller need to use %DRM_ELD_CONN_TYPE_HDMI or

%DRM_ELD_CONN_TYPE_DP to
- * identify the display type connected.
- */

include/drm/drm_edid.h +0 -2
-static inline u8 drm_eld_get_conn_type(const uint8_t *eld) -{
-	return eld[DRM_ELD_SAD_COUNT_CONN_TYPE] &

DRM_ELD_CONN_TYPE_MASK;

include/drm/drm_edid.h +0 -2
-}
-
 /**
  * drm_edid_decode_mfg_id - Decode the manufacturer ID
  * @mfg_id: The manufacturer ID
include/drm/drm_eld.h new file mode renamed from include/drm/drm_eld.h +0 -0

100644 index 000000000000..9bde89bd96ea

include/drm/drm_eld.h new file +17 -0
@@ -0,0 +1,159 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2023 Intel Corporation
+ */
+
+#ifndef __DRM_ELD_H__
+#define __DRM_ELD_H__
+
+#include <linux/types.h>
+
+/* ELD Header Block */
+#define DRM_ELD_HEADER_BLOCK_SIZE	4
+
+#define DRM_ELD_VER			0
+# define DRM_ELD_VER_SHIFT		3
+# define DRM_ELD_VER_MASK		(0x1f << 3)
+# define DRM_ELD_VER_CEA861D		(2 << 3) /* supports 861D or

below */

include/drm/drm_eld.h new file +26 -0
+# define DRM_ELD_VER_CANNED		(0x1f << 3)
+
+#define DRM_ELD_BASELINE_ELD_LEN	2	/* in dwords! */
+
+/* ELD Baseline Block for ELD_Ver == 2 */
+#define DRM_ELD_CEA_EDID_VER_MNL	4
+# define DRM_ELD_CEA_EDID_VER_SHIFT	5
+# define DRM_ELD_CEA_EDID_VER_MASK	(7 << 5)
+# define DRM_ELD_CEA_EDID_VER_NONE	(0 << 5)
+# define DRM_ELD_CEA_EDID_VER_CEA861	(1 << 5)
+# define DRM_ELD_CEA_EDID_VER_CEA861A	(2 << 5)
+# define DRM_ELD_CEA_EDID_VER_CEA861BCD	(3 << 5)
+# define DRM_ELD_MNL_SHIFT		0
+# define DRM_ELD_MNL_MASK		(0x1f << 0)
+
+#define DRM_ELD_SAD_COUNT_CONN_TYPE	5
+# define DRM_ELD_SAD_COUNT_SHIFT	4
+# define DRM_ELD_SAD_COUNT_MASK		(0xf << 4)
+# define DRM_ELD_CONN_TYPE_SHIFT	2
+# define DRM_ELD_CONN_TYPE_MASK		(3 << 2)
+# define DRM_ELD_CONN_TYPE_HDMI		(0 << 2)
+# define DRM_ELD_CONN_TYPE_DP		(1 << 2)
+# define DRM_ELD_SUPPORTS_AI		(1 << 1)
+# define DRM_ELD_SUPPORTS_HDCP		(1 << 0)
+
+#define DRM_ELD_AUD_SYNCH_DELAY		6	/* in units of

2 ms */

include/drm/drm_eld.h new file +13 -0
+# define DRM_ELD_AUD_SYNCH_DELAY_MAX	0xfa	/* 500 ms */
+
+#define DRM_ELD_SPEAKER			7
+# define DRM_ELD_SPEAKER_MASK		0x7f
+# define DRM_ELD_SPEAKER_RLRC		(1 << 6)
+# define DRM_ELD_SPEAKER_FLRC		(1 << 5)
+# define DRM_ELD_SPEAKER_RC		(1 << 4)
+# define DRM_ELD_SPEAKER_RLR		(1 << 3)
+# define DRM_ELD_SPEAKER_FC		(1 << 2)
+# define DRM_ELD_SPEAKER_LFE		(1 << 1)
+# define DRM_ELD_SPEAKER_FLR		(1 << 0)
+
+#define DRM_ELD_PORT_ID			8	/* offsets 8..15

inclusive */

include/drm/drm_eld.h new file +9 -0
+# define DRM_ELD_PORT_ID_LEN		8
+
+#define DRM_ELD_MANUFACTURER_NAME0	16
+#define DRM_ELD_MANUFACTURER_NAME1	17
+
+#define DRM_ELD_PRODUCT_CODE0		18
+#define DRM_ELD_PRODUCT_CODE1		19
+
+#define DRM_ELD_MONITOR_NAME_STRING	20	/* offsets

20..(20+mnl-1) inclusive */

include/drm/drm_eld.h new file +8 -0
+
+#define DRM_ELD_CEA_SAD(mnl, sad)	(20 + (mnl) + 3 * (sad))
+
+/**
+ * drm_eld_mnl - Get ELD monitor name length in bytes.
+ * @eld: pointer to an eld memory structure with mnl set  */ static
+inline int drm_eld_mnl(const uint8_t *eld) {
+	return (eld[DRM_ELD_CEA_EDID_VER_MNL] &

DRM_ELD_MNL_MASK) >>

include/drm/drm_eld.h new file +9 -0
+DRM_ELD_MNL_SHIFT; }
+
+/**
+ * drm_eld_sad - Get ELD SAD structures.
+ * @eld: pointer to an eld memory structure with sad_count set  */
+static inline const uint8_t *drm_eld_sad(const uint8_t *eld) {
+	unsigned int ver, mnl;
+
+	ver = (eld[DRM_ELD_VER] & DRM_ELD_VER_MASK) >>

DRM_ELD_VER_SHIFT;

include/drm/drm_eld.h new file +15 -0
+	if (ver != 2 && ver != 31)
+		return NULL;
+
+	mnl = drm_eld_mnl(eld);
+	if (mnl > 16)
+		return NULL;
+
+	return eld + DRM_ELD_CEA_SAD(mnl, 0);
+}
+
+/**
+ * drm_eld_sad_count - Get ELD SAD count.
+ * @eld: pointer to an eld memory structure with sad_count set  */
+static inline int drm_eld_sad_count(const uint8_t *eld) {
+	return (eld[DRM_ELD_SAD_COUNT_CONN_TYPE] &

DRM_ELD_SAD_COUNT_MASK) >>

include/drm/drm_eld.h new file +15 -0
+		DRM_ELD_SAD_COUNT_SHIFT;
+}
+
+/**
+ * drm_eld_calc_baseline_block_size - Calculate baseline block size in
+bytes
+ * @eld: pointer to an eld memory structure with mnl and sad_count set
+ *
+ * This is a helper for determining the payload size of the baseline
+block, in
+ * bytes, for e.g. setting the Baseline_ELD_Len field in the ELD header block.
+ */
+static inline int drm_eld_calc_baseline_block_size(const uint8_t *eld)
+{
+	return DRM_ELD_MONITOR_NAME_STRING -

DRM_ELD_HEADER_BLOCK_SIZE +

include/drm/drm_eld.h new file +15 -0
+		drm_eld_mnl(eld) + drm_eld_sad_count(eld) * 3; }
+
+/**
+ * drm_eld_size - Get ELD size in bytes
+ * @eld: pointer to a complete eld memory structure
+ *
+ * The returned value does not include the vendor block. It's vendor
+specific,
+ * and comprises of the remaining bytes in the ELD memory buffer after
+ * drm_eld_size() bytes of header and baseline block.
+ *
+ * The returned value is guaranteed to be a multiple of 4.
+ */
+static inline int drm_eld_size(const uint8_t *eld) {
+	return DRM_ELD_HEADER_BLOCK_SIZE +

eld[DRM_ELD_BASELINE_ELD_LEN] * 4;

include/drm/drm_eld.h new file +23 -0
+}
+
+/**
+ * drm_eld_get_spk_alloc - Get speaker allocation
+ * @eld: pointer to an ELD memory structure
+ *
+ * The returned value is the speakers mask. User has to use
+%DRM_ELD_SPEAKER
+ * field definitions to identify speakers.
+ */
+static inline u8 drm_eld_get_spk_alloc(const uint8_t *eld) {
+	return eld[DRM_ELD_SPEAKER] & DRM_ELD_SPEAKER_MASK; }
+
+/**
+ * drm_eld_get_conn_type - Get device type hdmi/dp connected
+ * @eld: pointer to an ELD memory structure
+ *
+ * The caller need to use %DRM_ELD_CONN_TYPE_HDMI or
+%DRM_ELD_CONN_TYPE_DP to
+ * identify the display type connected.
+ */
+static inline u8 drm_eld_get_conn_type(const uint8_t *eld) {
+	return eld[DRM_ELD_SAD_COUNT_CONN_TYPE] &

DRM_ELD_CONN_TYPE_MASK; }

include/drm/drm_eld.h

Quoted 2 lines
include/drm/drm_eld.h new file +2 -0
+
+#endif /* __DRM_ELD_H__ */

The commit splits drm_eld.h from drm_edid.h and commit message is also aligned to that.

Changes LGTM.

Quoted 2 lines

--
2.39.2

#3 lore raw

PATCH 2/6 drm/eld: replace uint8_t with u8

In reply to Jani Nikula

Unify on kernel types.

---
 include/drm/drm_eld.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
include/drm/drm_eld.h +7 -7
index 9bde89bd96ea..7b674256b9aa 100644
@@ -70,7 +70,7 @@
  * drm_eld_mnl - Get ELD monitor name length in bytes.
  * @eld: pointer to an eld memory structure with mnl set
  */
-static inline int drm_eld_mnl(const uint8_t *eld)
+static inline int drm_eld_mnl(const u8 *eld)
 {
 	return (eld[DRM_ELD_CEA_EDID_VER_MNL] & DRM_ELD_MNL_MASK) >> DRM_ELD_MNL_SHIFT;
 }
@@ -79,7 +79,7 @@ static inline int drm_eld_mnl(const uint8_t *eld)
  * drm_eld_sad - Get ELD SAD structures.
  * @eld: pointer to an eld memory structure with sad_count set
  */
-static inline const uint8_t *drm_eld_sad(const uint8_t *eld)
+static inline const u8 *drm_eld_sad(const u8 *eld)
 {
 	unsigned int ver, mnl;
 
@@ -98,7 +98,7 @@ static inline const uint8_t *drm_eld_sad(const uint8_t *eld)
  * drm_eld_sad_count - Get ELD SAD count.
  * @eld: pointer to an eld memory structure with sad_count set
  */
-static inline int drm_eld_sad_count(const uint8_t *eld)
+static inline int drm_eld_sad_count(const u8 *eld)
 {
 	return (eld[DRM_ELD_SAD_COUNT_CONN_TYPE] & DRM_ELD_SAD_COUNT_MASK) >>
 		DRM_ELD_SAD_COUNT_SHIFT;
@@ -111,7 +111,7 @@ static inline int drm_eld_sad_count(const uint8_t *eld)
  * This is a helper for determining the payload size of the baseline block, in
  * bytes, for e.g. setting the Baseline_ELD_Len field in the ELD header block.
  */
-static inline int drm_eld_calc_baseline_block_size(const uint8_t *eld)
+static inline int drm_eld_calc_baseline_block_size(const u8 *eld)
 {
 	return DRM_ELD_MONITOR_NAME_STRING - DRM_ELD_HEADER_BLOCK_SIZE +
 		drm_eld_mnl(eld) + drm_eld_sad_count(eld) * 3;
@@ -127,7 +127,7 @@ static inline int drm_eld_calc_baseline_block_size(const uint8_t *eld)
  *
  * The returned value is guaranteed to be a multiple of 4.
  */
-static inline int drm_eld_size(const uint8_t *eld)
+static inline int drm_eld_size(const u8 *eld)
 {
 	return DRM_ELD_HEADER_BLOCK_SIZE + eld[DRM_ELD_BASELINE_ELD_LEN] * 4;
 }
@@ -139,7 +139,7 @@ static inline int drm_eld_size(const uint8_t *eld)
  * The returned value is the speakers mask. User has to use %DRM_ELD_SPEAKER
  * field definitions to identify speakers.
  */
-static inline u8 drm_eld_get_spk_alloc(const uint8_t *eld)
+static inline u8 drm_eld_get_spk_alloc(const u8 *eld)
 {
 	return eld[DRM_ELD_SPEAKER] & DRM_ELD_SPEAKER_MASK;
 }
@@ -151,7 +151,7 @@ static inline u8 drm_eld_get_spk_alloc(const uint8_t *eld)
  * The caller need to use %DRM_ELD_CONN_TYPE_HDMI or %DRM_ELD_CONN_TYPE_DP to
  * identify the display type connected.
  */
-static inline u8 drm_eld_get_conn_type(const uint8_t *eld)
+static inline u8 drm_eld_get_conn_type(const u8 *eld)
 {
 	return eld[DRM_ELD_SAD_COUNT_CONN_TYPE] & DRM_ELD_CONN_TYPE_MASK;
 }
Signature · 1 line
2.39.2
Reviewed-by on v1 2/6
#4 lore raw

RE: [Intel-gfx] [PATCH 2/6] drm/eld: replace uint8_t with u8

Quoted 10 lines

-----Original Message-----
From: Intel-gfx <[email protected]> On Behalf Of Jani Nikula
Sent: Thursday, September 7, 2023 2:58 PM
To: [email protected]
Cc: Nikula, Jani <[email protected]>; [email protected]
Subject: [Intel-gfx] [PATCH 2/6] drm/eld: replace uint8_t with u8

Quoted 4 lines

Unify on kernel types.

LGTM

Quoted 78 lines
---
 include/drm/drm_eld.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
include/drm/drm_eld.h index renamed from include/drm/drm_eld.h +0 -0

9bde89bd96ea..7b674256b9aa 100644

include/drm/drm_eld.h +1 -1
@@ -70,7 +70,7 @@
  * drm_eld_mnl - Get ELD monitor name length in bytes.
  * @eld: pointer to an eld memory structure with mnl set
  */
-static inline int drm_eld_mnl(const uint8_t *eld)
+static inline int drm_eld_mnl(const u8 *eld)
 {
      return (eld[DRM_ELD_CEA_EDID_VER_MNL] &

DRM_ELD_MNL_MASK) >> DRM_ELD_MNL_SHIFT; } @@ -79,7 +79,7 @@ static inline int drm_eld_mnl(const uint8_t *eld)
* drm_eld_sad - Get ELD SAD structures.
* @eld: pointer to an eld memory structure with sad_count set */

include/drm/drm_eld.h +2 -2
-static inline const uint8_t *drm_eld_sad(const uint8_t *eld)
+static inline const u8 *drm_eld_sad(const u8 *eld)
 {
      unsigned int ver, mnl;
@@ -98,7 +98,7 @@ static inline const uint8_t *drm_eld_sad(const uint8_t
 *eld)
  * drm_eld_sad_count - Get ELD SAD count.
  * @eld: pointer to an eld memory structure with sad_count set
  */
-static inline int drm_eld_sad_count(const uint8_t *eld)
+static inline int drm_eld_sad_count(const u8 *eld)
 {
      return (eld[DRM_ELD_SAD_COUNT_CONN_TYPE] &

DRM_ELD_SAD_COUNT_MASK) >>

              DRM_ELD_SAD_COUNT_SHIFT;
include/drm/drm_eld.h +1 -1
@@ -111,7 +111,7 @@ static inline int drm_eld_sad_count(const uint8_t *eld)
  * This is a helper for determining the payload size of the baseline block, in
  * bytes, for e.g. setting the Baseline_ELD_Len field in the ELD header block.
  */
-static inline int drm_eld_calc_baseline_block_size(const uint8_t *eld)
+static inline int drm_eld_calc_baseline_block_size(const u8 *eld)
 {
      return DRM_ELD_MONITOR_NAME_STRING -

DRM_ELD_HEADER_BLOCK_SIZE +

              drm_eld_mnl(eld) + drm_eld_sad_count(eld) * 3; @@ -127,7

+127,7 @@ static inline int drm_eld_calc_baseline_block_size(const uint8_t *eld)
*
* The returned value is guaranteed to be a multiple of 4.
*/

include/drm/drm_eld.h +1 -1
-static inline int drm_eld_size(const uint8_t *eld)
+static inline int drm_eld_size(const u8 *eld)
 {
      return DRM_ELD_HEADER_BLOCK_SIZE +

eld[DRM_ELD_BASELINE_ELD_LEN] * 4; } @@ -139,7 +139,7 @@ static inline int drm_eld_size(const uint8_t *eld)
* The returned value is the speakers mask. User has to use
%DRM_ELD_SPEAKER
* field definitions to identify speakers.
*/

include/drm/drm_eld.h +1 -1
-static inline u8 drm_eld_get_spk_alloc(const uint8_t *eld)
+static inline u8 drm_eld_get_spk_alloc(const u8 *eld)
 {
      return eld[DRM_ELD_SPEAKER] & DRM_ELD_SPEAKER_MASK;  } @@ -

151,7 +151,7 @@ static inline u8 drm_eld_get_spk_alloc(const uint8_t *eld)
* The caller need to use %DRM_ELD_CONN_TYPE_HDMI or
%DRM_ELD_CONN_TYPE_DP to
* identify the display type connected.
*/

include/drm/drm_eld.h +1 -1
-static inline u8 drm_eld_get_conn_type(const uint8_t *eld)
+static inline u8 drm_eld_get_conn_type(const u8 *eld)
 {
      return eld[DRM_ELD_SAD_COUNT_CONN_TYPE] &

DRM_ELD_CONN_TYPE_MASK; }
--
2.39.2

Reviewed-by on v1 2/6
#5 lore raw

RE: [PATCH 2/6] drm/eld: replace uint8_t with u8

In reply to Jani Nikula
Quoted 86 lines

-----Original Message-----
From: Nikula, Jani <[email protected]>
Sent: Thursday, September 7, 2023 2:58 PM
To: [email protected]
Cc: [email protected]; Nikula, Jani <[email protected]>; Golani, Mitulkumar Ajitkumar <[email protected]>
Subject: [PATCH 2/6] drm/eld: replace uint8_t with u8

Unify on kernel types.

---
 include/drm/drm_eld.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
include/drm/drm_eld.h index renamed from include/drm/drm_eld.h +0 -0

9bde89bd96ea..7b674256b9aa 100644

include/drm/drm_eld.h +1 -1
@@ -70,7 +70,7 @@
  * drm_eld_mnl - Get ELD monitor name length in bytes.
  * @eld: pointer to an eld memory structure with mnl set
  */
-static inline int drm_eld_mnl(const uint8_t *eld)
+static inline int drm_eld_mnl(const u8 *eld)
 {
 	return (eld[DRM_ELD_CEA_EDID_VER_MNL] &

DRM_ELD_MNL_MASK) >> DRM_ELD_MNL_SHIFT; } @@ -79,7 +79,7 @@ static inline int drm_eld_mnl(const uint8_t *eld)
* drm_eld_sad - Get ELD SAD structures.
* @eld: pointer to an eld memory structure with sad_count set */

include/drm/drm_eld.h +2 -2
-static inline const uint8_t *drm_eld_sad(const uint8_t *eld)
+static inline const u8 *drm_eld_sad(const u8 *eld)
 {
 	unsigned int ver, mnl;
@@ -98,7 +98,7 @@ static inline const uint8_t *drm_eld_sad(const uint8_t
 *eld)
  * drm_eld_sad_count - Get ELD SAD count.
  * @eld: pointer to an eld memory structure with sad_count set
  */
-static inline int drm_eld_sad_count(const uint8_t *eld)
+static inline int drm_eld_sad_count(const u8 *eld)
 {
 	return (eld[DRM_ELD_SAD_COUNT_CONN_TYPE] &

DRM_ELD_SAD_COUNT_MASK) >>

include/drm/drm_eld.h +1 -1
 		DRM_ELD_SAD_COUNT_SHIFT;
@@ -111,7 +111,7 @@ static inline int drm_eld_sad_count(const uint8_t
 *eld)
  * This is a helper for determining the payload size of the baseline block, in
  * bytes, for e.g. setting the Baseline_ELD_Len field in the ELD header block.
  */
-static inline int drm_eld_calc_baseline_block_size(const uint8_t *eld)
+static inline int drm_eld_calc_baseline_block_size(const u8 *eld)
 {
 	return DRM_ELD_MONITOR_NAME_STRING -

DRM_ELD_HEADER_BLOCK_SIZE +
drm_eld_mnl(eld) + drm_eld_sad_count(eld) * 3; @@ -127,7
+127,7 @@ static inline int drm_eld_calc_baseline_block_size(const uint8_t *eld)
*
* The returned value is guaranteed to be a multiple of 4.
*/

include/drm/drm_eld.h +1 -1
-static inline int drm_eld_size(const uint8_t *eld)
+static inline int drm_eld_size(const u8 *eld)
 {
 	return DRM_ELD_HEADER_BLOCK_SIZE +

eld[DRM_ELD_BASELINE_ELD_LEN] * 4; } @@ -139,7 +139,7 @@ static inline int drm_eld_size(const uint8_t *eld)
* The returned value is the speakers mask. User has to use
%DRM_ELD_SPEAKER
* field definitions to identify speakers.
*/

include/drm/drm_eld.h +1 -1
-static inline u8 drm_eld_get_spk_alloc(const uint8_t *eld)
+static inline u8 drm_eld_get_spk_alloc(const u8 *eld)
 {
 	return eld[DRM_ELD_SPEAKER] & DRM_ELD_SPEAKER_MASK;  } @@ -

151,7 +151,7 @@ static inline u8 drm_eld_get_spk_alloc(const uint8_t *eld)
* The caller need to use %DRM_ELD_CONN_TYPE_HDMI or
%DRM_ELD_CONN_TYPE_DP to
* identify the display type connected.
*/

include/drm/drm_eld.h static inline u8 drm_eld_get_spk_alloc(const uint8_t *eld) · line 154

Quoted 2 lines
include/drm/drm_eld.h +1 -1
-static inline u8 drm_eld_get_conn_type(const uint8_t *eld)
+static inline u8 drm_eld_get_conn_type(const u8 *eld)

Changes LGTM

Quoted 5 lines

{
return eld[DRM_ELD_SAD_COUNT_CONN_TYPE] &
DRM_ELD_CONN_TYPE_MASK; }
--
2.39.2

#6 lore raw

PATCH 3/6 drm/edid: include drm_eld.h only where required

In reply to Jani Nikula

Reduce the dependencies on drm_eld.h. Some files might be able to drop the dependency on drm_edid.h too with the direct inclusion of drm_eld.h.

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c    | 1 +
 drivers/gpu/drm/drm_edid.c                           | 1 +
 drivers/gpu/drm/i915/display/intel_audio.c           | 1 +
 drivers/gpu/drm/i915/display/intel_crtc_state_dump.c | 1 +
 drivers/gpu/drm/i915/display/intel_sdvo.c            | 1 +
 drivers/gpu/drm/nouveau/dispnv50/disp.c              | 1 +
 drivers/gpu/drm/radeon/radeon_audio.c                | 1 +
 drivers/gpu/drm/tegra/hdmi.c                         | 1 +
 drivers/gpu/drm/tegra/sor.c                          | 1 +
 include/drm/drm_edid.h                               | 1 -
 sound/core/pcm_drm_eld.c                             | 1 +
 sound/soc/codecs/hdac_hdmi.c                         | 1 +
 sound/soc/codecs/hdmi-codec.c                        | 1 +
 sound/x86/intel_hdmi_audio.c                         | 1 +
 14 files changed, 13 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -0
index 268cb99a4c4b..fe7e307ae7f9 100644
@@ -86,6 +86,7 @@
 #include <drm/drm_blend.h>
 #include <drm/drm_fourcc.h>
 #include <drm/drm_edid.h>
+#include <drm/drm_eld.h>
 #include <drm/drm_vblank.h>
 #include <drm/drm_audio_component.h>
 #include <drm/drm_gem_atomic_helper.h>
drivers/gpu/drm/drm_edid.c +1 -0
index 39dd3f694544..2025970816c9 100644
@@ -41,6 +41,7 @@
 #include <drm/drm_displayid.h>
 #include <drm/drm_drv.h>
 #include <drm/drm_edid.h>
+#include <drm/drm_eld.h>
 #include <drm/drm_encoder.h>
 #include <drm/drm_print.h>
 
drivers/gpu/drm/i915/display/intel_audio.c +1 -0
index 19605264a35c..39f5b698e08a 100644
@@ -25,6 +25,7 @@
 #include <linux/kernel.h>
 
 #include <drm/drm_edid.h>
+#include <drm/drm_eld.h>
 #include <drm/i915_component.h>
 
 #include "i915_drv.h"
drivers/gpu/drm/i915/display/intel_crtc_state_dump.c +1 -0
index 8d4640d0fd34..fcddd6d81768 100644
@@ -4,6 +4,7 @@
  */
 
 #include <drm/drm_edid.h>
+#include <drm/drm_eld.h>
 
 #include "i915_drv.h"
 #include "intel_crtc_state_dump.h"
drivers/gpu/drm/i915/display/intel_sdvo.c +1 -0
index 135a2527fd1b..6abae283998e 100644
@@ -35,6 +35,7 @@
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_crtc.h>
 #include <drm/drm_edid.h>
+#include <drm/drm_eld.h>
 
 #include "i915_drv.h"
 #include "i915_reg.h"
drivers/gpu/drm/nouveau/dispnv50/disp.c +1 -0
index 4e7c9c353c51..9332aa633867 100644
@@ -38,6 +38,7 @@
 #include <drm/drm_atomic.h>
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_edid.h>
+#include <drm/drm_eld.h>
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_probe_helper.h>
 #include <drm/drm_vblank.h>
drivers/gpu/drm/radeon/radeon_audio.c +1 -0
index d6ccaf24ee0c..279bf130a18c 100644
@@ -26,6 +26,7 @@
 #include <linux/component.h>
 
 #include <drm/drm_crtc.h>
+#include <drm/drm_eld.h>
 #include "dce6_afmt.h"
 #include "evergreen_hdmi.h"
 #include "radeon.h"
drivers/gpu/drm/tegra/hdmi.c +1 -0
index 0ba3ca3ac509..a1fcee665023 100644
@@ -24,6 +24,7 @@
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_crtc.h>
 #include <drm/drm_debugfs.h>
+#include <drm/drm_eld.h>
 #include <drm/drm_file.h>
 #include <drm/drm_fourcc.h>
 #include <drm/drm_probe_helper.h>
drivers/gpu/drm/tegra/sor.c +1 -0
index d5a3d3f4fece..83341576630d 100644
@@ -20,6 +20,7 @@
 #include <drm/display/drm_scdc_helper.h>
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_debugfs.h>
+#include <drm/drm_eld.h>
 #include <drm/drm_file.h>
 #include <drm/drm_panel.h>
 #include <drm/drm_simple_kms_helper.h>
include/drm/drm_edid.h +0 -1
index 1ff52f57ab9c..e98aa6818700 100644
@@ -25,7 +25,6 @@
 
 #include <linux/types.h>
 #include <linux/hdmi.h>
-#include <drm/drm_eld.h> /* FIXME: remove this, include directly where needed */
 #include <drm/drm_mode.h>
 
 struct drm_device;
sound/core/pcm_drm_eld.c +1 -0
index 07075071972d..1cdca4d4fc9c 100644
@@ -6,6 +6,7 @@
 #include <linux/export.h>
 #include <linux/hdmi.h>
 #include <drm/drm_edid.h>
+#include <drm/drm_eld.h>
 #include <sound/pcm.h>
 #include <sound/pcm_drm_eld.h>
 
sound/soc/codecs/hdac_hdmi.c +1 -0
index 8b6b76029694..d1b53fc1efb6 100644
@@ -16,6 +16,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/hdmi.h>
 #include <drm/drm_edid.h>
+#include <drm/drm_eld.h>
 #include <sound/pcm_params.h>
 #include <sound/jack.h>
 #include <sound/soc.h>
sound/soc/codecs/hdmi-codec.c +1 -0
index d21f69f05342..9b01d060f7cc 100644
@@ -17,6 +17,7 @@
 #include <sound/pcm_iec958.h>
 
 #include <drm/drm_crtc.h> /* This is only to get MAX_ELD_BYTES */
+#include <drm/drm_eld.h>
 
 #define HDMI_CODEC_CHMAP_IDX_UNKNOWN  -1
 
sound/x86/intel_hdmi_audio.c +1 -0
index ab95fb34a635..02f5a7f9b728 100644
@@ -30,6 +30,7 @@
 #include <sound/control.h>
 #include <sound/jack.h>
 #include <drm/drm_edid.h>
+#include <drm/drm_eld.h>
 #include <drm/intel_lpe_audio.h>
 #include "intel_hdmi_audio.h"
 
Signature · 1 line
2.39.2
Reviewed-by on v1 3/6
#7 lore raw

RE: [PATCH 3/6] drm/edid: include drm_eld.h only where required

Quoted 196 lines

-----Original Message-----
From: Nikula, Jani <[email protected]>
Sent: Thursday, September 7, 2023 2:58 PM
To: [email protected]
Cc: [email protected]; Nikula, Jani <[email protected]>; Golani, Mitulkumar Ajitkumar <[email protected]>
Subject: [PATCH 3/6] drm/edid: include drm_eld.h only where required

Reduce the dependencies on drm_eld.h. Some files might be able to drop the dependency on drm_edid.h too with the direct inclusion of drm_eld.h.

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c    | 1 +
 drivers/gpu/drm/drm_edid.c                           | 1 +
 drivers/gpu/drm/i915/display/intel_audio.c           | 1 +
 drivers/gpu/drm/i915/display/intel_crtc_state_dump.c | 1 +
 drivers/gpu/drm/i915/display/intel_sdvo.c            | 1 +
 drivers/gpu/drm/nouveau/dispnv50/disp.c              | 1 +
 drivers/gpu/drm/radeon/radeon_audio.c                | 1 +
 drivers/gpu/drm/tegra/hdmi.c                         | 1 +
 drivers/gpu/drm/tegra/sor.c                          | 1 +
 include/drm/drm_edid.h                               | 1 -
 sound/core/pcm_drm_eld.c                             | 1 +
 sound/soc/codecs/hdac_hdmi.c                         | 1 +
 sound/soc/codecs/hdmi-codec.c                        | 1 +
 sound/x86/intel_hdmi_audio.c                         | 1 +
 14 files changed, 13 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -0
index 268cb99a4c4b..fe7e307ae7f9 100644
@@ -86,6 +86,7 @@
 #include <drm/drm_blend.h>
 #include <drm/drm_fourcc.h>
 #include <drm/drm_edid.h>
+#include <drm/drm_eld.h>
 #include <drm/drm_vblank.h>
 #include <drm/drm_audio_component.h>
 #include <drm/drm_gem_atomic_helper.h>
drivers/gpu/drm/drm_edid.c index renamed from drivers/gpu/drm/drm_edid.c +0 -0

39dd3f694544..2025970816c9 100644

drivers/gpu/drm/drm_edid.c +1 -0
@@ -41,6 +41,7 @@
 #include <drm/drm_displayid.h>
 #include <drm/drm_drv.h>
 #include <drm/drm_edid.h>
+#include <drm/drm_eld.h>
 #include <drm/drm_encoder.h>
 #include <drm/drm_print.h>
 
drivers/gpu/drm/i915/display/intel_audio.c +1 -0
index 19605264a35c..39f5b698e08a 100644
@@ -25,6 +25,7 @@
 #include <linux/kernel.h>
 
 #include <drm/drm_edid.h>
+#include <drm/drm_eld.h>
 #include <drm/i915_component.h>
 
 #include "i915_drv.h"
drivers/gpu/drm/i915/display/intel_crtc_state_dump.c +1 -0
index 8d4640d0fd34..fcddd6d81768 100644
@@ -4,6 +4,7 @@
  */
 
 #include <drm/drm_edid.h>
+#include <drm/drm_eld.h>
 
 #include "i915_drv.h"
 #include "intel_crtc_state_dump.h"
drivers/gpu/drm/i915/display/intel_sdvo.c +1 -0
index 135a2527fd1b..6abae283998e 100644
@@ -35,6 +35,7 @@
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_crtc.h>
 #include <drm/drm_edid.h>
+#include <drm/drm_eld.h>
 
 #include "i915_drv.h"
 #include "i915_reg.h"
drivers/gpu/drm/nouveau/dispnv50/disp.c +1 -0
index 4e7c9c353c51..9332aa633867 100644
@@ -38,6 +38,7 @@
 #include <drm/drm_atomic.h>
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_edid.h>
+#include <drm/drm_eld.h>
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_probe_helper.h>
 #include <drm/drm_vblank.h>
drivers/gpu/drm/radeon/radeon_audio.c +1 -0
index d6ccaf24ee0c..279bf130a18c 100644
@@ -26,6 +26,7 @@
 #include <linux/component.h>
 
 #include <drm/drm_crtc.h>
+#include <drm/drm_eld.h>
 #include "dce6_afmt.h"
 #include "evergreen_hdmi.h"
 #include "radeon.h"
drivers/gpu/drm/tegra/hdmi.c +1 -0
index 0ba3ca3ac509..a1fcee665023 100644
@@ -24,6 +24,7 @@
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_crtc.h>
 #include <drm/drm_debugfs.h>
+#include <drm/drm_eld.h>
 #include <drm/drm_file.h>
 #include <drm/drm_fourcc.h>
 #include <drm/drm_probe_helper.h>
drivers/gpu/drm/tegra/sor.c index renamed from drivers/gpu/drm/tegra/sor.c +0 -0

d5a3d3f4fece..83341576630d 100644

drivers/gpu/drm/tegra/sor.c +0 -0
@@ -20,6 +20,7 @@
 #include <drm/display/drm_scdc_helper.h>  #include

<drm/drm_atomic_helper.h> #include <drm/drm_debugfs.h>

drivers/gpu/drm/tegra/sor.c +1 -0
+#include <drm/drm_eld.h>
 #include <drm/drm_file.h>
 #include <drm/drm_panel.h>
 #include <drm/drm_simple_kms_helper.h>
include/drm/drm_edid.h index renamed from include/drm/drm_edid.h +0 -0

1ff52f57ab9c..e98aa6818700 100644

include/drm/drm_edid.h +0 -1
@@ -25,7 +25,6 @@
 
 #include <linux/types.h>
 #include <linux/hdmi.h>
-#include <drm/drm_eld.h> /* FIXME: remove this, include directly where

needed */ #include <drm/drm_mode.h>

struct drm_device;

sound/core/pcm_drm_eld.c index renamed from sound/core/pcm_drm_eld.c +0 -0

07075071972d..1cdca4d4fc9c 100644

sound/core/pcm_drm_eld.c +1 -0
@@ -6,6 +6,7 @@
 #include <linux/export.h>
 #include <linux/hdmi.h>
 #include <drm/drm_edid.h>
+#include <drm/drm_eld.h>
 #include <sound/pcm.h>
 #include <sound/pcm_drm_eld.h>
 
sound/soc/codecs/hdac_hdmi.c +1 -0
index 8b6b76029694..d1b53fc1efb6 100644
@@ -16,6 +16,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/hdmi.h>
 #include <drm/drm_edid.h>
+#include <drm/drm_eld.h>
 #include <sound/pcm_params.h>
 #include <sound/jack.h>
 #include <sound/soc.h>
sound/soc/codecs/hdmi- renamed from sound/soc/codecs/hdmi-codec.c +0 -0

codec.c index d21f69f05342..9b01d060f7cc 100644

sound/soc/codecs/hdmi-codec.c +1 -0
@@ -17,6 +17,7 @@
 #include <sound/pcm_iec958.h>
 
 #include <drm/drm_crtc.h> /* This is only to get MAX_ELD_BYTES */
+#include <drm/drm_eld.h>
 
 #define HDMI_CODEC_CHMAP_IDX_UNKNOWN  -1
 
sound/x86/intel_hdmi_audio.c +0 -0
index ab95fb34a635..02f5a7f9b728 100644

sound/x86/intel_hdmi_audio.c line 33

Quoted 4 lines
sound/x86/intel_hdmi_audio.c +1 -0
@@ -30,6 +30,7 @@
 #include <sound/control.h>
 #include <sound/jack.h>
 #include <drm/drm_edid.h>
+#include <drm/drm_eld.h>

Changes LGTM.

Quoted 5 lines
sound/x86/intel_hdmi_audio.c +0 -1
 #include <drm/intel_lpe_audio.h>
 #include "intel_hdmi_audio.h"
 
--

2.39.2

#8 lore raw

PATCH 4/6 drm/edid: use a temp variable for sads to drop one level of dereferences

In reply to Jani Nikula

It's arguably easier on the eyes, and drops a set of parenthesis too.

---
 drivers/gpu/drm/drm_edid.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/gpu/drm/drm_edid.c +9 -7
index 2025970816c9..fcdc2c314cde 100644
@@ -5583,7 +5583,7 @@ static void drm_edid_to_eld(struct drm_connector *connector,
 }
 
 static int _drm_edid_to_sad(const struct drm_edid *drm_edid,
-			    struct cea_sad **sads)
+			    struct cea_sad **psads)
 {
 	const struct cea_db *db;
 	struct cea_db_iter iter;
@@ -5592,19 +5592,21 @@ static int _drm_edid_to_sad(const struct drm_edid *drm_edid,
 	cea_db_iter_edid_begin(drm_edid, &iter);
 	cea_db_iter_for_each(db, &iter) {
 		if (cea_db_tag(db) == CTA_DB_AUDIO) {
+			struct cea_sad *sads;
 			int j;
 
 			count = cea_db_payload_len(db) / 3; /* SAD is 3B */
-			*sads = kcalloc(count, sizeof(**sads), GFP_KERNEL);
-			if (!*sads)
+			sads = kcalloc(count, sizeof(*sads), GFP_KERNEL);
+			*psads = sads;
+			if (!sads)
 				return -ENOMEM;
 			for (j = 0; j < count; j++) {
 				const u8 *sad = &db->data[j * 3];
 
-				(*sads)[j].format = (sad[0] & 0x78) >> 3;
-				(*sads)[j].channels = sad[0] & 0x7;
-				(*sads)[j].freq = sad[1] & 0x7F;
-				(*sads)[j].byte2 = sad[2];
+				sads[j].format = (sad[0] & 0x78) >> 3;
+				sads[j].channels = sad[0] & 0x7;
+				sads[j].freq = sad[1] & 0x7F;
+				sads[j].byte2 = sad[2];
 			}
 			break;
 		}
Signature · 1 line
2.39.2
#9 lore raw

RE: [PATCH 4/6] drm/edid: use a temp variable for sads to drop one level of dereferences

Hi Jani,

added comments in-line.

Quoted 10 lines

-----Original Message-----
From: Nikula, Jani <[email protected]>
Sent: Thursday, September 7, 2023 2:58 PM
To: [email protected]
Cc: [email protected]; Nikula, Jani <[email protected]>; Golani, Mitulkumar Ajitkumar <[email protected]>
Subject: [PATCH 4/6] drm/edid: use a temp variable for sads to drop one level of dereferences

It's arguably easier on the eyes, and drops a set of parenthesis too.

Please consider providing a bit more context in the commit message for better clarity.

Quoted 36 lines
---
 drivers/gpu/drm/drm_edid.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/gpu/drm/drm_edid.c index renamed from drivers/gpu/drm/drm_edid.c +0 -0

2025970816c9..fcdc2c314cde 100644

drivers/gpu/drm/drm_edid.c +5 -3
@@ -5583,7 +5583,7 @@ static void drm_edid_to_eld(struct drm_connector
 *connector,  }
 
 static int _drm_edid_to_sad(const struct drm_edid *drm_edid,
-			    struct cea_sad **sads)
+			    struct cea_sad **psads)
 {
 	const struct cea_db *db;
 	struct cea_db_iter iter;
@@ -5592,19 +5592,21 @@ static int _drm_edid_to_sad(const struct
 drm_edid *drm_edid,
 	cea_db_iter_edid_begin(drm_edid, &iter);
 	cea_db_iter_for_each(db, &iter) {
 		if (cea_db_tag(db) == CTA_DB_AUDIO) {
+			struct cea_sad *sads;
 			int j;
 
 			count = cea_db_payload_len(db) / 3; /* SAD is 3B */
-			*sads = kcalloc(count, sizeof(**sads), GFP_KERNEL);
-			if (!*sads)
+			sads = kcalloc(count, sizeof(*sads), GFP_KERNEL);
+			*psads = sads;
+			if (!sads)
 				return -ENOMEM;
 			for (j = 0; j < count; j++) {

drivers/gpu/drm/drm_edid.c static int _drm_edid_to_sad(const struct · line 5610

Quoted 10 lines
drivers/gpu/drm/drm_edid.c +4 -4
 				const u8 *sad = &db->data[j * 3];
 
-				(*sads)[j].format = (sad[0] & 0x78) >> 3;
-				(*sads)[j].channels = sad[0] & 0x7;
-				(*sads)[j].freq = sad[1] & 0x7F;
-				(*sads)[j].byte2 = sad[2];
+				sads[j].format = (sad[0] & 0x78) >> 3;
+				sads[j].channels = sad[0] & 0x7;
+				sads[j].freq = sad[1] & 0x7F;
+				sads[j].byte2 = sad[2];

Thanks for the code update. I noticed the use of magic values in this section, which can make the code less clear and harder to maintain. Would it be possible to define constants or use descriptive names instead of these magic values?

Regards,
Mitul

Quoted 5 lines
drivers/gpu/drm/drm_edid.c +0 -0
 			}
 			break;

}
--
2.39.2

#10 lore raw

RE: [PATCH 4/6] drm/edid: use a temp variable for sads to drop one level of dereferences

Quoted 55 lines · Mitulkumar Ajitkumar

Hi Jani,

added comments in-line.

Quoted 10 lines

-----Original Message-----
From: Nikula, Jani <[email protected]>
Sent: Thursday, September 7, 2023 2:58 PM
To: [email protected]
Cc: [email protected]; Nikula, Jani <[email protected]>; Golani, Mitulkumar Ajitkumar <[email protected]>
Subject: [PATCH 4/6] drm/edid: use a temp variable for sads to drop one level of dereferences

It's arguably easier on the eyes, and drops a set of parenthesis too.

Please consider providing a bit more context in the commit message for better clarity.

Quoted 38 lines
---
 drivers/gpu/drm/drm_edid.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/gpu/drm/drm_edid.c index renamed from drivers/gpu/drm/drm_edid.c +0 -0

2025970816c9..fcdc2c314cde 100644

drivers/gpu/drm/drm_edid.c +5 -3
@@ -5583,7 +5583,7 @@ static void drm_edid_to_eld(struct drm_connector
 *connector,  }
 
 static int _drm_edid_to_sad(const struct drm_edid *drm_edid,
-                         struct cea_sad **sads)
+                         struct cea_sad **psads)
 {
      const struct cea_db *db;
      struct cea_db_iter iter;
@@ -5592,19 +5592,21 @@ static int _drm_edid_to_sad(const struct
 drm_edid *drm_edid,
      cea_db_iter_edid_begin(drm_edid, &iter);
      cea_db_iter_for_each(db, &iter) {
              if (cea_db_tag(db) == CTA_DB_AUDIO) {
+                     struct cea_sad *sads;
                      int j;
 
                      count = cea_db_payload_len(db) / 3; /* SAD is 3B */
-                     *sads = kcalloc(count, sizeof(**sads), GFP_KERNEL);
-                     if (!*sads)
+                     sads = kcalloc(count, sizeof(*sads), GFP_KERNEL);
+                     *psads = sads;
+                     if (!sads)
                              return -ENOMEM;
                      for (j = 0; j < count; j++) {
                              const u8 *sad = &db->data[j * 3];
 
Quoted 12 lines

drivers/gpu/drm/drm_edid.c static int _drm_edid_to_sad(const struct drm_edid *drm_edid, · line 5609

Quoted 8 lines
drivers/gpu/drm/drm_edid.c +4 -4
-                             (*sads)[j].format = (sad[0] & 0x78) >> 3;
-                             (*sads)[j].channels = sad[0] & 0x7;
-                             (*sads)[j].freq = sad[1] & 0x7F;
-                             (*sads)[j].byte2 = sad[2];
+                             sads[j].format = (sad[0] & 0x78) >> 3;
+                             sads[j].channels = sad[0] & 0x7;
+                             sads[j].freq = sad[1] & 0x7F;
+                             sads[j].byte2 = sad[2];

Thanks for the code update. I noticed the use of magic values in this section, which can make the code less clear and harder to maintain. Would it be possible to define constants or use descriptive names instead of these magic values?

Yes, but that would be for a separate patch. The magic values aren't added here.

BR,
Jani.

Quoted 9 lines

Regards,
Mitul

Quoted 5 lines
drivers/gpu/drm/drm_edid.c +0 -0
                      }
                      break;
              }

--
2.39.2

Signature · 1 line
Jani Nikula, Intel
#11 lore raw

RE: [PATCH 4/6] drm/edid: use a temp variable for sads to drop one level of dereferences

Quoted 82 lines

-----Original Message-----
From: Nikula, Jani <[email protected]>
Sent: 26 September 2023 13:14
To: Golani, Mitulkumar Ajitkumar <[email protected]>; [email protected]
Cc: [email protected]
Subject: RE: [PATCH 4/6] drm/edid: use a temp variable for sads to drop one level of dereferences

Quoted 14 lines · Mitulkumar Ajitkumar

Hi Jani,

added comments in-line.

Quoted 10 lines

-----Original Message-----
From: Nikula, Jani <[email protected]>
Sent: Thursday, September 7, 2023 2:58 PM
To: [email protected]
Cc: [email protected]; Nikula, Jani <[email protected]>; Golani, Mitulkumar Ajitkumar <[email protected]>
Subject: [PATCH 4/6] drm/edid: use a temp variable for sads to drop one level of dereferences

Quoted 3 lines
Quoted 1 line

It's arguably easier on the eyes, and drops a set of parenthesis too.

Please consider providing a bit more context in the commit message for

better clarity.

Quoted 39 lines
Quoted 39 lines
---
 drivers/gpu/drm/drm_edid.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/gpu/drm/drm_edid.c +5 -3
index 2025970816c9..fcdc2c314cde 100644
@@ -5583,7 +5583,7 @@ static void drm_edid_to_eld(struct
 drm_connector *connector,  }
 
 static int _drm_edid_to_sad(const struct drm_edid *drm_edid,
-                         struct cea_sad **sads)
+                         struct cea_sad **psads)
 {
      const struct cea_db *db;
      struct cea_db_iter iter;
@@ -5592,19 +5592,21 @@ static int _drm_edid_to_sad(const struct
 drm_edid *drm_edid,
      cea_db_iter_edid_begin(drm_edid, &iter);
      cea_db_iter_for_each(db, &iter) {
              if (cea_db_tag(db) == CTA_DB_AUDIO) {
+                     struct cea_sad *sads;
                      int j;
 
                      count = cea_db_payload_len(db) / 3; /* SAD is 3B */
-                     *sads = kcalloc(count, sizeof(**sads), GFP_KERNEL);
-                     if (!*sads)
+                     sads = kcalloc(count, sizeof(*sads), GFP_KERNEL);
+                     *psads = sads;
+                     if (!sads)
                              return -ENOMEM;
                      for (j = 0; j < count; j++) {
                              const u8 *sad = &db->data[j * 3];
 
Quoted 12 lines

drivers/gpu/drm/drm_edid.c static int _drm_edid_to_sad(const struct drm_edid *drm_edid, · line 5609

Quoted 8 lines
drivers/gpu/drm/drm_edid.c +4 -4
-                             (*sads)[j].format = (sad[0] & 0x78) >> 3;
-                             (*sads)[j].channels = sad[0] & 0x7;
-                             (*sads)[j].freq = sad[1] & 0x7F;
-                             (*sads)[j].byte2 = sad[2];
+                             sads[j].format = (sad[0] & 0x78) >> 3;
+                             sads[j].channels = sad[0] & 0x7;
+                             sads[j].freq = sad[1] & 0x7F;
+                             sads[j].byte2 = sad[2];

Thanks for the code update. I noticed the use of magic values in this section, which can make the code less clear and harder to maintain. Would it be possible to define constants or use descriptive names instead

Quoted 4 lines

of these magic values?

Yes, but that would be for a separate patch. The magic values aren't added here.

Sure. Other changes looks good to me.

Quoted 16 lines

BR,
Jani.

Quoted 9 lines

Regards,
Mitul

Quoted 5 lines
drivers/gpu/drm/drm_edid.c +0 -0
                      }
                      break;
              }

--
2.39.2

--
Jani Nikula, Intel

#12 lore raw

PATCH 5/6 drm/edid: add helpers to get/set struct cea_sad from/to 3-byte sad

In reply to Jani Nikula

Add helpers to pack/unpack SADs. Both ways and non-static, as follow-up work needs them.

---
 drivers/gpu/drm/drm_edid.c     | 33 ++++++++++++++++++++++++---------
 drivers/gpu/drm/drm_internal.h |  6 ++++++
 2 files changed, 30 insertions(+), 9 deletions(-)
drivers/gpu/drm/drm_edid.c +24 -9
index fcdc2c314cde..1260e2688bd7 100644
@@ -5499,6 +5499,27 @@ static void clear_eld(struct drm_connector *connector)
 	connector->audio_latency[1] = 0;
 }
 
+/*
+ * Get 3-byte SAD buf from struct cea_sad.
+ */
+void drm_edid_cta_sad_get(const struct cea_sad *cta_sad, u8 *sad)
+{
+	sad[0] = cta_sad->format << 3 | cta_sad->channels;
+	sad[1] = cta_sad->freq;
+	sad[2] = cta_sad->byte2;
+}
+
+/*
+ * Set struct cea_sad from 3-byte SAD buf.
+ */
+void drm_edid_cta_sad_set(struct cea_sad *cta_sad, const u8 *sad)
+{
+	cta_sad->format = (sad[0] & 0x78) >> 3;
+	cta_sad->channels = sad[0] & 0x07;
+	cta_sad->freq = sad[1] & 0x7f;
+	cta_sad->byte2 = sad[2];
+}
+
 /*
  * drm_edid_to_eld - build ELD from EDID
  * @connector: connector corresponding to the HDMI/DP sink
@@ -5593,21 +5614,15 @@ static int _drm_edid_to_sad(const struct drm_edid *drm_edid,
 	cea_db_iter_for_each(db, &iter) {
 		if (cea_db_tag(db) == CTA_DB_AUDIO) {
 			struct cea_sad *sads;
-			int j;
+			int i;
 
 			count = cea_db_payload_len(db) / 3; /* SAD is 3B */
 			sads = kcalloc(count, sizeof(*sads), GFP_KERNEL);
 			*psads = sads;
 			if (!sads)
 				return -ENOMEM;
-			for (j = 0; j < count; j++) {
-				const u8 *sad = &db->data[j * 3];
-
-				sads[j].format = (sad[0] & 0x78) >> 3;
-				sads[j].channels = sad[0] & 0x7;
-				sads[j].freq = sad[1] & 0x7F;
-				sads[j].byte2 = sad[2];
-			}
+			for (i = 0; i < count; i++)
+				drm_edid_cta_sad_set(&sads[i], &db->data[i * 3]);
 			break;
 		}
 	}
drivers/gpu/drm/drm_internal.h +6 -0
index ab9a472f4a47..5b7c661da459 100644
@@ -22,6 +22,7 @@
  */
 
 #include <linux/kthread.h>
+#include <linux/types.h>
 
 #include <drm/drm_ioctl.h>
 #include <drm/drm_vblank.h>
@@ -31,6 +32,7 @@
 
 #define DRM_IF_VERSION(maj, min) (maj << 16 | min)
 
+struct cea_sad;
 struct dentry;
 struct dma_buf;
 struct iosys_map;
@@ -265,3 +267,7 @@ int drm_syncobj_query_ioctl(struct drm_device *dev, void *data,
 void drm_framebuffer_print_info(struct drm_printer *p, unsigned int indent,
 				const struct drm_framebuffer *fb);
 void drm_framebuffer_debugfs_init(struct drm_device *dev);
+
+/* drm_edid.c */
+void drm_edid_cta_sad_get(const struct cea_sad *cta_sad, u8 *sad);
+void drm_edid_cta_sad_set(struct cea_sad *cta_sad, const u8 *sad);
Signature · 1 line
2.39.2
#13 lore raw

Re: [PATCH 5/6] drm/edid: add helpers to get/set struct cea_sad from/to 3-byte sad

kernel test robot noticed the following build warnings:

Hi Jani,

kernel test robot noticed the following build warnings:

[auto build test WARNING on drm-tip/drm-tip]

url:    https://github.com/intel-lab-lkp/linux/commits/Jani-Nikula/drm-edid-split-out-drm_eld-h-from-drm_edid-h/20230907-173011
base:   git://anongit.freedesktop.org/drm/drm-tip drm-tip
patch link:    https://lore.kernel.org/r/eba53a0904126fb904a5190750002695350f44eb.1694078430.git.jani.nikula%40intel.com
patch subject: [PATCH 5/6] drm/edid: add helpers to get/set struct cea_sad from/to 3-byte sad
config: arm-defconfig (https://download.01.org/0day-ci/archive/20230907/[email protected]/config)
compiler: arm-linux-gnueabi-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230907/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/drm_edid.c:5505:6: warning: no previous prototype for 'drm_edid_cta_sad_get' [-Wmissing-prototypes]
    5505 | void drm_edid_cta_sad_get(const struct cea_sad *cta_sad, u8 *sad)
         |      ^~~~~~~~~~~~~~~~~~~~
>> drivers/gpu/drm/drm_edid.c:5515:6: warning: no previous prototype for 'drm_edid_cta_sad_set' [-Wmissing-prototypes]

5515 | void drm_edid_cta_sad_set(struct cea_sad *cta_sad, const u8 *sad)
| ^~~~~~~~~~~~~~~~~~~~

vim +/drm_edid_cta_sad_get +5505 drivers/gpu/drm/drm_edid.c

5501
5502 /*
5503 * Get 3-byte SAD buf from struct cea_sad.
5504 */

> 5505	void drm_edid_cta_sad_get(const struct cea_sad *cta_sad, u8 *sad)
  5506	{
  5507		sad[0] = cta_sad->format << 3 | cta_sad->channels;
  5508		sad[1] = cta_sad->freq;
  5509		sad[2] = cta_sad->byte2;
  5510	}
  5511	
  5512	/*
  5513	 * Set struct cea_sad from 3-byte SAD buf.
  5514	 */
> 5515	void drm_edid_cta_sad_set(struct cea_sad *cta_sad, const u8 *sad)

5516 {
5517 cta_sad->format = (sad[0] & 0x78) >> 3;
5518 cta_sad->channels = sad[0] & 0x07;
5519 cta_sad->freq = sad[1] & 0x7f;
5520 cta_sad->byte2 = sad[2];
5521 }
5522

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#14 lore raw

Re: [PATCH 5/6] drm/edid: add helpers to get/set struct cea_sad from/to 3-byte sad

In reply to Jani Nikula
kernel test robot noticed the following build warnings:

Hi Jani,

kernel test robot noticed the following build warnings:

[auto build test WARNING on drm-tip/drm-tip]

url:    https://github.com/intel-lab-lkp/linux/commits/Jani-Nikula/drm-edid-split-out-drm_eld-h-from-drm_edid-h/20230907-173011
base:   git://anongit.freedesktop.org/drm/drm-tip drm-tip
patch link:    https://lore.kernel.org/r/eba53a0904126fb904a5190750002695350f44eb.1694078430.git.jani.nikula%40intel.com
patch subject: [PATCH 5/6] drm/edid: add helpers to get/set struct cea_sad from/to 3-byte sad
config: i386-randconfig-013-20230907 (https://download.01.org/0day-ci/archive/20230907/[email protected]/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230907/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/drm_edid.c:5505:6: warning: no previous declaration for 'drm_edid_cta_sad_get' [-Wmissing-declarations]
    void drm_edid_cta_sad_get(const struct cea_sad *cta_sad, u8 *sad)
         ^~~~~~~~~~~~~~~~~~~~
>> drivers/gpu/drm/drm_edid.c:5515:6: warning: no previous declaration for 'drm_edid_cta_sad_set' [-Wmissing-declarations]

void drm_edid_cta_sad_set(struct cea_sad *cta_sad, const u8 *sad)
^~~~~~~~~~~~~~~~~~~~

vim +/drm_edid_cta_sad_get +5505 drivers/gpu/drm/drm_edid.c

5501
5502 /*
5503 * Get 3-byte SAD buf from struct cea_sad.
5504 */

> 5505	void drm_edid_cta_sad_get(const struct cea_sad *cta_sad, u8 *sad)
  5506	{
  5507		sad[0] = cta_sad->format << 3 | cta_sad->channels;
  5508		sad[1] = cta_sad->freq;
  5509		sad[2] = cta_sad->byte2;
  5510	}
  5511	
  5512	/*
  5513	 * Set struct cea_sad from 3-byte SAD buf.
  5514	 */
> 5515	void drm_edid_cta_sad_set(struct cea_sad *cta_sad, const u8 *sad)

5516 {
5517 cta_sad->format = (sad[0] & 0x78) >> 3;
5518 cta_sad->channels = sad[0] & 0x07;
5519 cta_sad->freq = sad[1] & 0x7f;
5520 cta_sad->byte2 = sad[2];
5521 }
5522

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Reviewed-by on v1 5/6
#15 lore raw

RE: [PATCH 5/6] drm/edid: add helpers to get/set struct cea_sad from/to 3-byte sad

In reply to Jani Nikula
Quoted 24 lines

-----Original Message-----
From: Nikula, Jani <[email protected]>
Sent: 07 September 2023 14:58
To: [email protected]
Cc: [email protected]; Nikula, Jani <[email protected]>; Golani, Mitulkumar Ajitkumar <[email protected]>
Subject: [PATCH 5/6] drm/edid: add helpers to get/set struct cea_sad from/to 3-byte sad

Add helpers to pack/unpack SADs. Both ways and non-static, as follow-up work needs them.

---
 drivers/gpu/drm/drm_edid.c     | 33 ++++++++++++++++++++++++---------
 drivers/gpu/drm/drm_internal.h |  6 ++++++
 2 files changed, 30 insertions(+), 9 deletions(-)
drivers/gpu/drm/drm_edid.c +0 -0
index fcdc2c314cde..1260e2688bd7 100644

drivers/gpu/drm/drm_edid.c static void clear_eld(struct drm_connector · line 5505

Quoted 7 lines
drivers/gpu/drm/drm_edid.c +3 -0
@@ -5499,6 +5499,27 @@ static void clear_eld(struct drm_connector
 *connector)
 	connector->audio_latency[1] = 0;
 }
 
+/*
+ * Get 3-byte SAD buf from struct cea_sad.
+ */

Just a small nit-pick: 'SAD buffer'.

Otherwise the change looks good to me.

Quoted 78 lines
drivers/gpu/drm/drm_edid.c +17 -0
+void drm_edid_cta_sad_get(const struct cea_sad *cta_sad, u8 *sad) {
+	sad[0] = cta_sad->format << 3 | cta_sad->channels;
+	sad[1] = cta_sad->freq;
+	sad[2] = cta_sad->byte2;
+}
+
+/*
+ * Set struct cea_sad from 3-byte SAD buf.
+ */
+void drm_edid_cta_sad_set(struct cea_sad *cta_sad, const u8 *sad) {
+	cta_sad->format = (sad[0] & 0x78) >> 3;
+	cta_sad->channels = sad[0] & 0x07;
+	cta_sad->freq = sad[1] & 0x7f;
+	cta_sad->byte2 = sad[2];
+}
+
 /*
  * drm_edid_to_eld - build ELD from EDID
  * @connector: connector corresponding to the HDMI/DP sink @@ -5593,21
+5614,15 @@ static int _drm_edid_to_sad(const struct drm_edid

*drm_edid,

drivers/gpu/drm/drm_edid.c +3 -9
 	cea_db_iter_for_each(db, &iter) {
 		if (cea_db_tag(db) == CTA_DB_AUDIO) {
 			struct cea_sad *sads;
-			int j;
+			int i;
 
 			count = cea_db_payload_len(db) / 3; /* SAD is 3B */
 			sads = kcalloc(count, sizeof(*sads), GFP_KERNEL);
 			*psads = sads;
 			if (!sads)
 				return -ENOMEM;
-			for (j = 0; j < count; j++) {
-				const u8 *sad = &db->data[j * 3];
-
-				sads[j].format = (sad[0] & 0x78) >> 3;
-				sads[j].channels = sad[0] & 0x7;
-				sads[j].freq = sad[1] & 0x7F;
-				sads[j].byte2 = sad[2];
-			}
+			for (i = 0; i < count; i++)
+				drm_edid_cta_sad_set(&sads[i], &db->data[i

* 3]);

drivers/gpu/drm/drm_edid.c +0 -0
 			break;
 		}
 	}
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_internal.h index ab9a472f4a47..5b7c661da459 100644

drivers/gpu/drm/drm_internal.h +6 -1
@@ -22,6 +22,7 @@
  */
 
 #include <linux/kthread.h>
+#include <linux/types.h>
 
 #include <drm/drm_ioctl.h>
 #include <drm/drm_vblank.h>
@@ -31,6 +32,7 @@
 
 #define DRM_IF_VERSION(maj, min) (maj << 16 | min)
 
+struct cea_sad;
 struct dentry;
 struct dma_buf;
 struct iosys_map;
@@ -265,3 +267,7 @@ int drm_syncobj_query_ioctl(struct drm_device *dev,
 void *data,  void drm_framebuffer_print_info(struct drm_printer *p,
 unsigned int indent,
 				const struct drm_framebuffer *fb);
 void drm_framebuffer_debugfs_init(struct drm_device *dev);
+
+/* drm_edid.c */
+void drm_edid_cta_sad_get(const struct cea_sad *cta_sad, u8 *sad); void
+drm_edid_cta_sad_set(struct cea_sad *cta_sad, const u8 *sad);
--

2.39.2

#16 lore raw

PATCH 6/6 drm/eld: add helpers to modify the SADs of an ELD

In reply to Jani Nikula

Occasionally it's necessary for drivers to modify the SADs of an ELD, but it's not so cool to have drivers poke at the ELD buffer directly.

Using the helpers to translate between 3-byte SAD and struct cea_sad, add ELD helpers to get/set the SADs from/to an ELD.

---
 Documentation/gpu/drm-kms-helpers.rst |  3 ++
 drivers/gpu/drm/Makefile              |  1 +
 drivers/gpu/drm/drm_eld.c             | 55 +++++++++++++++++++++++++++
 include/drm/drm_eld.h                 |  5 +++
 4 files changed, 64 insertions(+)
 create mode 100644 drivers/gpu/drm/drm_eld.c
Documentation/gpu/drm-kms-helpers.rst +3 -0
index f0f93aa62545..df91b7cd992e 100644
@@ -366,6 +366,9 @@ EDID Helper Functions Reference
 .. kernel-doc:: include/drm/drm_eld.h
    :internal:
 
+.. kernel-doc:: drivers/gpu/drm/drm_eld.c
+   :export:
+
 SCDC Helper Functions Reference
 ===============================
 
drivers/gpu/drm/Makefile +1 -0
index 215e78e79125..632e74d823e8 100644
@@ -22,6 +22,7 @@ drm-y := \
 	drm_drv.o \
 	drm_dumb_buffers.o \
 	drm_edid.o \
+	drm_eld.o \
 	drm_encoder.o \
 	drm_file.o \
 	drm_fourcc.o \
drivers/gpu/drm/drm_eld.c new file +55 -0

55 lines not on this page · raw message

include/drm/drm_eld.h +5 -0
index 7b674256b9aa..5b320157684c 100644
@@ -8,6 +8,8 @@
 
 #include <linux/types.h>
 
+struct cea_sad;
+
 /* ELD Header Block */
 #define DRM_ELD_HEADER_BLOCK_SIZE	4
 
@@ -75,6 +77,9 @@ static inline int drm_eld_mnl(const u8 *eld)
 	return (eld[DRM_ELD_CEA_EDID_VER_MNL] & DRM_ELD_MNL_MASK) >> DRM_ELD_MNL_SHIFT;
 }
 
+int drm_eld_sad_get(const u8 *eld, int i, struct cea_sad *cta_sad);
+int drm_eld_sad_set(u8 *eld, int i, const struct cea_sad *cta_sad);
+
 /**
  * drm_eld_sad - Get ELD SAD structures.
  * @eld: pointer to an eld memory structure with sad_count set
Signature · 1 line
2.39.2
#17 lore raw

RE: [PATCH 6/6] drm/eld: add helpers to modify the SADs of an ELD

Quoted 64 lines

-----Original Message-----
From: Nikula, Jani <[email protected]>
Sent: 07 September 2023 14:58
To: [email protected]
Cc: [email protected]; Nikula, Jani <[email protected]>; Golani, Mitulkumar Ajitkumar <[email protected]>
Subject: [PATCH 6/6] drm/eld: add helpers to modify the SADs of an ELD

Occasionally it's necessary for drivers to modify the SADs of an ELD, but it's not so cool to have drivers poke at the ELD buffer directly.

Using the helpers to translate between 3-byte SAD and struct cea_sad, add ELD helpers to get/set the SADs from/to an ELD.

---
 Documentation/gpu/drm-kms-helpers.rst |  3 ++
 drivers/gpu/drm/Makefile              |  1 +
 drivers/gpu/drm/drm_eld.c             | 55 +++++++++++++++++++++++++++
 include/drm/drm_eld.h                 |  5 +++
 4 files changed, 64 insertions(+)
 create mode 100644 drivers/gpu/drm/drm_eld.c
Documentation/gpu/drm-kms-helpers.rst +0 -0
index f0f93aa62545..df91b7cd992e 100644
@@ -366,6 +366,9 @@ EDID Helper Functions Reference  .. kernel-doc::

include/drm/drm_eld.h
:internal:

+.. kernel-doc:: drivers/gpu/drm/drm_eld.c

Documentation/gpu/drm-kms-helpers.rst +2 -0
+   :export:
+
 SCDC Helper Functions Reference
 ===============================
drivers/gpu/drm/Makefile index renamed from drivers/gpu/drm/Makefile +0 -0

215e78e79125..632e74d823e8 100644

drivers/gpu/drm/Makefile +1 -0
@@ -22,6 +22,7 @@ drm-y := \
 	drm_drv.o \
 	drm_dumb_buffers.o \
 	drm_edid.o \
+	drm_eld.o \
 	drm_encoder.o \
 	drm_file.o \
 	drm_fourcc.o \
drivers/gpu/drm/drm_eld.c new renamed from drivers/gpu/drm/drm_eld.c +0 -0

file mode 100644 index 000000000000..34e0d71c3550

drivers/gpu/drm/drm_eld.c new file +8 -0
@@ -0,0 +1,55 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2023 Intel Corporation
+ */
+
+#include <drm/drm_edid.h>
+#include <drm/drm_eld.h>
+

drivers/gpu/drm/drm_eld.c line 18

Quoted 10 lines
drivers/gpu/drm/drm_eld.c new file +10 -0
+#include "drm_internal.h"
+
+/**
+ * drm_eld_sad_get - get SAD from ELD to struct cea_sad
+ * @eld: ELD buffer
+ * @i: SAD number
+ * @cta_sad: destination struct cea_sad
+ *
+ * @return: 0 on success, or negative on errors  */ int
+drm_eld_sad_get(const u8 *eld, int i, struct cea_sad *cta_sad) {

Could we use a more descriptive variable name than 'i' for better code readability in the functions drm_eld_sad_get and drm_eld_sad_set? possibly something like, sad_number or index ?

Regards,
Mitul

Quoted 58 lines
drivers/gpu/drm/drm_eld.c new file +33 -0
+	const u8 *sad;
+
+	if (i >= drm_eld_sad_count(eld))
+		return -EINVAL;
+
+	sad = eld + DRM_ELD_CEA_SAD(drm_eld_mnl(eld), i);
+
+	drm_edid_cta_sad_set(cta_sad, sad);
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_eld_sad_get);
+
+/**
+ * drm_eld_sad_set - set SAD to ELD from struct cea_sad
+ * @eld: ELD buffer
+ * @i: SAD number
+ * @cta_sad: source struct cea_sad
+ *
+ * @return: 0 on success, or negative on errors  */ int
+drm_eld_sad_set(u8 *eld, int i, const struct cea_sad *cta_sad) {
+	u8 *sad;
+
+	if (i >= drm_eld_sad_count(eld))
+		return -EINVAL;
+
+	sad = eld + DRM_ELD_CEA_SAD(drm_eld_mnl(eld), i);
+
+	drm_edid_cta_sad_get(cta_sad, sad);
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_eld_sad_set);
include/drm/drm_eld.h index renamed from include/drm/drm_eld.h +0 -0

7b674256b9aa..5b320157684c 100644

include/drm/drm_eld.h +5 -1
@@ -8,6 +8,8 @@
 
 #include <linux/types.h>
 
+struct cea_sad;
+
 /* ELD Header Block */
 #define DRM_ELD_HEADER_BLOCK_SIZE	4
 
@@ -75,6 +77,9 @@ static inline int drm_eld_mnl(const u8 *eld)
 	return (eld[DRM_ELD_CEA_EDID_VER_MNL] &
 DRM_ELD_MNL_MASK) >> DRM_ELD_MNL_SHIFT;  }
 
+int drm_eld_sad_get(const u8 *eld, int i, struct cea_sad *cta_sad); int
+drm_eld_sad_set(u8 *eld, int i, const struct cea_sad *cta_sad);
+
 /**
  * drm_eld_sad - Get ELD SAD structures.
  * @eld: pointer to an eld memory structure with sad_count set
--

2.39.2

#18 lore raw

[Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/edid: split out drm_eld.[ch], add some SAD helpers

In reply to Jani Nikula
== Series Details ==

== Series Details ==

Series: drm/edid: split out drm_eld.[ch], add some SAD helpers
URL : https://patchwork.freedesktop.org/series/123384/
State : warning

== Summary ==

Error: dim checkpatch failed
940b009582a3 drm/edid: split out drm_eld.h from drm_edid.h
Traceback (most recent call last):
File "scripts/spdxcheck.py", line 6, in <module>
from ply import lex, yacc
ModuleNotFoundError: No module named 'ply'
-:205: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #205:
new file mode 100644

total: 0 errors, 1 warnings, 0 checks, 335 lines checked
bfb13c1d78fa drm/eld: replace uint8_t with u8
1458d514001c drm/edid: include drm_eld.h only where required
814b0bb13735 drm/edid: use a temp variable for sads to drop one level of dereferences 078b4dda5ca5 drm/edid: add helpers to get/set struct cea_sad from/to 3-byte sad 0c4ecf16ece2 drm/eld: add helpers to modify the SADs of an ELD
Traceback (most recent call last):
File "scripts/spdxcheck.py", line 6, in <module>
from ply import lex, yacc
ModuleNotFoundError: No module named 'ply'
-:42: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #42:
new file mode 100644

total: 0 errors, 1 warnings, 0 checks, 88 lines checked

#19 lore raw

[Intel-gfx] ✗ Fi.CI.SPARSE: warning for drm/edid: split out drm_eld.[ch], add some SAD helpers

In reply to Jani Nikula
== Series Details ==

== Series Details ==

Series: drm/edid: split out drm_eld.[ch], add some SAD helpers
URL : https://patchwork.freedesktop.org/series/123384/
State : warning

== Summary ==

Error: dim sparse failed
Sparse version: v0.6.2
Fast mode used, each commit won't be checked separately.

#20 lore raw

[Intel-gfx] ✗ Fi.CI.BAT: failure for drm/edid: split out drm_eld.[ch], add some SAD helpers

In reply to Jani Nikula
== Series Details ==

== Series Details ==

Series: drm/edid: split out drm_eld.[ch], add some SAD helpers
URL : https://patchwork.freedesktop.org/series/123384/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_13606 -> Patchwork_123384v1
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with Patchwork_123384v1 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes
introduced in Patchwork_123384v1, please notify your bug team ([email protected]) to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_123384v1/index.html

Participating hosts (39 -> 30)
------------------------------

Additional (1): fi-hsw-4770
Missing (10): fi-kbl-7567u fi-tgl-1115g4 fi-cfl-guc fi-apl-guc fi-snb-2520m fi-kbl-guc fi-kbl-x1275 bat-dg2-11 fi-bsw-nick bat-mtlp-6

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in Patchwork_123384v1:

### IGT changes ###

#### Possible regressions ####

* igt@gem_exec_suspend@basic-s0@smem:
- bat-dg2-9: [PASS][1] -> [INCOMPLETE][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13606/bat-dg2-9/igt@gem_exec_suspend@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_123384v1/bat-dg2-9/igt@gem_exec_suspend@[email protected]

Known issues
------------

Here are the changes found in Patchwork_123384v1 that come from known issues:

### CI changes ###

#### Issues hit ####

* boot:
- fi-hsw-4770: NOTRUN -> [FAIL][3] ([i915#8293])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_123384v1/fi-hsw-4770/boot.html

### IGT changes ###

#### Issues hit ####

* igt@kms_pipe_crc_basic@read-crc-frame-sequence@pipe-a-dp-5:
- bat-adlp-11: [PASS][4] -> [ABORT][5] ([i915#8668])
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13606/bat-adlp-11/igt@kms_pipe_crc_basic@[email protected]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_123384v1/bat-adlp-11/igt@kms_pipe_crc_basic@[email protected]

* igt@kms_pipe_crc_basic@read-crc-frame-sequence@pipe-d-edp-1:
- bat-rplp-1: [PASS][6] -> [ABORT][7] ([i915#8442] / [i915#8668])
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13606/bat-rplp-1/igt@kms_pipe_crc_basic@[email protected]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_123384v1/bat-rplp-1/igt@kms_pipe_crc_basic@[email protected]

#### Possible fixes ####

* igt@kms_pipe_crc_basic@read-crc-frame-sequence@pipe-b-dp-6:
- bat-adlp-11: [ABORT][8] ([i915#8668]) -> [PASS][9]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13606/bat-adlp-11/igt@kms_pipe_crc_basic@[email protected]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_123384v1/bat-adlp-11/igt@kms_pipe_crc_basic@[email protected]

[i915#8293]: https://gitlab.freedesktop.org/drm/intel/issues/8293
[i915#8442]: https://gitlab.freedesktop.org/drm/intel/issues/8442
[i915#8668]: https://gitlab.freedesktop.org/drm/intel/issues/8668

Build changes
-------------

* Linux: CI_DRM_13606 -> Patchwork_123384v1

CI-20190529: 20190529
CI_DRM_13606: 0723fc45231c46bbdaef60144e5af32323d27538 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_7474: 9d91cf2c6e7bb64d60c2030d1535e40ca0ad53ee @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_123384v1: 0723fc45231c46bbdaef60144e5af32323d27538 @ git://anongit.freedesktop.org/gfx-ci/linux

### Linux commits

dc6384398098 drm/eld: add helpers to modify the SADs of an ELD 9cbc38dd7951 drm/edid: add helpers to get/set struct cea_sad from/to 3-byte sad 6db20d05f1cc drm/edid: use a temp variable for sads to drop one level of dereferences bdb2982e84f2 drm/edid: include drm_eld.h only where required d499add4e943 drm/eld: replace uint8_t with u8
6e51d25293cf drm/edid: split out drm_eld.h from drm_edid.h

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_123384v1/index.html