From d4acd8b7ea890c01453cdcf9b04a999ca04dfd2a Mon Sep 17 00:00:00 2001 From: j-schambacher Date: Wed, 28 Feb 2024 11:25:14 +0100 Subject: [PATCH 1282/1295] ASOc: Add HiFiBerry DAC8X to the simple card driver Defines the settings for the 8 channel version of the standard DAC by overwriting the number of channels in the DAI defs. It can run in 8ch mode only on PI5 using the 4 lane data output of the designware I2S0 module. Signed-off-by: j-schambacher --- sound/soc/bcm/Kconfig | 5 +++-- sound/soc/bcm/rpi-simple-soundcard.c | 33 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) --- a/sound/soc/bcm/Kconfig +++ b/sound/soc/bcm/Kconfig @@ -40,11 +40,12 @@ config SND_BCM2708_SOC_GOOGLEVOICEHAT_SO Say Y or M if you want to add support for voiceHAT soundcard. config SND_BCM2708_SOC_HIFIBERRY_DAC - tristate "Support for HifiBerry DAC" + tristate "Support for HifiBerry DAC and DAC8X" select SND_SOC_PCM5102A select SND_RPI_SIMPLE_SOUNDCARD help - Say Y or M if you want to add support for HifiBerry DAC. + Say Y or M if you want to add support for HifiBerry DAC and DAC8X. + Note: DAC8X only works on PI5 config SND_BCM2708_SOC_HIFIBERRY_DACPLUS tristate "Support for HifiBerry DAC+" --- a/sound/soc/bcm/rpi-simple-soundcard.c +++ b/sound/soc/bcm/rpi-simple-soundcard.c @@ -316,6 +316,37 @@ static struct snd_rpi_simple_drvdata drv .dai = snd_hifiberry_dac_dai, }; +static int hifiberry_dac8x_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); + + /* override the defaults to reflect 4 x PCM5102A on the card + * and limit the sample rate to 192ksps + */ + codec_dai->driver->playback.channels_max = 8; + codec_dai->driver->playback.rates = SNDRV_PCM_RATE_8000_192000; + + return 0; +} + +static struct snd_soc_dai_link snd_hifiberry_dac8x_dai[] = { + { + .name = "HifiBerry DAC8x", + .stream_name = "HifiBerry DAC8x HiFi", + .dai_fmt = SND_SOC_DAIFMT_I2S | + SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, + .init = hifiberry_dac8x_init, + SND_SOC_DAILINK_REG(hifiberry_dac), + }, +}; + +static struct snd_rpi_simple_drvdata drvdata_hifiberry_dac8x = { + .card_name = "snd_rpi_hifiberry_dac8x", + .dai = snd_hifiberry_dac8x_dai, + .fixed_bclk_ratio = 64, +}; + SND_SOC_DAILINK_DEFS(dionaudio_kiwi, DAILINK_COMP_ARRAY(COMP_EMPTY()), DAILINK_COMP_ARRAY(COMP_CODEC("pcm1794a-codec", "pcm1794a-hifi")), @@ -417,6 +448,8 @@ static const struct of_device_id snd_rpi .data = (void *) &drvdata_hifiberry_amp3 }, { .compatible = "hifiberry,hifiberry-dac", .data = (void *) &drvdata_hifiberry_dac }, + { .compatible = "hifiberry,hifiberry-dac8x", + .data = (void *) &drvdata_hifiberry_dac8x }, { .compatible = "dionaudio,dionaudio-kiwi", .data = (void *) &drvdata_dionaudio_kiwi }, { .compatible = "rpi,rpi-dac", &drvdata_rpi_dac},