| From 6bfc653c77ad4548fa72421dd472ce6aedca9fa4 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 4fc733c8c570..e52a00ed3156 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 b61f980cabdc..b40e44dfb09c 100644 |
| --- a/sound/soc/codecs/hdmi-codec.c |
| +++ b/sound/soc/codecs/hdmi-codec.c |
| @@ -685,6 +685,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. |
| @@ -711,6 +740,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, |
| .auto_selectable_formats = &hdmi_codec_formats, |
| .num_auto_selectable_formats = 1, |
| }; |
| @@ -720,6 +750,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, |
| }; |
| |
| #define HDMI_RATES (SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\ |
| -- |
| 2.17.1 |
| |