summaryrefslogtreecommitdiff
path: root/bluetooth/audio/2.1/types.hal
blob: e0dcc02cc039e6d93f73c674a20b8ef1b3a2f9e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
 * Copyright 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.bluetooth.audio@2.1;

import @2.0::BitsPerSample;
import @2.0::ChannelMode;
import @2.0::CodecCapabilities;
import @2.0::CodecConfiguration;
import @2.0::CodecType;
import @2.0::PcmParameters;
import @2.0::SampleRate;
import @2.0::SessionType;

enum SessionType : @2.0::SessionType {
    /** Used when encoded by Bluetooth Stack and streaming to LE Audio device */
    LE_AUDIO_SOFTWARE_ENCODING_DATAPATH,
    /** Used when decoded by Bluetooth Stack and streaming to audio framework */
    LE_AUDIO_SOFTWARE_DECODED_DATAPATH,
    /** Encoding is done by HW an there is control only */
    LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH,
    /** Decoding is done by HW an there is control only */
    LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH,
};

enum CodecType : @2.0::CodecType {
    LC3 = 0x20,
};

enum SampleRate : @2.0::SampleRate {
    RATE_8000 = 0x100,
    RATE_32000 = 0x200,
};

/** Used for Software Encoding audio feed parameters */
struct PcmParameters {
    SampleRate sampleRate;
    ChannelMode channelMode;
    BitsPerSample bitsPerSample;
    /** Data interval for data transfer */
    uint32_t dataIntervalUs;
};

enum Lc3FrameDuration : uint8_t {
    DURATION_10000US = 0x00,
    DURATION_7500US = 0x01,
};

/**
 * Used for Hardware Encoding/Decoding LC3 codec parameters.
 */
struct Lc3Parameters {
    /* PCM is Input for encoder, Output for decoder */
    BitsPerSample pcmBitDepth;

    /* codec-specific parameters */
    SampleRate samplingFrequency;
    Lc3FrameDuration frameDuration;
    /* length in octets of a codec frame */
    uint32_t octetsPerFrame;
    /* Number of blocks of codec frames per single SDU (Service Data Unit) */
    uint8_t blocksPerSdu;
};

/**
 * Used to specify the capabilities of the LC3 codecs supported by Hardware Encoding.
 */
struct Lc3CodecCapabilities {
    /* This is bitfield, if bit N is set, HW Offloader supports N+1 channels at the same time.
     * Example: 0x27 = 0b00100111: One, two, three or six channels supported.*/
    uint8_t supportedChannelCounts;
    Lc3Parameters lc3Capabilities;
};

/** Used to specify the capabilities of the different session types */
safe_union AudioCapabilities {
    PcmParameters pcmCapabilities;
    CodecCapabilities codecCapabilities;
    Lc3CodecCapabilities leAudioCapabilities;
};

/**
 * Used to configure a LC3 Hardware Encoding session.
 */
struct Lc3CodecConfiguration {
    /* This is also bitfield, specifying how the channels are ordered in the outgoing media packet.
     * Bit meaning is defined in Bluetooth Assigned Numbers. */
    uint32_t audioChannelAllocation;
    Lc3Parameters lc3Config;
};

/** Used to configure either a Hardware or Software Encoding session based on session type */
safe_union AudioConfiguration {
    PcmParameters pcmConfig;
    CodecConfiguration codecConfig;
    Lc3CodecConfiguration leAudioCodecConfig;
};