linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] mgmt:  read supported codecs
@ 2012-11-22 12:47 Michael Knudsen
  2012-11-22 12:47 ` [PATCH 1/3] Bluetooth: Add HCI Coding Format definitions Michael Knudsen
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Michael Knudsen @ 2012-11-22 12:47 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Michael Knudsen

This implements the user space side of the read codecs command.

Michael Knudsen (3):
  Bluetooth:  Add HCI Coding Format definitions
  Bluetooth:  Support the read codecs operation
  Doco:  List the read codecs operation

 doc/mgmt-api.txt |   20 +++++++++++++++
 lib/hci.h        |    9 +++++++
 lib/mgmt.h       |    8 ++++++
 tools/btmgmt.c   |   74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 111 insertions(+)

-- 
1.7.9.5


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

* [PATCH 1/3] Bluetooth:  Add HCI Coding Format definitions
  2012-11-22 12:47 [PATCH 0/3] mgmt: read supported codecs Michael Knudsen
@ 2012-11-22 12:47 ` Michael Knudsen
  2012-11-22 12:47 ` [PATCH 2/3] Bluetooth: Support the read codecs operation Michael Knudsen
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Michael Knudsen @ 2012-11-22 12:47 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Michael Knudsen

---
 lib/hci.h |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lib/hci.h b/lib/hci.h
index 2f18ec8..5e5f6b5 100644
--- a/lib/hci.h
+++ b/lib/hci.h
@@ -295,6 +295,15 @@ enum {
 #define HCI_LM_RELIABLE	0x0010
 #define HCI_LM_SECURE	0x0020
 
+/* Coding Format */
+#define HCI_FORMAT_ULAW		0x00
+#define HCI_FORMAT_ALAW		0x01
+#define HCI_FORMAT_CVSD		0x02
+#define HCI_FORMAT_TRANSPARENT	0x03
+#define HCI_FORMAT_PCM		0x04
+#define HCI_FORMAT_MSBC		0x05
+#define HCI_FORMAT_VENDOR	0xff
+
 /* Link Key types */
 #define HCI_LK_COMBINATION		0x00
 #define HCI_LK_LOCAL_UNIT		0x01
-- 
1.7.9.5


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

* [PATCH 2/3] Bluetooth:  Support the read codecs operation
  2012-11-22 12:47 [PATCH 0/3] mgmt: read supported codecs Michael Knudsen
  2012-11-22 12:47 ` [PATCH 1/3] Bluetooth: Add HCI Coding Format definitions Michael Knudsen
@ 2012-11-22 12:47 ` Michael Knudsen
  2012-11-22 12:47 ` [PATCH 3/3] Doco: List " Michael Knudsen
  2012-11-23 10:10 ` [PATCH 0/3] mgmt: read supported codecs Kim Schulz
  3 siblings, 0 replies; 5+ messages in thread
From: Michael Knudsen @ 2012-11-22 12:47 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Michael Knudsen

---
 lib/mgmt.h     |    8 ++++++
 tools/btmgmt.c |   74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 82 insertions(+)

diff --git a/lib/mgmt.h b/lib/mgmt.h
index 6c7e44a..37b002c 100644
--- a/lib/mgmt.h
+++ b/lib/mgmt.h
@@ -318,6 +318,13 @@ struct mgmt_cp_set_device_id {
 	uint16_t version;
 } __packed;
 
+#define MGMT_OP_READ_CODECS            0x0029
+struct mgmt_rp_read_codecs {
+       uint8_t	count;
+       uint8_t	codec[0];
+} __packed;
+
+
 #define MGMT_EV_CMD_COMPLETE		0x0001
 struct mgmt_ev_cmd_complete {
 	uint16_t opcode;
@@ -496,6 +503,7 @@ static const char *mgmt_op[] = {
 	"Block Device",
 	"Unblock Device",
 	"Set Device ID",
+	"Read Codecs",
 };
 
 static const char *mgmt_ev[] = {
diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index ff6a46a..857c3a8 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
@@ -993,6 +993,79 @@ static void cmd_info(int mgmt_sk, uint16_t index, int argc, char **argv)
 	}
 }
 
+struct codecs_map {
+	int codec;
+	char *name;
+} codecs_map[] = {
+	{ HCI_FORMAT_ULAW,		"uLAW" },
+	{ HCI_FORMAT_ALAW,		"aLAW" },
+	{ HCI_FORMAT_CVSD,		"CVSD" },
+	{ HCI_FORMAT_TRANSPARENT,	"transparent" },
+	{ HCI_FORMAT_PCM,		"PCM" },
+	{ HCI_FORMAT_MSBC,		"mSBC" },
+	{ HCI_FORMAT_VENDOR,		"vendor" },
+	{ -1 },
+};
+
+static void codecs_rsp(int mgmt_sk, uint16_t op, uint16_t id, uint8_t status,
+				void *rsp, uint16_t len, void *user_data)
+{
+	struct mgmt_rp_read_codecs *rp = rsp;
+	char addr[18];
+	int i, count;
+
+	if (status != 0) {
+		fprintf(stderr,
+			"Reading hci%u info failed with status 0x%02x (%s)\n",
+					id, status, mgmt_errstr(status));
+		exit(EXIT_FAILURE);
+	}
+
+	if (len < sizeof(*rp)) {
+		fprintf(stderr, "Too small codecs reply (%u bytes)\n", len);
+		exit(EXIT_FAILURE);
+	}
+
+	count = rp->count;
+
+	printf("hci%u:\tnumber of codecs: %u\n", id, count);
+
+	for (i = 0; i < count; i++) {
+		int entry;
+		struct codecs_map *p;
+
+		entry = rp->codec[i];
+
+		p = codecs_map;
+
+		while (p->codec != -1) {
+			if (entry == p->codec)
+				break;
+			else
+				p++;
+		}
+
+		if (p->codec != -1)
+			printf("\t%s (0x%x)\n", p->name, p->codec);
+		else
+			printf("\tunknown (0x%x)\n", p->codec);
+	}
+
+	exit(EXIT_SUCCESS);
+}
+
+static void cmd_codecs(int mgmt_sk, uint16_t index, int argc, char **argv)
+{
+	if (index == MGMT_INDEX_NONE)
+		index = 0;
+
+	if (mgmt_send_cmd(mgmt_sk, MGMT_OP_READ_CODECS, index, NULL,
+						0, codecs_rsp, NULL) < 0) {
+		fprintf(stderr, "Unable to send read_info cmd\n");
+		exit(EXIT_FAILURE);
+	}
+}
+
 static void setting_rsp(int mgmt_sk, uint16_t op, uint16_t id, uint8_t status,
 				void *rsp, uint16_t len, void *user_data)
 {
@@ -1824,6 +1897,7 @@ static struct {
 	{ "version",	cmd_version,	"Get the MGMT Version"		},
 	{ "commands",	cmd_commands,	"List supported commands"	},
 	{ "info",	cmd_info,	"Show controller info"		},
+	{ "codecs",	cmd_codecs,	"List supported codecs"		},
 	{ "power",	cmd_power,	"Toggle powered state"		},
 	{ "discov",	cmd_discov,	"Toggle discoverable state"	},
 	{ "connectable",cmd_connectable,"Toggle connectable state"	},
-- 
1.7.9.5


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

* [PATCH 3/3] Doco:  List the read codecs operation
  2012-11-22 12:47 [PATCH 0/3] mgmt: read supported codecs Michael Knudsen
  2012-11-22 12:47 ` [PATCH 1/3] Bluetooth: Add HCI Coding Format definitions Michael Knudsen
  2012-11-22 12:47 ` [PATCH 2/3] Bluetooth: Support the read codecs operation Michael Knudsen
@ 2012-11-22 12:47 ` Michael Knudsen
  2012-11-23 10:10 ` [PATCH 0/3] mgmt: read supported codecs Kim Schulz
  3 siblings, 0 replies; 5+ messages in thread
From: Michael Knudsen @ 2012-11-22 12:47 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Michael Knudsen

---
 doc/mgmt-api.txt |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt
index 202c055..42af2d6 100644
--- a/doc/mgmt-api.txt
+++ b/doc/mgmt-api.txt
@@ -847,6 +847,26 @@ Set Device ID Command
 	a Command Status event on failure.
 
 
+Read Codecs Command
+====================
+
+	Command Code:		0x0029
+	Controller Index:	<controller id>
+	Command Parameters:
+	Return Parameters:
+				Num_Of_Codecs (1 Octet)
+				Codec1 (1 Octet)
+				Codec2 (1 Octet)
+				...
+
+	This command is used to read out the list of codecs that are
+	supported by the given controller.
+
+	This command generates a Command Complete event on success
+	or failure.
+
+
+
 Command Complete Event
 ======================
 
-- 
1.7.9.5


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

* Re: [PATCH 0/3] mgmt:  read supported codecs
  2012-11-22 12:47 [PATCH 0/3] mgmt: read supported codecs Michael Knudsen
                   ` (2 preceding siblings ...)
  2012-11-22 12:47 ` [PATCH 3/3] Doco: List " Michael Knudsen
@ 2012-11-23 10:10 ` Kim Schulz
  3 siblings, 0 replies; 5+ messages in thread
From: Kim Schulz @ 2012-11-23 10:10 UTC (permalink / raw)
  To: Michael Knudsen; +Cc: linux-bluetooth, Michael Knudsen

Den 2012-11-22 13:47, Michael Knudsen skrev:
> This implements the user space side of the read codecs command.
>
> Michael Knudsen (3):
>   Bluetooth:  Add HCI Coding Format definitions
>   Bluetooth:  Support the read codecs operation
>   Doco:  List the read codecs operation
>
>  doc/mgmt-api.txt |   20 +++++++++++++++
>  lib/hci.h        |    9 +++++++
>  lib/mgmt.h       |    8 ++++++
>  tools/btmgmt.c   |   74
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 111 insertions(+)



Looks like the codein these patches have some indentation problems 
(mixes tab and spaces).
-- 
Kim Schulz

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

end of thread, other threads:[~2012-11-23 10:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-22 12:47 [PATCH 0/3] mgmt: read supported codecs Michael Knudsen
2012-11-22 12:47 ` [PATCH 1/3] Bluetooth: Add HCI Coding Format definitions Michael Knudsen
2012-11-22 12:47 ` [PATCH 2/3] Bluetooth: Support the read codecs operation Michael Knudsen
2012-11-22 12:47 ` [PATCH 3/3] Doco: List " Michael Knudsen
2012-11-23 10:10 ` [PATCH 0/3] mgmt: read supported codecs Kim Schulz

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).