diff --git a/src/add-ons/kernel/drivers/audio/ac97/auich/util.c b/src/add-ons/kernel/drivers/audio/ac97/auich/util.c index 66d1ee1685..cce3cd2499 100644 --- a/src/add-ons/kernel/drivers/audio/ac97/auich/util.c +++ b/src/add-ons/kernel/drivers/audio/ac97/auich/util.c @@ -97,11 +97,6 @@ alloc_mem(void **phy, void **log, size_t size, const char *name) } -/* This is not the most advanced method to map physical memory for io access. - * Perhaps using B_ANY_KERNEL_ADDRESS instead of B_ANY_KERNEL_BLOCK_ADDRESS - * makes the whole offset calculation and relocation obsolete. But the code - * below does work, and I can't test if using B_ANY_KERNEL_ADDRESS also works. - */ area_id map_mem(void **log, void *phy, size_t size, const char *name) { @@ -115,7 +110,7 @@ map_mem(void **log, void *phy, size_t size, const char *name) offset = (uint32)phy & (B_PAGE_SIZE - 1); phyadr = phy - offset; size = round_to_pagesize(size + offset); - area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_BLOCK_ADDRESS, B_READ_AREA | B_WRITE_AREA, &mapadr); + area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_ADDRESS, 0, &mapadr); *log = mapadr + offset; LOG(("physical = %p, logical = %p, offset = %#x, phyadr = %p, mapadr = %p, size = %#x, area = %#x\n", diff --git a/src/add-ons/kernel/drivers/audio/echo/echo.cpp b/src/add-ons/kernel/drivers/audio/echo/echo.cpp index 41430b2671..700dcd2712 100644 --- a/src/add-ons/kernel/drivers/audio/echo/echo.cpp +++ b/src/add-ons/kernel/drivers/audio/echo/echo.cpp @@ -123,7 +123,7 @@ echo_mem_new(echo_dev *card, size_t size) void echo_mem_delete(echo_mem *mem) { - if(mem->area > B_OK) + if (mem->area > B_OK) delete_area(mem->area); free(mem); } @@ -159,11 +159,11 @@ echo_mem_free(echo_dev *card, void *ptr) /* Echo stream functions */ -extern char * pStatusStrs[ECHOSTATUS_LAST]; +extern char *pStatusStrs[ECHOSTATUS_LAST]; status_t echo_stream_set_audioparms(echo_stream *stream, uint8 channels, - uint8 bitsPerSample, uint32 sample_rate, uint8 index) + uint8 bitsPerSample, uint32 sample_rate, uint8 index) { int32 i; uint8 sample_size, frame_size; @@ -177,7 +177,7 @@ echo_stream_set_audioparms(echo_stream *stream, uint8 channels, if (stream->pipe >= 0) { close_params.wPipeIndex = stream->pipe; 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((" status: %s \n", pStatusStrs[status])); return B_ERROR; @@ -191,7 +191,7 @@ echo_stream_set_audioparms(echo_stream *stream, uint8 channels, open_params.ProcessId = NULL; 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((" status: %s \n", pStatusStrs[status])); return B_ERROR; @@ -199,7 +199,7 @@ echo_stream_set_audioparms(echo_stream *stream, uint8 channels, //PRINT(("VerifyAudioOpen\n")); status = stream->card->pEG->VerifyAudioOpen(stream->pipe); - if(status!=ECHOSTATUS_OK) { + if (status != ECHOSTATUS_OK) { PRINT(("echo_stream_set_audioparms : VerifyAudioOpen failed\n")); PRINT((" status: %s \n", pStatusStrs[status])); return B_ERROR; @@ -216,14 +216,14 @@ echo_stream_set_audioparms(echo_stream *stream, uint8 channels, format_params.wDataInterleave = channels == 1 ? 1 : 2; status = stream->card->pEG->QueryAudioFormat(stream->pipe, &format_params); - if(status!=ECHOSTATUS_OK) { + if (status != ECHOSTATUS_OK) { PRINT(("echo_stream_set_audioparms : bad format when querying\n")); PRINT((" status: %s \n", pStatusStrs[status])); return B_ERROR; } 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((" status: %s \n", pStatusStrs[status])); return B_ERROR; @@ -231,7 +231,7 @@ echo_stream_set_audioparms(echo_stream *stream, uint8 channels, /* XXXX : setting sample rate is global in this driver */ status = stream->card->pEG->QueryAudioSampleRate(sample_rate); - if(status!=ECHOSTATUS_OK) { + if (status != ECHOSTATUS_OK) { PRINT(("echo_stream_set_audioparms : bad sample rate when querying\n")); PRINT((" status: %s \n", pStatusStrs[status])); return B_ERROR; @@ -239,13 +239,13 @@ echo_stream_set_audioparms(echo_stream *stream, uint8 channels, /* XXXX : setting sample rate is global in this driver */ status = stream->card->pEG->SetAudioSampleRate(sample_rate); - if(status!=ECHOSTATUS_OK) { + if (status != ECHOSTATUS_OK) { PRINT(("echo_stream_set_audioparms : bad sample rate when setting\n")); PRINT((" status: %s \n", pStatusStrs[status])); return B_ERROR; } - if(stream->buffer) + if (stream->buffer) echo_mem_free(stream->card, stream->buffer->log_base); stream->bitsPerSample = bitsPerSample; @@ -262,21 +262,21 @@ echo_stream_set_audioparms(echo_stream *stream, uint8 channels, stream->blksize = stream->bufframes * frame_size; 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")); return B_ERROR; } uint32 dwNumFreeEntries = 0; - for(i=0; ibufcount; i++) { + for (i=0; ibufcount; i++) { duck->AddMapping(((uint32)stream->buffer->phy_base) + i * stream->blksize, stream->blksize, 0, TRUE, dwNumFreeEntries); } 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")); return B_ERROR; } @@ -287,7 +287,7 @@ echo_stream_set_audioparms(echo_stream *stream, uint8 channels, status_t 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; LOG(("echo_stream_get_nth_buffer\n")); @@ -386,7 +386,7 @@ void echo_stream_delete(echo_stream *stream) { cpu_status status; - ECHOGALS_CLOSEAUDIOPARAMETERS close_params; + ECHOGALS_CLOSEAUDIOPARAMETERS close_params; LOG(("echo_stream_delete\n")); echo_stream_halt(stream); @@ -400,7 +400,7 @@ echo_stream_delete(echo_stream *stream) } } - if(stream->buffer) + if (stream->buffer) echo_mem_free(stream->card, stream->buffer->log_base); status = lock(); @@ -415,16 +415,15 @@ echo_stream_delete(echo_stream *stream) int32 echo_int(void *arg) { - echo_dev *card = (echo_dev*)arg; - BOOL midiReceived; - ECHOSTATUS err; - - echo_stream *stream; - uint32 curblk; + echo_dev* card = (echo_dev*)arg; + BOOL midiReceived; + ECHOSTATUS err; + echo_stream* stream; + uint32 curblk; err = card->pEG->ServiceIrq(midiReceived); - if(err != ECHOSTATUS_OK) { + if (err != ECHOSTATUS_OK) { return B_UNHANDLED_INTERRUPT; } @@ -442,7 +441,7 @@ int32 echo_int(void *arg) //TRACE(("echo_int stream %p at trigblk %lu at stream->trigblk %lu\n", // stream, curblk, stream->trigblk)); if (curblk == stream->trigblk) { - if(stream->inth) + if (stream->inth) stream->inth(stream->inthparam); stream->trigblk++; @@ -520,7 +519,7 @@ init_hardware(void) put_module(B_PCI_MODULE_NAME); - if(err!=B_OK) { + if (err != B_OK) { PRINT(("no card found\n")); } @@ -536,11 +535,11 @@ init_driver(void) void *settings_handle; // get driver settings - settings_handle = load_driver_settings ("echo.settings"); + settings_handle = load_driver_settings ("echo.settings"); if (settings_handle != NULL) { - const char *item; - char *end; - uint32 value; + const char* item; + char* end; + uint32 value; item = get_driver_parameter (settings_handle, "channels", NULL, NULL); if (item) { @@ -774,7 +773,7 @@ echo_setup(echo_dev * card) card->pOSS = new COsSupport(card->info.device_id, card->info.revision); - if(card->pOSS == NULL) + if (card->pOSS == NULL) return B_ERROR; switch (card->type) { @@ -863,7 +862,7 @@ echo_setup(echo_dev * card) ECHOSTATUS status; status = card->pEG->InitHw(); - if(status != ECHOSTATUS_OK) + if (status != ECHOSTATUS_OK) return B_ERROR; card->pEG->GetCapabilities(&card->caps); @@ -911,7 +910,7 @@ echo_shutdown(echo_dev *card) remove_io_interrupt_handler(card->irq, echo_int, card); #ifdef MIDI_SUPPORT - delete_sem(card->midi.midi_ready_sem); + delete_sem(card->midi.midi_ready_sem); #endif delete card->pEG; diff --git a/src/add-ons/kernel/drivers/audio/echo/midi.cpp b/src/add-ons/kernel/drivers/audio/echo/midi.cpp index bd4088740f..d10d16dd55 100644 --- a/src/add-ons/kernel/drivers/audio/echo/midi.cpp +++ b/src/add-ons/kernel/drivers/audio/echo/midi.cpp @@ -35,23 +35,20 @@ static status_t midi_write(void *cookie, off_t pos, const void *data, size_t *le device_hooks midi_hooks = { - &midi_open, - &midi_close, - &midi_free, - &midi_control, - &midi_read, - &midi_write, - NULL, /* select */ - NULL, /* deselect */ - NULL, /* readv */ - NULL /* writev */ + &midi_open, + &midi_close, + &midi_free, + &midi_control, + &midi_read, + &midi_write, + NULL, /* select */ + NULL, /* deselect */ + NULL, /* readv */ + NULL /* writev */ }; static status_t -midi_open( - const char * name, - uint32 flags, - void ** cookie) +midi_open(const char* name, uint32 flags, void** cookie) { int ix; @@ -77,8 +74,7 @@ midi_open( static status_t -midi_close( - void * cookie) +midi_close(void* cookie) { LOG(("midi_close()\n")); return B_OK; @@ -86,8 +82,7 @@ midi_close( static status_t -midi_free( - void * cookie) +midi_free(void* cookie) { echo_dev *card = (echo_dev *) cookie; @@ -102,11 +97,7 @@ midi_free( static status_t -midi_control( - void * cookie, - uint32 iop, - void * data, - size_t len) +midi_control(void* cookie, uint32 iop, void* data, size_t len) { LOG(("midi_control()\n")); @@ -115,11 +106,7 @@ midi_control( static status_t -midi_read( - void * cookie, - off_t pos, - void * ptr, - size_t * nread) +midi_read(void* cookie, off_t pos, void* ptr, size_t* nread) { echo_dev *card = (echo_dev *) cookie; ECHOSTATUS err; @@ -144,18 +131,13 @@ midi_read( static status_t -midi_write( - void * cookie, - off_t pos, - const void * ptr, - size_t * nwritten) +midi_write(void* cookie, off_t pos, const void* ptr, size_t* nwritten) { echo_dev *card = (echo_dev *) cookie; - ECHOSTATUS err; + ECHOSTATUS err; LOG(("midi_write()\n")); err = card->pEG->WriteMidi(*nwritten, (PBYTE)ptr, nwritten); return (err != ECHOSTATUS_OK) ? B_ERROR : B_OK; } - diff --git a/src/add-ons/kernel/drivers/audio/echo/multi.cpp b/src/add-ons/kernel/drivers/audio/echo/multi.cpp index 2d9e81f8f6..860553a077 100644 --- a/src/add-ons/kernel/drivers/audio/echo/multi.cpp +++ b/src/add-ons/kernel/drivers/audio/echo/multi.cpp @@ -41,14 +41,14 @@ #include "util.h" typedef enum { - B_MIX_GAIN = 1 << 0, - B_MIX_MUTE = 1 << 1, - B_MIX_NOMINAL = 1 << 2 -} mixer_type; + B_MIX_GAIN = 1 << 0, + B_MIX_MUTE = 1 << 1, + B_MIX_NOMINAL = 1 << 2 +} mixer_type; + static void echo_channel_get_mix(void *card, MIXER_AUDIO_CHANNEL channel, int32 type, float *values) { - echo_dev *dev = (echo_dev*) card; MIXER_MULTI_FUNCTION multi_function[2]; PMIXER_FUNCTION function = multi_function[0].MixerFunction; @@ -57,15 +57,15 @@ echo_channel_get_mix(void *card, MIXER_AUDIO_CHANNEL channel, int32 type, float function[1].Channel = channel; function[1].Channel.wChannel++; switch (type) { - case B_MIX_GAIN: - function[0].iFunction = function[1].iFunction = MXF_GET_LEVEL; - break; - case B_MIX_MUTE: - function[0].iFunction = function[1].iFunction = MXF_GET_MUTE; - break; - case B_MIX_NOMINAL: - function[0].iFunction = function[1].iFunction = MXF_GET_NOMINAL; - break; + case B_MIX_GAIN: + function[0].iFunction = function[1].iFunction = MXF_GET_LEVEL; + break; + case B_MIX_MUTE: + function[0].iFunction = function[1].iFunction = MXF_GET_MUTE; + break; + case B_MIX_NOMINAL: + function[0].iFunction = function[1].iFunction = MXF_GET_NOMINAL; + break; } multi_function[0].iCount = 2; @@ -80,23 +80,25 @@ echo_channel_get_mix(void *card, MIXER_AUDIO_CHANNEL channel, int32 type, float } else { values[0] = function[0].Data.iNominal == 4 ? 1.0 : 0.0; } - PRINT(("echo_channel_get_mix iLevel: %ld, %d, %ld\n", function[0].Data.iLevel, channel.wChannel, channel.dwType)); + PRINT(("echo_channel_get_mix iLevel: %ld, %d, %ld\n", function[0].Data.iLevel, + channel.wChannel, channel.dwType)); } } + static void echo_channel_set_mix(void *card, MIXER_AUDIO_CHANNEL channel, int32 type, float *values) { echo_dev *dev = (echo_dev*) card; MIXER_MULTI_FUNCTION multi_function[2]; PMIXER_FUNCTION function = multi_function[0].MixerFunction; - INT32 size = ComputeMixerMultiFunctionSize(2); - function[0].Channel = channel; + INT32 size = ComputeMixerMultiFunctionSize(2); + function[0].Channel = channel; function[1].Channel = channel; function[1].Channel.wChannel++; if (type == B_MIX_GAIN) { function[0].Data.iLevel = (int)(values[0] * 256); - function[0].iFunction = MXF_SET_LEVEL; + function[0].iFunction = MXF_SET_LEVEL; function[1].Data.iLevel = (int)(values[1] * 256); function[1].iFunction = MXF_SET_LEVEL; } else if (type == B_MIX_MUTE) { @@ -106,35 +108,36 @@ echo_channel_set_mix(void *card, MIXER_AUDIO_CHANNEL channel, int32 type, float function[1].iFunction = MXF_SET_MUTE; } else { function[0].Data.iNominal = values[0] == 1.0 ? 4 : -10; - function[0].iFunction = MXF_SET_NOMINAL; - function[1].Data.iNominal = values[0] == 1.0 ? 4 : -10; - function[1].iFunction = MXF_SET_NOMINAL; + function[0].iFunction = MXF_SET_NOMINAL; + function[1].Data.iNominal = values[0] == 1.0 ? 4 : -10; + function[1].iFunction = MXF_SET_NOMINAL; } multi_function[0].iCount = 2; - dev->pEG->ProcessMixerMultiFunction(multi_function, size); - - if (function[0].RtnStatus == ECHOSTATUS_OK) { - PRINT(("echo_channel_set_mix OK: %ld, %d, %ld\n", function[0].Data.iLevel, channel.wChannel, channel.dwType)); - } + dev->pEG->ProcessMixerMultiFunction(multi_function, size); + + if (function[0].RtnStatus == ECHOSTATUS_OK) { + PRINT(("echo_channel_set_mix OK: %ld, %d, %ld\n", function[0].Data.iLevel, + channel.wChannel, channel.dwType)); + } } static int32 echo_create_group_control(multi_dev *multi, uint32 *index, int32 parent, - enum strind_id string, const char* name) { - uint32 i = *index; - (*index)++; - multi->controls[i].mix_control.id = MULTI_CONTROL_FIRSTID + i; - multi->controls[i].mix_control.parent = parent; - multi->controls[i].mix_control.flags = B_MULTI_MIX_GROUP; - multi->controls[i].mix_control.master = MULTI_CONTROL_MASTERID; - multi->controls[i].mix_control.string = string; - if(name) - strcpy(multi->controls[i].mix_control.name, name); - - return multi->controls[i].mix_control.id; + enum strind_id string, const char* name) { + uint32 i = *index; + (*index)++; + multi->controls[i].mix_control.id = MULTI_CONTROL_FIRSTID + i; + multi->controls[i].mix_control.parent = parent; + multi->controls[i].mix_control.flags = B_MULTI_MIX_GROUP; + multi->controls[i].mix_control.master = MULTI_CONTROL_MASTERID; + multi->controls[i].mix_control.string = string; + if (name) + strcpy(multi->controls[i].mix_control.name, name); + + return multi->controls[i].mix_control.id; } static void @@ -216,7 +219,7 @@ echo_create_controls_list(multi_dev *multi) channel.wChannel = i * 2; parent2 = echo_create_group_control(multi, &index, parent, S_null, "Input"); - + echo_create_channel_control(multi, &index, parent2, 0, channel, card->caps.dwBusInCaps[i*2] & ECHOCAPS_NOMINAL_LEVEL); } @@ -232,32 +235,32 @@ echo_get_mix(echo_dev *card, multi_mix_value_info * MMVI) int32 i; uint32 id; multi_mixer_control *control = NULL; - for(i=0; iitem_count; i++) { + for (i=0; iitem_count; i++) { id = MMVI->values[i].id - MULTI_CONTROL_FIRSTID; - if(id < 0 || id >= card->multi.control_count) { + if (id < 0 || id >= card->multi.control_count) { PRINT(("echo_get_mix : invalid control id requested : %li\n", id)); continue; } control = &card->multi.controls[id]; - if(control->mix_control.flags & B_MULTI_MIX_GAIN) { - if(control->get) { + if (control->mix_control.flags & B_MULTI_MIX_GAIN) { + if (control->get) { float values[2]; control->get(card, control->channel, control->type, values); - if(control->mix_control.master == MULTI_CONTROL_MASTERID) + if (control->mix_control.master == MULTI_CONTROL_MASTERID) MMVI->values[i].gain = values[0]; else MMVI->values[i].gain = values[1]; } } - if(control->mix_control.flags & B_MULTI_MIX_ENABLE && control->get) { + if (control->mix_control.flags & B_MULTI_MIX_ENABLE && control->get) { float values[1]; control->get(card, control->channel, control->type, values); MMVI->values[i].enable = (values[0] == 1.0); } - if(control->mix_control.flags & B_MULTI_MIX_MUX && control->get) { + if (control->mix_control.flags & B_MULTI_MIX_MUX && control->get) { float values[1]; control->get(card, control->channel, control->type, values); MMVI->values[i].mux = (int32)values[0]; @@ -266,61 +269,62 @@ echo_get_mix(echo_dev *card, multi_mix_value_info * MMVI) return B_OK; } + static status_t echo_set_mix(echo_dev *card, multi_mix_value_info * MMVI) { int32 i; uint32 id; multi_mixer_control *control = NULL; - for(i=0; iitem_count; i++) { + for (i=0; iitem_count; i++) { id = MMVI->values[i].id - MULTI_CONTROL_FIRSTID; - if(id < 0 || id >= card->multi.control_count) { + if (id < 0 || id >= card->multi.control_count) { PRINT(("echo_set_mix : invalid control id requested : %li\n", id)); continue; } control = &card->multi.controls[id]; - if(control->mix_control.flags & B_MULTI_MIX_GAIN) { + if (control->mix_control.flags & B_MULTI_MIX_GAIN) { multi_mixer_control *control2 = NULL; - if(i+1item_count) { + if (i+1item_count) { id = MMVI->values[i + 1].id - MULTI_CONTROL_FIRSTID; - if(id < 0 || id >= card->multi.control_count) { + if (id < 0 || id >= card->multi.control_count) { PRINT(("echo_set_mix : invalid control id requested : %li\n", id)); } else { control2 = &card->multi.controls[id]; - if(control2->mix_control.master != control->mix_control.id) + if (control2->mix_control.master != control->mix_control.id) control2 = NULL; } } - if(control->set) { + if (control->set) { float values[2]; values[0] = 0.0; values[1] = 0.0; - if(control->mix_control.master == MULTI_CONTROL_MASTERID) + if (control->mix_control.master == MULTI_CONTROL_MASTERID) values[0] = MMVI->values[i].gain; else values[1] = MMVI->values[i].gain; - if(control2 && control2->mix_control.master != MULTI_CONTROL_MASTERID) + if (control2 && control2->mix_control.master != MULTI_CONTROL_MASTERID) values[1] = MMVI->values[i+1].gain; control->set(card, control->channel, control->type, values); } - if(control2) - i++; + if (control2) + i++; } - if(control->mix_control.flags & B_MULTI_MIX_ENABLE && control->set) { + if (control->mix_control.flags & B_MULTI_MIX_ENABLE && control->set) { float values[1]; values[0] = MMVI->values[i].enable ? 1.0 : 0.0; control->set(card, control->channel, control->type, values); } - if(control->mix_control.flags & B_MULTI_MIX_MUX && control->set) { + if (control->mix_control.flags & B_MULTI_MIX_MUX && control->set) { float values[1]; values[0] = (float)MMVI->values[i].mux; @@ -330,6 +334,7 @@ echo_set_mix(echo_dev *card, multi_mix_value_info * MMVI) return B_OK; } + static status_t echo_list_mix_controls(echo_dev *card, multi_mix_control_info * MMCI) { @@ -337,12 +342,12 @@ echo_list_mix_controls(echo_dev *card, multi_mix_control_info * MMCI) uint32 i; MMC = MMCI->controls; - if(MMCI->control_count < 24) + if (MMCI->control_count < 24) return B_ERROR; - if(echo_create_controls_list(&card->multi) < B_OK) + if (echo_create_controls_list(&card->multi) < B_OK) return B_ERROR; - for(i=0; imulti.control_count; i++) { + for (i=0; imulti.control_count; i++) { MMC[i] = card->multi.controls[i].mix_control; } @@ -350,12 +355,14 @@ echo_list_mix_controls(echo_dev *card, multi_mix_control_info * MMCI) return B_OK; } + static status_t -echo_list_mix_connections(echo_dev *card, multi_mix_connection_info * data) +echo_list_mix_connections(echo_dev* card, multi_mix_connection_info* data) { return B_ERROR; } + static status_t echo_list_mix_channels(echo_dev *card, multi_mix_channel_info *data) { @@ -414,18 +421,18 @@ echo_create_channels_list(multi_dev *multi) chans = multi->chans; index = 0; - for(mode=ECHO_USE_PLAY; mode!=-1; + for (mode=ECHO_USE_PLAY; mode!=-1; mode = (mode == ECHO_USE_PLAY) ? ECHO_USE_RECORD : -1) { LIST_FOREACH(stream, &((echo_dev*)multi->card)->streams, next) { if ((stream->use & mode) == 0) continue; - if(stream->channels == 2) + if (stream->channels == 2) designations = B_CHANNEL_STEREO_BUS; else designations = B_CHANNEL_SURROUND_BUS; - for(i=0; ichannels; i++) { + for (i=0; ichannels; i++) { chans[index].channel_id = index; chans[index].kind = (mode == ECHO_USE_PLAY) ? B_MULTI_OUTPUT_CHANNEL : B_MULTI_INPUT_CHANNEL; chans[index].designations = designations | chan_designations[i]; @@ -434,7 +441,7 @@ echo_create_channels_list(multi_dev *multi) } } - if(mode==ECHO_USE_PLAY) { + if (mode==ECHO_USE_PLAY) { multi->output_channel_count = index; } else { multi->input_channel_count = index - multi->output_channel_count; @@ -618,8 +625,8 @@ echo_get_buffers(echo_dev *card, multi_buffer_list *data) if (data->request_playback_channels < data->return_playback_channels) { LOG(("not enough channels\n")); } - for(i=0; ichannels; j++) + for (i=0; ichannels; j++) echo_stream_get_nth_buffer(stream, j, i, &data->playback_buffers[i][channels+j].base, &data->playback_buffers[i][channels+j].stride); @@ -638,8 +645,8 @@ echo_get_buffers(echo_dev *card, multi_buffer_list *data) if (data->request_record_channels < data->return_record_channels) { LOG(("not enough channels\n")); } - for(i=0; ichannels; j++) + for (i=0; ichannels; j++) echo_stream_get_nth_buffer(stream, j, i, &data->record_buffers[i][channels+j].base, &data->record_buffers[i][channels+j].stride); @@ -706,7 +713,7 @@ echo_buffer_exchange(echo_dev *card, multi_buffer_info *data) (stream->use & ECHO_USE_PLAY == 0) ? echo_record_inth : echo_play_inth, stream); } - if(acquire_sem_etc(card->buffer_ready_sem, 1, B_RELATIVE_TIMEOUT | B_CAN_INTERRUPT, 50000) + if (acquire_sem_etc(card->buffer_ready_sem, 1, B_RELATIVE_TIMEOUT | B_CAN_INTERRUPT, 50000) == B_TIMED_OUT) { LOG(("buffer_exchange timeout ff\n")); } @@ -717,7 +724,7 @@ echo_buffer_exchange(echo_dev *card, multi_buffer_info *data) if ((pstream->use & ECHO_USE_PLAY) == 0 || (pstream->state & ECHO_STATE_STARTED) == 0) continue; - if(pstream->update_needed) + if (pstream->update_needed) break; } @@ -725,13 +732,13 @@ echo_buffer_exchange(echo_dev *card, multi_buffer_info *data) if ((rstream->use & ECHO_USE_RECORD) == 0 || (rstream->state & ECHO_STATE_STARTED) == 0) continue; - if(rstream->update_needed) + if (rstream->update_needed) break; } - if(!pstream) + if (!pstream) pstream = card->pstream; - if(!rstream) + if (!rstream) rstream = card->rstream; /* do playback */ @@ -753,6 +760,7 @@ echo_buffer_exchange(echo_dev *card, multi_buffer_info *data) return B_OK; } + static status_t echo_buffer_force_stop(echo_dev *card) { @@ -760,6 +768,7 @@ echo_buffer_force_stop(echo_dev *card) return B_OK; } + static status_t echo_multi_control(void *cookie, uint32 op, void *data, size_t length) { @@ -773,7 +782,7 @@ echo_multi_control(void *cookie, uint32 op, void *data, size_t length) } #endif - switch (op) { + switch (op) { case B_MULTI_GET_DESCRIPTION: LOG(("B_MULTI_GET_DESCRIPTION\n")); return echo_get_description(card, (multi_description *)data); @@ -841,6 +850,7 @@ echo_multi_control(void *cookie, uint32 op, void *data, size_t length) return B_ERROR; } + static status_t echo_open(const char *name, uint32 flags, void** cookie); static status_t echo_close(void* cookie); static status_t echo_free(void* cookie); @@ -848,6 +858,7 @@ static status_t echo_control(void* cookie, uint32 op, void* arg, size_t len); static status_t echo_read(void* cookie, off_t position, void *buf, size_t* num_bytes); static status_t echo_write(void* cookie, off_t position, const void* buffer, size_t* num_bytes); + device_hooks multi_hooks = { echo_open, /* -> open entry point */ echo_close, /* -> close entry point */ @@ -861,6 +872,7 @@ device_hooks multi_hooks = { NULL /* scatter-gather write to the device */ }; + static status_t echo_open(const char *name, uint32 flags, void** cookie) { @@ -884,7 +896,7 @@ echo_open(const char *name, uint32 flags, void** cookie) } #endif - if(card == NULL) { + if (card == NULL) { LOG(("open() card not found %s\n", name)); #ifdef CARDBUS LIST_FOREACH(card, &devices, next) { @@ -963,6 +975,7 @@ echo_open(const char *name, uint32 flags, void** cookie) return B_OK; } + static status_t echo_close(void* cookie) { @@ -975,6 +988,7 @@ echo_close(void* cookie) return B_OK; } + static status_t echo_free(void* cookie) { @@ -999,12 +1013,14 @@ echo_free(void* cookie) return B_OK; } + static status_t echo_control(void* cookie, uint32 op, void* arg, size_t len) { return echo_multi_control(cookie, op, arg, len); } + static status_t echo_read(void* cookie, off_t position, void *buf, size_t* num_bytes) { @@ -1012,10 +1028,10 @@ echo_read(void* cookie, off_t position, void *buf, size_t* num_bytes) return B_IO_ERROR; } + static status_t echo_write(void* cookie, off_t position, const void* buffer, size_t* num_bytes) { *num_bytes = 0; /* tell caller nothing was written */ return B_IO_ERROR; } - diff --git a/src/add-ons/kernel/drivers/audio/echo/util.c b/src/add-ons/kernel/drivers/audio/echo/util.c index e96381cf5b..43624031bd 100644 --- a/src/add-ons/kernel/drivers/audio/echo/util.c +++ b/src/add-ons/kernel/drivers/audio/echo/util.c @@ -93,15 +93,10 @@ alloc_mem(void **phy, void **log, size_t size, const char *name) *phy = pe.address; LOG(("area = %d, size = %d, log = %#08X, phy = %#08X\n", area, size, logadr, pe.address)); - return areaid; + return area; } -/* This is not the most advanced method to map physical memory for io access. - * Perhaps using B_ANY_KERNEL_ADDRESS instead of B_ANY_KERNEL_BLOCK_ADDRESS - * makes the whole offset calculation and relocation obsolete. But the code - * below does work, and I can't test if using B_ANY_KERNEL_ADDRESS also works. - */ area_id map_mem(void **log, void *phy, size_t size, const char *name) { @@ -115,7 +110,7 @@ map_mem(void **log, void *phy, size_t size, const char *name) offset = (uint32)phy & (B_PAGE_SIZE - 1); phyadr = (void*)((uint32)phy - offset); size = round_to_pagesize(size + offset); - area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_BLOCK_ADDRESS, B_READ_AREA | B_WRITE_AREA, &mapadr); + area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_ADDRESS, 0, &mapadr); *log = (void*) ((uint32)mapadr + offset); LOG(("physical = %p, logical = %p, offset = %#x, phyadr = %p, mapadr = %p, size = %#x, area = %#x\n",