diff mbox series

[v7,10/22] drm/edid: add helper for HDMI VSDB audio latency field length

Message ID da4293203ef2ddeb0bf66a2bfdbc129ab609c543.1672826282.git.jani.nikula@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/edid: info & modes parsing and drm_edid refactors | expand

Commit Message

Jani Nikula Jan. 4, 2023, 10:05 a.m. UTC
Add a helper for skipping the HDMI VSDB audio latency fields.

There's a functional change for HDMI VSDB blocks that do not respect the
spec: "I_Latency_Fields_Present shall be zero if Latency_Fields_Present
is zero". We assume this to hold when skipping the latency fields, and
ignore non-zero I_Latency_Fields_Present if Latency_Fields_Present is
zero.

Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/drm_edid.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

Comments

Ville Syrjälä Jan. 18, 2023, 3:42 p.m. UTC | #1
On Wed, Jan 04, 2023 at 12:05:25PM +0200, Jani Nikula wrote:
> Add a helper for skipping the HDMI VSDB audio latency fields.
> 
> There's a functional change for HDMI VSDB blocks that do not respect the
> spec: "I_Latency_Fields_Present shall be zero if Latency_Fields_Present
> is zero". We assume this to hold when skipping the latency fields, and
> ignore non-zero I_Latency_Fields_Present if Latency_Fields_Present is
> zero.
> 
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

> ---
>  drivers/gpu/drm/drm_edid.c | 18 +++++++++++-------
>  1 file changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 847076b29594..93067b8dd9f6 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -4695,6 +4695,16 @@ static bool hdmi_vsdb_i_latency_present(const u8 *db)
>  	return hdmi_vsdb_latency_present(db) && db[8] & BIT(6);
>  }
>  
> +static int hdmi_vsdb_latency_length(const u8 *db)
> +{
> +	if (hdmi_vsdb_i_latency_present(db))
> +		return 4;
> +	else if (hdmi_vsdb_latency_present(db))
> +		return 2;
> +	else
> +		return 0;
> +}
> +
>  /*
>   * do_hdmi_vsdb_modes - Parse the HDMI Vendor Specific data block
>   * @connector: connector corresponding to the HDMI sink
> @@ -4720,13 +4730,7 @@ do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len)
>  	if (!(db[8] & (1 << 5)))
>  		goto out;
>  
> -	/* Latency_Fields_Present */
> -	if (db[8] & (1 << 7))
> -		offset += 2;
> -
> -	/* I_Latency_Fields_Present */
> -	if (db[8] & (1 << 6))
> -		offset += 2;
> +	offset += hdmi_vsdb_latency_length(db);
>  
>  	/* the declared length is not long enough for the 2 first bytes
>  	 * of additional video format capabilities */
> -- 
> 2.34.1
Jani Nikula Jan. 19, 2023, 9:44 a.m. UTC | #2
On Wed, 18 Jan 2023, Ville Syrjälä <ville.syrjala@linux.intel.com> wrote:
> On Wed, Jan 04, 2023 at 12:05:25PM +0200, Jani Nikula wrote:
>> Add a helper for skipping the HDMI VSDB audio latency fields.
>> 
>> There's a functional change for HDMI VSDB blocks that do not respect the
>> spec: "I_Latency_Fields_Present shall be zero if Latency_Fields_Present
>> is zero". We assume this to hold when skipping the latency fields, and
>> ignore non-zero I_Latency_Fields_Present if Latency_Fields_Present is
>> zero.
>> 
>> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
>> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>
> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Thanks for the reviews so far, pushed up to and including this patch to
drm-misc-next.

BR,
Jani.


>
>> ---
>>  drivers/gpu/drm/drm_edid.c | 18 +++++++++++-------
>>  1 file changed, 11 insertions(+), 7 deletions(-)
>> 
>> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
>> index 847076b29594..93067b8dd9f6 100644
>> --- a/drivers/gpu/drm/drm_edid.c
>> +++ b/drivers/gpu/drm/drm_edid.c
>> @@ -4695,6 +4695,16 @@ static bool hdmi_vsdb_i_latency_present(const u8 *db)
>>  	return hdmi_vsdb_latency_present(db) && db[8] & BIT(6);
>>  }
>>  
>> +static int hdmi_vsdb_latency_length(const u8 *db)
>> +{
>> +	if (hdmi_vsdb_i_latency_present(db))
>> +		return 4;
>> +	else if (hdmi_vsdb_latency_present(db))
>> +		return 2;
>> +	else
>> +		return 0;
>> +}
>> +
>>  /*
>>   * do_hdmi_vsdb_modes - Parse the HDMI Vendor Specific data block
>>   * @connector: connector corresponding to the HDMI sink
>> @@ -4720,13 +4730,7 @@ do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len)
>>  	if (!(db[8] & (1 << 5)))
>>  		goto out;
>>  
>> -	/* Latency_Fields_Present */
>> -	if (db[8] & (1 << 7))
>> -		offset += 2;
>> -
>> -	/* I_Latency_Fields_Present */
>> -	if (db[8] & (1 << 6))
>> -		offset += 2;
>> +	offset += hdmi_vsdb_latency_length(db);
>>  
>>  	/* the declared length is not long enough for the 2 first bytes
>>  	 * of additional video format capabilities */
>> -- 
>> 2.34.1
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 847076b29594..93067b8dd9f6 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -4695,6 +4695,16 @@  static bool hdmi_vsdb_i_latency_present(const u8 *db)
 	return hdmi_vsdb_latency_present(db) && db[8] & BIT(6);
 }
 
+static int hdmi_vsdb_latency_length(const u8 *db)
+{
+	if (hdmi_vsdb_i_latency_present(db))
+		return 4;
+	else if (hdmi_vsdb_latency_present(db))
+		return 2;
+	else
+		return 0;
+}
+
 /*
  * do_hdmi_vsdb_modes - Parse the HDMI Vendor Specific data block
  * @connector: connector corresponding to the HDMI sink
@@ -4720,13 +4730,7 @@  do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len)
 	if (!(db[8] & (1 << 5)))
 		goto out;
 
-	/* Latency_Fields_Present */
-	if (db[8] & (1 << 7))
-		offset += 2;
-
-	/* I_Latency_Fields_Present */
-	if (db[8] & (1 << 6))
-		offset += 2;
+	offset += hdmi_vsdb_latency_length(db);
 
 	/* the declared length is not long enough for the 2 first bytes
 	 * of additional video format capabilities */