summaryrefslogtreecommitdiffstats
path: root/audio_a2dp_hw
diff options
context:
space:
mode:
authortbalden <illespal@gmail.com>2013-03-10 11:30:46 +0100
committerGerrit Code Review <gerrit@cyanogenmod.org>2013-03-24 16:03:27 -0700
commit4b56e400bc2e101b7c3242c4556381ac8cb14ea5 (patch)
tree5f414cfac5fb5f2820687ed151e50b90e8f24e59 /audio_a2dp_hw
parentb7f44f86839bbf77a3d885125a13b6c7fea7e7b0 (diff)
downloadexternal_bluetooth_bluedroid-4b56e400bc2e101b7c3242c4556381ac8cb14ea5.zip
external_bluetooth_bluedroid-4b56e400bc2e101b7c3242c4556381ac8cb14ea5.tar.gz
external_bluetooth_bluedroid-4b56e400bc2e101b7c3242c4556381ac8cb14ea5.tar.bz2
a2dp hw: adding a2dp tuning through bdroid_buildcfg.h
This adds possibility to configure a2dp tuning on an arbitrary sysfs path and arbitrary ON/OFF values. It's activated when a2dp is being used, and deactivates when a2dp is stopped. This way a device can either use an a2dp_tuning sysfs file or cpu scaling min freq sysfs path with a target min_freq value for elevation. Here are two example of the two strategies of usage for this: bdroid_buildcfg.h - sysfs tuning file #define A2DP_HW_SYSFS_TUNER "/sys/devices/platform/tegra_uart.2/a2dp_tuning" #define A2DP_HW_SYSFS_TUNER_OFF "0" #define A2DP_HW_SYSFS_TUNER_ON "1" bdroid_buildcfg.h - scaling min freq file #define A2DP_HW_SYSFS_TUNER "/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq" #define A2DP_HW_SYSFS_TUNER_OFF "0" #define A2DP_HW_SYSFS_TUNER_ON "204000" Change-Id: I2cd94e626eb2a6d04a6e52ddac94fa5773eb09d8
Diffstat (limited to 'audio_a2dp_hw')
-rw-r--r--audio_a2dp_hw/Android.mk5
-rw-r--r--audio_a2dp_hw/audio_a2dp_hw.c41
-rw-r--r--audio_a2dp_hw/audio_a2dp_hw.h5
3 files changed, 50 insertions, 1 deletions
diff --git a/audio_a2dp_hw/Android.mk b/audio_a2dp_hw/Android.mk
index bf00342..5adae79 100644
--- a/audio_a2dp_hw/Android.mk
+++ b/audio_a2dp_hw/Android.mk
@@ -11,7 +11,10 @@ endif
LOCAL_SRC_FILES:= \
audio_a2dp_hw.c
-LOCAL_C_INCLUDES+= .
+LOCAL_CFLAGS += $(bdroid_CFLAGS)
+
+LOCAL_C_INCLUDES+= . \
+ $(bdroid_C_INCLUDES)
LOCAL_SHARED_LIBRARIES := \
libcutils
diff --git a/audio_a2dp_hw/audio_a2dp_hw.c b/audio_a2dp_hw/audio_a2dp_hw.c
index 42e416e..e1a99c5 100644
--- a/audio_a2dp_hw/audio_a2dp_hw.c
+++ b/audio_a2dp_hw/audio_a2dp_hw.c
@@ -142,6 +142,34 @@ static const char* dump_a2dp_ctrl_event(char event)
}
}
+#ifdef A2DP_HW_SYSFS_TUNER
+/* If kernel supports some kind of A2DP related tuning,
+ this function should be used to switch tuning on/off.
+ Specify in BLUEDROID BUILDCFG the following values:
+ A2DP_HW_SYSFS_TUNER "/sysfs/path/to/tuner/or/scaling_min_freq"
+ A2DP_HW_SYSFS_TUNER_OFF "0" # value to switch tuning off,
+ # "0" or a Min Freq off value
+ # like "0"
+ A2DP_HW_SYSFS_TUNER_ON "1" # value to switch tuning on
+ # "1", or Min Freq boost value
+ # like "205000"
+*/
+static void a2dp_hw_sysfs_tuning(int state)
+{
+ int fd = open( A2DP_HW_SYSFS_TUNER, O_WRONLY);
+ if(fd > 0) {
+ char *val = A2DP_HW_SYSFS_TUNER_OFF;
+ if (state)
+ {
+ val = A2DP_HW_SYSFS_TUNER_ON;
+ }
+ write(fd, val, strlen(val));
+ INFO("a2dp tuning set to %s", val);
+ close(fd);
+ }
+}
+#endif
+
/* logs timestamp with microsec precision
pprev is optional in case a dedicated diff is required */
static void ts_log(char *tag, int val, struct timespec *pprev_opt)
@@ -356,6 +384,9 @@ static int start_audio_datapath(struct a2dp_stream_out *out)
out->state = AUDIO_A2DP_STATE_STARTED;
}
+#ifdef A2DP_HW_SYSFS_TUNER
+ a2dp_hw_sysfs_tuning(1);
+#endif
return 0;
}
@@ -366,6 +397,11 @@ static int stop_audio_datapath(struct a2dp_stream_out *out)
INFO("state %d", out->state);
+#ifdef A2DP_HW_SYSFS_TUNER
+ /* disable a2dp tuning ASAP */
+ a2dp_hw_sysfs_tuning(0);
+#endif
+
if (out->ctrl_fd == AUDIO_SKT_DISCONNECTED)
return -1;
@@ -393,6 +429,11 @@ static int suspend_audio_datapath(struct a2dp_stream_out *out, bool standby)
{
INFO("state %d", out->state);
+#ifdef A2DP_HW_SYSFS_TUNER
+ /* disable a2dp tuning ASAP */
+ a2dp_hw_sysfs_tuning(0);
+#endif
+
if (out->ctrl_fd == AUDIO_SKT_DISCONNECTED)
return -1;
diff --git a/audio_a2dp_hw/audio_a2dp_hw.h b/audio_a2dp_hw/audio_a2dp_hw.h
index 3076a6d..4a9f1a9 100644
--- a/audio_a2dp_hw/audio_a2dp_hw.h
+++ b/audio_a2dp_hw/audio_a2dp_hw.h
@@ -28,6 +28,11 @@
#ifndef AUDIO_A2DP_HW_H
#define AUDIO_A2DP_HW_H
+#ifdef HAS_BDROID_BUILDCFG
+#include "bdroid_buildcfg.h"
+#endif
+
+
/*****************************************************************************
** Constants & Macros
******************************************************************************/