Search:  
Gentoo Wiki

Bluetooth_headset

This article is part of the Tips & Tricks series.
Terminals / Shells Network X Window System Portage System Filesystems Kernel Other

Contents

Introduction

Thanks to hothead from gentoo-forums, I managed to get my headset working with the pc. Original discussion may be found here:[1]

If your headset works, please take a minute to post its brand in the discussion linked.

Hardware Known to Work

Marcel has a table : Bluetooth device features and revision information

Brand Model Version Status chipset picture Remark
Acer BT-300 none works "pskey mapsco 0" needed #Troubleshooting
BlueTrek G2 17711 works use channel "2" - e.g.: /usr/bin/btsco2 ADDRESS 2
BlueTrek BT007EX works CSR 4 [2] BT Ver 2.0
Cardo Systems Scala 500 n/a works CSR [3] Great headset
Cardo Systems Scala 600 n/a works CSR [4] Great headset
Dell BH200 none works
Epox BT-HS01 none works CSR [5]
Jabra BT200 none works CSR [6]
Jabra BT500v none works CSR [7]
Jabra BT2020 none works CSR [8]
Jabra BT620s none works CSR [9] very good
Logitech® Mobile Traveller ver 1.2 works n/a [10]
Logitech® Mobile Freedom ver 1.1 works n/a [11] doesnt have th gray line like in th pic
Logitech® Mobile Freedom ver 1.2 works n/a [12]
Logitech HS01-V14 n/a works CSR [13]
Logitech HS01-V16 ver 1.2 works
Motorola H350 none works
Motorola H500 none works
Motorola HS801 none works [14]
Motorola HS805 none works [15]
Motorola HS820 none works
Motorola HS850 none works [16]
Motorola H700 none works needs the broadcomm patch Troubleshooting section
Motorola H3 none works
Motorola S805 none works Cambridge Silicon Radio (10) Bluetooth 2.0 A2DP headset. Works great with mplayer and audacious (true stereo).
Nokia HS-54W n/a works [17] use channel "2" - e.g.: /usr/bin/btsco2 ADDRESS 2
NokiaBH-300 n/a n/a Cambridge Silicon Radio (10) Using alsamixer hasn't any influence on the volume of either the mic or the speaker. Otherwise works perfectly. BT 2.
Nokia HS-W3 v1.2 works (kernel used: hardened-sources-2.6.20-r2; btsco: 0.4; programs tested: Audacious, Ekiga) CSR (dongle used: Cellink BTA-3000) [18] bluez-utils-3.10 and bluez-libs-3.10 managed to screw up the established pin-helper mechanisms, so I had to issue the following command in order to succesfully pair the device: passkey-agent {PIN} {BTADDR}. Nice.
Plantronics Discovery 640 - works CSR? Both playback and recording work fine, but there seems to be no way of controlling the volume of either.
Plantronics Voyager 520 - works CSR (10) Sounds nice and clear via arecord/aplay. Gnome volume control/sound recorder can't seem to see it, but I don't know if they're supposed to. bluez-{libs,utils}-3.28, blues-gnome-0.24, gentoo-sources-2.6.23-r3
SilverCrest BTST 9300 v1.2 works CSR [19] Connection via class 3 is very poor. Use at least the delivered class 2 (Cellink BTA-3000) or a class 1 adapter.
Sony Ericsson HBH-IV835 works [20] May require bluez-3 and btsco-0.42 to function well.
Sony Ericsson HBH-602 n/a works
Sony Ericsson HBH-602a n/a works Texas Instruments Inc. bluez-3.20 alsa-1.14
Sony Ericsson HBH-DS980 n/a works Cambridge Silicon Radio (10) [21] bluez-3.24 alsa-3.15, bluez-utils-3.30, alsa-1.0.16
Toshiba TECRA M2 n/a works - kernel patch needed see: [22] CSR [23] also known as TAIYO-YUDEN
SOUTHWING SH310 n/a works CSR
PHILIPS SHB6100/00 / CSR WBD-300 SHB6100/00 N/A Works Great, but put the dongle as far up or out as possible. SHB6100/00 [24] WBD-300 [25] Class 2 Adapter
Zonet ZUB6100C none works CSR [26] Class 1 adaptor
Zonet ZUB6101C none pls advice broadcomm note Troubleshooting section Broadcom [27] Class 1 adaptor
Mobile Action Technology MA-700 none works partially with plantronics bt headset and btsco alsa driver. Sound from the headset (mic) works fine, sound to the headset (speaker) sometimes drops off after few minutes. Closing/reopening of the alsa device seems to fix this. EDIT: Dropouts only noticed with xmms and skype (using alsa output. Switching skype to use oss (you have to have oss emulation in your alsa installation) made it work w/o probs). Mplayer, xine, ekiga work fine. CSR [28] Class 1 adaptor
i.Tech CLIP I none works CSR [29]
Samsung WEP 150 none works with btsco-0.5 and bluetooth-alsa-kernel-0.5 and amarok n/a [30]
Kyocera TXCKT10155 Works with new method http://www.kyocera-wireless.com/image/support/bluetooth/stereo-headset.jpg Works

Assumptions

Software installation

Bluez-utils-3.16 and newer

Note: you will not need bluetooth-alsa, plugz, btsco or the like for audio to work. They are obsolete.
Note: you will still need to apply one of the "sco-flowcontrol-v4.*" kernel patches below, or you will likely experience kernel freezes.
Code: /etc/bluetooth/audio.service
[Bluetooth Service]
Identifier=audio
Name=Audio service
Description=Bluetooth Audio service
Autostart=true


pcm.bluetooth {
   type bluetooth
   device 00:11:22:33:44:55
}

where 00:11:22:33:44:55 is the Bluetooth address of your headset (use for example hcitool scan to find it)

mplayer -ao alsa:device=bluetooth song.ogg


Note: So far using the "audio" service in 64-bit environments has been a royal pain in the ass. Version 3.19 of bluez-{utils,libs} worked using the above method for some dude's amd64 box. Good luck.
Note: As I write this I'm listening to stereo music using a bluetooth USB dongle and a Platronix headset on a 64 bit system running vanilla-sources-2.6.23.16 with no additional patches and the ~amd64 version of bluez-utils and co. If you follow the steps above you'll get them running in no time. One pittfall was to add profile "auto" in /etc/asound.conf or ~/.asoundrc

Obsolete method 1

Newer versions of bluetooth-alsa do not require the btsco module anymore; you can do everything through alsa. See http://bluetooth-alsa.sourceforge.net/build.html (Configure A2DP Driver, Configure SCO (aka mono, aka voice) Driver).

Step 1: install

Code: Get libsbc-cvs
mkdir -p /usr/local/portage/net-wireless/libsbc-cvs
cd /usr/local/portage/net-wireless/libsbc-cvs
wget http://bugs.gentoo.org/attachment.cgi?id=124658 -O libsbc-cvs-20070712.ebuild
ebuild libsbc-cvs-20070712.ebuild digest

Code: Get plugz
mkdir -p /usr/local/portage/net-wireless/plugz-cvs
cd /usr/local/portage/net-wireless/plugz-cvs
wget http://bugs.gentoo.org/attachment.cgi?id=126016 -O plugz-cvs-20070721.ebuild
mkdir -p files
wget http://bugs.gentoo.org/attachment.cgi?id=112919 -O files/bluez-libs-2.25.diff
ebuild plugz-cvs-20070721.ebuild digest

Code: Get bluetooth-alsa-utils
mkdir -p /usr/local/portage/net-wireless/bluetooth-alsa-utils
cd /usr/local/portage/net-wireless/bluetooth-alsa-utils
wget http://bugs.gentoo.org/attachment.cgi?id=124661 -O bluetooth-alsa-utils-0.5-r1.ebuild
ebuild bluetooth-alsa-utils-0.5-r1.ebuild digest

Code: Get bluetooth-alsa-kernel
mkdir -p /usr/local/portage/net-wireless/bluetooth-alsa-kernel
cd /usr/local/portage/net-wireless/bluetooth-alsa-kernel
mkdir -p files
wget http://bugs.gentoo.org/attachment.cgi?id=105793 -O bluetooth-alsa-kernel-0.5.ebuild
ebuild bluetooth-alsa-kernel-0.5.ebuild digest

Note: note that the bluetooth-alsa-kernel-0.5 will not compile cleanly with 2.6.23-gentoo-r{3,6} due to some missing typedefs.
Code: Here are the missing typedefs in btsco.c
--- btsco-0.5/kernel/btsco.c    2006-10-28 16:39:27.000000000 +0200
+++ btsco-0.5.new/kernel/btsco.c        2008-02-01 22:21:50.000000000 +0200
@@ -123,6 +123,20 @@
        int playback_count, capture_count;
 } snd_card_bt_sco_info_t;

+/* FIX: GG */
+typedef struct snd_card snd_card_t;
+typedef struct snd_kcontrol snd_kcontrol_t;
+typedef struct snd_pcm_substream snd_pcm_substream_t;
+typedef struct snd_pcm_runtime snd_pcm_runtime_t;
+typedef struct snd_pcm_hardware snd_pcm_hardware_t;
+typedef struct snd_pcm_ops snd_pcm_ops_t;
+typedef struct snd_pcm snd_pcm_t;
+typedef struct snd_ctl_elem_info snd_ctl_elem_info_t;
+typedef struct snd_ctl_elem_value snd_ctl_elem_value_t;
+typedef struct snd_kcontrol_new snd_kcontrol_new_t;
+typedef struct snd_hwdep snd_hwdep_t;
+#include <linux/freezer.h>
+
 typedef struct snd_card_bt_sco {
        snd_card_t *card;
        spinlock_t mixer_lock;

Step 2: patch your kernel

plugz includes patches for various kernels:

Step 3: build your kernel & modules

Please make sure you have checked: Networking support / Bluetooth subsystem support / Bluetooth device drivers / HCI USB driver / SCO (voice) support).

Use genkernel if you like.

Step 4: install libsco, plugz, bluetooth-alsa-utils

Code: emerge
emerge -v libsbc-cvs plugz-cvs bluetooth-alsa-utils


Step 5: patch your asound.conf

FIXME: In debian anyway, no file called asound.conf. Please give full path. Do you mean ~/.asoundrc ?

Depending on which profile you'd like to use, you'll need to add something along in these lines:

Code: A2DPD
pcm.a2dpd {
    type a2dpd
}

Code: headset
pcm.headset-sco-resample {
        #Resample-Device for Skype >1.4
        type plug
        slave {
                pcm "headset"
                rate 8000
                format S16_LE
                channels 1
        }
}

pcm.headset {
        @args [BDADDR TIMEOUT]

        # The Bluetooth device address for target headset, used for Audio Gateway (PC) initiated connections
        # Please note that this value is ignored when the connection is Headset initiated
        @args.BDADDR {
                type string
                # Enter address of your headset here
                default "00:00:00:00:00:00"
        }

        # This value represents how long we will try to reach the headset, until we give up.
        # Value is in milliseconds
        @args.TIMEOUT {
                type integer
                default 6000
        }

        type        sco
        bdaddr      $BDADDR
        timeout     $TIMEOUT
}

ctl.headset {
        type sco
}

As required, also create ~/.a2dprc:

Code: .a2dprc
[a2dpd]
#
# Rate
# use 32000 if your headset seems to not support 44100 (HP/Logitech works well at 44100, Sonorix at 32000)
# However, 44100 is mandatory
# If using SCO, then 8000hz is the value needed.
# if the plugin do not give the 8000hz stream, then the conversion will be done by the daemon
# Until we use a real resample library, we won't get a good quality, this is prototype software.
#
rate=44100
#rate=32000

# buggy if I remember well
#channels=2

#
# plugin-rate default is the rate used between the plugin and the daemon
# if this value is not 0 then alsa will convert all stream to the specified rate and then send it to the daemon
# if this value is 0, then alsa will do no conversion at all, the daemon will do it's own resampling.
# This "features" is disabled because of the crappy quality of the daemon resampler
# For example, to test a2dpd resampling from 32000 to 44100 use plugin-rate=32000 and rate=44100
#plugin-rate=32000

# Allows to specify the sbc bitpool, this can help reducing bandwith
# 8 Allows to run on a 115200 bauds with corresponding quality ;)
# 64 needs USB or 921600 bauds
# Recommended value from Bluetooth spec. is 53
sbcbitpool=32

# flags that will later be combinable
# 1: display bandwith each seconds.
# 3: current state
flags=0

# Recommended
enablereversestereo=1

# Automatically connect to selected headset if a stream if started
# not recommended if running on battery ;)
enableautoconnect=1

# Automatically disconnect after a timeout (seconds)
timeout=20

#
# AVRCP Commands to run
# If these entries are emptied, then some keyboard entry will be sent to /dev/uinput
#
cmdplay=xmms --play
cmdpause=xmms --pause
cmdprev=xmms --rew
cmdnext=xmms --fwd
cmdnew=xmms --play
cmdstop=xmms --stop
#cmdplay=dcop amarok player play
#cmdpause=dcop amarok player pause
#cmdprev=dcop amarok player prev
#cmdnext=dcop amarok player next
#cmdnew=dcop amarok player play
#cmdstop=dcop amarok player stop

# Put to 0 to ignore AVRCP (if your computer freezes when commands are received)
enableavrcp=1

#
# Audio routing
#
# If set to 1 (at a2dp startup only) a2dp will reread configuration file
# for audio routing changes each second
enablerereadconfig=1

# Display debug traces or not
enabledebug=1

# Redirect stdout to this file
#logfile=/dev/null

# Poll stdin for control commands ('c'onnect/'s'tart/'p'ause/'d'isconnect/'a'utoconnect)
# Use a2dpd_ctl instead
enablestdin=0

# 0 => Bluetooth A2DP Sink
# 1 => Alsa
enableredirectalsa=0

# Your bluetooth headset address
#address=00:08:F4:30:07:64

# Address of your alsa output (default : plughw:0,0) you have to know what to do
alsaoutput=

Step 6: start everything

Start bluetooth with:

/etc/init.d/bluetooth start

Start a2dpd for A2DP headsets (as normal user):

a2dpd

Start headsetd for headset profiles:

headsetd

Step 7: listen

You should configure your players to output to a2dpd or headset device. For insturctions, see bluetooth alsa page.

Obsolete method 2

Download ebuilds to the overlay

Follow the instructions here and setup an overlay HOWTO Installing 3rd Party Ebuilds

These steps will get the btsco kernel and utils ebuilds to portage overlay using Subversion, ebuild and emerge them. At the time of this edit in the version 0.41, confirmed to work in kernels up to release 2.6.20. At the moment, one can build btsco-kernel under the 2.6.21 kernel after applying this kernel patch.

Code: Get btsco-kernel
mkdir -p /usr/local/portage/net-wireless/btsco-kernel
cd /usr/local/portage/net-wireless/btsco-kernel
svn co http://overlays.gentoo.org/svn/dev/liquidx/net-wireless/btsco-kernel/ .
ebuild /usr/local/portage/net-wireless/btsco-kernel/btsco-kernel-0.41.ebuild digest

Code: Get btsco
mkdir -p /usr/local/portage/net-wireless/btsco
cd /usr/local/portage/net-wireless/btsco
svn co http://overlays.gentoo.org/svn/dev/liquidx/net-wireless/btsco/ .
ebuild /usr/local/portage/net-wireless/btsco/btsco-0.41.ebuild digest

Code: Tell portage to accept btsco packages and emerge them
echo net-wireless/btsco-kernel ~x86 >> /etc/portage/package.keywords
echo net-wireless/btsco ~x86 >> /etc/portage/package.keywords
emerge -uDav btsco-kernel btsco

Note for PowerPC users: If you want install these ebuilds, please add '~ppc' to ARCH variable in the ebuilds and replace ~x86 to ~ppc in the step about /etc/portage/package.keywords.

Configure the system

(Quoting from the bluetooth-alsa project page)

First, load the module and control it is loaded:

modprobe snd_bt_sco
dmesg

In case Esound is running, you have to stop it (forget this if you don't know what this is):

esdctl stop

Remember to set /etc/bluetooth/pin to the headset's pin (usually a factory-default 0000). Then, put the headset in pairing mode (how you do it depends on your headset: you may have to turn the headset off and then hold the power buttom past the power-on signal, or there may be a dedicated button); then run:

hcitool scan

The scan will give you an address in the form XX:XX:XX:XX:XX:XX. Paste it in the command:

btsco -v XX:XX:XX:XX:XX:XX

headset init script

courtsy to Andrzej:

the file, https://bugs.gentoo.org/attachment.cgi?id=92013&action=view This updated headset scripts allows to configure in /etc/conf.d/headset whether you use btsco or btsco2 by setting BTSCO variable to one of these values. If you don't define BTSCO then it currently defaults to btsco.

Alternative: headset init script and headset auto-detection daemon

Just follow the instructions presented in 'TIP bluetooth headset daemon and init script' TIP bluetooth headset daemon and init script. This will provide you a quite comfortable solution for automatically loading btsco without any further interaction.

Sort out OSS emulation

Refer also to _markd's advice posted here in setting alsa-oss emulation. That was once important for programs like Skype.

You have to change or add some lines the alsa configuration file in /etc/modprobe.d/alsa; in the following example we assume you are using a intel8x0 card (typical soundcard integrated in mainboards). You must tell the system that you have a second "card", which will be managed by snd-bt-sco. {{Box File|/etc/modprobe.d/alsa|

# Alsa 0.9.X kernel modules' configuration file.
# $Header: [Data you are not really interested in...] $

# ALSA portion
alias char-major-116 snd
# OSS/Free portion
alias char-major-14 soundcore

##
## IMPORTANT:
## You need to customise this section for your specific sound card(s)
## and then run `update-modules' command.
## Read alsa-driver's INSTALL file in /usr/share/doc for more info.
##
##  ALSA portion
   alias snd-card-0 snd-intel8x0  # This is your normal sound card.
   alias snd-card-1 snd-bt-sco  # This is the new part

##  OSS/Free portion
   alias sound-slot-0 snd-card-0
   alias sound-slot-1 snd-card-1
##

# OSS/Free portion - card #1
alias sound-service-0-0 snd-mixer-oss
alias sound-service-0-1 snd-seq-oss
alias sound-service-0-3 snd-pcm-oss
alias sound-service-0-8 snd-seq-oss
alias sound-service-0-12 snd-pcm-oss
##  OSS/Free portion - card #2
 alias sound-service-1-0 snd-mixer-oss # Add the following lines if necessary
 alias sound-service-1-1 snd-seq-oss
 alias sound-service-1-3 snd-pcm-oss
 alias sound-service-1-8 snd-seq-oss
 alias sound-service-1-12 snd-pcm-oss

alias /dev/mixer snd-mixer-oss
alias /dev/dsp snd-pcm-oss
alias /dev/midi snd-seq-oss

# Set this to the correct number of cards.
options snd cards_limit=2  # Set this to two, of course (unless you have even more...).

Afterwards run update-modules.

ALSA support

Once you succeeded in pairing your headset to your computer, you will be able to use a new ALSA device 'hw:X,0' (where 'X' is '0' for your first device, '1' for your second...). So most likely your headset will be available as hw:1,0. However this is a 'raw' device which expects a certain format with a certain data rate. If you want ALSA to handle all necessary conversions for you, use the 'plughw:Headset' device.

Code: Test your new ALSA device
aplay -D plughw:Headset /usr/share/sounds/k3b_success1.wav
or
mplayer -ao alsa:device=hw=1.0 /usr/share/sounds/k3b_success1.wav
Code: change mic volume
alsamixer -c 1

aRts support

In Control Center's Sound System, go to the Hardware tab and configure as sound device "plughw:Headset". You are now set up for using Skype without OSS emulation.

Skype note

In order to use your headset with skype, you must not have Esound (USE flag = esd) running. I think that we need to alter current /usr/bin/skype script to use ALSA via OSS: aoss /opt/bin/skype.bin

Testing

Fireup xmms and go to the prefrences (Ctrl-P), click configure , and choose the BT device. Now load a track and play it to your earpiece.

Current open bugs and issues

Troubleshooting

Note: looks like broadcom based adaptors may give SCO , by applying [31]

The bluez mailing list has a wonderful collection of answers to common issues. here are some tools to give you keywords to search the mailing list:

Is BT working properly?

(copied from the gentoo bluetooth guide)

ps -ae | grep hcid
26050 ?        00:00:00 hcid

If it is missing , check if dbus is running:

ps -ae |grep dbus

If you see nothing , try running /etc/init.d./dbus start . this is bug 118786

ps -ae | grep sdpd
26054 ?        00:00:00 sdpd
hciconfig -a
hci0:   Type: USB
       BD Address: 00:0A:0B:0C:0D:0E ACL MTU: 192:8 SCO MTU: 64:8
       UP RUNNING PSCAN ISCAN AUTH ENCRYPT
       RX bytes:125 acl:0 sco:0 events:17 errors:0
       TX bytes:565 acl:0 sco:0 commands:17 errors:0
       Features: 0xff 0xff 0x0f 0x00 0x00 0x00 0x00 0x00
       Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
       Link policy: RSWITCH HOLD SNIFF PARK
       Link mode: SLAVE ACCEPT
       Name: 'BlueZ at bluehat (0)'
       Class: 0x3e0100
       Service Classes: Networking, Rendering, Capturing, Object Transfer,
       Audio
       Device Class: Computer, Uncategorized
       HCI Ver: 1.1 (0x1) HCI Rev: 0x1e7 LMP Ver: 1.1 (0x1) LMP Subver: 0x1e7
       Manufacturer: Cambridge Silicon Radio (10)

Can you "see" the headset:

hcitool scan

Scanning ...

        00:10:60:A8:86:A3      Grayhat

If have issues with the scan or the hciconfig you can reset it:

hciconfig hci0 reset

If you can't ping it, try putting the headset in pairing mode.

can you ping it?

l2ping 00:10:60:A8:86:A3

Ping: 00:0E:6D:45:97:A1 from 00:10:60:A8:86:A3 (data size 44) ...
0 bytes from 00:0E:6D:45:97:A1 id 0 time 60.47ms
0 bytes from 00:0E:6D:45:97:A1 id 1 time 14.12ms
0 bytes from 00:0E:6D:45:97:A1 id 2 time 16.72ms
0 bytes from 00:0E:6D:45:97:A1 id 3 time 15.07ms
0 bytes from 00:0E:6D:45:97:A1 id 4 time 16.55ms


If you can't ping it try to:

rm /var/lib/bluetooth/[dongleaddr]/linkkeys

Error: control open (hw:2): No such device

Headset is already connected or its turned off

Error: SCO packet for unknown connection handle xx - VERY often

There are a lot of people getting this error, sometimes 10000+ often. Unfortunately there isn't a general fix for this problem, but here we can collect some solutions.

patch your kernel with this little patch from here.

FIXME: could someone please put an updated link to a working patch? It is no longer available on sf.net. Also, has it been rolled into 2.6.25? or do we need a different one for that version?

other means of diagnosis

Retrieved from "http://www.gentoo-wiki.info/Bluetooth_headset"

Last modified: Wed, 27 Aug 2008 01:26:00 +0000 Hits: 65,092