Skip to content

Commit d58c054

Browse files
j-schambacherpelwell
authored andcommitted
ASoC: adds support for AMP4 Pro to the DAC Plus driver
The AMP4 Pro is a I2S master mode capable amplifier with clean onboard clock generators. We can share the card driver between TAS575x amplifiers and the PCM512x DACs as they are SW compatible. From a HW perspective though we need to limit the sample rates to the standard audio rates to avoid running the onboard clocks through the PLL. Using the PLL would require even a different HW. DAI/stream name are also set accordingly to allow the user a convenient identification of the soundcard Needs the pcm512x driver with TAS575x support (already in upstream kernel). Signed-off-by: Joerg Schambacher <[email protected]>
1 parent 89bd4e6 commit d58c054

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

sound/soc/bcm/hifiberry_dacplus.c

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,21 @@ static bool leds_off;
5858
static bool auto_mute;
5959
static int mute_ext_ctl;
6060
static int mute_ext;
61+
static bool tas_device;
6162
static struct gpio_desc *snd_mute_gpio;
6263
static struct gpio_desc *snd_reset_gpio;
6364
static struct snd_soc_card snd_rpi_hifiberry_dacplus;
6465

66+
static const u32 master_dai_rates[] = {
67+
44100, 48000, 88200, 96000,
68+
176400, 192000, 352800, 384000,
69+
};
70+
71+
static const struct snd_pcm_hw_constraint_list constraints_master = {
72+
.count = ARRAY_SIZE(master_dai_rates),
73+
.list = master_dai_rates,
74+
};
75+
6576
static int snd_rpi_hifiberry_dacplus_mute_set(int mute)
6677
{
6778
gpiod_set_value_cansleep(snd_mute_gpio, mute);
@@ -197,8 +208,13 @@ static int snd_rpi_hifiberry_dacplus_init(struct snd_soc_pcm_runtime *rtd)
197208
if (snd_rpi_hifiberry_is_dacpro) {
198209
struct snd_soc_dai_link *dai = rtd->dai_link;
199210

200-
dai->name = "HiFiBerry DAC+ Pro";
201-
dai->stream_name = "HiFiBerry DAC+ Pro HiFi";
211+
if (tas_device) {
212+
dai->name = "HiFiBerry AMP4 Pro";
213+
dai->stream_name = "HiFiBerry AMP4 Pro HiFi";
214+
} else {
215+
dai->name = "HiFiBerry DAC+ Pro";
216+
dai->stream_name = "HiFiBerry DAC+ Pro HiFi";
217+
}
202218
dai->dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
203219
| SND_SOC_DAIFMT_CBM_CFM;
204220

@@ -303,6 +319,18 @@ static int snd_rpi_hifiberry_dacplus_startup(
303319
{
304320
struct snd_soc_pcm_runtime *rtd = substream->private_data;
305321
struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
322+
int ret;
323+
324+
if (tas_device && !slave) {
325+
ret = snd_pcm_hw_constraint_list(substream->runtime, 0,
326+
SNDRV_PCM_HW_PARAM_RATE,
327+
&constraints_master);
328+
if (ret < 0) {
329+
dev_err(rtd->card->dev,
330+
"Cannot apply constraints for sample rates\n");
331+
return ret;
332+
}
333+
}
306334

307335
if (auto_mute)
308336
gpiod_set_value_cansleep(snd_mute_gpio, 0);
@@ -324,7 +352,7 @@ static void snd_rpi_hifiberry_dacplus_shutdown(
324352
}
325353

326354
/* machine stream operations */
327-
static struct snd_soc_ops snd_rpi_hifiberry_dacplus_ops = {
355+
static const struct snd_soc_ops snd_rpi_hifiberry_dacplus_ops = {
328356
.hw_params = snd_rpi_hifiberry_dacplus_hw_params,
329357
.startup = snd_rpi_hifiberry_dacplus_startup,
330358
.shutdown = snd_rpi_hifiberry_dacplus_shutdown,
@@ -394,6 +422,7 @@ static int snd_rpi_hifiberry_dacplus_probe(struct platform_device *pdev)
394422
struct snd_soc_card *card = &snd_rpi_hifiberry_dacplus;
395423
int len;
396424
struct device_node *tpa_node;
425+
struct device_node *tas_node;
397426
struct property *tpa_prop;
398427
struct of_changeset ocs;
399428
struct property *pp;
@@ -430,6 +459,12 @@ static int snd_rpi_hifiberry_dacplus_probe(struct platform_device *pdev)
430459
}
431460
}
432461

462+
tas_node = of_find_compatible_node(NULL, NULL, "ti,tas5756");
463+
if (tas_node) {
464+
tas_device = true;
465+
dev_info(&pdev->dev, "TAS5756 device found!\n");
466+
};
467+
433468
snd_rpi_hifiberry_dacplus.dev = &pdev->dev;
434469
if (pdev->dev.of_node) {
435470
struct device_node *i2s_node;

0 commit comments

Comments
 (0)