提交 fcd64917 编写于 作者: F Florian Meier 提交者: Zheng Zengkai

Add support for all the downstream rpi sound card drivers

raspberrypi inclusion
category: feature
bugzilla: 50432

--------------------------------

ASoC: Add support for Rpi-DAC

ASoC: Add prompt for ICS43432 codec

Without a prompt string, a config setting can't be included in a
defconfig. Give CONFIG_SND_SOC_ICS43432 a prompt so that Pi soundcards
can use the driver.
Signed-off-by: NPhil Elwell <phil@raspberrypi.org>

Add IQaudIO Sound Card support for Raspberry Pi

Set a limit of 0dB on Digital Volume Control

The main volume control in the PCM512x DAC has a range up to
+24dB. This is dangerously loud and can potentially cause massive
clipping in the output stages. Therefore this sets a sensible
limit of 0dB for this control.

Allow up to 24dB digital gain to be applied when using IQAudIO DAC+

24db_digital_gain DT param can be used to specify that PCM512x
codec "Digital" volume control should not be limited to 0dB gain,
and if specified will allow the full 24dB gain.

Modify IQAudIO DAC+ ASoC driver to set card/dai config from dt

Add the ability to set the card name, dai name and dai stream name, from
dt config.
Signed-off-by: NDigitalDreamtime <clive.messer@digitaldreamtime.co.uk>

IQaudIO: auto-mute for AMP+ and DigiAMP+

IQAudIO amplifier mute via GPIO22. Add dt params for "one-shot" unmute
and auto mute.

Revision 2, auto mute implementing HiassofT suggestion to mute/unmute
using set_bias_level, rather than startup/shutdown....
"By default DAPM waits 5 seconds (pmdown_time) before shutting down
playback streams so a close/stop immediately followed by open/start
doesn't trigger an amp mute+unmute."

Tested on both AMP+ (via DAC+) and DigiAMP+, with both options...

dtoverlay=iqaudio-dacplus,unmute_amp
 "one-shot" unmute when kernel module loads.

dtoverlay=iqaudio-dacplus,auto_mute_amp
 Unmute amp when ALSA device opened by a client. Mute, with 5 second delay
 when ALSA device closed. (Re-opening the device within the 5 second close
 window, will cancel mute.)

Revision 4, using gpiod.

Revision 5, clean-up formatting before adding mute code.
 - Convert tab plus 4 space formatting to 2x tab
 - Remove '// NOT USED' commented code

Revision 6, don't attempt to "one-shot" unmute amp, unless card is
successfully registered.
Signed-off-by: NDigitalDreamtime <clive.messer@digitaldreamtime.co.uk>

ASoC: iqaudio-dac: fix S24_LE format

Remove set_bclk_ratio call so 24-bit data is transmitted in
24 bclk cycles.
Signed-off-by: NMatthias Reichl <hias@horus.com>

ASoC: iqaudio-dac: use modern dai_link style
Signed-off-by: NMatthias Reichl <hias@horus.com>

Added support for HiFiBerry DAC+

The driver is based on the HiFiBerry DAC driver. However HiFiBerry DAC+ uses
a different codec chip (PCM5122), therefore a new driver is necessary.

Add support for the HiFiBerry DAC+ Pro.

The HiFiBerry DAC+ and DAC+ Pro products both use the existing bcm sound driver with the DAC+ Pro having a special clock device driver representing the two high precision oscillators.

An addition bug fix is included for the PCM512x codec where by the physical size of the sample frame is used in the calculation of the LRCK divisor as it was found to be wrong when using 24-bit depth sample contained in a little endian 4-byte sample frame.

Limit PCM512x "Digital" gain to 0dB by default with HiFiBerry DAC+

24db_digital_gain DT param can be used to specify that PCM512x
codec "Digital" volume control should not be limited to 0dB gain,
and if specified will allow the full 24dB gain.

Add dt param to force HiFiBerry DAC+ Pro into slave mode

"dtoverlay=hifiberry-dacplus,slave"

Add 'slave' param to use HiFiBerry DAC+ Pro in slave mode,
with Pi as master for bit and frame clock.
Signed-off-by: NDigitalDreamtime <clive.messer@digitaldreamtime.co.uk>

Fixed a bug when using 352.8kHz sample rate
Signed-off-by: NDaniel Matuschek <daniel@hifiberry.com>

ASoC: pcm512x: revert downstream changes

This partially reverts commit 185ea05465aac8bf02a0d2b2f4289d42c72870b7
which was added by https://github.com/raspberrypi/linux/pull/1152

The downstream pcm512x changes caused a regression, it broke normal
use of the 24bit format with the codec, eg when using simple-audio-card.

The actual bug with 24bit playback is the incorrect usage
of physical_width in various drivers in the downstream tree
which causes 24bit data to be transmitted with 32 clock
cycles. So it's not the pcm512x that needs fixing, it's the
soundcard drivers.
Signed-off-by: NMatthias Reichl <hias@horus.com>

ASoC: hifiberry_dacplus: fix S24_LE format

Remove set_bclk_ratio call so 24-bit data is transmitted in
24 bclk cycles.
Signed-off-by: NMatthias Reichl <hias@horus.com>

ASoC: hifiberry_dacplus: transmit S24_LE with 64 BCLK cycles
Signed-off-by: NMatthias Reichl <hias@horus.com>

hifiberry_dacplus: switch to snd_soc_dai_set_bclk_ratio
Signed-off-by: NMatthias Reichl <hias@horus.com>

ASoC: hifiberry_dacplus: use modern dai_link style
Signed-off-by: NHui Wang <hui.wang@canonical.com>

Add driver for rpi-proto

Forward port of 3.10.x driver from https://github.com/koalo
We are using a custom board and would like to use rpi 3.18.x
kernel. Patch works fine for our embedded system.

URL to the audio chip:
http://www.mikroe.com/add-on-boards/audio-voice/audio-codec-proto/

Playback tested with devicetree enabled.
Signed-off-by: NWaldemar Brodkorb <wbrodkorb@conet.de>

ASoC: rpi-proto: use modern dai_link style
Signed-off-by: NHui Wang <hui.wang@canonical.com>

Add Support for JustBoom Audio boards

justboom-dac: Adjust for ALSA API change

As of 4.4, snd_soc_limit_volume now takes a struct snd_soc_card *
rather than a struct snd_soc_codec *.
Signed-off-by: NPhil Elwell <phil@raspberrypi.org>

ASoC: justboom-dac: fix S24_LE format

Remove set_bclk_ratio call so 24-bit data is transmitted in
24 bclk cycles.

Also remove hw_params as it's no longer needed.
Signed-off-by: NMatthias Reichl <hias@horus.com>

ASoC: justboom-dac: use modern dai_link style
Signed-off-by: NMatthias Reichl <hias@horus.com>

New AudioInjector.net Pi soundcard with low jitter audio in and out.

Contains the sound/soc/bcm ALSA machine driver and necessary alterations to the Kconfig and Makefile.
Adds the dts overlay and updates the Makefile and README.
Updates the relevant defconfig files to enable building for the Raspberry Pi.
Thanks to Phil Elwell (pelwell) for the review, simple-card concepts and discussion. Thanks to Clive Messer for overlay naming suggestions.

Added support for headphones, microphone and bclk_ratio settings.

This patch adds headphone and microphone capability to the Audio Injector sound card. The patch also sets the bit clock ratio for use in the bcm2835-i2s driver. The bcm2835-i2s can't handle an 8 kHz sample rate when the bit clock is at 12 MHz because its register is only 10 bits wide which can't represent the ch2 offset of 1508. For that reason, the rate constraint is added.

ASoC: audioinjector-pi-soundcard: use modern dai_link style
Signed-off-by: NHui Wang <hui.wang@canonical.com>

New driver for RRA DigiDAC1 soundcard using WM8741 + WM8804

ASoC: digidac1-soundcard: use modern dai_link style
Signed-off-by: NHui Wang <hui.wang@canonical.com>

Add support for Dion Audio LOCO DAC-AMP HAT

Using dedicated machine driver and pcm5102a codec driver.
Signed-off-by: NDigitalDreamtime <clive.messer@digitaldreamtime.co.uk>

ASoC: dionaudio_loco: use modern dai_link style
Signed-off-by: NHui Wang <hui.wang@canonical.com>

Allo Piano DAC boards: Initial 2 channel (stereo) support (#1645)

Add initial 2 channel (stereo) support for Allo Piano DAC (2.0/2.1) boards,
using allo-piano-dac-pcm512x-audio overlay and allo-piano-dac ALSA ASoC
machine driver.

NB. The initial support is 2 channel (stereo) ONLY!
(The Piano DAC 2.1 will only support 2 channel (stereo) left/right output,
 pending an update to the upstream pcm512x codec driver, which will have
 to be submitted via upstream. With the initial downstream support,
 provided by this patch, the Piano DAC 2.1 subwoofer outputs will
 not function.)
Signed-off-by: NBaswaraj K <jaikumar@cem-solutions.net>
Signed-off-by: NClive Messer <clive.messer@digitaldreamtime.co.uk>
Tested-by: NClive Messer <clive.messer@digitaldreamtime.co.uk>

ASoC: allo-piano-dac: fix S24_LE format

Remove set_bclk_ratio call so 24-bit data is transmitted in
24 bclk cycles.

Also remove hw_params and ops as they are no longer needed.
Signed-off-by: NMatthias Reichl <hias@horus.com>

ASoC: allo-piano-dac: use modern dai_link style
Signed-off-by: NHui Wang <hui.wang@canonical.com>

Add support for Allo Piano DAC 2.1 plus add-on board for Raspberry Pi.

The Piano DAC 2.1 has support for 4 channels with subwoofer.
Signed-off-by: NBaswaraj K <jaikumar@cem-solutions.net>
Reviewed-by: NVijay Kumar B. <vijaykumar@zilogic.com>
Reviewed-by: NRaashid Muhammed <raashidmuhammed@zilogic.com>

Add clock changes and mute gpios (#1938)

Also improve code style and adhere to ALSA coding conventions.
Signed-off-by: NBaswaraj K <jaikumar@cem-solutions.net>
Reviewed-by: NVijay Kumar B. <vijaykumar@zilogic.com>
Reviewed-by: NRaashid Muhammed <raashidmuhammed@zilogic.com>

PianoPlus: Dual Mono & Dual Stereo features added (#2069)

allo-piano-dac-plus: Master volume added + fixes

Master volume added, which controls both DACs volumes.

See: https://github.com/raspberrypi/linux/pull/2149

Also fix initial max volume, default mode value, and unmute.
Signed-off-by: Nallocom <sparky-dev@allo.com>

ASoC: allo-piano-dac-plus: fix S24_LE format

Remove set_bclk_ratio call so 24-bit data is transmitted in
24 bclk cycles.
Signed-off-by: NMatthias Reichl <hias@horus.com>

sound: bcm: Fix memset dereference warning

This warning appears with GCC 6.4.0 from toolchains.bootlin.com:

../sound/soc/bcm/allo-piano-dac-plus.c: In function ‘snd_allo_piano_dac_init’:
../sound/soc/bcm/allo-piano-dac-plus.c:711:30: warning: argument to ‘sizeof’ in ‘memset’ call is the same expression as the destination; did you mean to dereference it? [-Wsizeof-pointer-memaccess]
  memset(glb_ptr, 0x00, sizeof(glb_ptr));
                              ^
Suggested-by: NPhil Elwell <phil@raspberrypi.org>
Signed-off-by: NNathan Chancellor <natechancellor@gmail.com>

ASoC: allo-piano-dac-plus: use modern dai_link style
Signed-off-by: NHui Wang <hui.wang@canonical.com>

Add support for Allo Boss DAC add-on board for Raspberry Pi. (#1924)
Signed-off-by: NBaswaraj K <jaikumar@cem-solutions.net>
Reviewed-by: NDeepak <deepak@zilogic.com>
Reviewed-by: NBabuSubashChandar <babusubashchandar@zilogic.com>

Add support for new clock rate and mute gpios.
Signed-off-by: NBaswaraj K <jaikumar@cem-solutions.net>
Reviewed-by: NDeepak <deepak@zilogic.com>
Reviewed-by: NBabuSubashChandar <babusubashchandar@zilogic.com>

ASoC: allo-boss-dac: fix S24_LE format

Remove set_bclk_ratio call so 24-bit data is transmitted in
24 bclk cycles.
Signed-off-by: NMatthias Reichl <hias@horus.com>

ASoC: allo-boss-dac: transmit S24_LE with 64 BCLK cycles
Signed-off-by: NMatthias Reichl <hias@horus.com>

allo-boss-dac: switch to snd_soc_dai_set_bclk_ratio
Signed-off-by: NMatthias Reichl <hias@horus.com>

ASoC: allo-boss-dac: use modern dai_link style
Signed-off-by: NHui Wang <hui.wang@canonical.com>

Support for Blokas Labs pisound board

Pisound dynamic overlay (#1760)

Restructuring pisound-overlay.dts, so it can be loaded and unloaded dynamically using dtoverlay.

Print a logline when the kernel module is removed.

pisound improvements:

* Added a writable sysfs object to enable scripts / user space software
to blink MIDI activity LEDs for variable duration.
* Improved hw_param constraints setting.
* Added compatibility with S16_LE sample format.
* Exposed some simple placeholder volume controls, so the card appears
in volumealsa widget.

Add missing SND_PISOUND selects dependency to SND_RAWMIDI

Without it the Pisound module fails to compile.
See https://github.com/raspberrypi/linux/issues/2366

Updates for Pisound module code:

	* Merged 'Fix a warning in DEBUG builds' (1c8b82b).
	* Updating some strings and copyright information.
	* Fix for handling high load of MIDI input and output.
	* Use dual rate oversampling ratio for 96kHz instead of single
	  rate one.
Signed-off-by: NGiedrius Trainavicius <giedrius@blokas.io>

Fixing memset call in pisound.c
Signed-off-by: NGiedrius Trainavicius <giedrius@blokas.io>

Fix for Pisound's MIDI Input getting blocked for a while in rare cases.

There was a possible race condition which could lead to Input's FIFO queue
to be underflown, causing high amount of processing in the worker thread for
some period of time.
Signed-off-by: NGiedrius Trainavicius <giedrius@blokas.io>

Fix for Pisound kernel module in Real Time kernel configuration.

When handler of data_available interrupt is fired, queue_work ends up
getting called and it can block on a spin lock which is not allowed in
interrupt context. The fix was to run the handler from a thread context
instead.

Pisound: Remove spinlock usage around spi_sync

ASoC: pisound: use modern dai_link style
Signed-off-by: NHui Wang <hui.wang@canonical.com>

ASoC: pisound: fix the parameter for spi_device_match
Signed-off-by: NHui Wang <hui.wang@canonical.com>

ASoC: Add driver for Cirrus Logic Audio Card

Note: due to problems with deferred probing of regulators
the following softdep should be added to a modprobe.d file

softdep arizona-spi pre: arizona-ldo1
Signed-off-by: NMatthias Reichl <hias@horus.com>

ASoC: rpi-cirrus: use modern dai_link style
Signed-off-by: NMatthias Reichl <hias@horus.com>

sound: Support for Dion Audio LOCO-V2 DAC-AMP HAT
Signed-off-by: NMiquel Blauw <info@dionaudio.nl>

ASoC: dionaudio_loco-v2: fix S24_LE format

Remove set_bclk_ratio call so 24-bit data is transmitted in
24 bclk cycles.

Also remove hw_params and ops as they are no longer needed.
Signed-off-by: NMatthias Reichl <hias@horus.com>

ASoC: dionaudio_loco-v2: use modern dai_link style
Signed-off-by: NHui Wang <hui.wang@canonical.com>

Add support for Fe-Pi audio sound card. (#1867)

Fe-Pi Audio Sound Card is based on NXP SGTL5000 codec.
Mechanical specification of the board is the same the Raspberry Pi Zero.
3.5mm jacks for Headphone/Mic, Line In, and Line Out.
Signed-off-by: NHenry Kupis <fe-pi@cox.net>

ASoC: fe-pi-audio: use modern dai_link style
Signed-off-by: NHui Wang <hui.wang@canonical.com>

Add support for the AudioInjector.net Octo sound card

AudioInjector Octo: sample rates, regulators, reset

This patch adds new sample rates to the Audioinjector Octo sound card. The
new supported rates are (in kHz) :
96, 48, 32, 24, 16, 8, 88.2, 44.1, 29.4, 22.05, 14.7

Reference the bcm270x DT regulators in the overlay.

This patch adds a reset GPIO for the AudioInjector.net octo sound card.

Audioinjector octo : Make the playback and capture symmetric

This patch ensures that the sample rate and channel count of the audioinjector
octo sound card are symmetric.

audioinjector-octo: Add continuous clock feature

By user request, add a switch to prevent the clocks being stopped when
the stream is paused, stopped or shutdown. Provide access to the switch
by adding a 'non-stop-clocks' parameter to the audioinjector-addons
overlay.

See: https://github.com/raspberrypi/linux/issues/2409Signed-off-by: NPhil Elwell <phil@raspberrypi.org>

sound: Fixes for audioinjector-octo under 4.19

1. Move the DT alias declaration to the I2C shim in the cases
where the shim is enabled. This works around a problem caused by a
4.19 commit [1] that generates DT/OF uevents for I2C drivers.

2. Fix the diagnostics in an error path of the soundcard driver to
correctly identify the reason for the failure to load.

3. Move the declaration of the clock node in the overlay outside
the I2C node to avoid warnings.

4. Sort the overlay nodes so that dependencies are only to earlier
fragments, in an attempt to get runtime dtoverlay application to
work (it still doesn't...)

See: https://github.com/Audio-Injector/Octo/issues/14Signed-off-by: NPhil Elwell <phil@raspberrypi.org>

[1] af503716 ("i2c: core: report OF style module alias for devices registered via OF")

ASoC: audioinjector-octo-soundcard: use modern dai_link style
Signed-off-by: NHui Wang <hui.wang@canonical.com>

Driver support for Google voiceHAT soundcard.

ASoC: googlevoicehat-codec: Use correct device when grabbing GPIO

The fixup for the VoiceHAT in 4.18 incorrectly tried to find the
sdmode GPIO pin under the card device, not the codec device.
This failed, and therefore caused the device probe to fail.
Signed-off-by: NDave Stevenson <dave.stevenson@raspberrypi.org>

ASoC: googlevoicehat-codec: Reformat for kernel coding standards

Fix all whitespace, indentation, and bracing errors.
Signed-off-by: NDave Stevenson <dave.stevenson@raspberrypi.org>

ASoC: googlevoicehat-codec: Make driver function structure const

Make voicehat_component_driver a const structure.
Signed-off-by: NDave Stevenson <dave.stevenson@raspberrypi.org>

ASoC: googlevoicehat-codec: Only convert from ms to jiffies once

Minor optimisation and allows to become checkpatch clean.
A msec value is read out of DT or from a define, and convert once to
jiffies, rather than every time that it is used.
Signed-off-by: NDave Stevenson <dave.stevenson@raspberrypi.org>

Driver and overlay for Allo Katana DAC

Allo Katana DAC: Updated default values
Signed-off-by: NJaikumar <jaikumar@cem-solutions.com>

Added mute stream func
Signed-off-by: NJaikumar <jaikumar@cem-solutions.net>

codecs: Correct Katana minimum volume

Update Katana minimum volume to get the exact 0.5 dB value in each step.
Signed-off-by: NSudeep Kumar <sudeepkumar@cem-solutions.net>

ASoC: Add generic RPI driver for simple soundcards.

The RPI simple sound card driver provides a generic ALSA SOC card driver
supporting a variety of Pi HAT soundcards. The intention is to avoid
the duplication of code for cards that can't be fully supported by
the soc simple/graph cards but are otherwise almost identical.

This initial commit adds support for the ADAU1977 ADC, Google VoiceHat,
HifiBerry AMP, HifiBerry DAC and RPI DAC.
Signed-off-by: NTim Gover <tim.gover@raspberrypi.org>

ASoC: Use correct card name in rpi-simple driver

Use the specific card name from drvdata instead of the snd_rpi_simple

rpi-simple-soundcard: Use nicer driver name "RPi-simple"

Rename the driver from "RPI simple soundcard" to "RPi-simple" so that
the driver name won't be mangled allowing to be used unaltered as the
card conf filename.

ASoC: rpi-simple-soundcard: use modern dai_link style
Signed-off-by: NHui Wang <hui.wang@canonical.com>

ASoC: Add Kconfig and Makefile for sound/soc/bcm
Signed-off-by: Npopcornmix <popcornmix@gmail.com>

ASoC: Create a generic Pi Hat WM8804 driver

Reduce the amount of duplicated code by creating a generic driver for
Pi Hat digi cards using the WM8804 codec.

This replaces the
Allo DigiOne, Hifiberry Digi/Pro, JustBoom Digi and IQAudIO Digi
dedicate soundcard drivers with a generic driver.

There are no significant changes to the runtime behavior of the drivers
and end users should not have to change any configuration settings
after upgrading.

Minor changes
* Check the return value of snd_soc_component_update_bits
* Added some pr_debug tracing
* Various checkpatch tidyups
* Updated allodigi-one to use use 128FS at > 96 Khz. This appears to
  be an omission in the original driver code so followed the Hifiberry
  DAC driver approach.

ASoC: rpi-wm8804-soundcard: use modern dai_link style
Signed-off-by: NMatthias Reichl <hias@horus.com>

rpi-wm8804-soundcard: drop PWRDN register writes

Since kernel 4.0 the PWRDN register bits are under DAPM
control from the wm8804 driver.

Drop code that modifies that register to avoid interfering
with DAPM.
Signed-off-by: NMatthias Reichl <hias@horus.com>

rpi-wm8804-soundcard: configure wm8804 clocks only on rate change

This should avoid clicks when stopping and immediately afterwards
starting a stream with the same samplerate as before.
Signed-off-by: NMatthias Reichl <hias@horus.com>

rpi-wm8804-soundcard: Fixed MCLKDIV for Allo Digione

The Allo Digione board wants a fixed MCLKDIV of 256.

See: https://github.com/raspberrypi/linux/issues/3296Signed-off-by: NPhil Elwell <phil@raspberrypi.org>

ASoC: Add support for AudioSense-Pi add-on soundcard

AudioSense-Pi is a RPi HAT based on a TI's TLV320AIC32x4 stereo codec

This hardware provides multiple audio I/O capabilities to the RPi.
The codec connects to the RPi's SoC through the I2S Bus.

The following devices can be connected through a 3.5mm jack
	1. Line-In: Plain old audio in from mobile phones, PCs, etc.,
	2. Mic-In: Connect a microphone
	3. Line-Out: Connect the output to a speaker
	4. Headphones: Connect a Headphone w or w/o microphones

Multiple Inputs:
	It supports the following combinations
	1. Two stereo Line-Inputs and a microphone
	2. One stereo Line-Input and two microphones
	3. Two stereo Line-Inputs, a microphone and
		one mono line-input (with h/w hack)
	4. One stereo Line-Input, two microphones and
		one mono line-input (with h/w hack)

Multiple Outputs:
	Audio output can be routed to the headphones or
		speakers (with additional hardware)
Signed-off-by: Nb-ak <anur.bhargav@gmail.com>

ASoC: audiosense-pi: use modern dai_link style
Signed-off-by: NHui Wang <hui.wang@canonical.com>

Added driver for the HiFiBerry DAC+ ADC (#2694)
Signed-off-by: NDaniel Matuschek <daniel@hifiberry.com>

hifiberry_dacplusadc: switch to snd_soc_dai_set_bclk_ratio
Signed-off-by: NMatthias Reichl <hias@horus.com>

ASoC: hifiberry_dacplusadc: fix DAI link setup

The driver only defines a single DAI link and the code that tries
to setup the second (non-existent) DAI link looks wrong - using dmic
as a CPU/platform driver doesn't make any sense.

The DT overlay doesn't define a dmic property, so the code was never
executed (otherwise it would have resulted in a memory corruption).

So drop the offending code to prevent issues if a dmic property
should be added to the DT overlay.
Signed-off-by: NMatthias Reichl <hias@horus.com>

ASoC: hifiberry_dacplusadc: use modern dai_link style
Signed-off-by: NMatthias Reichl <hias@horus.com>

Audiophonics I-Sabre 9038Q2M DAC driver
Signed-off-by: NAudiophonics <contact@audiophonics.fr>

ASoC: i-sabre-q2m: use modern dai_link style
Signed-off-by: NHui Wang <hui.wang@canonical.com>

Added IQaudIO Pi-Codec board support (#2969)

Add support for the IQaudIO Pi-Codec board.
Signed-off-by: NGordon <gordon@iqaudio.com>

Fixed 48k timing issue

ASoC: iqaudio-codec: use modern dai_link style
Signed-off-by: NHui Wang <hui.wang@canonical.com>

adds the Hifiberry DAC+ADC PRO version

This adds the driver for the DAC+ADC PRO version of the Hifiberry soundcard with software controlled PCM1863 ADC
Signed-off-by: Joerg Schambacher joerg@i2audio.com

Add Hifiberry DAC+DSP soundcard driver (#3224)

Adds the driver for the Hifiberry DAC+DSP. It supports capture and
playback depending on the DSP firmware.
Signed-off-by: NJoerg Schambacher <joerg@i2audio.com>

Allow simultaneous use of JustBoom DAC and Digi
Signed-off-by: NJohannes Krude <johannes@krude.de>

Pisound: MIDI communication fixes for scaled down CPU.

* Increased maximum SPI communication speed to avoid running too slow
  when the CPU is scaled down and losing MIDI data.

* Keep track of buffer usage in millibytes for higher precision.
Signed-off-by: NGiedrius Trainavičius <giedrius@blokas.io>

sound: Add the HiFiBerry DAC+HD version

This adds the driver for the DAC+HD version supporting HiFiBerry's
PCM179x based DACs. It also adds PLL control for clock generation.
Signed-off-by: NJoerg Schambacher <joerg@i2audio.com>

Fix master mode settings of HiFiBerry DAC+ADC PRO card (#3424)

This patch fixes the board DAI setting when in master-mode.
Wrong setting could have caused random pop noise.
Signed-off-by: NJoerg Schambacher <joerg@i2audio.com>

adds LED OFF feature to HiFiBerry DAC+ADC PRO sound card

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: NJoerg Schambacher <joerg@i2audio.com>

adds LED OFF feature to HiFiBerry DAC+ADC sound card

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: NJoerg Schambacher <joerg@i2audio.com>

adds LED OFF feature to HiFiBerry DAC+/DAC+PRO sound cards

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: NJoerg Schambacher <joerg@i2audio.com>

pisound: Added reading Pisound board hardware revision and exposing it (#3425)

pisound: Added reading Pisound board hardware revision and exposing it in kernel log and sysfs file:

/sys/kernel/pisound/hw_version
Signed-off-by: NGiedrius <giedrius@blokas.io>

Added driver for HiFiBerry Amp amplifier add-on board

The driver contains a low-level hardware driver for the TAS5713 and the
drivers for the Raspberry Pi I2S subsystem.

TAS5713: return error if initialisation fails

Existing TAS5713 driver logs errors during initialisation, but does not return
an error code. Therefore even if initialisation fails, the driver will still be
loaded, but won't work. This patch fixes this. I2C communication error will now
reported correctly by a non-zero return code.

HiFiBerry Amp: fix device-tree problems

Some code to load the driver based on device-tree-overlays was missing. This is added by this patch.

According to 5713 pdf doc CLOCK_CTRL is a readonly status register, and it behaves so. Remove useless setting

sound: pcm512x-codec: Adding 352.8kHz samplerate support

sound/soc: only first codec is master in multicodec setup

When using multiple codecs, at most one codec should generate the master
clock. All codecs except the first are therefore configured for slave
mode.
Signed-off-by: NJohannes Krude <johannes@krude.de>

ASoC: Fix snd_soc_get_pcm_runtime usage

Commit [1] changed the snd_soc_get_pcm_runtime to take a dai_link
pointer instead of a string. Patch up the downstream drivers to use
the modified API.
Signed-off-by: NPhil Elwell <phil@raspberrypi.com>

[1] 4468189f ("ASoC: soc-core: find rtd via dai_link pointer at snd_soc_get_pcm_runtime()")

Add support for the AudioInjector.net Isolated sound card

This patch adds support for the Audio Injector Isolated sound card.
Signed-off-by: NMatt Flax <flatmax@flatmax.org>

Add support for merus-amp soundcard and ma120x0p codec

Add 96KHz rate support to MA120X0P codec and make enable and mute gpio
pins optional.
Signed-off-by: NAMuszkat <ariel.muszkat@gmail.com>

Fixes a problem with clock settings of HiFiBerry DAC+ADC PRO (#3545)

This patch fixes a problem of the re-calculation of
i2s-clock and -parameter settings when only the ADC is activated.
Signed-off-by: NJoerg Schambacher <joerg@i2audio.com>

configs: Enable the AD193x codecs

See: https://github.com/raspberrypi/linux/issues/2850Signed-off-by: NPhil Elwell <phil@raspberrypi.org>

Switch to snd_soc_dai_set_bclk_ratio
Replaces obsolete function snd_soc_dai_set_tdm_slot
Signed-off-by: NJoerg Schambacher <joerg@i2audio.com>

Enhances the DAC+ driver to control the optional headphone amplifier

Probes on the I2C bus for TPA6130A2, if successful, it sets DT-parameter
'status' from 'disabled' to 'okay' using change_sets to enable
the headphone control.

Signed-off-by: Joerg Schambacher joerg@i2audio.com
Signed-off-by: NFang Yafen <yafen@iscas.ac.cn>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 2ff68b57
Device tree binding vendor prefix registry. Keep list in alphabetical order.
This isn't an exhaustive list, but you should add new prefixes to it before
using them to avoid name-space collisions.
abilis Abilis Systems
abracon Abracon Corporation
actions Actions Semiconductor Co., Ltd.
active-semi Active-Semi International Inc
ad Avionic Design GmbH
adafruit Adafruit Industries, LLC
adapteva Adapteva, Inc.
adaptrum Adaptrum, Inc.
adh AD Holdings Plc.
adi Analog Devices, Inc.
advantech Advantech Corporation
aeroflexgaisler Aeroflex Gaisler AB
al Annapurna Labs
allo Allo.com
allwinner Allwinner Technology Co., Ltd.
alphascale AlphaScale Integrated Circuits Systems, Inc.
altr Altera Corp.
amarula Amarula Solutions
amazon Amazon.com, Inc.
amcc Applied Micro Circuits Corporation (APM, formally AMCC)
amd Advanced Micro Devices (AMD), Inc.
amediatech Shenzhen Amediatech Technology Co., Ltd
amlogic Amlogic, Inc.
ampire Ampire Co., Ltd.
ams AMS AG
amstaos AMS-Taos Inc.
analogix Analogix Semiconductor, Inc.
andestech Andes Technology Corporation
apm Applied Micro Circuits Corporation (APM)
aptina Aptina Imaging
arasan Arasan Chip Systems
archermind ArcherMind Technology (Nanjing) Co., Ltd.
arctic Arctic Sand
aries Aries Embedded GmbH
arm ARM Ltd.
armadeus ARMadeus Systems SARL
arrow Arrow Electronics
artesyn Artesyn Embedded Technologies Inc.
asahi-kasei Asahi Kasei Corp.
aspeed ASPEED Technology Inc.
asus AsusTek Computer Inc.
atlas Atlas Scientific LLC
atmel Atmel Corporation
auo AU Optronics Corporation
auvidea Auvidea GmbH
avago Avago Technologies
avia avia semiconductor
avic Shanghai AVIC Optoelectronics Co., Ltd.
avnet Avnet, Inc.
axentia Axentia Technologies AB
axis Axis Communications AB
bananapi BIPAI KEJI LIMITED
bhf Beckhoff Automation GmbH & Co. KG
bitmain Bitmain Technologies
blokaslabs Vilniaus Blokas UAB
boe BOE Technology Group Co., Ltd.
bosch Bosch Sensortec GmbH
boundary Boundary Devices Inc.
brcm Broadcom Corporation
buffalo Buffalo, Inc.
bticino Bticino International
calxeda Calxeda
capella Capella Microsystems, Inc
cascoda Cascoda, Ltd.
catalyst Catalyst Semiconductor, Inc.
cavium Cavium, Inc.
cdns Cadence Design Systems Inc.
cdtech CDTech(H.K.) Electronics Limited
ceva Ceva, Inc.
chipidea Chipidea, Inc
chipone ChipOne
chipspark ChipSPARK
chrp Common Hardware Reference Platform
chunghwa Chunghwa Picture Tubes Ltd.
ciaa Computadora Industrial Abierta Argentina
cirrus Cirrus Logic, Inc.
cloudengines Cloud Engines, Inc.
cnm Chips&Media, Inc.
cnxt Conexant Systems, Inc.
compulab CompuLab Ltd.
cortina Cortina Systems, Inc.
cosmic Cosmic Circuits
crane Crane Connectivity Solutions
creative Creative Technology Ltd
crystalfontz Crystalfontz America, Inc.
csky Hangzhou C-SKY Microsystems Co., Ltd
cubietech Cubietech, Ltd.
cypress Cypress Semiconductor Corporation
cznic CZ.NIC, z.s.p.o.
dallas Maxim Integrated Products (formerly Dallas Semiconductor)
dataimage DataImage, Inc.
davicom DAVICOM Semiconductor, Inc.
delta Delta Electronics, Inc.
denx Denx Software Engineering
devantech Devantech, Ltd.
dh DH electronics GmbH
digi Digi International Inc.
digilent Diglent, Inc.
dioo Dioo Microcircuit Co., Ltd
dlc DLC Display Co., Ltd.
dlg Dialog Semiconductor
dlink D-Link Corporation
dmo Data Modul AG
domintech Domintech Co., Ltd.
dongwoon Dongwoon Anatech
dptechnics DPTechnics
dragino Dragino Technology Co., Limited
ea Embedded Artists AB
ebs-systart EBS-SYSTART GmbH
ebv EBV Elektronik
eckelmann Eckelmann AG
edt Emerging Display Technologies
eeti eGalax_eMPIA Technology Inc
elan Elan Microelectronic Corp.
elgin Elgin S/A.
embest Shenzhen Embest Technology Co., Ltd.
emlid Emlid, Ltd.
emmicro EM Microelectronic
emtrion emtrion GmbH
endless Endless Mobile, Inc.
energymicro Silicon Laboratories (formerly Energy Micro AS)
engicam Engicam S.r.l.
epcos EPCOS AG
epfl Ecole Polytechnique Fédérale de Lausanne
epson Seiko Epson Corp.
est ESTeem Wireless Modems
ettus NI Ettus Research
eukrea Eukréa Electromatique
everest Everest Semiconductor Co. Ltd.
everspin Everspin Technologies, Inc.
exar Exar Corporation
excito Excito
ezchip EZchip Semiconductor
facebook Facebook
fairphone Fairphone B.V.
faraday Faraday Technology Corporation
fastrax Fastrax Oy
fcs Fairchild Semiconductor
feiyang Shenzhen Fly Young Technology Co.,LTD.
firefly Firefly
focaltech FocalTech Systems Co.,Ltd
friendlyarm Guangzhou FriendlyARM Computer Tech Co., Ltd
fsl Freescale Semiconductor
fujitsu Fujitsu Ltd.
gateworks Gateworks Corporation
gcw Game Consoles Worldwide
ge General Electric Company
geekbuying GeekBuying
gef GE Fanuc Intelligent Platforms Embedded Systems, Inc.
GEFanuc GE Fanuc Intelligent Platforms Embedded Systems, Inc.
geniatech Geniatech, Inc.
giantec Giantec Semiconductor, Inc.
giantplus Giantplus Technology Co., Ltd.
globalscale Globalscale Technologies, Inc.
globaltop GlobalTop Technology, Inc.
gmt Global Mixed-mode Technology, Inc.
goodix Shenzhen Huiding Technology Co., Ltd.
google Google, Inc.
grinn Grinn
grmn Garmin Limited
gumstix Gumstix, Inc.
gw Gateworks Corporation
hannstar HannStar Display Corporation
haoyu Haoyu Microelectronic Co. Ltd.
hardkernel Hardkernel Co., Ltd
hideep HiDeep Inc.
himax Himax Technologies, Inc.
hisilicon Hisilicon Limited.
hit Hitachi Ltd.
hitex Hitex Development Tools
holt Holt Integrated Circuits, Inc.
honeywell Honeywell
hp Hewlett Packard
holtek Holtek Semiconductor, Inc.
hwacom HwaCom Systems Inc.
i2se I2SE GmbH
ibm International Business Machines (IBM)
icplus IC Plus Corp.
idt Integrated Device Technologies, Inc.
ifi Ingenieurburo Fur Ic-Technologie (I/F/I)
ilitek ILI Technology Corporation (ILITEK)
img Imagination Technologies Ltd.
infineon Infineon Technologies
inforce Inforce Computing
ingenic Ingenic Semiconductor
innolux Innolux Corporation
inside-secure INSIDE Secure
intel Intel Corporation
intercontrol Inter Control Group
invensense InvenSense Inc.
inversepath Inverse Path
iom Iomega Corporation
isee ISEE 2007 S.L.
isil Intersil
issi Integrated Silicon Solutions Inc.
itead ITEAD Intelligent Systems Co.Ltd
iwave iWave Systems Technologies Pvt. Ltd.
jdi Japan Display Inc.
jedec JEDEC Solid State Technology Association
jianda Jiandangjing Technology Co., Ltd.
karo Ka-Ro electronics GmbH
keithkoep Keith & Koep GmbH
keymile Keymile GmbH
khadas Khadas
kiebackpeter Kieback & Peter GmbH
kinetic Kinetic Technologies
kingdisplay King & Display Technology Co., Ltd.
kingnovel Kingnovel Technology Co., Ltd.
koe Kaohsiung Opto-Electronics Inc.
kosagi Sutajio Ko-Usagi PTE Ltd.
kyo Kyocera Corporation
lacie LaCie
laird Laird PLC
lantiq Lantiq Semiconductor
lattice Lattice Semiconductor
lego LEGO Systems A/S
lemaker Shenzhen LeMaker Technology Co., Ltd.
lenovo Lenovo Group Ltd.
lg LG Corporation
libretech Shenzhen Libre Technology Co., Ltd
licheepi Lichee Pi
linaro Linaro Limited
linksys Belkin International, Inc. (Linksys)
linux Linux-specific binding
linx Linx Technologies
lltc Linear Technology Corporation
logicpd Logic PD, Inc.
lsi LSI Corp. (LSI Logic)
lwn Liebherr-Werk Nenzing GmbH
macnica Macnica Americas
marvell Marvell Technology Group Ltd.
maxim Maxim Integrated Products
mbvl Mobiveil Inc.
mcube mCube
meas Measurement Specialties
mediatek MediaTek Inc.
megachips MegaChips
mele Shenzhen MeLE Digital Technology Ltd.
melexis Melexis N.V.
melfas MELFAS Inc.
mellanox Mellanox Technologies
memsic MEMSIC Inc.
merrii Merrii Technology Co., Ltd.
micrel Micrel Inc.
microchip Microchip Technology Inc.
microcrystal Micro Crystal AG
micron Micron Technology Inc.
mikroe MikroElektronika d.o.o.
minix MINIX Technology Ltd.
miramems MiraMEMS Sensing Technology Co., Ltd.
mitsubishi Mitsubishi Electric Corporation
mosaixtech Mosaix Technologies, Inc.
motorola Motorola, Inc.
moxa Moxa Inc.
mpl MPL AG
mqmaker mqmaker Inc.
mscc Microsemi Corporation
msi Micro-Star International Co. Ltd.
mti Imagination Technologies Ltd. (formerly MIPS Technologies Inc.)
multi-inno Multi-Inno Technology Co.,Ltd
mundoreader Mundo Reader S.L.
murata Murata Manufacturing Co., Ltd.
mxicy Macronix International Co., Ltd.
myir MYIR Tech Limited
national National Semiconductor
nec NEC LCD Technologies, Ltd.
neonode Neonode Inc.
netgear NETGEAR
netlogic Broadcom Corporation (formerly NetLogic Microsystems)
netron-dy Netron DY
netxeon Shenzhen Netxeon Technology CO., LTD
nexbox Nexbox
nextthing Next Thing Co.
newhaven Newhaven Display International
ni National Instruments
nintendo Nintendo
nlt NLT Technologies, Ltd.
nokia Nokia
nordic Nordic Semiconductor
novtech NovTech, Inc.
nutsboard NutsBoard
nuvoton Nuvoton Technology Corporation
nvd New Vision Display
nvidia NVIDIA
nxp NXP Semiconductors
okaya Okaya Electric America, Inc.
oki Oki Electric Industry Co., Ltd.
olimex OLIMEX Ltd.
olpc One Laptop Per Child
onion Onion Corporation
onnn ON Semiconductor Corp.
ontat On Tat Industrial Company
opalkelly Opal Kelly Incorporated
opencores OpenCores.org
openrisc OpenRISC.io
option Option NV
oranth Shenzhen Oranth Technology Co., Ltd.
ORCL Oracle Corporation
orisetech Orise Technology
ortustech Ortus Technology Co., Ltd.
ovti OmniVision Technologies
oxsemi Oxford Semiconductor, Ltd.
panasonic Panasonic Corporation
parade Parade Technologies Inc.
pda Precision Design Associates, Inc.
pericom Pericom Technology Inc.
pervasive Pervasive Displays, Inc.
phicomm PHICOMM Co., Ltd.
phytec PHYTEC Messtechnik GmbH
picochip Picochip Ltd
pine64 Pine64
pixcir PIXCIR MICROELECTRONICS Co., Ltd
plantower Plantower Co., Ltd
plathome Plat'Home Co., Ltd.
plda PLDA
plx Broadcom Corporation (formerly PLX Technology)
pni PNI Sensor Corporation
portwell Portwell Inc.
poslab Poslab Technology Co., Ltd.
powervr PowerVR (deprecated, use img)
probox2 PROBOX2 (by W2COMP Co., Ltd.)
pulsedlight PulsedLight, Inc
qca Qualcomm Atheros, Inc.
qcom Qualcomm Technologies, Inc
qemu QEMU, a generic and open source machine emulator and virtualizer
qi Qi Hardware
qiaodian QiaoDian XianShi Corporation
qnap QNAP Systems, Inc.
radxa Radxa
raidsonic RaidSonic Technology GmbH
ralink Mediatek/Ralink Technology Corp.
ramtron Ramtron International
raspberrypi Raspberry Pi Foundation
raydium Raydium Semiconductor Corp.
rda Unisoc Communications, Inc.
realtek Realtek Semiconductor Corp.
renesas Renesas Electronics Corporation
richtek Richtek Technology Corporation
ricoh Ricoh Co. Ltd.
rikomagic Rikomagic Tech Corp. Ltd
riscv RISC-V Foundation
rockchip Fuzhou Rockchip Electronics Co., Ltd
rohm ROHM Semiconductor Co., Ltd
roofull Shenzhen Roofull Technology Co, Ltd
samsung Samsung Semiconductor
samtec Samtec/Softing company
sancloud Sancloud Ltd
sandisk Sandisk Corporation
sbs Smart Battery System
schindler Schindler
seagate Seagate Technology PLC
semtech Semtech Corporation
sensirion Sensirion AG
sff Small Form Factor Committee
sgd Solomon Goldentek Display Corporation
sgx SGX Sensortech
sharp Sharp Corporation
shimafuji Shimafuji Electric, Inc.
si-en Si-En Technology Ltd.
sifive SiFive, Inc.
sigma Sigma Designs, Inc.
sii Seiko Instruments, Inc.
sil Silicon Image
silabs Silicon Laboratories
silead Silead Inc.
silergy Silergy Corp.
siliconmitus Silicon Mitus, Inc.
simtek
sirf SiRF Technology, Inc.
sis Silicon Integrated Systems Corp.
sitronix Sitronix Technology Corporation
skyworks Skyworks Solutions, Inc.
smsc Standard Microsystems Corporation
snps Synopsys, Inc.
socionext Socionext Inc.
solidrun SolidRun
solomon Solomon Systech Limited
sony Sony Corporation
spansion Spansion Inc.
sprd Spreadtrum Communications Inc.
sst Silicon Storage Technology, Inc.
st STMicroelectronics
starry Starry Electronic Technology (ShenZhen) Co., LTD
startek Startek
ste ST-Ericsson
stericsson ST-Ericsson
summit Summit microelectronics
sunchip Shenzhen Sunchip Technology Co., Ltd
SUNW Sun Microsystems, Inc
swir Sierra Wireless
syna Synaptics Inc.
synology Synology, Inc.
tbs TBS Technologies
tbs-biometrics Touchless Biometric Systems AG
tcg Trusted Computing Group
tcl Toby Churchill Ltd.
technexion TechNexion
technologic Technologic Systems
tempo Tempo Semiconductor
techstar Shenzhen Techstar Electronics Co., Ltd.
terasic Terasic Inc.
thine THine Electronics, Inc.
ti Texas Instruments
tianma Tianma Micro-electronics Co., Ltd.
tlm Trusted Logic Mobility
tmt Tecon Microprocessor Technologies, LLC.
topeet Topeet
toradex Toradex AG
toshiba Toshiba Corporation
toumaz Toumaz
tpk TPK U.S.A. LLC
tplink TP-LINK Technologies Co., Ltd.
tpo TPO
tronfy Tronfy
tronsmart Tronsmart
truly Truly Semiconductors Limited
tsd Theobroma Systems Design und Consulting GmbH
tyan Tyan Computer Corporation
u-blox u-blox
ucrobotics uCRobotics
ubnt Ubiquiti Networks
udoo Udoo
uniwest United Western Technologies Corp (UniWest)
upisemi uPI Semiconductor Corp.
urt United Radiant Technology Corporation
usi Universal Scientific Industrial Co., Ltd.
v3 V3 Semiconductor
vamrs Vamrs Ltd.
variscite Variscite Ltd.
via VIA Technologies, Inc.
virtio Virtual I/O Device Specification, developed by the OASIS consortium
vishay Vishay Intertechnology, Inc
vitesse Vitesse Semiconductor Corporation
vivante Vivante Corporation
vocore VoCore Studio
voipac Voipac Technologies s.r.o.
vot Vision Optical Technology Co., Ltd.
wd Western Digital Corp.
wetek WeTek Electronics, limited.
wexler Wexler
whwave Shenzhen whwave Electronics, Inc.
wi2wi Wi2Wi, Inc.
winbond Winbond Electronics corp.
winstar Winstar Display Corp.
wlf Wolfson Microelectronics
wm Wondermedia Technologies, Inc.
x-powers X-Powers
xes Extreme Engineering Solutions (X-ES)
xillybus Xillybus Ltd.
xlnx Xilinx
xunlong Shenzhen Xunlong Software CO.,Limited
ysoft Y Soft Corporation a.s.
zarlink Zarlink Semiconductor
zeitec ZEITEC Semiconductor Co., LTD.
zidoo Shenzhen Zidoo Technology Co., Ltd.
zii Zodiac Inflight Innovations
zte ZTE Corp.
zyxel ZyXEL Communications Corp.
......@@ -159,6 +159,8 @@ patternProperties:
description: Beckhoff Automation GmbH & Co. KG
"^bitmain,.*":
description: Bitmain Technologies
"^blokaslabs,.*":
description: Vilniaus Blokas UAB
"^boe,.*":
description: BOE Technology Group Co., Ltd.
"^bosch,.*":
......
......@@ -86,6 +86,12 @@ config COMMON_CLK_HI655X
multi-function device has one fixed-rate oscillator, clocked
at 32KHz.
config COMMON_CLK_HIFIBERRY_DACPLUSHD
tristate
config COMMON_CLK_HIFIBERRY_DACPRO
tristate
config COMMON_CLK_SCMI
tristate "Clock driver controlled via SCMI interface"
depends on ARM_SCMI_PROTOCOL || COMPILE_TEST
......
......@@ -18,6 +18,7 @@ endif
# hardware specific clock types
# please keep this section sorted lexicographically by file path name
obj-$(CONFIG_SND_BCM2708_SOC_ALLO_BOSS_DAC) += clk-allo-dac.o
obj-$(CONFIG_MACH_ASM9260) += clk-asm9260.o
obj-$(CONFIG_COMMON_CLK_AXI_CLKGEN) += clk-axi-clkgen.o
obj-$(CONFIG_ARCH_AXXIA) += clk-axm5516.o
......@@ -37,6 +38,8 @@ obj-$(CONFIG_MACH_ASPEED_G6) += clk-ast2600.o
obj-$(CONFIG_ARCH_HIGHBANK) += clk-highbank.o
obj-$(CONFIG_CLK_HSDK) += clk-hsdk-pll.o
obj-$(CONFIG_COMMON_CLK_LOCHNAGAR) += clk-lochnagar.o
obj-$(CONFIG_COMMON_CLK_HIFIBERRY_DACPRO) += clk-hifiberry-dacpro.o
obj-$(CONFIG_COMMON_CLK_HIFIBERRY_DACPLUSHD) += clk-hifiberry-dachd.o
obj-$(CONFIG_COMMON_CLK_MAX77686) += clk-max77686.o
obj-$(CONFIG_COMMON_CLK_MAX9485) += clk-max9485.o
obj-$(CONFIG_ARCH_MILBEAUT_M10V) += clk-milbeaut.o
......
/*
* Clock Driver for Allo DAC
*
* Author: Baswaraj K <jaikumar@cem-solutions.net>
* Copyright 2016
* based on code by Stuart MacLean
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*/
#include <linux/clk-provider.h>
#include <linux/clkdev.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/slab.h>
#include <linux/platform_device.h>
/* Clock rate of CLK44EN attached to GPIO6 pin */
#define CLK_44EN_RATE 45158400UL
/* Clock rate of CLK48EN attached to GPIO3 pin */
#define CLK_48EN_RATE 49152000UL
/**
* struct allo_dac_clk - Common struct to the Allo DAC
* @hw: clk_hw for the common clk framework
* @mode: 0 => CLK44EN, 1 => CLK48EN
*/
struct clk_allo_hw {
struct clk_hw hw;
uint8_t mode;
};
#define to_allo_clk(_hw) container_of(_hw, struct clk_allo_hw, hw)
static const struct of_device_id clk_allo_dac_dt_ids[] = {
{ .compatible = "allo,dac-clk",},
{ }
};
MODULE_DEVICE_TABLE(of, clk_allo_dac_dt_ids);
static unsigned long clk_allo_dac_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{
return (to_allo_clk(hw)->mode == 0) ? CLK_44EN_RATE :
CLK_48EN_RATE;
}
static long clk_allo_dac_round_rate(struct clk_hw *hw,
unsigned long rate, unsigned long *parent_rate)
{
long actual_rate;
if (rate <= CLK_44EN_RATE) {
actual_rate = (long)CLK_44EN_RATE;
} else if (rate >= CLK_48EN_RATE) {
actual_rate = (long)CLK_48EN_RATE;
} else {
long diff44Rate = (long)(rate - CLK_44EN_RATE);
long diff48Rate = (long)(CLK_48EN_RATE - rate);
if (diff44Rate < diff48Rate)
actual_rate = (long)CLK_44EN_RATE;
else
actual_rate = (long)CLK_48EN_RATE;
}
return actual_rate;
}
static int clk_allo_dac_set_rate(struct clk_hw *hw,
unsigned long rate, unsigned long parent_rate)
{
unsigned long actual_rate;
struct clk_allo_hw *clk = to_allo_clk(hw);
actual_rate = (unsigned long)clk_allo_dac_round_rate(hw, rate,
&parent_rate);
clk->mode = (actual_rate == CLK_44EN_RATE) ? 0 : 1;
return 0;
}
const struct clk_ops clk_allo_dac_rate_ops = {
.recalc_rate = clk_allo_dac_recalc_rate,
.round_rate = clk_allo_dac_round_rate,
.set_rate = clk_allo_dac_set_rate,
};
static int clk_allo_dac_probe(struct platform_device *pdev)
{
int ret;
struct clk_allo_hw *proclk;
struct clk *clk;
struct device *dev;
struct clk_init_data init;
dev = &pdev->dev;
proclk = kzalloc(sizeof(struct clk_allo_hw), GFP_KERNEL);
if (!proclk)
return -ENOMEM;
init.name = "clk-allo-dac";
init.ops = &clk_allo_dac_rate_ops;
init.flags = 0;
init.parent_names = NULL;
init.num_parents = 0;
proclk->mode = 0;
proclk->hw.init = &init;
clk = devm_clk_register(dev, &proclk->hw);
if (!IS_ERR(clk)) {
ret = of_clk_add_provider(dev->of_node, of_clk_src_simple_get,
clk);
} else {
dev_err(dev, "Fail to register clock driver\n");
kfree(proclk);
ret = PTR_ERR(clk);
}
return ret;
}
static int clk_allo_dac_remove(struct platform_device *pdev)
{
of_clk_del_provider(pdev->dev.of_node);
return 0;
}
static struct platform_driver clk_allo_dac_driver = {
.probe = clk_allo_dac_probe,
.remove = clk_allo_dac_remove,
.driver = {
.name = "clk-allo-dac",
.of_match_table = clk_allo_dac_dt_ids,
},
};
static int __init clk_allo_dac_init(void)
{
return platform_driver_register(&clk_allo_dac_driver);
}
core_initcall(clk_allo_dac_init);
static void __exit clk_allo_dac_exit(void)
{
platform_driver_unregister(&clk_allo_dac_driver);
}
module_exit(clk_allo_dac_exit);
MODULE_DESCRIPTION("Allo DAC clock driver");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:clk-allo-dac");
// SPDX-License-Identifier: GPL-2.0
/*
* Clock Driver for HiFiBerry DAC+ HD
*
* Author: Joerg Schambacher, i2Audio GmbH for HiFiBerry
* Copyright 2020
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*/
#include <linux/clk-provider.h>
#include <linux/clk.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/slab.h>
#include <linux/platform_device.h>
#include <linux/i2c.h>
#include <linux/regmap.h>
#define NO_PLL_RESET 0
#define PLL_RESET 1
#define HIFIBERRY_PLL_MAX_REGISTER 256
#define DEFAULT_RATE 44100
static struct reg_default hifiberry_pll_reg_defaults[] = {
{0x02, 0x53}, {0x03, 0x00}, {0x07, 0x20}, {0x0F, 0x00},
{0x10, 0x0D}, {0x11, 0x1D}, {0x12, 0x0D}, {0x13, 0x8C},
{0x14, 0x8C}, {0x15, 0x8C}, {0x16, 0x8C}, {0x17, 0x8C},
{0x18, 0x2A}, {0x1C, 0x00}, {0x1D, 0x0F}, {0x1F, 0x00},
{0x2A, 0x00}, {0x2C, 0x00}, {0x2F, 0x00}, {0x30, 0x00},
{0x31, 0x00}, {0x32, 0x00}, {0x34, 0x00}, {0x37, 0x00},
{0x38, 0x00}, {0x39, 0x00}, {0x3A, 0x00}, {0x3B, 0x01},
{0x3E, 0x00}, {0x3F, 0x00}, {0x40, 0x00}, {0x41, 0x00},
{0x5A, 0x00}, {0x5B, 0x00}, {0x95, 0x00}, {0x96, 0x00},
{0x97, 0x00}, {0x98, 0x00}, {0x99, 0x00}, {0x9A, 0x00},
{0x9B, 0x00}, {0xA2, 0x00}, {0xA3, 0x00}, {0xA4, 0x00},
{0xB7, 0x92},
{0x1A, 0x3D}, {0x1B, 0x09}, {0x1E, 0xF3}, {0x20, 0x13},
{0x21, 0x75}, {0x2B, 0x04}, {0x2D, 0x11}, {0x2E, 0xE0},
{0x3D, 0x7A},
{0x35, 0x9D}, {0x36, 0x00}, {0x3C, 0x42},
{ 177, 0xAC},
};
static struct reg_default common_pll_regs[HIFIBERRY_PLL_MAX_REGISTER];
static int num_common_pll_regs;
static struct reg_default dedicated_192k_pll_regs[HIFIBERRY_PLL_MAX_REGISTER];
static int num_dedicated_192k_pll_regs;
static struct reg_default dedicated_96k_pll_regs[HIFIBERRY_PLL_MAX_REGISTER];
static int num_dedicated_96k_pll_regs;
static struct reg_default dedicated_48k_pll_regs[HIFIBERRY_PLL_MAX_REGISTER];
static int num_dedicated_48k_pll_regs;
static struct reg_default dedicated_176k4_pll_regs[HIFIBERRY_PLL_MAX_REGISTER];
static int num_dedicated_176k4_pll_regs;
static struct reg_default dedicated_88k2_pll_regs[HIFIBERRY_PLL_MAX_REGISTER];
static int num_dedicated_88k2_pll_regs;
static struct reg_default dedicated_44k1_pll_regs[HIFIBERRY_PLL_MAX_REGISTER];
static int num_dedicated_44k1_pll_regs;
/**
* struct clk_hifiberry_drvdata - Common struct to the HiFiBerry DAC HD Clk
* @hw: clk_hw for the common clk framework
*/
struct clk_hifiberry_drvdata {
struct regmap *regmap;
struct clk *clk;
struct clk_hw hw;
unsigned long rate;
};
#define to_hifiberry_clk(_hw) \
container_of(_hw, struct clk_hifiberry_drvdata, hw)
static int clk_hifiberry_dachd_write_pll_regs(struct regmap *regmap,
struct reg_default *regs,
int num, int do_pll_reset)
{
int i;
int ret = 0;
char pll_soft_reset[] = { 177, 0xAC, };
for (i = 0; i < num; i++) {
ret |= regmap_write(regmap, regs[i].reg, regs[i].def);
if (ret)
return ret;
}
if (do_pll_reset) {
ret |= regmap_write(regmap, pll_soft_reset[0],
pll_soft_reset[1]);
mdelay(10);
}
return ret;
}
static unsigned long clk_hifiberry_dachd_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{
return to_hifiberry_clk(hw)->rate;
}
static long clk_hifiberry_dachd_round_rate(struct clk_hw *hw,
unsigned long rate, unsigned long *parent_rate)
{
return rate;
}
static int clk_hifiberry_dachd_set_rate(struct clk_hw *hw,
unsigned long rate, unsigned long parent_rate)
{
int ret;
struct clk_hifiberry_drvdata *drvdata = to_hifiberry_clk(hw);
switch (rate) {
case 44100:
ret = clk_hifiberry_dachd_write_pll_regs(drvdata->regmap,
dedicated_44k1_pll_regs, num_dedicated_44k1_pll_regs,
PLL_RESET);
break;
case 88200:
ret = clk_hifiberry_dachd_write_pll_regs(drvdata->regmap,
dedicated_88k2_pll_regs, num_dedicated_88k2_pll_regs,
PLL_RESET);
break;
case 176400:
ret = clk_hifiberry_dachd_write_pll_regs(drvdata->regmap,
dedicated_176k4_pll_regs, num_dedicated_176k4_pll_regs,
PLL_RESET);
break;
case 48000:
ret = clk_hifiberry_dachd_write_pll_regs(drvdata->regmap,
dedicated_48k_pll_regs, num_dedicated_48k_pll_regs,
PLL_RESET);
break;
case 96000:
ret = clk_hifiberry_dachd_write_pll_regs(drvdata->regmap,
dedicated_96k_pll_regs, num_dedicated_96k_pll_regs,
PLL_RESET);
break;
case 192000:
ret = clk_hifiberry_dachd_write_pll_regs(drvdata->regmap,
dedicated_192k_pll_regs, num_dedicated_192k_pll_regs,
PLL_RESET);
break;
default:
ret = -EINVAL;
break;
}
to_hifiberry_clk(hw)->rate = rate;
return ret;
}
const struct clk_ops clk_hifiberry_dachd_rate_ops = {
.recalc_rate = clk_hifiberry_dachd_recalc_rate,
.round_rate = clk_hifiberry_dachd_round_rate,
.set_rate = clk_hifiberry_dachd_set_rate,
};
static int clk_hifiberry_get_prop_values(struct device *dev,
char *prop_name,
struct reg_default *regs)
{
int ret;
int i;
u8 tmp[2 * HIFIBERRY_PLL_MAX_REGISTER];
ret = of_property_read_variable_u8_array(dev->of_node, prop_name,
tmp, 0, 2 * HIFIBERRY_PLL_MAX_REGISTER);
if (ret < 0)
return ret;
if (ret & 1) {
dev_err(dev,
"%s <%s> -> #%i odd number of bytes for reg/val pairs!",
__func__,
prop_name,
ret);
return -EINVAL;
}
ret /= 2;
for (i = 0; i < ret; i++) {
regs[i].reg = (u32)tmp[2 * i];
regs[i].def = (u32)tmp[2 * i + 1];
}
return ret;
}
static int clk_hifiberry_dachd_dt_parse(struct device *dev)
{
num_common_pll_regs = clk_hifiberry_get_prop_values(dev,
"common_pll_regs", common_pll_regs);
num_dedicated_44k1_pll_regs = clk_hifiberry_get_prop_values(dev,
"44k1_pll_regs", dedicated_44k1_pll_regs);
num_dedicated_88k2_pll_regs = clk_hifiberry_get_prop_values(dev,
"88k2_pll_regs", dedicated_88k2_pll_regs);
num_dedicated_176k4_pll_regs = clk_hifiberry_get_prop_values(dev,
"176k4_pll_regs", dedicated_176k4_pll_regs);
num_dedicated_48k_pll_regs = clk_hifiberry_get_prop_values(dev,
"48k_pll_regs", dedicated_48k_pll_regs);
num_dedicated_96k_pll_regs = clk_hifiberry_get_prop_values(dev,
"96k_pll_regs", dedicated_96k_pll_regs);
num_dedicated_192k_pll_regs = clk_hifiberry_get_prop_values(dev,
"192k_pll_regs", dedicated_192k_pll_regs);
return 0;
}
static int clk_hifiberry_dachd_remove(struct device *dev)
{
of_clk_del_provider(dev->of_node);
return 0;
}
const struct regmap_config hifiberry_pll_regmap = {
.reg_bits = 8,
.val_bits = 8,
.max_register = HIFIBERRY_PLL_MAX_REGISTER,
.reg_defaults = hifiberry_pll_reg_defaults,
.num_reg_defaults = ARRAY_SIZE(hifiberry_pll_reg_defaults),
.cache_type = REGCACHE_RBTREE,
};
EXPORT_SYMBOL_GPL(hifiberry_pll_regmap);
static int clk_hifiberry_dachd_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
struct clk_hifiberry_drvdata *hdclk;
int ret = 0;
struct clk_init_data init;
struct device *dev = &i2c->dev;
struct device_node *dev_node = dev->of_node;
struct regmap_config config = hifiberry_pll_regmap;
hdclk = devm_kzalloc(&i2c->dev,
sizeof(struct clk_hifiberry_drvdata), GFP_KERNEL);
if (!hdclk)
return -ENOMEM;
i2c_set_clientdata(i2c, hdclk);
hdclk->regmap = devm_regmap_init_i2c(i2c, &config);
if (IS_ERR(hdclk->regmap))
return PTR_ERR(hdclk->regmap);
/* start PLL to allow detection of DAC */
ret = clk_hifiberry_dachd_write_pll_regs(hdclk->regmap,
hifiberry_pll_reg_defaults,
ARRAY_SIZE(hifiberry_pll_reg_defaults),
PLL_RESET);
if (ret)
return ret;
clk_hifiberry_dachd_dt_parse(dev);
/* restart PLL with configs from DTB */
ret = clk_hifiberry_dachd_write_pll_regs(hdclk->regmap, common_pll_regs,
num_common_pll_regs, PLL_RESET);
if (ret)
return ret;
init.name = "clk-hifiberry-dachd";
init.ops = &clk_hifiberry_dachd_rate_ops;
init.flags = 0;
init.parent_names = NULL;
init.num_parents = 0;
hdclk->hw.init = &init;
hdclk->clk = devm_clk_register(dev, &hdclk->hw);
if (IS_ERR(hdclk->clk)) {
dev_err(dev, "unable to register %s\n", init.name);
return PTR_ERR(hdclk->clk);
}
ret = of_clk_add_provider(dev_node, of_clk_src_simple_get, hdclk->clk);
if (ret != 0) {
dev_err(dev, "Cannot of_clk_add_provider");
return ret;
}
ret = clk_set_rate(hdclk->hw.clk, DEFAULT_RATE);
if (ret != 0) {
dev_err(dev, "Cannot set rate : %d\n", ret);
return -EINVAL;
}
return ret;
}
static int clk_hifiberry_dachd_i2c_remove(struct i2c_client *i2c)
{
clk_hifiberry_dachd_remove(&i2c->dev);
return 0;
}
static const struct i2c_device_id clk_hifiberry_dachd_i2c_id[] = {
{ "dachd-clk", },
{ }
};
MODULE_DEVICE_TABLE(i2c, clk_hifiberry_dachd_i2c_id);
static const struct of_device_id clk_hifiberry_dachd_of_match[] = {
{ .compatible = "hifiberry,dachd-clk", },
{ }
};
MODULE_DEVICE_TABLE(of, clk_hifiberry_dachd_of_match);
static struct i2c_driver clk_hifiberry_dachd_i2c_driver = {
.probe = clk_hifiberry_dachd_i2c_probe,
.remove = clk_hifiberry_dachd_i2c_remove,
.id_table = clk_hifiberry_dachd_i2c_id,
.driver = {
.name = "dachd-clk",
.of_match_table = of_match_ptr(clk_hifiberry_dachd_of_match),
},
};
module_i2c_driver(clk_hifiberry_dachd_i2c_driver);
MODULE_DESCRIPTION("HiFiBerry DAC+ HD clock driver");
MODULE_AUTHOR("Joerg Schambacher <joerg@i2audio.com>");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:clk-hifiberry-dachd");
/*
* Clock Driver for HiFiBerry DAC Pro
*
* Author: Stuart MacLean
* Copyright 2015
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*/
#include <linux/clk-provider.h>
#include <linux/clkdev.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/slab.h>
#include <linux/platform_device.h>
/* Clock rate of CLK44EN attached to GPIO6 pin */
#define CLK_44EN_RATE 22579200UL
/* Clock rate of CLK48EN attached to GPIO3 pin */
#define CLK_48EN_RATE 24576000UL
/**
* struct hifiberry_dacpro_clk - Common struct to the HiFiBerry DAC Pro
* @hw: clk_hw for the common clk framework
* @mode: 0 => CLK44EN, 1 => CLK48EN
*/
struct clk_hifiberry_hw {
struct clk_hw hw;
uint8_t mode;
};
#define to_hifiberry_clk(_hw) container_of(_hw, struct clk_hifiberry_hw, hw)
static const struct of_device_id clk_hifiberry_dacpro_dt_ids[] = {
{ .compatible = "hifiberry,dacpro-clk",},
{ }
};
MODULE_DEVICE_TABLE(of, clk_hifiberry_dacpro_dt_ids);
static unsigned long clk_hifiberry_dacpro_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{
return (to_hifiberry_clk(hw)->mode == 0) ? CLK_44EN_RATE :
CLK_48EN_RATE;
}
static long clk_hifiberry_dacpro_round_rate(struct clk_hw *hw,
unsigned long rate, unsigned long *parent_rate)
{
long actual_rate;
if (rate <= CLK_44EN_RATE) {
actual_rate = (long)CLK_44EN_RATE;
} else if (rate >= CLK_48EN_RATE) {
actual_rate = (long)CLK_48EN_RATE;
} else {
long diff44Rate = (long)(rate - CLK_44EN_RATE);
long diff48Rate = (long)(CLK_48EN_RATE - rate);
if (diff44Rate < diff48Rate)
actual_rate = (long)CLK_44EN_RATE;
else
actual_rate = (long)CLK_48EN_RATE;
}
return actual_rate;
}
static int clk_hifiberry_dacpro_set_rate(struct clk_hw *hw,
unsigned long rate, unsigned long parent_rate)
{
unsigned long actual_rate;
struct clk_hifiberry_hw *clk = to_hifiberry_clk(hw);
actual_rate = (unsigned long)clk_hifiberry_dacpro_round_rate(hw, rate,
&parent_rate);
clk->mode = (actual_rate == CLK_44EN_RATE) ? 0 : 1;
return 0;
}
const struct clk_ops clk_hifiberry_dacpro_rate_ops = {
.recalc_rate = clk_hifiberry_dacpro_recalc_rate,
.round_rate = clk_hifiberry_dacpro_round_rate,
.set_rate = clk_hifiberry_dacpro_set_rate,
};
static int clk_hifiberry_dacpro_probe(struct platform_device *pdev)
{
int ret;
struct clk_hifiberry_hw *proclk;
struct clk *clk;
struct device *dev;
struct clk_init_data init;
dev = &pdev->dev;
proclk = kzalloc(sizeof(struct clk_hifiberry_hw), GFP_KERNEL);
if (!proclk)
return -ENOMEM;
init.name = "clk-hifiberry-dacpro";
init.ops = &clk_hifiberry_dacpro_rate_ops;
init.flags = 0;
init.parent_names = NULL;
init.num_parents = 0;
proclk->mode = 0;
proclk->hw.init = &init;
clk = devm_clk_register(dev, &proclk->hw);
if (!IS_ERR(clk)) {
ret = of_clk_add_provider(dev->of_node, of_clk_src_simple_get,
clk);
} else {
dev_err(dev, "Fail to register clock driver\n");
kfree(proclk);
ret = PTR_ERR(clk);
}
return ret;
}
static int clk_hifiberry_dacpro_remove(struct platform_device *pdev)
{
of_clk_del_provider(pdev->dev.of_node);
return 0;
}
static struct platform_driver clk_hifiberry_dacpro_driver = {
.probe = clk_hifiberry_dacpro_probe,
.remove = clk_hifiberry_dacpro_remove,
.driver = {
.name = "clk-hifiberry-dacpro",
.of_match_table = clk_hifiberry_dacpro_dt_ids,
},
};
static int __init clk_hifiberry_dacpro_init(void)
{
return platform_driver_register(&clk_hifiberry_dacpro_driver);
}
core_initcall(clk_hifiberry_dacpro_init);
static void __exit clk_hifiberry_dacpro_exit(void)
{
platform_driver_unregister(&clk_hifiberry_dacpro_driver);
}
module_exit(clk_hifiberry_dacpro_exit);
MODULE_DESCRIPTION("HiFiBerry DAC Pro clock driver");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:clk-hifiberry-dacpro");
......@@ -26,3 +26,277 @@ config SND_BCM63XX_I2S_WHISTLER
DSL/PON chips (bcm63158, bcm63178)
If you don't know what to do here, say N
config SND_BCM2708_SOC_GOOGLEVOICEHAT_SOUNDCARD
tristate "Support for Google voiceHAT soundcard"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_VOICEHAT
select SND_RPI_SIMPLE_SOUNDCARD
help
Say Y or M if you want to add support for voiceHAT soundcard.
config SND_BCM2708_SOC_HIFIBERRY_DAC
tristate "Support for HifiBerry DAC"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_PCM5102A
select SND_RPI_SIMPLE_SOUNDCARD
help
Say Y or M if you want to add support for HifiBerry DAC.
config SND_BCM2708_SOC_HIFIBERRY_DACPLUS
tristate "Support for HifiBerry DAC+"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_PCM512x
select SND_SOC_TPA6130A2
select COMMON_CLK_HIFIBERRY_DACPRO
help
Say Y or M if you want to add support for HifiBerry DAC+.
config SND_BCM2708_SOC_HIFIBERRY_DACPLUSHD
tristate "Support for HifiBerry DAC+ HD"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_PCM179X_I2C
select COMMON_CLK_HIFIBERRY_DACPLUSHD
help
Say Y or M if you want to add support for HifiBerry DAC+ HD.
config SND_BCM2708_SOC_HIFIBERRY_DACPLUSADC
tristate "Support for HifiBerry DAC+ADC"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_PCM512x_I2C
select SND_SOC_DMIC
select COMMON_CLK_HIFIBERRY_DACPRO
help
Say Y or M if you want to add support for HifiBerry DAC+ADC.
config SND_BCM2708_SOC_HIFIBERRY_DACPLUSADCPRO
tristate "Support for HifiBerry DAC+ADC PRO"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_PCM512x_I2C
select SND_SOC_PCM186X_I2C
select COMMON_CLK_HIFIBERRY_DACPRO
help
Say Y or M if you want to add support for HifiBerry DAC+ADC PRO.
config SND_BCM2708_SOC_HIFIBERRY_DACPLUSDSP
tristate "Support for HifiBerry DAC+DSP"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_RPI_SIMPLE_SOUNDCARD
help
Say Y or M if you want to add support for HifiBerry DSP-DAC.
config SND_BCM2708_SOC_HIFIBERRY_DIGI
tristate "Support for HifiBerry Digi"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_WM8804
help
Say Y or M if you want to add support for HifiBerry Digi S/PDIF output board.
config SND_BCM2708_SOC_HIFIBERRY_AMP
tristate "Support for the HifiBerry Amp"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_TAS5713
select SND_RPI_SIMPLE_SOUNDCARD
help
Say Y or M if you want to add support for the HifiBerry Amp amplifier board.
config SND_BCM2708_SOC_RPI_CIRRUS
tristate "Support for Cirrus Logic Audio Card"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_WM5102
select SND_SOC_WM8804
help
Say Y or M if you want to add support for the Wolfson and
Cirrus Logic audio cards.
config SND_BCM2708_SOC_RPI_DAC
tristate "Support for RPi-DAC"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_PCM1794A
select SND_RPI_SIMPLE_SOUNDCARD
help
Say Y or M if you want to add support for RPi-DAC.
config SND_BCM2708_SOC_RPI_PROTO
tristate "Support for Rpi-PROTO"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_WM8731
help
Say Y or M if you want to add support for Audio Codec Board PROTO (WM8731).
config SND_BCM2708_SOC_JUSTBOOM_BOTH
tristate "Support for simultaneous JustBoom Digi and JustBoom DAC"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_WM8804
select SND_SOC_PCM512x
help
Say Y or M if you want to add support for simultaneous
JustBoom Digi and JustBoom DAC.
This is not the right choice if you only have one but both of
these cards.
config SND_BCM2708_SOC_JUSTBOOM_DAC
tristate "Support for JustBoom DAC"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_PCM512x
help
Say Y or M if you want to add support for JustBoom DAC.
config SND_BCM2708_SOC_JUSTBOOM_DIGI
tristate "Support for JustBoom Digi"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_WM8804
select SND_RPI_WM8804_SOUNDCARD
help
Say Y or M if you want to add support for JustBoom Digi.
config SND_BCM2708_SOC_IQAUDIO_CODEC
tristate "Support for IQaudIO-CODEC"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_DA7213
help
Say Y or M if you want to add support for IQaudIO-CODEC.
config SND_BCM2708_SOC_IQAUDIO_DAC
tristate "Support for IQaudIO-DAC"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_PCM512x_I2C
help
Say Y or M if you want to add support for IQaudIO-DAC.
config SND_BCM2708_SOC_IQAUDIO_DIGI
tristate "Support for IQAudIO Digi"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_WM8804
select SND_RPI_WM8804_SOUNDCARD
help
Say Y or M if you want to add support for IQAudIO Digital IO board.
config SND_BCM2708_SOC_I_SABRE_Q2M
tristate "Support for Audiophonics I-Sabre Q2M DAC"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_I_SABRE_CODEC
help
Say Y or M if you want to add support for Audiophonics I-SABRE Q2M DAC
config SND_BCM2708_SOC_ADAU1977_ADC
tristate "Support for ADAU1977 ADC"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_ADAU1977_I2C
select SND_RPI_SIMPLE_SOUNDCARD
help
Say Y or M if you want to add support for ADAU1977 ADC.
config SND_AUDIOINJECTOR_PI_SOUNDCARD
tristate "Support for audioinjector.net Pi add on soundcard"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_WM8731
help
Say Y or M if you want to add support for audioinjector.net Pi Hat
config SND_AUDIOINJECTOR_OCTO_SOUNDCARD
tristate "Support for audioinjector.net Octo channel (Hat) soundcard"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_CS42XX8_I2C
help
Say Y or M if you want to add support for audioinjector.net octo add on
config SND_AUDIOINJECTOR_ISOLATED_SOUNDCARD
tristate "Support for audioinjector.net isolated DAC and ADC soundcard"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_CS4271_I2C
help
Say Y or M if you want to add support for audioinjector.net isolated soundcard
config SND_AUDIOSENSE_PI
tristate "Support for AudioSense Add-On Soundcard"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_TLV320AIC32X4_I2C
help
Say Y or M if you want to add support for tlv320aic32x4 add-on
config SND_DIGIDAC1_SOUNDCARD
tristate "Support for Red Rocks Audio DigiDAC1"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_WM8804
select SND_SOC_WM8741
help
Say Y or M if you want to add support for Red Rocks Audio DigiDAC1 board.
config SND_BCM2708_SOC_DIONAUDIO_LOCO
tristate "Support for Dion Audio LOCO DAC-AMP"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_PCM5102a
help
Say Y or M if you want to add support for Dion Audio LOCO.
config SND_BCM2708_SOC_DIONAUDIO_LOCO_V2
tristate "Support for Dion Audio LOCO-V2 DAC-AMP"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_PCM5122
help
Say Y or M if you want to add support for Dion Audio LOCO-V2.
config SND_BCM2708_SOC_ALLO_PIANO_DAC
tristate "Support for Allo Piano DAC"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_PCM512x_I2C
help
Say Y or M if you want to add support for Allo Piano DAC.
config SND_BCM2708_SOC_ALLO_PIANO_DAC_PLUS
tristate "Support for Allo Piano DAC Plus"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_PCM512x_I2C
help
Say Y or M if you want to add support for Allo Piano DAC Plus.
config SND_BCM2708_SOC_ALLO_BOSS_DAC
tristate "Support for Allo Boss DAC"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_PCM512x_I2C
help
Say Y or M if you want to add support for Allo Boss DAC.
config SND_BCM2708_SOC_ALLO_DIGIONE
tristate "Support for Allo DigiOne"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_WM8804
select SND_RPI_WM8804_SOUNDCARD
help
Say Y or M if you want to add support for Allo DigiOne.
config SND_BCM2708_SOC_ALLO_KATANA_DAC
tristate "Support for Allo Katana DAC"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
depends on I2C
select REGMAP_I2C
select SND_AUDIO_GRAPH_CARD
help
Say Y or M if you want to add support for Allo Katana DAC.
config SND_BCM2708_SOC_FE_PI_AUDIO
tristate "Support for Fe-Pi-Audio"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_SOC_SGTL5000
help
Say Y or M if you want to add support for Fe-Pi-Audio.
config SND_PISOUND
tristate "Support for Blokas Labs pisound"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_RAWMIDI
help
Say Y or M if you want to add support for Blokas Labs pisound.
config SND_RPI_SIMPLE_SOUNDCARD
tristate "Support for Raspberry Pi simple soundcards"
help
Say Y or M if you want to add support Raspbery Pi simple soundcards
config SND_RPI_WM8804_SOUNDCARD
tristate "Support for Raspberry Pi generic WM8804 soundcards"
help
Say Y or M if you want to add support for the Raspberry Pi
generic driver for WM8804 based soundcards.
......@@ -13,3 +13,64 @@ obj-$(CONFIG_SND_SOC_CYGNUS) += snd-soc-cygnus.o
snd-soc-63xx-objs := bcm63xx-i2s-whistler.o bcm63xx-pcm-whistler.o
obj-$(CONFIG_SND_BCM63XX_I2S_WHISTLER) += snd-soc-63xx.o
# Google voiceHAT custom codec support
snd-soc-googlevoicehat-codec-objs := googlevoicehat-codec.o
# BCM2708 Machine Support
snd-soc-hifiberry-dacplus-objs := hifiberry_dacplus.o
snd-soc-hifiberry-dacplushd-objs := hifiberry_dacplushd.o
snd-soc-hifiberry-dacplusadc-objs := hifiberry_dacplusadc.o
snd-soc-hifiberry-dacplusadcpro-objs := hifiberry_dacplusadcpro.o
snd-soc-hifiberry-dacplusdsp-objs := hifiberry_dacplusdsp.o
snd-soc-justboom-both-objs := justboom-both.o
snd-soc-justboom-dac-objs := justboom-dac.o
snd-soc-rpi-cirrus-objs := rpi-cirrus.o
snd-soc-rpi-proto-objs := rpi-proto.o
snd-soc-iqaudio-codec-objs := iqaudio-codec.o
snd-soc-iqaudio-dac-objs := iqaudio-dac.o
snd-soc-i-sabre-q2m-objs := i-sabre-q2m.o
snd-soc-audioinjector-pi-soundcard-objs := audioinjector-pi-soundcard.o
snd-soc-audioinjector-octo-soundcard-objs := audioinjector-octo-soundcard.o
snd-soc-audioinjector-isolated-soundcard-objs := audioinjector-isolated-soundcard.o
snd-soc-audiosense-pi-objs := audiosense-pi.o
snd-soc-digidac1-soundcard-objs := digidac1-soundcard.o
snd-soc-dionaudio-loco-objs := dionaudio_loco.o
snd-soc-dionaudio-loco-v2-objs := dionaudio_loco-v2.o
snd-soc-allo-boss-dac-objs := allo-boss-dac.o
snd-soc-allo-piano-dac-objs := allo-piano-dac.o
snd-soc-allo-piano-dac-plus-objs := allo-piano-dac-plus.o
snd-soc-allo-katana-codec-objs := allo-katana-codec.o
snd-soc-pisound-objs := pisound.o
snd-soc-fe-pi-audio-objs := fe-pi-audio.o
snd-soc-rpi-simple-soundcard-objs := rpi-simple-soundcard.o
snd-soc-rpi-wm8804-soundcard-objs := rpi-wm8804-soundcard.o
obj-$(CONFIG_SND_BCM2708_SOC_GOOGLEVOICEHAT_SOUNDCARD) += snd-soc-googlevoicehat-codec.o
obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS) += snd-soc-hifiberry-dacplus.o
obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSHD) += snd-soc-hifiberry-dacplushd.o
obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADC) += snd-soc-hifiberry-dacplusadc.o
obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADCPRO) += snd-soc-hifiberry-dacplusadcpro.o
obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSDSP) += snd-soc-hifiberry-dacplusdsp.o
obj-$(CONFIG_SND_BCM2708_SOC_JUSTBOOM_BOTH) += snd-soc-justboom-both.o
obj-$(CONFIG_SND_BCM2708_SOC_JUSTBOOM_DAC) += snd-soc-justboom-dac.o
obj-$(CONFIG_SND_BCM2708_SOC_RPI_CIRRUS) += snd-soc-rpi-cirrus.o
obj-$(CONFIG_SND_BCM2708_SOC_RPI_PROTO) += snd-soc-rpi-proto.o
obj-$(CONFIG_SND_BCM2708_SOC_IQAUDIO_CODEC) += snd-soc-iqaudio-codec.o
obj-$(CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC) += snd-soc-iqaudio-dac.o
obj-$(CONFIG_SND_BCM2708_SOC_I_SABRE_Q2M) += snd-soc-i-sabre-q2m.o
obj-$(CONFIG_SND_AUDIOINJECTOR_PI_SOUNDCARD) += snd-soc-audioinjector-pi-soundcard.o
obj-$(CONFIG_SND_AUDIOINJECTOR_OCTO_SOUNDCARD) += snd-soc-audioinjector-octo-soundcard.o
obj-$(CONFIG_SND_AUDIOINJECTOR_ISOLATED_SOUNDCARD) += snd-soc-audioinjector-isolated-soundcard.o
obj-$(CONFIG_SND_AUDIOSENSE_PI) += snd-soc-audiosense-pi.o
obj-$(CONFIG_SND_DIGIDAC1_SOUNDCARD) += snd-soc-digidac1-soundcard.o
obj-$(CONFIG_SND_BCM2708_SOC_DIONAUDIO_LOCO) += snd-soc-dionaudio-loco.o
obj-$(CONFIG_SND_BCM2708_SOC_DIONAUDIO_LOCO_V2) += snd-soc-dionaudio-loco-v2.o
obj-$(CONFIG_SND_BCM2708_SOC_ALLO_BOSS_DAC) += snd-soc-allo-boss-dac.o
obj-$(CONFIG_SND_BCM2708_SOC_ALLO_PIANO_DAC) += snd-soc-allo-piano-dac.o
obj-$(CONFIG_SND_BCM2708_SOC_ALLO_PIANO_DAC_PLUS) += snd-soc-allo-piano-dac-plus.o
obj-$(CONFIG_SND_BCM2708_SOC_ALLO_KATANA_DAC) += snd-soc-allo-katana-codec.o
obj-$(CONFIG_SND_PISOUND) += snd-soc-pisound.o
obj-$(CONFIG_SND_BCM2708_SOC_FE_PI_AUDIO) += snd-soc-fe-pi-audio.o
obj-$(CONFIG_SND_RPI_SIMPLE_SOUNDCARD) += snd-soc-rpi-simple-soundcard.o
obj-$(CONFIG_SND_RPI_WM8804_SOUNDCARD) += snd-soc-rpi-wm8804-soundcard.o
/*
* ALSA ASoC Machine Driver for Allo Boss DAC
*
* Author: Baswaraj K <jaikumar@cem-solutions.net>
* Copyright 2017
* based on code by Daniel Matuschek,
* Stuart MacLean <stuart@hifiberry.com>
* based on code by Florian Meier <florian.meier@koalo.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*/
#include <linux/module.h>
#include <linux/gpio/consumer.h>
#include <linux/platform_device.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include "../codecs/pcm512x.h"
#define ALLO_BOSS_NOCLOCK 0
#define ALLO_BOSS_CLK44EN 1
#define ALLO_BOSS_CLK48EN 2
struct pcm512x_priv {
struct regmap *regmap;
struct clk *sclk;
};
static struct gpio_desc *mute_gpio;
/* Clock rate of CLK44EN attached to GPIO6 pin */
#define CLK_44EN_RATE 45158400UL
/* Clock rate of CLK48EN attached to GPIO3 pin */
#define CLK_48EN_RATE 49152000UL
static bool slave;
static bool snd_soc_allo_boss_master;
static bool digital_gain_0db_limit = true;
static void snd_allo_boss_select_clk(struct snd_soc_component *component,
int clk_id)
{
switch (clk_id) {
case ALLO_BOSS_NOCLOCK:
snd_soc_component_update_bits(component, PCM512x_GPIO_CONTROL_1, 0x24, 0x00);
break;
case ALLO_BOSS_CLK44EN:
snd_soc_component_update_bits(component, PCM512x_GPIO_CONTROL_1, 0x24, 0x20);
break;
case ALLO_BOSS_CLK48EN:
snd_soc_component_update_bits(component, PCM512x_GPIO_CONTROL_1, 0x24, 0x04);
break;
}
}
static void snd_allo_boss_clk_gpio(struct snd_soc_component *component)
{
snd_soc_component_update_bits(component, PCM512x_GPIO_EN, 0x24, 0x24);
snd_soc_component_update_bits(component, PCM512x_GPIO_OUTPUT_3, 0x0f, 0x02);
snd_soc_component_update_bits(component, PCM512x_GPIO_OUTPUT_6, 0x0f, 0x02);
}
static bool snd_allo_boss_is_sclk(struct snd_soc_component *component)
{
unsigned int sck;
sck = snd_soc_component_read(component, PCM512x_RATE_DET_4);
return (!(sck & 0x40));
}
static bool snd_allo_boss_is_sclk_sleep(
struct snd_soc_component *component)
{
msleep(2);
return snd_allo_boss_is_sclk(component);
}
static bool snd_allo_boss_is_master_card(struct snd_soc_component *component)
{
bool isClk44EN, isClk48En, isNoClk;
snd_allo_boss_clk_gpio(component);
snd_allo_boss_select_clk(component, ALLO_BOSS_CLK44EN);
isClk44EN = snd_allo_boss_is_sclk_sleep(component);
snd_allo_boss_select_clk(component, ALLO_BOSS_NOCLOCK);
isNoClk = snd_allo_boss_is_sclk_sleep(component);
snd_allo_boss_select_clk(component, ALLO_BOSS_CLK48EN);
isClk48En = snd_allo_boss_is_sclk_sleep(component);
return (isClk44EN && isClk48En && !isNoClk);
}
static int snd_allo_boss_clk_for_rate(int sample_rate)
{
int type;
switch (sample_rate) {
case 11025:
case 22050:
case 44100:
case 88200:
case 176400:
case 352800:
type = ALLO_BOSS_CLK44EN;
break;
default:
type = ALLO_BOSS_CLK48EN;
break;
}
return type;
}
static void snd_allo_boss_set_sclk(struct snd_soc_component *component,
int sample_rate)
{
struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component);
if (!IS_ERR(pcm512x->sclk)) {
int ctype;
ctype = snd_allo_boss_clk_for_rate(sample_rate);
clk_set_rate(pcm512x->sclk, (ctype == ALLO_BOSS_CLK44EN)
? CLK_44EN_RATE : CLK_48EN_RATE);
snd_allo_boss_select_clk(component, ctype);
}
}
static int snd_allo_boss_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
struct pcm512x_priv *priv = snd_soc_component_get_drvdata(component);
if (slave)
snd_soc_allo_boss_master = false;
else
snd_soc_allo_boss_master =
snd_allo_boss_is_master_card(component);
if (snd_soc_allo_boss_master) {
struct snd_soc_dai_link *dai = rtd->dai_link;
dai->name = "BossDAC";
dai->stream_name = "Boss DAC HiFi [Master]";
dai->dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
| SND_SOC_DAIFMT_CBM_CFM;
snd_soc_component_update_bits(component, PCM512x_BCLK_LRCLK_CFG, 0x31, 0x11);
snd_soc_component_update_bits(component, PCM512x_MASTER_MODE, 0x03, 0x03);
snd_soc_component_update_bits(component, PCM512x_MASTER_CLKDIV_2, 0x7f, 63);
/*
* Default sclk to CLK_48EN_RATE, otherwise codec
* pcm512x_dai_startup_master method could call
* snd_pcm_hw_constraint_ratnums using CLK_44EN/64
* which will mask 384k sample rate.
*/
if (!IS_ERR(priv->sclk))
clk_set_rate(priv->sclk, CLK_48EN_RATE);
} else {
priv->sclk = ERR_PTR(-ENOENT);
}
snd_soc_component_update_bits(component, PCM512x_GPIO_EN, 0x08, 0x08);
snd_soc_component_update_bits(component, PCM512x_GPIO_OUTPUT_4, 0x0f, 0x02);
snd_soc_component_update_bits(component, PCM512x_GPIO_CONTROL_1, 0x08, 0x08);
if (digital_gain_0db_limit) {
int ret;
struct snd_soc_card *card = rtd->card;
ret = snd_soc_limit_volume(card, "Digital Playback Volume",
207);
if (ret < 0)
dev_warn(card->dev, "Failed to set volume limit: %d\n",
ret);
}
return 0;
}
static int snd_allo_boss_update_rate_den(
struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component);
struct snd_ratnum *rats_no_pll;
unsigned int num = 0, den = 0;
int err;
rats_no_pll = devm_kzalloc(rtd->dev, sizeof(*rats_no_pll), GFP_KERNEL);
if (!rats_no_pll)
return -ENOMEM;
rats_no_pll->num = clk_get_rate(pcm512x->sclk) / 64;
rats_no_pll->den_min = 1;
rats_no_pll->den_max = 128;
rats_no_pll->den_step = 1;
err = snd_interval_ratnum(hw_param_interval(params,
SNDRV_PCM_HW_PARAM_RATE), 1, rats_no_pll, &num, &den);
if (err >= 0 && den) {
params->rate_num = num;
params->rate_den = den;
}
devm_kfree(rtd->dev, rats_no_pll);
return 0;
}
static void snd_allo_boss_gpio_mute(struct snd_soc_card *card)
{
if (mute_gpio)
gpiod_set_value_cansleep(mute_gpio, 1);
}
static void snd_allo_boss_gpio_unmute(struct snd_soc_card *card)
{
if (mute_gpio)
gpiod_set_value_cansleep(mute_gpio, 0);
}
static int snd_allo_boss_set_bias_level(struct snd_soc_card *card,
struct snd_soc_dapm_context *dapm, enum snd_soc_bias_level level)
{
struct snd_soc_pcm_runtime *rtd;
struct snd_soc_dai *codec_dai;
rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]);
codec_dai = asoc_rtd_to_codec(rtd, 0);
if (dapm->dev != codec_dai->dev)
return 0;
switch (level) {
case SND_SOC_BIAS_PREPARE:
if (dapm->bias_level != SND_SOC_BIAS_STANDBY)
break;
/* UNMUTE DAC */
snd_allo_boss_gpio_unmute(card);
break;
case SND_SOC_BIAS_STANDBY:
if (dapm->bias_level != SND_SOC_BIAS_PREPARE)
break;
/* MUTE DAC */
snd_allo_boss_gpio_mute(card);
break;
default:
break;
}
return 0;
}
static int snd_allo_boss_hw_params(
struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params)
{
int ret = 0;
struct snd_soc_pcm_runtime *rtd = substream->private_data;
int channels = params_channels(params);
int width = snd_pcm_format_physical_width(params_format(params));
if (snd_soc_allo_boss_master) {
struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
snd_allo_boss_set_sclk(component,
params_rate(params));
ret = snd_allo_boss_update_rate_den(
substream, params);
if (ret)
return ret;
}
ret = snd_soc_dai_set_bclk_ratio(asoc_rtd_to_cpu(rtd, 0), channels * width);
if (ret)
return ret;
ret = snd_soc_dai_set_bclk_ratio(asoc_rtd_to_codec(rtd, 0), channels * width);
return ret;
}
static int snd_allo_boss_startup(
struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
struct snd_soc_card *card = rtd->card;
snd_soc_component_update_bits(component, PCM512x_GPIO_CONTROL_1, 0x08, 0x08);
snd_allo_boss_gpio_mute(card);
if (snd_soc_allo_boss_master) {
struct pcm512x_priv *priv = snd_soc_component_get_drvdata(component);
/*
* Default sclk to CLK_48EN_RATE, otherwise codec
* pcm512x_dai_startup_master method could call
* snd_pcm_hw_constraint_ratnums using CLK_44EN/64
* which will mask 384k sample rate.
*/
if (!IS_ERR(priv->sclk))
clk_set_rate(priv->sclk, CLK_48EN_RATE);
}
return 0;
}
static void snd_allo_boss_shutdown(
struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
snd_soc_component_update_bits(component, PCM512x_GPIO_CONTROL_1, 0x08, 0x00);
}
static int snd_allo_boss_prepare(
struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_card *card = rtd->card;
snd_allo_boss_gpio_unmute(card);
return 0;
}
/* machine stream operations */
static struct snd_soc_ops snd_allo_boss_ops = {
.hw_params = snd_allo_boss_hw_params,
.startup = snd_allo_boss_startup,
.shutdown = snd_allo_boss_shutdown,
.prepare = snd_allo_boss_prepare,
};
SND_SOC_DAILINK_DEFS(allo_boss,
DAILINK_COMP_ARRAY(COMP_CPU("bcm2708-i2s.0")),
DAILINK_COMP_ARRAY(COMP_CODEC("pcm512x.1-004d", "pcm512x-hifi")),
DAILINK_COMP_ARRAY(COMP_PLATFORM("bcm2708-i2s.0")));
static struct snd_soc_dai_link snd_allo_boss_dai[] = {
{
.name = "Boss DAC",
.stream_name = "Boss DAC HiFi",
.dai_fmt = SND_SOC_DAIFMT_I2S |
SND_SOC_DAIFMT_NB_NF |
SND_SOC_DAIFMT_CBS_CFS,
.ops = &snd_allo_boss_ops,
.init = snd_allo_boss_init,
SND_SOC_DAILINK_REG(allo_boss),
},
};
/* audio machine driver */
static struct snd_soc_card snd_allo_boss = {
.name = "BossDAC",
.owner = THIS_MODULE,
.dai_link = snd_allo_boss_dai,
.num_links = ARRAY_SIZE(snd_allo_boss_dai),
};
static int snd_allo_boss_probe(struct platform_device *pdev)
{
int ret = 0;
snd_allo_boss.dev = &pdev->dev;
if (pdev->dev.of_node) {
struct device_node *i2s_node;
struct snd_soc_dai_link *dai;
dai = &snd_allo_boss_dai[0];
i2s_node = of_parse_phandle(pdev->dev.of_node,
"i2s-controller", 0);
if (i2s_node) {
dai->cpus->dai_name = NULL;
dai->cpus->of_node = i2s_node;
dai->platforms->name = NULL;
dai->platforms->of_node = i2s_node;
}
digital_gain_0db_limit = !of_property_read_bool(
pdev->dev.of_node, "allo,24db_digital_gain");
slave = of_property_read_bool(pdev->dev.of_node,
"allo,slave");
mute_gpio = devm_gpiod_get_optional(&pdev->dev, "mute",
GPIOD_OUT_LOW);
if (IS_ERR(mute_gpio)) {
ret = PTR_ERR(mute_gpio);
dev_err(&pdev->dev,
"failed to get mute gpio: %d\n", ret);
return ret;
}
if (mute_gpio)
snd_allo_boss.set_bias_level =
snd_allo_boss_set_bias_level;
ret = snd_soc_register_card(&snd_allo_boss);
if (ret) {
dev_err(&pdev->dev,
"snd_soc_register_card() failed: %d\n", ret);
return ret;
}
if (mute_gpio)
snd_allo_boss_gpio_mute(&snd_allo_boss);
return 0;
}
return -EINVAL;
}
static int snd_allo_boss_remove(struct platform_device *pdev)
{
snd_allo_boss_gpio_mute(&snd_allo_boss);
return snd_soc_unregister_card(&snd_allo_boss);
}
static const struct of_device_id snd_allo_boss_of_match[] = {
{ .compatible = "allo,boss-dac", },
{ /* sentinel */ },
};
MODULE_DEVICE_TABLE(of, snd_allo_boss_of_match);
static struct platform_driver snd_allo_boss_driver = {
.driver = {
.name = "snd-allo-boss-dac",
.owner = THIS_MODULE,
.of_match_table = snd_allo_boss_of_match,
},
.probe = snd_allo_boss_probe,
.remove = snd_allo_boss_remove,
};
module_platform_driver(snd_allo_boss_driver);
MODULE_AUTHOR("Baswaraj K <jaikumar@cem-solutions.net>");
MODULE_DESCRIPTION("ALSA ASoC Machine Driver for Allo Boss DAC");
MODULE_LICENSE("GPL v2");
/*
* Driver for the ALLO KATANA CODEC
*
* Author: Jaikumar <jaikumar@cem-solutions.net>
* Copyright 2018
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*/
#include <linux/init.h>
#include <linux/module.h>
#include <linux/clk.h>
#include <linux/kernel.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/gcd.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include <sound/pcm_params.h>
#include <sound/tlv.h>
#include <linux/i2c.h>
#define KATANA_CODEC_CHIP_ID 0x30
#define KATANA_CODEC_VIRT_BASE 0x100
#define KATANA_CODEC_PAGE 0
#define KATANA_CODEC_CHIP_ID_REG (KATANA_CODEC_VIRT_BASE + 0)
#define KATANA_CODEC_RESET (KATANA_CODEC_VIRT_BASE + 1)
#define KATANA_CODEC_VOLUME_1 (KATANA_CODEC_VIRT_BASE + 2)
#define KATANA_CODEC_VOLUME_2 (KATANA_CODEC_VIRT_BASE + 3)
#define KATANA_CODEC_MUTE (KATANA_CODEC_VIRT_BASE + 4)
#define KATANA_CODEC_DSP_PROGRAM (KATANA_CODEC_VIRT_BASE + 5)
#define KATANA_CODEC_DEEMPHASIS (KATANA_CODEC_VIRT_BASE + 6)
#define KATANA_CODEC_DOP (KATANA_CODEC_VIRT_BASE + 7)
#define KATANA_CODEC_FORMAT (KATANA_CODEC_VIRT_BASE + 8)
#define KATANA_CODEC_COMMAND (KATANA_CODEC_VIRT_BASE + 9)
#define KATANA_CODEC_MUTE_STREAM (KATANA_CODEC_VIRT_BASE + 10)
#define KATANA_CODEC_MAX_REGISTER (KATANA_CODEC_VIRT_BASE + 10)
#define KATANA_CODEC_FMT 0xff
#define KATANA_CODEC_CHAN_MONO 0x00
#define KATANA_CODEC_CHAN_STEREO 0x80
#define KATANA_CODEC_ALEN_16 0x10
#define KATANA_CODEC_ALEN_24 0x20
#define KATANA_CODEC_ALEN_32 0x30
#define KATANA_CODEC_RATE_11025 0x01
#define KATANA_CODEC_RATE_22050 0x02
#define KATANA_CODEC_RATE_32000 0x03
#define KATANA_CODEC_RATE_44100 0x04
#define KATANA_CODEC_RATE_48000 0x05
#define KATANA_CODEC_RATE_88200 0x06
#define KATANA_CODEC_RATE_96000 0x07
#define KATANA_CODEC_RATE_176400 0x08
#define KATANA_CODEC_RATE_192000 0x09
#define KATANA_CODEC_RATE_352800 0x0a
#define KATANA_CODEC_RATE_384000 0x0b
struct katana_codec_priv {
struct regmap *regmap;
int fmt;
};
static const struct reg_default katana_codec_reg_defaults[] = {
{ KATANA_CODEC_RESET, 0x00 },
{ KATANA_CODEC_VOLUME_1, 0xF0 },
{ KATANA_CODEC_VOLUME_2, 0xF0 },
{ KATANA_CODEC_MUTE, 0x00 },
{ KATANA_CODEC_DSP_PROGRAM, 0x04 },
{ KATANA_CODEC_DEEMPHASIS, 0x00 },
{ KATANA_CODEC_DOP, 0x00 },
{ KATANA_CODEC_FORMAT, 0xb4 },
};
static const char * const katana_codec_dsp_program_texts[] = {
"Linear Phase Fast Roll-off Filter",
"Linear Phase Slow Roll-off Filter",
"Minimum Phase Fast Roll-off Filter",
"Minimum Phase Slow Roll-off Filter",
"Apodizing Fast Roll-off Filter",
"Corrected Minimum Phase Fast Roll-off Filter",
"Brick Wall Filter",
};
static const unsigned int katana_codec_dsp_program_values[] = {
0,
1,
2,
3,
4,
6,
7,
};
static SOC_VALUE_ENUM_SINGLE_DECL(katana_codec_dsp_program,
KATANA_CODEC_DSP_PROGRAM, 0, 0x07,
katana_codec_dsp_program_texts,
katana_codec_dsp_program_values);
static const char * const katana_codec_deemphasis_texts[] = {
"Bypass",
"32kHz",
"44.1kHz",
"48kHz",
};
static const unsigned int katana_codec_deemphasis_values[] = {
0,
1,
2,
3,
};
static SOC_VALUE_ENUM_SINGLE_DECL(katana_codec_deemphasis,
KATANA_CODEC_DEEMPHASIS, 0, 0x03,
katana_codec_deemphasis_texts,
katana_codec_deemphasis_values);
static const SNDRV_CTL_TLVD_DECLARE_DB_MINMAX(master_tlv, -12750, 0);
static const struct snd_kcontrol_new katana_codec_controls[] = {
SOC_DOUBLE_R_TLV("Master Playback Volume", KATANA_CODEC_VOLUME_1,
KATANA_CODEC_VOLUME_2, 0, 255, 1, master_tlv),
SOC_DOUBLE("Master Playback Switch", KATANA_CODEC_MUTE, 0, 0, 1, 1),
SOC_ENUM("DSP Program Route", katana_codec_dsp_program),
SOC_ENUM("Deemphasis Route", katana_codec_deemphasis),
SOC_SINGLE("DoP Playback Switch", KATANA_CODEC_DOP, 0, 1, 1)
};
static bool katana_codec_readable_register(struct device *dev,
unsigned int reg)
{
switch (reg) {
case KATANA_CODEC_CHIP_ID_REG:
return true;
default:
return reg < 0xff;
}
}
static int katana_codec_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{
struct snd_soc_component *component = dai->component;
struct katana_codec_priv *katana_codec =
snd_soc_component_get_drvdata(component);
int fmt = 0;
int ret;
dev_dbg(component->card->dev, "hw_params %u Hz, %u channels, %u bits\n",
params_rate(params),
params_channels(params),
params_width(params));
switch (katana_codec->fmt & SND_SOC_DAIFMT_MASTER_MASK) {
case SND_SOC_DAIFMT_CBM_CFM: // master
if (params_channels(params) == 2)
fmt = KATANA_CODEC_CHAN_STEREO;
else
fmt = KATANA_CODEC_CHAN_MONO;
switch (params_width(params)) {
case 16:
fmt |= KATANA_CODEC_ALEN_16;
break;
case 24:
fmt |= KATANA_CODEC_ALEN_24;
break;
case 32:
fmt |= KATANA_CODEC_ALEN_32;
break;
default:
dev_err(component->card->dev, "Bad frame size: %d\n",
params_width(params));
return -EINVAL;
}
switch (params_rate(params)) {
case 44100:
fmt |= KATANA_CODEC_RATE_44100;
break;
case 48000:
fmt |= KATANA_CODEC_RATE_48000;
break;
case 88200:
fmt |= KATANA_CODEC_RATE_88200;
break;
case 96000:
fmt |= KATANA_CODEC_RATE_96000;
break;
case 176400:
fmt |= KATANA_CODEC_RATE_176400;
break;
case 192000:
fmt |= KATANA_CODEC_RATE_192000;
break;
case 352800:
fmt |= KATANA_CODEC_RATE_352800;
break;
case 384000:
fmt |= KATANA_CODEC_RATE_384000;
break;
default:
dev_err(component->card->dev, "Bad sample rate: %d\n",
params_rate(params));
return -EINVAL;
}
ret = regmap_write(katana_codec->regmap, KATANA_CODEC_FORMAT,
fmt);
if (ret != 0) {
dev_err(component->card->dev, "Failed to set format: %d\n", ret);
return ret;
}
break;
case SND_SOC_DAIFMT_CBS_CFS:
break;
default:
return -EINVAL;
}
return 0;
}
static int katana_codec_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{
struct snd_soc_component *component = dai->component;
struct katana_codec_priv *katana_codec =
snd_soc_component_get_drvdata(component);
katana_codec->fmt = fmt;
return 0;
}
int katana_codec_dai_mute_stream(struct snd_soc_dai *dai, int mute,
int stream)
{
struct snd_soc_component *component = dai->component;
struct katana_codec_priv *katana_codec =
snd_soc_component_get_drvdata(component);
int ret = 0;
ret = regmap_write(katana_codec->regmap, KATANA_CODEC_MUTE_STREAM,
mute);
if (ret != 0) {
dev_err(component->card->dev, "Failed to set mute: %d\n", ret);
return ret;
}
return ret;
}
static const struct snd_soc_dai_ops katana_codec_dai_ops = {
.mute_stream = katana_codec_dai_mute_stream,
.hw_params = katana_codec_hw_params,
.set_fmt = katana_codec_set_fmt,
};
static struct snd_soc_dai_driver katana_codec_dai = {
.name = "allo-katana-codec",
.playback = {
.stream_name = "Playback",
.channels_min = 2,
.channels_max = 2,
.rates = SNDRV_PCM_RATE_CONTINUOUS,
.rate_min = 44100,
.rate_max = 384000,
.formats = SNDRV_PCM_FMTBIT_S16_LE |
SNDRV_PCM_FMTBIT_S32_LE
},
.ops = &katana_codec_dai_ops,
};
static struct snd_soc_component_driver katana_codec_component_driver = {
.idle_bias_on = true,
.controls = katana_codec_controls,
.num_controls = ARRAY_SIZE(katana_codec_controls),
};
static const struct regmap_range_cfg katana_codec_range = {
.name = "Pages", .range_min = KATANA_CODEC_VIRT_BASE,
.range_max = KATANA_CODEC_MAX_REGISTER,
.selector_reg = KATANA_CODEC_PAGE,
.selector_mask = 0xff,
.window_start = 0, .window_len = 0x100,
};
const struct regmap_config katana_codec_regmap = {
.reg_bits = 8,
.val_bits = 8,
.ranges = &katana_codec_range,
.num_ranges = 1,
.max_register = KATANA_CODEC_MAX_REGISTER,
.readable_reg = katana_codec_readable_register,
.reg_defaults = katana_codec_reg_defaults,
.num_reg_defaults = ARRAY_SIZE(katana_codec_reg_defaults),
.cache_type = REGCACHE_RBTREE,
};
static int allo_katana_component_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
struct regmap *regmap;
struct regmap_config config = katana_codec_regmap;
struct device *dev = &i2c->dev;
struct katana_codec_priv *katana_codec;
unsigned int chip_id = 0;
int ret;
regmap = devm_regmap_init_i2c(i2c, &config);
if (IS_ERR(regmap))
return PTR_ERR(regmap);
katana_codec = devm_kzalloc(dev, sizeof(struct katana_codec_priv),
GFP_KERNEL);
if (!katana_codec)
return -ENOMEM;
dev_set_drvdata(dev, katana_codec);
katana_codec->regmap = regmap;
ret = regmap_read(regmap, KATANA_CODEC_CHIP_ID_REG, &chip_id);
if ((ret != 0) || (chip_id != KATANA_CODEC_CHIP_ID)) {
dev_err(dev, "Failed to read Chip or wrong Chip id: %d\n", ret);
return ret;
}
regmap_update_bits(regmap, KATANA_CODEC_RESET, 0x01, 0x01);
msleep(10);
ret = snd_soc_register_component(dev, &katana_codec_component_driver,
&katana_codec_dai, 1);
if (ret != 0) {
dev_err(dev, "failed to register codec: %d\n", ret);
return ret;
}
return 0;
}
static int allo_katana_component_remove(struct i2c_client *i2c)
{
snd_soc_unregister_component(&i2c->dev);
return 0;
}
static const struct i2c_device_id allo_katana_component_id[] = {
{ "allo-katana-codec", },
{ }
};
MODULE_DEVICE_TABLE(i2c, allo_katana_component_id);
static const struct of_device_id allo_katana_codec_of_match[] = {
{ .compatible = "allo,allo-katana-codec", },
{ }
};
MODULE_DEVICE_TABLE(of, allo_katana_codec_of_match);
static struct i2c_driver allo_katana_component_driver = {
.probe = allo_katana_component_probe,
.remove = allo_katana_component_remove,
.id_table = allo_katana_component_id,
.driver = {
.name = "allo-katana-codec",
.of_match_table = allo_katana_codec_of_match,
},
};
module_i2c_driver(allo_katana_component_driver);
MODULE_DESCRIPTION("ASoC Allo Katana Codec Driver");
MODULE_AUTHOR("Jaikumar <jaikumar@cem-solutions.net>");
MODULE_LICENSE("GPL v2");
此差异已折叠。
/*
* ALSA ASoC Machine Driver for Allo Piano DAC
*
* Author: Baswaraj K <jaikumar@cem-solutions.net>
* Copyright 2016
* based on code by Daniel Matuschek <info@crazy-audio.com>
* based on code by Florian Meier <florian.meier@koalo.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*/
#include <linux/module.h>
#include <linux/platform_device.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
static bool digital_gain_0db_limit = true;
static int snd_allo_piano_dac_init(struct snd_soc_pcm_runtime *rtd)
{
if (digital_gain_0db_limit) {
int ret;
struct snd_soc_card *card = rtd->card;
ret = snd_soc_limit_volume(card, "Digital Playback Volume",
207);
if (ret < 0)
dev_warn(card->dev, "Failed to set volume limit: %d\n",
ret);
}
return 0;
}
SND_SOC_DAILINK_DEFS(allo_piano_dai,
DAILINK_COMP_ARRAY(COMP_CPU("bcm2708-i2s.0")),
DAILINK_COMP_ARRAY(COMP_CODEC("pcm512x.1-004c", "pcm512x-hifi")),
DAILINK_COMP_ARRAY(COMP_PLATFORM("bcm2708-i2s.0")));
static struct snd_soc_dai_link snd_allo_piano_dac_dai[] = {
{
.name = "Piano DAC",
.stream_name = "Piano DAC HiFi",
.dai_fmt = SND_SOC_DAIFMT_I2S |
SND_SOC_DAIFMT_NB_NF |
SND_SOC_DAIFMT_CBS_CFS,
.init = snd_allo_piano_dac_init,
SND_SOC_DAILINK_REG(allo_piano_dai),
},
};
/* audio machine driver */
static struct snd_soc_card snd_allo_piano_dac = {
.name = "PianoDAC",
.owner = THIS_MODULE,
.dai_link = snd_allo_piano_dac_dai,
.num_links = ARRAY_SIZE(snd_allo_piano_dac_dai),
};
static int snd_allo_piano_dac_probe(struct platform_device *pdev)
{
int ret = 0;
snd_allo_piano_dac.dev = &pdev->dev;
if (pdev->dev.of_node) {
struct device_node *i2s_node;
struct snd_soc_dai_link *dai;
dai = &snd_allo_piano_dac_dai[0];
i2s_node = of_parse_phandle(pdev->dev.of_node,
"i2s-controller", 0);
if (i2s_node) {
dai->cpus->dai_name = NULL;
dai->cpus->of_node = i2s_node;
dai->platforms->name = NULL;
dai->platforms->of_node = i2s_node;
}
digital_gain_0db_limit = !of_property_read_bool(
pdev->dev.of_node, "allo,24db_digital_gain");
}
ret = devm_snd_soc_register_card(&pdev->dev, &snd_allo_piano_dac);
if (ret && ret != -EPROBE_DEFER)
dev_err(&pdev->dev,
"snd_soc_register_card() failed: %d\n", ret);
return ret;
}
static const struct of_device_id snd_allo_piano_dac_of_match[] = {
{ .compatible = "allo,piano-dac", },
{ /* sentinel */ },
};
MODULE_DEVICE_TABLE(of, snd_allo_piano_dac_of_match);
static struct platform_driver snd_allo_piano_dac_driver = {
.driver = {
.name = "snd-allo-piano-dac",
.owner = THIS_MODULE,
.of_match_table = snd_allo_piano_dac_of_match,
},
.probe = snd_allo_piano_dac_probe,
};
module_platform_driver(snd_allo_piano_dac_driver);
MODULE_AUTHOR("Baswaraj K <jaikumar@cem-solutions.net>");
MODULE_DESCRIPTION("ALSA ASoC Machine Driver for Allo Piano DAC");
MODULE_LICENSE("GPL v2");
/*
* ASoC Driver for AudioInjector.net isolated soundcard
*
* Created on: 20-February-2020
* Author: flatmax@flatmax.org
* based on audioinjector-octo-soundcard.c
*
* Copyright (C) 2020 Flatmax Pty. Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*/
#include <linux/module.h>
#include <linux/types.h>
#include <linux/gpio/consumer.h>
#include <sound/core.h>
#include <sound/soc.h>
#include <sound/pcm_params.h>
#include <sound/control.h>
static struct gpio_desc *mute_gpio;
static const unsigned int audioinjector_isolated_rates[] = {
192000, 96000, 48000, 32000, 24000, 16000, 8000
};
static struct snd_pcm_hw_constraint_list audioinjector_isolated_constraints = {
.list = audioinjector_isolated_rates,
.count = ARRAY_SIZE(audioinjector_isolated_rates),
};
static int audioinjector_isolated_dai_init(struct snd_soc_pcm_runtime *rtd)
{
int ret=snd_soc_dai_set_sysclk(asoc_rtd_to_codec(rtd, 0), 0, 24576000, 0);
if (ret)
return ret;
return snd_soc_dai_set_bclk_ratio(asoc_rtd_to_cpu(rtd, 0), 64);
}
static int audioinjector_isolated_startup(struct snd_pcm_substream *substream)
{
snd_pcm_hw_constraint_list(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_RATE, &audioinjector_isolated_constraints);
return 0;
}
static int audioinjector_isolated_trigger(struct snd_pcm_substream *substream,
int cmd){
switch (cmd) {
case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_SUSPEND:
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
gpiod_set_value(mute_gpio, 0);
break;
case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
gpiod_set_value(mute_gpio, 1);
break;
default:
return -EINVAL;
}
return 0;
}
static struct snd_soc_ops audioinjector_isolated_ops = {
.startup = audioinjector_isolated_startup,
.trigger = audioinjector_isolated_trigger,
};
SND_SOC_DAILINK_DEFS(audioinjector_isolated,
DAILINK_COMP_ARRAY(COMP_CPU("bcm2708-i2s.0")),
DAILINK_COMP_ARRAY(COMP_CODEC("cs4271.1-0010", "cs4271-hifi")),
DAILINK_COMP_ARRAY(COMP_PLATFORM("bcm2708-i2s.0")));
static struct snd_soc_dai_link audioinjector_isolated_dai[] = {
{
.name = "AudioInjector ISO",
.stream_name = "AI-HIFI",
.ops = &audioinjector_isolated_ops,
.init = audioinjector_isolated_dai_init,
.symmetric_rates = 1,
.symmetric_channels = 1,
.dai_fmt = SND_SOC_DAIFMT_CBM_CFM|SND_SOC_DAIFMT_I2S|SND_SOC_DAIFMT_NB_NF,
SND_SOC_DAILINK_REG(audioinjector_isolated),
}
};
static const struct snd_soc_dapm_widget audioinjector_isolated_widgets[] = {
SND_SOC_DAPM_OUTPUT("OUTPUTS"),
SND_SOC_DAPM_INPUT("INPUTS"),
};
static const struct snd_soc_dapm_route audioinjector_isolated_route[] = {
/* Balanced outputs */
{"OUTPUTS", NULL, "AOUTA+"},
{"OUTPUTS", NULL, "AOUTA-"},
{"OUTPUTS", NULL, "AOUTB+"},
{"OUTPUTS", NULL, "AOUTB-"},
/* Balanced inputs */
{"AINA", NULL, "INPUTS"},
{"AINB", NULL, "INPUTS"},
};
static struct snd_soc_card snd_soc_audioinjector_isolated = {
.name = "audioinjector-isolated-soundcard",
.dai_link = audioinjector_isolated_dai,
.num_links = ARRAY_SIZE(audioinjector_isolated_dai),
.dapm_widgets = audioinjector_isolated_widgets,
.num_dapm_widgets = ARRAY_SIZE(audioinjector_isolated_widgets),
.dapm_routes = audioinjector_isolated_route,
.num_dapm_routes = ARRAY_SIZE(audioinjector_isolated_route),
};
static int audioinjector_isolated_probe(struct platform_device *pdev)
{
struct snd_soc_card *card = &snd_soc_audioinjector_isolated;
int ret;
card->dev = &pdev->dev;
if (pdev->dev.of_node) {
struct snd_soc_dai_link *dai = &audioinjector_isolated_dai[0];
struct device_node *i2s_node =
of_parse_phandle(pdev->dev.of_node, "i2s-controller", 0);
if (i2s_node) {
dai->cpus->dai_name = NULL;
dai->cpus->of_node = i2s_node;
dai->platforms->name = NULL;
dai->platforms->of_node = i2s_node;
} else {
dev_err(&pdev->dev,
"i2s-controller missing or invalid in DT\n");
return -EINVAL;
}
mute_gpio = devm_gpiod_get_optional(&pdev->dev, "mute", GPIOD_OUT_LOW);
if (IS_ERR(mute_gpio)){
dev_err(&pdev->dev, "mute gpio not found in dt overlay\n");
return PTR_ERR(mute_gpio);
}
}
ret = devm_snd_soc_register_card(&pdev->dev, card);
if (ret && ret != -EPROBE_DEFER)
dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret);
return ret;
}
static const struct of_device_id audioinjector_isolated_of_match[] = {
{ .compatible = "ai,audioinjector-isolated-soundcard", },
{},
};
MODULE_DEVICE_TABLE(of, audioinjector_isolated_of_match);
static struct platform_driver audioinjector_isolated_driver = {
.driver = {
.name = "audioinjector-isolated",
.owner = THIS_MODULE,
.of_match_table = audioinjector_isolated_of_match,
},
.probe = audioinjector_isolated_probe,
};
module_platform_driver(audioinjector_isolated_driver);
MODULE_AUTHOR("Matt Flax <flatmax@flatmax.org>");
MODULE_DESCRIPTION("AudioInjector.net isolated Soundcard");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:audioinjector-isolated-soundcard");
/*
* ASoC Driver for AudioInjector Pi octo channel soundcard (hat)
*
* Created on: 27-October-2016
* Author: flatmax@flatmax.org
* based on audioinjector-pi-soundcard.c
*
* Copyright (C) 2016 Flatmax Pty. Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*/
#include <linux/module.h>
#include <linux/types.h>
#include <linux/gpio/consumer.h>
#include <sound/core.h>
#include <sound/soc.h>
#include <sound/pcm_params.h>
#include <sound/control.h>
static struct gpio_descs *mult_gpios;
static struct gpio_desc *codec_rst_gpio;
static unsigned int audioinjector_octo_rate;
static bool non_stop_clocks;
static const unsigned int audioinjector_octo_rates[] = {
96000, 48000, 32000, 24000, 16000, 8000, 88200, 44100, 29400, 22050, 14700,
};
static struct snd_pcm_hw_constraint_list audioinjector_octo_constraints = {
.list = audioinjector_octo_rates,
.count = ARRAY_SIZE(audioinjector_octo_rates),
};
static int audioinjector_octo_dai_init(struct snd_soc_pcm_runtime *rtd)
{
return snd_soc_dai_set_bclk_ratio(asoc_rtd_to_cpu(rtd, 0), 64);
}
static int audioinjector_octo_startup(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
asoc_rtd_to_cpu(rtd, 0)->driver->playback.channels_min = 8;
asoc_rtd_to_cpu(rtd, 0)->driver->playback.channels_max = 8;
asoc_rtd_to_cpu(rtd, 0)->driver->capture.channels_min = 8;
asoc_rtd_to_cpu(rtd, 0)->driver->capture.channels_max = 8;
asoc_rtd_to_codec(rtd, 0)->driver->capture.channels_max = 8;
snd_pcm_hw_constraint_list(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_RATE,
&audioinjector_octo_constraints);
return 0;
}
static void audioinjector_octo_shutdown(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
asoc_rtd_to_cpu(rtd, 0)->driver->playback.channels_min = 2;
asoc_rtd_to_cpu(rtd, 0)->driver->playback.channels_max = 2;
asoc_rtd_to_cpu(rtd, 0)->driver->capture.channels_min = 2;
asoc_rtd_to_cpu(rtd, 0)->driver->capture.channels_max = 2;
asoc_rtd_to_codec(rtd, 0)->driver->capture.channels_max = 6;
}
static int audioinjector_octo_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
// set codec DAI configuration
int ret = snd_soc_dai_set_fmt(asoc_rtd_to_codec(rtd, 0),
SND_SOC_DAIFMT_CBS_CFS|SND_SOC_DAIFMT_DSP_A|
SND_SOC_DAIFMT_NB_NF);
if (ret < 0)
return ret;
// set cpu DAI configuration
ret = snd_soc_dai_set_fmt(asoc_rtd_to_cpu(rtd, 0),
SND_SOC_DAIFMT_CBM_CFM|SND_SOC_DAIFMT_I2S|
SND_SOC_DAIFMT_NB_NF);
if (ret < 0)
return ret;
audioinjector_octo_rate = params_rate(params);
// Set the correct sysclock for the codec
switch (audioinjector_octo_rate) {
case 96000:
case 48000:
return snd_soc_dai_set_sysclk(asoc_rtd_to_codec(rtd, 0), 0, 49152000,
0);
break;
case 24000:
return snd_soc_dai_set_sysclk(asoc_rtd_to_codec(rtd, 0), 0, 49152000/2,
0);
break;
case 32000:
case 16000:
return snd_soc_dai_set_sysclk(asoc_rtd_to_codec(rtd, 0), 0, 49152000/3,
0);
break;
case 8000:
return snd_soc_dai_set_sysclk(asoc_rtd_to_codec(rtd, 0), 0, 49152000/6,
0);
break;
case 88200:
case 44100:
return snd_soc_dai_set_sysclk(asoc_rtd_to_codec(rtd, 0), 0, 45185400,
0);
break;
case 22050:
return snd_soc_dai_set_sysclk(asoc_rtd_to_codec(rtd, 0), 0, 45185400/2,
0);
break;
case 29400:
case 14700:
return snd_soc_dai_set_sysclk(asoc_rtd_to_codec(rtd, 0), 0, 45185400/3,
0);
break;
default:
return -EINVAL;
}
}
static int audioinjector_octo_trigger(struct snd_pcm_substream *substream,
int cmd){
DECLARE_BITMAP(mult, 4);
memset(mult, 0, sizeof(mult));
switch (cmd) {
case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_SUSPEND:
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
if (!non_stop_clocks)
break;
/* fall through */
case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
switch (audioinjector_octo_rate) {
case 96000:
__assign_bit(3, mult, 1);
/* fall through */
case 88200:
__assign_bit(1, mult, 1);
__assign_bit(2, mult, 1);
break;
case 48000:
__assign_bit(3, mult, 1);
/* fall through */
case 44100:
__assign_bit(2, mult, 1);
break;
case 32000:
__assign_bit(3, mult, 1);
/* fall through */
case 29400:
__assign_bit(0, mult, 1);
__assign_bit(1, mult, 1);
break;
case 24000:
__assign_bit(3, mult, 1);
/* fall through */
case 22050:
__assign_bit(1, mult, 1);
break;
case 16000:
__assign_bit(3, mult, 1);
/* fall through */
case 14700:
__assign_bit(0, mult, 1);
break;
case 8000:
__assign_bit(3, mult, 1);
break;
default:
return -EINVAL;
}
break;
default:
return -EINVAL;
}
gpiod_set_array_value_cansleep(mult_gpios->ndescs, mult_gpios->desc,
NULL, mult);
return 0;
}
static struct snd_soc_ops audioinjector_octo_ops = {
.startup = audioinjector_octo_startup,
.shutdown = audioinjector_octo_shutdown,
.hw_params = audioinjector_octo_hw_params,
.trigger = audioinjector_octo_trigger,
};
SND_SOC_DAILINK_DEFS(audioinjector_octo,
DAILINK_COMP_ARRAY(COMP_EMPTY()),
DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "cs42448")),
DAILINK_COMP_ARRAY(COMP_EMPTY()));
static struct snd_soc_dai_link audioinjector_octo_dai[] = {
{
.name = "AudioInjector Octo",
.stream_name = "AudioInject-HIFI",
.ops = &audioinjector_octo_ops,
.init = audioinjector_octo_dai_init,
.symmetric_rates = 1,
.symmetric_channels = 1,
SND_SOC_DAILINK_REG(audioinjector_octo),
},
};
static const struct snd_soc_dapm_widget audioinjector_octo_widgets[] = {
SND_SOC_DAPM_OUTPUT("OUTPUTS0"),
SND_SOC_DAPM_OUTPUT("OUTPUTS1"),
SND_SOC_DAPM_OUTPUT("OUTPUTS2"),
SND_SOC_DAPM_OUTPUT("OUTPUTS3"),
SND_SOC_DAPM_INPUT("INPUTS0"),
SND_SOC_DAPM_INPUT("INPUTS1"),
SND_SOC_DAPM_INPUT("INPUTS2"),
};
static const struct snd_soc_dapm_route audioinjector_octo_route[] = {
/* Balanced outputs */
{"OUTPUTS0", NULL, "AOUT1L"},
{"OUTPUTS0", NULL, "AOUT1R"},
{"OUTPUTS1", NULL, "AOUT2L"},
{"OUTPUTS1", NULL, "AOUT2R"},
{"OUTPUTS2", NULL, "AOUT3L"},
{"OUTPUTS2", NULL, "AOUT3R"},
{"OUTPUTS3", NULL, "AOUT4L"},
{"OUTPUTS3", NULL, "AOUT4R"},
/* Balanced inputs */
{"AIN1L", NULL, "INPUTS0"},
{"AIN1R", NULL, "INPUTS0"},
{"AIN2L", NULL, "INPUTS1"},
{"AIN2R", NULL, "INPUTS1"},
{"AIN3L", NULL, "INPUTS2"},
{"AIN3R", NULL, "INPUTS2"},
};
static struct snd_soc_card snd_soc_audioinjector_octo = {
.name = "audioinjector-octo-soundcard",
.dai_link = audioinjector_octo_dai,
.num_links = ARRAY_SIZE(audioinjector_octo_dai),
.dapm_widgets = audioinjector_octo_widgets,
.num_dapm_widgets = ARRAY_SIZE(audioinjector_octo_widgets),
.dapm_routes = audioinjector_octo_route,
.num_dapm_routes = ARRAY_SIZE(audioinjector_octo_route),
};
static int audioinjector_octo_probe(struct platform_device *pdev)
{
struct snd_soc_card *card = &snd_soc_audioinjector_octo;
int ret;
card->dev = &pdev->dev;
if (pdev->dev.of_node) {
struct snd_soc_dai_link *dai = &audioinjector_octo_dai[0];
struct device_node *i2s_node =
of_parse_phandle(pdev->dev.of_node,
"i2s-controller", 0);
struct device_node *codec_node =
of_parse_phandle(pdev->dev.of_node,
"codec", 0);
mult_gpios = devm_gpiod_get_array_optional(&pdev->dev, "mult",
GPIOD_OUT_LOW);
if (IS_ERR(mult_gpios))
return PTR_ERR(mult_gpios);
codec_rst_gpio = devm_gpiod_get_optional(&pdev->dev, "reset",
GPIOD_OUT_LOW);
if (IS_ERR(codec_rst_gpio))
return PTR_ERR(codec_rst_gpio);
non_stop_clocks = of_property_read_bool(pdev->dev.of_node, "non-stop-clocks");
if (codec_rst_gpio)
gpiod_set_value(codec_rst_gpio, 1);
msleep(500);
if (codec_rst_gpio)
gpiod_set_value(codec_rst_gpio, 0);
msleep(500);
if (codec_rst_gpio)
gpiod_set_value(codec_rst_gpio, 1);
msleep(500);
if (i2s_node && codec_node) {
dai->cpus->dai_name = NULL;
dai->cpus->of_node = i2s_node;
dai->platforms->name = NULL;
dai->platforms->of_node = i2s_node;
dai->codecs->name = NULL;
dai->codecs->of_node = codec_node;
} else
if (!i2s_node) {
dev_err(&pdev->dev,
"i2s-controller missing or invalid in DT\n");
return -EINVAL;
} else {
dev_err(&pdev->dev,
"Property 'codec' missing or invalid\n");
return -EINVAL;
}
}
ret = devm_snd_soc_register_card(&pdev->dev, card);
if (ret != 0)
dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret);
return ret;
}
static const struct of_device_id audioinjector_octo_of_match[] = {
{ .compatible = "ai,audioinjector-octo-soundcard", },
{},
};
MODULE_DEVICE_TABLE(of, audioinjector_octo_of_match);
static struct platform_driver audioinjector_octo_driver = {
.driver = {
.name = "audioinjector-octo",
.owner = THIS_MODULE,
.of_match_table = audioinjector_octo_of_match,
},
.probe = audioinjector_octo_probe,
};
module_platform_driver(audioinjector_octo_driver);
MODULE_AUTHOR("Matt Flax <flatmax@flatmax.org>");
MODULE_DESCRIPTION("AudioInjector.net octo Soundcard");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:audioinjector-octo-soundcard");
/*
* ASoC Driver for AudioInjector Pi add on soundcard
*
* Created on: 13-May-2016
* Author: flatmax@flatmax.org
* based on code by Cliff Cai <Cliff.Cai@analog.com> for the ssm2602 machine blackfin.
* with help from Lars-Peter Clausen for simplifying the original code to use the dai_fmt field.
* i2s_node code taken from the other sound/soc/bcm machine drivers.
*
* Copyright (C) 2016 Flatmax Pty. Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*/
#include <linux/module.h>
#include <linux/types.h>
#include <sound/core.h>
#include <sound/soc.h>
#include <sound/pcm_params.h>
#include <sound/control.h>
#include "../codecs/wm8731.h"
static const unsigned int bcm2835_rates_12000000[] = {
8000, 16000, 32000, 44100, 48000, 96000, 88200,
};
static struct snd_pcm_hw_constraint_list bcm2835_constraints_12000000 = {
.list = bcm2835_rates_12000000,
.count = ARRAY_SIZE(bcm2835_rates_12000000),
};
static int snd_audioinjector_pi_soundcard_startup(struct snd_pcm_substream *substream)
{
/* Setup constraints, because there is a 12 MHz XTAL on the board */
snd_pcm_hw_constraint_list(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_RATE,
&bcm2835_constraints_12000000);
return 0;
}
static int snd_audioinjector_pi_soundcard_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
switch (params_rate(params)){
case 8000:
return snd_soc_dai_set_bclk_ratio(cpu_dai, 1);
case 16000:
return snd_soc_dai_set_bclk_ratio(cpu_dai, 750);
case 32000:
return snd_soc_dai_set_bclk_ratio(cpu_dai, 375);
case 44100:
return snd_soc_dai_set_bclk_ratio(cpu_dai, 272);
case 48000:
return snd_soc_dai_set_bclk_ratio(cpu_dai, 250);
case 88200:
return snd_soc_dai_set_bclk_ratio(cpu_dai, 136);
case 96000:
return snd_soc_dai_set_bclk_ratio(cpu_dai, 125);
default:
return snd_soc_dai_set_bclk_ratio(cpu_dai, 125);
}
}
/* machine stream operations */
static struct snd_soc_ops snd_audioinjector_pi_soundcard_ops = {
.startup = snd_audioinjector_pi_soundcard_startup,
.hw_params = snd_audioinjector_pi_soundcard_hw_params,
};
static int audioinjector_pi_soundcard_dai_init(struct snd_soc_pcm_runtime *rtd)
{
return snd_soc_dai_set_sysclk(asoc_rtd_to_codec(rtd, 0), WM8731_SYSCLK_XTAL, 12000000, SND_SOC_CLOCK_IN);
}
SND_SOC_DAILINK_DEFS(audioinjector_pi,
DAILINK_COMP_ARRAY(COMP_CPU("bcm2708-i2s.0")),
DAILINK_COMP_ARRAY(COMP_CODEC("wm8731.1-001a", "wm8731-hifi")),
DAILINK_COMP_ARRAY(COMP_PLATFORM("bcm2835-i2s.0")));
static struct snd_soc_dai_link audioinjector_pi_soundcard_dai[] = {
{
.name = "AudioInjector audio",
.stream_name = "AudioInjector audio",
.ops = &snd_audioinjector_pi_soundcard_ops,
.init = audioinjector_pi_soundcard_dai_init,
.dai_fmt = SND_SOC_DAIFMT_CBM_CFM|SND_SOC_DAIFMT_I2S|SND_SOC_DAIFMT_NB_NF,
SND_SOC_DAILINK_REG(audioinjector_pi),
},
};
static const struct snd_soc_dapm_widget wm8731_dapm_widgets[] = {
SND_SOC_DAPM_HP("Headphone Jack", NULL),
SND_SOC_DAPM_SPK("Ext Spk", NULL),
SND_SOC_DAPM_LINE("Line In Jacks", NULL),
SND_SOC_DAPM_MIC("Microphone", NULL),
};
static const struct snd_soc_dapm_route audioinjector_audio_map[] = {
/* headphone connected to LHPOUT, RHPOUT */
{"Headphone Jack", NULL, "LHPOUT"},
{"Headphone Jack", NULL, "RHPOUT"},
/* speaker connected to LOUT, ROUT */
{"Ext Spk", NULL, "ROUT"},
{"Ext Spk", NULL, "LOUT"},
/* line inputs */
{"Line In Jacks", NULL, "Line Input"},
/* mic is connected to Mic Jack, with WM8731 Mic Bias */
{"Microphone", NULL, "Mic Bias"},
};
static struct snd_soc_card snd_soc_audioinjector = {
.name = "audioinjector-pi-soundcard",
.dai_link = audioinjector_pi_soundcard_dai,
.num_links = ARRAY_SIZE(audioinjector_pi_soundcard_dai),
.dapm_widgets = wm8731_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(wm8731_dapm_widgets),
.dapm_routes = audioinjector_audio_map,
.num_dapm_routes = ARRAY_SIZE(audioinjector_audio_map),
};
static int audioinjector_pi_soundcard_probe(struct platform_device *pdev)
{
struct snd_soc_card *card = &snd_soc_audioinjector;
int ret;
card->dev = &pdev->dev;
if (pdev->dev.of_node) {
struct snd_soc_dai_link *dai = &audioinjector_pi_soundcard_dai[0];
struct device_node *i2s_node = of_parse_phandle(pdev->dev.of_node,
"i2s-controller", 0);
if (i2s_node) {
dai->cpus->dai_name = NULL;
dai->cpus->of_node = i2s_node;
dai->platforms->name = NULL;
dai->platforms->of_node = i2s_node;
} else
if (!dai->cpus->of_node) {
dev_err(&pdev->dev, "Property 'i2s-controller' missing or invalid\n");
return -EINVAL;
}
}
if ((ret = devm_snd_soc_register_card(&pdev->dev, card))) {
dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret);
}
return ret;
}
static const struct of_device_id audioinjector_pi_soundcard_of_match[] = {
{ .compatible = "ai,audioinjector-pi-soundcard", },
{},
};
MODULE_DEVICE_TABLE(of, audioinjector_pi_soundcard_of_match);
static struct platform_driver audioinjector_pi_soundcard_driver = {
.driver = {
.name = "audioinjector-stereo",
.owner = THIS_MODULE,
.of_match_table = audioinjector_pi_soundcard_of_match,
},
.probe = audioinjector_pi_soundcard_probe,
};
module_platform_driver(audioinjector_pi_soundcard_driver);
MODULE_AUTHOR("Matt Flax <flatmax@flatmax.org>");
MODULE_DESCRIPTION("AudioInjector.net Pi Soundcard");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:audioinjector-pi-soundcard");
/*
* ASoC Driver for AudioSense add on soundcard
* Author:
* Bhargav A K <anur.bhargav@gmail.com>
* Copyright 2017
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*/
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/clk.h>
#include <linux/i2c.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/jack.h>
#include <sound/control.h>
#include <sound/tlv320aic32x4.h>
#include "../codecs/tlv320aic32x4.h"
#define AIC32X4_SYSCLK_XTAL 0x00
/*
* Setup Codec Sample Rates and Channels
* Supported Rates:
* 8000, 11025, 16000, 22050, 32000, 44100, 48000, 64000, 88200, 96000,
*/
static const unsigned int audiosense_pi_rate[] = {
48000,
};
static struct snd_pcm_hw_constraint_list audiosense_constraints_rates = {
.list = audiosense_pi_rate,
.count = ARRAY_SIZE(audiosense_pi_rate),
};
static const unsigned int audiosense_pi_channels[] = {
2,
};
static struct snd_pcm_hw_constraint_list audiosense_constraints_ch = {
.count = ARRAY_SIZE(audiosense_pi_channels),
.list = audiosense_pi_channels,
.mask = 0,
};
/* Setup DAPM widgets and paths */
static const struct snd_soc_dapm_widget audiosense_pi_dapm_widgets[] = {
SND_SOC_DAPM_HP("Headphone Jack", NULL),
SND_SOC_DAPM_LINE("Line Out", NULL),
SND_SOC_DAPM_LINE("Line In", NULL),
SND_SOC_DAPM_INPUT("CM_L"),
SND_SOC_DAPM_INPUT("CM_R"),
};
static const struct snd_soc_dapm_route audiosense_pi_audio_map[] = {
/* Line Inputs are connected to
* (IN1_L | IN1_R)
* (IN2_L | IN2_R)
* (IN3_L | IN3_R)
*/
{"IN1_L", NULL, "Line In"},
{"IN1_R", NULL, "Line In"},
{"IN2_L", NULL, "Line In"},
{"IN2_R", NULL, "Line In"},
{"IN3_L", NULL, "Line In"},
{"IN3_R", NULL, "Line In"},
/* Mic is connected to IN2_L and IN2_R */
{"Left ADC", NULL, "Mic Bias"},
{"Right ADC", NULL, "Mic Bias"},
/* Headphone connected to HPL, HPR */
{"Headphone Jack", NULL, "HPL"},
{"Headphone Jack", NULL, "HPR"},
/* Speakers connected to LOL and LOR */
{"Line Out", NULL, "LOL"},
{"Line Out", NULL, "LOR"},
};
static int audiosense_pi_card_init(struct snd_soc_pcm_runtime *rtd)
{
/* TODO: init of the codec specific dapm data, ignore suspend/resume */
struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
snd_soc_component_update_bits(component, AIC32X4_MICBIAS, 0x78,
AIC32X4_MICBIAS_LDOIN |
AIC32X4_MICBIAS_2075V);
snd_soc_component_update_bits(component, AIC32X4_PWRCFG, 0x08,
AIC32X4_AVDDWEAKDISABLE);
snd_soc_component_update_bits(component, AIC32X4_LDOCTL, 0x01,
AIC32X4_LDOCTLEN);
return 0;
}
static int audiosense_pi_card_hw_params(
struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
int ret = 0;
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
/* Set the codec system clock, there is a 12 MHz XTAL on the board */
ret = snd_soc_dai_set_sysclk(codec_dai, AIC32X4_SYSCLK_XTAL,
12000000, SND_SOC_CLOCK_IN);
if (ret) {
dev_err(rtd->card->dev,
"could not set codec driver clock params\n");
return ret;
}
return 0;
}
static int audiosense_pi_card_startup(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
/*
* Set codec to 48Khz Sampling, Stereo I/O and 16 bit audio
*/
runtime->hw.channels_max = 2;
snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
&audiosense_constraints_ch);
runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16);
snd_pcm_hw_constraint_list(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_RATE,
&audiosense_constraints_rates);
return 0;
}
static struct snd_soc_ops audiosense_pi_card_ops = {
.startup = audiosense_pi_card_startup,
.hw_params = audiosense_pi_card_hw_params,
};
SND_SOC_DAILINK_DEFS(audiosense_pi,
DAILINK_COMP_ARRAY(COMP_CPU("bcm2708-i2s.0")),
DAILINK_COMP_ARRAY(COMP_CODEC("tlv320aic32x4.1-0018", "tlv320aic32x4-hifi")),
DAILINK_COMP_ARRAY(COMP_PLATFORM("bcm2708-i2s.0")));
static struct snd_soc_dai_link audiosense_pi_card_dai[] = {
{
.name = "TLV320AIC3204 Audio",
.stream_name = "TLV320AIC3204 Hifi Audio",
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
SND_SOC_DAIFMT_CBM_CFM,
.ops = &audiosense_pi_card_ops,
.init = audiosense_pi_card_init,
SND_SOC_DAILINK_REG(audiosense_pi),
},
};
static struct snd_soc_card audiosense_pi_card = {
.name = "audiosense-pi",
.driver_name = "audiosense-pi",
.dai_link = audiosense_pi_card_dai,
.owner = THIS_MODULE,
.num_links = ARRAY_SIZE(audiosense_pi_card_dai),
.dapm_widgets = audiosense_pi_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(audiosense_pi_dapm_widgets),
.dapm_routes = audiosense_pi_audio_map,
.num_dapm_routes = ARRAY_SIZE(audiosense_pi_audio_map),
};
static int audiosense_pi_card_probe(struct platform_device *pdev)
{
int ret = 0;
struct snd_soc_card *card = &audiosense_pi_card;
struct snd_soc_dai_link *dai = &audiosense_pi_card_dai[0];
struct device_node *i2s_node = pdev->dev.of_node;
card->dev = &pdev->dev;
if (!dai) {
dev_err(&pdev->dev, "DAI not found. Missing or Invalid\n");
return -EINVAL;
}
i2s_node = of_parse_phandle(pdev->dev.of_node, "i2s-controller", 0);
if (!i2s_node) {
dev_err(&pdev->dev,
"Property 'i2s-controller' missing or invalid\n");
return -EINVAL;
}
dai->cpus->dai_name = NULL;
dai->cpus->of_node = i2s_node;
dai->platforms->name = NULL;
dai->platforms->of_node = i2s_node;
of_node_put(i2s_node);
ret = snd_soc_register_card(card);
if (ret && ret != -EPROBE_DEFER)
dev_err(&pdev->dev,
"snd_soc_register_card() failed: %d\n", ret);
return ret;
}
static int audiosense_pi_card_remove(struct platform_device *pdev)
{
struct snd_soc_card *card = platform_get_drvdata(pdev);
return snd_soc_unregister_card(card);
}
static const struct of_device_id audiosense_pi_card_of_match[] = {
{ .compatible = "as,audiosense-pi", },
{},
};
MODULE_DEVICE_TABLE(of, audiosense_pi_card_of_match);
static struct platform_driver audiosense_pi_card_driver = {
.driver = {
.name = "audiosense-snd-card",
.owner = THIS_MODULE,
.of_match_table = audiosense_pi_card_of_match,
},
.probe = audiosense_pi_card_probe,
.remove = audiosense_pi_card_remove,
};
module_platform_driver(audiosense_pi_card_driver);
MODULE_AUTHOR("Bhargav AK <anur.bhargav@gmail.com>");
MODULE_DESCRIPTION("ASoC Driver for TLV320AIC3204 Audio");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:audiosense-pi");
/*
* ASoC Driver for RRA DigiDAC1
* Copyright 2016
* Author: José M. Tasende <vintage@redrocksaudio.es>
* based on the HifiBerry DAC driver by Florian Meier <florian.meier@koalo.de>
* and the Wolfson card driver by Nikesh Oswal, <Nikesh.Oswal@wolfsonmicro.com>
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*/
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/i2c.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/jack.h>
#include <sound/soc-dapm.h>
#include <sound/tlv.h>
#include <linux/regulator/consumer.h>
#include "../codecs/wm8804.h"
#include "../codecs/wm8741.h"
#define WM8741_NUM_SUPPLIES 2
/* codec private data */
struct wm8741_priv {
struct wm8741_platform_data pdata;
struct regmap *regmap;
struct regulator_bulk_data supplies[WM8741_NUM_SUPPLIES];
unsigned int sysclk;
const struct snd_pcm_hw_constraint_list *sysclk_constraints;
};
static int samplerate = 44100;
/* New Alsa Controls not exposed by original wm8741 codec driver */
/* in actual driver the att. adjustment is wrong because */
/* this DAC has a coarse attenuation register with 4dB steps */
/* and a fine level register with 0.125dB steps */
/* each register has 32 steps so combining both we have 1024 steps */
/* of 0.125 dB. */
/* The original level controls from driver are removed at startup */
/* and replaced by the corrected ones. */
/* The same wm8741 driver can be used for wm8741 and wm8742 devices */
static const DECLARE_TLV_DB_SCALE(dac_tlv_fine, 0, 13, 0);
static const DECLARE_TLV_DB_SCALE(dac_tlv_coarse, -12700, 400, 1);
static const char *w8741_dither[4] = {"Off", "RPDF", "TPDF", "HPDF"};
static const char *w8741_filter[5] = {
"Type 1", "Type 2", "Type 3", "Type 4", "Type 5"};
static const char *w8741_switch[2] = {"Off", "On"};
static const struct soc_enum w8741_enum[] = {
SOC_ENUM_SINGLE(WM8741_MODE_CONTROL_2, 0, 4, w8741_dither),/* dithering type */
SOC_ENUM_SINGLE(WM8741_FILTER_CONTROL, 0, 5, w8741_filter),/* filter type */
SOC_ENUM_SINGLE(WM8741_FORMAT_CONTROL, 6, 2, w8741_switch),/* phase invert */
SOC_ENUM_SINGLE(WM8741_VOLUME_CONTROL, 0, 2, w8741_switch),/* volume ramp */
SOC_ENUM_SINGLE(WM8741_VOLUME_CONTROL, 3, 2, w8741_switch),/* soft mute */
};
static const struct snd_kcontrol_new w8741_snd_controls_stereo[] = {
SOC_DOUBLE_R_TLV("DAC Fine Playback Volume", WM8741_DACLLSB_ATTENUATION,
WM8741_DACRLSB_ATTENUATION, 0, 31, 1, dac_tlv_fine),
SOC_DOUBLE_R_TLV("Digital Playback Volume", WM8741_DACLMSB_ATTENUATION,
WM8741_DACRMSB_ATTENUATION, 0, 31, 1, dac_tlv_coarse),
SOC_ENUM("DAC Dither", w8741_enum[0]),
SOC_ENUM("DAC Digital Filter", w8741_enum[1]),
SOC_ENUM("DAC Phase Invert", w8741_enum[2]),
SOC_ENUM("DAC Volume Ramp", w8741_enum[3]),
SOC_ENUM("DAC Soft Mute", w8741_enum[4]),
};
static const struct snd_kcontrol_new w8741_snd_controls_mono_left[] = {
SOC_SINGLE_TLV("DAC Fine Playback Volume", WM8741_DACLLSB_ATTENUATION,
0, 31, 0, dac_tlv_fine),
SOC_SINGLE_TLV("Digital Playback Volume", WM8741_DACLMSB_ATTENUATION,
0, 31, 1, dac_tlv_coarse),
SOC_ENUM("DAC Dither", w8741_enum[0]),
SOC_ENUM("DAC Digital Filter", w8741_enum[1]),
SOC_ENUM("DAC Phase Invert", w8741_enum[2]),
SOC_ENUM("DAC Volume Ramp", w8741_enum[3]),
SOC_ENUM("DAC Soft Mute", w8741_enum[4]),
};
static const struct snd_kcontrol_new w8741_snd_controls_mono_right[] = {
SOC_SINGLE_TLV("DAC Fine Playback Volume", WM8741_DACRLSB_ATTENUATION,
0, 31, 0, dac_tlv_fine),
SOC_SINGLE_TLV("Digital Playback Volume", WM8741_DACRMSB_ATTENUATION,
0, 31, 1, dac_tlv_coarse),
SOC_ENUM("DAC Dither", w8741_enum[0]),
SOC_ENUM("DAC Digital Filter", w8741_enum[1]),
SOC_ENUM("DAC Phase Invert", w8741_enum[2]),
SOC_ENUM("DAC Volume Ramp", w8741_enum[3]),
SOC_ENUM("DAC Soft Mute", w8741_enum[4]),
};
static int w8741_add_controls(struct snd_soc_component *component)
{
struct wm8741_priv *wm8741 = snd_soc_component_get_drvdata(component);
switch (wm8741->pdata.diff_mode) {
case WM8741_DIFF_MODE_STEREO:
case WM8741_DIFF_MODE_STEREO_REVERSED:
snd_soc_add_component_controls(component,
w8741_snd_controls_stereo,
ARRAY_SIZE(w8741_snd_controls_stereo));
break;
case WM8741_DIFF_MODE_MONO_LEFT:
snd_soc_add_component_controls(component,
w8741_snd_controls_mono_left,
ARRAY_SIZE(w8741_snd_controls_mono_left));
break;
case WM8741_DIFF_MODE_MONO_RIGHT:
snd_soc_add_component_controls(component,
w8741_snd_controls_mono_right,
ARRAY_SIZE(w8741_snd_controls_mono_right));
break;
default:
return -EINVAL;
}
return 0;
}
static int digidac1_soundcard_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
struct snd_soc_card *card = rtd->card;
struct snd_soc_pcm_runtime *wm8741_rtd;
struct snd_soc_component *wm8741_component;
struct snd_card *sound_card = card->snd_card;
struct snd_kcontrol *kctl;
int ret;
wm8741_rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[1]);
if (!wm8741_rtd) {
dev_warn(card->dev, "digidac1_soundcard_init: couldn't get wm8741 rtd\n");
return -EFAULT;
}
wm8741_component = asoc_rtd_to_codec(wm8741_rtd, 0)->component;
ret = w8741_add_controls(wm8741_component);
if (ret < 0)
dev_warn(card->dev, "Failed to add new wm8741 controls: %d\n",
ret);
/* enable TX output */
snd_soc_component_update_bits(component, WM8804_PWRDN, 0x4, 0x0);
kctl = snd_soc_card_get_kcontrol(card,
"Playback Volume");
if (kctl) {
kctl->vd[0].access = SNDRV_CTL_ELEM_ACCESS_READWRITE;
snd_ctl_remove(sound_card, kctl);
}
kctl = snd_soc_card_get_kcontrol(card,
"Fine Playback Volume");
if (kctl) {
kctl->vd[0].access = SNDRV_CTL_ELEM_ACCESS_READWRITE;
snd_ctl_remove(sound_card, kctl);
}
return 0;
}
static int digidac1_soundcard_startup(struct snd_pcm_substream *substream)
{
/* turn on wm8804 digital output */
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
struct snd_soc_card *card = rtd->card;
struct snd_soc_pcm_runtime *wm8741_rtd;
struct snd_soc_component *wm8741_component;
snd_soc_component_update_bits(component, WM8804_PWRDN, 0x3c, 0x00);
wm8741_rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[1]);
if (!wm8741_rtd) {
dev_warn(card->dev, "digidac1_soundcard_startup: couldn't get WM8741 rtd\n");
return -EFAULT;
}
wm8741_component = asoc_rtd_to_codec(wm8741_rtd, 0)->component;
/* latch wm8741 level */
snd_soc_component_update_bits(wm8741_component, WM8741_DACLLSB_ATTENUATION,
WM8741_UPDATELL, WM8741_UPDATELL);
snd_soc_component_update_bits(wm8741_component, WM8741_DACLMSB_ATTENUATION,
WM8741_UPDATELM, WM8741_UPDATELM);
snd_soc_component_update_bits(wm8741_component, WM8741_DACRLSB_ATTENUATION,
WM8741_UPDATERL, WM8741_UPDATERL);
snd_soc_component_update_bits(wm8741_component, WM8741_DACRMSB_ATTENUATION,
WM8741_UPDATERM, WM8741_UPDATERM);
return 0;
}
static void digidac1_soundcard_shutdown(struct snd_pcm_substream *substream)
{
/* turn off wm8804 digital output */
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
snd_soc_component_update_bits(component, WM8804_PWRDN, 0x3c, 0x3c);
}
static int digidac1_soundcard_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
struct snd_soc_card *card = rtd->card;
struct snd_soc_pcm_runtime *wm8741_rtd;
struct snd_soc_component *wm8741_component;
int sysclk = 27000000;
long mclk_freq = 0;
int mclk_div = 1;
int sampling_freq = 1;
int ret;
wm8741_rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[1]);
if (!wm8741_rtd) {
dev_warn(card->dev, "digidac1_soundcard_hw_params: couldn't get WM8741 rtd\n");
return -EFAULT;
}
wm8741_component = asoc_rtd_to_codec(wm8741_rtd, 0)->component;
samplerate = params_rate(params);
if (samplerate <= 96000) {
mclk_freq = samplerate*256;
mclk_div = WM8804_MCLKDIV_256FS;
} else {
mclk_freq = samplerate*128;
mclk_div = WM8804_MCLKDIV_128FS;
}
switch (samplerate) {
case 32000:
sampling_freq = 0x03;
break;
case 44100:
sampling_freq = 0x00;
break;
case 48000:
sampling_freq = 0x02;
break;
case 88200:
sampling_freq = 0x08;
break;
case 96000:
sampling_freq = 0x0a;
break;
case 176400:
sampling_freq = 0x0c;
break;
case 192000:
sampling_freq = 0x0e;
break;
default:
dev_err(card->dev,
"Failed to set WM8804 SYSCLK, unsupported samplerate %d\n",
samplerate);
}
snd_soc_dai_set_clkdiv(codec_dai, WM8804_MCLK_DIV, mclk_div);
snd_soc_dai_set_pll(codec_dai, 0, 0, sysclk, mclk_freq);
ret = snd_soc_dai_set_sysclk(codec_dai, WM8804_TX_CLKSRC_PLL,
sysclk, SND_SOC_CLOCK_OUT);
if (ret < 0) {
dev_err(card->dev,
"Failed to set WM8804 SYSCLK: %d\n", ret);
return ret;
}
/* Enable wm8804 TX output */
snd_soc_component_update_bits(component, WM8804_PWRDN, 0x4, 0x0);
/* wm8804 Power on */
snd_soc_component_update_bits(component, WM8804_PWRDN, 0x9, 0);
/* wm8804 set sampling frequency status bits */
snd_soc_component_update_bits(component, WM8804_SPDTX4, 0x0f, sampling_freq);
/* Now update wm8741 registers for the correct oversampling */
if (samplerate <= 48000)
snd_soc_component_update_bits(wm8741_component, WM8741_MODE_CONTROL_1,
WM8741_OSR_MASK, 0x00);
else if (samplerate <= 96000)
snd_soc_component_update_bits(wm8741_component, WM8741_MODE_CONTROL_1,
WM8741_OSR_MASK, 0x20);
else
snd_soc_component_update_bits(wm8741_component, WM8741_MODE_CONTROL_1,
WM8741_OSR_MASK, 0x40);
/* wm8741 bit size */
switch (params_width(params)) {
case 16:
snd_soc_component_update_bits(wm8741_component, WM8741_FORMAT_CONTROL,
WM8741_IWL_MASK, 0x00);
break;
case 20:
snd_soc_component_update_bits(wm8741_component, WM8741_FORMAT_CONTROL,
WM8741_IWL_MASK, 0x01);
break;
case 24:
snd_soc_component_update_bits(wm8741_component, WM8741_FORMAT_CONTROL,
WM8741_IWL_MASK, 0x02);
break;
case 32:
snd_soc_component_update_bits(wm8741_component, WM8741_FORMAT_CONTROL,
WM8741_IWL_MASK, 0x03);
break;
default:
dev_dbg(card->dev, "wm8741_hw_params: Unsupported bit size param = %d",
params_width(params));
return -EINVAL;
}
return snd_soc_dai_set_bclk_ratio(cpu_dai, 64);
}
/* machine stream operations */
static struct snd_soc_ops digidac1_soundcard_ops = {
.hw_params = digidac1_soundcard_hw_params,
.startup = digidac1_soundcard_startup,
.shutdown = digidac1_soundcard_shutdown,
};
SND_SOC_DAILINK_DEFS(digidac1,
DAILINK_COMP_ARRAY(COMP_CPU("bcm2708-i2s.0")),
DAILINK_COMP_ARRAY(COMP_CODEC("wm8804.1-003b", "wm8804-spdif")),
DAILINK_COMP_ARRAY(COMP_PLATFORM("bcm2835-i2s.0")));
SND_SOC_DAILINK_DEFS(digidac11,
DAILINK_COMP_ARRAY(COMP_CPU("wm8804-spdif")),
DAILINK_COMP_ARRAY(COMP_CODEC("wm8741.1-001a", "wm8741")),
DAILINK_COMP_ARRAY(COMP_EMPTY()));
static struct snd_soc_dai_link digidac1_soundcard_dai[] = {
{
.name = "RRA DigiDAC1",
.stream_name = "RRA DigiDAC1 HiFi",
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
SND_SOC_DAIFMT_CBM_CFM,
.ops = &digidac1_soundcard_ops,
.init = digidac1_soundcard_init,
SND_SOC_DAILINK_REG(digidac1),
},
{
.name = "RRA DigiDAC11",
.stream_name = "RRA DigiDAC11 HiFi",
.dai_fmt = SND_SOC_DAIFMT_I2S
| SND_SOC_DAIFMT_NB_NF
| SND_SOC_DAIFMT_CBS_CFS,
SND_SOC_DAILINK_REG(digidac11),
},
};
/* audio machine driver */
static struct snd_soc_card digidac1_soundcard = {
.name = "digidac1-soundcard",
.owner = THIS_MODULE,
.dai_link = digidac1_soundcard_dai,
.num_links = ARRAY_SIZE(digidac1_soundcard_dai),
};
static int digidac1_soundcard_probe(struct platform_device *pdev)
{
int ret = 0;
digidac1_soundcard.dev = &pdev->dev;
if (pdev->dev.of_node) {
struct device_node *i2s_node;
struct snd_soc_dai_link *dai = &digidac1_soundcard_dai[0];
i2s_node = of_parse_phandle(pdev->dev.of_node,
"i2s-controller", 0);
if (i2s_node) {
dai->cpus->dai_name = NULL;
dai->cpus->of_node = i2s_node;
dai->platforms->name = NULL;
dai->platforms->of_node = i2s_node;
}
}
ret = devm_snd_soc_register_card(&pdev->dev, &digidac1_soundcard);
if (ret && ret != -EPROBE_DEFER)
dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
ret);
return ret;
}
static const struct of_device_id digidac1_soundcard_of_match[] = {
{ .compatible = "rra,digidac1-soundcard", },
{},
};
MODULE_DEVICE_TABLE(of, digidac1_soundcard_of_match);
static struct platform_driver digidac1_soundcard_driver = {
.driver = {
.name = "digidac1-audio",
.owner = THIS_MODULE,
.of_match_table = digidac1_soundcard_of_match,
},
.probe = digidac1_soundcard_probe,
};
module_platform_driver(digidac1_soundcard_driver);
MODULE_AUTHOR("José M. Tasende <vintage@redrocksaudio.es>");
MODULE_DESCRIPTION("ASoC Driver for RRA DigiDAC1");
MODULE_LICENSE("GPL v2");
/*
* ASoC Driver for Dion Audio LOCO-V2 DAC-AMP
*
* Author: Miquel Blauw <info@dionaudio.nl>
* Copyright 2017
*
* Based on the software of the RPi-DAC writen by Florian Meier
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*/
#include <linux/module.h>
#include <linux/platform_device.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/jack.h>
static bool digital_gain_0db_limit = true;
static int snd_rpi_dionaudio_loco_v2_init(struct snd_soc_pcm_runtime *rtd)
{
if (digital_gain_0db_limit) {
int ret;
struct snd_soc_card *card = rtd->card;
ret = snd_soc_limit_volume(card, "Digital Playback Volume", 207);
if (ret < 0)
dev_warn(card->dev, "Failed to set volume limit: %d\n", ret);
}
return 0;
}
SND_SOC_DAILINK_DEFS(dionaudio_loco_v2,
DAILINK_COMP_ARRAY(COMP_CPU("bcm2708-i2s.0")),
DAILINK_COMP_ARRAY(COMP_CODEC("pcm512x.1-004d", "pcm512x-hifi")),
DAILINK_COMP_ARRAY(COMP_PLATFORM("bcm2708-i2s.0")));
static struct snd_soc_dai_link snd_rpi_dionaudio_loco_v2_dai[] = {
{
.name = "DionAudio LOCO-V2",
.stream_name = "DionAudio LOCO-V2 DAC-AMP",
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
SND_SOC_DAIFMT_CBS_CFS,
.init = snd_rpi_dionaudio_loco_v2_init,
SND_SOC_DAILINK_REG(dionaudio_loco_v2),
},};
/* audio machine driver */
static struct snd_soc_card snd_rpi_dionaudio_loco_v2 = {
.name = "Dion Audio LOCO-V2",
.dai_link = snd_rpi_dionaudio_loco_v2_dai,
.num_links = ARRAY_SIZE(snd_rpi_dionaudio_loco_v2_dai),
};
static int snd_rpi_dionaudio_loco_v2_probe(struct platform_device *pdev)
{
int ret = 0;
snd_rpi_dionaudio_loco_v2.dev = &pdev->dev;
if (pdev->dev.of_node) {
struct device_node *i2s_node;
struct snd_soc_dai_link *dai =
&snd_rpi_dionaudio_loco_v2_dai[0];
i2s_node = of_parse_phandle(pdev->dev.of_node,
"i2s-controller", 0);
if (i2s_node) {
dai->cpus->dai_name = NULL;
dai->cpus->of_node = i2s_node;
dai->platforms->name = NULL;
dai->platforms->of_node = i2s_node;
}
digital_gain_0db_limit = !of_property_read_bool(
pdev->dev.of_node, "dionaudio,24db_digital_gain");
}
ret = devm_snd_soc_register_card(&pdev->dev, &snd_rpi_dionaudio_loco_v2);
if (ret)
dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
ret);
return ret;
}
static const struct of_device_id dionaudio_of_match[] = {
{ .compatible = "dionaudio,dionaudio-loco-v2", },
{},
};
MODULE_DEVICE_TABLE(of, dionaudio_of_match);
static struct platform_driver snd_rpi_dionaudio_loco_v2_driver = {
.driver = {
.name = "snd-rpi-dionaudio-loco-v2",
.owner = THIS_MODULE,
.of_match_table = dionaudio_of_match,
},
.probe = snd_rpi_dionaudio_loco_v2_probe,
};
module_platform_driver(snd_rpi_dionaudio_loco_v2_driver);
MODULE_AUTHOR("Miquel Blauw <info@dionaudio.nl>");
MODULE_DESCRIPTION("ASoC Driver for DionAudio LOCO-V2");
MODULE_LICENSE("GPL v2");
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -45,11 +45,18 @@ static struct i2c_device_id cs42xx8_i2c_id[] = {
};
MODULE_DEVICE_TABLE(i2c, cs42xx8_i2c_id);
const struct of_device_id cs42xx8_i2c_of_match[] = {
{ .compatible = "cirrus,cs42448", .data = &cs42448_data, },
{ .compatible = "cirrus,cs42888", .data = &cs42888_data, },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, cs42xx8_i2c_of_match);
static struct i2c_driver cs42xx8_i2c_driver = {
.driver = {
.name = "cs42xx8",
.pm = &cs42xx8_pm,
.of_match_table = cs42xx8_of_match,
.of_match_table = cs42xx8_i2c_of_match,
},
.probe = cs42xx8_i2c_probe,
.remove = cs42xx8_i2c_remove,
......
......@@ -517,8 +517,10 @@ const struct of_device_id cs42xx8_of_match[] = {
{ .compatible = "cirrus,cs42888", .data = &cs42888_data, },
{ /* sentinel */ }
};
#if !IS_ENABLED(CONFIG_SND_SOC_CS42XX8_I2C)
MODULE_DEVICE_TABLE(of, cs42xx8_of_match);
EXPORT_SYMBOL_GPL(cs42xx8_of_match);
#endif
int cs42xx8_probe(struct device *dev, struct regmap *regmap)
{
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -534,7 +534,7 @@ static unsigned long pcm512x_ncp_target(struct pcm512x_priv *pcm512x,
static const u32 pcm512x_dai_rates[] = {
8000, 11025, 16000, 22050, 32000, 44100, 48000, 64000,
88200, 96000, 176400, 192000, 384000,
88200, 96000, 176400, 192000, 352800, 384000,
};
static const struct snd_pcm_hw_constraint_list constraints_slave = {
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册