Skip to content

Commit 80bb36b

Browse files
HiassofTpopcornmix
authored andcommitted
drm/vc4: add iec958 controls to vc4_hdmi
Although vc4 get an IEC958 formatted stream passed in from userspace the driver needs the info from the channel status bits to properly set up the hardware, eg for HBR passthrough. Add iec958 controls so the channel status bits can be passed in from userspace. Signed-off-by: Matthias Reichl <hias@horus.com>
1 parent 0a38702 commit 80bb36b

2 files changed

Lines changed: 62 additions & 0 deletions

File tree

‎drivers/gpu/drm/vc4/vc4_hdmi.c‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include <linux/pm_runtime.h>
4444
#include <linux/rational.h>
4545
#include <linux/reset.h>
46+
#include <sound/asoundef.h>
4647
#include <sound/dmaengine_pcm.h>
4748
#include <sound/pcm_drm_eld.h>
4849
#include <sound/pcm_params.h>
@@ -1103,6 +1104,47 @@ static int vc4_hdmi_audio_eld_ctl_get(struct snd_kcontrol *kcontrol,
11031104
return 0;
11041105
}
11051106

1107+
static int vc4_spdif_info(struct snd_kcontrol *kcontrol,
1108+
struct snd_ctl_elem_info *uinfo)
1109+
{
1110+
uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
1111+
uinfo->count = 1;
1112+
return 0;
1113+
}
1114+
1115+
static int vc4_spdif_playback_get(struct snd_kcontrol *kcontrol,
1116+
struct snd_ctl_elem_value *ucontrol)
1117+
{
1118+
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
1119+
struct vc4_hdmi *vc4_hdmi = snd_component_to_hdmi(component);
1120+
1121+
memcpy(ucontrol->value.iec958.status, vc4_hdmi->audio.iec_status,
1122+
sizeof(vc4_hdmi->audio.iec_status));
1123+
1124+
return 0;
1125+
}
1126+
1127+
static int vc4_spdif_playback_put(struct snd_kcontrol *kcontrol,
1128+
struct snd_ctl_elem_value *ucontrol)
1129+
{
1130+
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
1131+
struct vc4_hdmi *vc4_hdmi = snd_component_to_hdmi(component);
1132+
1133+
memcpy(vc4_hdmi->audio.iec_status, ucontrol->value.iec958.status,
1134+
sizeof(vc4_hdmi->audio.iec_status));
1135+
1136+
return 0;
1137+
}
1138+
1139+
static int vc4_spdif_mask_get(struct snd_kcontrol *kcontrol,
1140+
struct snd_ctl_elem_value *ucontrol)
1141+
{
1142+
memset(ucontrol->value.iec958.status, 0xff,
1143+
sizeof_field(struct vc4_hdmi_audio, iec_status));
1144+
1145+
return 0;
1146+
}
1147+
11061148
static const struct snd_kcontrol_new vc4_hdmi_audio_controls[] = {
11071149
{
11081150
.access = SNDRV_CTL_ELEM_ACCESS_READ |
@@ -1112,6 +1154,19 @@ static const struct snd_kcontrol_new vc4_hdmi_audio_controls[] = {
11121154
.info = vc4_hdmi_audio_eld_ctl_info,
11131155
.get = vc4_hdmi_audio_eld_ctl_get,
11141156
},
1157+
{
1158+
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1159+
.name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, DEFAULT),
1160+
.info = vc4_spdif_info,
1161+
.get = vc4_spdif_playback_get,
1162+
.put = vc4_spdif_playback_put,
1163+
},
1164+
{
1165+
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1166+
.name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, MASK),
1167+
.info = vc4_spdif_info,
1168+
.get = vc4_spdif_mask_get,
1169+
},
11151170
};
11161171

11171172
static const struct snd_soc_dapm_widget vc4_hdmi_audio_widgets[] = {
@@ -1232,6 +1287,11 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi)
12321287
vc4_hdmi->audio.dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
12331288
vc4_hdmi->audio.dma_data.maxburst = 2;
12341289

1290+
vc4_hdmi->audio.iec_status[0] = IEC958_AES0_CON_NOT_COPYRIGHT;
1291+
vc4_hdmi->audio.iec_status[1] =
1292+
IEC958_AES1_CON_ORIGINAL | IEC958_AES1_CON_PCM_CODER;
1293+
vc4_hdmi->audio.iec_status[3] = IEC958_AES3_CON_FS_48000;
1294+
12351295
ret = devm_snd_dmaengine_pcm_register(dev, &pcm_conf, 0);
12361296
if (ret) {
12371297
dev_err(dev, "Could not register PCM component: %d\n", ret);

‎drivers/gpu/drm/vc4/vc4_hdmi.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ struct vc4_hdmi_audio {
115115
struct snd_pcm_substream *substream;
116116

117117
bool streaming;
118+
119+
unsigned char iec_status[4];
118120
};
119121

120122
/* General HDMI hardware state. */

0 commit comments

Comments
 (0)