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

Commit 90ddcaa9 authored by Lakshman Chaluvaraju's avatar Lakshman Chaluvaraju Committed by Gerrit - the friendly Code Review server
Browse files

audio: Fix to return proper channel index masks supported for USB

Channel Index mask was coming zero when queried through
getChannelIndexMask API in Tunnel Mode for USB CTSVerifer
since supported channel mask array was not filled
ChannelIndexMask details.

Add changes to fill supported channel mask array with both channel
 maks and ChannelIndexMask in accordance with Non Tunnel Mode
so that USB CTSVerifer gets the proper channel and ChanneIndexmask
count when queried through corresponding API's.

CRs-Fixed:2330574

Change-Id: I9a07343536df6d8c676c1b9bf8c7a5b320ad8ad2
parent 9cc13492
Loading
Loading
Loading
Loading
+11 −14
Original line number Original line Diff line number Diff line
@@ -1703,28 +1703,25 @@ static inline int read_usb_sup_channel_masks(bool is_playback,
    if (channels > MAX_HIFI_CHANNEL_COUNT)
    if (channels > MAX_HIFI_CHANNEL_COUNT)
        channels = MAX_HIFI_CHANNEL_COUNT;
        channels = MAX_HIFI_CHANNEL_COUNT;


    channel_count = DEFAULT_CHANNEL_COUNT;

    if (is_playback) {
    if (is_playback) {
        // For playback we never report mono because the framework always outputs stereo
        // For playback we never report mono because the framework always outputs stereo
        channel_count = DEFAULT_CHANNEL_COUNT;
        // audio_channel_out_mask_from_count() does return positional masks for channel counts
        // audio_channel_out_mask_from_count() does return positional masks for channel counts
        // above 2 but we want indexed masks here. So we
        // above 2 but we want indexed masks here.
        for ( ; channel_count <= channels && num_masks < max_masks; channel_count++) {
        supported_channel_masks[num_masks++] = audio_channel_out_mask_from_count(channel_count);
        supported_channel_masks[num_masks++] = audio_channel_out_mask_from_count(channel_count);
        }
        for ( ; channel_count <= channels && num_masks < max_masks; channel_count++) {
            supported_channel_masks[num_masks++] =
                    audio_channel_mask_for_index_assignment_from_count(channel_count);
        }
    } else {
    } else {
        // For capture we report all supported channel masks from 1 channel up.
        channel_count = MIN_CHANNEL_COUNT;
        // audio_channel_in_mask_from_count() does the right conversion to either positional or
        // audio_channel_in_mask_from_count() does the right conversion to either positional or
        // indexed mask
        // indexed mask
        for ( ; channel_count <= channels && num_masks < max_masks; channel_count++) {
        supported_channel_masks[num_masks++] = audio_channel_in_mask_from_count(channel_count);
            supported_channel_masks[num_masks++] =
                    audio_channel_in_mask_from_count(channel_count);
    }
    }

    for (channel_count = channels; ((channel_count >= DEFAULT_CHANNEL_COUNT) &&
                                    (num_masks < max_masks)); channel_count--) {
            supported_channel_masks[num_masks++] =
                    audio_channel_mask_for_index_assignment_from_count(channel_count);
    }
    }

    ALOGV("%s: %s supported ch %d supported_channel_masks[0] %08x num_masks %d", __func__,
    ALOGV("%s: %s supported ch %d supported_channel_masks[0] %08x num_masks %d", __func__,
          is_playback ? "P" : "C", channels, supported_channel_masks[0], num_masks);
          is_playback ? "P" : "C", channels, supported_channel_masks[0], num_masks);
    return num_masks;
    return num_masks;