Hi,
We need to enable SPDIF input feature on i.MX6 Android platform.
In the BSP 4.2.2_1.0.0, there are SPDIF related source codes in hardware/imx/alsa/config_spdif.h & hardware/imx/alsa/tinyalsa_hal.c.
I find AUDIO_DEVICE_IN_AUX_DIGITAL device is assigned for SPDIF input, but it seems not work actually when I set attached_input_devices to AUDIO_DEVICE_IN_AUX_DIGITAL in audio_policy.conf.
The logs are as below.
=====
1699:01-02 00:28:39.410 I/OMXPlayer( 2284): Audio source: 1
1700:01-02 00:28:39.410 W/audio_hw_primary( 2284): In channels 1, rate 8000, devices 0x80000020
1701:01-02 00:28:39.410 W/audio_hw_primary( 2284): get_input_buffer_size size = 96, channel_count = 1
1702:01-02 00:28:39.410 W/audio_hw_primary( 2284): get_input_buffer_size size = 96, channel_count = 1
1703:01-02 00:28:39.430 E/AudioPolicyManagerBase( 2284): getDeviceForStrategy() speaker device not found for STRATEGY_SONIFICATION
1704:01-02 00:28:39.430 E/AudioPolicyManagerBase( 2284): getDeviceForStrategy() speaker device not found for STRATEGY_SONIFICATION
1707:01-02 00:28:39.440 I/OMXPlayer( 2284): Set AudioSource start time.
1708:01-02 00:28:39.440 W/audio_hw_primary( 2284): in_set_parameters input_source=1;routing=-2147483616, ret 11
1709:01-02 00:28:39.450 W/audio_hw_primary( 2284): start_input_stream....
1710:01-02 00:28:39.450 W/audio_hw_primary( 2284): card 1, port 0 device 0x20
1711:01-02 00:28:39.450 W/audio_hw_primary( 2284): rate 44100, channel 2 format 2, period_size 0x200
1713:01-02 00:28:41.460 I/OMXPlayer( 2284): OMX.Freescale.std.audio_source.android.sw-based wait command[0:3] timeout.
1718:01-02 00:28:42.040 I/OMXPlayer( 2284): OMX.Freescale.std.audio_source.android.sw-based send command[0:2] timeout.
1722:01-02 00:28:42.580 I/OMXPlayer( 2284): OMX.Freescale.std.audio_source.android.sw-based Time out for Sending Command [2:1], Busy on Command [0:2].
1724:01-02 00:28:42.580 I/OMXPlayer( 2284): OMX.Freescale.std.audio_source.android.sw-based Wait incorrect Command[2:1], ProcessingCmd is [0:2].
1737:01-02 00:28:49.470 W/audio_hw_primary( 2284): ret -1, pcm write 768 error cannot write stream data: I/O error.
1738:01-02 00:28:49.470 E/audio_hw_primary( 2284): get_next_buffer() pcm_read_wrapper error -1
1739:01-02 00:28:49.470 E/audio_hw_primary( 2284): get_next_buffer() pcm_read_convert error -1
1740:01-02 00:28:49.470 W/audio_hw_primary( 2284): ret -1, pcm read error cannot read stream data: I/O error.
1741:01-02 00:28:49.470 W/audio_hw_primary( 2284): ret -1, pcm write 768 error cannot prepare channel: Device or resource busy.
1742:01-02 00:28:49.470 W/audio_hw_primary( 2284): ret -1, pcm write 768 error cannot prepare channel: Device or resource busy.
1743:01-02 00:28:49.480 E/audio_hw_primary( 2284): get_next_buffer() pcm_read_wrapper error -16
1744:01-02 00:28:49.480 E/audio_hw_primary( 2284): get_next_buffer() pcm_read_convert error -16
1745:01-02 00:28:49.480 W/audio_hw_primary( 2284): ret -16, pcm read error cannot prepare channel: Device or resource busy.
1746:01-02 00:28:49.480 W/audio_hw_primary( 2284): ret -1, pcm write 768 error cannot prepare channel: Device or resource busy.
1748:01-02 00:28:49.480 I/OMXPlayer( 2284): OMX.Freescale.std.audio_source.android.sw-based Invalid state transitioin: 3 -> 1.
1752:01-02 00:28:49.490 W/audio_hw_primary( 2284): do_out_standby... 1074310608
1753:01-02 00:28:49.490 E/audio_hw_primary( 2284): get_next_buffer() pcm_read_wrapper error -16
1754:01-02 00:28:49.490 E/audio_hw_primary( 2284): get_next_buffer() pcm_read_convert error -16
1755:01-02 00:28:49.490 W/audio_hw_primary( 2284): ret -16, pcm read error cannot prepare channel: Device or resource busy.
1756:01-02 00:28:49.500 E/audio_hw_primary( 2284): get_next_buffer() pcm_read_wrapper error -16
1757:01-02 00:28:49.500 E/audio_hw_primary( 2284): get_next_buffer() pcm_read_convert error -16
1758:01-02 00:28:49.500 W/audio_hw_primary( 2284): ret -16, pcm read error cannot prepare channel: Device or resource busy.
1759:01-02 00:28:49.520 E/audio_hw_primary( 2284): get_next_buffer() pcm_read_wrapper error -16
1760:01-02 00:28:49.520 E/audio_hw_primary( 2284): get_next_buffer() pcm_read_convert error -16
1761:01-02 00:28:49.520 W/audio_hw_primary( 2284): ret -16, pcm read error cannot prepare channel: Device or resource busy.
1762:01-02 00:28:49.530 E/audio_hw_primary( 2284): get_next_buffer() pcm_read_wrapper error -16
1763:01-02 00:28:49.530 E/audio_hw_primary( 2284): get_next_buffer() pcm_read_convert error -16
1764:01-02 00:28:49.530 W/audio_hw_primary( 2284): ret -16, pcm read error cannot prepare channel: Device or resource busy.
1765:01-02 00:28:49.540 E/audio_hw_primary( 2284): get_next_buffer() pcm_read_wrapper error -16
1766:01-02 00:28:49.540 E/audio_hw_primary( 2284): get_next_buffer() pcm_read_convert error -16
=====
In addition, it also failed when I try to capture SPDIF frame with tinycap.
=====
root@android:/data # tinycap test.wav -D 1 -d 0
Unable to open PCM device (cannot set hw params: Invalid argument)
Captured 0 frames
=====
Thanks,
Daniel