[PATCH 1/6] ASoC: hdmi-codec: add PCM trigger operator

Allen-KH Cheng (程冠勳) Allen-KH.Cheng at mediatek.com
Thu Nov 24 06:52:33 CET 2022


Hi Tzung-Bi,

We would want to confirm with you as we work on the hdmi-codec for the
mt8186.

Do you have any plan to continue working on this series? We may take
over as well.

Thanks,
Allen

On Tue, 2019-10-22 at 19:45 +0800, Tzung-Bi Shih wrote:
> HDMI codec may be also interested in PCM triggers.  Add PCM trigger
> operator.
>
> Signed-off-by: Tzung-Bi Shih <tzungbi at google.com>
> ---
>  include/sound/hdmi-codec.h    | 13 +++++++++++++
>  sound/soc/codecs/hdmi-codec.c | 31 +++++++++++++++++++++++++++++++
>  2 files changed, 44 insertions(+)
>
> diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h
> index 83b17682e01c..9de462ef170d 100644
> --- a/include/sound/hdmi-codec.h
> +++ b/include/sound/hdmi-codec.h
> @@ -50,6 +50,13 @@ struct hdmi_codec_params {
>  typedef void (*hdmi_codec_plugged_cb)(struct device *dev,
>        bool plugged);
>
> +enum {
> +HDMI_CODEC_TRIGGER_EVENT_STOP,
> +HDMI_CODEC_TRIGGER_EVENT_START,
> +HDMI_CODEC_TRIGGER_EVENT_SUSPEND,
> +HDMI_CODEC_TRIGGER_EVENT_RESUME,
> +};
> +
>  struct hdmi_codec_pdata;
>  struct hdmi_codec_ops {
>  /*
> @@ -66,6 +73,12 @@ struct hdmi_codec_ops {
>   struct hdmi_codec_daifmt *fmt,
>   struct hdmi_codec_params *hparms);
>
> +/*
> + * PCM trigger callback.
> + * Optional
> + */
> +int (*trigger)(struct device *dev, int event);
> +
>  /*
>   * Shuts down the audio stream.
>   * Mandatory
> diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-
> codec.c
> index b5fd8f08726e..1ba2fa26ba03 100644
> --- a/sound/soc/codecs/hdmi-codec.c
> +++ b/sound/soc/codecs/hdmi-codec.c
> @@ -565,12 +565,42 @@ static int hdmi_codec_digital_mute(struct
> snd_soc_dai *dai, int mute)
>  return 0;
>  }
>
> +static int hdmi_codec_trigger(struct snd_pcm_substream *substream,
> int cmd,
> +      struct snd_soc_dai *dai)
> +{
> +struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai);
> +int event;
> +
> +if (!hcp->hcd.ops->trigger)
> +return 0;
> +
> +switch (cmd) {
> +case SNDRV_PCM_TRIGGER_STOP:
> +event = HDMI_CODEC_TRIGGER_EVENT_STOP;
> +break;
> +case SNDRV_PCM_TRIGGER_START:
> +event = HDMI_CODEC_TRIGGER_EVENT_START;
> +break;
> +case SNDRV_PCM_TRIGGER_SUSPEND:
> +event = HDMI_CODEC_TRIGGER_EVENT_SUSPEND;
> +break;
> +case SNDRV_PCM_TRIGGER_RESUME:
> +event = HDMI_CODEC_TRIGGER_EVENT_RESUME;
> +break;
> +default:
> +return -EINVAL;
> +}
> +
> +return hcp->hcd.ops->trigger(dai->dev->parent, event);
> +}
> +
>  static const struct snd_soc_dai_ops hdmi_codec_i2s_dai_ops = {
>  .startup= hdmi_codec_startup,
>  .shutdown= hdmi_codec_shutdown,
>  .hw_params= hdmi_codec_hw_params,
>  .set_fmt= hdmi_codec_i2s_set_fmt,
>  .digital_mute= hdmi_codec_digital_mute,
> +.trigger= hdmi_codec_trigger,
>  };
>
>  static const struct snd_soc_dai_ops hdmi_codec_spdif_dai_ops = {
> @@ -578,6 +608,7 @@ static const struct snd_soc_dai_ops
> hdmi_codec_spdif_dai_ops = {
>  .shutdown= hdmi_codec_shutdown,
>  .hw_params= hdmi_codec_hw_params,
>  .digital_mute= hdmi_codec_digital_mute,
> +.trigger= hdmi_codec_trigger,
>  };
>
>  #define HDMI_RATES(SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\


************* MEDIATEK Confidentiality Notice ********************
The information contained in this e-mail message (including any
attachments) may be confidential, proprietary, privileged, or otherwise
exempt from disclosure under applicable laws. It is intended to be
conveyed only to the designated recipient(s). Any use, dissemination,
distribution, printing, retaining or copying of this e-mail (including its
attachments) by unintended recipient(s) is strictly prohibited and may
be unlawful. If you are not an intended recipient of this e-mail, or believe
that you have received this e-mail in error, please notify the sender
immediately (by replying to this e-mail), delete any and all copies of
this e-mail (including any attachments) from your system, and do not
disclose the content of this e-mail to any other person. Thank you!


More information about the Alsa-devel mailing list