linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: linux-bluetooth@vger.kernel.org, David Heidelberg <david@ixit.cz>
Subject: [PATCH 2/3] src/profile: Export Remote Audio Volume Control SDP value for HSP HS role via first bit in features value
Date: Mon, 13 Apr 2020 18:25:12 +0200	[thread overview]
Message-ID: <20200413162513.2221-3-pali@kernel.org> (raw)
In-Reply-To: <20200413162513.2221-1-pali@kernel.org>

Remote Audio Volume Control property in SDP record for HSP HS role
indicates if device supports volume control.

It is required for DBus agents which implements audio part of HSP
profile to know if remote device supports volume control or not.

With this change bluez exports status of this SDP property via firt bit
in Features entry in NewConnection() DBus callback method, like for HFP
profile.

Signed-off-by: Pali Rohár <pali@kernel.org>
---
 src/profile.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/src/profile.c b/src/profile.c
index 884440408..3b7e08f26 100644
--- a/src/profile.c
+++ b/src/profile.c
@@ -923,10 +923,26 @@ static void append_prop(gpointer a, gpointer b)
 }
 
 static uint16_t get_supported_features(const sdp_record_t *rec,
-					bool *have_features)
+					const char *uuid, bool *have_features)
 {
 	sdp_data_t *data;
 
+	if (strcasecmp(uuid, HSP_AG_UUID) == 0) {
+		/* HSP AG role does not provide any features */
+		*have_features = false;
+		return 0;
+	} else if (strcasecmp(uuid, HSP_HS_UUID) == 0) {
+		/* HSP HS role provides Remote Audio Volume Control */
+		data = sdp_data_get(rec, SDP_ATTR_REMOTE_AUDIO_VOLUME_CONTROL);
+		if (!data || data->dtd != SDP_BOOL) {
+			*have_features = false;
+			return 0;
+		} else {
+			*have_features = true;
+			return data->val.int8 ? 0x1 : 0x0;
+		}
+	}
+
 	data = sdp_data_get(rec, SDP_ATTR_SUPPORTED_FEATURES);
 	if (!data || data->dtd != SDP_UINT16) {
 		*have_features = false;
@@ -979,7 +995,7 @@ static bool send_new_connection(struct ext_profile *ext, struct ext_io *conn)
 		rec = btd_device_get_record(conn->device, remote_uuid);
 		if (rec) {
 			conn->features = get_supported_features(rec,
-							&conn->have_features);
+					remote_uuid, &conn->have_features);
 			conn->version = get_profile_version(rec);
 		}
 	}
@@ -1596,7 +1612,7 @@ static void record_cb(sdp_list_t *recs, int err, gpointer user_data)
 		if (conn->psm == 0 && sdp_get_proto_desc(protos, OBEX_UUID))
 			conn->psm = get_goep_l2cap_psm(rec);
 
-		conn->features = get_supported_features(rec,
+		conn->features = get_supported_features(rec, ext->remote_uuid,
 							&conn->have_features);
 		conn->version = get_profile_version(rec);
 
-- 
2.20.1


  parent reply	other threads:[~2020-04-13 16:25 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-12 17:29 bluez: Export SDP "Remote audio volume control" item for HSP profile Pali Rohár
2019-12-12 19:42 ` Luiz Augusto von Dentz
2019-12-12 23:03   ` Pali Rohár
2020-02-09 13:02     ` Pali Rohár
2020-03-20 13:01       ` Pali Rohár
2020-03-20 17:48         ` Luiz Augusto von Dentz
2020-03-21 18:40           ` Pali Rohár
2020-03-21 19:54             ` Pali Rohár
2020-04-13 16:25               ` [PATCH 0/3] " Pali Rohár
2020-04-13 16:25                 ` [PATCH 1/3] src/profile: Distinguish between zero-set HFP AG features and unset HFP AG features Pali Rohár
2020-04-13 16:44                   ` Luiz Augusto von Dentz
2020-04-13 16:52                     ` Pali Rohár
2020-04-13 16:58                       ` Luiz Augusto von Dentz
2020-04-13 17:17                         ` Pali Rohár
2020-04-13 17:47                           ` Luiz Augusto von Dentz
2020-04-13 17:58                             ` Pali Rohár
2020-04-13 19:41                               ` Luiz Augusto von Dentz
2020-04-13 19:51                                 ` Pali Rohár
2020-04-13 20:24                                   ` Luiz Augusto von Dentz
2020-04-13 20:42                                     ` Pali Rohár
2020-04-13 21:07                                       ` Luiz Augusto von Dentz
2020-04-13 22:26                                         ` Pali Rohár
2020-04-13 16:25                 ` Pali Rohár [this message]
2020-04-13 16:25                 ` [PATCH 3/3] src/profile: Add default SDP record for Headset role of HSP 1.2 profile with Erratum 3507 Pali Rohár
2020-04-13 16:51                   ` Luiz Augusto von Dentz
2020-04-14  0:09                 ` [PATCH 0/3] bluez: Export SDP "Remote audio volume control" item for HSP profile Luiz Augusto von Dentz
2020-04-14  8:09                   ` Pali Rohár
2020-04-14 19:53                   ` Pali Rohár
2020-04-14 20:28                     ` Luiz Augusto von Dentz
2020-04-14 20:46                       ` [PATCH] doc: Update documentation for HSP and HFP profiles Pali Rohár
2020-04-14 21:03                         ` Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200413162513.2221-3-pali@kernel.org \
    --to=pali@kernel.org \
    --cc=david@ixit.cz \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).