Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6a0c4b39 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "hal: add multizone input bus support for automotive"

parents c10ebff4 1404ba18
Loading
Loading
Loading
Loading
+28 −1
Original line number Diff line number Diff line
@@ -6087,6 +6087,9 @@ static auto_hal_get_car_audio_stream_from_address_t auto_hal_get_car_audio_strea
typedef int (*auto_hal_open_output_stream_t)(struct stream_out*);
static auto_hal_open_output_stream_t auto_hal_open_output_stream;

typedef int (*auto_hal_open_input_stream_t)(struct stream_in*);
static auto_hal_open_input_stream_t auto_hal_open_input_stream;

typedef bool (*auto_hal_is_bus_device_usecase_t)(audio_usecase_t);
static auto_hal_is_bus_device_usecase_t auto_hal_is_bus_device_usecase;

@@ -6118,6 +6121,10 @@ typedef snd_device_t (*auto_hal_get_output_snd_device_t)(struct audio_device*,
                                audio_usecase_t);
static auto_hal_get_output_snd_device_t auto_hal_get_output_snd_device;

typedef snd_device_t (*auto_hal_get_snd_device_for_car_audio_stream_t)(int
                                car_audio_stream);
static auto_hal_get_snd_device_for_car_audio_stream_t auto_hal_get_snd_device_for_car_audio_stream;

int auto_hal_feature_init(bool is_feature_enabled)
{
    ALOGD("%s: Called with feature %s", __func__,
@@ -6147,6 +6154,9 @@ int auto_hal_feature_init(bool is_feature_enabled)
            !(auto_hal_open_output_stream =
                 (auto_hal_open_output_stream_t)dlsym(
                            auto_hal_lib_handle, "auto_hal_open_output_stream")) ||
            !(auto_hal_open_input_stream =
                 (auto_hal_open_input_stream_t)dlsym(
                            auto_hal_lib_handle, "auto_hal_open_input_stream")) ||
            !(auto_hal_is_bus_device_usecase =
                 (auto_hal_is_bus_device_usecase_t)dlsym(
                            auto_hal_lib_handle, "auto_hal_is_bus_device_usecase")) ||
@@ -6170,7 +6180,10 @@ int auto_hal_feature_init(bool is_feature_enabled)
                            auto_hal_lib_handle, "auto_hal_get_input_snd_device")) ||
            !(auto_hal_get_output_snd_device =
                 (auto_hal_get_output_snd_device_t)dlsym(
                            auto_hal_lib_handle, "auto_hal_get_output_snd_device"))) {
                            auto_hal_lib_handle, "auto_hal_get_output_snd_device")) ||
            !(auto_hal_get_snd_device_for_car_audio_stream =
                 (auto_hal_get_snd_device_for_car_audio_stream_t)dlsym(
                            auto_hal_lib_handle, "auto_hal_get_snd_device_for_car_audio_stream"))) {
            ALOGE("%s: dlsym failed", __func__);
            goto feature_disabled;
        }
@@ -6190,6 +6203,7 @@ feature_disabled:
    auto_hal_release_audio_patch = NULL;
    auto_hal_get_car_audio_stream_from_address = NULL;
    auto_hal_open_output_stream = NULL;
    auto_hal_open_input_stream = NULL;
    auto_hal_is_bus_device_usecase = NULL;
    auto_hal_get_audio_port = NULL;
    auto_hal_set_audio_port_config = NULL;
@@ -6198,6 +6212,7 @@ feature_disabled:
    auto_hal_stop_hfp_downlink = NULL;
    auto_hal_get_input_snd_device = NULL;
    auto_hal_get_output_snd_device = NULL;
    auto_hal_get_snd_device_for_car_audio_stream = NULL;

    ALOGW(":: %s: ---- Feature AUTO_HAL is disabled ----", __func__);
    return -ENOSYS;
@@ -6268,6 +6283,12 @@ int audio_extn_auto_hal_open_output_stream(struct stream_out *out)
                            auto_hal_open_output_stream(out): -ENOSYS);
}

int audio_extn_auto_hal_open_input_stream(struct stream_in *in)
{
    return ((auto_hal_open_input_stream) ?
                            auto_hal_open_input_stream(in): -ENOSYS);
}

bool audio_extn_auto_hal_is_bus_device_usecase(audio_usecase_t uc_id)
{
    return ((auto_hal_is_bus_device_usecase) ?
@@ -6322,6 +6343,12 @@ snd_device_t audio_extn_auto_hal_get_output_snd_device(struct audio_device *adev
    return ((auto_hal_get_output_snd_device) ?
                            auto_hal_get_output_snd_device(adev, uc_id): SND_DEVICE_NONE);
}

snd_device_t audio_extn_auto_hal_get_snd_device_for_car_audio_stream(int car_audio_stream)
{
    return ((auto_hal_get_snd_device_for_car_audio_stream) ?
                            auto_hal_get_snd_device_for_car_audio_stream(car_audio_stream): SND_DEVICE_NONE);
}
// END: AUTO_HAL ===================================================================

void audio_extn_feature_init()
+12 −0
Original line number Diff line number Diff line
@@ -1350,6 +1350,16 @@ int audio_extn_utils_get_license_params(const struct audio_device *adev, struct
#ifndef AUDIO_OUTPUT_FLAG_REAR_SEAT
#define AUDIO_OUTPUT_FLAG_REAR_SEAT 0x2000000
#endif
#ifndef AUDIO_INPUT_FLAG_PRIMARY
#define AUDIO_INPUT_FLAG_PRIMARY 0x100000
#endif
#ifndef AUDIO_INPUT_FLAG_FRONT_PASSENGER
#define AUDIO_INPUT_FLAG_FRONT_PASSENGER 0x200000
#endif
#ifndef AUDIO_INPUT_FLAG_REAR_SEAT
#define AUDIO_INPUT_FLAG_REAR_SEAT 0x400000
#endif

int audio_extn_auto_hal_init(struct audio_device *adev);
void audio_extn_auto_hal_deinit(void);
int audio_extn_auto_hal_create_audio_patch(struct audio_hw_device *dev,
@@ -1362,6 +1372,7 @@ int audio_extn_auto_hal_release_audio_patch(struct audio_hw_device *dev,
                                audio_patch_handle_t handle);
int audio_extn_auto_hal_get_car_audio_stream_from_address(const char *address);
int audio_extn_auto_hal_open_output_stream(struct stream_out *out);
int audio_extn_auto_hal_open_input_stream(struct stream_in *in);
bool audio_extn_auto_hal_is_bus_device_usecase(audio_usecase_t uc_id);
int audio_extn_auto_hal_get_audio_port(struct audio_hw_device *dev,
                                struct audio_port *config);
@@ -1377,6 +1388,7 @@ snd_device_t audio_extn_auto_hal_get_input_snd_device(struct audio_device *adev,
                                audio_usecase_t uc_id);
snd_device_t audio_extn_auto_hal_get_output_snd_device(struct audio_device *adev,
                                audio_usecase_t uc_id);
snd_device_t audio_extn_auto_hal_get_snd_device_for_car_audio_stream(int car_audio_stream);

typedef streams_input_ctxt_t* (*fp_in_get_stream_t)(struct audio_device*, audio_io_handle_t);
typedef streams_output_ctxt_t* (*fp_out_get_stream_t)(struct audio_device*, audio_io_handle_t);
+42 −4
Original line number Diff line number Diff line
@@ -309,6 +309,35 @@ int auto_hal_get_car_audio_stream_from_address(const char *address)
    return (0x1 << bus_num);
}

int auto_hal_open_input_stream(struct stream_in *in)
{
    int ret = 0;

    switch(in->car_audio_stream) {
    case CAR_AUDIO_STREAM_IN_PRIMARY:
        in->usecase = USECASE_AUDIO_RECORD_BUS;
        if (in->flags == AUDIO_INPUT_FLAG_NONE)
            in->flags |= AUDIO_INPUT_FLAG_PRIMARY;
        break;
    case CAR_AUDIO_STREAM_IN_FRONT_PASSENGER:
        in->usecase = USECASE_AUDIO_RECORD_BUS_FRONT_PASSENGER;
        if (in->flags == AUDIO_INPUT_FLAG_NONE)
            in->flags |= AUDIO_INPUT_FLAG_FRONT_PASSENGER;
        break;
    case CAR_AUDIO_STREAM_IN_REAR_SEAT:
        in->usecase = USECASE_AUDIO_RECORD_BUS_REAR_SEAT;
        if (in->flags == AUDIO_INPUT_FLAG_NONE)
            in->flags |= AUDIO_INPUT_FLAG_REAR_SEAT;
        break;
    default:
        ALOGE("%s: Car audio stream 0x%x not supported", __func__,
            in->car_audio_stream);
        ret = -EINVAL;
    }

    return ret;
}

int auto_hal_open_output_stream(struct stream_out *out)
{
    int ret = 0;
@@ -401,11 +430,11 @@ bool auto_hal_is_bus_device_usecase(audio_usecase_t uc_id)
    return false;
}

snd_device_t auto_hal_get_snd_device_for_car_audio_stream(struct stream_out *out)
snd_device_t auto_hal_get_snd_device_for_car_audio_stream(int car_audio_stream)
{
    snd_device_t snd_device = SND_DEVICE_NONE;

    switch(out->car_audio_stream) {
    switch(car_audio_stream) {
    case CAR_AUDIO_STREAM_MEDIA:
        snd_device = SND_DEVICE_OUT_BUS_MEDIA;
        break;
@@ -424,9 +453,18 @@ snd_device_t auto_hal_get_snd_device_for_car_audio_stream(struct stream_out *out
    case CAR_AUDIO_STREAM_REAR_SEAT:
        snd_device = SND_DEVICE_OUT_BUS_RSE;
        break;
    case CAR_AUDIO_STREAM_IN_PRIMARY:
        snd_device = SND_DEVICE_IN_BUS;
        break;
    case CAR_AUDIO_STREAM_IN_FRONT_PASSENGER:
        snd_device = SND_DEVICE_IN_BUS_PAX;
        break;
    case CAR_AUDIO_STREAM_IN_REAR_SEAT:
        snd_device = SND_DEVICE_IN_BUS_RSE;
        break;
    default:
        ALOGE("%s: Unknown car audio stream (%x)",
            __func__, out->car_audio_stream);
        ALOGE("%s: Unknown car audio stream (%#x)",
            __func__, car_audio_stream);
    }
    return snd_device;
}
+3 −0
Original line number Diff line number Diff line
@@ -66,4 +66,7 @@ static const audio_usecase_t bus_device_usecases[] = {
    USECASE_AUDIO_PLAYBACK_PHONE,
    USECASE_AUDIO_PLAYBACK_FRONT_PASSENGER,
    USECASE_AUDIO_PLAYBACK_REAR_SEAT,
    USECASE_AUDIO_RECORD_BUS,
    USECASE_AUDIO_RECORD_BUS_FRONT_PASSENGER,
    USECASE_AUDIO_RECORD_BUS_REAR_SEAT,
};
+3 −0
Original line number Diff line number Diff line
@@ -164,6 +164,9 @@ const struct string_to_enum s_flag_name_to_enum_table[] = {
    STRING_TO_ENUM(AUDIO_INPUT_FLAG_VOIP_TX),
    STRING_TO_ENUM(AUDIO_INPUT_FLAG_HW_AV_SYNC),
    STRING_TO_ENUM(AUDIO_INPUT_FLAG_DIRECT),
    STRING_TO_ENUM(AUDIO_INPUT_FLAG_PRIMARY),
    STRING_TO_ENUM(AUDIO_INPUT_FLAG_FRONT_PASSENGER),
    STRING_TO_ENUM(AUDIO_INPUT_FLAG_REAR_SEAT),
};

const struct string_to_enum s_format_name_to_enum_table[] = {
Loading