linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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: [RFC v2 2/6] btio: Add option for SCO voice setting
Date: Fri,  5 Jul 2013 17:46:43 +0200	[thread overview]
Message-ID: <1373039207-20959-3-git-send-email-frederic.dalleau@linux.intel.com> (raw)
In-Reply-To: <1373039207-20959-1-git-send-email-frederic.dalleau@linux.intel.com>

---
 btio/btio.c |   18 +++++++++++++++---
 btio/btio.h |    1 +
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/btio/btio.c b/btio/btio.c
index cb8860a..032a5fa 100644
--- a/btio/btio.c
+++ b/btio/btio.c
@@ -78,6 +78,7 @@ struct set_opts {
 	uint8_t mode;
 	int flushable;
 	uint32_t priority;
+	uint16_t voice;
 };
 
 struct connect {
@@ -723,9 +724,10 @@ static int sco_connect(int sock, const bdaddr_t *dst)
 	return 0;
 }
 
-static gboolean sco_set(int sock, uint16_t mtu, GError **err)
+static gboolean sco_set(int sock, uint16_t mtu, uint16_t voice, GError **err)
 {
 	struct sco_options sco_opt;
+	struct bt_voice bt_voice;
 	socklen_t len;
 
 	if (!mtu)
@@ -745,6 +747,13 @@ static gboolean sco_set(int sock, uint16_t mtu, GError **err)
 		return FALSE;
 	}
 
+	bt_voice.setting = voice;
+	if (setsockopt(sock, SOL_BLUETOOTH, BT_VOICE, &bt_voice,
+						sizeof(bt_voice)) < 0) {
+		ERROR_FAILED(err, "setsockopt(BT_VOICE)", errno);
+		return FALSE;
+	}
+
 	return TRUE;
 }
 
@@ -832,6 +841,9 @@ static gboolean parse_set_opts(struct set_opts *opts, GError **err,
 		case BT_IO_OPT_PRIORITY:
 			opts->priority = va_arg(args, int);
 			break;
+		case BT_IO_OPT_VOICE:
+			opts->voice = va_arg(args, int);
+			break;
 		default:
 			g_set_error(err, BT_IO_ERROR, EINVAL,
 					"Unknown option %d", opt);
@@ -1310,7 +1322,7 @@ gboolean bt_io_set(GIOChannel *io, GError **err, BtIOOption opt1, ...)
 	case BT_IO_RFCOMM:
 		return rfcomm_set(sock, opts.sec_level, opts.master, err);
 	case BT_IO_SCO:
-		return sco_set(sock, opts.mtu, err);
+		return sco_set(sock, opts.mtu, opts.voice, err);
 	default:
 		g_set_error(err, BT_IO_ERROR, EINVAL,
 				"Unknown BtIO type %d", type);
@@ -1377,7 +1389,7 @@ static GIOChannel *create_io(gboolean server, struct set_opts *opts,
 		}
 		if (sco_bind(sock, &opts->src, err) < 0)
 			goto failed;
-		if (!sco_set(sock, opts->mtu, err))
+		if (!sco_set(sock, opts->mtu, opts->voice, err))
 			goto failed;
 		break;
 	default:
diff --git a/btio/btio.h b/btio/btio.h
index ac1366b..2dce9f0 100644
--- a/btio/btio.h
+++ b/btio/btio.h
@@ -55,6 +55,7 @@ typedef enum {
 	BT_IO_OPT_MODE,
 	BT_IO_OPT_FLUSHABLE,
 	BT_IO_OPT_PRIORITY,
+	BT_IO_OPT_VOICE,
 } BtIOOption;
 
 typedef enum {
-- 
1.7.9.5


  parent reply	other threads:[~2013-07-05 15:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-05 15:46 [RFC v2 0/6] sco: Integrate SCO socket option in user space Frédéric Dalleau
2013-07-05 15:46 ` [RFC v2 1/6] lib: SCO voice setting support header Frédéric Dalleau
2013-07-05 15:46 ` Frédéric Dalleau [this message]
2013-07-09 11:39   ` [RFC v2 2/6] btio: Add option for SCO voice setting Johan Hedberg
2013-07-05 15:46 ` [RFC v2 3/6] btiotest: " Frédéric Dalleau
2013-07-05 15:46 ` [RFC v2 4/6] scotest: " Frédéric Dalleau
2013-07-05 15:46 ` [RFC v2 5/6] sco-tester: Initial sco tester implementation Frédéric Dalleau
2013-07-09 11:41   ` Johan Hedberg
2013-07-05 15:46 ` [RFC v2 6/6] sco-tester: Test BT_VOICE option with 1.1 adapter Frédéric Dalleau
2013-07-09 11:42   ` Johan Hedberg
2013-08-01  9:57     ` Johan Hedberg

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=1373039207-20959-3-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).