DBRI fixes and improvements [2.4]
This patch greatly improves quality of audio output on my Sparcstation 20. It also contains some other fixes and improvements.
A full list of changes:
- [audio.c] Added missing semicolon when debug information is enabled (compilation bug).
- [audio.c] Number of input and output 8KB buffers is now a module parameter as previous authors requested. More buffers should help on slower machines.
- [audio.c] Fixes some debug strings, so compilation warnings are gone (when debug is enabled).
- [dbri.c] Added missing dbri_get_formats() function, so sox/play now plays sound files without forcing it to Sun audio output interface (OSS works).
- [dbri.c] Enabled burst transfers for DBRI.
- [dbri.c] Added a fix to not leave few bytes in a next memory chunk when building chain of output data buffers for DBRI. It is really a critical thing if the next change is applied.
- [dbri.c] [the most important one] Writing an output data (playback) returns immediately which allows audio player to prepare next data when an audio codec is playing the previous. It removes clicking noise on output signal.
I tested it on dual SuperSPARC 60MHz CPU (OGG file playback = 50% usage of 1 CPU). I am interested in feedback about audio quality change on machines of different speed.
Regards,
Krzysztof Helt
tmp/drivers/sbus/audio/audio.c renamed from drivers/sbus/audio/audio.c +14 -8
@@ -65,6 +65,14 @@#define tprintk (x)#endif +static int audio_input_buffers =8 ; +MODULE_PARM (audio_input_buffers,"i" ); +MODULE_PARM_DESC (audio_input_buffers,"Number of input 8KB buffers." ); + +static int audio_output_buffers =8 ; +MODULE_PARM (audio_output_buffers,"i" ); +MODULE_PARM_DESC (audio_output_buffers,"Number of output 8KB buffer." ); +static short lis_get_elist_ent (strevent_t *list,pid_t pid );static int lis_add_to_elist (strevent_t **list,pid_t pid,short events );static int lis_del_from_elist (strevent_t **list,pid_t pid,short events );
@@ -438,7 +446,7 @@ m = drv->ops->get_input_balance (drv); i =OSS_TO_GAIN (k); j =OSS_TO_BAL (k); -oprintk ((" for stereo to do %d (bal %d):" , i, j)); +oprintk ((" for stereo to do %ld (bal %ld):" , i, j));if (drv->ops->set_input_volume) drv->ops->set_input_volume (drv, i);if (drv->ops->set_input_balance)
@@ -488,7 +496,7 @@oprintk ((" started as (0x%x)\n" ,BAL_TO_OSS (l,m))); i =OSS_TO_GAIN (k); j =OSS_TO_BAL (k); -oprintk ((" for stereo to %d (bal %d)\n" , i, j)); +oprintk ((" for stereo to %ld (bal %ld)\n" , i, j));if (drv->ops->set_output_volume) drv->ops->set_output_volume (drv, i);if (drv->ops->set_output_balance)
@@ -565,7 +573,7 @@if (k &SOUND_MASK_CD ) j =AUDIO_CD ;if (k &SOUND_MASK_LINE ) j =AUDIO_LINE_IN ;if (k &SOUND_MASK_MIC ) j =AUDIO_MICROPHONE ; -oprintk (("setting inport to %d\n" , j)); +oprintk (("setting inport to %ld\n" , j)); i = drv->ops->set_input_port (drv, j);return put_user (i, (int *)arg);
@@ -798,7 +806,7 @@ retval = -EINVAL ;break ; } - get_user(i, (int *)arg) +get_user (i, (int *)arg);tprintk (("setting speed to %d\n" , i)); drv->ops->set_input_rate (drv, i); drv->ops->set_output_rate (drv, i);
@@ -1955,8 +1963,6 @@* Input buffers, on the other hand, always fill completely, * so we don't need input counts - each contains input_buffer_size * bytes of audio data. -* -* TODO: Make number of input/output buffers tunable parameters */ init_waitqueue_head (&drv->open_wait);
@@ -1964,7 +1970,7 @@init_waitqueue_head (&drv->output_drain_wait);init_waitqueue_head (&drv->input_read_wait); - drv->num_output_buffers =8 ; + drv->num_output_buffers = audio_output_buffers; drv->output_buffer_size = (4096 *2 ); drv->playing_count =0 ; drv->output_offset =0 ;
@@ -1997,7 +2003,7 @@ }/* Setup the circular queue of input buffers. */ - drv->num_input_buffers =8 ; + drv->num_input_buffers = audio_input_buffers; drv->input_buffer_size = (4096 *2 ); drv->recording_count =0 ; drv->input_front =0 ;
tmp/drivers/sbus/audio/dbri.c renamed from drivers/sbus/audio/dbri.c +64 -29
221 lines not on this page · raw message
There is a mistake in original patch. CS4215 does not support ADPCM and little-endian formats. The corrected patch is attached.
Krzysztof
tmp/drivers/sbus/audio/audio.c renamed from drivers/sbus/audio/audio.c +14 -8
@@ -65,6 +65,14 @@#define tprintk (x)#endif +static int audio_input_buffers =8 ; +MODULE_PARM (audio_input_buffers,"i" ); +MODULE_PARM_DESC (audio_input_buffers,"Number of input 8KB buffers." ); + +static int audio_output_buffers =8 ; +MODULE_PARM (audio_output_buffers,"i" ); +MODULE_PARM_DESC (audio_output_buffers,"Number of output 8KB buffer." ); +static short lis_get_elist_ent (strevent_t *list,pid_t pid );static int lis_add_to_elist (strevent_t **list,pid_t pid,short events );static int lis_del_from_elist (strevent_t **list,pid_t pid,short events );
@@ -438,7 +446,7 @@ m = drv->ops->get_input_balance (drv); i =OSS_TO_GAIN (k); j =OSS_TO_BAL (k); -oprintk ((" for stereo to do %d (bal %d):" , i, j)); +oprintk ((" for stereo to do %ld (bal %ld):" , i, j));if (drv->ops->set_input_volume) drv->ops->set_input_volume (drv, i);if (drv->ops->set_input_balance)
@@ -488,7 +496,7 @@oprintk ((" started as (0x%x)\n" ,BAL_TO_OSS (l,m))); i =OSS_TO_GAIN (k); j =OSS_TO_BAL (k); -oprintk ((" for stereo to %d (bal %d)\n" , i, j)); +oprintk ((" for stereo to %ld (bal %ld)\n" , i, j));if (drv->ops->set_output_volume) drv->ops->set_output_volume (drv, i);if (drv->ops->set_output_balance)
@@ -565,7 +573,7 @@if (k &SOUND_MASK_CD ) j =AUDIO_CD ;if (k &SOUND_MASK_LINE ) j =AUDIO_LINE_IN ;if (k &SOUND_MASK_MIC ) j =AUDIO_MICROPHONE ; -oprintk (("setting inport to %d\n" , j)); +oprintk (("setting inport to %ld\n" , j)); i = drv->ops->set_input_port (drv, j);return put_user (i, (int *)arg);
@@ -798,7 +806,7 @@ retval = -EINVAL ;break ; } - get_user(i, (int *)arg) +get_user (i, (int *)arg);tprintk (("setting speed to %d\n" , i)); drv->ops->set_input_rate (drv, i); drv->ops->set_output_rate (drv, i);
@@ -1955,8 +1963,6 @@* Input buffers, on the other hand, always fill completely, * so we don't need input counts - each contains input_buffer_size * bytes of audio data. -* -* TODO: Make number of input/output buffers tunable parameters */ init_waitqueue_head (&drv->open_wait);
@@ -1964,7 +1970,7 @@init_waitqueue_head (&drv->output_drain_wait);init_waitqueue_head (&drv->input_read_wait); - drv->num_output_buffers =8 ; + drv->num_output_buffers = audio_output_buffers; drv->output_buffer_size = (4096 *2 ); drv->playing_count =0 ; drv->output_offset =0 ;
@@ -1997,7 +2003,7 @@ }/* Setup the circular queue of input buffers. */ - drv->num_input_buffers =8 ; + drv->num_input_buffers = audio_input_buffers; drv->input_buffer_size = (4096 *2 ); drv->recording_count =0 ; drv->input_front =0 ;
tmp/drivers/sbus/audio/dbri.c renamed from drivers/sbus/audio/dbri.c +63 -29
220 lines not on this page · raw message
David S. Miller
maintainerQuoted 2 lines · On Sat, 26 Feb 2005 21:51:25 +0100 Krzysztof Helt <[email protected]> wrote:
There is a mistake in original patch. CS4215 does not support ADPCM and little-endian formats. The corrected patch is attached.
Looks really good. I've applied this to my tree and will push it to Marcelo unless something major wrong is found.
Feel free to do a 2.6.x sound layer port of this driver if you wish :-) It's the only SBUS audio driver that no port attempt was done for.
Quoted 3 lines · David S. Miller
Feel free to do a 2.6.x sound layer port of this driver if you wish :-) It's the only SBUS audio driver that no port attempt was done for.
For 2.6, there is a DBRI driver in ALSA 1.0.8.
It may need some improvements based in these fixes though. I remember struggling with dbri_cmdsend() at the time.
Signature · 1 line
Martin
Quoted 5 lines · David S. Miller
Feel free to do a 2.6.x sound layer port of this driver if you wish :-) It's the only SBUS audio driver that no port attempt was done for.
DBRI audio needs more work - playback is not fully working (e.g. 8-bit modes, no stereo in A-law, u-law). Recording is even worse - I haven't tested but I see many empty functions. There is also space for improvements (e.g. replace modulo and division operators with mask and shifting in simple cases).
I think that fixing the driver first (at least playback) is better then port it with fixes rather than porting now then prepare two patches for every fix (for 2.4 and 2.6). I don't know much about ALSA architecture either. But I may try with if time allows.
Krzysztof