Skip to content

Commit

Permalink
adds LED OFF feature to HiFiBerry DAC+ADC PRO sound card
Browse files Browse the repository at this point in the history
This adds a DT overlay parameter 'leds_off' which allows
to switch off the onboard activity LEDs at all times
which has been requested by some users.

Signed-off-by: Joerg Schambacher <[email protected]>
  • Loading branch information
j-schambacher authored and pelwell committed Jan 27, 2020
1 parent 6e7d9fb commit a79f5f5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions arch/arm/boot/dts/overlays/README
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,8 @@ Params: 24db_digital_gain Allow gain to be applied via the PCM512x codec
that does not result in clipping/distortion!)
slave Force DAC+ADC Pro into slave mode, using Pi as
master for bit clock and frame clock.
leds_off If set to 'true' the onboard indicator LEDs
are switched off at all times.


Name: hifiberry-dacplusdsp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@
24db_digital_gain =
<&hifiberry_dacplusadcpro>,"hifiberry-dacplusadcpro,24db_digital_gain?";
slave = <&hifiberry_dacplusadcpro>,"hifiberry-dacplusadcpro,slave?";
leds_off = <&hifiberry_dacplusadcpro>,"hifiberry-dacplusadcpro,leds_off?";
};
};
15 changes: 13 additions & 2 deletions sound/soc/bcm/hifiberry_dacplusadcpro.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ struct pcm512x_priv {
static bool slave;
static bool snd_rpi_hifiberry_is_dacpro;
static bool digital_gain_0db_limit = true;
static bool leds_off;

static const unsigned int pcm186x_adc_input_channel_sel_value[] = {
0x00, 0x01, 0x02, 0x03, 0x10
Expand Down Expand Up @@ -321,7 +322,10 @@ static int snd_rpi_hifiberry_dacplusadcpro_init(struct snd_soc_pcm_runtime *rtd)

snd_soc_component_update_bits(dac, PCM512x_GPIO_EN, 0x08, 0x08);
snd_soc_component_update_bits(dac, PCM512x_GPIO_OUTPUT_4, 0x0f, 0x02);
snd_soc_component_update_bits(dac, PCM512x_GPIO_CONTROL_1, 0x08, 0x08);
if (leds_off)
snd_soc_component_update_bits(dac, PCM512x_GPIO_CONTROL_1, 0x08, 0x00);
else
snd_soc_component_update_bits(dac, PCM512x_GPIO_CONTROL_1, 0x08, 0x08);

ret = pcm1863_add_controls(adc);
if (ret < 0)
Expand All @@ -331,7 +335,10 @@ static int snd_rpi_hifiberry_dacplusadcpro_init(struct snd_soc_pcm_runtime *rtd)
/* set GPIO2 to output, GPIO3 input */
snd_soc_component_write(adc, PCM186X_GPIO3_2_CTRL, 0x00);
snd_soc_component_write(adc, PCM186X_GPIO3_2_DIR_CTRL, 0x04);
snd_soc_component_update_bits(adc, PCM186X_GPIO_IN_OUT, 0x40, 0x40);
if (leds_off)
snd_soc_component_update_bits(adc, PCM186X_GPIO_IN_OUT, 0x40, 0x00);
else
snd_soc_component_update_bits(adc, PCM186X_GPIO_IN_OUT, 0x40, 0x40);

if (digital_gain_0db_limit) {
int ret;
Expand Down Expand Up @@ -417,6 +424,8 @@ static int snd_rpi_hifiberry_dacplusadcpro_startup(
struct snd_soc_component *dac = rtd->codec_dais[0]->component;
struct snd_soc_component *adc = rtd->codec_dais[1]->component;

if (leds_off)
return 0;
/* switch on respective LED */
if (!substream->stream)
snd_soc_component_update_bits(dac, PCM512x_GPIO_CONTROL_1, 0x08, 0x08);
Expand Down Expand Up @@ -508,6 +517,8 @@ static int snd_rpi_hifiberry_dacplusadcpro_probe(struct platform_device *pdev)
pdev->dev.of_node, "hifiberry-dacplusadcpro,24db_digital_gain");
slave = of_property_read_bool(pdev->dev.of_node,
"hifiberry-dacplusadcpro,slave");
leds_off = of_property_read_bool(pdev->dev.of_node,
"hifiberry-dacplusadcpro,leds_off");
ret = snd_soc_register_card(&snd_rpi_hifiberry_dacplusadcpro);
if (ret && ret != -EPROBE_DEFER)
dev_err(&pdev->dev,
Expand Down

0 comments on commit a79f5f5

Please sign in to comment.