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

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

Merge "hal: Support for FLAC 24 bit format in offload path"

parents 28669554 3ee55c65
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -137,6 +137,10 @@ ifeq ($(strip $(AUDIO_FEATURE_ENABLED_MULTIPLE_TUNNEL)), true)
    LOCAL_CFLAGS += -DMULTIPLE_OFFLOAD_ENABLED
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_EXTN_FLAC_DECODER)),true)
    LOCAL_CFLAGS += -DQTI_FLAC_DECODER
endif

LOCAL_SHARED_LIBRARIES := \
	liblog \
	libcutils \
+10 −0
Original line number Diff line number Diff line
@@ -51,6 +51,16 @@
#define AUDIO_DEVICE_IN_FM_RX_A2DP (AUDIO_DEVICE_BIT_IN | 0x10000)
#endif

#ifndef QTI_FLAC_DECODER
#define AUDIO_FORMAT_FLAC 0x19000000UL
#define AUDIO_OFFLOAD_CODEC_FLAC_MIN_BLK_SIZE "music_offload_flac_min_blk_size"
#define AUDIO_OFFLOAD_CODEC_FLAC_MAX_BLK_SIZE "music_offload_flac_max_blk_size"
#define AUDIO_OFFLOAD_CODEC_FLAC_MIN_FRAME_SIZE "music_offload_flac_min_frame_size"
#define AUDIO_OFFLOAD_CODEC_FLAC_MAX_FRAME_SIZE "music_offload_flac_max_frame_size"
#define PCM_OUTPUT_BIT_WIDTH (CODEC_BACKEND_DEFAULT_BIT_WIDTH)
#else
#define PCM_OUTPUT_BIT_WIDTH (config->offload_info.bit_width)
#endif

#define MAX_LENGTH_MIXER_CONTROL_IN_INT                  (128)

+58 −5
Original line number Diff line number Diff line
@@ -209,7 +209,8 @@ static bool is_supported_format(audio_format_t format)
    if (format == AUDIO_FORMAT_MP3 ||
        format == AUDIO_FORMAT_AAC ||
        format == AUDIO_FORMAT_PCM_16_BIT_OFFLOAD ||
        format == AUDIO_FORMAT_PCM_24_BIT_OFFLOAD)
        format == AUDIO_FORMAT_PCM_24_BIT_OFFLOAD ||
        format == AUDIO_FORMAT_FLAC)
           return true;

    return false;
@@ -230,6 +231,9 @@ static int get_snd_codec_id(audio_format_t format)
    case AUDIO_FORMAT_PCM_24_BIT_OFFLOAD:
        id = SND_AUDIOCODEC_PCM;
        break;
    case AUDIO_FORMAT_FLAC:
        id = SND_AUDIOCODEC_FLAC;
        break;
    default:
        ALOGE("%s: Unsupported audio format :%x", __func__, format);
    }
@@ -447,6 +451,15 @@ static void check_usecases_codec_backend(struct audio_device *adev,
     * because of the limitation that both the devices cannot be enabled
     * at the same time as they share the same backend.
     */
    /*
     * This call is to check if we need to force routing for a particular stream
     * If there is a backend configuration change for the device when a
     * new stream starts, then ADM needs to be closed and re-opened with the new
     * configuraion. This call check if we need to re-route all the streams
     * associated with the backend. Touch tone + 24 bit playback.
     */
    bool force_routing = platform_check_and_set_codec_backend_cfg(adev, uc_info);

    /* Disable all the usecases on the shared backend other than the
       specified usecase */
    for (i = 0; i < AUDIO_USECASE_MAX; i++)
@@ -456,7 +469,7 @@ static void check_usecases_codec_backend(struct audio_device *adev,
        usecase = node_to_item(node, struct audio_usecase, list);
        if (usecase->type != PCM_CAPTURE &&
                usecase != uc_info &&
                usecase->out_snd_device != snd_device &&
                (usecase->out_snd_device != snd_device || force_routing)  &&
                usecase->devices & AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND) {
            ALOGV("%s: Usecase (%s) is active on (%s) - disabling ..",
                  __func__, use_case_table[usecase->id],
@@ -1501,6 +1514,29 @@ static int parse_compress_metadata(struct stream_out *out, struct str_parms *par
        out->send_new_metadata = 1;
    }

    if (out->format == AUDIO_FORMAT_FLAC) {
        ret = str_parms_get_str(parms, AUDIO_OFFLOAD_CODEC_FLAC_MIN_BLK_SIZE, value, sizeof(value));
        if (ret >= 0) {
            out->compr_config.codec->options.flac_dec.min_blk_size = atoi(value);
            out->send_new_metadata = 1;
        }
        ret = str_parms_get_str(parms, AUDIO_OFFLOAD_CODEC_FLAC_MAX_BLK_SIZE, value, sizeof(value));
        if (ret >= 0) {
            out->compr_config.codec->options.flac_dec.max_blk_size = atoi(value);
            out->send_new_metadata = 1;
        }
        ret = str_parms_get_str(parms, AUDIO_OFFLOAD_CODEC_FLAC_MIN_FRAME_SIZE, value, sizeof(value));
        if (ret >= 0) {
            out->compr_config.codec->options.flac_dec.min_frame_size = atoi(value);
            out->send_new_metadata = 1;
        }
        ret = str_parms_get_str(parms, AUDIO_OFFLOAD_CODEC_FLAC_MAX_FRAME_SIZE, value, sizeof(value));
        if (ret >= 0) {
            out->compr_config.codec->options.flac_dec.max_frame_size = atoi(value);
            out->send_new_metadata = 1;
        }
    }

    ret = str_parms_get_str(parms, AUDIO_OFFLOAD_CODEC_SAMPLE_RATE, value, sizeof(value));
    if(ret >= 0)
        is_meta_data_params = true;
@@ -2335,6 +2371,7 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
    out->channel_mask = AUDIO_CHANNEL_OUT_STEREO;
    out->supported_channel_masks[0] = AUDIO_CHANNEL_OUT_STEREO;
    out->handle = handle;
    out->bit_width = CODEC_BACKEND_DEFAULT_BIT_WIDTH;

    /* Init use case and pcm_config */
    if ((out->flags == AUDIO_OUTPUT_FLAG_DIRECT) &&
@@ -2409,6 +2446,7 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
        out->stream.resume = out_resume;
        out->stream.drain = out_drain;
        out->stream.flush = out_flush;
        out->bit_width = CODEC_BACKEND_DEFAULT_BIT_WIDTH;

        if (audio_extn_is_dolby_format(config->offload_info.format))
            out->compr_config.codec->id =
@@ -2432,13 +2470,26 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
        out->compr_config.codec->ch_in =
                    popcount(config->channel_mask);
        out->compr_config.codec->ch_out = out->compr_config.codec->ch_in;
        out->compr_config.codec->format = SND_AUDIOSTREAMFORMAT_RAW;
        out->bit_width = PCM_OUTPUT_BIT_WIDTH;

        if (config->offload_info.format == AUDIO_FORMAT_AAC)
            out->compr_config.codec->format = SND_AUDIOSTREAMFORMAT_RAW;
        if (config->offload_info.format == AUDIO_FORMAT_PCM_16_BIT_OFFLOAD)
            out->compr_config.codec->format = SNDRV_PCM_FORMAT_S16_LE;
        else if(config->offload_info.format == AUDIO_FORMAT_PCM_24_BIT_OFFLOAD)
        if(config->offload_info.format == AUDIO_FORMAT_PCM_24_BIT_OFFLOAD)
            out->compr_config.codec->format = SNDRV_PCM_FORMAT_S24_LE;

        if (out->bit_width == 24) {
            out->compr_config.codec->format = SNDRV_PCM_FORMAT_S24_LE;
        }

        if (out->bit_width == 24 && !platform_check_24_bit_support()) {
            ALOGW("24 bit support is not enabled, using 16 bit backend");
            out->compr_config.codec->format = SNDRV_PCM_FORMAT_S16_LE;
        }

        out->compr_config.codec->options.flac_dec.sample_size = out->bit_width;

        if (flags & AUDIO_OUTPUT_FLAG_NON_BLOCKING)
            out->non_blocking = 1;

@@ -3005,6 +3056,8 @@ static int adev_open(const hw_module_t *module, const char *name,
    adev->bluetooth_nrec = true;
    adev->acdb_settings = TTY_MODE_OFF;
    /* adev->cur_hdmi_channels = 0;  by calloc() */
    adev->cur_codec_backend_samplerate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
    adev->cur_codec_backend_bit_width = CODEC_BACKEND_DEFAULT_BIT_WIDTH;
    adev->snd_dev_ref_cnt = calloc(SND_DEVICE_MAX, sizeof(int));
    voice_init(adev);
    list_init(&adev->usecase_list);
+3 −0
Original line number Diff line number Diff line
@@ -188,6 +188,7 @@ struct stream_out {
    void *offload_cookie;
    struct compr_gapless_mdata gapless_mdata;
    int send_new_metadata;
    unsigned int bit_width;

    struct audio_device *dev;
};
@@ -272,6 +273,8 @@ struct audio_device {
    bool bt_wb_speech_enabled;

    int snd_card;
    unsigned int cur_codec_backend_samplerate;
    unsigned int cur_codec_backend_bit_width;
    void *platform;
    unsigned int offload_usecases_state;
    void *visualizer_lib;
+7 −0
Original line number Diff line number Diff line
@@ -2041,3 +2041,10 @@ uint32_t platform_get_pcm_offload_buffer_size(audio_offload_info_t* info)
    return fragment_size;
}

bool platform_check_24_bit_support() {
    return false;
}

bool platform_check_and_set_codec_backend_cfg(struct audio_device* adev, struct audio_usecase *usecase) {
    return false;
}
Loading