All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH  1/4] monitor: Add AVRCP GetFolderItems Support
@ 2015-04-16 13:16 Bharat Panda
  2015-04-16 13:16 ` [PATCH 2/4] monitor: Add MediaPlayerItem for GetFolderItems Bharat Panda
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Bharat Panda @ 2015-04-16 13:16 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: cpgs, Bharat Panda

Support for decoding AVRCP GetFolderItems added in btmon.

      Channel: 65 len 20 ctrl 0x0000 [PSM 27 mode 3] {chan 1}
      I-frame: Unsegmented TxSeq 0 ReqSeq 0
      AVCTP Browsing: Command: type 0x00 label 0 PID 0x110e
        AVRCP: GetFolderItems: len 0x000a
          Scope: 0x01 (Media Player Virtual Filesystem)
          StartItem: 0x00000000 (0)
          EndItem: 0x0000000a (10)
          AttributeCount: 0xff (255)
          AttributeID: 0x0000326e (Reserved)
---
 monitor/avctp.c | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 111 insertions(+), 2 deletions(-)

diff --git a/monitor/avctp.c b/monitor/avctp.c
index c599aa4..a55cb41 100644
--- a/monitor/avctp.c
+++ b/monitor/avctp.c
@@ -182,6 +182,11 @@
 #define AVRCP_MEDIA_SEARCH		0x02
 #define AVRCP_MEDIA_NOW_PLAYING		0x03
 
+/* Media Item Type */
+#define AVRCP_MEDIA_PLAYER_ITEM_TYPE	0x01
+#define AVRCP_FOLDER_ITEM_TYPE			0x02
+#define AVRCP_MEDIA_ELEMENT_ITEM_TYPE	0x03
+
 /* operands in passthrough commands */
 #define AVC_PANEL_VOLUME_UP		0x41
 #define AVC_PANEL_VOLUME_DOWN		0x42
@@ -677,6 +682,20 @@ static char *op2str(uint8_t op)
 	}
 }
 
+static const char *type2str(uint8_t type)
+{
+	switch (type) {
+	case AVRCP_MEDIA_PLAYER_ITEM_TYPE:
+		return "Media Player";
+	case AVRCP_FOLDER_ITEM_TYPE:
+		return "Folder";
+	case AVRCP_MEDIA_ELEMENT_ITEM_TYPE:
+		return "Media Element";
+	default:
+		return "Unknown";
+	}
+}
+
 static bool avrcp_passthrough_packet(struct avctp_frame *avctp_frame,
 								uint8_t indent)
 {
@@ -1096,10 +1115,10 @@ static bool avrcp_get_element_attributes(struct avctp_frame *avctp_frame,
 	for (; num > 0; num--) {
 		uint32_t attr;
 
-		if (!l2cap_frame_get_be32(frame, &attr))
+		if (!l2cap_frame_get_le32(frame, &attr))
 			return false;
 
-		print_field("%*cAttribute: 0x%08x (%s)", (indent - 8),
+		print_field("%*cAttributeID: 0x%08x (%s)", (indent - 8),
 					' ', attr, mediattr2str(attr));
 	}
 
@@ -1637,6 +1656,93 @@ static bool avrcp_control_packet(struct avctp_frame *avctp_frame)
 	}
 }
 
+static bool avrcp_get_folder_items(struct avctp_frame *avctp_frame)
+{
+	struct l2cap_frame *frame = &avctp_frame->l2cap_frame;
+	uint8_t scope, count, status, indent = 2;
+	uint32_t start, end;
+	uint16_t uid, num;
+
+	if (avctp_frame->hdr & 0x02)
+		goto response;
+
+	if (!l2cap_frame_get_u8(frame, &scope))
+		return false;
+
+	print_field("%*cScope: 0x%02x (%s)", indent, ' ',
+					scope, scope2str(scope));
+
+	if (!l2cap_frame_get_be32(frame, &start))
+		return false;
+
+	print_field("%*cStartItem: 0x%08x (%u)", indent, ' ', start, start);
+
+	if (!l2cap_frame_get_be32(frame, &end))
+		return false;
+
+	print_field("%*cEndItem: 0x%08x (%u)", indent, ' ', end, end);
+
+	if (!l2cap_frame_get_u8(frame, &count))
+		return false;
+
+	print_field("%*cAttributeCount: 0x%02x (%u)", indent, ' ',
+						count, count);
+
+	for (; count > 0; count--) {
+		uint16_t attr;
+
+		if (!l2cap_frame_get_be16(frame, &attr)) {
+			return false;
+		}
+
+		print_field("%*cAttributeID: 0x%08x (%s)", indent, ' ',
+					attr, mediattr2str(attr));
+	}
+
+	return false;
+
+response:
+	if (!l2cap_frame_get_u8(frame, &status))
+		return false;
+
+	print_field("%*cStatus: 0x%02x (%s)", indent, ' ',
+				status, error2str(status));
+
+	if (!l2cap_frame_get_be16(frame, &uid))
+		return false;
+
+	print_field("%*cUIDCounter: 0x%04x (%u)", indent, ' ', uid, uid);
+
+	if (!l2cap_frame_get_be16(frame, &num))
+		return false;
+
+	print_field("%*cUIDCounter: 0x%04x (%u)", indent, ' ', num, num);
+
+	for (; num > 0; num--) {
+		uint8_t type;
+		uint16_t len;
+
+		if (!l2cap_frame_get_u8(frame, &type))
+			return false;
+
+		if (!l2cap_frame_get_be16(frame, &len))
+			return false;
+
+		print_field("%*cItem: 0x%02x (%s) ", indent, ' ',
+					type, type2str(type));
+		print_field("%*cLength: 0x%04x (%u)", indent, ' ', len, len);
+
+		switch (type) {
+		case AVRCP_MEDIA_PLAYER_ITEM_TYPE:
+		case AVRCP_FOLDER_ITEM_TYPE:
+		case AVRCP_MEDIA_ELEMENT_ITEM_TYPE:
+			packet_hexdump(frame->data, frame->size);
+			break;
+		}
+	}
+	return true;
+}
+
 static bool avrcp_set_browsed_player(struct avctp_frame *avctp_frame)
 {
 	struct l2cap_frame *frame = &avctp_frame->l2cap_frame;
@@ -1722,6 +1828,9 @@ static bool avrcp_browsing_packet(struct avctp_frame *avctp_frame)
 	case AVRCP_SET_BROWSED_PLAYER:
 		avrcp_set_browsed_player(avctp_frame);
 		break;
+	case AVRCP_GET_FOLDER_ITEMS:
+		avrcp_get_folder_items(avctp_frame);
+		break;
 	default:
 		packet_hexdump(frame->data, frame->size);
 	}
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH  2/4] monitor: Add MediaPlayerItem for GetFolderItems
  2015-04-16 13:16 [PATCH 1/4] monitor: Add AVRCP GetFolderItems Support Bharat Panda
@ 2015-04-16 13:16 ` Bharat Panda
  2015-04-16 13:16 ` [PATCH 3/4] monitor: Add FolderItem support " Bharat Panda
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Bharat Panda @ 2015-04-16 13:16 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: cpgs, Bharat Panda

Add support for decoding GetFolderItems(MediaPlayerItem) for avrcp
in bluetooth monitor.

      Channel: 65 len 20 ctrl 0x0306 [PSM 27 mode 3] {chan 1}
      I-frame: Unsegmented TxSeq 3 ReqSeq 3
      AVCTP Browsing: Command: type 0x00 label 0 PID 0x110e
        AVRCP: GetFolderItems: len 0x000a
          Scope: 0x00 (Media Player List)
          StartItem: 0x00000000 (0)
          EndItem: 0x00000064 (100)
          AttributeCount: 0x00 (0)
---
 monitor/avctp.c | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 monitor/l2cap.h |  16 ++++++++
 2 files changed, 133 insertions(+), 2 deletions(-)

diff --git a/monitor/avctp.c b/monitor/avctp.c
index a55cb41..a109d5c 100644
--- a/monitor/avctp.c
+++ b/monitor/avctp.c
@@ -696,6 +696,58 @@ static const char *type2str(uint8_t type)
 	}
 }
 
+static const char *playertype2str(uint8_t type)
+{
+	switch (type & 0x0F) {
+	case 0x01:
+		return "Audio";
+	case 0x02:
+		return "Video";
+	case 0x03:
+		return "Audio, Video";
+	case 0x04:
+		return "Audio Broadcasting";
+	case 0x05:
+		return "Audio, Audio Broadcasting";
+	case 0x06:
+		return "Video, Audio Broadcasting";
+	case 0x07:
+		return "Audio, Video, Audio Broadcasting";
+	case 0x08:
+		return "Video Broadcasting";
+	case 0x09:
+		return "Audio, Video Broadcasting";
+	case 0x0A:
+		return "Video, Video Broadcasting";
+	case 0x0B:
+		return "Audio, Video, Video Broadcasting";
+	case 0x0C:
+		return "Audio Broadcasting, Video Broadcasting";
+	case 0x0D:
+		return "Audio, Audio Broadcasting, Video Broadcasting";
+	case 0x0E:
+		return "Video, Audio Broadcasting, Video Broadcasting";
+	case 0x0F:
+		return "Audio, Video, Audio Broadcasting, Video Broadcasting";
+	}
+
+	return "None";
+}
+
+static const char *playersubtype2str(uint32_t subtype)
+{
+	switch (subtype & 0x03) {
+	case 0x01:
+		return "Audio Book";
+	case 0x02:
+		return "Podcast";
+	case 0x03:
+		return "Audio Book, Podcast";
+	}
+
+	return "None";
+}
+
 static bool avrcp_passthrough_packet(struct avctp_frame *avctp_frame,
 								uint8_t indent)
 {
@@ -1656,6 +1708,68 @@ static bool avrcp_control_packet(struct avctp_frame *avctp_frame)
 	}
 }
 
+static bool avrcp_media_player_item(struct avctp_frame *avctp_frame,
+							uint8_t indent)
+{
+	struct l2cap_frame *frame = &avctp_frame->l2cap_frame;
+	uint16_t id, charset, namelen;
+	uint8_t type, status;
+	uint32_t subtype;
+	uint64_t features[2];
+
+	if (!l2cap_frame_get_be16(frame, &id))
+		return false;
+
+	print_field("%*cPlayerID: 0x%04x (%u)", indent, ' ', id, id);
+
+	if (!l2cap_frame_get_u8(frame, &type))
+		return false;
+
+	print_field("%*cPlayerID: 0x%04x (%s)", indent, ' ',
+						type, playertype2str(type));
+
+	if (!l2cap_frame_get_be32(frame, &subtype))
+		return false;
+
+	print_field("%*cPlayerID: 0x%08x (%s)", indent, ' ',
+					subtype, playersubtype2str(subtype));
+
+	if (!l2cap_frame_get_u8(frame, &status))
+		return false;
+
+	print_field("%*cPlayerID: 0x%02x (%s)", indent, ' ',
+						status, playstatus2str(status));
+
+	if (l2cap_frame_get_be128(frame, &features[0], &features[1]))
+		return false;
+
+	print_field("%*cFeatures: 0x%16" PRIx64 "%16" PRIx64, indent, ' ',
+						features[1], features[0]);
+
+	if (!l2cap_frame_get_be16(frame, &charset))
+		return false;
+
+	print_field("%*cCharsetID: 0x%04x (%s)", indent, ' ',
+						charset, charset2str(charset));
+
+	if (!l2cap_frame_get_be16(frame, &namelen))
+		return false;
+
+	print_field("%*cNameLength: 0x%04x (%u)", indent, ' ',
+						namelen, namelen);
+
+	printf("%*cName: ", indent, ' ');
+	for (; namelen > 0; namelen--) {
+		uint8_t c;
+
+		if (!l2cap_frame_get_u8(frame, &c))
+			return false;
+		printf("%1c", isprint(c) ? c : '.');
+	}
+
+	return true;
+}
+
 static bool avrcp_get_folder_items(struct avctp_frame *avctp_frame)
 {
 	struct l2cap_frame *frame = &avctp_frame->l2cap_frame;
@@ -1691,9 +1805,8 @@ static bool avrcp_get_folder_items(struct avctp_frame *avctp_frame)
 	for (; count > 0; count--) {
 		uint16_t attr;
 
-		if (!l2cap_frame_get_be16(frame, &attr)) {
+		if (!l2cap_frame_get_be16(frame, &attr))
 			return false;
-		}
 
 		print_field("%*cAttributeID: 0x%08x (%s)", indent, ' ',
 					attr, mediattr2str(attr));
@@ -1734,6 +1847,8 @@ response:
 
 		switch (type) {
 		case AVRCP_MEDIA_PLAYER_ITEM_TYPE:
+			avrcp_media_player_item(avctp_frame, indent);
+			break;
 		case AVRCP_FOLDER_ITEM_TYPE:
 		case AVRCP_MEDIA_ELEMENT_ITEM_TYPE:
 			packet_hexdump(frame->data, frame->size);
diff --git a/monitor/l2cap.h b/monitor/l2cap.h
index 711bcb1..0364454 100644
--- a/monitor/l2cap.h
+++ b/monitor/l2cap.h
@@ -153,6 +153,22 @@ static inline bool l2cap_frame_get_le64(struct l2cap_frame *frame,
 	return true;
 }
 
+static inline bool l2cap_frame_get_be128(struct l2cap_frame *frame,
+					uint64_t *lvalue, uint64_t *rvalue)
+{
+	if (frame->size < (sizeof(*lvalue) + sizeof(*rvalue)))
+		return false;
+
+	if (lvalue && rvalue) {
+		*lvalue = get_be64(frame->data);
+		*rvalue = get_be64(frame->data);
+	}
+
+	l2cap_frame_pull(frame, frame, (sizeof(*lvalue) + sizeof(*rvalue)));
+
+	return true;
+}
+
 void l2cap_packet(uint16_t index, bool in, uint16_t handle, uint8_t flags,
 					const void *data, uint16_t size);
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH  3/4] monitor: Add FolderItem support for GetFolderItems
  2015-04-16 13:16 [PATCH 1/4] monitor: Add AVRCP GetFolderItems Support Bharat Panda
  2015-04-16 13:16 ` [PATCH 2/4] monitor: Add MediaPlayerItem for GetFolderItems Bharat Panda
@ 2015-04-16 13:16 ` Bharat Panda
  2015-04-16 13:16 ` [PATCH 4/4] monitor: Add MediaElementItem " Bharat Panda
  2015-04-17 14:03 ` [PATCH 1/4] monitor: Add AVRCP GetFolderItems Support Luiz Augusto von Dentz
  3 siblings, 0 replies; 6+ messages in thread
From: Bharat Panda @ 2015-04-16 13:16 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: cpgs, Bharat Panda

Add support for decoding GetFolderItems(FolderItem) for avrcp in
bluetooth monitor.

      Channel: 65 len 20 ctrl 0x0000 [PSM 27 mode 3] {chan 1}
      I-frame: Unsegmented TxSeq 0 ReqSeq 0
      AVCTP Browsing: Command: type 0x00 label 0 PID 0x110e
        AVRCP: GetFolderItems: len 0x000a
          Scope: 0x01 (Media Player Virtual Filesystem)
          StartItem: 0x00000000 (0)
          EndItem: 0x0000000a (10)
          AttributeCount: 0xff (255)
          AttributeID: 0x0000326e (Reserved)
---
 monitor/avctp.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)

diff --git a/monitor/avctp.c b/monitor/avctp.c
index a109d5c..7e55bef 100644
--- a/monitor/avctp.c
+++ b/monitor/avctp.c
@@ -748,6 +748,28 @@ static const char *playersubtype2str(uint32_t subtype)
 	return "None";
 }
 
+static const char *foldertype2str(uint8_t type)
+{
+	switch (type) {
+	case 0x00:
+		return "Mixed";
+	case 0x01:
+		return "Titles";
+	case 0x02:
+		return "Albuns";
+	case 0x03:
+		return "Artists";
+	case 0x04:
+		return "Genres";
+	case 0x05:
+		return "Playlists";
+	case 0x06:
+		return "Years";
+	}
+
+	return "Reserved";
+}
+
 static bool avrcp_passthrough_packet(struct avctp_frame *avctp_frame,
 								uint8_t indent)
 {
@@ -1770,6 +1792,61 @@ static bool avrcp_media_player_item(struct avctp_frame *avctp_frame,
 	return true;
 }
 
+static bool avrcp_folder_item(struct avctp_frame *avctp_frame,
+							uint8_t indent)
+{
+	struct l2cap_frame *frame = &avctp_frame->l2cap_frame;
+	uint8_t type, playable;
+	uint16_t charset, namelen;
+	uint64_t uid;
+
+	if (frame->size < 14) {
+		printf("PDU Malformed\n");
+		return false;
+	}
+
+	if (!l2cap_frame_get_be64(frame, &uid))
+		return false;
+
+	print_field("%*cFolderUID: 0x%16" PRIx64 " (%" PRIu64 ")", indent, ' ',
+						uid, uid);
+
+	if (!l2cap_frame_get_u8(frame, &type))
+		return false;
+
+	print_field("%*cFolderType: 0x%02x (%s)", indent, ' ',
+						type, foldertype2str(type));
+
+	if (!l2cap_frame_get_u8(frame, &playable))
+		return false;
+
+	print_field("%*cIsPlayable: 0x%02x (%s)", indent, ' ', playable,
+					playable & 0x01 ? "True" : "False");
+
+	if (!l2cap_frame_get_be16(frame, &charset))
+		return false;
+
+	print_field("%*cCharsetID: 0x%04x (%s)", indent, ' ',
+					charset, charset2str(charset));
+
+	if (!l2cap_frame_get_be16(frame, &namelen))
+		return false;
+
+	print_field("%*cNameLength: 0x%04x (%u)", indent, ' ',
+					namelen, namelen);
+
+	print_field("%*cName: ", indent, ' ');
+	for (; namelen > 0; namelen--) {
+		uint8_t c;
+		if (!l2cap_frame_get_u8(frame, &c))
+			return false;
+
+		printf("%1c", isprint(c) ? c : '.');
+	}
+
+	return true;
+}
+
 static bool avrcp_get_folder_items(struct avctp_frame *avctp_frame)
 {
 	struct l2cap_frame *frame = &avctp_frame->l2cap_frame;
@@ -1850,6 +1927,8 @@ response:
 			avrcp_media_player_item(avctp_frame, indent);
 			break;
 		case AVRCP_FOLDER_ITEM_TYPE:
+			avrcp_folder_item(avctp_frame, indent);
+			break;
 		case AVRCP_MEDIA_ELEMENT_ITEM_TYPE:
 			packet_hexdump(frame->data, frame->size);
 			break;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH  4/4] monitor: Add MediaElementItem for GetFolderItems
  2015-04-16 13:16 [PATCH 1/4] monitor: Add AVRCP GetFolderItems Support Bharat Panda
  2015-04-16 13:16 ` [PATCH 2/4] monitor: Add MediaPlayerItem for GetFolderItems Bharat Panda
  2015-04-16 13:16 ` [PATCH 3/4] monitor: Add FolderItem support " Bharat Panda
@ 2015-04-16 13:16 ` Bharat Panda
  2015-04-17 14:03 ` [PATCH 1/4] monitor: Add AVRCP GetFolderItems Support Luiz Augusto von Dentz
  3 siblings, 0 replies; 6+ messages in thread
From: Bharat Panda @ 2015-04-16 13:16 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: cpgs, Bharat Panda

Add support for decoding GetFolderItems(MediaElementItem) for avrcp in
bluetooth monitor.

      Channel: 65 len 20 ctrl 0x0000 [PSM 27 mode 3] {chan 1}
      I-frame: Unsegmented TxSeq 0 ReqSeq 0
      AVCTP Browsing: Command: type 0x00 label 0 PID 0x110e
        AVRCP: GetFolderItems: len 0x000a
          Scope: 0x01 (Media Player Virtual Filesystem)
          StartItem: 0x00000000 (0)
          EndItem: 0x0000000a (10)
          AttributeCount: 0xff (255)
          AttributeID: 0x0000326e (Reserved)
---
 monitor/avctp.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 111 insertions(+)

diff --git a/monitor/avctp.c b/monitor/avctp.c
index 7e55bef..4fcbfa1 100644
--- a/monitor/avctp.c
+++ b/monitor/avctp.c
@@ -770,6 +770,18 @@ static const char *foldertype2str(uint8_t type)
 	return "Reserved";
 }
 
+static const char *elementtype2str(uint8_t type)
+{
+	switch (type) {
+	case 0x00:
+		return "Audio";
+	case 0x01:
+		return "Video";
+	}
+
+	return "Reserved";
+}
+
 static bool avrcp_passthrough_packet(struct avctp_frame *avctp_frame,
 								uint8_t indent)
 {
@@ -1847,6 +1859,101 @@ static bool avrcp_folder_item(struct avctp_frame *avctp_frame,
 	return true;
 }
 
+static bool avrcp_attribute_entry_list(struct avctp_frame *avctp_frame,
+						uint8_t indent, uint8_t count)
+{
+	struct l2cap_frame *frame = &avctp_frame->l2cap_frame;
+
+	for (; count > 0; count--) {
+		uint32_t attr;
+		uint16_t charset;
+		uint8_t len;
+
+		if (!l2cap_frame_get_be32(frame, &attr))
+			return false;
+
+		print_field("%*cAttributeID: 0x%08x (%s)", indent, ' ',
+						attr, mediattr2str(attr));
+
+		if (!l2cap_frame_get_be16(frame, &charset))
+			return false;
+
+		print_field("%*cCharsetID: 0x%04x (%s)", indent, ' ',
+						charset, charset2str(charset));
+
+		if (!l2cap_frame_get_u8(frame, &len))
+			return false;
+
+		print_field("%*cAttributeLength: 0x%02x (%u)", indent, ' ',
+						len, len);
+
+		print_field("%*cAttributeValue: ", indent, ' ');
+		for (; len > 0; len--) {
+			uint8_t c;
+
+			if (!l2cap_frame_get_u8(frame, &c))
+				return false;
+
+			printf("%1c", isprint(c) ? c : '.');
+		}
+	}
+
+	return true;
+}
+
+static bool avrcp_media_element_item(struct avctp_frame *avctp_frame,
+							uint8_t indent)
+{
+	struct l2cap_frame *frame = &avctp_frame->l2cap_frame;
+	uint64_t uid;
+	uint16_t charset, namelen;
+	uint8_t type, count;
+
+	if (!l2cap_frame_get_be64(frame, &uid))
+		return false;
+
+	print_field("%*cElementUID: 0x%16" PRIx64 " (%" PRIu64 ")",
+					indent, ' ', uid, uid);
+
+	if (!l2cap_frame_get_u8(frame, &type))
+		return false;
+
+	print_field("%*cElementType: 0x%02x (%s)", indent, ' ',
+					type, elementtype2str(type));
+
+	if (!l2cap_frame_get_be16(frame, &charset))
+		return false;
+
+	print_field("%*cCharsetID: 0x%04x (%s)", indent, ' ',
+					charset, charset2str(charset));
+
+	if (!l2cap_frame_get_be16(frame, &namelen))
+		return false;
+
+	print_field("%*cNameLength: 0x%04x (%u)", indent, ' ',
+					namelen, namelen);
+
+	print_field("%*cName: ", indent, ' ');
+	for (; namelen > 0; namelen--) {
+		uint8_t c;
+		if (!l2cap_frame_get_u8(frame, &c))
+			return false;
+
+		printf("%1c", isprint(c) ? c : '.');
+	}
+
+	if (!l2cap_frame_get_u8(frame, &count))
+		return false;
+
+	print_field("%*cAttributeCount: 0x%02x (%u)", indent, ' ',
+						count, count);
+
+	if (!avrcp_attribute_entry_list(avctp_frame, indent, count))
+		return false;
+
+	return true;
+}
+
 static bool avrcp_get_folder_items(struct avctp_frame *avctp_frame)
 {
 	struct l2cap_frame *frame = &avctp_frame->l2cap_frame;
@@ -1930,6 +2037,10 @@ response:
 			avrcp_folder_item(avctp_frame, indent);
 			break;
 		case AVRCP_MEDIA_ELEMENT_ITEM_TYPE:
+			avrcp_media_element_item(avctp_frame, indent);
+			break;
+		default:
+			print_field("%*cUnknown Media Item type", indent, ' ');
 			packet_hexdump(frame->data, frame->size);
 			break;
 		}
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/4] monitor: Add AVRCP GetFolderItems Support
  2015-04-16 13:16 [PATCH 1/4] monitor: Add AVRCP GetFolderItems Support Bharat Panda
                   ` (2 preceding siblings ...)
  2015-04-16 13:16 ` [PATCH 4/4] monitor: Add MediaElementItem " Bharat Panda
@ 2015-04-17 14:03 ` Luiz Augusto von Dentz
  2015-04-21 11:58   ` Bharat Bhusan Panda
  3 siblings, 1 reply; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2015-04-17 14:03 UTC (permalink / raw)
  To: Bharat Panda; +Cc: linux-bluetooth, cpgs

Hi Bharat,

On Thu, Apr 16, 2015 at 4:16 PM, Bharat Panda <bharat.panda@samsung.com> wrote:
> Support for decoding AVRCP GetFolderItems added in btmon.
>
>       Channel: 65 len 20 ctrl 0x0000 [PSM 27 mode 3] {chan 1}
>       I-frame: Unsegmented TxSeq 0 ReqSeq 0
>       AVCTP Browsing: Command: type 0x00 label 0 PID 0x110e
>         AVRCP: GetFolderItems: len 0x000a
>           Scope: 0x01 (Media Player Virtual Filesystem)
>           StartItem: 0x00000000 (0)
>           EndItem: 0x0000000a (10)
>           AttributeCount: 0xff (255)
>           AttributeID: 0x0000326e (Reserved)
> ---
>  monitor/avctp.c | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 111 insertions(+), 2 deletions(-)
>
> diff --git a/monitor/avctp.c b/monitor/avctp.c
> index c599aa4..a55cb41 100644
> --- a/monitor/avctp.c
> +++ b/monitor/avctp.c
> @@ -182,6 +182,11 @@
>  #define AVRCP_MEDIA_SEARCH             0x02
>  #define AVRCP_MEDIA_NOW_PLAYING                0x03
>
> +/* Media Item Type */
> +#define AVRCP_MEDIA_PLAYER_ITEM_TYPE   0x01
> +#define AVRCP_FOLDER_ITEM_TYPE                 0x02
> +#define AVRCP_MEDIA_ELEMENT_ITEM_TYPE  0x03
> +
>  /* operands in passthrough commands */
>  #define AVC_PANEL_VOLUME_UP            0x41
>  #define AVC_PANEL_VOLUME_DOWN          0x42
> @@ -677,6 +682,20 @@ static char *op2str(uint8_t op)
>         }
>  }
>
> +static const char *type2str(uint8_t type)
> +{
> +       switch (type) {
> +       case AVRCP_MEDIA_PLAYER_ITEM_TYPE:
> +               return "Media Player";
> +       case AVRCP_FOLDER_ITEM_TYPE:
> +               return "Folder";
> +       case AVRCP_MEDIA_ELEMENT_ITEM_TYPE:
> +               return "Media Element";
> +       default:
> +               return "Unknown";
> +       }
> +}
> +
>  static bool avrcp_passthrough_packet(struct avctp_frame *avctp_frame,
>                                                                 uint8_t indent)
>  {
> @@ -1096,10 +1115,10 @@ static bool avrcp_get_element_attributes(struct avctp_frame *avctp_frame,
>         for (; num > 0; num--) {
>                 uint32_t attr;
>
> -               if (!l2cap_frame_get_be32(frame, &attr))
> +               if (!l2cap_frame_get_le32(frame, &attr))
>                         return false;
>
> -               print_field("%*cAttribute: 0x%08x (%s)", (indent - 8),
> +               print_field("%*cAttributeID: 0x%08x (%s)", (indent - 8),
>                                         ' ', attr, mediattr2str(attr));
>         }
>
> @@ -1637,6 +1656,93 @@ static bool avrcp_control_packet(struct avctp_frame *avctp_frame)
>         }
>  }
>
> +static bool avrcp_get_folder_items(struct avctp_frame *avctp_frame)
> +{
> +       struct l2cap_frame *frame = &avctp_frame->l2cap_frame;
> +       uint8_t scope, count, status, indent = 2;
> +       uint32_t start, end;
> +       uint16_t uid, num;
> +
> +       if (avctp_frame->hdr & 0x02)
> +               goto response;
> +
> +       if (!l2cap_frame_get_u8(frame, &scope))
> +               return false;
> +
> +       print_field("%*cScope: 0x%02x (%s)", indent, ' ',
> +                                       scope, scope2str(scope));
> +
> +       if (!l2cap_frame_get_be32(frame, &start))
> +               return false;
> +
> +       print_field("%*cStartItem: 0x%08x (%u)", indent, ' ', start, start);
> +
> +       if (!l2cap_frame_get_be32(frame, &end))
> +               return false;
> +
> +       print_field("%*cEndItem: 0x%08x (%u)", indent, ' ', end, end);
> +
> +       if (!l2cap_frame_get_u8(frame, &count))
> +               return false;
> +
> +       print_field("%*cAttributeCount: 0x%02x (%u)", indent, ' ',
> +                                               count, count);
> +
> +       for (; count > 0; count--) {
> +               uint16_t attr;
> +
> +               if (!l2cap_frame_get_be16(frame, &attr)) {
> +                       return false;
> +               }
> +
> +               print_field("%*cAttributeID: 0x%08x (%s)", indent, ' ',
> +                                       attr, mediattr2str(attr));
> +       }
> +
> +       return false;
> +
> +response:
> +       if (!l2cap_frame_get_u8(frame, &status))
> +               return false;
> +
> +       print_field("%*cStatus: 0x%02x (%s)", indent, ' ',
> +                               status, error2str(status));
> +
> +       if (!l2cap_frame_get_be16(frame, &uid))
> +               return false;
> +
> +       print_field("%*cUIDCounter: 0x%04x (%u)", indent, ' ', uid, uid);
> +
> +       if (!l2cap_frame_get_be16(frame, &num))
> +               return false;
> +
> +       print_field("%*cUIDCounter: 0x%04x (%u)", indent, ' ', num, num);
> +
> +       for (; num > 0; num--) {
> +               uint8_t type;
> +               uint16_t len;
> +
> +               if (!l2cap_frame_get_u8(frame, &type))
> +                       return false;
> +
> +               if (!l2cap_frame_get_be16(frame, &len))
> +                       return false;
> +
> +               print_field("%*cItem: 0x%02x (%s) ", indent, ' ',
> +                                       type, type2str(type));
> +               print_field("%*cLength: 0x%04x (%u)", indent, ' ', len, len);
> +
> +               switch (type) {
> +               case AVRCP_MEDIA_PLAYER_ITEM_TYPE:
> +               case AVRCP_FOLDER_ITEM_TYPE:
> +               case AVRCP_MEDIA_ELEMENT_ITEM_TYPE:
> +                       packet_hexdump(frame->data, frame->size);
> +                       break;
> +               }
> +       }
> +       return true;
> +}
> +
>  static bool avrcp_set_browsed_player(struct avctp_frame *avctp_frame)
>  {
>         struct l2cap_frame *frame = &avctp_frame->l2cap_frame;
> @@ -1722,6 +1828,9 @@ static bool avrcp_browsing_packet(struct avctp_frame *avctp_frame)
>         case AVRCP_SET_BROWSED_PLAYER:
>                 avrcp_set_browsed_player(avctp_frame);
>                 break;
> +       case AVRCP_GET_FOLDER_ITEMS:
> +               avrcp_get_folder_items(avctp_frame);
> +               break;
>         default:
>                 packet_hexdump(frame->data, frame->size);
>         }
> --
> 1.9.1

Applied, note that one of the patches was not compiling:

http://fpaste.org/212274/29279121/

Im not sure how you were even able to test it before because
if(l2cap_frame_get_be128 should always return but after fixing the
check for !l2cap_frame_get_be128 it seems to work properly.


-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH 1/4] monitor: Add AVRCP GetFolderItems Support
  2015-04-17 14:03 ` [PATCH 1/4] monitor: Add AVRCP GetFolderItems Support Luiz Augusto von Dentz
@ 2015-04-21 11:58   ` Bharat Bhusan Panda
  0 siblings, 0 replies; 6+ messages in thread
From: Bharat Bhusan Panda @ 2015-04-21 11:58 UTC (permalink / raw)
  To: 'Luiz Augusto von Dentz'; +Cc: linux-bluetooth, cpgs

Hi Luiz,

> -----Original Message-----
> From: linux-bluetooth-owner@vger.kernel.org [mailto:linux-bluetooth-
> owner@vger.kernel.org] On Behalf Of Luiz Augusto von Dentz
> Sent: Friday, April 17, 2015 7:34 PM
> To: Bharat Panda
> Cc: linux-bluetooth@vger.kernel.org; cpgs@samsung.com
> Subject: Re: [PATCH 1/4] monitor: Add AVRCP GetFolderItems Support
> 
> Hi Bharat,
> 
> On Thu, Apr 16, 2015 at 4:16 PM, Bharat Panda
> <bharat.panda@samsung.com> wrote:
> > Support for decoding AVRCP GetFolderItems added in btmon.
> >
> >       Channel: 65 len 20 ctrl 0x0000 [PSM 27 mode 3] {chan 1}
> >       I-frame: Unsegmented TxSeq 0 ReqSeq 0
> >       AVCTP Browsing: Command: type 0x00 label 0 PID 0x110e
> >         AVRCP: GetFolderItems: len 0x000a
> >           Scope: 0x01 (Media Player Virtual Filesystem)
> >           StartItem: 0x00000000 (0)
> >           EndItem: 0x0000000a (10)
> >           AttributeCount: 0xff (255)
> >           AttributeID: 0x0000326e (Reserved)
> > ---
> >  monitor/avctp.c | 113
> > +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
> >  1 file changed, 111 insertions(+), 2 deletions(-)
> >
> > diff --git a/monitor/avctp.c b/monitor/avctp.c index c599aa4..a55cb41
> > 100644
> > --- a/monitor/avctp.c
> > +++ b/monitor/avctp.c
> > @@ -182,6 +182,11 @@
> >  #define AVRCP_MEDIA_SEARCH             0x02
> >  #define AVRCP_MEDIA_NOW_PLAYING                0x03
> >
> > +/* Media Item Type */
> > +#define AVRCP_MEDIA_PLAYER_ITEM_TYPE   0x01
> > +#define AVRCP_FOLDER_ITEM_TYPE                 0x02
> > +#define AVRCP_MEDIA_ELEMENT_ITEM_TYPE  0x03
> > +
> >  /* operands in passthrough commands */
> >  #define AVC_PANEL_VOLUME_UP            0x41
> >  #define AVC_PANEL_VOLUME_DOWN          0x42
> > @@ -677,6 +682,20 @@ static char *op2str(uint8_t op)
> >         }
> >  }
> >
> > +static const char *type2str(uint8_t type) {
> > +       switch (type) {
> > +       case AVRCP_MEDIA_PLAYER_ITEM_TYPE:
> > +               return "Media Player";
> > +       case AVRCP_FOLDER_ITEM_TYPE:
> > +               return "Folder";
> > +       case AVRCP_MEDIA_ELEMENT_ITEM_TYPE:
> > +               return "Media Element";
> > +       default:
> > +               return "Unknown";
> > +       }
> > +}
> > +
> >  static bool avrcp_passthrough_packet(struct avctp_frame *avctp_frame,
> >
> > uint8_t indent)  { @@ -1096,10 +1115,10 @@ static bool
> > avrcp_get_element_attributes(struct avctp_frame *avctp_frame,
> >         for (; num > 0; num--) {
> >                 uint32_t attr;
> >
> > -               if (!l2cap_frame_get_be32(frame, &attr))
> > +               if (!l2cap_frame_get_le32(frame, &attr))
> >                         return false;
> >
> > -               print_field("%*cAttribute: 0x%08x (%s)", (indent - 8),
> > +               print_field("%*cAttributeID: 0x%08x (%s)", (indent -
> > + 8),
> >                                         ' ', attr, mediattr2str(attr));
> >         }
> >
> > @@ -1637,6 +1656,93 @@ static bool avrcp_control_packet(struct
> avctp_frame *avctp_frame)
> >         }
> >  }
> >
> > +static bool avrcp_get_folder_items(struct avctp_frame *avctp_frame) {
> > +       struct l2cap_frame *frame = &avctp_frame->l2cap_frame;
> > +       uint8_t scope, count, status, indent = 2;
> > +       uint32_t start, end;
> > +       uint16_t uid, num;
> > +
> > +       if (avctp_frame->hdr & 0x02)
> > +               goto response;
> > +
> > +       if (!l2cap_frame_get_u8(frame, &scope))
> > +               return false;
> > +
> > +       print_field("%*cScope: 0x%02x (%s)", indent, ' ',
> > +                                       scope, scope2str(scope));
> > +
> > +       if (!l2cap_frame_get_be32(frame, &start))
> > +               return false;
> > +
> > +       print_field("%*cStartItem: 0x%08x (%u)", indent, ' ', start,
> > + start);
> > +
> > +       if (!l2cap_frame_get_be32(frame, &end))
> > +               return false;
> > +
> > +       print_field("%*cEndItem: 0x%08x (%u)", indent, ' ', end, end);
> > +
> > +       if (!l2cap_frame_get_u8(frame, &count))
> > +               return false;
> > +
> > +       print_field("%*cAttributeCount: 0x%02x (%u)", indent, ' ',
> > +                                               count, count);
> > +
> > +       for (; count > 0; count--) {
> > +               uint16_t attr;
> > +
> > +               if (!l2cap_frame_get_be16(frame, &attr)) {
> > +                       return false;
> > +               }
> > +
> > +               print_field("%*cAttributeID: 0x%08x (%s)", indent, ' ',
> > +                                       attr, mediattr2str(attr));
> > +       }
> > +
> > +       return false;
> > +
> > +response:
> > +       if (!l2cap_frame_get_u8(frame, &status))
> > +               return false;
> > +
> > +       print_field("%*cStatus: 0x%02x (%s)", indent, ' ',
> > +                               status, error2str(status));
> > +
> > +       if (!l2cap_frame_get_be16(frame, &uid))
> > +               return false;
> > +
> > +       print_field("%*cUIDCounter: 0x%04x (%u)", indent, ' ', uid,
> > + uid);
> > +
> > +       if (!l2cap_frame_get_be16(frame, &num))
> > +               return false;
> > +
> > +       print_field("%*cUIDCounter: 0x%04x (%u)", indent, ' ', num,
> > + num);
> > +
> > +       for (; num > 0; num--) {
> > +               uint8_t type;
> > +               uint16_t len;
> > +
> > +               if (!l2cap_frame_get_u8(frame, &type))
> > +                       return false;
> > +
> > +               if (!l2cap_frame_get_be16(frame, &len))
> > +                       return false;
> > +
> > +               print_field("%*cItem: 0x%02x (%s) ", indent, ' ',
> > +                                       type, type2str(type));
> > +               print_field("%*cLength: 0x%04x (%u)", indent, ' ',
> > + len, len);
> > +
> > +               switch (type) {
> > +               case AVRCP_MEDIA_PLAYER_ITEM_TYPE:
> > +               case AVRCP_FOLDER_ITEM_TYPE:
> > +               case AVRCP_MEDIA_ELEMENT_ITEM_TYPE:
> > +                       packet_hexdump(frame->data, frame->size);
> > +                       break;
> > +               }
> > +       }
> > +       return true;
> > +}
> > +
> >  static bool avrcp_set_browsed_player(struct avctp_frame *avctp_frame)
> > {
> >         struct l2cap_frame *frame = &avctp_frame->l2cap_frame; @@
> > -1722,6 +1828,9 @@ static bool avrcp_browsing_packet(struct avctp_frame
> *avctp_frame)
> >         case AVRCP_SET_BROWSED_PLAYER:
> >                 avrcp_set_browsed_player(avctp_frame);
> >                 break;
> > +       case AVRCP_GET_FOLDER_ITEMS:
> > +               avrcp_get_folder_items(avctp_frame);
> > +               break;
> >         default:
> >                 packet_hexdump(frame->data, frame->size);
> >         }
> > --
> > 1.9.1
> 
> Applied, note that one of the patches was not compiling:
> 
> http://fpaste.org/212274/29279121/
> 
> Im not sure how you were even able to test it before because
> if(l2cap_frame_get_be128 should always return but after fixing the check for
> !l2cap_frame_get_be128 it seems to work properly.
> 

Thanks. I will make sure such mistakes won't happen in future patches.

Best Regards,
Bharat



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-04-21 11:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-16 13:16 [PATCH 1/4] monitor: Add AVRCP GetFolderItems Support Bharat Panda
2015-04-16 13:16 ` [PATCH 2/4] monitor: Add MediaPlayerItem for GetFolderItems Bharat Panda
2015-04-16 13:16 ` [PATCH 3/4] monitor: Add FolderItem support " Bharat Panda
2015-04-16 13:16 ` [PATCH 4/4] monitor: Add MediaElementItem " Bharat Panda
2015-04-17 14:03 ` [PATCH 1/4] monitor: Add AVRCP GetFolderItems Support Luiz Augusto von Dentz
2015-04-21 11:58   ` Bharat Bhusan Panda

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.