* whitespace cleanup and some style fixes

* fixes TODO about using phys_addr_t instead of void*


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37013 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2010-06-04 22:52:06 +00:00
parent e43d37db09
commit ac0b32534b
5 changed files with 147 additions and 148 deletions
+98 -98
View File
@@ -122,7 +122,7 @@ echo_mem *
echo_mem_alloc(echo_dev *card, size_t size) echo_mem_alloc(echo_dev *card, size_t size)
{ {
echo_mem *mem; echo_mem *mem;
mem = echo_mem_new(card, size); mem = echo_mem_new(card, size);
if (mem == NULL) if (mem == NULL)
return (NULL); return (NULL);
@@ -136,12 +136,12 @@ void
echo_mem_free(echo_dev *card, void *ptr) echo_mem_free(echo_dev *card, void *ptr)
{ {
echo_mem *mem; echo_mem *mem;
LIST_FOREACH(mem, &card->mems, next) { LIST_FOREACH(mem, &card->mems, next) {
if (mem->log_base != ptr) if (mem->log_base != ptr)
continue; continue;
LIST_REMOVE(mem, next); LIST_REMOVE(mem, next);
echo_mem_delete(mem); echo_mem_delete(mem);
break; break;
} }
@@ -161,11 +161,11 @@ echo_stream_set_audioparms(echo_stream *stream, uint8 channels,
ECHOGALS_CLOSEAUDIOPARAMETERS close_params; ECHOGALS_CLOSEAUDIOPARAMETERS close_params;
ECHOGALS_AUDIOFORMAT format_params; ECHOGALS_AUDIOFORMAT format_params;
ECHOSTATUS status; ECHOSTATUS status;
LOG(("echo_stream_set_audioparms\n")); LOG(("echo_stream_set_audioparms\n"));
if (stream->pipe >= 0) { if (stream->pipe >= 0) {
close_params.wPipeIndex = stream->pipe; close_params.wPipeIndex = stream->pipe;
status = stream->card->pEG->CloseAudio(&close_params); status = stream->card->pEG->CloseAudio(&close_params);
if (status != ECHOSTATUS_OK && status != ECHOSTATUS_CHANNEL_NOT_OPEN) { if (status != ECHOSTATUS_OK && status != ECHOSTATUS_CHANNEL_NOT_OPEN) {
PRINT(("echo_stream_set_audioparms : CloseAudio failed\n")); PRINT(("echo_stream_set_audioparms : CloseAudio failed\n"));
@@ -173,13 +173,13 @@ echo_stream_set_audioparms(echo_stream *stream, uint8 channels,
return B_ERROR; return B_ERROR;
} }
} }
open_params.bIsCyclic = TRUE; open_params.bIsCyclic = TRUE;
open_params.Pipe.nPipe = index; open_params.Pipe.nPipe = index;
open_params.Pipe.bIsInput = stream->use == ECHO_USE_RECORD ? TRUE : FALSE; open_params.Pipe.bIsInput = stream->use == ECHO_USE_RECORD ? TRUE : FALSE;
open_params.Pipe.wInterleave = channels; open_params.Pipe.wInterleave = channels;
open_params.ProcessId = NULL; open_params.ProcessId = NULL;
status = stream->card->pEG->OpenAudio(&open_params, &stream->pipe); status = stream->card->pEG->OpenAudio(&open_params, &stream->pipe);
if (status != ECHOSTATUS_OK) { if (status != ECHOSTATUS_OK) {
PRINT(("echo_stream_set_audioparms : OpenAudio failed\n")); PRINT(("echo_stream_set_audioparms : OpenAudio failed\n"));
@@ -197,10 +197,10 @@ echo_stream_set_audioparms(echo_stream *stream, uint8 channels,
if (bitsPerSample == 24) if (bitsPerSample == 24)
bitsPerSample = 32; bitsPerSample = 32;
if ((stream->channels == channels) && if ((stream->channels == channels)
(stream->bitsPerSample == bitsPerSample) && && (stream->bitsPerSample == bitsPerSample)
(stream->sample_rate == sample_rate)) && (stream->sample_rate == sample_rate))
return B_OK; return B_OK;
format_params.wBitsPerSample = bitsPerSample; format_params.wBitsPerSample = bitsPerSample;
@@ -214,14 +214,14 @@ echo_stream_set_audioparms(echo_stream *stream, uint8 channels,
PRINT((" status: %s \n", pStatusStrs[status])); PRINT((" status: %s \n", pStatusStrs[status]));
return B_ERROR; return B_ERROR;
} }
status = stream->card->pEG->SetAudioFormat(stream->pipe, &format_params); status = stream->card->pEG->SetAudioFormat(stream->pipe, &format_params);
if (status != ECHOSTATUS_OK) { if (status != ECHOSTATUS_OK) {
PRINT(("echo_stream_set_audioparms : bad format when setting\n")); PRINT(("echo_stream_set_audioparms : bad format when setting\n"));
PRINT((" status: %s \n", pStatusStrs[status])); PRINT((" status: %s \n", pStatusStrs[status]));
return B_ERROR; return B_ERROR;
} }
/* XXXX : setting sample rate is global in this driver */ /* XXXX : setting sample rate is global in this driver */
status = stream->card->pEG->QueryAudioSampleRate(sample_rate); status = stream->card->pEG->QueryAudioSampleRate(sample_rate);
if (status != ECHOSTATUS_OK) { if (status != ECHOSTATUS_OK) {
@@ -229,7 +229,7 @@ echo_stream_set_audioparms(echo_stream *stream, uint8 channels,
PRINT((" status: %s \n", pStatusStrs[status])); PRINT((" status: %s \n", pStatusStrs[status]));
return B_ERROR; return B_ERROR;
} }
/* XXXX : setting sample rate is global in this driver */ /* XXXX : setting sample rate is global in this driver */
status = stream->card->pEG->SetAudioSampleRate(sample_rate); status = stream->card->pEG->SetAudioSampleRate(sample_rate);
if (status != ECHOSTATUS_OK) { if (status != ECHOSTATUS_OK) {
@@ -237,61 +237,61 @@ echo_stream_set_audioparms(echo_stream *stream, uint8 channels,
PRINT((" status: %s \n", pStatusStrs[status])); PRINT((" status: %s \n", pStatusStrs[status]));
return B_ERROR; return B_ERROR;
} }
if (stream->buffer) if (stream->buffer)
echo_mem_free(stream->card, stream->buffer->log_base); echo_mem_free(stream->card, stream->buffer->log_base);
stream->bitsPerSample = bitsPerSample; stream->bitsPerSample = bitsPerSample;
stream->sample_rate = sample_rate; stream->sample_rate = sample_rate;
stream->channels = channels; stream->channels = channels;
sample_size = stream->bitsPerSample / 8; sample_size = stream->bitsPerSample / 8;
frame_size = sample_size * stream->channels; frame_size = sample_size * stream->channels;
stream->buffer = echo_mem_alloc(stream->card, stream->bufframes * frame_size * stream->bufcount); stream->buffer = echo_mem_alloc(stream->card, stream->bufframes * frame_size * stream->bufcount);
stream->trigblk = 1; stream->trigblk = 1;
stream->blkmod = stream->bufcount; stream->blkmod = stream->bufcount;
stream->blksize = stream->bufframes * frame_size; stream->blksize = stream->bufframes * frame_size;
CDaffyDuck *duck = stream->card->pEG->GetDaffyDuck(stream->pipe); CDaffyDuck *duck = stream->card->pEG->GetDaffyDuck(stream->pipe);
if (duck == NULL) { if (duck == NULL) {
PRINT(("echo_stream_set_audioparms : Could not get daffy duck pointer\n")); PRINT(("echo_stream_set_audioparms : Could not get daffy duck pointer\n"));
return B_ERROR; return B_ERROR;
} }
uint32 dwNumFreeEntries = 0; uint32 dwNumFreeEntries = 0;
for (i = 0; i < stream->bufcount; i++) { for (i = 0; i < stream->bufcount; i++) {
duck->AddMapping(((uint32)stream->buffer->phy_base) + duck->AddMapping(((uint32)stream->buffer->phy_base) +
i * stream->blksize, stream->blksize, 0, TRUE, dwNumFreeEntries); i * stream->blksize, stream->blksize, 0, TRUE, dwNumFreeEntries);
} }
duck->Wrap(); duck->Wrap();
if (stream->card->pEG->GetAudioPositionPtr(stream->pipe, stream->position)!=ECHOSTATUS_OK) { if (stream->card->pEG->GetAudioPositionPtr(stream->pipe, stream->position)!=ECHOSTATUS_OK) {
PRINT(("echo_stream_set_audioparms : Could not get audio position ptr\n")); PRINT(("echo_stream_set_audioparms : Could not get audio position ptr\n"));
return B_ERROR; return B_ERROR;
} }
return B_OK; return B_OK;
} }
status_t status_t
echo_stream_get_nth_buffer(echo_stream *stream, uint8 chan, uint8 buf, echo_stream_get_nth_buffer(echo_stream *stream, uint8 chan, uint8 buf,
char** buffer, size_t *stride) char** buffer, size_t *stride)
{ {
uint8 sample_size, frame_size; uint8 sample_size, frame_size;
LOG(("echo_stream_get_nth_buffer\n")); LOG(("echo_stream_get_nth_buffer\n"));
sample_size = stream->bitsPerSample / 8; sample_size = stream->bitsPerSample / 8;
frame_size = sample_size * stream->channels; frame_size = sample_size * stream->channels;
*buffer = (char*)stream->buffer->log_base + (buf * stream->bufframes * frame_size) *buffer = (char*)stream->buffer->log_base + (buf * stream->bufframes * frame_size)
+ chan * sample_size; + chan * sample_size;
*stride = frame_size; *stride = frame_size;
return B_OK; return B_OK;
} }
@@ -310,16 +310,16 @@ echo_stream_start(echo_stream *stream, void (*inth) (void *), void *inthparam)
{ {
LOG(("echo_stream_start\n")); LOG(("echo_stream_start\n"));
ECHOSTATUS status; ECHOSTATUS status;
stream->inth = inth; stream->inth = inth;
stream->inthparam = inthparam; stream->inthparam = inthparam;
stream->state |= ECHO_STATE_STARTED; stream->state |= ECHO_STATE_STARTED;
status = stream->card->pEG->Start(stream->pipe); status = stream->card->pEG->Start(stream->pipe);
if (status!=ECHOSTATUS_OK) { if (status!=ECHOSTATUS_OK) {
PRINT(("echo_stream_start : Could not start the pipe %s\n", pStatusStrs[status])); PRINT(("echo_stream_start : Could not start the pipe %s\n", pStatusStrs[status]));
} }
} }
void void
@@ -327,13 +327,13 @@ echo_stream_halt(echo_stream *stream)
{ {
LOG(("echo_stream_halt\n")); LOG(("echo_stream_halt\n"));
ECHOSTATUS status; ECHOSTATUS status;
stream->state &= ~ECHO_STATE_STARTED; stream->state &= ~ECHO_STATE_STARTED;
status = stream->card->pEG->Stop(stream->pipe); status = stream->card->pEG->Stop(stream->pipe);
if (status!=ECHOSTATUS_OK) { if (status!=ECHOSTATUS_OK) {
PRINT(("echo_stream_halt : Could not stop the pipe %s\n", pStatusStrs[status])); PRINT(("echo_stream_halt : Could not stop the pipe %s\n", pStatusStrs[status]));
} }
} }
echo_stream * echo_stream *
@@ -360,18 +360,18 @@ echo_stream_new(echo_dev *card, uint8 use, uint32 bufframes, uint8 bufcount)
stream->blksize = 0; stream->blksize = 0;
stream->trigblk = 0; stream->trigblk = 0;
stream->blkmod = 0; stream->blkmod = 0;
stream->pipe = -1; stream->pipe = -1;
stream->frames_count = 0; stream->frames_count = 0;
stream->real_time = 0; stream->real_time = 0;
stream->buffer_cycle = 0; stream->buffer_cycle = 0;
stream->update_needed = false; stream->update_needed = false;
status = lock(); status = lock();
LIST_INSERT_HEAD((&card->streams), stream, next); LIST_INSERT_HEAD((&card->streams), stream, next);
unlock(status); unlock(status);
return stream; return stream;
} }
@@ -381,25 +381,25 @@ echo_stream_delete(echo_stream *stream)
cpu_status status; cpu_status status;
ECHOGALS_CLOSEAUDIOPARAMETERS close_params; ECHOGALS_CLOSEAUDIOPARAMETERS close_params;
LOG(("echo_stream_delete\n")); LOG(("echo_stream_delete\n"));
echo_stream_halt(stream); echo_stream_halt(stream);
if (stream->pipe >= 0) { if (stream->pipe >= 0) {
close_params.wPipeIndex = stream->pipe; close_params.wPipeIndex = stream->pipe;
status = stream->card->pEG->CloseAudio(&close_params); status = stream->card->pEG->CloseAudio(&close_params);
if (status != ECHOSTATUS_OK && status != ECHOSTATUS_CHANNEL_NOT_OPEN) { if (status != ECHOSTATUS_OK && status != ECHOSTATUS_CHANNEL_NOT_OPEN) {
PRINT(("echo_stream_set_audioparms : CloseAudio failed\n")); PRINT(("echo_stream_set_audioparms : CloseAudio failed\n"));
PRINT((" status: %s \n", pStatusStrs[status])); PRINT((" status: %s \n", pStatusStrs[status]));
} }
} }
if (stream->buffer) if (stream->buffer)
echo_mem_free(stream->card, stream->buffer->log_base); echo_mem_free(stream->card, stream->buffer->log_base);
status = lock(); status = lock();
LIST_REMOVE(stream, next); LIST_REMOVE(stream, next);
unlock(status); unlock(status);
free(stream); free(stream);
} }
@@ -413,9 +413,9 @@ int32 echo_int(void *arg)
ECHOSTATUS err; ECHOSTATUS err;
echo_stream* stream; echo_stream* stream;
uint32 curblk; uint32 curblk;
err = card->pEG->ServiceIrq(midiReceived); err = card->pEG->ServiceIrq(midiReceived);
if (err != ECHOSTATUS_OK) { if (err != ECHOSTATUS_OK) {
return B_UNHANDLED_INTERRUPT; return B_UNHANDLED_INTERRUPT;
} }
@@ -429,7 +429,7 @@ int32 echo_int(void *arg)
if ((stream->state & ECHO_STATE_STARTED) == 0 || if ((stream->state & ECHO_STATE_STARTED) == 0 ||
(stream->inth == NULL)) (stream->inth == NULL))
continue; continue;
curblk = echo_stream_curaddr(stream); curblk = echo_stream_curaddr(stream);
//TRACE(("echo_int stream %p at trigblk %lu at stream->trigblk %lu\n", //TRACE(("echo_int stream %p at trigblk %lu at stream->trigblk %lu\n",
// stream, curblk, stream->trigblk)); // stream, curblk, stream->trigblk));
@@ -451,14 +451,14 @@ echo_dump_caps(echo_dev *card)
{ {
PECHOGALS_CAPS caps = &card->caps; PECHOGALS_CAPS caps = &card->caps;
PRINT(("name: %s\n", caps->szName)); PRINT(("name: %s\n", caps->szName));
PRINT(("out pipes: %d, in pipes: %d, out busses: %d, in busses: %d, out midi: %d, in midi: %d\n", PRINT(("out pipes: %d, in pipes: %d, out busses: %d, in busses: %d, out midi: %d, in midi: %d\n",
caps->wNumPipesOut, caps->wNumPipesIn, caps->wNumBussesOut, caps->wNumBussesIn, caps->wNumMidiOut, caps->wNumMidiIn)); caps->wNumPipesOut, caps->wNumPipesIn, caps->wNumBussesOut, caps->wNumBussesIn, caps->wNumMidiOut, caps->wNumMidiIn));
} }
/* detect presence of our hardware */ /* detect presence of our hardware */
status_t status_t
init_hardware(void) init_hardware(void)
{ {
#ifdef CARDBUS #ifdef CARDBUS
@@ -467,7 +467,7 @@ init_hardware(void)
int ix=0; int ix=0;
pci_info info; pci_info info;
status_t err = ENODEV; status_t err = ENODEV;
LOG_CREATE(); LOG_CREATE();
PRINT(("init_hardware()\n")); PRINT(("init_hardware()\n"));
@@ -476,14 +476,14 @@ init_hardware(void)
return ENOSYS; return ENOSYS;
while ((*pci->get_nth_pci_info)(ix, &info) == B_OK) { while ((*pci->get_nth_pci_info)(ix, &info) == B_OK) {
ushort card_type = info.u.h0.subsystem_id & 0xfff0; ushort card_type = info.u.h0.subsystem_id & 0xfff0;
if (info.vendor_id == VENDOR_ID && if (info.vendor_id == VENDOR_ID
((info.device_id == DEVICE_ID_56301) && ((info.device_id == DEVICE_ID_56301)
|| (info.device_id == DEVICE_ID_56361)) && || (info.device_id == DEVICE_ID_56361))
(info.u.h0.subsystem_vendor_id == SUBVENDOR_ID) && && (info.u.h0.subsystem_vendor_id == SUBVENDOR_ID)
( && (
#ifdef ECHOGALS_FAMILY #ifdef ECHOGALS_FAMILY
(card_type == DARLA) (card_type == DARLA)
|| (card_type == GINA) || (card_type == GINA)
@@ -509,7 +509,7 @@ init_hardware(void)
} }
ix++; ix++;
} }
put_module(B_PCI_MODULE_NAME); put_module(B_PCI_MODULE_NAME);
if (err != B_OK) { if (err != B_OK) {
@@ -546,22 +546,22 @@ init_driver(void)
return B_OK; return B_OK;
#else #else
int ix=0; int ix=0;
pci_info info; pci_info info;
status_t err; status_t err;
num_cards = 0; num_cards = 0;
if (get_module(B_PCI_MODULE_NAME, (module_info **) &pci)) if (get_module(B_PCI_MODULE_NAME, (module_info **) &pci))
return ENOSYS; return ENOSYS;
while ((*pci->get_nth_pci_info)(ix++, &info) == B_OK) { while ((*pci->get_nth_pci_info)(ix++, &info) == B_OK) {
ushort card_type = info.u.h0.subsystem_id & 0xfff0; ushort card_type = info.u.h0.subsystem_id & 0xfff0;
if (info.vendor_id == VENDOR_ID && if (info.vendor_id == VENDOR_ID
((info.device_id == DEVICE_ID_56301) && ((info.device_id == DEVICE_ID_56301)
|| (info.device_id == DEVICE_ID_56361)) && || (info.device_id == DEVICE_ID_56361))
(info.u.h0.subsystem_vendor_id == SUBVENDOR_ID) && && (info.u.h0.subsystem_vendor_id == SUBVENDOR_ID)
( && (
#ifdef ECHOGALS_FAMILY #ifdef ECHOGALS_FAMILY
(card_type == DARLA) (card_type == DARLA)
|| (card_type == GINA) || (card_type == GINA)
@@ -582,8 +582,8 @@ init_driver(void)
#ifdef ECHO3G_FAMILY #ifdef ECHO3G_FAMILY
(card_type == ECHO3G) (card_type == ECHO3G)
#endif #endif
)) { )) {
if (num_cards == NUM_CARDS) { if (num_cards == NUM_CARDS) {
PRINT(("Too many "DRIVER_NAME" cards installed!\n")); PRINT(("Too many "DRIVER_NAME" cards installed!\n"));
break; break;
@@ -618,7 +618,7 @@ init_driver(void)
PRINT(("no suitable cards found\n")); PRINT(("no suitable cards found\n"));
return ENODEV; return ENODEV;
} }
return B_OK; return B_OK;
#endif #endif
} }
@@ -640,7 +640,7 @@ make_device_names(
} }
#else #else
status_t status_t
cardbus_device_added(pci_info *info, void **cookie) { cardbus_device_added(pci_info *info, void **cookie) {
echo_dev * card, *dev; echo_dev * card, *dev;
uint32 index; uint32 index;
@@ -657,14 +657,14 @@ cardbus_device_added(pci_info *info, void **cookie) {
card->info = *info; card->info = *info;
card->plugged = true; card->plugged = true;
card->index = 0; card->index = 0;
LIST_FOREACH(dev, &devices, next) { LIST_FOREACH(dev, &devices, next) {
if (dev->index == card->index) { if (dev->index == card->index) {
card->index++; card->index++;
dev = LIST_FIRST(&devices); dev = LIST_FIRST(&devices);
} }
} }
// Format device name // Format device name
sprintf(card->name, "audio/hmulti/" DRIVER_NAME "/%ld", card->index); sprintf(card->name, "audio/hmulti/" DRIVER_NAME "/%ld", card->index);
// Lock the devices // Lock the devices
@@ -672,7 +672,7 @@ cardbus_device_added(pci_info *info, void **cookie) {
LIST_INSERT_HEAD((&devices), card, next); LIST_INSERT_HEAD((&devices), card, next);
// Unlock the devices // Unlock the devices
release_sem(device_lock); release_sem(device_lock);
echo_setup(card); echo_setup(card);
return B_OK; return B_OK;
} }
@@ -680,20 +680,20 @@ cardbus_device_added(pci_info *info, void **cookie) {
// cardbus_device_removed - handle cardbus device removal. // cardbus_device_removed - handle cardbus device removal.
// status : OK // status : OK
void void
cardbus_device_removed(void *cookie) cardbus_device_removed(void *cookie)
{ {
echo_dev *card = (echo_dev *) cookie; echo_dev *card = (echo_dev *) cookie;
LOG((": cardbus_device_removed\n")); LOG((": cardbus_device_removed\n"));
// Check // Check
if (card == NULL) { if (card == NULL) {
LOG((": null device 0x%.8x\n", card)); LOG((": null device 0x%.8x\n", card));
return; return;
} }
echo_shutdown(card); echo_shutdown(card);
// Lock the devices // Lock the devices
acquire_sem(device_lock); acquire_sem(device_lock);
// Finalize // Finalize
@@ -718,19 +718,19 @@ echo_setup(echo_dev * card)
{ {
unsigned char cmd; unsigned char cmd;
char *name; char *name;
PRINT(("echo_setup(%p)\n", card)); PRINT(("echo_setup(%p)\n", card));
#ifndef CARDBUS #ifndef CARDBUS
(*pci->write_pci_config)(card->info.bus, card->info.device, (*pci->write_pci_config)(card->info.bus, card->info.device,
card->info.function, PCI_latency, 1, 0xc0 ); card->info.function, PCI_latency, 1, 0xc0 );
make_device_names(card); make_device_names(card);
#endif #endif
card->bmbar = card->info.u.h0.base_registers[0]; card->bmbar = card->info.u.h0.base_registers[0];
card->irq = card->info.u.h0.interrupt_line; card->irq = card->info.u.h0.interrupt_line;
card->area_bmbar = map_mem(&card->log_bmbar, (void *)card->bmbar, card->area_bmbar = map_mem(&card->log_bmbar, card->bmbar,
card->info.u.h0.base_register_sizes[0], DRIVER_NAME" bmbar io"); card->info.u.h0.base_register_sizes[0], DRIVER_NAME" bmbar io");
if (card->area_bmbar <= B_OK) { if (card->area_bmbar <= B_OK) {
LOG(("mapping of bmbar io failed, error = %#x\n",card->area_bmbar)); LOG(("mapping of bmbar io failed, error = %#x\n",card->area_bmbar));
@@ -801,18 +801,18 @@ echo_setup(echo_dev * card)
break; break;
#endif #endif
default: default:
PRINT(("card type 0x%x not supported by "DRIVER_NAME"\n", PRINT(("card type 0x%x not supported by "DRIVER_NAME"\n",
card->type)); card->type));
} }
if (card->pEG == NULL) if (card->pEG == NULL)
goto err2; goto err2;
#ifndef CARDBUS #ifndef CARDBUS
cmd = (*pci->read_pci_config)(card->info.bus, card->info.device, cmd = (*pci->read_pci_config)(card->info.bus, card->info.device,
card->info.function, PCI_command, 2); card->info.function, PCI_command, 2);
PRINT(("PCI command before: %x\n", cmd)); PRINT(("PCI command before: %x\n", cmd));
(*pci->write_pci_config)(card->info.bus, card->info.device, (*pci->write_pci_config)(card->info.bus, card->info.device,
card->info.function, PCI_command, 2, cmd | PCI_command_io); card->info.function, PCI_command, 2, cmd | PCI_command_io);
cmd = (*pci->read_pci_config)(card->info.bus, card->info.device, cmd = (*pci->read_pci_config)(card->info.bus, card->info.device,
card->info.function, PCI_command, 2); card->info.function, PCI_command, 2);
@@ -830,28 +830,28 @@ echo_setup(echo_dev * card)
/* Init streams list */ /* Init streams list */
LIST_INIT(&(card->streams)); LIST_INIT(&(card->streams));
/* Init mems list */ /* Init mems list */
LIST_INIT(&(card->mems)); LIST_INIT(&(card->mems));
#ifdef MIDI_SUPPORT #ifdef MIDI_SUPPORT
card->midi.midi_ready_sem = create_sem(0, "midi sem"); card->midi.midi_ready_sem = create_sem(0, "midi sem");
#endif #endif
PRINT(("installing interrupt : %x\n", card->irq)); PRINT(("installing interrupt : %x\n", card->irq));
status = install_io_interrupt_handler(card->irq, echo_int, card, 0); status = install_io_interrupt_handler(card->irq, echo_int, card, 0);
if (status != B_OK) { if (status != B_OK) {
PRINT(("failed to install interrupt\n")); PRINT(("failed to install interrupt\n"));
goto err2; goto err2;
} }
PRINT(("echo_setup done\n")); PRINT(("echo_setup done\n"));
echo_dump_caps(card); echo_dump_caps(card);
#ifdef ECHO3G_FAMILY #ifdef ECHO3G_FAMILY
if (card->type == ECHO3G) { if (card->type == ECHO3G) {
strncpy(card->caps.szName, ((C3g*)card->pEG)->Get3gBoxName(), strncpy(card->caps.szName, ((C3g*)card->pEG)->Get3gBoxName(),
ECHO_MAXNAMELEN); ECHO_MAXNAMELEN);
} }
#endif #endif
@@ -894,10 +894,10 @@ echo_shutdown(echo_dev *card)
#ifdef MIDI_SUPPORT #ifdef MIDI_SUPPORT
delete_sem(card->midi.midi_ready_sem); delete_sem(card->midi.midi_ready_sem);
#endif #endif
delete card->pEG; delete card->pEG;
delete card->pOSS; delete card->pOSS;
delete_area(card->area_bmbar); delete_area(card->area_bmbar);
} }
@@ -907,10 +907,10 @@ void
uninit_driver(void) uninit_driver(void)
{ {
PRINT(("uninit_driver()\n")); PRINT(("uninit_driver()\n"));
#ifdef CARDBUS #ifdef CARDBUS
echo_dev *dev; echo_dev *dev;
LIST_FOREACH(dev, &devices, next) { LIST_FOREACH(dev, &devices, next) {
echo_shutdown(dev); echo_shutdown(dev);
} }
@@ -921,7 +921,7 @@ uninit_driver(void)
for (ix=0; ix<cnt; ix++) { for (ix=0; ix<cnt; ix++) {
echo_shutdown(&cards[ix]); echo_shutdown(&cards[ix]);
} }
memset(&cards, 0, sizeof(cards)); memset(&cards, 0, sizeof(cards));
put_module(B_PCI_MODULE_NAME); put_module(B_PCI_MODULE_NAME);
#endif #endif
+17 -17
View File
@@ -1,6 +1,6 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// EchoGals/Echo24 BeOS Driver for Echo audio cards // EchoGals/Echo24 BeOS Driver for Echo audio cards
// //
// Copyright (c) 2003, Jérôme Duval // Copyright (c) 2003, Jérôme Duval
// //
// Permission is hereby granted, free of charge, to any person obtaining a // Permission is hereby granted, free of charge, to any person obtaining a
@@ -57,7 +57,7 @@ typedef struct _midi_dev {
/* /*
* Streams * Streams
*/ */
typedef struct _echo_stream { typedef struct _echo_stream {
struct _echo_dev *card; struct _echo_dev *card;
uint8 use; uint8 use;
@@ -67,20 +67,20 @@ typedef struct _echo_stream {
uint8 channels; uint8 channels;
uint32 bufframes; uint32 bufframes;
uint8 bufcount; uint8 bufcount;
WORD pipe; WORD pipe;
PDWORD position; PDWORD position;
LIST_ENTRY(_echo_stream) next; LIST_ENTRY(_echo_stream) next;
void (*inth) (void *); void (*inth) (void *);
void *inthparam; void *inthparam;
echo_mem *buffer; echo_mem *buffer;
uint16 blksize; /* in samples */ uint16 blksize; /* in samples */
uint16 trigblk; /* blk on which to trigger inth */ uint16 trigblk; /* blk on which to trigger inth */
uint16 blkmod; /* Modulo value to wrap trigblk */ uint16 blkmod; /* Modulo value to wrap trigblk */
/* multi_audio */ /* multi_audio */
volatile int64 frames_count; // for play or record volatile int64 frames_count; // for play or record
volatile bigtime_t real_time; // for play or record volatile bigtime_t real_time; // for play or record
@@ -93,32 +93,32 @@ typedef struct _echo_stream {
typedef struct _echo_dev { typedef struct _echo_dev {
char name[DEVNAME]; /* used for resources */ char name[DEVNAME]; /* used for resources */
pci_info info; pci_info info;
uint32 bmbar; uint32 bmbar;
void * log_bmbar; void * log_bmbar;
area_id area_bmbar; area_id area_bmbar;
uint32 irq; uint32 irq;
uint16 type; uint16 type;
PCEchoGals pEG; PCEchoGals pEG;
ECHOGALS_CAPS caps; ECHOGALS_CAPS caps;
NUINT mixer; NUINT mixer;
PCOsSupport pOSS; PCOsSupport pOSS;
void *ptb_log_base; void *ptb_log_base;
void *ptb_phy_base; phys_addr_t ptb_phy_base;
area_id ptb_area; area_id ptb_area;
sem_id buffer_ready_sem; sem_id buffer_ready_sem;
LIST_HEAD(, _echo_stream) streams; LIST_HEAD(, _echo_stream) streams;
LIST_HEAD(, _echo_mem) mems; LIST_HEAD(, _echo_mem) mems;
echo_stream *pstream; echo_stream *pstream;
echo_stream *rstream; echo_stream *rstream;
/* multi_audio */ /* multi_audio */
multi_dev multi; multi_dev multi;
#ifdef MIDI_SUPPORT #ifdef MIDI_SUPPORT
midi_dev midi; midi_dev midi;
#endif #endif
@@ -144,7 +144,7 @@ extern "C" {
status_t echo_stream_set_audioparms(echo_stream *stream, uint8 channels, status_t echo_stream_set_audioparms(echo_stream *stream, uint8 channels,
uint8 bitsPerSample, uint32 sample_ratei, uint8 index); uint8 bitsPerSample, uint32 sample_ratei, uint8 index);
status_t echo_stream_get_nth_buffer(echo_stream *stream, uint8 chan, uint8 buf, status_t echo_stream_get_nth_buffer(echo_stream *stream, uint8 chan, uint8 buf,
char** buffer, size_t *stride); char** buffer, size_t *stride);
void echo_stream_start(echo_stream *stream, void (*inth) (void *), void *inthparam); void echo_stream_start(echo_stream *stream, void (*inth) (void *), void *inthparam);
void echo_stream_halt(echo_stream *stream); void echo_stream_halt(echo_stream *stream);
@@ -117,7 +117,7 @@ typedef unsigned long ECHOSTATUS;
typedef struct _echo_mem { typedef struct _echo_mem {
LIST_ENTRY(_echo_mem) next; LIST_ENTRY(_echo_mem) next;
void *log_base; void *log_base;
void *phy_base; phys_addr_t phy_base;
area_id area; area_id area;
size_t size; size_t size;
} echo_mem; } echo_mem;
@@ -130,8 +130,8 @@ typedef struct _echo_mem {
// //
// Define what a physical address is on this OS // Define what a physical address is on this OS
// //
typedef unsigned long PHYS_ADDR; // Define physical addr type typedef phys_addr_t PHYS_ADDR; // Define physical addr type
typedef unsigned long* PPHYS_ADDR; // Define physical addr pointer type typedef phys_addr_t* PPHYS_ADDR; // Define physical addr pointer type
typedef echo_mem* PPAGE_BLOCK; typedef echo_mem* PPAGE_BLOCK;
@@ -207,7 +207,7 @@ ECHOSTATUS OsFreeNonPaged
// Since static variables are used in place of globals, an instance must // Since static variables are used in place of globals, an instance must
// be constructed and initialized by the OS Interface object prior to // be constructed and initialized by the OS Interface object prior to
// constructing the CEchoGals derived object. The CEchoGals and // constructing the CEchoGals derived object. The CEchoGals and
// CDspCommObject classes must have access to it during their respective // CDspCommObject classes must have access to it during their respective
// construction times. // construction times.
// //
class COsSupport class COsSupport
@@ -260,7 +260,7 @@ public:
DWORD dwBytes, DWORD dwBytes,
PPAGE_BLOCK &pPageBlock PPAGE_BLOCK &pPageBlock
); );
// //
// Free a block of physical memory // Free a block of physical memory
// //
@@ -269,7 +269,7 @@ public:
DWORD dwBytes, DWORD dwBytes,
PPAGE_BLOCK pPageBlock PPAGE_BLOCK pPageBlock
); );
// //
// Get the virtual address for a page block // Get the virtual address for a page block
// //
@@ -308,7 +308,7 @@ public:
// //
WORD GetDeviceId() WORD GetDeviceId()
{ return( m_wDeviceId ); } { return( m_wDeviceId ); }
// //
// Return the hardware revision number // Return the hardware revision number
// //
@@ -316,7 +316,7 @@ public:
{ {
return m_wCardRev; return m_wCardRev;
} }
// //
// Get the current timestamp for MIDI input data // Get the current timestamp for MIDI input data
// //
@@ -324,9 +324,9 @@ public:
{ {
return system_time(); return system_time();
} }
// //
// Overload new & delete so memory for this object is allocated // Overload new & delete so memory for this object is allocated
// from non-paged memory. // from non-paged memory.
// //
PVOID operator new( size_t Size ); PVOID operator new( size_t Size );
@@ -344,7 +344,7 @@ private:
#ifdef ECHO_DEBUG #ifdef ECHO_DEBUG
DWORD m_dwPageBlockCount; DWORD m_dwPageBlockCount;
#endif #endif
}; // class COsSupport }; // class COsSupport
typedef COsSupport * PCOsSupport; typedef COsSupport * PCOsSupport;
+7 -8
View File
@@ -64,9 +64,8 @@ round_to_pagesize(uint32 size)
area_id area_id
alloc_mem(void **phy, void **log, size_t size, const char *name) alloc_mem(phys_addr_t *phy, void **log, size_t size, const char *name)
{ {
// TODO: phy should be phys_addr_t*!
physical_entry pe; physical_entry pe;
void * logadr; void * logadr;
area_id area; area_id area;
@@ -91,7 +90,7 @@ alloc_mem(void **phy, void **log, size_t size, const char *name)
if (log) if (log)
*log = logadr; *log = logadr;
if (phy) if (phy)
*phy = (void*)(addr_t)pe.address; *phy = pe.address;
LOG(("area = %d, size = %d, log = %#08X, phy = %#08X\n", area, size, logadr, LOG(("area = %d, size = %d, log = %#08X, phy = %#08X\n", area, size, logadr,
pe.address)); pe.address));
return area; return area;
@@ -99,19 +98,19 @@ alloc_mem(void **phy, void **log, size_t size, const char *name)
area_id area_id
map_mem(void **log, void *phy, size_t size, const char *name) map_mem(void **log, phys_addr_t phy, size_t size, const char *name)
{ {
uint32 offset; uint32 offset;
void *phyadr; phys_addr_t phyadr;
void *mapadr; void *mapadr;
area_id area; area_id area;
LOG(("mapping physical address %p with %#x bytes for %s\n",phy,size,name)); LOG(("mapping physical address %p with %#x bytes for %s\n",phy,size,name));
offset = (uint32)phy & (B_PAGE_SIZE - 1); offset = phy & (B_PAGE_SIZE - 1);
phyadr = (void*)((uint32)phy - offset); phyadr = phy - offset;
size = round_to_pagesize(size + offset); size = round_to_pagesize(size + offset);
area = map_physical_memory(name, (addr_t)phyadr, size, B_ANY_KERNEL_ADDRESS, area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_ADDRESS,
0, &mapadr); 0, &mapadr);
*log = (void*) ((uint32)mapadr + offset); *log = (void*) ((uint32)mapadr + offset);
+14 -14
View File
@@ -4,24 +4,24 @@
* Copyright (c) 2002, Marcus Overhagen <[email protected]> * Copyright (c) 2002, Marcus Overhagen <[email protected]>
* *
* All rights reserved. * All rights reserved.
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
* *
* - Redistributions of source code must retain the above copyright notice, * - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice, * - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution. * and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
*/ */
@@ -34,14 +34,14 @@ extern "C" {
#include <KernelExport.h> #include <KernelExport.h>
area_id alloc_mem(void **phy, void **log, size_t size, const char *name); area_id alloc_mem(phys_addr_t* phy, void **log, size_t size, const char *name);
cpu_status lock(void); cpu_status lock(void);
void unlock(cpu_status status); void unlock(cpu_status status);
extern spinlock slock; extern spinlock slock;
area_id map_mem(void **log, void *phy, size_t size, const char *name); area_id map_mem(void **log, phys_addr_t phy, size_t size, const char *name);
#ifdef __cplusplus #ifdef __cplusplus
} }