[PATCH 18/26] tools/hcidump: Decode aptX codec capabilities

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 tools/parser/avdtp.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 47 insertions(+), 3 deletions(-)

diff --git a/tools/parser/avdtp.c b/tools/parser/avdtp.c
index 5806c07..14dc417 100644
--- a/tools/parser/avdtp.c
+++ b/tools/parser/avdtp.c
@@ -150,6 +150,13 @@ static char *codec2str(uint8_t type, uint8_t codec)
 	return "Unknown";
 }
 
+static char *vndcodec2str(uint32_t vendor, uint16_t vndcodec)
+{
+	if (vendor == 0x0000004f && vndcodec == 0x0001)
+		return "aptX";
+	return "Unknown";
+}
+
 static char *cat2str(uint8_t cat)
 {
 	switch (cat) {
@@ -213,13 +220,23 @@ static void capabilities(int level, struct frame *frm)
 
 		if (cat == 7) {
 			uint8_t type, codec;
-			uint16_t tmp, freq;
-			uint32_t bitrate;
+			uint16_t tmp, freq, vndcodec = 0;
+			uint32_t bitrate, vendor = 0;
 
 			type  = get_u8(frm);
 			codec = get_u8(frm);
 
-			printf("%s - %s\n", cat2str(cat), codec2str(type, codec));
+			if (codec == 255) {
+				vendor = btohl(htonl(get_u32(frm)));
+				vndcodec = btohs(htons(get_u16(frm)));
+
+				printf("%s - %s (%s)\n", cat2str(cat),
+						codec2str(type, codec),
+						vndcodec2str(vendor, vndcodec));
+			} else {
+				printf("%s - %s\n", cat2str(cat),
+							codec2str(type, codec));
+			}
 
 			switch (codec) {
 			case 0:
@@ -324,6 +341,33 @@ static void capabilities(int level, struct frame *frm)
 				printf("%ubps ", bitrate);
 				printf("%s\n", tmp & 0x80 ? "VBR" : "");
 				break;
+			case 255:
+				if (vendor == 0x0000004f &&
+							vndcodec == 0x0001) {
+					tmp = get_u8(frm);
+					p_indent(level + 1, frm);
+					if (tmp & 0x80)
+						printf("16kHz ");
+					if (tmp & 0x40)
+						printf("32kHz ");
+					if (tmp & 0x20)
+						printf("44.1kHz ");
+					if (tmp & 0x10)
+						printf("48kHz ");
+					printf("\n");
+					p_indent(level + 1, frm);
+					if (tmp & 0x02)
+						printf("Stereo ");
+					if (tmp & 0x01)
+						printf("Mono ");
+					printf("\n");
+					break;
+				} else {
+					hex_dump(level + 1, frm, len - 8);
+					frm->ptr += (len - 8);
+					frm->len -= (len - 8);
+				}
+				break;
 			default:
 				hex_dump(level + 1, frm, len - 2);
 				frm->ptr += (len - 2);
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux