I run JellyBean 4.3 on i.MX6-based device ...
While my kernel supports S/PDIF all right (tested with Debian user space), I cannot figure out how to route sound to spdif in Android user space.
Any advice will be highly appreciated !
-- Andrey
Solved! Go to Solution.
For the sake of all the lost souls out there, the solution that I have eventually figured out ...
[1]
Look at hardware/imx/alsa/config_spdif.h
static struct audio_card spdif_card = {
.name = "imx-spdif",
.driver_name = "imx-spdif",
- .supported_out_devices = 0,
+ .supported_out_devices = AUDIO_DEVICE_OUT_AUX_DIGITAL,
.supported_in_devices = AUDIO_DEVICE_IN_AUX_DIGITAL,
S/PDIF must be registered as output device.
However there is one problem - AUDIO_DEVICE_OUT_AUX_DIGITAL is actually HDMI audio output.
Q: So which audio sink will be selected automatically ?
A: The one that was registered first by the kernel, i.e. the first kernel module that was loaded at boot time. Refer to tinyalsa_hal.c:get_card_for_device() if you don't believe.
[2]
Here we suggest a solution to the HDMI/SPDIF competition, so that HDMI and S/PDIF could co-exist side by side.
Let's assign to spdif_card.supported_out_devices a sink that is not used in our device - in my device it would be AUDIO_DEVICE_OUT_WIRED_HEADPHONE, as there is no headphones.
So make sure no other audio sink in use registers itself as AUDIO_DEVICE_OUT_WIRED_HEADPHONE ...
hardware/imx/alsa/config_wm8731.h
.supported_out_devices = (
AUDIO_DEVICE_OUT_EARPIECE |
AUDIO_DEVICE_OUT_SPEAKER |
AUDIO_DEVICE_OUT_WIRED_HEADSET |
- AUDIO_DEVICE_OUT_WIRED_HEADPHONE |
hardware/imx/alsa/config_spdif.h
static struct audio_card spdif_card = {
.name = "imx-spdif",
.driver_name = "imx-spdif",
- .supported_out_devices = AUDIO_DEVICE_OUT_AUX_DIGITAL,
+ .supported_out_devices = AUDIO_DEVICE_OUT_WIRED_HEADPHONE,
.supported_in_devices = AUDIO_DEVICE_IN_AUX_DIGITAL,
Now select "Wired headphones" to play S/PDIF.
[3]
Q: How to select "Wired headphones" as Android-wide audio sink ?
A: There are applications in Google Play Store. One that I have tested with is AudioAbout.
For the sake of all the lost souls out there, the solution that I have eventually figured out ...
[1]
Look at hardware/imx/alsa/config_spdif.h
static struct audio_card spdif_card = {
.name = "imx-spdif",
.driver_name = "imx-spdif",
- .supported_out_devices = 0,
+ .supported_out_devices = AUDIO_DEVICE_OUT_AUX_DIGITAL,
.supported_in_devices = AUDIO_DEVICE_IN_AUX_DIGITAL,
S/PDIF must be registered as output device.
However there is one problem - AUDIO_DEVICE_OUT_AUX_DIGITAL is actually HDMI audio output.
Q: So which audio sink will be selected automatically ?
A: The one that was registered first by the kernel, i.e. the first kernel module that was loaded at boot time. Refer to tinyalsa_hal.c:get_card_for_device() if you don't believe.
[2]
Here we suggest a solution to the HDMI/SPDIF competition, so that HDMI and S/PDIF could co-exist side by side.
Let's assign to spdif_card.supported_out_devices a sink that is not used in our device - in my device it would be AUDIO_DEVICE_OUT_WIRED_HEADPHONE, as there is no headphones.
So make sure no other audio sink in use registers itself as AUDIO_DEVICE_OUT_WIRED_HEADPHONE ...
hardware/imx/alsa/config_wm8731.h
.supported_out_devices = (
AUDIO_DEVICE_OUT_EARPIECE |
AUDIO_DEVICE_OUT_SPEAKER |
AUDIO_DEVICE_OUT_WIRED_HEADSET |
- AUDIO_DEVICE_OUT_WIRED_HEADPHONE |
hardware/imx/alsa/config_spdif.h
static struct audio_card spdif_card = {
.name = "imx-spdif",
.driver_name = "imx-spdif",
- .supported_out_devices = AUDIO_DEVICE_OUT_AUX_DIGITAL,
+ .supported_out_devices = AUDIO_DEVICE_OUT_WIRED_HEADPHONE,
.supported_in_devices = AUDIO_DEVICE_IN_AUX_DIGITAL,
Now select "Wired headphones" to play S/PDIF.
[3]
Q: How to select "Wired headphones" as Android-wide audio sink ?
A: There are applications in Google Play Store. One that I have tested with is AudioAbout.
Hi Andrey
I think suggestions from link below may be useful
set correct device & card number for your SPDIF device.
tinyplay test.wav -D 1 -d 0
to see the SPDIF device in kernel log like this.
ALSA device list:
#0: sgtl5000-audio
#1: imx-spdif
#2: imx-hdmi-soc
[Android] How to support SPDIF input feature?
Best regards
igor