diff options
author | Viorel Suman <viorel.suman@nxp.com> | 2019-11-21 16:29:52 +0200 |
---|---|---|
committer | Viorel Suman <viorel.suman@nxp.com> | 2019-12-09 10:48:39 +0200 |
commit | 4f88881c9f6dd96dbd40522f281bf515eef5c5c7 (patch) | |
tree | 355a5ce9ce12351dcc96e6239efeae244c6792b4 /sound | |
parent | 98d54c55b422310330ab8339aac950ce828e331d (diff) |
MLK-22384-1: ASoC: fsl_sai: split playback and capture controls
The patch adds controls as function of streams supported.
Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
(cherry picked from commit aa16c95a044bc20d6af24a65ea8c22ad70303a85)
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/fsl/fsl_sai.c | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index 9c716090c33a..855adeb331f9 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -1038,30 +1038,41 @@ int fsl_sai_get_reg(struct snd_kcontrol *kcontrol, { .regbase = xreg, .regcount = 1, .nbits = 32, \ .invert = 0, .min = 0, .max = 0xffffffff, } } -static const struct snd_kcontrol_new fsl_sai_ctrls[] = { +static const struct snd_kcontrol_new fsl_sai_pb_ctrls[] = { SOC_ENUM("Playback Timestamp Control", tstmp_enum[0]), - SOC_ENUM("Capture Timestamp Control", tstmp_enum[1]), SOC_ENUM("Playback Timestamp Increment", tstmp_enum[2]), - SOC_ENUM("Capture Timestamp Increment", tstmp_enum[3]), SOC_SINGLE("Playback Timestamp Reset", FSL_SAI_TTCTL, 8, 1, 0), - SOC_SINGLE("Capture Timestamp Reset", FSL_SAI_RTCTL, 8, 1, 0), SOC_SINGLE("Playback Bit Counter Reset", FSL_SAI_TTCTL, 9, 1, 0), - SOC_SINGLE("Capture Bit Counter Reset", FSL_SAI_RTCTL, 9, 1, 0), SOC_SINGLE_REG_RO("Playback Timestamp Counter", FSL_SAI_TTCTN), - SOC_SINGLE_REG_RO("Capture Timestamp Counter", FSL_SAI_RTCTN), SOC_SINGLE_REG_RO("Playback Bit Counter", FSL_SAI_TBCTN), - SOC_SINGLE_REG_RO("Capture Bit Counter", FSL_SAI_RBCTN), SOC_SINGLE_REG_RO("Playback Latched Timestamp Counter", FSL_SAI_TTCAP), +}; + +static const struct snd_kcontrol_new fsl_sai_cp_ctrls[] = { + SOC_ENUM("Capture Timestamp Control", tstmp_enum[1]), + SOC_ENUM("Capture Timestamp Increment", tstmp_enum[3]), + SOC_SINGLE("Capture Timestamp Reset", FSL_SAI_RTCTL, 8, 1, 0), + SOC_SINGLE("Capture Bit Counter Reset", FSL_SAI_RTCTL, 9, 1, 0), + SOC_SINGLE_REG_RO("Capture Timestamp Counter", FSL_SAI_RTCTN), + SOC_SINGLE_REG_RO("Capture Bit Counter", FSL_SAI_RBCTN), SOC_SINGLE_REG_RO("Capture Latched Timestamp Counter", FSL_SAI_RTCAP), }; -static int fsl_sai_component_probe(struct snd_soc_component *comp) +static int fsl_sai_pcm_new(struct snd_soc_pcm_runtime *rtd, + struct snd_soc_dai *dai) { - struct fsl_sai *sai = dev_get_drvdata(comp->dev); - - if (sai->verid.timestamp_en) - snd_soc_add_component_controls(comp, fsl_sai_ctrls, - ARRAY_SIZE(fsl_sai_ctrls)); + struct fsl_sai *sai = dev_get_drvdata(dai->dev); + struct snd_pcm *pcm = rtd->pcm; + bool ts_enabled = sai->verid.timestamp_en; + struct snd_soc_component *comp = dai->component; + + if (ts_enabled && pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) + snd_soc_add_component_controls(comp, fsl_sai_pb_ctrls, + ARRAY_SIZE(fsl_sai_pb_ctrls)); + + if (ts_enabled && pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) + snd_soc_add_component_controls(comp, fsl_sai_cp_ctrls, + ARRAY_SIZE(fsl_sai_cp_ctrls)); return 0; } @@ -1103,6 +1114,7 @@ static int fsl_sai_dai_resume(struct snd_soc_dai *cpu_dai) } static struct snd_soc_dai_driver fsl_sai_dai = { + .pcm_new = fsl_sai_pcm_new, .probe = fsl_sai_dai_probe, .playback = { .stream_name = "CPU-Playback", @@ -1128,7 +1140,6 @@ static struct snd_soc_dai_driver fsl_sai_dai = { static const struct snd_soc_component_driver fsl_component = { .name = "fsl-sai", - .probe = fsl_sai_component_probe, }; static struct reg_default fsl_sai_v2_reg_defaults[] = { |