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 2/4] monitor/att: Add decoding support for PAC Sink/Source Location
Date: Thu, 16 Jun 2022 17:49:55 -0700	[thread overview]
Message-ID: <20220617004957.1148939-2-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 Sink/Source Location 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: 0x001a Type: Sink Audio Locations (0x2bca)
< 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: 03000000
        Handle: 0x001a Type: Sink Audio Locations (0x2bca)
           Location: 0x00000003
              Front Left (0x00000001)
              Front Right (0x00000002)
---
 monitor/att.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)

diff --git a/monitor/att.c b/monitor/att.c
index 34babac6b..8b47cbd9f 100644
--- a/monitor/att.c
+++ b/monitor/att.c
@@ -1050,6 +1050,74 @@ static void ase_cp_notify(const struct l2cap_frame *frame)
 	print_ase_cp_rsp(frame);
 }
 
+static const struct bitfield_data pac_loc_table[] = {
+	{  0, "Front Left (0x00000001)"			},
+	{  1, "Front Right (0x00000002)"		},
+	{  2, "Front Center (0x00000004)"		},
+	{  3, "Low Frequency Effects 1 (0x00000008)"	},
+	{  4, "Back Left (0x00000010)"			},
+	{  5, "Back Right (0x00000020)"			},
+	{  6, "Front Left of Center (0x00000040)"	},
+	{  7, "Front Right of Center (0x00000080)"	},
+	{  8, "Back Center (0x00000100)"		},
+	{  9, "Low Frequency Effects 2 (0x00000200)"	},
+	{  10, "Side Left (0x00000400)"			},
+	{  11, "Side Right (0x00000800)"		},
+	{  12, "Top Front Left (0x00001000)"		},
+	{  13, "Top Front Right (0x00002000)"		},
+	{  14, "Top Front Center (0x00004000)"		},
+	{  15, "Top Center (0x00008000)"		},
+	{  16, "Top Back Left (0x00010000)"		},
+	{  17, "Top Back Right (0x00020000)"		},
+	{  18, "Top Side Left (0x00040000)"		},
+	{  19, "Top Side Right (0x00080000)"		},
+	{  20, "Top Back Center (0x00100000)"		},
+	{  21, "Bottom Front Center (0x00200000)"	},
+	{  22, "Bottom Front Left (0x00400000)"		},
+	{  23, "Bottom Front Right (0x00800000)"	},
+	{  24, "Front Left Wide (0x01000000)"		},
+	{  25, "Front Right Wide (0x02000000)"		},
+	{  26, "Left Surround (0x04000000)"		},
+	{  27, "Right Surround (0x08000000)"		},
+	{  28, "RFU (0x10000000)"			},
+	{  29, "RFU (0x20000000)"			},
+	{  30, "RFU (0x40000000)"			},
+	{  31, "RFU (0x80000000)"			},
+	{ }
+};
+
+static void print_loc_pac(const struct l2cap_frame *frame)
+{
+	uint32_t value;
+	uint8_t mask;
+
+	if (!l2cap_frame_get_le32((void *)frame, &value)) {
+		print_text(COLOR_ERROR, "    value: invalid size");
+		goto done;
+	}
+
+	print_field("  Location: 0x%8.8x", value);
+
+	mask = print_bitfield(4, value, pac_loc_table);
+	if (mask)
+		print_text(COLOR_WHITE_BG, "    Unknown fields (0x%2.2x)",
+								mask);
+
+done:
+	if (frame->size)
+		print_hex_field("  Data", frame->data, frame->size);
+}
+
+static void pac_loc_read(const struct l2cap_frame *frame)
+{
+	print_loc_pac(frame);
+}
+
+static void pac_loc_notify(const struct l2cap_frame *frame)
+{
+	print_loc_pac(frame);
+}
+
 #define GATT_HANDLER(_uuid, _read, _write, _notify) \
 { \
 	.uuid = { \
@@ -1072,7 +1140,9 @@ struct gatt_handler {
 	GATT_HANDLER(0x2bc5, ase_read, NULL, ase_notify),
 	GATT_HANDLER(0x2bc6, NULL, ase_cp_write, ase_cp_notify),
 	GATT_HANDLER(0x2bc9, pac_read, NULL, pac_notify),
+	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),
 };
 
 static struct gatt_handler *get_handler(struct gatt_db_attribute *attr)
-- 
2.35.3


  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 ` Luiz Augusto von Dentz [this message]
2022-06-17  0:49 ` [PATCH BlueZ 3/4] monitor/att: Add decoding support for PAC Audio Context Luiz Augusto von Dentz
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-2-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).