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

Commit c3c5d43c authored by Satish Babu Patakokila's avatar Satish Babu Patakokila Committed by Shiv Maliyappanahalli
Browse files

hal: Add API to support device configuration

Add new API to set device configuration from Client.
Currently the device config is set from edid.
New API overwrites the default device config with
client provided values.

CRs-fixed: 2071954
Change-Id: I1f0918acf0a420f9c9d8a17bc070637199cb7105
parent ff61315a
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -221,6 +221,21 @@ struct audio_out_channel_map_param {
   uint8_t       channel_map[AUDIO_CHANNEL_COUNT_MAX];  /* Input Channel Map */
};

struct audio_device_cfg_param {
   uint32_t   sample_rate;
   uint32_t   channels;
   uint32_t   bit_width;
   audio_format_t format;
   audio_devices_t device;
   uint8_t    channel_map[AUDIO_CHANNEL_COUNT_MAX];
   uint16_t   channel_allocation;
};

struct audio_device_config_param {
   bool use_client_dev_cfg;
   struct audio_device_cfg_param dev_cfg_params;
};

typedef union {
    struct source_tracking_param st_params;
    struct sound_focus_param sf_params;
@@ -232,6 +247,7 @@ typedef union {
    struct audio_out_correct_drift drift_correction_param;
    struct audio_adsp_event adsp_event_params;
    struct audio_out_channel_map_param channel_map_param;
    struct audio_device_cfg_param device_cfg;
} audio_extn_param_payload;

typedef enum {
@@ -247,7 +263,8 @@ typedef enum {
    AUDIO_EXTN_PARAM_OUT_CORRECT_DRIFT,
    AUDIO_EXTN_PARAM_ADSP_STREAM_CMD,
    /* param to set input channel map for playback stream */
    AUDIO_EXTN_PARAM_OUT_CHANNEL_MAP
    AUDIO_EXTN_PARAM_OUT_CHANNEL_MAP,
    AUDIO_EXTN_PARAM_DEVICE_CONFIG
} audio_extn_param_id;

#endif /* AUDIO_DEFS_H */
+50 −0
Original line number Diff line number Diff line
@@ -1418,3 +1418,53 @@ int audio_extn_out_get_param_data(struct stream_out *out,

    return ret;
}

int audio_extn_set_device_cfg_params(struct audio_device *adev,
                                     struct audio_device_cfg_param *payload)
{
    struct audio_device_cfg_param *device_cfg_params = payload;
    int ret = -EINVAL;
    struct stream_out out;
    uint32_t snd_device = 0, backend_idx = 0;
    struct audio_device_config_param *adev_device_cfg_ptr = adev->device_cfg_params;

    ALOGV("%s", __func__);

    if (!device_cfg_params || !adev) {
        ALOGE("%s:: Invalid Param", __func__);
        return ret;
    }

    /* Config is not supported for combo devices */
    if (popcount(device_cfg_params->device) != 1) {
        ALOGE("%s:: Invalid Device (%#x) - Config is ignored", __func__, device_cfg_params->device);
        return ret;
    }

    /* Create an out stream to get snd device from audio device */
    out.devices = device_cfg_params->device;
    out.sample_rate = device_cfg_params->sample_rate;
    snd_device = platform_get_output_snd_device(adev->platform, &out);
    backend_idx = platform_get_backend_index(snd_device);

    ALOGV("%s:: device %d sample_rate %d snd_device %d backend_idx %d",
                __func__, out.devices, out.sample_rate, snd_device, backend_idx);

    ALOGV("%s:: Device Config Params from Client samplerate %d  channels %d"
          " bit_width %d  format %d  device %d  channel_map[0] %d channel_map[1] %d"
          " channel_map[2] %d channel_map[3] %d channel_map[4] %d channel_map[5] %d"
          " channel_allocation %d\n", __func__, device_cfg_params->sample_rate,
          device_cfg_params->channels, device_cfg_params->bit_width,
          device_cfg_params->format, device_cfg_params->device,
          device_cfg_params->channel_map[0], device_cfg_params->channel_map[1],
          device_cfg_params->channel_map[2], device_cfg_params->channel_map[3],
          device_cfg_params->channel_map[4], device_cfg_params->channel_map[5],
          device_cfg_params->channel_allocation);

    /* Copy the config values into adev structure variable */
    adev_device_cfg_ptr += backend_idx;
    adev_device_cfg_ptr->use_client_dev_cfg = true;
    memcpy(&adev_device_cfg_ptr->dev_cfg_params, device_cfg_params, sizeof(struct audio_device_cfg_param));

    return 0;
}
+2 −1
Original line number Diff line number Diff line
@@ -867,7 +867,8 @@ int audio_extn_out_set_param_data(struct stream_out *out,
int audio_extn_out_get_param_data(struct stream_out *out,
                             audio_extn_param_id param_id,
                             audio_extn_param_payload *payload);

int audio_extn_set_device_cfg_params(struct audio_device *adev,
                                     struct audio_device_cfg_param *payload);
int audio_extn_utils_get_avt_device_drift(
                struct audio_usecase *usecase,
                struct audio_avt_device_drift_param *drift_param);
+10 −0
Original line number Diff line number Diff line
@@ -5538,6 +5538,10 @@ static int adev_close(hw_device_t *device)
        audio_extn_adsp_hdlr_deinit();
        audio_extn_snd_mon_deinit();
        audio_extn_loopback_deinit(adev);
        if (adev->device_cfg_params) {
            free(adev->device_cfg_params);
            adev->device_cfg_params = NULL;
        }
        free(device);
        adev = NULL;
    }
@@ -5838,6 +5842,12 @@ static int adev_open(const hw_module_t *module, const char *name,
    adev->card_status = CARD_STATUS_ONLINE;
    pthread_mutex_unlock(&adev->lock);
    audio_extn_sound_trigger_init(adev); /* dependent on snd_mon_init() */
    /* Allocate memory for Device config params */
    adev->device_cfg_params = (struct audio_device_config_param*)
                                  calloc(platform_get_max_codec_backend(),
                                  sizeof(struct audio_device_config_param));
    if (adev->device_cfg_params == NULL)
        ALOGE("%s: Memory allocation failed for Device config params", __func__);

    ALOGV("%s: exit", __func__);
    return 0;
+1 −0
Original line number Diff line number Diff line
@@ -471,6 +471,7 @@ struct audio_device {
    qahwi_device_t qahwi_dev;
    bool vr_audio_mode_enabled;
    bool bt_sco_on;
    struct audio_device_config_param *device_cfg_params;
};

int select_devices(struct audio_device *adev,
Loading