All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC 0/3] btattach: Use HCI UART vendor specific setup kernel calls
@ 2015-04-02 14:38 Frederic Danis
  2015-04-02 14:38 ` [RFC 1/3] btattach: Add SetDevType ioctl call Frederic Danis
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Frederic Danis @ 2015-04-02 14:38 UTC (permalink / raw)
  To: linux-bluetooth

This series of patches uses the new IOCTLs introduced in RFC "Move HCI UART
vendor specific setup to kernel" previously sent.

Frederic Danis (3):
  btattach: Add SetDevType ioctl call
  btattach: Add SetBaudRate ioctl call
  btattach: Increase timeout for raw user channel creation

 tools/btattach.c  | 38 ++++++++++++++++++++++++++++++++------
 tools/hciattach.h |  2 ++
 2 files changed, 34 insertions(+), 6 deletions(-)

-- 
1.9.1


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

* [RFC 1/3] btattach: Add SetDevType ioctl call
  2015-04-02 14:38 [RFC 0/3] btattach: Use HCI UART vendor specific setup kernel calls Frederic Danis
@ 2015-04-02 14:38 ` Frederic Danis
  2015-04-02 15:18   ` Marcel Holtmann
  2015-04-02 14:38 ` [RFC 2/3] btattach: Add SetBaudRate " Frederic Danis
  2015-04-02 14:38 ` [RFC 3/3] btattach: Increase timeout for raw user channel creation Frederic Danis
  2 siblings, 1 reply; 5+ messages in thread
From: Frederic Danis @ 2015-04-02 14:38 UTC (permalink / raw)
  To: linux-bluetooth

---
 tools/btattach.c  | 22 +++++++++++++++++-----
 tools/hciattach.h |  1 +
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/tools/btattach.c b/tools/btattach.c
index b7948a3..63620e4 100644
--- a/tools/btattach.c
+++ b/tools/btattach.c
@@ -106,7 +106,7 @@ static void local_version_callback(const void *data, uint8_t size,
 }
 
 static int attach_proto(const char *path, unsigned int proto,
-						unsigned int flags)
+					unsigned int flags, const char *type)
 {
 	int fd, dev_id;
 
@@ -120,6 +120,14 @@ static int attach_proto(const char *path, unsigned int proto,
 		return -1;
 	}
 
+	if (type) {
+		if (ioctl(fd, HCIUARTSETDEVTYPE, type) < 0) {
+			perror("Failed to set device type");
+			close(fd);
+			return -1;
+		}
+	}
+
 	if (ioctl(fd, HCIUARTSETPROTO, proto) < 0) {
 		perror("Failed to set protocol");
 		close(fd);
@@ -193,6 +201,7 @@ static void usage(void)
 static const struct option main_options[] = {
 	{ "bredr",   required_argument, NULL, 'B' },
 	{ "amp",     required_argument, NULL, 'A' },
+	{ "type",    required_argument, NULL, 't' },
 	{ "version", no_argument,       NULL, 'v' },
 	{ "help",    no_argument,       NULL, 'h' },
 	{ }
@@ -200,7 +209,7 @@ static const struct option main_options[] = {
 
 int main(int argc, char *argv[])
 {
-	const char *bredr_path = NULL, *amp_path = NULL;
+	const char *bredr_path = NULL, *amp_path = NULL, *type = NULL;
 	bool raw_device = false;
 	sigset_t mask;
 	int exit_status, count = 0;
@@ -208,7 +217,7 @@ int main(int argc, char *argv[])
 	for (;;) {
 		int opt;
 
-		opt = getopt_long(argc, argv, "B:A:Rvh",
+		opt = getopt_long(argc, argv, "B:A:t:Rvh",
 						main_options, NULL);
 		if (opt < 0)
 			break;
@@ -220,6 +229,9 @@ int main(int argc, char *argv[])
 		case 'A':
 			amp_path = optarg;
 			break;
+		case 't':
+			type = optarg;
+			break;
 		case 'R':
 			raw_device = true;
 			break;
@@ -258,7 +270,7 @@ int main(int argc, char *argv[])
 		if (raw_device)
 			flags = (1 << HCI_UART_RAW_DEVICE);
 
-		fd = attach_proto(bredr_path, HCI_UART_H4, flags);
+		fd = attach_proto(bredr_path, HCI_UART_H4, flags, type);
 		if (fd >= 0) {
 			mainloop_add_fd(fd, 0, uart_callback, NULL, NULL);
 			count++;
@@ -277,7 +289,7 @@ int main(int argc, char *argv[])
 		if (raw_device)
 			flags = (1 << HCI_UART_RAW_DEVICE);
 
-		fd = attach_proto(amp_path, HCI_UART_H4, flags);
+		fd = attach_proto(amp_path, HCI_UART_H4, flags, type);
 		if (fd >= 0) {
 			mainloop_add_fd(fd, 0, uart_callback, NULL, NULL);
 			count++;
diff --git a/tools/hciattach.h b/tools/hciattach.h
index 2aaf075..8a199e9 100644
--- a/tools/hciattach.h
+++ b/tools/hciattach.h
@@ -32,6 +32,7 @@
 #define HCIUARTGETDEVICE	_IOR('U', 202, int)
 #define HCIUARTSETFLAGS		_IOW('U', 203, int)
 #define HCIUARTGETFLAGS		_IOR('U', 204, int)
+#define HCIUARTSETDEVTYPE	_IOW('U', 205, int)
 
 #define HCI_UART_H4	0
 #define HCI_UART_BCSP	1
-- 
1.9.1


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

* [RFC 2/3] btattach: Add SetBaudRate ioctl call
  2015-04-02 14:38 [RFC 0/3] btattach: Use HCI UART vendor specific setup kernel calls Frederic Danis
  2015-04-02 14:38 ` [RFC 1/3] btattach: Add SetDevType ioctl call Frederic Danis
@ 2015-04-02 14:38 ` Frederic Danis
  2015-04-02 14:38 ` [RFC 3/3] btattach: Increase timeout for raw user channel creation Frederic Danis
  2 siblings, 0 replies; 5+ messages in thread
From: Frederic Danis @ 2015-04-02 14:38 UTC (permalink / raw)
  To: linux-bluetooth

---
 tools/btattach.c  | 22 ++++++++++++++++++----
 tools/hciattach.h |  1 +
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/tools/btattach.c b/tools/btattach.c
index 63620e4..d97429e 100644
--- a/tools/btattach.c
+++ b/tools/btattach.c
@@ -106,7 +106,8 @@ static void local_version_callback(const void *data, uint8_t size,
 }
 
 static int attach_proto(const char *path, unsigned int proto,
-					unsigned int flags, const char *type)
+					unsigned int flags, const char *type,
+					unsigned int speed)
 {
 	int fd, dev_id;
 
@@ -128,6 +129,14 @@ static int attach_proto(const char *path, unsigned int proto,
 		}
 	}
 
+	if (speed) {
+		if (ioctl(fd, HCIUARTSETBAUDRATE, speed) < 0) {
+			perror("Failed to set speed");
+			close(fd);
+			return -1;
+		}
+	}
+
 	if (ioctl(fd, HCIUARTSETPROTO, proto) < 0) {
 		perror("Failed to set protocol");
 		close(fd);
@@ -202,6 +211,7 @@ static const struct option main_options[] = {
 	{ "bredr",   required_argument, NULL, 'B' },
 	{ "amp",     required_argument, NULL, 'A' },
 	{ "type",    required_argument, NULL, 't' },
+	{ "speed",   required_argument, NULL, 's' },
 	{ "version", no_argument,       NULL, 'v' },
 	{ "help",    no_argument,       NULL, 'h' },
 	{ }
@@ -210,6 +220,7 @@ static const struct option main_options[] = {
 int main(int argc, char *argv[])
 {
 	const char *bredr_path = NULL, *amp_path = NULL, *type = NULL;
+	unsigned int speed = 0;
 	bool raw_device = false;
 	sigset_t mask;
 	int exit_status, count = 0;
@@ -217,7 +228,7 @@ int main(int argc, char *argv[])
 	for (;;) {
 		int opt;
 
-		opt = getopt_long(argc, argv, "B:A:t:Rvh",
+		opt = getopt_long(argc, argv, "B:A:t:s:Rvh",
 						main_options, NULL);
 		if (opt < 0)
 			break;
@@ -229,6 +240,9 @@ int main(int argc, char *argv[])
 		case 'A':
 			amp_path = optarg;
 			break;
+		case 's':
+			speed = atoi(optarg);
+			break;
 		case 't':
 			type = optarg;
 			break;
@@ -270,7 +284,7 @@ int main(int argc, char *argv[])
 		if (raw_device)
 			flags = (1 << HCI_UART_RAW_DEVICE);
 
-		fd = attach_proto(bredr_path, HCI_UART_H4, flags, type);
+		fd = attach_proto(bredr_path, HCI_UART_H4, flags, type, speed);
 		if (fd >= 0) {
 			mainloop_add_fd(fd, 0, uart_callback, NULL, NULL);
 			count++;
@@ -289,7 +303,7 @@ int main(int argc, char *argv[])
 		if (raw_device)
 			flags = (1 << HCI_UART_RAW_DEVICE);
 
-		fd = attach_proto(amp_path, HCI_UART_H4, flags, type);
+		fd = attach_proto(amp_path, HCI_UART_H4, flags, type, speed);
 		if (fd >= 0) {
 			mainloop_add_fd(fd, 0, uart_callback, NULL, NULL);
 			count++;
diff --git a/tools/hciattach.h b/tools/hciattach.h
index 8a199e9..2a084f7 100644
--- a/tools/hciattach.h
+++ b/tools/hciattach.h
@@ -33,6 +33,7 @@
 #define HCIUARTSETFLAGS		_IOW('U', 203, int)
 #define HCIUARTGETFLAGS		_IOR('U', 204, int)
 #define HCIUARTSETDEVTYPE	_IOW('U', 205, int)
+#define HCIUARTSETBAUDRATE	_IOW('U', 206, int)
 
 #define HCI_UART_H4	0
 #define HCI_UART_BCSP	1
-- 
1.9.1


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

* [RFC 3/3] btattach: Increase timeout for raw user channel creation
  2015-04-02 14:38 [RFC 0/3] btattach: Use HCI UART vendor specific setup kernel calls Frederic Danis
  2015-04-02 14:38 ` [RFC 1/3] btattach: Add SetDevType ioctl call Frederic Danis
  2015-04-02 14:38 ` [RFC 2/3] btattach: Add SetBaudRate " Frederic Danis
@ 2015-04-02 14:38 ` Frederic Danis
  2 siblings, 0 replies; 5+ messages in thread
From: Frederic Danis @ 2015-04-02 14:38 UTC (permalink / raw)
  To: linux-bluetooth

As Bluetooth controller initialization is now performed in kernel, it can
take longer time to get user channel socket.
So move timeout from 1.5 seconds to 6 seconds.
---
 tools/btattach.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/btattach.c b/tools/btattach.c
index d97429e..8fc5868 100644
--- a/tools/btattach.c
+++ b/tools/btattach.c
@@ -153,7 +153,7 @@ static int attach_proto(const char *path, unsigned int proto,
 	printf("Device index %d attached\n", dev_id);
 
 	if (flags & (1 << HCI_UART_RAW_DEVICE)) {
-		unsigned int attempts = 6;
+		unsigned int attempts = 24;
 		struct bt_hci *hci;
 
 		while (attempts-- > 0) {
-- 
1.9.1


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

* Re: [RFC 1/3] btattach: Add SetDevType ioctl call
  2015-04-02 14:38 ` [RFC 1/3] btattach: Add SetDevType ioctl call Frederic Danis
@ 2015-04-02 15:18   ` Marcel Holtmann
  0 siblings, 0 replies; 5+ messages in thread
From: Marcel Holtmann @ 2015-04-02 15:18 UTC (permalink / raw)
  To: Frederic Danis; +Cc: linux-bluetooth

Hi Fred,

> ---
> tools/btattach.c  | 22 +++++++++++++++++-----
> tools/hciattach.h |  1 +
> 2 files changed, 18 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/btattach.c b/tools/btattach.c
> index b7948a3..63620e4 100644
> --- a/tools/btattach.c
> +++ b/tools/btattach.c
> @@ -106,7 +106,7 @@ static void local_version_callback(const void *data, uint8_t size,
> }
> 
> static int attach_proto(const char *path, unsigned int proto,
> -						unsigned int flags)
> +					unsigned int flags, const char *type)
> {
> 	int fd, dev_id;
> 
> @@ -120,6 +120,14 @@ static int attach_proto(const char *path, unsigned int proto,
> 		return -1;
> 	}
> 
> +	if (type) {
> +		if (ioctl(fd, HCIUARTSETDEVTYPE, type) < 0) {
> +			perror("Failed to set device type");
> +			close(fd);
> +			return -1;
> +		}
> +	}
> +
> 	if (ioctl(fd, HCIUARTSETPROTO, proto) < 0) {
> 		perror("Failed to set protocol");
> 		close(fd);
> @@ -193,6 +201,7 @@ static void usage(void)
> static const struct option main_options[] = {
> 	{ "bredr",   required_argument, NULL, 'B' },
> 	{ "amp",     required_argument, NULL, 'A' },
> +	{ "type",    required_argument, NULL, 't' },
> 	{ "version", no_argument,       NULL, 'v' },
> 	{ "help",    no_argument,       NULL, 'h' },
> 	{ }
> @@ -200,7 +209,7 @@ static const struct option main_options[] = {
> 
> int main(int argc, char *argv[])
> {
> -	const char *bredr_path = NULL, *amp_path = NULL;
> +	const char *bredr_path = NULL, *amp_path = NULL, *type = NULL;
> 	bool raw_device = false;
> 	sigset_t mask;
> 	int exit_status, count = 0;
> @@ -208,7 +217,7 @@ int main(int argc, char *argv[])
> 	for (;;) {
> 		int opt;
> 
> -		opt = getopt_long(argc, argv, "B:A:Rvh",
> +		opt = getopt_long(argc, argv, "B:A:t:Rvh",
> 						main_options, NULL);
> 		if (opt < 0)
> 			break;
> @@ -220,6 +229,9 @@ int main(int argc, char *argv[])
> 		case 'A':
> 			amp_path = optarg;
> 			break;
> +		case 't':
> +			type = optarg;
> +			break;
> 		case 'R':
> 			raw_device = true;
> 			break;
> @@ -258,7 +270,7 @@ int main(int argc, char *argv[])
> 		if (raw_device)
> 			flags = (1 << HCI_UART_RAW_DEVICE);
> 
> -		fd = attach_proto(bredr_path, HCI_UART_H4, flags);
> +		fd = attach_proto(bredr_path, HCI_UART_H4, flags, type);

I think the real feature you want to add here is the ability to choose different HCI_UART_* types. So lets define a list of types that we support. This should just be drivers/vendors and not all different chips like in hciattach.

However you need to do a lot of input verification checks here. For example AMP implies H:4 at the moment.

The kernel calls is PROTO at the moment and with that we most likely should just call it --protocol / -p here. If not specified it defaults to H:4.

Regards

Marcel


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

end of thread, other threads:[~2015-04-02 15:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-02 14:38 [RFC 0/3] btattach: Use HCI UART vendor specific setup kernel calls Frederic Danis
2015-04-02 14:38 ` [RFC 1/3] btattach: Add SetDevType ioctl call Frederic Danis
2015-04-02 15:18   ` Marcel Holtmann
2015-04-02 14:38 ` [RFC 2/3] btattach: Add SetBaudRate " Frederic Danis
2015-04-02 14:38 ` [RFC 3/3] btattach: Increase timeout for raw user channel creation Frederic Danis

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.