All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: fsl_spdif: add ALSA event on dpll locked
@ 2022-09-08 13:33 robert.rosengren
  2022-09-09  8:17 ` Shengjiu Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: robert.rosengren @ 2022-09-08 13:33 UTC (permalink / raw)
  To: Shengjiu Wang, Xiubo Li, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai
  Cc: Nicolin Chen, kernel, alsa-devel, Fabio Estevam

From: Robert Rosengren <robert.rosengren@axis.com>

Add an ALSA event on the RX Sample Rate controller upon the dpll locked
interrupt, making it possible for audio applications to monitor changes
in the hardware.

Signed-off-by: Robert Rosengren <robert.rosengren@axis.com>
---
 sound/soc/fsl/fsl_spdif.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c
index 7fc1c96929bb..1679a21ffdca 100644
--- a/sound/soc/fsl/fsl_spdif.c
+++ b/sound/soc/fsl/fsl_spdif.c
@@ -44,6 +44,8 @@ static u8 srpc_dpll_locked[] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0xa, 0xb };
 
 #define DEFAULT_RXCLK_SRC	1
 
+#define RX_SAMPLE_RATE_KCONTROL "RX Sample Rate"
+
 /**
  * struct fsl_spdif_soc_data: soc specific data
  *
@@ -122,6 +124,7 @@ struct fsl_spdif_priv {
 	const struct fsl_spdif_soc_data *soc;
 	struct spdif_mixer_control fsl_spdif_control;
 	struct snd_soc_dai_driver cpu_dai_drv;
+	struct snd_soc_dai *dai;
 	struct platform_device *pdev;
 	struct regmap *regmap;
 	bool dpll_locked;
@@ -223,9 +226,19 @@ static void spdif_irq_dpll_lock(struct fsl_spdif_priv *spdif_priv)
 	locked &= SRPC_DPLL_LOCKED;
 
 	dev_dbg(&pdev->dev, "isr: Rx dpll %s \n",
-			locked ? "locked" : "loss lock");
+		locked ? "locked" : "loss lock");
 
 	spdif_priv->dpll_locked = locked ? true : false;
+
+	if (spdif_priv->dai) {
+		struct snd_soc_component *component = spdif_priv->dai->component;
+		struct snd_kcontrol *kctl = snd_soc_card_get_kcontrol(component->card,
+						RX_SAMPLE_RATE_KCONTROL);
+
+		if (kctl)
+			snd_ctl_notify(component->card->snd_card,
+				SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id);
+	}
 }
 
 /* Receiver found illegal symbol interrupt handler */
@@ -1197,7 +1210,7 @@ static struct snd_kcontrol_new fsl_spdif_ctrls[] = {
 	/* DPLL lock info get controller */
 	{
 		.iface = SNDRV_CTL_ELEM_IFACE_PCM,
-		.name = "RX Sample Rate",
+		.name = RX_SAMPLE_RATE_KCONTROL,
 		.access = SNDRV_CTL_ELEM_ACCESS_READ |
 			SNDRV_CTL_ELEM_ACCESS_VOLATILE,
 		.info = fsl_spdif_rxrate_info,
@@ -1241,6 +1254,7 @@ static struct snd_kcontrol_new fsl_spdif_ctrls_rcm[] = {
 static int fsl_spdif_dai_probe(struct snd_soc_dai *dai)
 {
 	struct fsl_spdif_priv *spdif_private = snd_soc_dai_get_drvdata(dai);
+	spdif_private->dai = dai;
 
 	snd_soc_dai_init_dma_data(dai, &spdif_private->dma_params_tx,
 				  &spdif_private->dma_params_rx);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] ASoC: fsl_spdif: add ALSA event on dpll locked
  2022-09-08 13:33 [PATCH] ASoC: fsl_spdif: add ALSA event on dpll locked robert.rosengren
@ 2022-09-09  8:17 ` Shengjiu Wang
  2022-09-09  8:26 ` Shengjiu Wang
  2022-09-09  8:27 ` Jaroslav Kysela
  2 siblings, 0 replies; 6+ messages in thread
From: Shengjiu Wang @ 2022-09-09  8:17 UTC (permalink / raw)
  To: robert.rosengren
  Cc: alsa-devel, Liam Girdwood, Xiubo Li, Takashi Iwai, Nicolin Chen,
	Mark Brown, kernel, Fabio Estevam

Hi

On Thu, Sep 8, 2022 at 9:33 PM <robert.rosengren@axis.com> wrote:

> From: Robert Rosengren <robert.rosengren@axis.com>
>
> Add an ALSA event on the RX Sample Rate controller upon the dpll locked
> interrupt, making it possible for audio applications to monitor changes
> in the hardware.
>
> Signed-off-by: Robert Rosengren <robert.rosengren@axis.com>
> ---
>  sound/soc/fsl/fsl_spdif.c | 18 ++++++++++++++++--
>  1 file changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c
> index 7fc1c96929bb..1679a21ffdca 100644
> --- a/sound/soc/fsl/fsl_spdif.c
> +++ b/sound/soc/fsl/fsl_spdif.c
> @@ -44,6 +44,8 @@ static u8 srpc_dpll_locked[] = { 0x0, 0x1, 0x2, 0x3,
> 0x4, 0xa, 0xb };
>
>  #define DEFAULT_RXCLK_SRC      1
>
> +#define RX_SAMPLE_RATE_KCONTROL "RX Sample Rate"
> +
>  /**
>   * struct fsl_spdif_soc_data: soc specific data
>   *
> @@ -122,6 +124,7 @@ struct fsl_spdif_priv {
>         const struct fsl_spdif_soc_data *soc;
>         struct spdif_mixer_control fsl_spdif_control;
>         struct snd_soc_dai_driver cpu_dai_drv;
> +       struct snd_soc_dai *dai;
>         struct platform_device *pdev;
>         struct regmap *regmap;
>         bool dpll_locked;
> @@ -223,9 +226,19 @@ static void spdif_irq_dpll_lock(struct fsl_spdif_priv
> *spdif_priv)
>         locked &= SRPC_DPLL_LOCKED;
>
>         dev_dbg(&pdev->dev, "isr: Rx dpll %s \n",
> -                       locked ? "locked" : "loss lock");
> +               locked ? "locked" : "loss lock");
>
>         spdif_priv->dpll_locked = locked ? true : false;
> +
> +       if (spdif_priv->dai) {
> +               struct snd_soc_component *component =
> spdif_priv->dai->component;
> +               struct snd_kcontrol *kctl =
> snd_soc_card_get_kcontrol(component->card,
> +                                               RX_SAMPLE_RATE_KCONTROL);
>

Alignment should match open parenthesis


> +
> +               if (kctl)
> +                       snd_ctl_notify(component->card->snd_card,
> +                               SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id);
>
Alignment should match open parenthesis

Best regards
Wang shengjiu

> +       }
>  }
>
>  /* Receiver found illegal symbol interrupt handler */
> @@ -1197,7 +1210,7 @@ static struct snd_kcontrol_new fsl_spdif_ctrls[] = {
>         /* DPLL lock info get controller */
>         {
>                 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
> -               .name = "RX Sample Rate",
> +               .name = RX_SAMPLE_RATE_KCONTROL,
>                 .access = SNDRV_CTL_ELEM_ACCESS_READ |
>                         SNDRV_CTL_ELEM_ACCESS_VOLATILE,
>                 .info = fsl_spdif_rxrate_info,
> @@ -1241,6 +1254,7 @@ static struct snd_kcontrol_new fsl_spdif_ctrls_rcm[]
> = {
>  static int fsl_spdif_dai_probe(struct snd_soc_dai *dai)
>  {
>         struct fsl_spdif_priv *spdif_private =
> snd_soc_dai_get_drvdata(dai);
> +       spdif_private->dai = dai;
>
>         snd_soc_dai_init_dma_data(dai, &spdif_private->dma_params_tx,
>                                   &spdif_private->dma_params_rx);
> --
> 2.30.2
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ASoC: fsl_spdif: add ALSA event on dpll locked
  2022-09-08 13:33 [PATCH] ASoC: fsl_spdif: add ALSA event on dpll locked robert.rosengren
  2022-09-09  8:17 ` Shengjiu Wang
@ 2022-09-09  8:26 ` Shengjiu Wang
  2022-09-16  6:09   ` Robert Rosengren
  2022-09-09  8:27 ` Jaroslav Kysela
  2 siblings, 1 reply; 6+ messages in thread
From: Shengjiu Wang @ 2022-09-09  8:26 UTC (permalink / raw)
  To: robert.rosengren
  Cc: alsa-devel, Liam Girdwood, Xiubo Li, Takashi Iwai, Nicolin Chen,
	Mark Brown, kernel, Fabio Estevam

Hi

On Thu, Sep 8, 2022 at 9:33 PM <robert.rosengren@axis.com> wrote:

> From: Robert Rosengren <robert.rosengren@axis.com>
>
> Add an ALSA event on the RX Sample Rate controller upon the dpll locked
> interrupt, making it possible for audio applications to monitor changes
> in the hardware.
>
> Signed-off-by: Robert Rosengren <robert.rosengren@axis.com>
> ---
>  sound/soc/fsl/fsl_spdif.c | 18 ++++++++++++++++--
>  1 file changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c
> index 7fc1c96929bb..1679a21ffdca 100644
> --- a/sound/soc/fsl/fsl_spdif.c
> +++ b/sound/soc/fsl/fsl_spdif.c
> @@ -44,6 +44,8 @@ static u8 srpc_dpll_locked[] = { 0x0, 0x1, 0x2, 0x3,
> 0x4, 0xa, 0xb };
>
>  #define DEFAULT_RXCLK_SRC      1
>
> +#define RX_SAMPLE_RATE_KCONTROL "RX Sample Rate"
> +
>  /**
>   * struct fsl_spdif_soc_data: soc specific data
>   *
> @@ -122,6 +124,7 @@ struct fsl_spdif_priv {
>         const struct fsl_spdif_soc_data *soc;
>         struct spdif_mixer_control fsl_spdif_control;
>         struct snd_soc_dai_driver cpu_dai_drv;
> +       struct snd_soc_dai *dai;
>

warning: Function parameter or member 'dai' not described in
'fsl_spdif_priv'
please add.

Best regards
Wang shengjiu

>         struct platform_device *pdev;
>         struct regmap *regmap;
>         bool dpll_locked;
> @@ -223,9 +226,19 @@ static void spdif_irq_dpll_lock(struct fsl_spdif_priv
> *spdif_priv)
>         locked &= SRPC_DPLL_LOCKED;
>
>         dev_dbg(&pdev->dev, "isr: Rx dpll %s \n",
> -                       locked ? "locked" : "loss lock");
> +               locked ? "locked" : "loss lock");
>
>         spdif_priv->dpll_locked = locked ? true : false;
> +
> +       if (spdif_priv->dai) {
> +               struct snd_soc_component *component =
> spdif_priv->dai->component;
> +               struct snd_kcontrol *kctl =
> snd_soc_card_get_kcontrol(component->card,
> +                                               RX_SAMPLE_RATE_KCONTROL);
> +
> +               if (kctl)
> +                       snd_ctl_notify(component->card->snd_card,
> +                               SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id);
> +       }
>  }
>
>  /* Receiver found illegal symbol interrupt handler */
> @@ -1197,7 +1210,7 @@ static struct snd_kcontrol_new fsl_spdif_ctrls[] = {
>         /* DPLL lock info get controller */
>         {
>                 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
> -               .name = "RX Sample Rate",
> +               .name = RX_SAMPLE_RATE_KCONTROL,
>                 .access = SNDRV_CTL_ELEM_ACCESS_READ |
>                         SNDRV_CTL_ELEM_ACCESS_VOLATILE,
>                 .info = fsl_spdif_rxrate_info,
> @@ -1241,6 +1254,7 @@ static struct snd_kcontrol_new fsl_spdif_ctrls_rcm[]
> = {
>  static int fsl_spdif_dai_probe(struct snd_soc_dai *dai)
>  {
>         struct fsl_spdif_priv *spdif_private =
> snd_soc_dai_get_drvdata(dai);
> +       spdif_private->dai = dai;
>
>         snd_soc_dai_init_dma_data(dai, &spdif_private->dma_params_tx,
>                                   &spdif_private->dma_params_rx);
> --
> 2.30.2
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ASoC: fsl_spdif: add ALSA event on dpll locked
  2022-09-08 13:33 [PATCH] ASoC: fsl_spdif: add ALSA event on dpll locked robert.rosengren
  2022-09-09  8:17 ` Shengjiu Wang
  2022-09-09  8:26 ` Shengjiu Wang
@ 2022-09-09  8:27 ` Jaroslav Kysela
  2022-09-16  6:12   ` Robert Rosengren
  2 siblings, 1 reply; 6+ messages in thread
From: Jaroslav Kysela @ 2022-09-09  8:27 UTC (permalink / raw)
  To: robert.rosengren, Shengjiu Wang, Xiubo Li, Liam Girdwood,
	Mark Brown, Takashi Iwai
  Cc: Nicolin Chen, kernel, alsa-devel, Fabio Estevam

On 08. 09. 22 15:33, robert.rosengren@axis.com wrote:
> From: Robert Rosengren <robert.rosengren@axis.com>
> 
> Add an ALSA event on the RX Sample Rate controller upon the dpll locked
> interrupt, making it possible for audio applications to monitor changes
> in the hardware.
> 
> Signed-off-by: Robert Rosengren <robert.rosengren@axis.com>
> ---
>   sound/soc/fsl/fsl_spdif.c | 18 ++++++++++++++++--
>   1 file changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c
> index 7fc1c96929bb..1679a21ffdca 100644
> --- a/sound/soc/fsl/fsl_spdif.c
> +++ b/sound/soc/fsl/fsl_spdif.c
> @@ -44,6 +44,8 @@ static u8 srpc_dpll_locked[] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0xa, 0xb };
>   
>   #define DEFAULT_RXCLK_SRC	1
>   
> +#define RX_SAMPLE_RATE_KCONTROL "RX Sample Rate"
> +
>   /**
>    * struct fsl_spdif_soc_data: soc specific data
>    *
> @@ -122,6 +124,7 @@ struct fsl_spdif_priv {
>   	const struct fsl_spdif_soc_data *soc;
>   	struct spdif_mixer_control fsl_spdif_control;
>   	struct snd_soc_dai_driver cpu_dai_drv;
> +	struct snd_soc_dai *dai;
>   	struct platform_device *pdev;
>   	struct regmap *regmap;
>   	bool dpll_locked;
> @@ -223,9 +226,19 @@ static void spdif_irq_dpll_lock(struct fsl_spdif_priv *spdif_priv)
>   	locked &= SRPC_DPLL_LOCKED;
>   
>   	dev_dbg(&pdev->dev, "isr: Rx dpll %s \n",
> -			locked ? "locked" : "loss lock");
> +		locked ? "locked" : "loss lock");
>   
>   	spdif_priv->dpll_locked = locked ? true : false;
> +
> +	if (spdif_priv->dai) {
> +		struct snd_soc_component *component = spdif_priv->dai->component;
> +		struct snd_kcontrol *kctl = snd_soc_card_get_kcontrol(component->card,
> +						RX_SAMPLE_RATE_KCONTROL);

I would cache the pointer to snd_kcontrol structure in spdif_priv. This lookup 
is expensive for the interrupt routine in my eyes.

					Jaroslav

-- 
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ASoC: fsl_spdif: add ALSA event on dpll locked
  2022-09-09  8:26 ` Shengjiu Wang
@ 2022-09-16  6:09   ` Robert Rosengren
  0 siblings, 0 replies; 6+ messages in thread
From: Robert Rosengren @ 2022-09-16  6:09 UTC (permalink / raw)
  To: Shengjiu Wang, Robert Rosengren
  Cc: alsa-devel, Liam Girdwood, Xiubo Li, Takashi Iwai, Nicolin Chen,
	Mark Brown, kernel, Fabio Estevam

Hi,

On 9/9/22 10:26, Shengjiu Wang wrote:
>
>     +      struct snd_soc_dai *dai;
>
>
> warning: Function parameter or member 'dai' not described in 
> 'fsl_spdif_priv'
> please add.
> Best regards
> Wang shengjiu

Thanks! Sorry for a bit late answer, but submitted new patch few days
ago with fix for this and the other remarks.

Best regards,
Robert



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ASoC: fsl_spdif: add ALSA event on dpll locked
  2022-09-09  8:27 ` Jaroslav Kysela
@ 2022-09-16  6:12   ` Robert Rosengren
  0 siblings, 0 replies; 6+ messages in thread
From: Robert Rosengren @ 2022-09-16  6:12 UTC (permalink / raw)
  To: Jaroslav Kysela, Robert Rosengren, Shengjiu Wang, Xiubo Li,
	Liam Girdwood, Mark Brown, Takashi Iwai
  Cc: Nicolin Chen, kernel, alsa-devel, Fabio Estevam

Hi,

On 9/9/22 10:27, Jaroslav Kysela wrote:
>
> I would cache the pointer to snd_kcontrol structure in spdif_priv. 
> This lookup
> is expensive for the interrupt routine in my eyes.
>
>                                         Jaroslav
Thanks! Sorry for a bit late answer, but re-worked solution submitted 
few days ago where caching as you suggest is implemented.

Best regards,
Robert

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-09-16  6:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-08 13:33 [PATCH] ASoC: fsl_spdif: add ALSA event on dpll locked robert.rosengren
2022-09-09  8:17 ` Shengjiu Wang
2022-09-09  8:26 ` Shengjiu Wang
2022-09-16  6:09   ` Robert Rosengren
2022-09-09  8:27 ` Jaroslav Kysela
2022-09-16  6:12   ` Robert Rosengren

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.