summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Kapdi2018-02-07 17:08:01 -0600
committerPetri Gynther2018-03-12 14:18:52 -0500
commite65621491504030ffb960978b9e05edea7c83961 (patch)
tree914f8ba6d3f89ca2f2a0bfe2246d076836a03f49 /bluetooth/a2dp
parent99a619059adcc719fab5867fbd86f71b4f3ea44d (diff)
downloadplatform-hardware-interfaces-e65621491504030ffb960978b9e05edea7c83961.tar.gz
platform-hardware-interfaces-e65621491504030ffb960978b9e05edea7c83961.tar.xz
platform-hardware-interfaces-e65621491504030ffb960978b9e05edea7c83961.zip
Bluetooth: A2DP offload HIDL
Interface for Bluetooth A2DP offload feature. Bug: 63932139 Bug: 72242910 Test: Manual; TestTracker/148125 Change-Id: I3649800dfe3e1a2d66b76859be87e01ee58d2de0 (cherry picked from commit 4e95d81ef048bfdc33cee7cf8bdbe66603b30f96)
Diffstat (limited to 'bluetooth/a2dp')
-rw-r--r--bluetooth/a2dp/1.0/Android.bp27
-rw-r--r--bluetooth/a2dp/1.0/IBluetoothAudioHost.hal61
-rw-r--r--bluetooth/a2dp/1.0/IBluetoothAudioOffload.hal85
-rw-r--r--bluetooth/a2dp/1.0/default/Android.bp14
-rw-r--r--bluetooth/a2dp/1.0/default/BluetoothAudioOffload.cpp74
-rw-r--r--bluetooth/a2dp/1.0/default/BluetoothAudioOffload.h60
-rw-r--r--bluetooth/a2dp/1.0/types.hal99
7 files changed, 420 insertions, 0 deletions
diff --git a/bluetooth/a2dp/1.0/Android.bp b/bluetooth/a2dp/1.0/Android.bp
new file mode 100644
index 00000000..5e852901
--- /dev/null
+++ b/bluetooth/a2dp/1.0/Android.bp
@@ -0,0 +1,27 @@
1// This file is autogenerated by hidl-gen -Landroidbp.
2
3hidl_interface {
4 name: "android.hardware.bluetooth.a2dp@1.0",
5 root: "android.hardware",
6 vndk: {
7 enabled: true,
8 },
9 srcs: [
10 "types.hal",
11 "IBluetoothAudioHost.hal",
12 "IBluetoothAudioOffload.hal",
13 ],
14 interfaces: [
15 "android.hidl.base@1.0",
16 ],
17 types: [
18 "BitsPerSample",
19 "ChannelMode",
20 "CodecConfiguration",
21 "CodecType",
22 "SampleRate",
23 "Status",
24 ],
25 gen_java: false,
26}
27
diff --git a/bluetooth/a2dp/1.0/IBluetoothAudioHost.hal b/bluetooth/a2dp/1.0/IBluetoothAudioHost.hal
new file mode 100644
index 00000000..666419db
--- /dev/null
+++ b/bluetooth/a2dp/1.0/IBluetoothAudioHost.hal
@@ -0,0 +1,61 @@
1/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.hardware.bluetooth.a2dp@1.0;
18
19/**
20 * HAL interface for Bluetooth A2DP Offload functionality where
21 * the encoding of the A2DP data packets is offloaded to platform
22 * specific encoders. The A2DP control path is maintained in the
23 * Bluetooth stack.
24 *
25 * This interface is from HAL server to HAL client.
26 *
27 * The HAL server must call into the IBluetoothAudioHost to initiate
28 * the start, suspend and stop of the streaming operation. These
29 * calls return immediately and the results, if any, are send over
30 * the IBluetoothAudioOffload interface.
31 */
32
33interface IBluetoothAudioHost {
34 /**
35 * Invoked when the start stream is requested from HAL server
36 * to HAL client. This indicates that the HAL server
37 * has initialized the platform for streaming use case, and the
38 * HAL client can proceed with the streaming procedure. The
39 * result of the operation must be provided by the HAL
40 * client using the IBluetoothAudioOffload interface.
41 */
42 oneway startStream();
43
44 /**
45 * Invoked when the suspend stream is requested from HAL server
46 * to HAL client. This indicates that the HAL server
47 * wants to suspend the streaming procedure. The result of the
48 * operation must be provided by the HAL client using the
49 * IBluetoothAudioOffload interface.
50 */
51 oneway suspendStream();
52
53 /**
54 * Invoked when the stop stream is requested from HAL server
55 * to HAL client. This indicates that the HAL server wants to
56 * stop and reset the streaming procedure. There is no result
57 * provided by the HAL client for this call.
58 */
59 oneway stopStream();
60
61};
diff --git a/bluetooth/a2dp/1.0/IBluetoothAudioOffload.hal b/bluetooth/a2dp/1.0/IBluetoothAudioOffload.hal
new file mode 100644
index 00000000..52a580f8
--- /dev/null
+++ b/bluetooth/a2dp/1.0/IBluetoothAudioOffload.hal
@@ -0,0 +1,85 @@
1/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.hardware.bluetooth.a2dp@1.0;
18
19import IBluetoothAudioHost;
20
21/**
22 * HAL interface for Bluetooth A2DP Offload functionality where
23 * the encoding of the A2DP data packets is offloaded to platform
24 * specific encoders. The A2DP control path is maintained in the
25 * Bluetooth stack.
26 *
27 * This interface is from HAL client to HAL server.
28 *
29 * The HAL client must provide the handle of IBluetoothAudioHost as well
30 * as codec configuration to the HAL server, when its connected to an
31 * active A2DP Sink device. HAL Server, based on the feedback from the Audio
32 * framework must call into the commands provided by the IBluetoothAudioHost.
33 * HAL client must call into IBluetoothAudioOffload to provide the status of
34 * these commands. Once the device becomes inactive, the HAL client must
35 * call the endSession to terminate the session with the HAL server.
36 */
37interface IBluetoothAudioOffload {
38
39 /**
40 * Indicates that the HAL client is connected to an A2DP Sink device
41 * and is ready to stream audio. This function is also used to register
42 * the BluetoothAudioHost interface and the provide the current negotiated
43 * codec.
44 *
45 * |endSession| must be called to unregister the interface.
46 *
47 * @param hostIf interface used to request stream control
48 * @param codecConfig Codec configuration as negotiated with the A2DP Sink
49 * device
50 * @return status one of the following
51 * SUCCESS if HAL server successfully initializes the platform with the
52 * given codec configuration
53 * UNSUPPORTED_CODEC_CONFIGURATION if HAL server cannot initialize the
54 * platform with the given codec configuration
55 * FAILURE if HAL server cannot initialize the platform for any other
56 * reason
57 */
58 startSession(IBluetoothAudioHost hostIf, CodecConfiguration codecConfig) generates (Status status);
59
60 /**
61 * Updates status for start stream request. The HAL client may need
62 * to communicate to Bluetooth Controller and remote Sink device, in which
63 * case it must update with PENDING status. Once the operation is
64 * completed, it must return with either SUCCESS or FAILURE.
65 *
66 * @param status SUCCESS, FAILURE or PENDING
67 */
68 oneway streamStarted(Status status);
69
70 /**
71 * Updates status for suspend stream request. The HAL client may need
72 * to communicate to Bluetooth Controller and remote device, in which case
73 * it must update with PENDING status. Once the operation is completed, it
74 * must return with either SUCCESS or FAILURE.
75 *
76 * @param status SUCCESS, FAILURE or PENDING
77 */
78 oneway streamSuspended(Status status);
79
80 /**
81 * Ends the current A2DP offload session and unregisters the
82 * BluetoothAudioHost interface.
83 */
84 oneway endSession();
85};
diff --git a/bluetooth/a2dp/1.0/default/Android.bp b/bluetooth/a2dp/1.0/default/Android.bp
new file mode 100644
index 00000000..8e6f32db
--- /dev/null
+++ b/bluetooth/a2dp/1.0/default/Android.bp
@@ -0,0 +1,14 @@
1cc_library_shared {
2 name: "android.hardware.bluetooth.a2dp@1.0-impl",
3 relative_install_path: "hw",
4 vendor: true,
5 srcs: [
6 "BluetoothAudioOffload.cpp",
7 ],
8 shared_libs: [
9 "libhidlbase",
10 "libhidltransport",
11 "libutils",
12 "android.hardware.bluetooth.a2dp@1.0",
13 ],
14}
diff --git a/bluetooth/a2dp/1.0/default/BluetoothAudioOffload.cpp b/bluetooth/a2dp/1.0/default/BluetoothAudioOffload.cpp
new file mode 100644
index 00000000..2a66abe6
--- /dev/null
+++ b/bluetooth/a2dp/1.0/default/BluetoothAudioOffload.cpp
@@ -0,0 +1,74 @@
1/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "BluetoothAudioOffload.h"
18
19namespace android {
20namespace hardware {
21namespace bluetooth {
22namespace a2dp {
23namespace V1_0 {
24namespace implementation {
25
26IBluetoothAudioOffload* HIDL_FETCH_IBluetoothAudioOffload(const char* /* name */) {
27 return new BluetoothAudioOffload();
28}
29
30// Methods from ::android::hardware::bluetooth::a2dp::V1_0::IBluetoothAudioOffload follow.
31Return<::android::hardware::bluetooth::a2dp::V1_0::Status> BluetoothAudioOffload::startSession(
32 const sp<::android::hardware::bluetooth::a2dp::V1_0::IBluetoothAudioHost>& hostIf __unused,
33 const ::android::hardware::bluetooth::a2dp::V1_0::CodecConfiguration& codecConfig __unused) {
34 /**
35 * Initialize the audio platform if codecConfiguration is supported.
36 * Save the the IBluetoothAudioHost interface, so that it can be used
37 * later to send stream control commands to the HAL client, based on
38 * interaction with Audio framework.
39 */
40 return ::android::hardware::bluetooth::a2dp::V1_0::Status::FAILURE;
41}
42
43Return<void> BluetoothAudioOffload::streamStarted(
44 ::android::hardware::bluetooth::a2dp::V1_0::Status status __unused) {
45 /**
46 * Streaming on control path has started,
47 * HAL server should start the streaming on data path.
48 */
49 return Void();
50}
51
52Return<void> BluetoothAudioOffload::streamSuspended(
53 ::android::hardware::bluetooth::a2dp::V1_0::Status status __unused) {
54 /**
55 * Streaming on control path has suspend,
56 * HAL server should suspend the streaming on data path.
57 */
58 return Void();
59}
60
61Return<void> BluetoothAudioOffload::endSession() {
62 /**
63 * Cleanup the audio platform as remote A2DP Sink device is no
64 * longer active
65 */
66 return Void();
67}
68
69} // namespace implementation
70} // namespace V1_0
71} // namespace a2dp
72} // namespace bluetooth
73} // namespace hardware
74} // namespace android
diff --git a/bluetooth/a2dp/1.0/default/BluetoothAudioOffload.h b/bluetooth/a2dp/1.0/default/BluetoothAudioOffload.h
new file mode 100644
index 00000000..5d07b5bc
--- /dev/null
+++ b/bluetooth/a2dp/1.0/default/BluetoothAudioOffload.h
@@ -0,0 +1,60 @@
1/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_HARDWARE_BLUETOOTH_A2DP_V1_0_BLUETOOTHAUDIOOFFLOAD_H
18#define ANDROID_HARDWARE_BLUETOOTH_A2DP_V1_0_BLUETOOTHAUDIOOFFLOAD_H
19
20#include <android/hardware/bluetooth/a2dp/1.0/IBluetoothAudioOffload.h>
21#include <hidl/MQDescriptor.h>
22#include <hidl/Status.h>
23
24namespace android {
25namespace hardware {
26namespace bluetooth {
27namespace a2dp {
28namespace V1_0 {
29namespace implementation {
30
31using ::android::hardware::hidl_array;
32using ::android::hardware::hidl_memory;
33using ::android::hardware::hidl_string;
34using ::android::hardware::hidl_vec;
35using ::android::hardware::Return;
36using ::android::hardware::Void;
37using ::android::sp;
38
39struct BluetoothAudioOffload : public IBluetoothAudioOffload {
40 BluetoothAudioOffload() {}
41 // Methods from ::android::hardware::bluetooth::a2dp::V1_0::IBluetoothAudioOffload follow.
42 Return<::android::hardware::bluetooth::a2dp::V1_0::Status> startSession(
43 const sp<::android::hardware::bluetooth::a2dp::V1_0::IBluetoothAudioHost>& hostIf,
44 const ::android::hardware::bluetooth::a2dp::V1_0::CodecConfiguration& codecConfig) override;
45 Return<void> streamStarted(::android::hardware::bluetooth::a2dp::V1_0::Status status) override;
46 Return<void> streamSuspended(
47 ::android::hardware::bluetooth::a2dp::V1_0::Status status) override;
48 Return<void> endSession() override;
49};
50
51extern "C" IBluetoothAudioOffload* HIDL_FETCH_IBluetoothAudioOffload(const char* name);
52
53} // namespace implementation
54} // namespace V1_0
55} // namespace a2dp
56} // namespace bluetooth
57} // namespace hardware
58} // namespace android
59
60#endif // ANDROID_HARDWARE_BLUETOOTH_A2DP_V1_0_BLUETOOTHAUDIOOFFLOAD_H
diff --git a/bluetooth/a2dp/1.0/types.hal b/bluetooth/a2dp/1.0/types.hal
new file mode 100644
index 00000000..6a430f05
--- /dev/null
+++ b/bluetooth/a2dp/1.0/types.hal
@@ -0,0 +1,99 @@
1/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.hardware.bluetooth.a2dp@1.0;
18
19enum Status : uint8_t {
20 SUCCESS,
21 FAILURE,
22 /** codec configuration not supported by the audio platform */
23 UNSUPPORTED_CODEC_CONFIGURATION ,
24 /** operation is pending */
25 PENDING,
26};
27
28enum CodecType : uint32_t {
29 UNKNOWN = 0x00,
30 SBC = 0x01,
31 AAC = 0x02,
32 APTX = 0x04,
33 APTX_HD = 0x08,
34 LDAC = 0x10,
35};
36enum SampleRate : uint32_t {
37 RATE_UNKNOWN = 0x00,
38 RATE_44100 = 0x01,
39 RATE_48000 = 0x02,
40 RATE_88200 = 0x04,
41 RATE_96000 = 0x08,
42 RATE_176400 = 0x10,
43 RATE_192000 = 0x20,
44};
45enum BitsPerSample : uint8_t {
46 BITS_UNKNOWN = 0x00,
47 BITS_16 = 0x01,
48 BITS_24 = 0x02,
49 BITS_32 = 0x04,
50};
51enum ChannelMode : uint8_t {
52 UNKNOWN = 0x00,
53 MONO = 0x01,
54 STEREO = 0x02,
55};
56struct CodecConfiguration {
57 /** Bluetooth A2DP codec */
58 CodecType codecType;
59 /** Sampling rate for encoder */
60 SampleRate sampleRate;
61 /** Bits per sample for encoder */
62 BitsPerSample bitsPerSample;
63 /** Channel mode for encoder */
64 ChannelMode channelMode;
65 /**
66 * The encoded audio bitrate in bits / second.
67 * 0x00000000 - The audio bitrate is not specified / unused
68 * 0x00000001 - 0x00FFFFFF - Encoded audio bitrate in bits/second
69 * 0x01000000 - 0xFFFFFFFF - Reserved
70 */
71 uint32_t encodedAudioBitrate;
72 /** Peer MTU (in octets) */
73 uint16_t peerMtu;
74 union CodecSpecific {
75 /**
76 * SBC Codec specific information
77 * Refer to SBC Codec specific information elements in A2DP v1.3
78 * Profile Specification.
79 */
80 struct SbcData {
81 /** Block length: 4 bits | Subbands: 2 bits | Allocation Method: 2 bits */
82 uint8_t codecParameters;
83 /** Minimum bitpool value */
84 uint8_t minBitpool;
85 /** Maximum bitpool value */
86 uint8_t maxBitpool;
87 } sbcData;
88 struct LdacData {
89 /**
90 * LDAC bitrate index value:
91 * 0x00 - High
92 * 0x01 - Mid
93 * 0x02 - Low
94 * 0x7F - ABR (Adaptive Bit Rate)
95 */
96 uint8_t bitrateIndex;
97 } ldacData;
98 } codecSpecific;
99};