From: "Frédéric Dalleau" <frederic.dalleau@linux.intel.com>
To: linux-bluetooth@vger.kernel.org
Cc: "Frédéric Dalleau" <frederic.dalleau@linux.intel.com>
Subject: [PATCH v8 3/8] Bluetooth: Add bluetooth socket voice option
Date: Fri, 5 Jul 2013 17:01:37 +0200 [thread overview]
Message-ID: <1373036503-1349-4-git-send-email-frederic.dalleau@linux.intel.com> (raw)
In-Reply-To: <1373036503-1349-1-git-send-email-frederic.dalleau@linux.intel.com>
This patch extends the current bluetooth socket option to add BT_VOICE.
This is intended to choose voice data type at runtime. It only applies to SCO
sockets.
Incoming connections shall be setup during defered setup. Outgoing connections
shall be setup before connect(). The desired setting is stored in the sco
socket info.
This patch declares needed members, modifies getsockopt() and setsockopt().
Signed-off-by: Frédéric Dalleau <frederic.dalleau@linux.intel.com>
---
include/net/bluetooth/bluetooth.h | 8 ++++++++
include/net/bluetooth/sco.h | 1 +
net/bluetooth/sco.c | 40 ++++++++++++++++++++++++++++++++++++-
3 files changed, 48 insertions(+), 1 deletion(-)
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index 10eb9b3..10d43d8 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -107,6 +107,14 @@ struct bt_power {
*/
#define BT_CHANNEL_POLICY_AMP_PREFERRED 2
+#define BT_VOICE 11
+struct bt_voice {
+ __u16 setting;
+};
+
+#define BT_VOICE_TRANSPARENT 0x0003
+#define BT_VOICE_CVSD_16BIT 0x0060
+
__printf(1, 2)
int bt_info(const char *fmt, ...);
__printf(1, 2)
diff --git a/include/net/bluetooth/sco.h b/include/net/bluetooth/sco.h
index 1e35c43..e252a31 100644
--- a/include/net/bluetooth/sco.h
+++ b/include/net/bluetooth/sco.h
@@ -73,6 +73,7 @@ struct sco_conn {
struct sco_pinfo {
struct bt_sock bt;
__u32 flags;
+ __u16 setting;
struct sco_conn *conn;
};
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index 0c15a0c..ce8690f 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -416,6 +416,8 @@ static struct sock *sco_sock_alloc(struct net *net, struct socket *sock, int pro
sk->sk_protocol = proto;
sk->sk_state = BT_OPEN;
+ sco_pi(sk)->setting = BT_VOICE_CVSD_16BIT;
+
setup_timer(&sk->sk_timer, sco_sock_timeout, (unsigned long)sk);
bt_sock_link(&sco_sk_list, sk);
@@ -709,7 +711,8 @@ static int sco_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
static int sco_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen)
{
struct sock *sk = sock->sk;
- int err = 0;
+ int len, err = 0;
+ struct bt_voice voice;
u32 opt;
BT_DBG("sk %p", sk);
@@ -735,6 +738,31 @@ static int sco_sock_setsockopt(struct socket *sock, int level, int optname, char
clear_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags);
break;
+ case BT_VOICE:
+ if (sk->sk_state != BT_OPEN && sk->sk_state != BT_BOUND &&
+ sk->sk_state != BT_CONNECT2) {
+ err = -EINVAL;
+ break;
+ }
+
+ voice.setting = sco_pi(sk)->setting;
+
+ len = min_t(unsigned int, sizeof(voice), optlen);
+ if (copy_from_user((char *) &voice, optval, len)) {
+ err = -EFAULT;
+ break;
+ }
+
+ /* Explicitly check for these values */
+ if (voice.setting != BT_VOICE_TRANSPARENT &&
+ voice.setting != BT_VOICE_CVSD_16BIT) {
+ err = -EINVAL;
+ break;
+ }
+
+ sco_pi(sk)->setting = voice.setting;
+ break;
+
default:
err = -ENOPROTOOPT;
break;
@@ -804,6 +832,7 @@ static int sco_sock_getsockopt(struct socket *sock, int level, int optname, char
{
struct sock *sk = sock->sk;
int len, err = 0;
+ struct bt_voice voice;
BT_DBG("sk %p", sk);
@@ -829,6 +858,15 @@ static int sco_sock_getsockopt(struct socket *sock, int level, int optname, char
break;
+ case BT_VOICE:
+ voice.setting = sco_pi(sk)->setting;
+
+ len = min_t(unsigned int, len, sizeof(voice));
+ if (copy_to_user(optval, (char *)&voice, len))
+ err = -EFAULT;
+
+ break;
+
default:
err = -ENOPROTOOPT;
break;
--
1.7.9.5
next prev parent reply other threads:[~2013-07-05 15:01 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-05 15:01 [PATCH v8 0/8] sco: SCO socket option for voice_setting Frédéric Dalleau
2013-07-05 15:01 ` [PATCH v8 1/8] Bluetooth: Use hci_connect_sco directly Frédéric Dalleau
2013-07-05 15:01 ` [PATCH v8 2/8] Bluetooth: Remove unused mask parameter in sco_conn_defer_accept Frédéric Dalleau
2013-07-08 19:10 ` Marcel Holtmann
2013-07-09 7:00 ` Frédéric DALLEAU
2013-07-09 7:37 ` Marcel Holtmann
2013-07-05 15:01 ` Frédéric Dalleau [this message]
2013-07-08 19:17 ` [PATCH v8 3/8] Bluetooth: Add bluetooth socket voice option Marcel Holtmann
2013-07-05 15:01 ` [PATCH v8 4/8] Bluetooth: Constants declaration for SCO airmode Frédéric Dalleau
2013-07-08 19:04 ` Marcel Holtmann
2013-07-05 15:01 ` [PATCH v8 5/8] Bluetooth: Use voice setting in defered SCO connection request Frédéric Dalleau
2013-07-08 19:12 ` Marcel Holtmann
2013-07-09 9:36 ` Frédéric DALLEAU
2013-07-05 15:01 ` [PATCH v8 6/8] Bluetooth: Parameters for outgoing SCO connections Frédéric Dalleau
2013-07-08 19:20 ` Marcel Holtmann
2013-07-05 15:01 ` [PATCH v8 7/8] Bluetooth: SCO connection fallback Frédéric Dalleau
2013-07-08 19:23 ` Marcel Holtmann
2013-07-09 9:57 ` Frédéric DALLEAU
2013-07-09 14:25 ` Marcel Holtmann
2013-07-05 15:01 ` [PATCH v8 8/8] Bluetooth: Prevent transparent SCO on older devices Frédéric Dalleau
2013-07-08 2:33 ` Vinicius Costa Gomes
2013-07-08 9:31 ` Frédéric DALLEAU
2013-07-08 19:25 ` Marcel Holtmann
2013-07-12 13:48 ` Frédéric DALLEAU
2013-07-12 16:35 ` Marcel Holtmann
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=1373036503-1349-4-git-send-email-frederic.dalleau@linux.intel.com \
--to=frederic.dalleau@linux.intel.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).