2024-05-31 20:07:46

by Dmitry Baryshkov

[permalink] [raw]
Subject: [PATCH v4 1/9] drm/connector: hdmi: accept NULL for Audio Infoframe

Allow passing NULL as audio infoframe as a way to disable Audio
Infoframe generation.

Signed-off-by: Dmitry Baryshkov <[email protected]>
---
drivers/gpu/drm/display/drm_hdmi_state_helper.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/display/drm_hdmi_state_helper.c b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
index ce96837eea65..5356723d21f5 100644
--- a/drivers/gpu/drm/display/drm_hdmi_state_helper.c
+++ b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
@@ -681,7 +681,7 @@ EXPORT_SYMBOL(drm_atomic_helper_connector_hdmi_update_infoframes);
/**
* drm_atomic_helper_connector_hdmi_update_audio_infoframe - Update the Audio Infoframe
* @connector: A pointer to the HDMI connector
- * @frame: A pointer to the audio infoframe to write
+ * @frame: A pointer to the audio infoframe to write or NULL to disable sending the frame
*
* This function is meant for HDMI connector drivers to update their
* audio infoframe. It will typically be used in one of the ALSA hooks
@@ -704,10 +704,16 @@ drm_atomic_helper_connector_hdmi_update_audio_infoframe(struct drm_connector *co

mutex_lock(&connector->hdmi.infoframes.lock);

- memcpy(&infoframe->data, frame, sizeof(infoframe->data));
- infoframe->set = true;
+ if (frame) {
+ memcpy(&infoframe->data, frame, sizeof(infoframe->data));
+ infoframe->set = true;
+
+ ret = write_infoframe(connector, infoframe);
+ } else {
+ infoframe->set = false;

- ret = write_infoframe(connector, infoframe);
+ ret = clear_infoframe(connector, infoframe);
+ }

mutex_unlock(&connector->hdmi.infoframes.lock);


--
2.39.2



2024-06-03 09:09:53

by Maxime Ripard

[permalink] [raw]
Subject: Re: [PATCH v4 1/9] drm/connector: hdmi: accept NULL for Audio Infoframe

Hi,

Sorry for not answering your mail on the previous version sooner.

On Fri, May 31, 2024 at 11:07:24PM GMT, Dmitry Baryshkov wrote:
> Allow passing NULL as audio infoframe as a way to disable Audio
> Infoframe generation.
>
> Signed-off-by: Dmitry Baryshkov <[email protected]>
> ---
> drivers/gpu/drm/display/drm_hdmi_state_helper.c | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/display/drm_hdmi_state_helper.c b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
> index ce96837eea65..5356723d21f5 100644
> --- a/drivers/gpu/drm/display/drm_hdmi_state_helper.c
> +++ b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
> @@ -681,7 +681,7 @@ EXPORT_SYMBOL(drm_atomic_helper_connector_hdmi_update_infoframes);
> /**
> * drm_atomic_helper_connector_hdmi_update_audio_infoframe - Update the Audio Infoframe
> * @connector: A pointer to the HDMI connector
> - * @frame: A pointer to the audio infoframe to write
> + * @frame: A pointer to the audio infoframe to write or NULL to disable sending the frame

I'm still two-minded about this. I think I would like a separate helper
better, to also make things consistent with the HDMI helpers.

Most importantly, it looks like you're not using it at all in your series?

> * This function is meant for HDMI connector drivers to update their
> * audio infoframe. It will typically be used in one of the ALSA hooks
> @@ -704,10 +704,16 @@ drm_atomic_helper_connector_hdmi_update_audio_infoframe(struct drm_connector *co
>
> mutex_lock(&connector->hdmi.infoframes.lock);
>
> - memcpy(&infoframe->data, frame, sizeof(infoframe->data));
> - infoframe->set = true;
> + if (frame) {
> + memcpy(&infoframe->data, frame, sizeof(infoframe->data));
> + infoframe->set = true;
> +
> + ret = write_infoframe(connector, infoframe);
> + } else {
> + infoframe->set = false;
>
> - ret = write_infoframe(connector, infoframe);
> + ret = clear_infoframe(connector, infoframe);
> + }

We should probably clear infoframe->data here too

Maxime


Attachments:
(No filename) (2.06 kB)
signature.asc (281.00 B)
Download all attachments

2024-06-03 10:06:08

by Dmitry Baryshkov

[permalink] [raw]
Subject: Re: [PATCH v4 1/9] drm/connector: hdmi: accept NULL for Audio Infoframe

On Mon, Jun 03, 2024 at 11:09:40AM +0200, Maxime Ripard wrote:
> Hi,
>
> Sorry for not answering your mail on the previous version sooner.
>
> On Fri, May 31, 2024 at 11:07:24PM GMT, Dmitry Baryshkov wrote:
> > Allow passing NULL as audio infoframe as a way to disable Audio
> > Infoframe generation.
> >
> > Signed-off-by: Dmitry Baryshkov <[email protected]>
> > ---
> > drivers/gpu/drm/display/drm_hdmi_state_helper.c | 14 ++++++++++----
> > 1 file changed, 10 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/display/drm_hdmi_state_helper.c b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
> > index ce96837eea65..5356723d21f5 100644
> > --- a/drivers/gpu/drm/display/drm_hdmi_state_helper.c
> > +++ b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
> > @@ -681,7 +681,7 @@ EXPORT_SYMBOL(drm_atomic_helper_connector_hdmi_update_infoframes);
> > /**
> > * drm_atomic_helper_connector_hdmi_update_audio_infoframe - Update the Audio Infoframe
> > * @connector: A pointer to the HDMI connector
> > - * @frame: A pointer to the audio infoframe to write
> > + * @frame: A pointer to the audio infoframe to write or NULL to disable sending the frame
>
> I'm still two-minded about this. I think I would like a separate helper
> better, to also make things consistent with the HDMI helpers.
>
> Most importantly, it looks like you're not using it at all in your series?

It should have been a part of msm_hdmi_audio_disable(), but it seems
with all the refactorings I forgot to use it. I'll check again the
behaviour and either drop this patch or add a separate helper and fix
other comments below.

>
> > * This function is meant for HDMI connector drivers to update their
> > * audio infoframe. It will typically be used in one of the ALSA hooks
> > @@ -704,10 +704,16 @@ drm_atomic_helper_connector_hdmi_update_audio_infoframe(struct drm_connector *co
> >
> > mutex_lock(&connector->hdmi.infoframes.lock);
> >
> > - memcpy(&infoframe->data, frame, sizeof(infoframe->data));
> > - infoframe->set = true;
> > + if (frame) {
> > + memcpy(&infoframe->data, frame, sizeof(infoframe->data));
> > + infoframe->set = true;
> > +
> > + ret = write_infoframe(connector, infoframe);
> > + } else {
> > + infoframe->set = false;
> >
> > - ret = write_infoframe(connector, infoframe);
> > + ret = clear_infoframe(connector, infoframe);
> > + }
>
> We should probably clear infoframe->data here too


--
With best wishes
Dmitry