pmaports/temp/pulseaudio/0009-bluetooth-support-AT-NREC.patch
Dylan Van Assche f9c7ffa9b6
temp/pulseaudio: fork for Bluetooth HFP/HSP support (MR 3080)
PulseAudio is used for handling all audio on postmarketOS.
This also involves Bluetooth audio such as A2DP, HSP and HFP audio.
In the case of HFP/HSP, the HF and AG can interact with each other
through AT commands defined in the Bluetooth HFP 1.8 spec.

This set of patches implements HFP support to allow Bluetooth devices
to accept/reject/hangup calls, dial numbers, DTMF tone generation,
query signal strength, roaming status, service status, AG battery level,
call status, etc.

More details in the upstream MR:
https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/693

Available in edge for testing this merge request with a broader user
base. Not intended for backporting to stable branches.

[ci:skip-build]: already built successfully in CI
2022-06-16 09:33:35 +02:00

48 lines
1.9 KiB
Diff

From 0dc5b589220e830ab18ddbcf90f2cfbe1c4927f7 Mon Sep 17 00:00:00 2001
From: Dylan Van Assche <me@dylanvanassche.be>
Date: Wed, 13 Apr 2022 20:25:47 +0200
Subject: [PATCH 09/26] bluetooth: support AT+NREC
AT+NREC=0 disables Noise Reduction and Echo Canceling in the AG.
Bluetooth HFP 1.8 only supports the disable operation, so return
an CME ERROR extended error code if another value is send by the HF.
---
src/modules/bluetooth/backend-native.c | 7 +++++++
src/modules/bluetooth/bluez5-util.h | 3 ++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/modules/bluetooth/backend-native.c b/src/modules/bluetooth/backend-native.c
index 3110c5ef2..394c2a4da 100644
--- a/src/modules/bluetooth/backend-native.c
+++ b/src/modules/bluetooth/backend-native.c
@@ -652,6 +652,13 @@ static bool hfp_rfcomm_handle(int fd, pa_bluetooth_transport *t, const char *buf
return false;
}
pa_assert_not_reached();
+ } else if (sscanf(buf, "AT+NREC=%d", &val) == 1) {
+ if (val == 0)
+ return true;
+
+ /* Noise Redction and Echo Canceling can only have value '0' (disable) following Bluetooth HFP 1.8 */
+ rfcomm_write_error(discovery->native_backend, fd, CMEE_OPERATION_NOT_ALLOWED);
+ return false;
}
/* first-time initialize selected codec to CVSD */
diff --git a/src/modules/bluetooth/bluez5-util.h b/src/modules/bluetooth/bluez5-util.h
index 4cc5c2882..fa26a8361 100644
--- a/src/modules/bluetooth/bluez5-util.h
+++ b/src/modules/bluetooth/bluez5-util.h
@@ -214,7 +214,8 @@ struct pa_bluetooth_adapter {
/* extended error reporting values, described in Bluetooth HFP 1.8 spec */
typedef enum pa_bluetooth_cmee {
CMEE_AG_FAILURE = 0,
- CMEE_OPERATION_NOT_SUPPORTED = 4,
+ CMEE_OPERATION_NOT_ALLOWED = 3,
+ CMEE_OPERATION_NOT_SUPPORTED = 4
} pa_bluetooth_cmee_t;
#ifdef HAVE_BLUEZ_5_OFONO_HEADSET
--
2.35.1