diff mbox series

[v2,17/25] drm/edid: add drm_edid helper for drm_edid_to_sad()

Message ID 14aa1e44caa2e9c1b54c2f2a471d2fd7d3f62d5d.1652097712.git.jani.nikula@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/edid: introduce struct drm_edid | expand

Commit Message

Jani Nikula May 9, 2022, 12:03 p.m. UTC
We'll need to propagate drm_edid everywhere.

v2: Handle NULL EDID pointer (Ville, CI)

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/drm_edid.c | 34 +++++++++++++++++++++-------------
 1 file changed, 21 insertions(+), 13 deletions(-)

Comments

Nautiyal, Ankit K May 10, 2022, 9:55 a.m. UTC | #1
On 5/9/2022 5:33 PM, Jani Nikula wrote:
> We'll need to propagate drm_edid everywhere.
>
> v2: Handle NULL EDID pointer (Ville, CI)
>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>


LGTM.

Reviewed-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>

Regards,

Ankit

> ---
>   drivers/gpu/drm/drm_edid.c | 34 +++++++++++++++++++++-------------
>   1 file changed, 21 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 61551ce0db88..dee09359bbc3 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -4972,24 +4972,14 @@ static void drm_edid_to_eld(struct drm_connector *connector,
>   		      drm_eld_size(eld), total_sad_count);
>   }
>   
> -/**
> - * drm_edid_to_sad - extracts SADs from EDID
> - * @edid: EDID to parse
> - * @sads: pointer that will be set to the extracted SADs
> - *
> - * Looks for CEA EDID block and extracts SADs (Short Audio Descriptors) from it.
> - *
> - * Note: The returned pointer needs to be freed using kfree().
> - *
> - * Return: The number of found SADs or negative number on error.
> - */
> -int drm_edid_to_sad(const struct edid *edid, struct cea_sad **sads)
> +static int _drm_edid_to_sad(const struct drm_edid *drm_edid,
> +			    struct cea_sad **sads)
>   {
>   	const struct cea_db *db;
>   	struct cea_db_iter iter;
>   	int count = 0;
>   
> -	cea_db_iter_edid_begin(edid, &iter);
> +	cea_db_iter_edid_begin(drm_edid ? drm_edid->edid : NULL, &iter);
>   	cea_db_iter_for_each(db, &iter) {
>   		if (cea_db_tag(db) == CTA_DB_AUDIO) {
>   			int j;
> @@ -5015,6 +5005,24 @@ int drm_edid_to_sad(const struct edid *edid, struct cea_sad **sads)
>   
>   	return count;
>   }
> +
> +/**
> + * drm_edid_to_sad - extracts SADs from EDID
> + * @edid: EDID to parse
> + * @sads: pointer that will be set to the extracted SADs
> + *
> + * Looks for CEA EDID block and extracts SADs (Short Audio Descriptors) from it.
> + *
> + * Note: The returned pointer needs to be freed using kfree().
> + *
> + * Return: The number of found SADs or negative number on error.
> + */
> +int drm_edid_to_sad(const struct edid *edid, struct cea_sad **sads)
> +{
> +	struct drm_edid drm_edid;
> +
> +	return _drm_edid_to_sad(drm_edid_legacy_init(&drm_edid, edid), sads);
> +}
>   EXPORT_SYMBOL(drm_edid_to_sad);
>   
>   /**
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 61551ce0db88..dee09359bbc3 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -4972,24 +4972,14 @@  static void drm_edid_to_eld(struct drm_connector *connector,
 		      drm_eld_size(eld), total_sad_count);
 }
 
-/**
- * drm_edid_to_sad - extracts SADs from EDID
- * @edid: EDID to parse
- * @sads: pointer that will be set to the extracted SADs
- *
- * Looks for CEA EDID block and extracts SADs (Short Audio Descriptors) from it.
- *
- * Note: The returned pointer needs to be freed using kfree().
- *
- * Return: The number of found SADs or negative number on error.
- */
-int drm_edid_to_sad(const struct edid *edid, struct cea_sad **sads)
+static int _drm_edid_to_sad(const struct drm_edid *drm_edid,
+			    struct cea_sad **sads)
 {
 	const struct cea_db *db;
 	struct cea_db_iter iter;
 	int count = 0;
 
-	cea_db_iter_edid_begin(edid, &iter);
+	cea_db_iter_edid_begin(drm_edid ? drm_edid->edid : NULL, &iter);
 	cea_db_iter_for_each(db, &iter) {
 		if (cea_db_tag(db) == CTA_DB_AUDIO) {
 			int j;
@@ -5015,6 +5005,24 @@  int drm_edid_to_sad(const struct edid *edid, struct cea_sad **sads)
 
 	return count;
 }
+
+/**
+ * drm_edid_to_sad - extracts SADs from EDID
+ * @edid: EDID to parse
+ * @sads: pointer that will be set to the extracted SADs
+ *
+ * Looks for CEA EDID block and extracts SADs (Short Audio Descriptors) from it.
+ *
+ * Note: The returned pointer needs to be freed using kfree().
+ *
+ * Return: The number of found SADs or negative number on error.
+ */
+int drm_edid_to_sad(const struct edid *edid, struct cea_sad **sads)
+{
+	struct drm_edid drm_edid;
+
+	return _drm_edid_to_sad(drm_edid_legacy_init(&drm_edid, edid), sads);
+}
 EXPORT_SYMBOL(drm_edid_to_sad);
 
 /**