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

Commit f48adb4b authored by Manish Dewangan's avatar Manish Dewangan
Browse files

hal: Limit multichannel clips >48khz to 48Khz

-Configuring copp and backend at 48Khz for multichannel
clips > 48khz
-This is to address ADSP MIPS concern for playback of multichannel
 clip with sample rate > 48khz with pp (SA+ or SA+_HPX)

Change-Id: Ic010ce212011519e729601d067f8ddb6737c6b28
parent deb25d02
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -421,6 +421,7 @@ void audio_extn_utils_update_stream_app_type_cfg(void *platform,
                                  audio_format_t format,
                                  uint32_t sample_rate,
                                  uint32_t bit_width,
                                  audio_channel_mask_t channel_mask,
                                  struct stream_app_type_cfg *app_type_cfg);
int audio_extn_utils_send_app_type_cfg(struct audio_usecase *usecase);
void audio_extn_utils_send_audio_calibration(struct audio_device *adev,
+21 −0
Original line number Diff line number Diff line
@@ -452,12 +452,14 @@ void audio_extn_utils_update_stream_app_type_cfg(void *platform,
                                  audio_format_t format,
                                  uint32_t sample_rate,
                                  uint32_t bit_width,
                                  audio_channel_mask_t channel_mask,
                                  struct stream_app_type_cfg *app_type_cfg)
{
    struct listnode *node_i, *node_j, *node_k;
    struct streams_output_cfg *so_info;
    struct stream_format *sf_info;
    struct stream_sample_rate *ss_info;
    char value[PROPERTY_VALUE_MAX] = {0};

    if ((24 == bit_width) &&
        (devices & AUDIO_DEVICE_OUT_SPEAKER)) {
@@ -468,6 +470,16 @@ void audio_extn_utils_update_stream_app_type_cfg(void *platform,
        ALOGI("%s Allowing 24-bit playback on speaker ONLY at default sampling rate", __func__);
    }

    property_get("audio.playback.mch.downsample",value,"");
    if (!strncmp("true", value, sizeof("true"))) {
        if ((popcount(channel_mask) > 2) &&
                (sample_rate > CODEC_BACKEND_DEFAULT_SAMPLE_RATE) &&
                !(flags & AUDIO_OUTPUT_FLAG_COMPRESS_PASSTHROUGH))  {
                    sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
                    ALOGD("%s: MCH session defaulting sample rate to %d",
                               __func__, sample_rate);
        }
    }
    ALOGV("%s: flags: %x, format: %x sample_rate %d",
           __func__, flags, format, sample_rate);
    list_for_each(node_i, streams_output_cfg_list) {
@@ -509,6 +521,7 @@ int audio_extn_utils_send_app_type_cfg(struct audio_usecase *usecase)
    struct mixer_ctl *ctl;
    int pcm_device_id, acdb_dev_id, snd_device = usecase->out_snd_device;
    int32_t sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
    char value[PROPERTY_VALUE_MAX] = {0};

    ALOGV("%s", __func__);

@@ -558,6 +571,14 @@ int audio_extn_utils_send_app_type_cfg(struct audio_usecase *usecase)
        sample_rate = out->app_type_cfg.sample_rate;
    }

    property_get("audio.playback.mch.downsample",value,"");
    if (!strncmp("true", value, sizeof("true"))) {
        if ((popcount(out->channel_mask) > 2) &&
               (out->sample_rate > CODEC_BACKEND_DEFAULT_SAMPLE_RATE) &&
               !(out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_PASSTHROUGH))
           sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
    }

    app_type_cfg[len++] = out->app_type_cfg.app_type;
    app_type_cfg[len++] = acdb_dev_id;
    if (((out->format == AUDIO_FORMAT_E_AC3) ||
+3 −1
Original line number Diff line number Diff line
@@ -954,6 +954,7 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id)
                                                usecase->stream.out->format,
                                                usecase->stream.out->sample_rate,
                                                usecase->stream.out->bit_width,
                                                usecase->stream.out->channel_mask,
                                                &usecase->stream.out->app_type_cfg);
        ALOGI("%s Selected apptype: %d", __func__, usecase->stream.out->app_type_cfg.app_type);
    }
@@ -2978,7 +2979,8 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
    audio_extn_utils_update_stream_app_type_cfg(adev->platform,
                                                &adev->streams_output_cfg_list,
                                                devices, flags, format, out->sample_rate,
                                                out->bit_width, &out->app_type_cfg);
                                                out->bit_width, out->channel_mask,
                                                &out->app_type_cfg);
    if ((out->usecase == USECASE_AUDIO_PLAYBACK_PRIMARY) ||
        (flags & AUDIO_OUTPUT_FLAG_PRIMARY)) {
        /* Ensure the default output is not selected twice */
+17 −0
Original line number Diff line number Diff line
@@ -3441,6 +3441,7 @@ bool platform_check_codec_backend_cfg(struct audio_device* adev,
    struct stream_out *out = NULL;
    unsigned int bit_width = CODEC_BACKEND_DEFAULT_BIT_WIDTH;
    unsigned int sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
    char value[PROPERTY_VALUE_MAX] = {0};

    // For voice calls use default configuration
    // force routing is not required here, caller will do it anyway
@@ -3480,6 +3481,22 @@ bool platform_check_codec_backend_cfg(struct audio_device* adev,
    if (16 == bit_width) {
        sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
    }

    //check if mulitchannel clip needs to be down sampled to 48k
    property_get("audio.playback.mch.downsample",value,"");
    if (!strncmp("true", value, sizeof("true"))) {
        out = usecase->stream.out;
        if ((popcount(out->channel_mask) > 2) &&
                      (out->sample_rate > CODEC_BACKEND_DEFAULT_SAMPLE_RATE) &&
                      !(out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_PASSTHROUGH)) {
           sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
          /* update out sample rate to reflect current backend sample rate  */
           out->sample_rate = sample_rate;
           ALOGD("%s: MCH session defaulting sample rate to %d",
                        __func__, sample_rate);
         }
    }

    // 24 bit playback on speakers is allowed through 48 khz backend only
    // bit width re-configured based on platform info
    if ((24 == bit_width) &&
+16 −0
Original line number Diff line number Diff line
@@ -3133,6 +3133,7 @@ bool platform_check_codec_backend_cfg(struct audio_device* adev,
    struct stream_out *out = NULL;
    unsigned int bit_width = CODEC_BACKEND_DEFAULT_BIT_WIDTH;
    unsigned int sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
    char value[PROPERTY_VALUE_MAX] = {0};

    // For voice calls use default configuration
    // force routing is not required here, caller will do it anyway
@@ -3172,6 +3173,21 @@ bool platform_check_codec_backend_cfg(struct audio_device* adev,
    if (16 == bit_width) {
        sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
    }

    //check if mulitchannel clip needs to be down sampled  to 48k
    property_get("audio.playback.mch.downsample",value,"");
    if (!strncmp("true", value, sizeof("true"))) {
        out = usecase->stream.out;
        if ((popcount(out->channel_mask) > 2) &&
                      (out->sample_rate > CODEC_BACKEND_DEFAULT_SAMPLE_RATE) &&
                      !(out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_PASSTHROUGH)) {
            /* update out sample rate to reflect current backend sample rate  */
            sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
            ALOGD("%s: MCH session defaulting sample rate to %d",
                 __func__, sample_rate);
        }
    }

    // 24 bit playback on speakers is allowed through 48 khz backend only
    // bit width re-configured based on platform info
    if ((24 == bit_width) &&