* cleanup
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29529 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -34,24 +34,24 @@ es1370_ac97_get_mix(void *card, const void *cookie, int32 type, float *values) {
|
|||||||
case B_MIX_GAIN:
|
case B_MIX_GAIN:
|
||||||
value = es1370_codec_read(&dev->config, info->reg);
|
value = es1370_codec_read(&dev->config, info->reg);
|
||||||
//PRINT(("B_MIX_GAIN value : %u\n", value));
|
//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;
|
mask = ((1 << (info->bits + 1)) - 1) << 8;
|
||||||
gain = ((value & mask) >> 8) * info->granularity;
|
gain = ((value & mask) >> 8) * info->granularity;
|
||||||
if(info->polarity == 1)
|
if (info->polarity == 1)
|
||||||
values[0] = info->max_gain - gain;
|
values[0] = info->max_gain - gain;
|
||||||
else
|
else
|
||||||
values[0] = gain - info->min_gain;
|
values[0] = gain - info->min_gain;
|
||||||
|
|
||||||
mask = ((1 << (info->bits + 1)) - 1);
|
mask = ((1 << (info->bits + 1)) - 1);
|
||||||
gain = (value & mask) * info->granularity;
|
gain = (value & mask) * info->granularity;
|
||||||
if(info->polarity == 1)
|
if (info->polarity == 1)
|
||||||
values[1] = info->max_gain - gain;
|
values[1] = info->max_gain - gain;
|
||||||
else
|
else
|
||||||
values[1] = gain - info->min_gain;
|
values[1] = gain - info->min_gain;
|
||||||
} else {
|
} else {
|
||||||
mask = ((1 << (info->bits + 1)) - 1);
|
mask = ((1 << (info->bits + 1)) - 1);
|
||||||
gain = (value & mask) * info->granularity;
|
gain = (value & mask) * info->granularity;
|
||||||
if(info->polarity == 1)
|
if (info->polarity == 1)
|
||||||
values[0] = info->max_gain - gain;
|
values[0] = info->max_gain - gain;
|
||||||
else
|
else
|
||||||
values[0] = gain - info->min_gain;
|
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) {
|
switch(type) {
|
||||||
case B_MIX_GAIN:
|
case B_MIX_GAIN:
|
||||||
value = es1370_codec_read(&dev->config, info->reg);
|
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;
|
mask = ((1 << (info->bits + 1)) - 1) << 8;
|
||||||
value &= ~mask;
|
value &= ~mask;
|
||||||
|
|
||||||
if(info->polarity == 1)
|
if (info->polarity == 1)
|
||||||
gain = info->max_gain - values[0];
|
gain = info->max_gain - values[0];
|
||||||
else
|
else
|
||||||
gain = values[0] - info->min_gain;
|
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);
|
mask = ((1 << (info->bits + 1)) - 1);
|
||||||
value &= ~mask;
|
value &= ~mask;
|
||||||
if(info->polarity == 1)
|
if (info->polarity == 1)
|
||||||
gain = info->max_gain - values[1];
|
gain = info->max_gain - values[1];
|
||||||
else
|
else
|
||||||
gain = values[1] - info->min_gain;
|
gain = values[1] - info->min_gain;
|
||||||
@@ -111,7 +111,7 @@ es1370_ac97_set_mix(void *card, const void *cookie, int32 type, float *values) {
|
|||||||
} else {
|
} else {
|
||||||
mask = ((1 << (info->bits + 1)) - 1);
|
mask = ((1 << (info->bits + 1)) - 1);
|
||||||
value &= ~mask;
|
value &= ~mask;
|
||||||
if(info->polarity == 1)
|
if (info->polarity == 1)
|
||||||
gain = info->max_gain - values[0];
|
gain = info->max_gain - values[0];
|
||||||
else
|
else
|
||||||
gain = values[0] - info->min_gain;
|
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 = es1370_codec_read(&dev->config, info->reg);
|
||||||
value &= ~mask;
|
value &= ~mask;
|
||||||
value |= ((values[0] == 1.0 ? 1 : 0 ) << 15 & 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
|
// there is a independent mute for each channel
|
||||||
mask = ((1 << 1) - 1) << 7;
|
mask = ((1 << 1) - 1) << 7;
|
||||||
value &= ~mask;
|
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.flags = B_MULTI_MIX_GROUP;
|
||||||
multi->controls[i].mix_control.master = EMU_MULTI_CONTROL_MASTERID;
|
multi->controls[i].mix_control.master = EMU_MULTI_CONTROL_MASTERID;
|
||||||
multi->controls[i].mix_control.string = string;
|
multi->controls[i].mix_control.string = string;
|
||||||
if(name)
|
if (name)
|
||||||
strcpy(multi->controls[i].mix_control.name, name);
|
strcpy(multi->controls[i].mix_control.name, name);
|
||||||
|
|
||||||
return multi->controls[i].mix_control.id;
|
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;
|
int32 i, id;
|
||||||
multi_mixer_control *control = NULL;
|
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;
|
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));
|
PRINT(("es1370_get_mix : invalid control id requested : %li\n", id));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
control = &card->multi.controls[id];
|
control = &card->multi.controls[id];
|
||||||
|
|
||||||
if(control->mix_control.flags & B_MULTI_MIX_GAIN) {
|
if (control->mix_control.flags & B_MULTI_MIX_GAIN) {
|
||||||
if(control->get) {
|
if (control->get) {
|
||||||
float values[2];
|
float values[2];
|
||||||
control->get(card, control->cookie, control->type, values);
|
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];
|
mmvi->values[i].u.gain = values[0];
|
||||||
else
|
else
|
||||||
mmvi->values[i].u.gain = values[1];
|
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];
|
float values[1];
|
||||||
control->get(card, control->cookie, control->type, values);
|
control->get(card, control->cookie, control->type, values);
|
||||||
mmvi->values[i].u.enable = (values[0] == 1.0);
|
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];
|
float values[1];
|
||||||
control->get(card, control->cookie, control->type, values);
|
control->get(card, control->cookie, control->type, values);
|
||||||
mmvi->values[i].u.mux = (int32)values[0];
|
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;
|
int32 i, id;
|
||||||
multi_mixer_control *control = NULL;
|
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;
|
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));
|
PRINT(("es1370_set_mix : invalid control id requested : %li\n", id));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
control = &card->multi.controls[id];
|
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;
|
multi_mixer_control *control2 = NULL;
|
||||||
if(i+1<mmvi->item_count) {
|
if (i+1<mmvi->item_count) {
|
||||||
id = mmvi->values[i + 1].id - EMU_MULTI_CONTROL_FIRSTID;
|
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));
|
PRINT(("es1370_set_mix : invalid control id requested : %li\n", id));
|
||||||
} else {
|
} else {
|
||||||
control2 = &card->multi.controls[id];
|
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;
|
control2 = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(control->set) {
|
if (control->set) {
|
||||||
float values[2];
|
float values[2];
|
||||||
values[0] = 0.0;
|
values[0] = 0.0;
|
||||||
values[1] = 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;
|
values[0] = mmvi->values[i].u.gain;
|
||||||
else
|
else
|
||||||
values[1] = mmvi->values[i].u.gain;
|
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;
|
values[1] = mmvi->values[i+1].u.gain;
|
||||||
|
|
||||||
control->set(card, control->cookie, control->type, values);
|
control->set(card, control->cookie, control->type, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(control2)
|
if (control2)
|
||||||
i++;
|
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];
|
float values[1];
|
||||||
|
|
||||||
values[0] = mmvi->values[i].u.enable ? 1.0 : 0.0;
|
values[0] = mmvi->values[i].u.enable ? 1.0 : 0.0;
|
||||||
control->set(card, control->cookie, control->type, values);
|
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];
|
float values[1];
|
||||||
|
|
||||||
values[0] = (float)mmvi->values[i].u.mux;
|
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;
|
int32 i;
|
||||||
|
|
||||||
mmc = mmci->controls;
|
mmc = mmci->controls;
|
||||||
if(mmci->control_count < 24)
|
if (mmci->control_count < 24)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
if(es1370_create_controls_list(&card->multi) < B_OK)
|
if (es1370_create_controls_list(&card->multi) < B_OK)
|
||||||
return B_ERROR;
|
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;
|
mmc[i] = card->multi.controls[i].mix_control;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -362,18 +362,18 @@ es1370_create_channels_list(multi_dev *multi)
|
|||||||
chans = multi->chans;
|
chans = multi->chans;
|
||||||
index = 0;
|
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) {
|
mode = (mode == ES1370_USE_PLAY) ? ES1370_USE_RECORD : -1) {
|
||||||
LIST_FOREACH(stream, &((es1370_dev*)multi->card)->streams, next) {
|
LIST_FOREACH(stream, &((es1370_dev*)multi->card)->streams, next) {
|
||||||
if ((stream->use & mode) == 0)
|
if ((stream->use & mode) == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(stream->channels == 2)
|
if (stream->channels == 2)
|
||||||
designations = B_CHANNEL_STEREO_BUS;
|
designations = B_CHANNEL_STEREO_BUS;
|
||||||
else
|
else
|
||||||
designations = B_CHANNEL_SURROUND_BUS;
|
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].channel_id = index;
|
||||||
chans[index].kind = (mode == ES1370_USE_PLAY) ? B_MULTI_OUTPUT_CHANNEL : B_MULTI_INPUT_CHANNEL;
|
chans[index].kind = (mode == ES1370_USE_PLAY) ? B_MULTI_OUTPUT_CHANNEL : B_MULTI_INPUT_CHANNEL;
|
||||||
chans[index].designations = designations | chan_designations[i];
|
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;
|
multi->output_channel_count = index;
|
||||||
} else {
|
} else {
|
||||||
multi->input_channel_count = index - multi->output_channel_count;
|
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 */
|
data->return_playback_buffer_size = current_settings.buffer_frames; /* frames */
|
||||||
|
|
||||||
bufcount = current_settings.buffer_count;
|
bufcount = current_settings.buffer_count;
|
||||||
if(bufcount > data->request_playback_buffers)
|
if (bufcount > data->request_playback_buffers)
|
||||||
bufcount = data->request_playback_buffers;
|
bufcount = data->request_playback_buffers;
|
||||||
|
|
||||||
for(i = 0; i < bufcount; i++)
|
for (i = 0; i < bufcount; i++)
|
||||||
for(j=0; j<pchannels; j++)
|
for (j=0; j<pchannels; j++)
|
||||||
es1370_stream_get_nth_buffer(card->pstream, j, i,
|
es1370_stream_get_nth_buffer(card->pstream, j, i,
|
||||||
&data->playback_buffers[i][j].base,
|
&data->playback_buffers[i][j].base,
|
||||||
&data->playback_buffers[i][j].stride);
|
&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 */
|
data->return_record_buffer_size = current_settings.buffer_frames; /* frames */
|
||||||
|
|
||||||
bufcount = current_settings.buffer_count;
|
bufcount = current_settings.buffer_count;
|
||||||
if(bufcount > data->request_record_buffers)
|
if (bufcount > data->request_record_buffers)
|
||||||
bufcount = data->request_record_buffers;
|
bufcount = data->request_record_buffers;
|
||||||
|
|
||||||
for(i = 0; i < bufcount; i++)
|
for (i = 0; i < bufcount; i++)
|
||||||
for(j=0; j<rchannels; j++)
|
for (j=0; j<rchannels; j++)
|
||||||
es1370_stream_get_nth_buffer(card->rstream, j, i,
|
es1370_stream_get_nth_buffer(card->rstream, j, i,
|
||||||
&data->record_buffers[i][j].base,
|
&data->record_buffers[i][j].base,
|
||||||
&data->record_buffers[i][j].stride);
|
&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 ||
|
if ((pstream->use & ES1370_USE_PLAY) == 0 ||
|
||||||
(pstream->state & ES1370_STATE_STARTED) == 0)
|
(pstream->state & ES1370_STATE_STARTED) == 0)
|
||||||
continue;
|
continue;
|
||||||
if(pstream->update_needed)
|
if (pstream->update_needed)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -645,13 +645,13 @@ es1370_buffer_exchange(es1370_dev *card, multi_buffer_info *data)
|
|||||||
if ((rstream->use & ES1370_USE_RECORD) == 0 ||
|
if ((rstream->use & ES1370_USE_RECORD) == 0 ||
|
||||||
(rstream->state & ES1370_STATE_STARTED) == 0)
|
(rstream->state & ES1370_STATE_STARTED) == 0)
|
||||||
continue;
|
continue;
|
||||||
if(rstream->update_needed)
|
if (rstream->update_needed)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!pstream)
|
if (!pstream)
|
||||||
pstream = card->pstream;
|
pstream = card->pstream;
|
||||||
if(!rstream)
|
if (!rstream)
|
||||||
rstream = card->rstream;
|
rstream = card->rstream;
|
||||||
|
|
||||||
/* do playback */
|
/* 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));
|
LOG(("open() card not found %s\n", name));
|
||||||
for (ix=0; ix<num_cards; ix++) {
|
for (ix=0; ix<num_cards; ix++) {
|
||||||
LOG(("open() card available %s\n", cards[ix].name));
|
LOG(("open() card available %s\n", cards[ix].name));
|
||||||
|
|||||||
Reference in New Issue
Block a user