webOS Nation Forums >  Homebrew >  WebOS Internals > Bluetooth A2DP audio fix kernel
Bluetooth A2DP audio fix kernel

  Reply
 
LinkBack Thread Tools Display Modes
Old 11/25/2011, 02:56 PM   #1 (permalink)
Member
 
Join Date: Sep 2009
Location: Canada
Posts: 1,488
Likes Received: 311
Thanks: 64
Thanked 660 Times in 214 Posts
Default Bluetooth A2DP audio fix kernel

So ive been looking into this bluetooth sound quality issue (sound quality of music over a2dp to bluetooth stereo devices is just terrible)

and apparently in linux the bluetooth stack is run in the kernel, and this is where you change the "bitpool" (the quality at which bluetooth audio is sent)

Android and webOS have it set to a maximum of 32, which only allows 32khz of audio. Most audio is 44Khz, and thus the recommended max bitpool is 52. (some overhead for good measure)

I have come across kernel fixes for it in Android,

UnixPsycho and RWhitby, is there anyway we can appropriate these kernel fixes to fix the issue in webOS?

I am attaching all the resources I found.

I am a web programmer, this kernel stuff might as well be written in cantonese, but I am hoping someone here can understand it and run with it.

[Q] Bluetooth Bitpool Setting - Compiled into the kernel? - xda-developers

http://forum.xda-developers.com/showthread.php?t=708685

Looks like Cyanogen sets the bitpool based on sampling frequency, which makes sense. For high sample rates they use 31, for low samples they use 53.

Code repository for Cyanogen Froyo is here https://github.com/CyanogenMod/andro...udio/ipctest.c

Code:
static uint8_t a2dp_default_bitpool(uint8_t freq, uint8_t mode)
{
	switch (freq) {
	case BT_SBC_SAMPLING_FREQ_16000:
	case BT_SBC_SAMPLING_FREQ_32000:
		return 53;

	case BT_SBC_SAMPLING_FREQ_44100:

		switch (mode) {
		case BT_A2DP_CHANNEL_MODE_MONO:
		case BT_A2DP_CHANNEL_MODE_DUAL_CHANNEL:
			return 31;

		case BT_A2DP_CHANNEL_MODE_STEREO:
		case BT_A2DP_CHANNEL_MODE_JOINT_STEREO:
			return 53;

		default:
			DBG("Invalid channel mode %u", mode);
			return 53;
		}
Lets fix the audio over bluetooth qualit once and for all!
__________________
Please Donate if you like my patches and work. Thanks
rmausser is offline   Reply With Quote
Old 11/25/2011, 03:05 PM   #2 (permalink)
Member
 
Join Date: Oct 2009
Location: Berlin
Posts: 2,440
Likes Received: 76
Thanks: 517
Thanked 759 Times in 433 Posts
Default

Nice find.
Sorry for highjacking:
Do you know where I could find the driver to the battery or the A6 chip in TouchPad?
Thanks
__________________
Dr. Battery
somline is offline   Reply With Quote
Old 11/26/2011, 09:19 AM   #3 (permalink)
Member
 
unixpsycho's Avatar
 
Join Date: May 2009
Location: Boston, MA
Posts: 1,331
Likes Received: 20
Thanks: 52
Thanked 1,371 Times in 348 Posts
Default

Quote:
Originally Posted by rmausser View Post
So ive been looking into this bluetooth sound quality issue (sound quality of music over a2dp to bluetooth stereo devices is just terrible)

and apparently in linux the bluetooth stack is run in the kernel, and this is where you change the "bitpool" (the quality at which bluetooth audio is sent)

Android and webOS have it set to a maximum of 32, which only allows 32khz of audio. Most audio is 44Khz, and thus the recommended max bitpool is 52. (some overhead for good measure)

I have come across kernel fixes for it in Android,

UnixPsycho and RWhitby, is there anyway we can appropriate these kernel fixes to fix the issue in webOS?

I am attaching all the resources I found.

I am a web programmer, this kernel stuff might as well be written in cantonese, but I am hoping someone here can understand it and run with it.

[Q] Bluetooth Bitpool Setting - Compiled into the kernel? - xda-developers

Bluetooth A2DP bitpool - xda-developers

Looks like Cyanogen sets the bitpool based on sampling frequency, which makes sense. For high sample rates they use 31, for low samples they use 53.

Code repository for Cyanogen Froyo is here https://github.com/CyanogenMod/andro...udio/ipctest.c

Code:
static uint8_t a2dp_default_bitpool(uint8_t freq, uint8_t mode)
{
    switch (freq) {
    case BT_SBC_SAMPLING_FREQ_16000:
    case BT_SBC_SAMPLING_FREQ_32000:
        return 53;

    case BT_SBC_SAMPLING_FREQ_44100:

        switch (mode) {
        case BT_A2DP_CHANNEL_MODE_MONO:
        case BT_A2DP_CHANNEL_MODE_DUAL_CHANNEL:
            return 31;

        case BT_A2DP_CHANNEL_MODE_STEREO:
        case BT_A2DP_CHANNEL_MODE_JOINT_STEREO:
            return 53;

        default:
            DBG("Invalid channel mode %u", mode);
            return 53;
        }
Lets fix the audio over bluetooth qualit once and for all!
This isn't a kernel fix. This is a userspace bluetooth stack hack.

Last time I looked, webOS has a "special" bluetooth stack, so no source code.
__________________
Live free or DIE!
unixpsycho is offline   Reply With Quote
Old 11/26/2011, 07:34 PM   #4 (permalink)
Member
 
Join Date: Sep 2009
Location: Canada
Posts: 1,488
Likes Received: 311
Thanks: 64
Thanked 660 Times in 214 Posts
Default

No way we could disable, the special one and replace it with an open-source one?

Or is that getting into closed source territory as well.

What a shame.
__________________
Please Donate if you like my patches and work. Thanks
rmausser is offline   Reply With Quote
Old 11/26/2011, 08:27 PM   #5 (permalink)
Member
 
unixpsycho's Avatar
 
Join Date: May 2009
Location: Boston, MA
Posts: 1,331
Likes Received: 20
Thanks: 52
Thanked 1,371 Times in 348 Posts
Default

I thought I saw somewhere that a group was trying to get the open source stack running?

I'm a kernel guy for webOS so i wouldn't know what's involved for userspace since the UI is dependant on certain things, but I know on a normal Linux system I would just grab the BlueZ sources and have at it.

There is a kernel module for a2dp, but it is a DSP plugin and I assume a userspace driver to talk to it directly.
__________________
Live free or DIE!
unixpsycho is offline   Reply With Quote
Old 11/27/2011, 01:39 PM   #6 (permalink)
Member
 
Join Date: Sep 2009
Location: Canada
Posts: 1,488
Likes Received: 311
Thanks: 64
Thanked 660 Times in 214 Posts
Default

OK thanks UnixPsycho,

I am swamped with work and have just simple patches on the go, that I can do in my spare time.

This would take a while to wrap my head around, even with 13 years of linux under my belt.

If someone else could take this project on, that would be amazing.

Heres the code:

https://github.com/CyanogenMod/andro...udio/ipctest.c
__________________
Please Donate if you like my patches and work. Thanks
rmausser is offline   Reply With Quote
Reply

 

Thread Tools
Display Modes



 


Content Relevant URLs by vBSEO 3.6.0