4 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Dohyun Pyun <dh79.pyun@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
24 #include <oal-event.h>
25 #include <oal-hardware.h>
26 #include <oal-audio-src.h>
28 #include "bt-service-common.h"
29 #include "bt-service-audio-common.h"
31 static unsigned int absolute_volume = 0;
32 static unsigned int bt_volume = 0;
33 static int avc_mode = BT_AVC_OFF;
35 int _bt_audio_set_absolute_volume(unsigned int volume)
37 int result = BLUETOOTH_ERROR_NONE;
39 /* 1. Translate the absolute volume to bt volume */
41 /* Convert system gain to BT
42 BT volume range : 0 ~ 127
43 system volume range : 0 ~ 150 */
45 bt_volume = 127 * volume / 150;
48 system volume : 0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150
49 avrcp_ volume : 0 9 17 26 34 43 51 60 68 77 85 94 102 111 119 127 */
51 if (bt_volume > 0 && bt_volume < 127)
54 /* 2. Notify the bt_volume to transport (BT Headset) */
56 /* 3. Notify the avc mode to the pulseaudio if it is needed */
61 /* Just return the absolute_volume value */
62 int _bt_audio_get_absolute_volume(unsigned int *volume)
64 int result = BLUETOOTH_ERROR_NONE;
66 *volume = absolute_volume;
71 int _bt_audio_is_avc_activated(bool *activated)
73 *activated = (avc_mode == BT_AVC_OFF) ? false : true;
75 return BLUETOOTH_ERROR_NONE;
78 /* 1. When a2dp headset is connected, we should set 'AVC' mode into pulseaudio */
79 /* 2. If the avc mode is changed, we should inform 'AVC' mode to pulseaudio */
80 /* 3. If BT is off, we should send 'AVC' off mode event for application */
81 /* 4. If BT A2DP is disconnected, we should send 'AVC' off mode event for application */