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

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

Merge "audio: hal: support for audio render window"

parents d99547d5 27346045
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -164,18 +164,29 @@ struct audio_avt_device_drift_param {
    uint32_t        ref_timer_abs_ts_msw;
};

/*use these for setting infine window.i.e free run mode */
#define AUDIO_MAX_RENDER_START_WINDOW 0x8000000000000000
#define AUDIO_MAX_RENDER_END_WINDOW   0x7FFFFFFFFFFFFFFF

struct audio_out_render_window_param {
   uint64_t        render_ws; /* render window start value in microseconds*/
   uint64_t        render_we; /* render window end value in microseconds*/
};

typedef union {
    struct source_tracking_param st_params;
    struct sound_focus_param sf_params;
    struct aptx_dec_param aptx_params;
    struct audio_avt_device_drift_param drift_params;
    struct audio_out_render_window_param render_window_param;
} audio_extn_param_payload;

typedef enum {
    AUDIO_EXTN_PARAM_SOURCE_TRACK,
    AUDIO_EXTN_PARAM_SOUND_FOCUS,
    AUDIO_EXTN_PARAM_APTX_DEC,
    AUDIO_EXTN_PARAM_AVT_DEVICE_DRIFT
    AUDIO_EXTN_PARAM_AVT_DEVICE_DRIFT,
    AUDIO_EXTN_PARAM_OUT_RENDER_WINDOW /* PARAM to set render window */
} audio_extn_param_id;

#endif /* AUDIO_DEFS_H */
+4 −0
Original line number Diff line number Diff line
@@ -834,4 +834,8 @@ int audio_extn_utils_get_avt_device_drift(
                struct audio_avt_device_drift_param *drift_param);
int audio_extn_utils_compress_get_dsp_latency(struct stream_out *out);
int audio_extn_utils_compress_set_render_mode(struct stream_out *out);
int audio_extn_utils_compress_set_clk_rec_mode(struct audio_usecase *usecase);
int audio_extn_utils_compress_set_render_window(
            struct stream_out *out,
            struct audio_out_render_window_param *render_window);
#endif /* AUDIO_EXTN_H */
+135 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#define LOG_TAG "audio_hw_utils"
/* #define LOG_NDEBUG 0 */

#include <inttypes.h>
#include <errno.h>
#include <cutils/properties.h>
#include <cutils/config_utils.h>
@@ -1741,3 +1742,137 @@ int audio_extn_utils_compress_set_render_mode(struct stream_out *out __unused)
    return 0;
}
#endif

#ifdef SNDRV_COMPRESS_CLK_REC_MODE
int audio_extn_utils_compress_set_clk_rec_mode(
            struct audio_usecase *usecase)
{
    struct snd_compr_metadata metadata;
    struct stream_out *out = NULL;
    int ret = -EINVAL;

    if (usecase != NULL && usecase->type != PCM_PLAYBACK) {
        ALOGE("%s:: Invalid use case", __func__);
        goto exit;
    }

    out = usecase->stream.out;
    if (!out) {
        ALOGE("%s:: invalid stream", __func__);
        goto exit;
    }

    if (!is_offload_usecase(out->usecase)) {
        ALOGE("%s:: not supported for non offload session", __func__);
        goto exit;
    }

    if (out->render_mode != RENDER_MODE_AUDIO_STC_MASTER) {
        ALOGD("%s:: clk recovery is only supported in STC render mode",
                __func__);
        ret = 0;
        goto exit;
    }

    if (!out->compr) {
        ALOGD("%s:: Invalid compress handle",
                __func__);
        goto exit;
    }
    metadata.key = SNDRV_COMPRESS_CLK_REC_MODE;
    switch(usecase->out_snd_device) {
        case SND_DEVICE_OUT_HDMI:
        case SND_DEVICE_OUT_SPEAKER_AND_HDMI:
        case SND_DEVICE_OUT_DISPLAY_PORT:
        case SND_DEVICE_OUT_SPEAKER_AND_DISPLAY_PORT:
            metadata.value[0] = SNDRV_COMPRESS_CLK_REC_MODE_NONE;
            break;
        default:
            metadata.value[0] = SNDRV_COMPRESS_CLK_REC_MODE_AUTO;
            break;
    }

    ALOGD("%s:: clk recovery mode %d",__func__, metadata.value[0]);

    ret = compress_set_metadata(out->compr, &metadata);
    if(ret) {
        ALOGE("%s::error %s", __func__, compress_get_error(out->compr));
    }

exit:
    return ret;
}
#else
int audio_extn_utils_compress_set_clk_rec_mode(
            struct audio_usecase *usecase __unused)
{
    ALOGD("%s:: configuring render mode not supported", __func__);
    return 0;
}
#endif

#ifdef SNDRV_COMPRESS_RENDER_WINDOW
int audio_extn_utils_compress_set_render_window(
            struct stream_out *out,
            struct audio_out_render_window_param *render_window)
{
    struct snd_compr_metadata metadata;
    int ret = -EINVAL;

    ALOGD("%s:: render window start 0x%"PRIx64" end 0x%"PRIx64"",
          __func__,render_window->render_ws, render_window->render_we);

    if(render_window == NULL) {
        ALOGE("%s:: Invalid render_window", __func__);
        goto exit;
    }

    if (!is_offload_usecase(out->usecase)) {
        ALOGE("%s:: not supported for non offload session", __func__);
        goto exit;
    }

    if ((out->render_mode == RENDER_MODE_AUDIO_MASTER) ||
        (out->render_mode == RENDER_MODE_AUDIO_STC_MASTER)) {
        memcpy(&out->render_window, render_window,
               sizeof(struct audio_out_render_window_param));
    } else {
        ALOGD("%s:: only supported in timestamp mode, current "
              "render mode mode %d", __func__, out->render_mode);
        goto exit;
    }

    if (!out->compr) {
        ALOGW("%s:: offload session not yet opened,"
               "render window will be configure later", __func__);
        /* store render window to reconfigure in start_output_stream() */
       goto exit;
    }

    metadata.key = SNDRV_COMPRESS_RENDER_WINDOW;
    /*render window start value */
    metadata.value[0] = 0xFFFFFFFF & render_window->render_ws; /* lsb */
    metadata.value[1] = \
            (0xFFFFFFFF00000000 & render_window->render_ws) >> 32; /* msb*/
    /*render window end value */
    metadata.value[2] = 0xFFFFFFFF & render_window->render_we; /* lsb */
    metadata.value[3] = \
            (0xFFFFFFFF00000000 & render_window->render_we) >> 32; /* msb*/

    ret = compress_set_metadata(out->compr, &metadata);
    if(ret) {
        ALOGE("%s::error %s", __func__, compress_get_error(out->compr));
    }

exit:
    return ret;
}
#else
int audio_extn_utils_compress_set_render_window(
            struct stream_out *out __unused,
            struct audio_out_render_window_param *render_window __unused)
{
    ALOGD("%s:: configuring render window not supported", __func__);
    return 0;
}
#endif
+15 −0
Original line number Diff line number Diff line
@@ -710,6 +710,7 @@ int enable_audio_route(struct audio_device *adev,
{
    snd_device_t snd_device;
    char mixer_path[MIXER_PATH_MAX_LENGTH];
    struct stream_out *out = NULL;

    if (usecase == NULL)
        return -EINVAL;
@@ -730,6 +731,12 @@ int enable_audio_route(struct audio_device *adev,
    audio_extn_listen_update_stream_status(usecase, LISTEN_EVENT_STREAM_BUSY);
    audio_extn_utils_send_app_type_cfg(adev, usecase);
    audio_extn_utils_send_audio_calibration(adev, usecase);
    if ((usecase->type == PCM_PLAYBACK) && is_offload_usecase(usecase->id)) {
        out = usecase->stream.out;
        if (out && out->compr)
            audio_extn_utils_compress_set_clk_rec_mode(usecase);
    }

    strlcpy(mixer_path, use_case_table[usecase->id], MIXER_PATH_MAX_LENGTH);
    platform_add_backend_name(mixer_path, snd_device, usecase);
    ALOGD("%s: apply mixer and update path: %s", __func__, mixer_path);
@@ -2364,6 +2371,11 @@ int start_output_stream(struct stream_out *out)
        }

        audio_extn_utils_compress_set_render_mode(out);
        audio_extn_utils_compress_set_clk_rec_mode(uc_info);
        /* set render window if it was set before compress_open() */
        if (out->render_window.render_ws != 0 && out->render_window.render_we != 0)
            audio_extn_utils_compress_set_render_window(out,
                                            &out->render_window);

        audio_extn_dts_create_state_notifier_node(out->usecase);
        audio_extn_dts_notify_playback_state(out->usecase, 0, out->sample_rate,
@@ -4144,6 +4156,9 @@ int adev_open_output_stream(struct audio_hw_device *dev,
            out->render_mode = RENDER_MODE_AUDIO_NO_TIMESTAMP;
        }

        memset(&out->render_window, 0,
                sizeof(struct audio_out_render_window_param));

        out->send_new_metadata = 1;
        out->send_next_track_params = false;
        out->is_compr_metadata_avail = false;
+1 −0
Original line number Diff line number Diff line
@@ -265,6 +265,7 @@ struct stream_out {
    struct listnode qaf_offload_cmd_list;
    uint32_t platform_latency;
    render_mode_t render_mode;
    struct audio_out_render_window_param render_window; /*render winodw*/

    audio_offload_info_t info;
};
Loading