| From 9826c7cbe0fd8c4a22af2e28071c0d4d7e10cca2 Mon Sep 17 00:00:00 2001 |
| From: Tzung-Bi Shih <tzungbi@google.com> |
| Date: Tue, 22 Oct 2019 19:45:00 +0800 |
| Subject: [PATCH] FROMLIST: ASoC: hdmi-codec: add PCM trigger operator |
| |
| HDMI codec may be also interested in PCM triggers. Add PCM trigger |
| operator. |
| |
| Signed-off-by: Tzung-Bi Shih <tzungbi@google.com> |
| (am from https://patchwork.kernel.org/patch/11204313/) |
| (also found at https://lkml.kernel.org/r/20191022193301.1.I3039014cf259de5e4d6315fc05dff111591a0901@changeid) |
| |
| BUG=b:140826029, b:122050085 |
| TEST=emerge-kukui chromeos-kernel-4_19 |
| |
| Change-Id: I3039014cf259de5e4d6315fc05dff111591a0901 |
| Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org> |
| Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/1742260 |
| Reviewed-by: Nicolas Boichat <drinkcat@chromium.org> |
| Reviewed-by: Sean Paul <seanpaul@chromium.org> |
| |
| Conflicts: |
| sound/soc/codecs/hdmi-codec.c |
| [rebase510(cujomalainey): Fixed contextual conflicts] |
| Signed-off-by: Curtis Malainey <cujomalainey@chromium.org> |
| Change-Id: I33a3d6e7f7c4874a9ef5d1d3d9d35de386e6f70b |
| --- |
| 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 9b162ac1e08e04ee37f49911ba72ef8c3e13fc0b..f61055dc4860bc344819f1a3bd502f1abd14ec82 100644 |
| --- a/include/sound/hdmi-codec.h |
| +++ b/include/sound/hdmi-codec.h |
| @@ -55,6 +55,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 { |
| /* |
| @@ -81,6 +88,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 13689e718d36fee41152fe688ea043f7aa333a31..f710a70e3b57529330592e7882b7616fef959b8b 100644 |
| --- a/sound/soc/codecs/hdmi-codec.c |
| +++ b/sound/soc/codecs/hdmi-codec.c |
| @@ -704,6 +704,35 @@ static int hdmi_codec_mute(struct snd_soc_dai *dai, int mute, int direction) |
| return -ENOTSUPP; |
| } |
| |
| +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); |
| +} |
| + |
| /* |
| * This driver can select all SND_SOC_DAIFMT_CBx_CFx, |
| * but need to be selected from Sound Card, not be auto selected. |
| @@ -911,6 +940,7 @@ static const struct snd_soc_dai_ops hdmi_codec_i2s_dai_ops = { |
| .prepare = hdmi_codec_prepare, |
| .set_fmt = hdmi_codec_i2s_set_fmt, |
| .mute_stream = hdmi_codec_mute, |
| + .trigger = hdmi_codec_trigger, |
| .pcm_new = hdmi_codec_pcm_new, |
| .auto_selectable_formats = &hdmi_codec_formats, |
| .num_auto_selectable_formats = 1, |
| @@ -922,6 +952,7 @@ static const struct snd_soc_dai_ops hdmi_codec_spdif_dai_ops = { |
| .shutdown = hdmi_codec_shutdown, |
| .hw_params = hdmi_codec_hw_params, |
| .mute_stream = hdmi_codec_mute, |
| + .trigger = hdmi_codec_trigger, |
| .pcm_new = hdmi_codec_pcm_new, |
| }; |
| |
| -- |
| 2.34.1 |
| |