Bluetooth: Use hci_connect_sco directly

hci_connect is a super function for connecting hci protocols. But the
voice_setting parameter is only needed by SCO and security requirements are not
needed for SCO channels. Thus, it makes sense to have a separate function.

Signed-off-by: Frédéric Dalleau <frederic.dalleau@linux.intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Bluetooth: Remove unused mask parameter in sco_conn_defer_accept

Signed-off-by: Frédéric Dalleau <frederic.dalleau@linux.intel.com>
Bluetooth: Add bluetooth socket voice option

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>
Bluetooth: Constants and macro declaration for SCO airmode

This patchs define constants and macro for extracting SCO airmode from SCO
voice setting. It refers to Bluetooth Core V4.0 specification, Part E, Chap
6.12 which describe SCO voice setting format.

Signed-off-by: Frédéric Dalleau <frederic.dalleau@linux.intel.com>
Bluetooth: Use voice setting in incoming SCO connection

When an incoming SCO connection is requested, check the selected voice setting,
and reply appropriately. Voice setting should have been negotiated previously.
For example, in case of HFP, the codec is negotiated using AT commands on the
RFCOMM channel. This patch only changes replies for socket with defered setup
enabled.

Signed-off-by: Frédéric Dalleau <frederic.dalleau@linux.intel.com>
Bluetooth: Parameters for outgoing SCO connections

In order to establish a transparent SCO connection, the correct settings must
be specified in the Setup Synchronous Connection request. For that,
voice_setting is added to ACL connection flags to set up the desired
parameters. If this value is zero, a legacy SCO connection will be requested.
This patch uses T2 settings.

Signed-off-by: Frédéric Dalleau <frederic.dalleau@linux.intel.com>
Bluetooth: Fallback transparent SCO from T2 to T1

When initiating a transparent eSCO connection, make use of T2 settings at
first try. T2 is the recommended settings from HFP 1.6 WideBand Speech. Upon
connection failure, try T1 settings.
T2 failure is detected if Synchronous Connection Complete event fails with
error 0x0d. This error code has been found experimentally by sending a T2
request to a T1 only SCO listener. It means "Connection Rejected due to
Limited resource".
To know which of T2 or T1 should be used, conn->fallback is used.  Bluez only
attempt to reconnect twice. In the future, we will need more than 2 fallback
possibilities. Thus, test conn->fallback as an alternative measure. We want to
fallback only if conn->fallback is positive. Calling hci_setup_sync with
conn->fallback == 0 is an initial connection attempt.

Signed-off-by: Frédéric Dalleau <frederic.dalleau@linux.intel.com>
Bluetooth: Add support for fallback between S3, S2, S1 settings

When CVSD is requested and eSCO is supported, try to establish eSCO connection
using S3 settings. If it fails, fallback to S2 settings, then to S1 settings.
See Bluetooth HFP 1.6 specifications page 101 for description of Sx settings.

UNTESTED!!!

Signed-off-by: Frédéric Dalleau <frederic.dalleau@linux.intel.com>
Bluetooth: btusb module parameter to force alternate setting

In bluetooth USB driver, test all possible alternate settings.  This is the
reason why we add this parameter to force usage of a specific alternate
setting. The alternate settings are hardcoded in Bluetooth Core Specification.
The spec defines an alternate setting 0, but we don't support this one.
In this case the value 0 is the default and means : let the driver decide
alternate setting.
This is mostly a debug parameter.

Signed-off-by: Frédéric Dalleau <frederic.dalleau@linux.intel.com>