Inject uplink audio in call with Snapdragon MSM8960 SoC
Asked Answered
M

1

6

I've been investigating on this topic specific to MSM8960 for some time. I looked into the ALSA hardware module from google. Michael's answer in the post did mention that MSM8960 supported the in-call uplink audio injection at "Hardware and Device Driver" level. Did it refer to the level at this ALSA module?

From the ALSA config file on the phone, it seems the in call voice playback is done through /dev/snd/pcmC0D0p, or at least comply with the ALSA paradigm. Is it possible to play with one of the file descriptor to achieve the purpose? I do see some interesting USE_CASE definition in libalsa-intf.

Metathesis answered 4/3, 2013 at 15:3 Comment(0)
I
9

The MSM8960 provides an ALSA control named Incall_Music Audio Mixer, to which you can connect CPU DAIs MultiMedia1 and MultiMedia2 (which would correspond to ALSA devices pcmC0D0p and pcmC0D1p, respectively). (see the msm-pcm-routing source code)

So if you had a voice call running and wanted to play some audio on the uplink through pcmC0D0p you could do this through adb shell (assuming that you've got root access):

amix 'Incall_Music Audio Mixer MultiMedia1' 1
aplay -Dhw:0,0 mono_8khz_audio.wav


The more elegant way would be to create a new use-case in the device's UCM file (snd_soc_msm_blah_blah..) where you add the incall music routing in the enable-sequence of your new modifer:

'Incall_Music Audio Mixer MultiMedia1':1:1

(remember to turn it off in the disable-sequence).
For apps to be able to use this functionality on your custom ROM you'd also have to make some other changes in the audio HAL and multimedia framework, so that your new UCM setting is selected for the desired stream types when a call is active.
Due to copyright reasons I can't go into any detail about the rest of the implementation, so I'll leave it as an exercise for those interested to figure it out for themselves.

Invoke answered 4/3, 2013 at 15:48 Comment(17)
it seems the amix and aplay are not present on the Samsung Galaxy S3 phone. How to build them from the google git repository? as it's not part of the default android source tree that I've synced.Metathesis
I doubt that they're part of Google's repo since they're located in the Qualcomm-specific audio git. You can find the source code for them at the Code Aurora ForumInvoke
After successfully making it working on MSM8960, now I've moved onto APQ8064. But it seems the feature is supported in a different way though the "Incall_Music Audio Mixer MultiMedia1" remains there. I saw an interesting commit to Code Aurora android.googlesource.com/kernel/msm/+/… and I believe for APQ8064, different mixer controls might have been introduced to do the same. Could you please help to figure out what the difference is on APQ8064?Metathesis
could you please give me a pointer? since as you mentioned, both MSM8960 and APQ8064 are both doable.@InvokeMetathesis
IIRC you need to use SLIMBUS_4_RX on the APQ8064.Invoke
I remember I tried "SLIMBUS_4_RX Audio Mixer MultiMedia1", then playback to -Dhw:0,0, the command seems to have written the data to PCM successfully, and didn't give any error, but the other end of the call heard nothing.Metathesis
Did you make sure that the audio file was 8 kHz mono? Because otherwise the audio won't be heard. I tested this use-case successfully on an XPeria Z or ZL (which are APQ8064-based) a few months ago, and I'm nearly 100% sure that I used SLIMBUS_4_RX.Invoke
I just tried that out on my Samsung Galaxy S4 (APQ8064T), yes, I'm using 8KHz Mono wav file. I'm facing a weird thing, after I execute the aplay command, before it ended, if I press the "volume" hardware button on the phone and tap the "gear" icon to show a panel of 4 sliders to control different volumn, such as call, media, notification, the audio can be heard from the phone's own earpiece rather than the far end of the call. Do you have any clue what could possibly cause this?Metathesis
Here's what I did:amix 'SLIMBUS_4_RX Audio Mixer MultiMedia1' 1, aplay -D hw:0,0 /sdcard/AGAM1F01.wavMetathesis
It's probably playing some kind of notification in the earpiece (either a touch sound, or some kind of acknowledgement of having changed the volume). While doing this it will most likely connect MultiMedia1 (which corresponds to pcmC0D0p) to SLIMBUS_0_RX going to the earpiece. Since MultiMedia1 is the same interface you use for your incall music you'll hear that audio as well in the earpiece. To avoid this you could use MultiMedia2 (corresponds to pcmC0D1p) for the incall music playback.Invoke
Thanks for pointing that out. But I'm still unable to deliver the audio through cellular to the far side. I tried according to your comment above on Galaxy S4 APQ8064T, the aplay command seemed being executed properly with SLIMBUS_4_RX connected with MultiMedia2, the command return "Done playing", however during the playback, nothing was heard on the remote side.Metathesis
After spending days trying on Samsung Galaxy S4 I9505 (APQ8064T), it seems both SLIMBUS_4_RX Audio Mixer MultiMedia2 (playback) and MultiMedia2 Mixer SLIM_4_TX(capture) are not working as expected. aplay and arec can be executed without error, but audio can not be heard from the far end of the call during the playback and the recorded wave file contains only silence. I don't have other APQ8064(T) device to try out. Could it be due to the difference between APQ8064 and APQ8064T thought they're using the same codec? or extra mixer controls are required? @InvokeMetathesis
There could be driver differences between the two platform variants - I'm not familiar with the APQ8064T. I don't recall having to set up any additional ALSA controls on the APQ8064, but I no longer have access to those phones so I can't verify it.Invoke
I think I figured out why setting the mixer control only doesn't work out. For APQ8064T platform, there's an additional library to interact with. I've posted all about that in a new question. For the music delivery, I've set it straight. But, the opposite, to record in-call voice is not that easy. That new question is how to enable the in-call by the same library. Do you have any clue about that?Metathesis
Does anyone know if it is doable on Samsung A52 and A72 devices? both of them use Qualcomm chipset. I want to play an audio file on a call when the mic is muted. I wanted to know can I use this way to achieve this requirement? @InvokeWatcher
@SimonWeng Could you please explain more about how you inject the audio file on a call? I want to implement an android app for rooted devices. This app should inject an audio file on a call while the mic is muted. After a lot of researches I reached to this post but I didn't get how I should use the commands using adb shell in my appWatcher
@SimonWeng I've connected to the rooted emulator using adb connect command. Now I don't know how I can inject an audio file on a callWatcher

© 2022 - 2024 — McMap. All rights reserved.