* Count samples, not bytes, stupid :P

* Don't try to bypass semaphore counting, it should just work(tm)
* Minor cleanups.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21158 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ithamar R. Adema
2007-05-16 21:43:15 +00:00
parent ea69b502e1
commit 7c8482e991
4 changed files with 7 additions and 11 deletions
@@ -7,7 +7,6 @@ pci_module_info* pci;
const char** publish_devices(void); /* Just to silence compiler */ const char** publish_devices(void); /* Just to silence compiler */
status_t status_t
init_hardware(void) init_hardware(void)
{ {
@@ -8,7 +8,7 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#ifdef COMPILED_FOR_R5 #ifdef COMPILE_FOR_R5
#define DEVFS_PATH_FORMAT "audio/multi/hda/%lu" #define DEVFS_PATH_FORMAT "audio/multi/hda/%lu"
#include <multi_audio.h> #include <multi_audio.h>
#else #else
@@ -60,10 +60,8 @@ hda_stream_check_intr(hda_controller* ctrlr, hda_stream* s)
uint8 sts = OREG8(ctrlr,s->off,STS); uint8 sts = OREG8(ctrlr,s->off,STS);
if (sts) { if (sts) {
cpu_status status; cpu_status status;
int32 count;
OREG8(ctrlr,s->off,STS) = sts; OREG8(ctrlr,s->off,STS) = sts;
status = disable_interrupts(); status = disable_interrupts();
acquire_spinlock(&s->lock); acquire_spinlock(&s->lock);
@@ -74,9 +72,7 @@ hda_stream_check_intr(hda_controller* ctrlr, hda_stream* s)
release_spinlock(&s->lock); release_spinlock(&s->lock);
restore_interrupts(status); restore_interrupts(status);
get_sem_count(s->buffer_ready_sem, &count); release_sem_etc(s->buffer_ready_sem, 1, B_DO_NOT_RESCHEDULE);
if (count <= 0)
release_sem_etc(s->buffer_ready_sem, 1, B_DO_NOT_RESCHEDULE);
} }
} }
@@ -176,7 +172,7 @@ hda_stream_setup_buffers(hda_codec* codec, hda_stream* s, const char* desc)
/* Setup BDL entries */ /* Setup BDL entries */
for (idx=0; idx < s->num_buffers; idx++, bdl++) { for (idx=0; idx < s->num_buffers; idx++, bdl++) {
bdl->address = buffer_pa + (idx*buffer_size); bdl->address = buffer_pa + (idx*buffer_size);
bdl->length = buffer_size; bdl->length = s->sample_size * s->num_channels * s->buffer_length;
bdl->ioc = 1; bdl->ioc = 1;
} }
@@ -208,7 +204,7 @@ hda_stream_setup_buffers(hda_codec* codec, hda_stream* s, const char* desc)
OREG32(codec->ctrlr,s->off,BDPL) = s->bdl_pa; OREG32(codec->ctrlr,s->off,BDPL) = s->bdl_pa;
OREG32(codec->ctrlr,s->off,BDPU) = 0; OREG32(codec->ctrlr,s->off,BDPU) = 0;
OREG16(codec->ctrlr,s->off,LVI) = s->num_buffers -1; OREG16(codec->ctrlr,s->off,LVI) = s->num_buffers -1;
OREG32(codec->ctrlr,s->off,CBL) = s->num_channels * s->num_buffers * s->sample_size; OREG32(codec->ctrlr,s->off,CBL) = s->num_channels * s->num_buffers;
OREG8(codec->ctrlr,s->off,CTL0) = CTL0_IOCE | CTL0_FEIE | CTL0_DEIE; OREG8(codec->ctrlr,s->off,CTL0) = CTL0_IOCE | CTL0_FEIE | CTL0_DEIE;
OREG8(codec->ctrlr,s->off,CTL2) = s->id << 4; OREG8(codec->ctrlr,s->off,CTL2) = s->id << 4;
@@ -216,9 +216,10 @@ buffer_exchange(hda_codec* codec, multi_buffer_info* data)
hda_stream_start(codec->ctrlr, codec->playback_stream); hda_stream_start(codec->ctrlr, codec->playback_stream);
/* do playback */ /* do playback */
rc=acquire_sem_etc(codec->playback_stream->buffer_ready_sem, 1, B_RELATIVE_TIMEOUT | B_CAN_INTERRUPT, 50000); rc=acquire_sem(codec->playback_stream->buffer_ready_sem);
if (rc != B_OK) { if (rc != B_OK) {
dprintf("%s: Timeout waiting for playback buffer to finish!\n", __func__); dprintf("%s: Error waiting for playback buffer to finish (%s)!\n", __func__,
strerror(rc));
return rc; return rc;
} }