All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ASoC: fsl_spdif: add ALSA event on dpll locked
@ 2022-09-12 10:54 Robert Rosengren
  2022-09-16  7:34 ` Shengjiu Wang
  2022-09-19 23:10 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Robert Rosengren @ 2022-09-12 10:54 UTC (permalink / raw)
  To: Shengjiu Wang, Xiubo Li, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai
  Cc: Nicolin Chen, kernel, alsa-devel, Fabio Estevam

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>
---

Notes:
    v2: Cache RX Sample Rate kcontrol to avoid lookup in interrupt.
    Properly add description to fsl_spdif_priv.
    Fix indentation.

 sound/soc/fsl/fsl_spdif.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c
index 7fc1c96929bb..275aba8e0c46 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
  *
@@ -98,6 +100,8 @@ struct spdif_mixer_control {
  * @soc: SPDIF soc data
  * @fsl_spdif_control: SPDIF control data
  * @cpu_dai_drv: cpu dai driver
+ * @snd_card: sound card pointer
+ * @rxrate_kcontrol: kcontrol for RX Sample Rate
  * @pdev: platform device pointer
  * @regmap: regmap handler
  * @dpll_locked: dpll lock flag
@@ -122,6 +126,8 @@ 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_card *snd_card;
+	struct snd_kcontrol *rxrate_kcontrol;
 	struct platform_device *pdev;
 	struct regmap *regmap;
 	bool dpll_locked;
@@ -226,6 +232,12 @@ static void spdif_irq_dpll_lock(struct fsl_spdif_priv *spdif_priv)
 			locked ? "locked" : "loss lock");
 
 	spdif_priv->dpll_locked = locked ? true : false;
+
+	if (spdif_priv->snd_card && spdif_priv->rxrate_kcontrol) {
+		snd_ctl_notify(spdif_priv->snd_card,
+			       SNDRV_CTL_EVENT_MASK_VALUE,
+			       &spdif_priv->rxrate_kcontrol->id);
+	}
 }
 
 /* Receiver found illegal symbol interrupt handler */
@@ -1197,7 +1209,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,
@@ -1251,6 +1263,13 @@ static int fsl_spdif_dai_probe(struct snd_soc_dai *dai)
 		snd_soc_add_dai_controls(dai, fsl_spdif_ctrls_rcm,
 					 ARRAY_SIZE(fsl_spdif_ctrls_rcm));
 
+	spdif_private->snd_card = dai->component->card->snd_card;
+	spdif_private->rxrate_kcontrol = snd_soc_card_get_kcontrol(dai->component->card,
+								   RX_SAMPLE_RATE_KCONTROL);
+	if (!spdif_private->rxrate_kcontrol)
+		dev_err(&spdif_private->pdev->dev, "failed to get %s kcontrol\n",
+			RX_SAMPLE_RATE_KCONTROL);
+
 	/*Clear the val bit for Tx*/
 	regmap_update_bits(spdif_private->regmap, REG_SPDIF_SCR,
 			   SCR_VAL_MASK, SCR_VAL_CLEAR);
-- 
2.30.2


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

* Re: [PATCH v2] ASoC: fsl_spdif: add ALSA event on dpll locked
  2022-09-12 10:54 [PATCH v2] ASoC: fsl_spdif: add ALSA event on dpll locked Robert Rosengren
@ 2022-09-16  7:34 ` Shengjiu Wang
  2022-09-19 23:10 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Shengjiu Wang @ 2022-09-16  7:34 UTC (permalink / raw)
  To: Robert Rosengren
  Cc: alsa-devel, Liam Girdwood, Xiubo Li, Takashi Iwai, Nicolin Chen,
	Mark Brown, kernel, Fabio Estevam

On Mon, Sep 12, 2022 at 6:54 PM Robert Rosengren <robert.rosengren@axis.com>
wrote:

> 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>
>

Acked-by: Shengjiu Wang <shengjiu.wang@gmail.com>

Best regards
Wang Shengjiu

> ---
>
> Notes:
>     v2: Cache RX Sample Rate kcontrol to avoid lookup in interrupt.
>     Properly add description to fsl_spdif_priv.
>     Fix indentation.
>
>  sound/soc/fsl/fsl_spdif.c | 21 ++++++++++++++++++++-
>  1 file changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c
> index 7fc1c96929bb..275aba8e0c46 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
>   *
> @@ -98,6 +100,8 @@ struct spdif_mixer_control {
>   * @soc: SPDIF soc data
>   * @fsl_spdif_control: SPDIF control data
>   * @cpu_dai_drv: cpu dai driver
> + * @snd_card: sound card pointer
> + * @rxrate_kcontrol: kcontrol for RX Sample Rate
>   * @pdev: platform device pointer
>   * @regmap: regmap handler
>   * @dpll_locked: dpll lock flag
> @@ -122,6 +126,8 @@ 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_card *snd_card;
> +       struct snd_kcontrol *rxrate_kcontrol;
>         struct platform_device *pdev;
>         struct regmap *regmap;
>         bool dpll_locked;
> @@ -226,6 +232,12 @@ static void spdif_irq_dpll_lock(struct fsl_spdif_priv
> *spdif_priv)
>                         locked ? "locked" : "loss lock");
>
>         spdif_priv->dpll_locked = locked ? true : false;
> +
> +       if (spdif_priv->snd_card && spdif_priv->rxrate_kcontrol) {
> +               snd_ctl_notify(spdif_priv->snd_card,
> +                              SNDRV_CTL_EVENT_MASK_VALUE,
> +                              &spdif_priv->rxrate_kcontrol->id);
> +       }
>  }
>
>  /* Receiver found illegal symbol interrupt handler */
> @@ -1197,7 +1209,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,
> @@ -1251,6 +1263,13 @@ static int fsl_spdif_dai_probe(struct snd_soc_dai
> *dai)
>                 snd_soc_add_dai_controls(dai, fsl_spdif_ctrls_rcm,
>                                          ARRAY_SIZE(fsl_spdif_ctrls_rcm));
>
> +       spdif_private->snd_card = dai->component->card->snd_card;
> +       spdif_private->rxrate_kcontrol =
> snd_soc_card_get_kcontrol(dai->component->card,
> +
> RX_SAMPLE_RATE_KCONTROL);
> +       if (!spdif_private->rxrate_kcontrol)
> +               dev_err(&spdif_private->pdev->dev, "failed to get %s
> kcontrol\n",
> +                       RX_SAMPLE_RATE_KCONTROL);
> +
>         /*Clear the val bit for Tx*/
>         regmap_update_bits(spdif_private->regmap, REG_SPDIF_SCR,
>                            SCR_VAL_MASK, SCR_VAL_CLEAR);
> --
> 2.30.2
>
>

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

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

On Mon, 12 Sep 2022 12:54:07 +0200, Robert Rosengren wrote:
> 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.
> 
> 

Applied to

   broonie/sound.git for-next

Thanks!

[1/1] ASoC: fsl_spdif: add ALSA event on dpll locked
      commit: e31a4a9320f1ccf75a690fe7f759896f285bb62e

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

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

end of thread, other threads:[~2022-09-19 23:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-12 10:54 [PATCH v2] ASoC: fsl_spdif: add ALSA event on dpll locked Robert Rosengren
2022-09-16  7:34 ` Shengjiu Wang
2022-09-19 23:10 ` Mark Brown

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.