Radxa Phone rock5b call audio

I managed to make GSM module to work on rock5b, initiate calls, send receive SMS.


Currently I dont have sound in calls. Because sound system is different than RIL I decided to create new post here.
GSM module is recognized as USB sound device. I need to forward sound from audio input to GSM. And also from GSM to audio output.

SPEAKER card, got card=0,device=0
card1 id:rockchiphdmiin
HDMI card, got card=1,device=0
card2 id:rockchiphdmi0
HDMI card, got card=2,device=0
card3 id:rockchiphdmi1
card4 id:EG25G
dump out device info
dev_info SPEAKER card=0, device:0
dev_info HDMI card=2, device:0
out->Device : 0x2
out->SampleRate : 48000
out->Channels : 2
out->Format : 0
out->PreiodSize : 480

3 Likes

current status

`
alsa_route: set_controls() Can not get ctl: Left Headphone Mixer Left DAC

vol.Events: STREAM_VOICE_CALL true

AS.AudioServiceL rescaleIndex : index range should not be zero`

for some reason volume controls do not work

Interesting example to check
https://android.googlesource.com/device/samsung/tuna/+/refs/heads/master/audio/audio_hw.c

rock5b uses
.name = “Manta audio HW HAL”

DeviceVector AudioPolicyManager::selectBestRxSinkDevicesForCall(bool fromCache)

{
ALOGW(“AudioPolicyManager::%s”, func);

DeviceVector rxSinkdevices{};
rxSinkdevices = mEngine->getOutputDevicesForAttributes(
            attributes_initializer(AUDIO_USAGE_VOICE_COMMUNICATION), nullptr, fromCache);
if (!rxSinkdevices.isEmpty() && mAvailableOutputDevices.contains(rxSinkdevices.itemAt(0))) {
    auto rxSinkDevice = rxSinkdevices.itemAt(0);
    auto telephonyRxModule = mHwModules.getModuleForDeviceType(
                AUDIO_DEVICE_IN_TELEPHONY_RX, AUDIO_FORMAT_DEFAULT);
    // retrieve Rx Source device descriptor
    sp<DeviceDescriptor> rxSourceDevice = mAvailableInputDevices.getDevice(
                AUDIO_DEVICE_IN_TELEPHONY_RX, String8(), AUDIO_FORMAT_DEFAULT);

    // RX Telephony and Rx sink devices are declared by Primary Audio HAL
    if (isPrimaryModule(telephonyRxModule) && (telephonyRxModule->getHalVersionMajor() >= 3) &&
            telephonyRxModule->supportsPatch(rxSourceDevice, rxSinkDevice)) {
        ALOGW("%s() device %s using HW Bridge", __func__, rxSinkDevice->toString().c_str());
        return DeviceVector(rxSinkDevice);
    }
}
// Note that despite the fact that getNewOutputDevices() is called on the primary output,
// the device returned is not necessarily reachable via this output
// (filter later by setOutputDevices())
return getNewOutputDevices(mPrimaryOutput, fromCache);

}

// You can enable VERBOSE logging as follows:
// adb shell setprop log.tag.APM_AudioPolicyManager V

For tinyalsa
LOCAL_CFLAGS += -DSUPPORT_USB

because

#ifdef SUPPORT_USB //usb input maybe used for primary

./hardware/rockchip/audio/tinyalsa_hal/codec_config/mixer_paths.xml

AudioHwDevice* AudioFlinger::findSuitableHwDev_l(
audio_module_handle_t module,
audio_devices_t deviceType)
//…
loadHwModule_l(audio_interfaces[i]);
//…
if (dev->getSupportedDevices(&supportedDevices) == OK &&
(supportedDevices & deviceType) == deviceType) {
return audioHwDevice;
}

//AudioPolicyManager
audio_stream_type_t stream = mEngine->getStreamTypeForAttributes(*attr);
// …
if (stream == AUDIO_STREAM_VOICE_CALL &&
audio_is_linear_pcm(config->format) &&
(*flags & AUDIO_OUTPUT_FLAG_INCALL_MUSIC) == 0) {
*flags = (audio_output_flags_t)(AUDIO_OUTPUT_FLAG_VOIP_RX |
AUDIO_OUTPUT_FLAG_DIRECT);
ALOGV(“Set VoIP and Direct output flags for PCM format”);
}
//…
status_t status = openDirectOutput(stream, session, &directConfig, *flags, devices, &output);

typedef struct {
audio_content_type_t content_type;
audio_usage_t usage;
audio_source_t source;
audio_flags_mask_t flags;
char tags[AUDIO_ATTRIBUTES_TAGS_MAX_SIZE]; /* UTF8 */
} attribute((packed)) audio_attributes_t;

https://android.googlesource.com/platform/frameworks/av/+/1b4d229ee6b2abef871bcfcd30e0f1d7a1e42afb/services/audiopolicy/AudioPolicyManager.cpp#509

./packages/services/Telecomm/src/com/android/server/telecom/CallAudioModeStateMachine.java

./frameworks/av/services/audiopolicy/engineconfigurable/config/example/phone/audio_policy_engine_product_strategies.xml