added driver settings, untested

package symlink is now hmulti


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17105 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2006-04-12 12:51:45 +00:00
parent 0e0b8fd554
commit 16155f88ca
6 changed files with 128 additions and 55 deletions

View File

@ -12,10 +12,14 @@ KernelAddon emuxki : kernel drivers bin :
util.c
;
SEARCH on <emuxki!driver>emuxki.settings = $(SUBDIR) ;
Package haiku-emuxki-cvs
:
emuxki
:
boot home config add-ons kernel drivers bin ;
PackageDriverSymLink haiku-emuxki-cvs : audio multi emuxki ;
PackageDriverSymLink haiku-emuxki-cvs : audio hmulti emuxki ;
Package haiku-emuxki-cvs : <emuxki!driver>emuxki.settings
: boot home config settings kernel drivers ;

View File

@ -44,18 +44,19 @@
#include <ByteOrder.h>
#include <KernelExport.h>
#include <PCI.h>
#include <string.h>
#include <stdio.h>
#include <driver_settings.h>
#include <fcntl.h>
#include <malloc.h>
#include <math.h>
#include <midi_driver.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "emuxki.h"
#include "debug.h"
#include "config.h"
#include "util.h"
#include "io.h"
#include <fcntl.h>
#include <unistd.h>
#include <malloc.h>
#include "multi.h"
#include "ac97.h"
@ -76,6 +77,14 @@ emuxki_dev cards[NUM_CARDS];
int32 num_names;
char * names[NUM_CARDS*20+1];
emuxki_settings current_settings = {
2, // channels
16, // bits per sample
48000, // sample rate
512, // buffer frames
2 // buffer count
};
status_t emuxki_init(emuxki_dev * card);
extern device_hooks multi_hooks;
@ -2164,7 +2173,7 @@ emuxki_setup(emuxki_dev * card)
EMU_HCFG_LOCKTANKCACHE_MASK | EMU_HCFG_JOYENABLE | EMU_HCFG_AUTOMUTE);
}
PRINT(("init_driver done\n"));
PRINT(("setup_emuxki done\n"));
return err;
}
@ -2727,12 +2736,43 @@ status_t
init_driver(void)
{
int ix=0;
void *settings_handle;
pci_info info;
num_cards = 0;
PRINT(("init_driver()\n"));
load_driver_symbols("emuxki");
// get driver settings
settings_handle = load_driver_settings ("emuxki.settings");
if (settings_handle != NULL) {
const char *item;
char *end;
uint32 value;
item = get_driver_parameter (settings_handle, "channels", "0", "0");
value = strtoul (item, &end, 0);
if (*end == '\0') current_settings.channels = value;
item = get_driver_parameter (settings_handle, "bitsPerSample", "0", "0");
value = strtoul (item, &end, 0);
if (*end == '\0') current_settings.bitsPerSample = value;
item = get_driver_parameter (settings_handle, "sample_rate", "0", "0");
value = strtoul (item, &end, 0);
if (*end == '\0') current_settings.sample_rate = value;
item = get_driver_parameter (settings_handle, "buffer_frames", "0", "0");
value = strtoul (item, &end, 0);
if (*end == '\0') current_settings.buffer_frames = value;
item = get_driver_parameter (settings_handle, "buffer_count", "0", "0");
value = strtoul (item, &end, 0);
if (*end == '\0') current_settings.buffer_count = value;
unload_driver_settings (settings_handle);
}
if (get_module(pci_name, (module_info **) &pci))
return ENOSYS;

View File

@ -66,6 +66,20 @@
#define FRIENDLY_NAME_AUDIGY2 FRIENDLY_NAME_AUDIGY" 2"
#define AUTHOR "Jérôme Duval"
/*
* Emuxki settings
*/
typedef struct {
uint8 channels;
uint8 bitsPerSample;
uint32 sample_rate;
uint32 buffer_frames;
int32 buffer_count;
} emuxki_settings;
extern emuxki_settings current_settings;
/*
* Emu10k1 midi
*/

View File

@ -0,0 +1,11 @@
# Settings file for the emuxki driver
#
# This file should be moved to the directory
# ~/config/settings/kernel/drivers/
#
#channels 2
#bitsPerSample 16
#sample_rate 48000
#buffer_frames 512
#buffer_count 2

View File

@ -814,16 +814,21 @@ emuxki_get_description(emuxki_dev *card, multi_description *data)
memcpy(data->channels, card->multi.chans, size * sizeof(card->multi.chans[0]));
}
data->output_rates = B_SR_48000;// | B_SR_44100 | B_SR_CVSR;
data->input_rates = B_SR_48000;// | B_SR_44100 | B_SR_CVSR;
//data->output_rates = B_SR_44100;
//data->input_rates = B_SR_44100;
switch (current_settings.sample_rate) {
case 192000: data->output_rates = data->input_rates = B_SR_192000; break;
case 96000: data->output_rates = data->input_rates = B_SR_96000; break;
case 48000: data->output_rates = data->input_rates = B_SR_48000; break;
case 44100: data->output_rates = data->input_rates = B_SR_44100; break;
}
data->min_cvsr_rate = 0;
data->max_cvsr_rate = 48000;
//data->max_cvsr_rate = 44100;
data->output_formats = B_FMT_16BIT;
data->input_formats = B_FMT_16BIT;
switch (current_settings.bitsPerSample) {
case 8: data->output_formats = data->input_formats = B_FMT_8BIT_U; break;
case 16: data->output_formats = data->input_formats = B_FMT_16BIT; break;
case 24: data->output_formats = data->input_formats = B_FMT_24BIT; break;
case 32: data->output_formats = data->input_formats = B_FMT_32BIT; break;
}
data->lock_sources = B_MULTI_LOCK_INTERNAL;
data->timecode_sources = 0;
data->interface_flags = B_MULTI_INTERFACE_PLAYBACK | B_MULTI_INTERFACE_RECORD;
@ -867,18 +872,19 @@ emuxki_get_global_format(emuxki_dev *card, multi_format_info *data)
data->output_latency = 0;
data->input_latency = 0;
data->timecode_kind = 0;
data->input.rate = B_SR_48000;
data->input.cvsr = 48000;
data->input.format = B_FMT_16BIT;
data->output.rate = B_SR_48000;
data->output.cvsr = 48000;
data->output.format = B_FMT_16BIT;
/*data->input.rate = B_SR_44100;
data->input.cvsr = 44100;
data->input.format = B_FMT_16BIT;
data->output.rate = B_SR_44100;
data->output.cvsr = 44100;
data->output.format = B_FMT_16BIT;*/
switch (current_settings.sample_rate) {
case 192000: data->output.rate = data->input.rate = B_SR_192000; break;
case 96000: data->output.rate = data->input.rate = B_SR_96000; break;
case 48000: data->output.rate = data->input.rate = B_SR_48000; break;
case 44100: data->output.rate = data->input.rate = B_SR_44100; break;
}
switch (current_settings.bitsPerSample) {
case 8: data->input.format = data->output.format = B_FMT_8BIT_U; break;
case 16: data->input.format = data->output.format = B_FMT_16BIT; break;
case 24: data->input.format = data->output.format = B_FMT_24BIT; break;
case 32: data->input.format = data->output.format = B_FMT_32BIT; break;
}
data->input.cvsr = data->output.cvsr = current_settings.sample_rate;
return B_OK;
}
@ -900,44 +906,42 @@ emuxki_get_buffers(emuxki_dev *card, multi_buffer_list *data)
rchannels = card->rstream->nmono + card->rstream->nstereo * 2;
rchannels2 = card->rstream2->nmono + card->rstream2->nstereo * 2;
if (data->request_playback_buffers < BUFFER_COUNT ||
if (data->request_playback_buffers < current_settings.buffer_count ||
data->request_playback_channels < (pchannels + pchannels2) ||
data->request_record_buffers < BUFFER_COUNT ||
data->request_record_buffers < current_settings.buffer_count ||
data->request_record_channels < (rchannels + rchannels2)) {
LOG(("not enough channels/buffers\n"));
}
ASSERT(BUFFER_COUNT == 2);
data->flags = B_MULTI_BUFFER_PLAYBACK | B_MULTI_BUFFER_RECORD;
data->return_playback_buffers = BUFFER_COUNT; /* playback_buffers[b][] */
data->return_playback_buffers = current_settings.buffer_count; /* playback_buffers[b][] */
data->return_playback_channels = pchannels + pchannels2; /* playback_buffers[][c] */
data->return_playback_buffer_size = BUFFER_FRAMES; /* frames */
data->return_playback_buffer_size = current_settings.buffer_frames; /* frames */
for(i=0; i<BUFFER_COUNT; i++)
for(i=0; i<current_settings.buffer_count; i++)
for(j=0; j<pchannels; j++)
emuxki_stream_get_nth_buffer(card->pstream, j, i,
&data->playback_buffers[i][j].base,
&data->playback_buffers[i][j].stride);
for(i=0; i<BUFFER_COUNT; i++)
for(i=0; i<current_settings.buffer_count; i++)
for(j=0; j<pchannels2; j++)
emuxki_stream_get_nth_buffer(card->pstream2, j, i,
&data->playback_buffers[i][pchannels + j].base,
&data->playback_buffers[i][pchannels + j].stride);
data->return_record_buffers = BUFFER_COUNT;
data->return_record_buffers = current_settings.buffer_count;
data->return_record_channels = rchannels + rchannels2;
data->return_record_buffer_size = BUFFER_FRAMES; /* frames */
data->return_record_buffer_size = current_settings.buffer_frames; /* frames */
for(i=0; i<BUFFER_COUNT; i++)
for(i=0; i<current_settings.buffer_count; i++)
for(j=0; j<rchannels; j++)
emuxki_stream_get_nth_buffer(card->rstream, j, i,
&data->record_buffers[i][j].base,
&data->record_buffers[i][j].stride);
for(i=0; i<BUFFER_COUNT; i++)
for(i=0; i<current_settings.buffer_count; i++)
for(j=0; j<rchannels2; j++)
emuxki_stream_get_nth_buffer(card->rstream2, j, i,
&data->record_buffers[i][rchannels + j].base,
@ -955,7 +959,7 @@ emuxki_play_inth(void* inthparams)
acquire_spinlock(&slock);
stream->real_time = system_time();
stream->frames_count += BUFFER_FRAMES;
stream->frames_count += current_settings.buffer_frames;
stream->buffer_cycle = stream->first_voice->trigblk;
stream->update_needed = true;
release_spinlock(&slock);
@ -975,7 +979,7 @@ emuxki_record_inth(void* inthparams)
acquire_spinlock(&slock);
stream->real_time = system_time();
stream->frames_count += BUFFER_FRAMES;
stream->frames_count += current_settings.buffer_frames;
stream->buffer_cycle = (stream->first_voice->trigblk
+ stream->first_voice->blkmod -1) % stream->first_voice->blkmod;
stream->update_needed = true;
@ -1195,28 +1199,32 @@ emuxki_open(const char *name, uint32 flags, void** cookie)
LOG(("voice_new\n"));
card->rstream2 = emuxki_stream_new(card, EMU_USE_RECORD, BUFFER_FRAMES, BUFFER_COUNT);
card->rstream = emuxki_stream_new(card, EMU_USE_RECORD, BUFFER_FRAMES, BUFFER_COUNT);
card->pstream2 = emuxki_stream_new(card, EMU_USE_PLAY, BUFFER_FRAMES, BUFFER_COUNT);
card->pstream = emuxki_stream_new(card, EMU_USE_PLAY, BUFFER_FRAMES, BUFFER_COUNT);
card->rstream2 = emuxki_stream_new(card, EMU_USE_RECORD, current_settings.buffer_frames, current_settings.buffer_count);
card->rstream = emuxki_stream_new(card, EMU_USE_RECORD, current_settings.buffer_frames, current_settings.buffer_count);
card->pstream2 = emuxki_stream_new(card, EMU_USE_PLAY, current_settings.buffer_frames, current_settings.buffer_count);
card->pstream = emuxki_stream_new(card, EMU_USE_PLAY, current_settings.buffer_frames, current_settings.buffer_count);
card->buffer_ready_sem = create_sem(0,"pbuffer ready");
LOG(("voice_setaudio\n"));
emuxki_stream_set_audioparms(card->pstream, true, 2, true, 48000);
emuxki_stream_set_audioparms(card->pstream2, false, 4, true, 48000);
emuxki_stream_set_audioparms(card->rstream, true, 2, true, 48000);
emuxki_stream_set_audioparms(card->rstream2, true, 2, true, 48000);
emuxki_stream_set_audioparms(card->pstream, true, current_settings.channels,
current_settings.bitsPerSample == 16, current_settings.sample_rate);
emuxki_stream_set_audioparms(card->pstream2, false, 4,
current_settings.bitsPerSample == 16, current_settings.sample_rate);
emuxki_stream_set_audioparms(card->rstream, true, current_settings.channels,
current_settings.bitsPerSample == 16, current_settings.sample_rate);
emuxki_stream_set_audioparms(card->rstream2, true, current_settings.channels,
current_settings.bitsPerSample == 16, current_settings.sample_rate);
recparams.efx_voices[0] = 3; // channels 1,2
recparams.efx_voices[1] = 0;
emuxki_stream_set_recparms(card->rstream, EMU_RECSRC_ADC, NULL);
emuxki_stream_set_recparms(card->rstream2, EMU_RECSRC_FX, &recparams);
card->pstream->first_channel = 0;
card->pstream2->first_channel = 2;
card->rstream->first_channel = 6;
card->rstream2->first_channel = 8;
card->pstream2->first_channel = current_settings.channels;
card->rstream->first_channel = current_settings.channels + 4;
card->rstream2->first_channel = 2 * current_settings.channels + 4;
emuxki_stream_commit_parms(card->pstream);
emuxki_stream_commit_parms(card->pstream2);

View File

@ -31,10 +31,6 @@
#ifndef _MULTI_H_
#define _MULTI_H_
#define BUFFER_FRAMES 512
//#define BUFFER_FRAMES 32 // this is the minimum which works
#define BUFFER_COUNT 2
typedef struct _multi_mixer_control {
struct _multi_dev *multi;
void (*get) (void *card, const void *cookie, int32 type, float *values);