Skip to contentSkip to conversation

Bluetooth: Add option to enable/disable SCO support

PATCH In review Arron Wang 2 participants 9 messages May 22, 2015 – Jun 9, 2015

Subsystems (2)
lore
Share & tools
lore

Arron Wang

author
#0 lore raw

PATCH 1/2 Bluetooth: Add option to enable/disable SCO support

Embedded device may need flexible option to reduce the code size and memory use

---
 include/net/bluetooth/bluetooth.h |   11 +++++++++++
 include/net/bluetooth/hci_core.h  |   13 +++++++++++++
 net/bluetooth/Kconfig             |   10 +++++++++-
 net/bluetooth/Makefile            |    3 ++-
 4 files changed, 35 insertions(+), 2 deletions(-)
include/net/bluetooth/bluetooth.h +11 -0
index 7dba805..f085ff14 100644
@@ -365,8 +365,19 @@ extern struct dentry *bt_debugfs;
 int l2cap_init(void);
 void l2cap_exit(void);
 
+#if IS_ENABLED(CONFIG_BT_SCO)
 int sco_init(void);
 void sco_exit(void);
+#else
+static inline int sco_init(void)
+{
+	return 0;
+}
+
+static inline void sco_exit(void)
+{
+}
+#endif
 
 int mgmt_init(void);
 void mgmt_exit(void);
include/net/bluetooth/hci_core.h +13 -0
index a056c2b..7c70034 100644
@@ -532,8 +532,21 @@ int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr);
 int l2cap_disconn_ind(struct hci_conn *hcon);
 int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags);
 
+#if IS_ENABLED(CONFIG_BT_SCO)
 int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags);
 int sco_recv_scodata(struct hci_conn *hcon, struct sk_buff *skb);
+#else
+static inline int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr,
+				  __u8 *flags)
+{
+	return 0;
+}
+
+static inline int sco_recv_scodata(struct hci_conn *hcon, struct sk_buff *skb)
+{
+	return 0;
+}
+#endif
 
 /* ----- Inquiry cache ----- */
 #define INQUIRY_CACHE_AGE_MAX   (HZ*30)   /* 30 seconds */
net/bluetooth/Kconfig +9 -1
index b8c794b..e7bca37 100644
@@ -23,10 +23,10 @@ menuconfig BT
 	  Linux Bluetooth subsystem consist of several layers:
 	     Bluetooth Core
 		HCI device and connection manager, scheduler
-		SCO audio links
 		L2CAP (Logical Link Control and Adaptation Protocol)
 		SMP (Security Manager Protocol) on LE (Low Energy) links
 	     HCI Device drivers (Interface to the hardware)
+	     SCO Module (SCO audio links)
 	     RFCOMM Module (RFCOMM Protocol)  
 	     BNEP Module (Bluetooth Network Encapsulation Protocol)
 	     CMTP Module (CAPI Message Transport Protocol)
@@ -45,6 +45,14 @@ config BT_BREDR
 	depends on BT
 	default y
 
+config BT_SCO
+	bool "Bluetooth SCO support"
+	depends on BT_BREDR
+	default y
+	help
+	  SCO link provides voice transport over Bluetooth.  SCO support is
+	  required for voice applications like Headset and Audio.
+
 source "net/bluetooth/rfcomm/Kconfig"
 
 source "net/bluetooth/bnep/Kconfig"
net/bluetooth/Makefile +2 -1
index 9a8ea23..21fe57a 100644
@@ -12,9 +12,10 @@ obj-$(CONFIG_BT_6LOWPAN) += bluetooth_6lowpan.o
 bluetooth_6lowpan-y := 6lowpan.o
 
 bluetooth-y := af_bluetooth.o hci_core.o hci_conn.o hci_event.o mgmt.o \
-	hci_sock.o hci_sysfs.o l2cap_core.o l2cap_sock.o smp.o sco.o lib.o \
+	hci_sock.o hci_sysfs.o l2cap_core.o l2cap_sock.o smp.o lib.o \
 	a2mp.o amp.o ecc.o hci_request.o mgmt_util.o
 
+bluetooth-$(CONFIG_BT_SCO) += sco.o
 bluetooth-$(CONFIG_BT_DEBUGFS) += hci_debugfs.o
 bluetooth-$(CONFIG_BT_SELFTEST) += selftest.o
 
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH 2/2 Bluetooth: Add option to enable/disable A2MP module

Make Bluetooth 3.0 HS feature configurable

---
 net/bluetooth/Kconfig          |    5 +
 net/bluetooth/Makefile         |    3 +-
 net/bluetooth/a2mp.h           |   19 +++
 net/bluetooth/amp.h            |   11 ++
 net/bluetooth/hci_event.c      |  260 +-----------------------------------
 net/bluetooth/hci_event_a2mp.c |  283 ++++++++++++++++++++++++++++++++++++++++
 net/bluetooth/hci_event_a2mp.h |   91 +++++++++++++
 7 files changed, 412 insertions(+), 260 deletions(-)
 create mode 100644 net/bluetooth/hci_event_a2mp.c
 create mode 100644 net/bluetooth/hci_event_a2mp.h
net/bluetooth/Kconfig +5 -0
index e7bca37..a558c66 100644
@@ -27,6 +27,7 @@ menuconfig BT
 		SMP (Security Manager Protocol) on LE (Low Energy) links
 	     HCI Device drivers (Interface to the hardware)
 	     SCO Module (SCO audio links)
+	     A2MP Module (AMP Manager Protocol)
 	     RFCOMM Module (RFCOMM Protocol)  
 	     BNEP Module (Bluetooth Network Encapsulation Protocol)
 	     CMTP Module (CAPI Message Transport Protocol)
@@ -53,6 +54,10 @@ config BT_SCO
 	  SCO link provides voice transport over Bluetooth.  SCO support is
 	  required for voice applications like Headset and Audio.
 
+config BT_A2MP
+	bool "Bluetooth Alternate MAC/PHY (AMP) features"
+	depends on BT_BREDR
+
 source "net/bluetooth/rfcomm/Kconfig"
 
 source "net/bluetooth/bnep/Kconfig"
net/bluetooth/Makefile +2 -1
index 21fe57a..a87fc90 100644
@@ -13,9 +13,10 @@ bluetooth_6lowpan-y := 6lowpan.o
 
 bluetooth-y := af_bluetooth.o hci_core.o hci_conn.o hci_event.o mgmt.o \
 	hci_sock.o hci_sysfs.o l2cap_core.o l2cap_sock.o smp.o lib.o \
-	a2mp.o amp.o ecc.o hci_request.o mgmt_util.o
+	ecc.o hci_request.o mgmt_util.o
 
 bluetooth-$(CONFIG_BT_SCO) += sco.o
+bluetooth-$(CONFIG_BT_A2MP) += a2mp.o amp.o hci_event_a2mp.o
 bluetooth-$(CONFIG_BT_DEBUGFS) += hci_debugfs.o
 bluetooth-$(CONFIG_BT_SELFTEST) += selftest.o
 
net/bluetooth/a2mp.h +19 -0
index 296f665..d92577a 100644
@@ -130,10 +130,29 @@ struct a2mp_physlink_rsp {
 #define A2MP_STATUS_SECURITY_VIOLATION		0x06
 
 struct amp_mgr *amp_mgr_get(struct amp_mgr *mgr);
+
+#if IS_ENABLED(CONFIG_BT_A2MP)
 int amp_mgr_put(struct amp_mgr *mgr);
 struct l2cap_chan *a2mp_channel_create(struct l2cap_conn *conn,
 				       struct sk_buff *skb);
 void a2mp_discover_amp(struct l2cap_chan *chan);
+#else
+static inline int amp_mgr_put(struct amp_mgr *mgr)
+{
+	return 0;
+}
+
+static inline struct l2cap_chan *a2mp_channel_create(struct l2cap_conn *conn,
+						     struct sk_buff *skb)
+{
+	return NULL;
+}
+
+static inline void a2mp_discover_amp(struct l2cap_chan *chan)
+{
+}
+#endif
+
 void a2mp_send_getinfo_rsp(struct hci_dev *hdev);
 void a2mp_send_getampassoc_rsp(struct hci_dev *hdev, u8 status);
 void a2mp_send_create_phy_link_req(struct hci_dev *hdev, u8 status);
net/bluetooth/amp.h +11 -0
index 7ea3db7..508b06d 100644
@@ -47,8 +47,19 @@ void amp_accept_phylink(struct hci_dev *hdev, struct amp_mgr *mgr,
 void amp_write_remote_assoc(struct hci_dev *hdev, u8 handle);
 void amp_write_rem_assoc_continue(struct hci_dev *hdev, u8 handle);
 void amp_physical_cfm(struct hci_conn *bredr_hcon, struct hci_conn *hs_hcon);
+
+#if IS_ENABLED(CONFIG_BT_A2MP)
 void amp_create_logical_link(struct l2cap_chan *chan);
 void amp_disconnect_logical_link(struct hci_chan *hchan);
+#else
+static inline void amp_create_logical_link(struct l2cap_chan *chan)
+{
+}
+
+static inline void amp_disconnect_logical_link(struct hci_chan *hchan)
+{
+}
+#endif
 void amp_destroy_logical_link(struct hci_chan *hchan, u8 reason);
 
 #endif /* __AMP_H */
net/bluetooth/hci_event.c +1 -259

297 lines not on this page · raw message

net/bluetooth/hci_event_a2mp.c new file +283 -0

283 lines not on this page · raw message

net/bluetooth/hci_event_a2mp.h new file +91 -0

91 lines not on this page · raw message

Signature · 1 line
1.7.9.5
maintainer
#2 lore raw

Re: [PATCH 2/2] Bluetooth: Add option to enable/disable A2MP module

Hi Arron,

Quoted 12 lines

Make Bluetooth 3.0 HS feature configurable

---

net/bluetooth/Kconfig          |    5 +
net/bluetooth/Makefile         |    3 +-
net/bluetooth/a2mp.h           |   19 +++
net/bluetooth/amp.h            |   11 ++
net/bluetooth/hci_event.c      |  260 +-----------------------------------
net/bluetooth/hci_event_a2mp.c |  283 ++++++++++++++++++++++++++++++++++++++++
net/bluetooth/hci_event_a2mp.h |   91 +++++++++++++
7 files changed, 412 insertions(+), 260 deletions(-)
Quoted 2 lines

create mode 100644 net/bluetooth/hci_event_a2mp.c
create mode 100644 net/bluetooth/hci_event_a2mp.h

I don’t think this is the solution here. I think A2MP support should be self contained and utilises the synchronous HCI command framework we have in place and also use in mgmt.

Quoted 13 lines
net/bluetooth/Kconfig +1 -0
index e7bca37..a558c66 100644
@@ -27,6 +27,7 @@ menuconfig BT
 		SMP (Security Manager Protocol) on LE (Low Energy) links
 	     HCI Device drivers (Interface to the hardware)
 	     SCO Module (SCO audio links)
+	     A2MP Module (AMP Manager Protocol)
 	     RFCOMM Module (RFCOMM Protocol)  
 	     BNEP Module (Bluetooth Network Encapsulation Protocol)
 	     CMTP Module (CAPI Message Transport Protocol)

net/bluetooth/Kconfig config BT_SCO · line 60

Quoted 7 lines
net/bluetooth/Kconfig +4 -0
@@ -53,6 +54,10 @@ config BT_SCO
 	  SCO link provides voice transport over Bluetooth.  SCO support is
 	  required for voice applications like Headset and Audio.
 
+config BT_A2MP
+	bool "Bluetooth Alternate MAC/PHY (AMP) features"
+	depends on BT_BREDR
+

The option name you are looking for for BT_HS for high speed support. A2MP and AMP support should be hidden behind that config option.

Regards

Marcel

#3 lore raw

RE: [PATCH 2/2] Bluetooth: Add option to enable/disable A2MP module

Hi Marcel,

Quoted 21 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Marcel Holtmann
Sent: Tuesday, May 26, 2015 3:06 AM
To: Wang, Arron
Cc: [email protected]
Subject: Re: [PATCH 2/2] Bluetooth: Add option to enable/disable A2MP module

Hi Arron,

Quoted 10 lines

Make Bluetooth 3.0 HS feature configurable

---

net/bluetooth/Kconfig          |    5 +
net/bluetooth/Makefile         |    3 +-
net/bluetooth/a2mp.h           |   19 +++
net/bluetooth/amp.h            |   11 ++
net/bluetooth/hci_event.c      |  260 +-----------------------------------
net/bluetooth/hci_event_a2mp.c |  283

++++++++++++++++++++++++++++++++++++++++

Quoted 8 lines
Quoted 4 lines

net/bluetooth/hci_event_a2mp.h | 91 +++++++++++++

7 files changed, 412 insertions(+), 260 deletions(-) create mode

100644 net/bluetooth/hci_event_a2mp.c create mode 100644 net/bluetooth/hci_event_a2mp.h

I don’t think this is the solution here. I think A2MP support should be self contained and utilises the synchronous HCI command framework we have in place and also use in mgmt.

Yes, create a separate file for hci a2mp event maybe not suitable, but there are many hci ops/events for different Bluetooth controller BREDR/AMP/LE, add the macro to separate them in one file may not easy to maintain, can we move these AMP releated hci ops/event function to file amp.c?

Quoted 16 lines
Quoted 16 lines
net/bluetooth/Kconfig index renamed from net/bluetooth/Kconfig +0 -0

e7bca37..a558c66 100644

net/bluetooth/Kconfig +1 -0
@@ -27,6 +27,7 @@ menuconfig BT
 		SMP (Security Manager Protocol) on LE (Low Energy) links
 	     HCI Device drivers (Interface to the hardware)
 	     SCO Module (SCO audio links)
+	     A2MP Module (AMP Manager Protocol)
 	     RFCOMM Module (RFCOMM Protocol)
 	     BNEP Module (Bluetooth Network Encapsulation Protocol)
 	     CMTP Module (CAPI Message Transport Protocol) @@ -53,6 +54,10 @@

config BT_SCO
SCO link provides voice transport over Bluetooth. SCO support is required for voice applications like Headset and Audio.

Quoted 7 lines

net/bluetooth/Kconfig config BT_SCO · line 60

Quoted 4 lines
net/bluetooth/Kconfig +4 -0
+config BT_A2MP
+	bool "Bluetooth Alternate MAC/PHY (AMP) features"
+	depends on BT_BREDR
+

The option name you are looking for for BT_HS for high speed support. A2MP and AMP support should be hidden behind that config option.

Yes, I'll change them to BT_HS.

Thanks
Arron

maintainer
#4 lore raw

Re: [PATCH 2/2] Bluetooth: Add option to enable/disable A2MP module

Hi Arron,

Quoted 16 lines
Quoted 16 lines
Quoted 10 lines

Make Bluetooth 3.0 HS feature configurable

---

net/bluetooth/Kconfig          |    5 +
net/bluetooth/Makefile         |    3 +-
net/bluetooth/a2mp.h           |   19 +++
net/bluetooth/amp.h            |   11 ++
net/bluetooth/hci_event.c      |  260 +-----------------------------------
net/bluetooth/hci_event_a2mp.c |  283

++++++++++++++++++++++++++++++++++++++++

Quoted 4 lines

net/bluetooth/hci_event_a2mp.h | 91 +++++++++++++

7 files changed, 412 insertions(+), 260 deletions(-) create mode

100644 net/bluetooth/hci_event_a2mp.c create mode 100644 net/bluetooth/hci_event_a2mp.h

Quoted 5 lines
Quoted 3 lines

I don’t think this is the solution here. I think A2MP support should be self contained and utilises the synchronous HCI command framework we have in place and also use in mgmt.

Yes, create a separate file for hci a2mp event maybe not suitable, but there are many hci ops/events for different Bluetooth controller BREDR/AMP/LE, add the macro to separate them in one file may not easy to maintain, can we move these AMP releated hci ops/event function to file amp.c?

unless it has some complicated state machine impact, using the hci_request infrastructure should be preferred compared to go through callback handlers in hci_event.c. So first of all it needs to be investigated which of the A2MP HCI functions can be turned into using hci_request.

Regards

Marcel

#5 lore raw

RE: [PATCH 2/2] Bluetooth: Add option to enable/disable A2MP module

Hi Marcel,

Quoted 30 lines

-----Original Message-----
From: Marcel Holtmann [mailto:[email protected]]
Sent: Saturday, June 6, 2015 12:57 PM
To: Wang, Arron
Cc: [email protected]
Subject: Re: [PATCH 2/2] Bluetooth: Add option to enable/disable A2MP module

Hi Arron,

Quoted 16 lines
Quoted 16 lines
Quoted 10 lines

Make Bluetooth 3.0 HS feature configurable

---

net/bluetooth/Kconfig          |    5 +
net/bluetooth/Makefile         |    3 +-
net/bluetooth/a2mp.h           |   19 +++
net/bluetooth/amp.h            |   11 ++
net/bluetooth/hci_event.c      |  260 +-----------------------------------
net/bluetooth/hci_event_a2mp.c |  283

++++++++++++++++++++++++++++++++++++++++

Quoted 4 lines

net/bluetooth/hci_event_a2mp.h | 91 +++++++++++++

7 files changed, 412 insertions(+), 260 deletions(-) create mode

100644 net/bluetooth/hci_event_a2mp.c create mode 100644 net/bluetooth/hci_event_a2mp.h

Quoted 5 lines
Quoted 3 lines

I don’t think this is the solution here. I think A2MP support should be self contained and utilises the synchronous HCI command framework we have in place and also use in mgmt.

Yes, create a separate file for hci a2mp event maybe not suitable, but there are

Quoted 8 lines

many hci ops/events for different Bluetooth controller BREDR/AMP/LE, add the macro to separate them in one file may not easy to maintain, can we move these AMP releated hci ops/event function to file amp.c?

unless it has some complicated state machine impact, using the hci_request infrastructure should be preferred compared to go through callback handlers in hci_event.c. So first of all it needs to be investigated which of the A2MP HCI functions can be turned into using hci_request.

I found the current A2MP functions already use hci_request send command to hci subsystem, in hci_event.c they just invoke these functions, we can define these functions as inline but I not sure whether we also should put A2MP related events under BT_HS config option.

Thanks
Arron

maintainer
#6 lore raw

Re: [PATCH 2/2] Bluetooth: Add option to enable/disable A2MP module

Hi Arron,

Quoted 25 lines
Quoted 25 lines
Quoted 16 lines
Quoted 16 lines
Quoted 10 lines

Make Bluetooth 3.0 HS feature configurable

---

net/bluetooth/Kconfig          |    5 +
net/bluetooth/Makefile         |    3 +-
net/bluetooth/a2mp.h           |   19 +++
net/bluetooth/amp.h            |   11 ++
net/bluetooth/hci_event.c      |  260 +-----------------------------------
net/bluetooth/hci_event_a2mp.c |  283

++++++++++++++++++++++++++++++++++++++++

Quoted 4 lines

net/bluetooth/hci_event_a2mp.h | 91 +++++++++++++

7 files changed, 412 insertions(+), 260 deletions(-) create mode

100644 net/bluetooth/hci_event_a2mp.c create mode 100644 net/bluetooth/hci_event_a2mp.h

Quoted 5 lines
Quoted 3 lines

I don’t think this is the solution here. I think A2MP support should be self contained and utilises the synchronous HCI command framework we have in place and also use in mgmt.

Yes, create a separate file for hci a2mp event maybe not suitable, but there are

many hci ops/events for different Bluetooth controller BREDR/AMP/LE, add the macro to separate them in one file may not easy to maintain, can we move these AMP releated hci ops/event function to file amp.c?

Quoted 6 lines
Quoted 4 lines

unless it has some complicated state machine impact, using the hci_request infrastructure should be preferred compared to go through callback handlers in hci_event.c. So first of all it needs to be investigated which of the A2MP HCI functions can be turned into using hci_request.

I found the current A2MP functions already use hci_request send command to hci subsystem, in hci_event.c they just invoke these functions, we can define these functions as inline but I not sure whether we also should put A2MP related events under BT_HS config option.

I am actually seeing hci_send_cmd being used a lot in amp.c.

Regards

Marcel

maintainer
#7 lore raw
In reply to Arron Wang

Hi Arron,

Quoted 42 lines

Embedded device may need flexible option to reduce the code size and memory use

---

include/net/bluetooth/bluetooth.h |   11 +++++++++++
include/net/bluetooth/hci_core.h  |   13 +++++++++++++
net/bluetooth/Kconfig             |   10 +++++++++-
net/bluetooth/Makefile            |    3 ++-
4 files changed, 35 insertions(+), 2 deletions(-)
include/net/bluetooth/bluetooth.h +11 -0
index 7dba805..f085ff14 100644
@@ -365,8 +365,19 @@ extern struct dentry *bt_debugfs;
 int l2cap_init(void);
 void l2cap_exit(void);
 
+#if IS_ENABLED(CONFIG_BT_SCO)
 int sco_init(void);
 void sco_exit(void);
+#else
+static inline int sco_init(void)
+{
+	return 0;
+}
+
+static inline void sco_exit(void)
+{
+}
+#endif
 
 int mgmt_init(void);
 void mgmt_exit(void);
include/net/bluetooth/hci_core.h +0 -0
index a056c2b..7c70034 100644
@@ -532,8 +532,21 @@ int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr);
 int l2cap_disconn_ind(struct hci_conn *hcon);
 int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags);

include/net/bluetooth/hci_core.h int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr); · line 543

Quoted 10 lines
include/net/bluetooth/hci_core.h +7 -0
 
+#if IS_ENABLED(CONFIG_BT_SCO)
 int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags);
 int sco_recv_scodata(struct hci_conn *hcon, struct sk_buff *skb);
+#else
+static inline int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr,
+				  __u8 *flags)
+{
+	return 0;
+}

shouldn’t this return an error?

include/net/bluetooth/hci_core.h int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr); · line 547

Quoted 4 lines
include/net/bluetooth/hci_core.h +4 -0
+
+static inline int sco_recv_scodata(struct hci_conn *hcon, struct sk_buff *skb)
+{
+	return 0;

I wonder now why this is returning anything at all. Should we maybe make this void in the first place?

Quoted 23 lines
include/net/bluetooth/hci_core.h +2 -0
+}
+#endif
 
 /* ----- Inquiry cache ----- */
 #define INQUIRY_CACHE_AGE_MAX   (HZ*30)   /* 30 seconds */
net/bluetooth/Kconfig +1 -1
index b8c794b..e7bca37 100644
@@ -23,10 +23,10 @@ menuconfig BT
 	  Linux Bluetooth subsystem consist of several layers:
 	     Bluetooth Core
 		HCI device and connection manager, scheduler
-		SCO audio links
 		L2CAP (Logical Link Control and Adaptation Protocol)
 		SMP (Security Manager Protocol) on LE (Low Energy) links
 	     HCI Device drivers (Interface to the hardware)
+	     SCO Module (SCO audio links)
 	     RFCOMM Module (RFCOMM Protocol)  
 	     BNEP Module (Bluetooth Network Encapsulation Protocol)
 	     CMTP Module (CAPI Message Transport Protocol)
@@ -45,6 +45,14 @@ config BT_BREDR
 	depends on BT

net/bluetooth/Kconfig config BT_BREDR · line 55

Quoted 10 lines
net/bluetooth/Kconfig +8 -0
 	default y
 
+config BT_SCO
+	bool "Bluetooth SCO support"
+	depends on BT_BREDR
+	default y
+	help
+	  SCO link provides voice transport over Bluetooth.  SCO support is
+	  required for voice applications like Headset and Audio.
+

This can be all hidden behind the BT_BREDR config option. No need to create another one. BR/EDR without SCO/eSCO support is a pretty useless offer. And if you do BR/EDR, then the little extra SCO socket handling is not big overhead.

Quoted 15 lines

source "net/bluetooth/rfcomm/Kconfig"

source "net/bluetooth/bnep/Kconfig"

net/bluetooth/Makefile +0 -0
index 9a8ea23..21fe57a 100644
@@ -12,9 +12,10 @@ obj-$(CONFIG_BT_6LOWPAN) += bluetooth_6lowpan.o

bluetooth_6lowpan-y := 6lowpan.o

bluetooth-y := af_bluetooth.o hci_core.o hci_conn.o hci_event.o mgmt.o \

net/bluetooth/Makefile +1 -1
-	hci_sock.o hci_sysfs.o l2cap_core.o l2cap_sock.o smp.o sco.o lib.o \
+	hci_sock.o hci_sysfs.o l2cap_core.o l2cap_sock.o smp.o lib.o \

a2mp.o amp.o ecc.o hci_request.o mgmt_util.o

Quoted 3 lines

+bluetooth-$(CONFIG_BT_SCO) += sco.o
bluetooth-$(CONFIG_BT_DEBUGFS) += hci_debugfs.o
bluetooth-$(CONFIG_BT_SELFTEST) += selftest.o

Regards

Marcel

#8 lore raw

Hi Marcel,

Quoted 55 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Marcel Holtmann
Sent: Tuesday, May 26, 2015 3:06 AM
To: Wang, Arron
Cc: [email protected]
Subject: Re: [PATCH 1/2] Bluetooth: Add option to enable/disable SCO support

Hi Arron,

Quoted 45 lines

Embedded device may need flexible option to reduce the code size and memory use

---

include/net/bluetooth/bluetooth.h |   11 +++++++++++
include/net/bluetooth/hci_core.h  |   13 +++++++++++++
net/bluetooth/Kconfig             |   10 +++++++++-
net/bluetooth/Makefile            |    3 ++-
4 files changed, 35 insertions(+), 2 deletions(-)
include/net/bluetooth/bluetooth.h +11 -0
index 7dba805..f085ff14 100644
@@ -365,8 +365,19 @@ extern struct dentry *bt_debugfs; int
 l2cap_init(void); void l2cap_exit(void);
 
+#if IS_ENABLED(CONFIG_BT_SCO)
 int sco_init(void);
 void sco_exit(void);
+#else
+static inline int sco_init(void)
+{
+	return 0;
+}
+
+static inline void sco_exit(void)
+{
+}
+#endif
 
 int mgmt_init(void);
 void mgmt_exit(void);
include/net/bluetooth/hci_core.h +0 -0
index a056c2b..7c70034 100644
@@ -532,8 +532,21 @@ int l2cap_connect_ind(struct hci_dev *hdev,

bdaddr_t *bdaddr); int l2cap_disconn_ind(struct hci_conn *hcon); int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags);

Quoted 12 lines

include/net/bluetooth/hci_core.h int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr); · line 543

Quoted 10 lines

+#if IS_ENABLED(CONFIG_BT_SCO)
int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags); int sco_recv_scodata(struct hci_conn *hcon, struct sk_buff *skb);

include/net/bluetooth/hci_core.h +6 -0
+#else
+static inline int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr,
+				  __u8 *flags)
+{
+	return 0;
+}

shouldn’t this return an error?

This function returns link mode value, default zero indicate no link mode is chose and lead to hci reject the connection.

Quoted 7 lines

include/net/bluetooth/hci_core.h int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr); · line 547

Quoted 4 lines
include/net/bluetooth/hci_core.h +4 -0
+
+static inline int sco_recv_scodata(struct hci_conn *hcon, struct
+sk_buff *skb) {
+	return 0;

I wonder now why this is returning anything at all. Should we maybe make this void in the first place?

Yes, my function just follow with the definition, I'll change them to return void.

Quoted 25 lines
Quoted 25 lines
include/net/bluetooth/hci_core.h +2 -0
+}
+#endif

/* ----- Inquiry cache ----- */
#define INQUIRY_CACHE_AGE_MAX (HZ*30) /* 30 seconds */

net/bluetooth/Kconfig index renamed from net/bluetooth/Kconfig +0 -0

b8c794b..e7bca37 100644

net/bluetooth/Kconfig +1 -1
@@ -23,10 +23,10 @@ menuconfig BT
 	  Linux Bluetooth subsystem consist of several layers:
 	     Bluetooth Core
 		HCI device and connection manager, scheduler
-		SCO audio links
 		L2CAP (Logical Link Control and Adaptation Protocol)
 		SMP (Security Manager Protocol) on LE (Low Energy) links
 	     HCI Device drivers (Interface to the hardware)
+	     SCO Module (SCO audio links)
 	     RFCOMM Module (RFCOMM Protocol)
 	     BNEP Module (Bluetooth Network Encapsulation Protocol)
 	     CMTP Module (CAPI Message Transport Protocol) @@ -45,6 +45,14 @@

config BT_BREDR
depends on BT
default y

Quoted 12 lines

net/bluetooth/Kconfig config BT_BREDR · line 55

Quoted 8 lines
net/bluetooth/Kconfig +8 -0
+config BT_SCO
+	bool "Bluetooth SCO support"
+	depends on BT_BREDR
+	default y
+	help
+	  SCO link provides voice transport over Bluetooth.  SCO support is
+	  required for voice applications like Headset and Audio.
+

This can be all hidden behind the BT_BREDR config option. No need to create another one. BR/EDR without SCO/eSCO support is a pretty useless offer. And if you do BR/EDR, then the little extra SCO socket handling is not big overhead.

Yes, I'll change them under BT_BREDR config option

Quoted 15 lines
Quoted 15 lines

source "net/bluetooth/rfcomm/Kconfig"

source "net/bluetooth/bnep/Kconfig"

net/bluetooth/Makefile index renamed from net/bluetooth/Makefile +0 -0

9a8ea23..21fe57a 100644

net/bluetooth/Makefile +0 -0
@@ -12,9 +12,10 @@ obj-$(CONFIG_BT_6LOWPAN) += bluetooth_6lowpan.o

bluetooth_6lowpan-y := 6lowpan.o

bluetooth-y := af_bluetooth.o hci_core.o hci_conn.o hci_event.o mgmt.o \

net/bluetooth/Makefile +1 -1
-	hci_sock.o hci_sysfs.o l2cap_core.o l2cap_sock.o smp.o sco.o lib.o \
+	hci_sock.o hci_sysfs.o l2cap_core.o l2cap_sock.o smp.o lib.o \

a2mp.o amp.o ecc.o hci_request.o mgmt_util.o

Quoted 8 lines
Quoted 3 lines

+bluetooth-$(CONFIG_BT_SCO) += sco.o
bluetooth-$(CONFIG_BT_DEBUGFS) += hci_debugfs.o
bluetooth-$(CONFIG_BT_SELFTEST) += selftest.o

Regards

Marcel

Thanks
Arron