diff mbox series

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

Message ID eba53a0904126fb904a5190750002695350f44eb.1694078430.git.jani.nikula@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/edid: split out drm_eld.[ch], add some SAD helpers | expand

Commit Message

Jani Nikula Sept. 7, 2023, 9:28 a.m. UTC
Add helpers to pack/unpack SADs. Both ways and non-static, as follow-up
work needs them.

Cc: Mitul Golani <mitulkumar.ajitkumar.golani@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/drm_edid.c     | 33 ++++++++++++++++++++++++---------
 drivers/gpu/drm/drm_internal.h |  6 ++++++
 2 files changed, 30 insertions(+), 9 deletions(-)

Comments

kernel test robot Sept. 7, 2023, 11:49 a.m. UTC | #1
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/202309071934.AzntzCVc-lkp@intel.com/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/202309071934.AzntzCVc-lkp@intel.com/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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309071934.AzntzCVc-lkp@intel.com/

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
kernel test robot Sept. 7, 2023, 1:37 p.m. UTC | #2
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/202309072156.iD0ETpd1-lkp@intel.com/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/202309072156.iD0ETpd1-lkp@intel.com/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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309072156.iD0ETpd1-lkp@intel.com/

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
Golani, Mitulkumar Ajitkumar Sept. 26, 2023, 6:13 p.m. UTC | #3
> -----Original Message-----
> From: Nikula, Jani <jani.nikula@intel.com>
> Sent: 07 September 2023 14:58
> To: dri-devel@lists.freedesktop.org
> Cc: intel-gfx@lists.freedesktop.org; Nikula, Jani <jani.nikula@intel.com>;
> Golani, Mitulkumar Ajitkumar <mitulkumar.ajitkumar.golani@intel.com>
> 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.
> 
> Cc: Mitul Golani <mitulkumar.ajitkumar.golani@intel.com>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
>  drivers/gpu/drm/drm_edid.c     | 33 ++++++++++++++++++++++++---------
>  drivers/gpu/drm/drm_internal.h |  6 ++++++
>  2 files changed, 30 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index fcdc2c314cde..1260e2688bd7 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -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.
Reviewed-by: Mitul Golani <mitulkumar.ajitkumar.golani@intel.com>

> +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;
>  		}
>  	}
> diff --git a/drivers/gpu/drm/drm_internal.h
> b/drivers/gpu/drm/drm_internal.h index ab9a472f4a47..5b7c661da459
> 100644
> --- a/drivers/gpu/drm/drm_internal.h
> +++ b/drivers/gpu/drm/drm_internal.h
> @@ -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
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index fcdc2c314cde..1260e2688bd7 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -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;
 		}
 	}
diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h
index ab9a472f4a47..5b7c661da459 100644
--- a/drivers/gpu/drm/drm_internal.h
+++ b/drivers/gpu/drm/drm_internal.h
@@ -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);