linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 3/4] monitor/att: Add decoding support for PAC Audio Context
Date: Thu, 16 Jun 2022 17:49:56 -0700	[thread overview]
Message-ID: <20220617004957.1148939-3-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20220617004957.1148939-1-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This adds decoding support for PAC Audio Context attributes:

> ACL Data RX: Handle 42 flags 0x02 dlen 9
      Channel: 65 len 5 sdu 3 [PSM 39 mode Enhanced Credit (0x81)] {chan 1}
      ATT: Read Request (0x0a) len 2
        Handle: 0x0026 Type: Supported Audio Contexts (0x2bce)
< ACL Data TX: Handle 42 flags 0x00 dlen 11
      Channel: 64 len 7 sdu 5 [PSM 39 mode Enhanced Credit (0x81)] {chan 1}
      ATT: Read Response (0x0b) len 4
        Value: ff0f0e00
        Handle: 0x0026 Type: Supported Audio Contexts (0x2bce)
            Sink Context: 0x0fff
              Unspecified (0x0001)
              Conversational (0x0002)
              Media (0x0004)
              Game (0x0008)
              Instructional (0x0010)
              Voice Assistants (0x0020)
              Live (0x0040)
              Sound Effects (0x0080)
              Notifications (0x0100)
              Ringtone (0x0200)
              Alerts (0x0400)
              Emergency alarm (0x0800)
            Source Context: 0x000e
              Conversational (0x0002)
              Media (0x0004)
              Game (0x0008)
---
 monitor/att.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)

diff --git a/monitor/att.c b/monitor/att.c
index 8b47cbd9f..21fa5dde3 100644
--- a/monitor/att.c
+++ b/monitor/att.c
@@ -1118,6 +1118,69 @@ static void pac_loc_notify(const struct l2cap_frame *frame)
 	print_loc_pac(frame);
 }
 
+static const struct bitfield_data pac_context_table[] = {
+	{  0, "Unspecified (0x0001)"			},
+	{  1, "Conversational (0x0002)"			},
+	{  2, "Media (0x0004)"				},
+	{  3, "Game (0x0008)"				},
+	{  4, "Instructional (0x0010)"			},
+	{  5, "Voice Assistants (0x0020)"		},
+	{  6, "Live (0x0040)"				},
+	{  7, "Sound Effects (0x0080)"			},
+	{  8, "Notifications (0x0100)"			},
+	{  9, "Ringtone (0x0200)"			},
+	{  10, "Alerts (0x0400)"			},
+	{  11, "Emergency alarm (0x0800)"		},
+	{  12, "RFU (0x1000)"				},
+	{  13, "RFU (0x2000)"				},
+	{  14, "RFU (0x4000)"				},
+	{  15, "RFU (0x8000)"				},
+};
+
+static void print_pac_context(const struct l2cap_frame *frame)
+{
+	uint16_t snk, src;
+	uint16_t mask;
+
+	if (!l2cap_frame_get_le16((void *)frame, &snk)) {
+		print_text(COLOR_ERROR, "    value: invalid size");
+		goto done;
+	}
+
+	print_field("  Sink Context: 0x%4.4x", snk);
+
+	mask = print_bitfield(4, snk, pac_context_table);
+	if (mask)
+		print_text(COLOR_WHITE_BG, "    Unknown fields (0x%4.4x)",
+								mask);
+
+	if (!l2cap_frame_get_le16((void *)frame, &src)) {
+		print_text(COLOR_ERROR, "    sink: invalid size");
+		goto done;
+	}
+
+	print_field("  Source Context: 0x%4.4x", src);
+
+	mask = print_bitfield(4, src, pac_context_table);
+	if (mask)
+		print_text(COLOR_WHITE_BG, "    Unknown fields (0x%4.4x)",
+								mask);
+
+done:
+	if (frame->size)
+		print_hex_field("  Data", frame->data, frame->size);
+}
+
+static void pac_context_read(const struct l2cap_frame *frame)
+{
+	print_pac_context(frame);
+}
+
+static void pac_context_notify(const struct l2cap_frame *frame)
+{
+	print_pac_context(frame);
+}
+
 #define GATT_HANDLER(_uuid, _read, _write, _notify) \
 { \
 	.uuid = { \
@@ -1143,6 +1206,8 @@ struct gatt_handler {
 	GATT_HANDLER(0x2bca, pac_loc_read, NULL, pac_loc_notify),
 	GATT_HANDLER(0x2bcb, pac_read, NULL, pac_notify),
 	GATT_HANDLER(0x2bcc, pac_loc_read, NULL, pac_loc_notify),
+	GATT_HANDLER(0x2bcd, pac_context_read, NULL, pac_context_notify),
+	GATT_HANDLER(0x2bce, pac_context_read, NULL, pac_context_notify),
 };
 
 static struct gatt_handler *get_handler(struct gatt_db_attribute *attr)
-- 
2.35.3


  parent reply	other threads:[~2022-06-17  0:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-17  0:49 [PATCH BlueZ 1/4] monitor/att: Print attribute information on ATT_REQ_RSP Luiz Augusto von Dentz
2022-06-17  0:49 ` [PATCH BlueZ 2/4] monitor/att: Add decoding support for PAC Sink/Source Location Luiz Augusto von Dentz
2022-06-17  0:49 ` Luiz Augusto von Dentz [this message]
2022-06-17  0:49 ` [PATCH BlueZ 4/4] monitor/att: Add LTV deconding support for PAC/ASE Luiz Augusto von Dentz
2022-06-17  5:28 ` [BlueZ,1/4] monitor/att: Print attribute information on ATT_REQ_RSP bluez.test.bot
2022-06-17 21:10 ` [PATCH BlueZ 1/4] " patchwork-bot+bluetooth

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=20220617004957.1148939-3-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /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).