HFP Client SCO audio routing?

That is an excellent reason. I’m glad that I could help you with it.

Hi Mr. doitright,

You thread is really very helpful for those who are working on SCO on Hikey960.
I am also trying to do the same but facing some issues.

I have modified the kernel code similarly and ‘tinypcminfo’ produces following -

hikey960:/ # tinypcminfo -D 0 -d 0
Info for card 0, device 0:

PCM out:
Access: 0x000009
Format[0]: 0x000004
Format[1]: 00000000
Format Name: S16_LE
Subformat: 0x000001
Rate: min=8000Hz max=48000Hz
Channels: min=1 max=2
Sample bits: min=16 max=16
Period size: min=1024 max=2048
Period count: min=4 max=32

PCM in:
Access: 0x000009
Format[0]: 0x000004
Format[1]: 00000000
Format Name: S16_LE
Subformat: 0x000001
Rate: min=8000Hz max=48000Hz
Channels: min=1 max=2
Sample bits: min=16 max=16
Period size: min=1024 max=2048
Period count: min=4 max=32

However, I can see, after sending the required vendor commands - Write_Codec_Config, Write_Codec_Config_Enhanced and enabling pcm loopback, I2S2_DOUT is always zero i.e. no sound from loopback(probing BT pin57 using ‘Saleae USB DX’) though DIN seems to be proper. Mr. doitright, Mr. Loic, can you please help me to debug?

My VSCs are -

Write_Codec_Config -
06 fd 22 00 0c 01 80 bb 00 00 00 00 00 00 00 10 00 01 00 01 10 00 01 00 00 00 10 00 11 00 01 10 00 11 00 00 00

Write_Codec_Config_Enhanced -
07 fd 18 00 00 00 00 00 00 04 04 01 00 00 00 00 00 00 04 04 01 00 00 00 00 00 00

PCM loopback enable -
28 fe 01 01

I am sending the VSCs inside Bta_hf_client_main.bta_hf_client_api_enable() function so that during hfp cleint profile init, pcm will be initialized. bt snoop log is proper as I can see controller is sending command status = 0x00. Do you see any problem in sending VSCs here?

Thanking you,
Arnab Dey

This topic was solved quite a long time ago. I’ve been actually using it in my car for a few months now, and am finding it to be the absolute most reliable HFP device I’ve ever used. Over months now of testing, every single call has been successful.

On the kernel side, these three commits are all you need;

Note that the VSCs are sent from the ALSA driver in the second of those 3 commits.

1 Like

Hi Mr. doitright,

Thank you very much for the consolidated answer. It worked like a charm!!! I am sending the VSC from userspace. Thank you.

Regards,
Arnab Dey

Hi, doitright

Could you help share your HFP connection picture?
Such as the Mic, headset or speaker, and the Hikey960. HFP didn’t work in my native environment.

Thank you so much for your great help!

I’m not sure what you mean by “picture”. Could you explain what you’ve done? And what steps you’ve taken to debug it?

EDIT: I looked back on your previous posts, and now I remember that you were the one who was working with an external bluetooth device. So I presume that your biggest problem is that you don’t have any audio data lines connected with your bluetooth device, or they aren’t working.

The picture that you are looking for is then this;

Microphone → Vantec NBA-200U (left microphone input)
Speakers → Vantec NBA-200U (front speakers output)
Hikey960 USB → Vantec NBA-200U

Audio input path, in my configuration;
Microphone → Vantec NBA-200U → 960 → I2S2 → Wilink8

Audio output path;
Wilink8 → I2S2 → 960 → Vantec NBA-200U → Speakers

Now if you’re not using the Wilink8, then you have basically two options;

  1. If you have managed to attach your bluetooth device to the CPU via I2S0 (on the low speed port), then you have an updated path;
    Microphone → Vantec NBA-200U → 960 → I2S0 → Your bluetooth chip
    Your bluetooth chip → I2S0 → 960 → Vantec NBA-200U → Microphone
  2. If you have NOT managed to attach your bluetooth device to the CPU via I2S, then you cannot make HFP work, since Android does not actually support SCO over HCI.

You may want to chat with @dey_arnab, since he’s managed to get HFP working with a bluetooth chip attached via LS header (including i2s), or at least read the thread where he got it working; How to make I2S0(on LF connector) a PCM slave?
**Note however, most of the conversation actually revolved around converting the audio to work with a 24 bit sound card.

Hi, Mr doitright

Thank you so much for your great help.
The picture I mentioned is what you described. I want to know how you use the mic or speaker and I2S0 at the same time. Thank you for your details info.
Actually I didn’t learn of I2S0 knowledge. And I know I must use I2S0 to pass the voice audio to 960 according to your advice. But i don’t know how to use the I2S or LS header. And I bought the device Vantec NBA-200U you used in these days. I will check another topic thread to check how to use external bt chip to make hfp work. Thank you very much for your details sharing.