linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Bluez-devel] SCO. Some ideas.
@ 2004-02-29 16:15 James Courtier-Dutton
  2004-02-29 17:02 ` Marcel Holtmann
  0 siblings, 1 reply; 19+ messages in thread
From: James Courtier-Dutton @ 2004-02-29 16:15 UTC (permalink / raw)
  To: bluez-devel

As SCO over bluetooth is only really suitable for audio sound data, I 
see no real problem with alsa being the only interface in linux to send 
data over a bluetooth SCO connection. (only the actually sco data, not 
the bluetooth profile control)
Does anyone see a problem with that?

If people think we should also make it easy to add an OSS driver, and 
also a network socket driver, we could maybe work out some devision 
between the SCO specifics and the ALSA specifics. But for a first 
attempt, we should keep the SCO and ALSA driver tightly matched.
Therefore maybe making the bluetooth sco and alsa-sco module being the 
same module, with an ioctl interface so that a user space application 
can handle the creation of bluetooth profile SCO pairing.
For example, if using a Headset profile, the alsa PCM and alsa MIXER 
device would only appear if the userspace application had already set up 
the RFCOMM connections. The userspace application would also have to 
have set up the bluetooth specific details for the SCO connection, so 
that when alsa opens the PCM, it has enough information to open a SCO 
connection.

I have looked at this for the alsa->sco->bluetooth->hci_usb  drivers.
The alsa driver has to be able to do the following: -
1) open - this should check that all bluetooth connections are up that 
need to be up in order for SCO data to pass. It could do this via 
interaction with the userspace bluetooth profile.

2) close - close everything neatly.

3) hw_params - allocate buffers etc. for the pcm audio as well as the 
hw_params config. Can be called multiple times, so re-alloc of buffers 
should be allowed for. hw_params are things like sample rate, number of 
channels, PCM format. Obviously there are limits on what these values 
can take when using bluetooth. 16bit PCM, 8bit PCM, 8bit A-law, 8bit 
u-Law. Start by also limiting it to 1 PCM channel. I.E. Mono and not stereo.

4) pcm_prepare - actually set the hw_params. e.g. do the equivalent of 
hciconfig hci0 voice XX, where XX depends on the hw_params.
Also selecting usb alt profiles.
The only difference between hw_params and pcm_prepare is that 
pcm_prepare is called for xrun recovery.

5) trigger - actually start/stop usb_urbs (e.g. call 
usb_submit_urb/usb_unlink_urb now.)

6) pointer - get hw_usb_frame_pointer and modify the result to simulate 
an audio ring buffer of the size configured in the hw_params.
When retrieving the pointer, one should also retrieve the valid range 
that the pointer can have, so one can adjust for pointer wrap around.
For usb, this would be the usb_get_current_frame_number() for the 
pointer, and dev->bus->iso_sched_frames for the range of values it can take.

7) period_time_elapsed - hci_usb should call this on each urb_complete 
call. For our use, it seems sensible to make 1 urb == 1 alsa period.

If we can let the alsa bluetooth audio driver have access to the 
hardware pointers (in this case the usb current frame pointers), we will 
get a much more accurate idea of exactly which audio sample is currently 
being played.

Also, letting alsa control period and buffer sizes, and getting that to 
directly determine usb urb sizes, we would give complete control of 
buffer sizes to the application, which is vital for low latency 
applications like Voice over IP.

Summary: -
we need to provide up to the sco level, control of low level usb 
interface isoc parameters. E.g. prepare, trigger, pointer, 
period_time_elapsed, hw_params.

If people are happy with this proposal, I will start writing the alsa 
driver, and also start adding to the bluetooth -> hci_usb driver api to 
allow for it. The api will only change for SCO data handling, as Bulk 
and Int handling don't need such fine controls.

Cheers
James



-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 19+ messages in thread
* RE: [Bluez-devel] SCO. Some ideas.
@ 2004-03-01 16:27 Williams, Richard
  2004-03-01 17:20 ` Simon Vogl
  2004-03-01 17:39 ` James Courtier-Dutton
  0 siblings, 2 replies; 19+ messages in thread
From: Williams, Richard @ 2004-03-01 16:27 UTC (permalink / raw)
  To: BlueZ Mailing List

Hi Guys,

Your discussion is very relevant to me, since I'm building a small
wearable computer system that will have several Bluetooth devices -=20
among them will be a headset. I was planning to use standard rfcomm
to send data among the other devices and use SCO for the interface=20
from my computer to the BT headset.

It sounds from your discussion that SCO is really not ready to be used.
In my case, since I'm building an embedded system, I want simple
and low power. For my system I'd really like a socket interface to SCO.
If I MUST use a large audio package like ALSA, then I'll do that, but
I really want something small and simple.

Is there a bluez SCO that I can use ?=20
Do you have any idea when a stable SCO package will be available ?

I'm currently using linux-2.4.19 on an Intel Xscale processor.

thank you very much,

Regards,

Rich

Richard B. Williams
Vitronics, Inc.
3 Corbett Way
Eatontown, NJ 07724-2262
732-389-0244 x29
Richard.Williams@vitronics.com


-----Original Message-----
From: Marcel Holtmann [mailto:marcel@holtmann.org]
Sent: Monday, March 01, 2004 10:29 AM
To: James Courtier-Dutton
Cc: BlueZ Mailing List
Subject: Re: [Bluez-devel] SCO. Some ideas.


Hi James,

> I have started to think of how we might better achieve our goal =
without=20
> explicitly having trigger/pointer etc. api calls from the HCI to the =
SCO=20
> layer.
> The current bluez stack handles HCI SCO receiving ok for now. HCI SCO=20
> packets can be lost, but that is not so much of a problem.
> The current problem is the HCI SCO sending. i.e. CPU to Bluetooth air.
> There is no rate limiting in the HCI SCO sending.
> Options for rate limiting: -
> 1) For best sound quality, the rate limiting should be based on the =
HCI=20
> hardware, and not any other source.
> 2) Only send hci sco when one receives an hci sco
> This causes problems if received hci sco packets get dropped due to=20
> missed irqs etc. So it is better to not link the TX rate limiting to =
any=20
> RX packet rate.
> 3) Use the linux system time.
> If the user changes the time, the linux system time get changed, so =
the=20
> rate limiting will be messed up each time the linux system time is=20
> changed. So, better not to use the linux system time.
>=20
> So, we really want to use (1) if we can.
> How about?: -
>=20
> 1) Each hci sco packet being send from the sco layer to the hci layer =
is=20
> tagged with a sequence number.
> We send the hci sco packet from sco layer to hci layer.
> When the tx_complete for that hci sco packet happens, the packet is=20
> returned to the sco layer being taged as complete and then the sco =
layer=20
> refills it with new data and sends it down again. As we tagged the hci =

> sco packet with a sequence number, when it comes back we know which=20
> packet was actually send. As it has a sequence number on it, we can=20
> detect lost packets.
> Because the completed packet is send back up to the sco layer, we are=20
> able to remove one malloc/free from the process.
> Currently we have sco layer doing alloc, hci layer doing free.
>=20
> 2) Just use a limited sized queue.
> sco layer fills the queue, but when the queue is full, it waits.
> the hci layer empties the queue as and when it needs to.
> Currently, I think we have a queue, but the size of the queue is not=20
> controllable from the sco layer.
> It might be better if the hci layer reads the first item in the queue, =

> schedules it for output. the hci layer only frees the item from the=20
> queue when it reaches tx_complete.
> The tx_complete state is reached when the bluetooth hardware calls the =

> interrupt handler.
>=20
> I think option (2) fits more closely with the current bluez design. =
All=20
> I need is the answer to "How does one limit the queue size?".

maybe you should look at hci_send_sco() and you can control everything
by yourself that you wanna send down to the HCI layer and thus to the
driver. Every connection has its own data queue (data_q).

Regards

Marcel




-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=3D1356&alloc_id=3D3438&op=3Dclick
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 19+ messages in thread
* RE: [Bluez-devel] SCO. Some ideas.
@ 2004-03-01 19:08 Williams, Richard
  2004-03-01 19:45 ` James Courtier-Dutton
  2004-03-01 19:46 ` James Courtier-Dutton
  0 siblings, 2 replies; 19+ messages in thread
From: Williams, Richard @ 2004-03-01 19:08 UTC (permalink / raw)
  To: James Courtier-Dutton; +Cc: BlueZ Mailing List

James,

Thanks for the reply. But I am having trouble getting SCO to work on my
platform. Can you point me to any documentation that explains how
to get this to work ? I want to have a Sony-Ericsson BT headset to=20
send/receive audio to/from my Linux box - 2.4.19.=20

I do have BT working: rfcomm, SDP, Obex, but SCO is giving me more=20
trouble.

Thanks very much,

Rich

-----Original Message-----
From: James Courtier-Dutton [mailto:James@superbug.demon.co.uk]
Sent: Monday, March 01, 2004 12:39 PM
To: Williams, Richard
Cc: BlueZ Mailing List
Subject: Re: [Bluez-devel] SCO. Some ideas.


Williams, Richard wrote:
> Hi Guys,
>=20
> Your discussion is very relevant to me, since I'm building a small
> wearable computer system that will have several Bluetooth devices -=20
> among them will be a headset. I was planning to use standard rfcomm
> to send data among the other devices and use SCO for the interface=20
> from my computer to the BT headset.
>=20
> It sounds from your discussion that SCO is really not ready to be =
used.
> In my case, since I'm building an embedded system, I want simple
> and low power. For my system I'd really like a socket interface to =
SCO.
> If I MUST use a large audio package like ALSA, then I'll do that, but
> I really want something small and simple.
>=20
> Is there a bluez SCO that I can use ?=20
> Do you have any idea when a stable SCO package will be available ?
>=20
> I'm currently using linux-2.4.19 on an Intel Xscale processor.
>=20
> thank you very much,
>=20
> Regards,
>=20
> Rich
>=20
> Richard B. Williams
> Vitronics, Inc.
> 3 Corbett Way
> Eatontown, NJ 07724-2262
> 732-389-0244 x29
> Richard.Williams@vitronics.com
>=20

SCO connections currently functions over the socket interface.
You can send sound to the headset, and receive sound from the headset=20
mics. The only problem is in the buffering. That support is there in=20
kernel 2.6.4, or 2.6.3 with patches, and also 2.4.x with other patches.

The problem in the buffering is the current lack of any feedback.
E.g. You output 0.1 second of samples. There is no feedback to tell you=20
that all the samples have been played, or if it is still in the middle=20
of playing.
So, lets take a possible real world setup.
One is playing an internet video stream. One has no way to keep audio in =

sync with video.

Summary: -
The current SCO support if fine, unless you need to keep the playback=20
audio in sync with anything.

Cheers
James


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 19+ messages in thread
* RE: [Bluez-devel] SCO. Some ideas.
@ 2004-03-01 20:25 Williams, Richard
  0 siblings, 0 replies; 19+ messages in thread
From: Williams, Richard @ 2004-03-01 20:25 UTC (permalink / raw)
  To: James Courtier-Dutton; +Cc: BlueZ Mailing List

James,

I currently have two systems:=20
- my development host machine - an x86 PC, 2.4.20-6 Red Hat. There is
no patch available for this kernel, so I'm doing my work on the =
following:
- my target machine, an xScale single board computer, 2.4.19,=20
with several hardware specific patches. I did apply the 2.4.19.mh14 =
patch to this.

For both machines. I use an Anycomm USB BT dongle. I don't know what =
chipset is inside.

So I've got rfcomm, hci, SDP and sco.c on the target xScale machine.=20
The modules are loaded OK. I can "hcitool scan" and see the headset.

I've been running the following commands:
hcid
hciconfig hci0 voice 0x0040
sdpd
sdptool add --channel=3D7 HSET
hstest play file 00:02:72:41:2E:2F 7
<<< nothing seems to happen>>>>

Before I can connect, the headset must be paired. I put the headset=20
into pairing mode, then how do I get linux to initiate pairing with=20
the headset ?

I'm not sure what to do next. Any advice is appreciated.

Thanks,

Rich


-----Original Message-----
From: James Courtier-Dutton [mailto:James@superbug.demon.co.uk]
Sent: Monday, March 01, 2004 2:47 PM
To: Williams, Richard
Cc: BlueZ Mailing List
Subject: Re: [Bluez-devel] SCO. Some ideas.


Williams, Richard wrote:
> James,
>=20
> Thanks for the reply. But I am having trouble getting SCO to work on =
my
> platform. Can you point me to any documentation that explains how
> to get this to work ? I want to have a Sony-Ericsson BT headset to=20
> send/receive audio to/from my Linux box - 2.4.19.=20
>=20
> I do have BT working: rfcomm, SDP, Obex, but SCO is giving me more=20
> trouble.
>=20
> Thanks very much,
>=20
> Rich
>=20

Which type of bluetooth interface do you have on the PC?
I currently use a USB CSR based bluetooth device and a Sony-Ericsson=20
HBH-30 headset.

Cheers
James


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2004-03-02  7:43 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-29 16:15 [Bluez-devel] SCO. Some ideas James Courtier-Dutton
2004-02-29 17:02 ` Marcel Holtmann
2004-02-29 18:40   ` James Courtier-Dutton
2004-02-29 20:38     ` Marcel Holtmann
2004-02-29 21:19       ` James Courtier-Dutton
2004-02-29 22:01         ` Marcel Holtmann
2004-02-29 23:25           ` James Courtier-Dutton
2004-02-29 23:38             ` Marcel Holtmann
2004-03-01 14:11               ` James Courtier-Dutton
2004-03-01 15:28                 ` Marcel Holtmann
  -- strict thread matches above, loose matches on Subject: below --
2004-03-01 16:27 Williams, Richard
2004-03-01 17:20 ` Simon Vogl
2004-03-01 17:22   ` Marcel Holtmann
2004-03-02  7:43     ` Simon Vogl
2004-03-01 17:39 ` James Courtier-Dutton
2004-03-01 19:08 Williams, Richard
2004-03-01 19:45 ` James Courtier-Dutton
2004-03-01 19:46 ` James Courtier-Dutton
2004-03-01 20:25 Williams, Richard

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).