diff --git a/src/add-ons/kernel/drivers/audio/ac97/es1370/multi.c b/src/add-ons/kernel/drivers/audio/ac97/es1370/multi.c index 1a5277ddc6..0586bfe1ed 100644 --- a/src/add-ons/kernel/drivers/audio/ac97/es1370/multi.c +++ b/src/add-ons/kernel/drivers/audio/ac97/es1370/multi.c @@ -34,24 +34,24 @@ es1370_ac97_get_mix(void *card, const void *cookie, int32 type, float *values) { case B_MIX_GAIN: value = es1370_codec_read(&dev->config, info->reg); //PRINT(("B_MIX_GAIN value : %u\n", value)); - if(info->type & B_MIX_STEREO) { + if (info->type & B_MIX_STEREO) { mask = ((1 << (info->bits + 1)) - 1) << 8; gain = ((value & mask) >> 8) * info->granularity; - if(info->polarity == 1) + if (info->polarity == 1) values[0] = info->max_gain - gain; else values[0] = gain - info->min_gain; mask = ((1 << (info->bits + 1)) - 1); gain = (value & mask) * info->granularity; - if(info->polarity == 1) + if (info->polarity == 1) values[1] = info->max_gain - gain; else values[1] = gain - info->min_gain; } else { mask = ((1 << (info->bits + 1)) - 1); gain = (value & mask) * info->granularity; - if(info->polarity == 1) + if (info->polarity == 1) values[0] = info->max_gain - gain; else values[0] = gain - info->min_gain; @@ -91,11 +91,11 @@ es1370_ac97_set_mix(void *card, const void *cookie, int32 type, float *values) { switch(type) { case B_MIX_GAIN: value = es1370_codec_read(&dev->config, info->reg); - if(info->type & B_MIX_STEREO) { + if (info->type & B_MIX_STEREO) { mask = ((1 << (info->bits + 1)) - 1) << 8; value &= ~mask; - if(info->polarity == 1) + if (info->polarity == 1) gain = info->max_gain - values[0]; else gain = values[0] - info->min_gain; @@ -103,7 +103,7 @@ es1370_ac97_set_mix(void *card, const void *cookie, int32 type, float *values) { mask = ((1 << (info->bits + 1)) - 1); value &= ~mask; - if(info->polarity == 1) + if (info->polarity == 1) gain = info->max_gain - values[1]; else gain = values[1] - info->min_gain; @@ -111,7 +111,7 @@ es1370_ac97_set_mix(void *card, const void *cookie, int32 type, float *values) { } else { mask = ((1 << (info->bits + 1)) - 1); value &= ~mask; - if(info->polarity == 1) + if (info->polarity == 1) gain = info->max_gain - values[0]; else gain = values[0] - info->min_gain; @@ -125,7 +125,7 @@ es1370_ac97_set_mix(void *card, const void *cookie, int32 type, float *values) { value = es1370_codec_read(&dev->config, info->reg); value &= ~mask; value |= ((values[0] == 1.0 ? 1 : 0 ) << 15 & mask); - if(info->reg == AC97_SURR_VOLUME) { + if (info->reg == AC97_SURR_VOLUME) { // there is a independent mute for each channel mask = ((1 << 1) - 1) << 7; value &= ~mask; @@ -163,7 +163,7 @@ es1370_create_group_control(multi_dev *multi, int32 *index, int32 parent, multi->controls[i].mix_control.flags = B_MULTI_MIX_GROUP; multi->controls[i].mix_control.master = EMU_MULTI_CONTROL_MASTERID; multi->controls[i].mix_control.string = string; - if(name) + if (name) strcpy(multi->controls[i].mix_control.name, name); return multi->controls[i].mix_control.id; @@ -182,32 +182,32 @@ es1370_get_mix(es1370_dev *card, multi_mix_value_info * mmvi) { int32 i, id; multi_mixer_control *control = NULL; - for(i = 0; i < mmvi->item_count; i++) { + for (i = 0; i < mmvi->item_count; i++) { id = mmvi->values[i].id - EMU_MULTI_CONTROL_FIRSTID; - if(id < 0 || id >= card->multi.control_count) { + if (id < 0 || id >= card->multi.control_count) { PRINT(("es1370_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->cookie, control->type, values); - if(control->mix_control.master == EMU_MULTI_CONTROL_MASTERID) + if (control->mix_control.master == EMU_MULTI_CONTROL_MASTERID) mmvi->values[i].u.gain = values[0]; else mmvi->values[i].u.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->cookie, control->type, values); mmvi->values[i].u.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->cookie, control->type, values); mmvi->values[i].u.mux = (int32)values[0]; @@ -221,55 +221,55 @@ es1370_set_mix(es1370_dev *card, multi_mix_value_info * mmvi) { int32 i, id; multi_mixer_control *control = NULL; - for(i = 0; i < mmvi->item_count; i++) { + for (i = 0; i < mmvi->item_count; i++) { id = mmvi->values[i].id - EMU_MULTI_CONTROL_FIRSTID; - if(id < 0 || id >= card->multi.control_count) { + if (id < 0 || id >= card->multi.control_count) { PRINT(("es1370_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 - EMU_MULTI_CONTROL_FIRSTID; - if(id < 0 || id >= card->multi.control_count) { + if (id < 0 || id >= card->multi.control_count) { PRINT(("es1370_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 == EMU_MULTI_CONTROL_MASTERID) + if (control->mix_control.master == EMU_MULTI_CONTROL_MASTERID) values[0] = mmvi->values[i].u.gain; else values[1] = mmvi->values[i].u.gain; - if(control2 && control2->mix_control.master != EMU_MULTI_CONTROL_MASTERID) + if (control2 && control2->mix_control.master != EMU_MULTI_CONTROL_MASTERID) values[1] = mmvi->values[i+1].u.gain; control->set(card, control->cookie, control->type, values); } - if(control2) + 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].u.enable ? 1.0 : 0.0; control->set(card, control->cookie, 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].u.mux; @@ -286,12 +286,12 @@ es1370_list_mix_controls(es1370_dev *card, multi_mix_control_info * mmci) int32 i; mmc = mmci->controls; - if(mmci->control_count < 24) + if (mmci->control_count < 24) return B_ERROR; - if(es1370_create_controls_list(&card->multi) < B_OK) + if (es1370_create_controls_list(&card->multi) < B_OK) return B_ERROR; - for(i = 0; i < card->multi.control_count; i++) { + for (i = 0; i < card->multi.control_count; i++) { mmc[i] = card->multi.controls[i].mix_control; } @@ -362,18 +362,18 @@ es1370_create_channels_list(multi_dev *multi) chans = multi->chans; index = 0; - for(mode=ES1370_USE_PLAY; mode!=-1; + for (mode=ES1370_USE_PLAY; mode!=-1; mode = (mode == ES1370_USE_PLAY) ? ES1370_USE_RECORD : -1) { LIST_FOREACH(stream, &((es1370_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; i < stream->channels; i++) { + for (i = 0; i < stream->channels; i++) { chans[index].channel_id = index; chans[index].kind = (mode == ES1370_USE_PLAY) ? B_MULTI_OUTPUT_CHANNEL : B_MULTI_INPUT_CHANNEL; chans[index].designations = designations | chan_designations[i]; @@ -382,7 +382,7 @@ es1370_create_channels_list(multi_dev *multi) } } - if(mode==ES1370_USE_PLAY) { + if (mode==ES1370_USE_PLAY) { multi->output_channel_count = index; } else { multi->input_channel_count = index - multi->output_channel_count; @@ -547,11 +547,11 @@ es1370_get_buffers(es1370_dev *card, multi_buffer_list *data) data->return_playback_buffer_size = current_settings.buffer_frames; /* frames */ bufcount = current_settings.buffer_count; - if(bufcount > data->request_playback_buffers) + if (bufcount > data->request_playback_buffers) bufcount = data->request_playback_buffers; - for(i = 0; i < bufcount; i++) - for(j=0; jpstream, j, i, &data->playback_buffers[i][j].base, &data->playback_buffers[i][j].stride); @@ -561,11 +561,11 @@ es1370_get_buffers(es1370_dev *card, multi_buffer_list *data) data->return_record_buffer_size = current_settings.buffer_frames; /* frames */ bufcount = current_settings.buffer_count; - if(bufcount > data->request_record_buffers) + if (bufcount > data->request_record_buffers) bufcount = data->request_record_buffers; - for(i = 0; i < bufcount; i++) - for(j=0; jrstream, j, i, &data->record_buffers[i][j].base, &data->record_buffers[i][j].stride); @@ -637,7 +637,7 @@ es1370_buffer_exchange(es1370_dev *card, multi_buffer_info *data) if ((pstream->use & ES1370_USE_PLAY) == 0 || (pstream->state & ES1370_STATE_STARTED) == 0) continue; - if(pstream->update_needed) + if (pstream->update_needed) break; } @@ -645,13 +645,13 @@ es1370_buffer_exchange(es1370_dev *card, multi_buffer_info *data) if ((rstream->use & ES1370_USE_RECORD) == 0 || (rstream->state & ES1370_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 */ @@ -788,7 +788,7 @@ es1370_open(const char *name, uint32 flags, void** cookie) } } - if(card == NULL) { + if (card == NULL) { LOG(("open() card not found %s\n", name)); for (ix=0; ix