[Android] How to support SPDIF input feature?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

[Android] How to support SPDIF input feature?

10,811件の閲覧回数
charleshuang
Senior Contributor II

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

ラベル(3)
タグ(2)
0 件の賞賛
返信
42 返答(返信)

4,155件の閲覧回数
YixingKong
Senior Contributor IV

Daniel

Had your issue got resolved? If yes, we are going to close the discussion in 3 days. If you still need help, please feel free to reply with an update to this discussion.

Thanks,

Yixing

0 件の賞賛
返信

4,155件の閲覧回数
danielhung
Contributor III

Hi Yixing & Jim,

I check the BSP for Sabre-AI board and find there are two things different to Sabre-SD.

  1. It builds AudioRoute app to control SPDIF input path.

  2. It adds AUDIO_DEVICE_IN_AUX_DIGITAL for primary input devices in audio_policy.conf.

After integrated the codes above, I can see the system is trying to open SPDIF input device for recording.

However, the Android default recorder app just stops suddenly and jumps back to app list.

I find this is caused by audio formats.

For sgtl5000, it supports PCM_FORMAT_S16_LE (format 0) and it can work fine with recorder app.

But, SPDIF seems to only support PCM_FORMAT_S24_LE (format 2).

======

08-19 07:46:25.820 W/audio_hw_primary( 2272): card 0, id sgtl5000audio ,driver sgtl5000-audio, name sgtl5000-audio
08-19 07:46:25.840 W/audio_hw_primary( 2272): out rate 44100
08-19 07:46:25.840 W/audio_hw_primary( 2272): in rate 44100, channels 2 format 0

08-19 07:46:25.840 W/audio_hw_primary( 2272): card 1, id imxspdif ,driver imx-spdif, name imx-spdif
08-19 07:46:25.840 W/audio_hw_primary( 2272): out rate 44100
08-19 07:46:25.840 W/audio_hw_primary( 2272): in rate 44100, channels 2 format 2

=======

Maybe I should use 24 bits recorder for SPDIF. Does it also the same way you tested?

Thanks,

Daniel

0 件の賞賛
返信

4,155件の閲覧回数
jim_lin
NXP Employee
NXP Employee

update the test procedure the test team run on SabreAI:

1, Build the android image for sabreAI board.

2. Connect PC with SabreAI board with spdif cable, send spdif data from PC to board

3. Use Audio Route app to enable the spdif feature.

4. Use recorder to record the audio.

FYI~

Jim Lin.

0 件の賞賛
返信

4,155件の閲覧回数
danielhung
Contributor III

Hi Jim,

Thanks for the information. The procedure looks similar with mine, but the default recorder does not work on my side.

If possible, could you provide the "logcat" log message for my reference?

You can start the logcat when system is booting and stop it after the whole test procedure on SabreAI finished.

Thank you.

Daniel

0 件の賞賛
返信

4,165件の閲覧回数
weidong_sun
NXP TechSupport
NXP TechSupport

Hi Daniel,

      If  you want to use SPDIF input feature, you should multiplex SPDIF_IN signal via one of the following CPU PADs on you board(hardware) :

SPDIF_IN.png

Then add multiplexing codes to BSP file or corresponding header file, multiplexing PADs are defined in ~/myandroid/kernel_imx/arch/arm/plat-mxc/include/mach/iomux_mx6q.h

Please try it on!

Regards,

Weidong

0 件の賞賛
返信

4,165件の閲覧回数
YixingKong
Senior Contributor IV

Weidong, could you please continue to help the customer?

Thanks,

Yixing

0 件の賞賛
返信

4,165件の閲覧回数
danielhung
Contributor III

Hi Yixing & Weidong,

May I know do you have any update for this issue?

Thanks for your support.

Best regards,

Daniel

0 件の賞賛
返信

4,165件の閲覧回数
weidong_sun
NXP TechSupport
NXP TechSupport

Hi Daniel,

     I confirmed the issue with R&D ,  In our android bsp, tinyalsa_hal.c supports SPDIF input, you can check this source code.

Regards,

Weidong

0 件の賞賛
返信

4,165件の閲覧回数
danielhung
Contributor III

Hi Weidong,

Yes. I see AUDIO_DEVICE_IN_AUX_DIGITAL device for SPDIF audio input in tinyalso HAL, but it seems not complete enough to work.

In my opinion, there should be more modifications in tinyalsa_hal.c and add SPDIF input configs in audio_policy.conf file.

Could you double confirm if SPDIF input device really work on Freescale sabresd demo board?

Thanks,

Daniel

0 件の賞賛
返信

4,155件の閲覧回数
weidong_sun
NXP TechSupport
NXP TechSupport

Daniel,

     I confirmed with tinyalsa_hal owner from R&D team, On our SabreSD board , there is not SPDIF input pin, so you can't use this board to test the funciton. On our sabreauto board, this function is supported.

     If you want to sabresd board, you will have to adjust hardware, I mean you should make SPDIF signal output at first, then test it.

Regards,

weidong

0 件の賞賛
返信

4,155件の閲覧回数
YixingKong
Senior Contributor IV

Weidong, The issue is still open. Could you please followit up it?

Thanks,

Yixing

jim.lin

0 件の賞賛
返信

4,155件の閲覧回数
YixingKong
Senior Contributor IV

Weidong, this DI has been opened for long time. Could you please see if you can close the DI or let me know if any help is needed?

Thanks,

Yixing

0 件の賞賛
返信

4,155件の閲覧回数
weidong_sun
NXP TechSupport
NXP TechSupport

Hi charles,

      I will confirm the issue with the owner of audio source code. please wait...!

Regards,

Weidong

0 件の賞賛
返信

4,155件の閲覧回数
weidong_sun
NXP TechSupport
NXP TechSupport

Hello Charles,

      Jim and I confirmed the issue you submitted with R&D team, Out test team has tested SPDIF input function on Sabre-AI board, he suggested you check BSP for Sabre-AI board and find how to ...

Regards,

Weidong

0 件の賞賛
返信

4,155件の閲覧回数
danielhung
Contributor III

Hi Weidong,

Thanks for update. Just double confirm if you test with Android system on Sabre-AI board?

Furthermore, could I know how you verify on Android system? Via the sound recorder app?

Thanks,

Daniel

0 件の賞賛
返信

4,155件の閲覧回数
jim_lin
NXP Employee
NXP Employee

Hello Daniel,

to your question,

yes, R&D confirmed that they have tested SPDIF INPUT in Android on Sabre-AI board,

suggest to compare the setting between SabreSD and Sabre-AI regarding the setting of SPDIF INPUT in Android BSP, the difference might be the solution, FYI~

Best regards,

Jim Lin.

0 件の賞賛
返信

4,155件の閲覧回数
YixingKong
Senior Contributor IV

JIm

PLease keep following the customer's isue and close it as soon as possible.

Thanks,

Yixing

0 件の賞賛
返信

4,155件の閲覧回数
YixingKong
Senior Contributor IV

Weidong, could you keep helping this issue thread and close this?

Thanks,

Yixing

0 件の賞賛
返信

4,155件の閲覧回数
jim_lin
NXP Employee
NXP Employee

Hello Weidong,

I think the question here is:

Does SPDIF INPUT work in Android BSP, no matter it's on SabreSD or SabreAuto?

Daniel tested SPDIF INPUT and OUTPUT work in Linux on their MX6 board, supposed the hardware design is ok. But only SPDIF OUTPUT works in Android on the same board, can't have SPDIF INPUT working, will need your comment if SPDIF INPUT is not enabled in Android.

thanks,

Jim Lin.

0 件の賞賛
返信

4,155件の閲覧回数
danielhung
Contributor III

Hi Weidong,

Thanks for confirmation. Actually, we use our own hardware for spdif feature. It can work fine for Linux, but SPDIF input is not available for Android.

As you mentioned, could you help to verify SPDIF input feature on sabreauto board with Android system?

Thanks,

Daniel

0 件の賞賛
返信