Bluetooth: Move A2DP HAL 2.0 interface to opensource

- Moved A2DP HAL 2.0 interface to opensource.

CRs-Fixed: 2467348
Change-Id: I57ff44907706b54c5d5a2a2a1f6ee274769498ef
This commit is contained in:
Srinu Jella
2019-05-17 15:47:40 +05:30
committed by Gerrit - the friendly Code Review server
parent 6b55634529
commit a01c238d7f
6 changed files with 677 additions and 0 deletions

View File

@@ -25,3 +25,8 @@ hidl_package_root {
name: "vendor.qti.hardware.servicetracker",
path: "vendor/qcom/opensource/interfaces/servicetracker",
}
hidl_package_root {
name: "vendor.qti.hardware.bluetooth_audio",
path: "vendor/qcom/opensource/interfaces/bluetooth_audio",
}

View File

@@ -0,0 +1,87 @@
/*
* Copyright (c) 2019 The Linux Foundation. All rights reserved.
* Not a contribution.
*/
/*
* Copyright 2018 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 vendor.qti.hardware.bluetooth_audio@2.0;
/**
* HAL interface from the Audio HAL to the Bluetooth stack
*
* The Audio HAL calls methods in this interface to start, suspend, and stop
* an audio stream. These calls return immediately and the results, if any,
* are sent over the IBluetoothAudioProvider interface.
*
* Moreover, the Audio HAL can also get the presentation position of the stream
* and provide stream metadata.
*
* Note: For HIDL APIs with a "generates" statement, the callback parameter used
* for return value must be invoked synchronously before the API call returns.
*/
interface IBluetoothAudioPort {
/**
* This indicates that the caller of this method has opened the data path
* and wants to start an audio stream. The caller must wait for a
* IBluetoothAudioProvider.streamStarted(Status) call.
*/
startStream();
/**
* This indicates that the caller of this method wants to suspend the audio
* stream. The caller must wait for the Bluetooth process to call
* IBluetoothAudioProvider.streamSuspended(Status). The caller still keeps
* the data path open.
*/
suspendStream();
/**
* This indicates that the caller of this method wants to stop the audio
* stream. The data path will be closed after this call. There is no
* callback from the IBluetoothAudioProvider interface even though the
* teardown is asynchronous.
*/
stopStream();
/**
* Get the audio presentation position.
*
* @return status the command status
* @return remoteDeviceAudioDelayNanos the audio delay from when the remote
* device (e.g. headset) receives audio data to when the device plays the
* sound. If the delay is unknown, the value is set to zero.
* @return transmittedOctets the number of audio data octets that were sent
* to a remote device. This excludes octets that have been written to the
* data path but have not been sent to the remote device. The count is
* not reset until stopStream() is called. If the software data path is
* unused (e.g. A2DP Hardware Offload), the value is set to 0.
* @return transmittedOctetsTimeStamp the value of CLOCK_MONOTONIC
* corresponding to transmittedOctets. If the software data path is
* unused (e.g., for A2DP Hardware Offload), the value is set to zero.
*/
getPresentationPosition() generates (Status status,
uint64_t remoteDeviceAudioDelayNanos, uint64_t transmittedOctets,
TimeSpec transmittedOctetsTimeStamp);
/**
* Called when Audio remorts Aptx Adaptive operating mode has changes
*
* @param aptxMode: Value of the current Aptx Adaptive Mode
*/
updateAptxMode(uint16_t aptxMode);
};

View File

@@ -0,0 +1,92 @@
/*
* Copyright (c) 2019 The Linux Foundation. All rights reserved.
* Not a contribution.
*/
/*
* Copyright 2018 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 vendor.qti.hardware.bluetooth_audio@2.0;
import IBluetoothAudioPort;
/**
* HAL interface from the Bluetooth stack to the Audio HAL
*
* The Bluetooth stack calls methods in this interface to start and end audio
* sessions and sends callback events to the Audio HAL.
*
* Note: For HIDL APIs with a "generates" statement, the callback parameter used
* for return value must be invoked synchronously before the API call returns.
*/
interface IBluetoothAudioProvider {
/**
* This method indicates that the Bluetooth stack is ready to stream audio.
* It registers an instance of IBluetoothAudioPort with and provides the
* current negotiated codec to the Audio HAL. After this method is called,
* the Audio HAL can invoke IBluetoothAudioPort.startStream().
*
* Note: endSession() must be called to unregister this IBluetoothAudioPort
*
* @param hostIf An instance of IBluetoothAudioPort for stream control
* @param audioConfig The audio configuration negotiated with the remote
* device. The PCM parameters are set if software based encoding,
* otherwise the correct codec configuration is used for hardware
* encoding.
*
* @return status One of the following
* SUCCESS if this IBluetoothAudioPort was successfully registered with
* the Audio HAL
* UNSUPPORTED_CODEC_CONFIGURATION if the Audio HAL cannot register this
* IBluetoothAudioPort with the given codec configuration
* FAILURE if the Audio HAL cannot register this IBluetoothAudioPort for
* any other reason
* @return dataMQ The fast message queue for audio data from this provider.
* Audio data will be in PCM format as specified by the
* audioConfig.pcmConfig parameter.
* Invalid if streaming is offloaded to hardware or on failure.
*/
startSession(IBluetoothAudioPort hostIf, AudioConfiguration audioConfig)
generates (Status status, fmq_sync<uint8_t> dataMQ);
/**
* Callback for IBluetoothAudioPort.startStream()
*
* @param status SUCCESS or FAILURE
*/
streamStarted(Status status);
/**
* Callback for IBluetoothAudioPort.suspendStream()
*
* @param status SUCCESS or FAILURE
*/
streamSuspended(Status status);
/**
* Call to update Sesion Parameters in runtime
*
*/
updateSessionParams(SessionParams sessionParams);
/**
* Ends the current session and unregisters the IBluetoothAudioPort
* interface.
*/
endSession();
};

View File

@@ -0,0 +1,76 @@
/*
* Copyright (c) 2019 The Linux Foundation. All rights reserved.
* Not a contribution.
*/
/*
* Copyright 2018 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 vendor.qti.hardware.bluetooth_audio@2.0;
import IBluetoothAudioProvider;
/**
* This factory allows a HAL implementation to be split into multiple
* independent providers.
*
* When the Bluetooth stack is ready to create an audio session, it must first
* obtain the IBluetoothAudioProvider for that session type by calling
* openProvider().
*
* Note: For HIDL APIs with a "generates" statement, the callback parameter used
* for return value must be invoked synchronously before the API call returns.
*/
interface IBluetoothAudioProvidersFactory {
/**
* Opens an audio provider for a session type. To close the provider, it is
* necessary to release references to the returned provider object.
*
* @param sessionType The session type (e.g.
* A2DP_SOFTWARE_ENCODING_DATAPATH).
*
* @return status One of the following
* SUCCESS if the Audio HAL successfully opens the provider with the
* given session type
* FAILURE if the Audio HAL cannot open the provider
* @return provider The provider of the specified session type
*/
openProvider(SessionType sessionType)
generates (Status status, IBluetoothAudioProvider provider);
/**
* Gets a list of audio capabilities for a session type.
*
* For software encoding, the PCM capabilities are returned.
* For hardware encoding, the supported codecs and their capabilities are
* returned.
*
* @param sessionType The session type (e.g.
* A2DP_SOFTWARE_ENCODING_DATAPATH).
* @return audioCapabilities A list containing all the capabilities
* supported by the sesson type. The capabilities is a list of
* available options when configuring the codec for the session.
* For software encoding it is the PCM data rate.
* For hardware encoding it is the list of supported codecs and their
* capabilities.
* If a provider isn't supported, an empty list should be returned.
* Note: Only one entry should exist per codec when using hardware
* encoding.
*/
getProviderCapabilities(SessionType sessionType)
generates (vec<AudioCapabilities> audioCapabilities);
};

View File

@@ -0,0 +1,384 @@
/*
* Copyright (c) 2019 The Linux Foundation. All rights reserved.
* Not a contribution.
*/
/*
* Copyright 2018 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 vendor.qti.hardware.bluetooth_audio@2.0;
/**
* The different audio parameter structs are used to provide a method to list
* all the Capabilities of a codec as well as to configure the codecs. All
* fields are bitfields unless specified. If used as a configuration, only one
* bit may be enabled. If used for Capabilities, enable all bits corresponding to
* supported features.
*/
/**
* POSIX timespec.
*/
struct TimeSpec {
uint64_t tvSec; // seconds
uint64_t tvNSec; // nanoseconds
};
enum Status : uint8_t {
SUCCESS = 0x00,
/** Codec configuration not supported by the audio platform */
UNSUPPORTED_CODEC_CONFIGURATION,
/** Any other failure */
FAILURE,
/* Pending response from Sink*/
SINK_NOT_READY,
/* Telephony Call in progress*/
CALL_IN_PROGRESS,
/* Short wait error */
SW_ERROR,
/* Long wait error */
LW_ERROR,
/* disconnection in progress */
FAILURE_DISC_IN_PROGRESS,
/* No wait failure */
FAILURE_NO_WAIT
};
enum SessionType : uint8_t {
UNKNOWN,
/** A2DP legacy that AVDTP media is encoded by Bluetooth Stack */
A2DP_SOFTWARE_ENCODING_DATAPATH,
/** The encoding of AVDTP media is done by HW and there is control only */
A2DP_HARDWARE_OFFLOAD_DATAPATH,
/** Used when encoded by Bluetooth Stack and streaming to Hearing Aid */
HEARING_AID_SOFTWARE_ENCODING_DATAPATH,
};
enum CodecType : uint32_t {
UNKNOWN = 0x00,
SBC = 0x01,
AAC = 0x02,
APTX = 0x04,
APTX_HD = 0x08,
LDAC = 0x10,
BA_CELT = 0x11,
APTX_ADAPTIVE = 0x12,
APTX_TWS = 0x14,
};
enum SampleRate : uint32_t {
RATE_UNKNOWN = 0x00,
RATE_44100 = 0x01,
RATE_48000 = 0x02,
RATE_88200 = 0x04,
RATE_96000 = 0x08,
RATE_176400 = 0x10,
RATE_192000 = 0x20,
RATE_16000 = 0x40,
RATE_24000 = 0x60,
RATE_32000 = 0x80,
};
enum BitsPerSample : uint8_t {
BITS_UNKNOWN = 0x00,
BITS_16 = 0x01,
BITS_24 = 0x02,
BITS_32 = 0x04,
};
enum ChannelMode : uint8_t {
UNKNOWN = 0x00,
MONO = 0x01,
STEREO = 0x02,
};
enum SbcChannelMode : uint8_t {
/** Channel Mode: 4 bits */
UNKNOWN = 0x00,
JOINT_STEREO = 0x01,
STEREO = 0x02,
DUAL = 0x04,
MONO = 0x08,
};
enum SbcBlockLength : uint8_t {
BLOCKS_4 = 0x80,
BLOCKS_8 = 0x40,
BLOCKS_12 = 0x20,
BLOCKS_16 = 0x10,
};
enum SbcNumSubbands : uint8_t {
SUBBAND_4 = 0x08,
SUBBAND_8 = 0x04,
};
enum SbcAllocMethod : uint8_t {
/** SNR */
ALLOC_MD_S = 0x02,
/** Loudness */
ALLOC_MD_L = 0x01,
};
enum AacObjectType : uint8_t {
/** MPEG-2 Low Complexity. Support is Mandatory. */
MPEG2_LC = 0x80,
/** MPEG-4 Low Complexity. Support is Optional. */
MPEG4_LC = 0x40,
/** MPEG-4 Long Term Prediction. Support is Optional. */
MPEG4_LTP = 0x20,
/** MPEG-4 Scalable. Support is Optional. */
MPEG4_SCALABLE = 0x10,
};
enum AacVariableBitRate : uint8_t {
ENABLED = 0x80,
DISABLED = 0x00,
};
enum AptxAdaptiveChannelMode : int32_t {
/** Channel Mode: 5 bits */
UNCHANGED = -1,
JOINT_STEREO = 0,
MONO = 1,
DUAL_MONO = 2,
TWS_STEREO = 4,
EARBUD = 8,
TWS_MONO = 10,
UNKNOWN = 0xFF,
};
enum AptxMode : uint32_t {
/** Aptx Adaptive Mode: 32 bits */
UNKNOWN = 0x00,
HQ = 0x1000,
LL = 0x2000,
ULL = 0x4000,
SCAN_CONTROL = 0x8000,
};
enum InputMode : uint32_t {
/** Aptx Adaptive Input Mode: 32 bits */
STEREO = 0x00,
DUAL_MONO = 0x01,
};
struct AptxSinkBuffering {
uint8_t minSinkBuff_LL;
uint8_t maxSinkBuff_LL;
uint8_t minSinkBuff_HQ;
uint8_t maxSinkBuff_HQ;
uint8_t minSinkBuff_TWS;
uint8_t maxSinkBuff_TWS;
};
struct AptxAdaptive_TTP {
uint8_t TTP_LL_low;
uint8_t TTP_LL_high;
uint8_t TTP_HQ_low;
uint8_t TTP_HQ_high;
uint8_t TTP_TWS_low;
uint8_t TTP_TWS_high;
};
enum LdacChannelMode : uint8_t {
/** Channel Mode: 3 bits */
UNKNOWN = 0x00,
STEREO = 0x01,
DUAL = 0x02,
MONO = 0x04,
};
enum LdacQualityIndex : uint8_t {
// 990kbps
QUALITY_HIGH = 0x00,
// 660kbps
QUALITY_MID = 0x01,
// 330kbps
QUALITY_LOW = 0x02,
// Adaptive Bit Rate mode
QUALITY_ABR = 0x7F,
};
enum SessionParamType : uint8_t {
UNKNOWN = 0x00,
MTU = 0x01,
BITRATE = 0x02,
SINK_LATENCY = 0x03,
};
/** Used for Software Encoding audio feed parameters */
struct PcmParameters {
SampleRate sampleRate;
ChannelMode channelMode;
BitsPerSample bitsPerSample;
};
/**
* Used for Hardware Encoding SBC codec parameters.
* minBitpool and maxBitpool are not bitfields.
*/
struct SbcParameters {
SampleRate sampleRate;
SbcChannelMode channelMode;
SbcBlockLength blockLength;
SbcNumSubbands numSubbands;
SbcAllocMethod allocMethod;
BitsPerSample bitsPerSample;
uint8_t minBitpool;
uint8_t maxBitpool;
};
/** Used for Hardware Encoding AAC codec parameters */
struct AacParameters {
AacObjectType objectType;
SampleRate sampleRate;
ChannelMode channelMode;
AacVariableBitRate variableBitRateEnabled;
BitsPerSample bitsPerSample;
bool frameControlEnabled;
};
/**
* Used for Hardware Encoding LDAC codec parameters
* Only used when configuring the codec. When Capabilities are requested, this
* field is left empty since all qualities must be supported. Not a bitfield.
*/
struct LdacParameters {
SampleRate sampleRate;
LdacChannelMode channelMode;
LdacQualityIndex qualityIndex;
BitsPerSample bitsPerSample;
};
/** Used for Hardware Encoding AptX and AptX-HD codec parameters */
struct AptxParameters {
SampleRate sampleRate;
ChannelMode channelMode;
BitsPerSample bitsPerSample;
};
/** Used for Hardware Encoding AptX-Adaptive codec parameters */
struct AptxAdaptiveParameters {
SampleRate sampleRate;
AptxAdaptiveChannelMode channelMode;
BitsPerSample bitsPerSample;
AptxMode aptxMode;
AptxSinkBuffering sinkBuffering;
AptxAdaptive_TTP ttp;
InputMode inputMode;
uint32_t inputFadeDuration;
uint8_t[25] aptxAdaptiveConfigStream;
};
/** Used for Hardware Encoding AptX TWS codec parameters */
struct AptxTwsParameters {
SampleRate sampleRate;
ChannelMode channelMode;
uint8_t syncMode;
};
/** Used for Hardware Encoding BA CELT codec parameters */
struct BaCeltParameters {
SampleRate sampleRate;
ChannelMode channelMode;
uint16_t frameSize;
uint16_t complexity;
uint16_t predictionMode;
uint16_t vbrFlag;
};
/**
* Used to specify the capabilities of the codecs supported by Hardware Encoding.
* AptX and AptX-HD both use the AptxParameters field.
*/
struct CodecCapabilities {
CodecType codecType;
union Capabilities {
SbcParameters sbcCapabilities;
AacParameters aacCapabilities;
LdacParameters ldacCapabilities;
AptxParameters aptxCapabilities;
AptxAdaptiveParameters aptxAdaptiveCapabilities;
AptxTwsParameters aptxTwsCapabilities;
BaCeltParameters baCeltCapabilities;
} capabilities;
};
struct SinkLatency {
uint64_t remoteDeviceAudioDelay;
uint64_t transmittedOctets;
TimeSpec transmittedOctetsTimeStamp;
};
/**
* Used for proactive update of Session Parameters to server
*/
struct SessionParams {
SessionParamType paramType;
union Param {
uint16_t mtu;
uint32_t encodedAudioBitrate;
SinkLatency sinkLatency;
} param;
};
/** Used to specify the capabilities of the different session types. */
union AudioCapabilities {
PcmParameters pcmCapabilities;
CodecCapabilities codecCapabilities;
};
/**
* Used to configure a Hardware Encoding session.
* AptX and AptX-HD both use the AptxParameters field.
*/
struct CodecConfiguration {
CodecType codecType;
/**
* The encoded audio bitrate in bits / second.
* 0x00000000 - The audio bitrate is not specified / unused
* 0x00000001 - 0x00FFFFFF - Encoded audio bitrate in bits/second
* 0x01000000 - 0xFFFFFFFF - Reserved
*
* The HAL needs to support all legal bitrates for the selected codec.
*/
uint32_t encodedAudioBitrate;
/** Peer MTU (in octets) */
uint16_t peerMtu;
/** Content protection by SCMS-T */
bool isScmstEnabled;
/** Scrambling Requirement */
bool isScramblingEnabled;
union CodecSpecific {
SbcParameters sbcConfig;
AacParameters aacConfig;
LdacParameters ldacConfig;
AptxParameters aptxConfig;
AptxAdaptiveParameters aptxAdaptiveConfig;
AptxTwsParameters aptxTwsConfig;
BaCeltParameters baCeltConfig;
} config;
};
/** Used to configure either a Hardware or Software Encoding session based on session type */
union AudioConfiguration {
PcmParameters pcmConfig;
CodecConfiguration codecConfig;
};

View File

@@ -0,0 +1,33 @@
#Copyright (c) 2019, The Linux Foundation. All rights reserved.
#Redistribution and use in source and binary forms, with or without
#modification, are permitted provided that the following conditions are
#met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of The Linux Foundation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
#WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
#ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
#BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
#CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
#SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
#BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
#OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
#IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#HAL released in Android Q
#Bluetooth Audio
e318824d1eb40ba520316343fbbd3683b90c011e2c66338d8db7aa801da222e7 vendor.qti.hardware.bluetooth_audio@2.0::types
4efce82a613cd7e4886a8d75328d1476366a48a7d221b3238c5c0a084663bb9a vendor.qti.hardware.bluetooth_audio@2.0::IBluetoothAudioPort
80850a7fcdf4bcd89df865226d4e16862d9ca4a832b2e6677e0dd7bb9297e037 vendor.qti.hardware.bluetooth_audio@2.0::IBluetoothAudioProvider
95dfb82e79fc47813b8f4f773b1eb60f79ea7e42e12642356bdf14e144089758 vendor.qti.hardware.bluetooth_audio@2.0::IBluetoothAudioProvidersFactory