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

Commit 7df84d17 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "audiohal: Sourcetrack: Add new set api" into audio-userspace.lnx.2.2-dev

parents ac7eca64 daf1d06f
Loading
Loading
Loading
Loading
+66 −49
Original line number Diff line number Diff line
/*
 * Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
 * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
@@ -555,12 +555,73 @@ void audio_extn_source_track_get_parameters(const struct audio_device *adev,
    }
}

void audio_extn_source_track_set_parameters(struct audio_device *adev,
                                            struct str_parms *parms)
static int set_source_track_data(struct audio_device *adev,
                           struct sound_focus_param *sound_focus_param)
{
    int len, ret, count;;
    int i, ret, count;
    struct mixer_ctl *ctl;
    char sound_focus_mixer_ctl_name[MIXER_PATH_MAX_LENGTH] = "Sound Focus";

    /* Derive the mixer control name based on the use case and the audio h/w
     * interface name for the corresponding audio device
     */
    ret = derive_mixer_ctl_from_usecase_intf(adev, sound_focus_mixer_ctl_name);
    if (ret != 0) {
        ALOGE("%s: Could not set Sound Focus Params:%d", __func__, ret);
        return ret;
    } else {
        ALOGV("%s: Mixer Ctl name: %s", __func__, sound_focus_mixer_ctl_name);
    }

    ctl = mixer_get_ctl_by_name(adev->mixer, sound_focus_mixer_ctl_name);
    if (!ctl) {
        ALOGE("%s: Could not get ctl for mixer cmd - %s",
                __func__, sound_focus_mixer_ctl_name);
        ret = -EINVAL;
        return ret;
    } else {
        ALOGV("%s: Setting Sound Focus Params", __func__);

        for (i = 0; i < MAX_SECTORS;i++) {
            ALOGV("%s: start_angles[%d] = %d", __func__, i, sound_focus_param->start_angle[i]);
        }
        for (i = 0; i < MAX_SECTORS;i++) {
            ALOGV("%s: enable_sectors[%d] = %d", __func__, i, sound_focus_param->enable[i]);
        }
        ALOGV("%s: gain_step = %d", __func__, sound_focus_param->gain_step);

        mixer_ctl_update(ctl);
        count = mixer_ctl_get_num_values(ctl);
        if (count != sizeof(struct sound_focus_param)) {
            ALOGE("%s: mixer_ctl_get_num_values() invalid data size", __func__);
            return ret;
        }

        // Set the parameters on the mixer control derived above
        ret = mixer_ctl_set_array(ctl, (void *)sound_focus_param, count);
        if (ret != 0) {
            ALOGE("%s: mixer_ctl_set_array() failed to set Sound Focus Params:%d",
                      __func__, ret);
        }
    }
    return ret;
}

int audio_extn_set_soundfocus_data(struct audio_device *adev,
                              struct sound_focus_param *payload)
{
    int ret = 0;
    struct sound_focus_param *sound_focus_data = payload;

    ret = set_source_track_data(adev, sound_focus_data);

    return ret ;
}

void audio_extn_source_track_set_parameters(struct audio_device *adev,
                                            struct str_parms *parms)
{
    int len, ret;
    char *value = NULL;
    char *kv_pairs = str_parms_to_str(parms);

@@ -626,51 +687,7 @@ void audio_extn_source_track_set_parameters(struct audio_device *adev,
            goto done;
        }

        /* Derive the mixer control name based on the use case and the audio h/w
         * interface name for the corresponding audio device
         */
        ret = derive_mixer_ctl_from_usecase_intf(adev, sound_focus_mixer_ctl_name);
        if (ret != 0) {
            ALOGE("%s: Could not set Sound Focus Params", __func__);

            goto done;
        } else {
            ALOGV("%s: Mixer Ctl name: %s", __func__, sound_focus_mixer_ctl_name);
        }

        ctl = mixer_get_ctl_by_name(adev->mixer, sound_focus_mixer_ctl_name);
        if (!ctl) {
            ALOGE("%s: Could not get ctl for mixer cmd - %s",
                  __func__, sound_focus_mixer_ctl_name);

            goto done;
        } else {
            ALOGV("%s: Setting Sound Focus Params", __func__);

            for (i = 0; i < MAX_SECTORS;i++) {
                ALOGV("%s: start_angles[%d] = %d", __func__, i, sound_focus_param.start_angle[i]);
            }
            for (i = 0; i < MAX_SECTORS;i++) {
                ALOGV("%s: enable_sectors[%d] = %d", __func__, i, sound_focus_param.enable[i]);
            }
            ALOGV("%s: gain_step = %d", __func__, sound_focus_param.gain_step);

            mixer_ctl_update(ctl);
            count = mixer_ctl_get_num_values(ctl);
            if (count != sizeof(struct sound_focus_param)) {
                ALOGE("%s: mixer_ctl_get_num_values() invalid data size", __func__);

                goto done;
            }

            // Set the parameters on the mixer control derived above
            ret = mixer_ctl_set_array(ctl, (void *)&sound_focus_param, count);
            if (ret != 0) {
                ALOGE("%s: mixer_ctl_set_array() failed to set Sound Focus Params", __func__);

                goto done;
            }
       }
        set_source_track_data(adev, &sound_focus_param);
    }

done:
+36 −7
Original line number Diff line number Diff line
/*
* Copyright (c) 2016, The Linux Foundation. All rights reserved.
* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -48,13 +48,14 @@ uint64_t timestamp;
};
#endif

int qahwi_get_param_data(const struct audio_device *adev,
int qahwi_get_param_data(const struct audio_hw_device *adev,
                         qahw_param_id param_id, qahw_param_payload *payload)
{
    int ret = 0;
    const struct audio_device *dev = (const struct audio_device *)adev;

    if (adev == NULL) {
        ALOGE("%s::INVALID PARAM\n",__func__);
        ALOGE("%s::INVALID PARAM adev\n",__func__);
        return -EINVAL;
    }

@@ -65,20 +66,48 @@ int qahwi_get_param_data(const struct audio_device *adev,

    switch (param_id) {
        case QAHW_PARAM_SOUND_FOCUS:
              ret = audio_extn_get_soundfocus_data(adev,
              ret = audio_extn_get_soundfocus_data(dev,
                     (struct qahw_sound_focus_param *)payload);
              break;
        case QAHW_PARAM_SOURCE_TRACK:
              ret = audio_extn_get_sourcetrack_data(adev,
              ret = audio_extn_get_sourcetrack_data(dev,
                     (struct qahw_source_tracking_param*)payload);
              break;
       default:
             ALOGE("%s::INVALID PARAM ID:%d\n",__func__,param_id);
             ret = -EINVAL;
             break;

    }
    return ret;
}

int qahwi_set_param_data(struct audio_hw_device *adev,
                         qahw_param_id param_id, qahw_param_payload *payload)
{
    int ret = 0;
    struct audio_device *dev = (struct audio_device *)adev;

    if (adev == NULL) {
        ALOGE("%s::INVALID PARAM adev\n",__func__);
        return -EINVAL;
    }

    if (payload == NULL) {
        ALOGE("%s::INVALID PAYLOAD VALUE\n",__func__);
        return -EINVAL;
    }

    switch (param_id) {
        case QAHW_PARAM_SOUND_FOCUS:
              ret = audio_extn_set_soundfocus_data(dev,
                     (struct qahw_sound_focus_param *)payload);
              break;
       default:
             ALOGE("%s::INVALID PARAM ID:%d\n",__func__,param_id);
             ret = -EINVAL;
             break;
    }
    return ret;
}

ssize_t qahwi_in_read_v2(struct audio_stream_in *stream, void* buffer,