Skip to content

Commit f77a066

Browse files
committed
ASoC: hdmi-codec: Allow playback and capture to be disabled
Currently the hdmi-codec driver always registers both playback and capture capabilities but for most systems there's no actual capture capability, usually HDMI is transmit only. Provide platform data which allows the users to indicate what is supported so that we don't end up advertising things to userspace that we can't actually support. In order to avoid breaking existing users the flags in platform data are a bit awkward and specify what should be disabled rather than doing the perhaps more expected thing and defaulting to not supporting capture. Reviewed-by: Russell King (Oracle) <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent eb70814 commit f77a066

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

include/sound/hdmi-codec.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,11 @@ struct hdmi_codec_ops {
124124
struct hdmi_codec_pdata {
125125
const struct hdmi_codec_ops *ops;
126126
uint i2s:1;
127+
uint no_i2s_playback:1;
128+
uint no_i2s_capture:1;
127129
uint spdif:1;
130+
uint no_spdif_playback:1;
131+
uint no_spdif_capture:1;
128132
int max_i2s_channels;
129133
void *data;
130134
};

sound/soc/codecs/hdmi-codec.c

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -816,12 +816,19 @@ static int hdmi_dai_probe(struct snd_soc_dai *dai)
816816
.source = "RX",
817817
},
818818
};
819-
int ret;
819+
int ret, i;
820820

821821
dapm = snd_soc_component_get_dapm(dai->component);
822-
ret = snd_soc_dapm_add_routes(dapm, route, 2);
823-
if (ret)
824-
return ret;
822+
823+
/* One of the directions might be omitted for unidirectional DAIs */
824+
for (i = 0; i < ARRAY_SIZE(route); i++) {
825+
if (!route[i].source || !route[i].sink)
826+
continue;
827+
828+
ret = snd_soc_dapm_add_routes(dapm, &route[i], 1);
829+
if (ret)
830+
return ret;
831+
}
825832

826833
daifmt = devm_kzalloc(dai->dev, sizeof(*daifmt), GFP_KERNEL);
827834
if (!daifmt)
@@ -1009,11 +1016,24 @@ static int hdmi_codec_probe(struct platform_device *pdev)
10091016
if (hcd->i2s) {
10101017
daidrv[i] = hdmi_i2s_dai;
10111018
daidrv[i].playback.channels_max = hcd->max_i2s_channels;
1019+
if (hcd->no_i2s_playback)
1020+
memset(&daidrv[i].playback, 0,
1021+
sizeof(daidrv[i].playback));
1022+
if (hcd->no_i2s_capture)
1023+
memset(&daidrv[i].capture, 0,
1024+
sizeof(daidrv[i].capture));
10121025
i++;
10131026
}
10141027

1015-
if (hcd->spdif)
1028+
if (hcd->spdif) {
10161029
daidrv[i] = hdmi_spdif_dai;
1030+
if (hcd->no_spdif_playback)
1031+
memset(&daidrv[i].playback, 0,
1032+
sizeof(daidrv[i].playback));
1033+
if (hcd->no_spdif_capture)
1034+
memset(&daidrv[i].capture, 0,
1035+
sizeof(daidrv[i].capture));
1036+
}
10171037

10181038
dev_set_drvdata(dev, hcp);
10191039

0 commit comments

Comments
 (0)