* style cleanup
* avoid using read/write and block flags for mapping register memory git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26867 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -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
|
area_id
|
||||||
map_mem(void **log, void *phy, size_t size, const char *name)
|
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);
|
offset = (uint32)phy & (B_PAGE_SIZE - 1);
|
||||||
phyadr = phy - offset;
|
phyadr = phy - offset;
|
||||||
size = round_to_pagesize(size + 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 = mapadr + offset;
|
||||||
|
|
||||||
LOG(("physical = %p, logical = %p, offset = %#x, phyadr = %p, mapadr = %p, size = %#x, area = %#x\n",
|
LOG(("physical = %p, logical = %p, offset = %#x, phyadr = %p, mapadr = %p, size = %#x, area = %#x\n",
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ echo_mem_new(echo_dev *card, size_t size)
|
|||||||
void
|
void
|
||||||
echo_mem_delete(echo_mem *mem)
|
echo_mem_delete(echo_mem *mem)
|
||||||
{
|
{
|
||||||
if(mem->area > B_OK)
|
if (mem->area > B_OK)
|
||||||
delete_area(mem->area);
|
delete_area(mem->area);
|
||||||
free(mem);
|
free(mem);
|
||||||
}
|
}
|
||||||
@@ -159,11 +159,11 @@ echo_mem_free(echo_dev *card, void *ptr)
|
|||||||
|
|
||||||
/* Echo stream functions */
|
/* Echo stream functions */
|
||||||
|
|
||||||
extern char * pStatusStrs[ECHOSTATUS_LAST];
|
extern char *pStatusStrs[ECHOSTATUS_LAST];
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
echo_stream_set_audioparms(echo_stream *stream, uint8 channels,
|
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;
|
int32 i;
|
||||||
uint8 sample_size, frame_size;
|
uint8 sample_size, frame_size;
|
||||||
@@ -177,7 +177,7 @@ echo_stream_set_audioparms(echo_stream *stream, uint8 channels,
|
|||||||
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]));
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -191,7 +191,7 @@ echo_stream_set_audioparms(echo_stream *stream, uint8 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"));
|
||||||
PRINT((" status: %s \n", pStatusStrs[status]));
|
PRINT((" status: %s \n", pStatusStrs[status]));
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -199,7 +199,7 @@ echo_stream_set_audioparms(echo_stream *stream, uint8 channels,
|
|||||||
|
|
||||||
//PRINT(("VerifyAudioOpen\n"));
|
//PRINT(("VerifyAudioOpen\n"));
|
||||||
status = stream->card->pEG->VerifyAudioOpen(stream->pipe);
|
status = stream->card->pEG->VerifyAudioOpen(stream->pipe);
|
||||||
if(status!=ECHOSTATUS_OK) {
|
if (status != ECHOSTATUS_OK) {
|
||||||
PRINT(("echo_stream_set_audioparms : VerifyAudioOpen failed\n"));
|
PRINT(("echo_stream_set_audioparms : VerifyAudioOpen failed\n"));
|
||||||
PRINT((" status: %s \n", pStatusStrs[status]));
|
PRINT((" status: %s \n", pStatusStrs[status]));
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -216,14 +216,14 @@ echo_stream_set_audioparms(echo_stream *stream, uint8 channels,
|
|||||||
format_params.wDataInterleave = channels == 1 ? 1 : 2;
|
format_params.wDataInterleave = channels == 1 ? 1 : 2;
|
||||||
|
|
||||||
status = stream->card->pEG->QueryAudioFormat(stream->pipe, &format_params);
|
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(("echo_stream_set_audioparms : bad format when querying\n"));
|
||||||
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;
|
||||||
@@ -231,7 +231,7 @@ echo_stream_set_audioparms(echo_stream *stream, uint8 channels,
|
|||||||
|
|
||||||
/* 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) {
|
||||||
PRINT(("echo_stream_set_audioparms : bad sample rate when querying\n"));
|
PRINT(("echo_stream_set_audioparms : bad sample rate when querying\n"));
|
||||||
PRINT((" status: %s \n", pStatusStrs[status]));
|
PRINT((" status: %s \n", pStatusStrs[status]));
|
||||||
return B_ERROR;
|
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 */
|
/* 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) {
|
||||||
PRINT(("echo_stream_set_audioparms : bad sample rate when setting\n"));
|
PRINT(("echo_stream_set_audioparms : bad sample rate when setting\n"));
|
||||||
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;
|
||||||
@@ -262,21 +262,21 @@ echo_stream_set_audioparms(echo_stream *stream, uint8 channels,
|
|||||||
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;
|
||||||
}
|
}
|
||||||
@@ -287,7 +287,7 @@ echo_stream_set_audioparms(echo_stream *stream, uint8 channels,
|
|||||||
|
|
||||||
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"));
|
||||||
@@ -386,7 +386,7 @@ void
|
|||||||
echo_stream_delete(echo_stream *stream)
|
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);
|
||||||
@@ -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);
|
echo_mem_free(stream->card, stream->buffer->log_base);
|
||||||
|
|
||||||
status = lock();
|
status = lock();
|
||||||
@@ -415,16 +415,15 @@ echo_stream_delete(echo_stream *stream)
|
|||||||
|
|
||||||
int32 echo_int(void *arg)
|
int32 echo_int(void *arg)
|
||||||
{
|
{
|
||||||
echo_dev *card = (echo_dev*)arg;
|
echo_dev* card = (echo_dev*)arg;
|
||||||
BOOL midiReceived;
|
BOOL midiReceived;
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -442,7 +441,7 @@ int32 echo_int(void *arg)
|
|||||||
//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));
|
||||||
if (curblk == stream->trigblk) {
|
if (curblk == stream->trigblk) {
|
||||||
if(stream->inth)
|
if (stream->inth)
|
||||||
stream->inth(stream->inthparam);
|
stream->inth(stream->inthparam);
|
||||||
|
|
||||||
stream->trigblk++;
|
stream->trigblk++;
|
||||||
@@ -520,7 +519,7 @@ init_hardware(void)
|
|||||||
|
|
||||||
put_module(B_PCI_MODULE_NAME);
|
put_module(B_PCI_MODULE_NAME);
|
||||||
|
|
||||||
if(err!=B_OK) {
|
if (err != B_OK) {
|
||||||
PRINT(("no card found\n"));
|
PRINT(("no card found\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -536,11 +535,11 @@ init_driver(void)
|
|||||||
|
|
||||||
void *settings_handle;
|
void *settings_handle;
|
||||||
// get driver settings
|
// get driver settings
|
||||||
settings_handle = load_driver_settings ("echo.settings");
|
settings_handle = load_driver_settings ("echo.settings");
|
||||||
if (settings_handle != NULL) {
|
if (settings_handle != NULL) {
|
||||||
const char *item;
|
const char* item;
|
||||||
char *end;
|
char* end;
|
||||||
uint32 value;
|
uint32 value;
|
||||||
|
|
||||||
item = get_driver_parameter (settings_handle, "channels", NULL, NULL);
|
item = get_driver_parameter (settings_handle, "channels", NULL, NULL);
|
||||||
if (item) {
|
if (item) {
|
||||||
@@ -774,7 +773,7 @@ echo_setup(echo_dev * card)
|
|||||||
|
|
||||||
|
|
||||||
card->pOSS = new COsSupport(card->info.device_id, card->info.revision);
|
card->pOSS = new COsSupport(card->info.device_id, card->info.revision);
|
||||||
if(card->pOSS == NULL)
|
if (card->pOSS == NULL)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
switch (card->type) {
|
switch (card->type) {
|
||||||
@@ -863,7 +862,7 @@ echo_setup(echo_dev * card)
|
|||||||
|
|
||||||
ECHOSTATUS status;
|
ECHOSTATUS status;
|
||||||
status = card->pEG->InitHw();
|
status = card->pEG->InitHw();
|
||||||
if(status != ECHOSTATUS_OK)
|
if (status != ECHOSTATUS_OK)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
card->pEG->GetCapabilities(&card->caps);
|
card->pEG->GetCapabilities(&card->caps);
|
||||||
@@ -911,7 +910,7 @@ echo_shutdown(echo_dev *card)
|
|||||||
remove_io_interrupt_handler(card->irq, echo_int, card);
|
remove_io_interrupt_handler(card->irq, echo_int, 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;
|
||||||
|
|||||||
@@ -35,23 +35,20 @@ static status_t midi_write(void *cookie, off_t pos, const void *data, size_t *le
|
|||||||
|
|
||||||
|
|
||||||
device_hooks midi_hooks = {
|
device_hooks midi_hooks = {
|
||||||
&midi_open,
|
&midi_open,
|
||||||
&midi_close,
|
&midi_close,
|
||||||
&midi_free,
|
&midi_free,
|
||||||
&midi_control,
|
&midi_control,
|
||||||
&midi_read,
|
&midi_read,
|
||||||
&midi_write,
|
&midi_write,
|
||||||
NULL, /* select */
|
NULL, /* select */
|
||||||
NULL, /* deselect */
|
NULL, /* deselect */
|
||||||
NULL, /* readv */
|
NULL, /* readv */
|
||||||
NULL /* writev */
|
NULL /* writev */
|
||||||
};
|
};
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
midi_open(
|
midi_open(const char* name, uint32 flags, void** cookie)
|
||||||
const char * name,
|
|
||||||
uint32 flags,
|
|
||||||
void ** cookie)
|
|
||||||
{
|
{
|
||||||
int ix;
|
int ix;
|
||||||
|
|
||||||
@@ -77,8 +74,7 @@ midi_open(
|
|||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
midi_close(
|
midi_close(void* cookie)
|
||||||
void * cookie)
|
|
||||||
{
|
{
|
||||||
LOG(("midi_close()\n"));
|
LOG(("midi_close()\n"));
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -86,8 +82,7 @@ midi_close(
|
|||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
midi_free(
|
midi_free(void* cookie)
|
||||||
void * cookie)
|
|
||||||
{
|
{
|
||||||
echo_dev *card = (echo_dev *) cookie;
|
echo_dev *card = (echo_dev *) cookie;
|
||||||
|
|
||||||
@@ -102,11 +97,7 @@ midi_free(
|
|||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
midi_control(
|
midi_control(void* cookie, uint32 iop, void* data, size_t len)
|
||||||
void * cookie,
|
|
||||||
uint32 iop,
|
|
||||||
void * data,
|
|
||||||
size_t len)
|
|
||||||
{
|
{
|
||||||
LOG(("midi_control()\n"));
|
LOG(("midi_control()\n"));
|
||||||
|
|
||||||
@@ -115,11 +106,7 @@ midi_control(
|
|||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
midi_read(
|
midi_read(void* cookie, off_t pos, void* ptr, size_t* nread)
|
||||||
void * cookie,
|
|
||||||
off_t pos,
|
|
||||||
void * ptr,
|
|
||||||
size_t * nread)
|
|
||||||
{
|
{
|
||||||
echo_dev *card = (echo_dev *) cookie;
|
echo_dev *card = (echo_dev *) cookie;
|
||||||
ECHOSTATUS err;
|
ECHOSTATUS err;
|
||||||
@@ -144,18 +131,13 @@ midi_read(
|
|||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
midi_write(
|
midi_write(void* cookie, off_t pos, const void* ptr, size_t* nwritten)
|
||||||
void * cookie,
|
|
||||||
off_t pos,
|
|
||||||
const void * ptr,
|
|
||||||
size_t * nwritten)
|
|
||||||
{
|
{
|
||||||
echo_dev *card = (echo_dev *) cookie;
|
echo_dev *card = (echo_dev *) cookie;
|
||||||
ECHOSTATUS err;
|
ECHOSTATUS err;
|
||||||
|
|
||||||
LOG(("midi_write()\n"));
|
LOG(("midi_write()\n"));
|
||||||
|
|
||||||
err = card->pEG->WriteMidi(*nwritten, (PBYTE)ptr, nwritten);
|
err = card->pEG->WriteMidi(*nwritten, (PBYTE)ptr, nwritten);
|
||||||
return (err != ECHOSTATUS_OK) ? B_ERROR : B_OK;
|
return (err != ECHOSTATUS_OK) ? B_ERROR : B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,14 +41,14 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
B_MIX_GAIN = 1 << 0,
|
B_MIX_GAIN = 1 << 0,
|
||||||
B_MIX_MUTE = 1 << 1,
|
B_MIX_MUTE = 1 << 1,
|
||||||
B_MIX_NOMINAL = 1 << 2
|
B_MIX_NOMINAL = 1 << 2
|
||||||
} mixer_type;
|
} mixer_type;
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
echo_channel_get_mix(void *card, MIXER_AUDIO_CHANNEL channel, int32 type, float *values) {
|
echo_channel_get_mix(void *card, MIXER_AUDIO_CHANNEL channel, int32 type, float *values) {
|
||||||
|
|
||||||
echo_dev *dev = (echo_dev*) card;
|
echo_dev *dev = (echo_dev*) card;
|
||||||
MIXER_MULTI_FUNCTION multi_function[2];
|
MIXER_MULTI_FUNCTION multi_function[2];
|
||||||
PMIXER_FUNCTION function = multi_function[0].MixerFunction;
|
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 = channel;
|
||||||
function[1].Channel.wChannel++;
|
function[1].Channel.wChannel++;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case B_MIX_GAIN:
|
case B_MIX_GAIN:
|
||||||
function[0].iFunction = function[1].iFunction = MXF_GET_LEVEL;
|
function[0].iFunction = function[1].iFunction = MXF_GET_LEVEL;
|
||||||
break;
|
break;
|
||||||
case B_MIX_MUTE:
|
case B_MIX_MUTE:
|
||||||
function[0].iFunction = function[1].iFunction = MXF_GET_MUTE;
|
function[0].iFunction = function[1].iFunction = MXF_GET_MUTE;
|
||||||
break;
|
break;
|
||||||
case B_MIX_NOMINAL:
|
case B_MIX_NOMINAL:
|
||||||
function[0].iFunction = function[1].iFunction = MXF_GET_NOMINAL;
|
function[0].iFunction = function[1].iFunction = MXF_GET_NOMINAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
multi_function[0].iCount = 2;
|
multi_function[0].iCount = 2;
|
||||||
@@ -80,23 +80,25 @@ echo_channel_get_mix(void *card, MIXER_AUDIO_CHANNEL channel, int32 type, float
|
|||||||
} else {
|
} else {
|
||||||
values[0] = function[0].Data.iNominal == 4 ? 1.0 : 0.0;
|
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
|
static void
|
||||||
echo_channel_set_mix(void *card, MIXER_AUDIO_CHANNEL channel, int32 type, float *values) {
|
echo_channel_set_mix(void *card, MIXER_AUDIO_CHANNEL channel, int32 type, float *values) {
|
||||||
echo_dev *dev = (echo_dev*) card;
|
echo_dev *dev = (echo_dev*) card;
|
||||||
MIXER_MULTI_FUNCTION multi_function[2];
|
MIXER_MULTI_FUNCTION multi_function[2];
|
||||||
PMIXER_FUNCTION function = multi_function[0].MixerFunction;
|
PMIXER_FUNCTION function = multi_function[0].MixerFunction;
|
||||||
INT32 size = ComputeMixerMultiFunctionSize(2);
|
INT32 size = ComputeMixerMultiFunctionSize(2);
|
||||||
function[0].Channel = channel;
|
function[0].Channel = channel;
|
||||||
function[1].Channel = channel;
|
function[1].Channel = channel;
|
||||||
function[1].Channel.wChannel++;
|
function[1].Channel.wChannel++;
|
||||||
if (type == B_MIX_GAIN) {
|
if (type == B_MIX_GAIN) {
|
||||||
function[0].Data.iLevel = (int)(values[0] * 256);
|
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].Data.iLevel = (int)(values[1] * 256);
|
||||||
function[1].iFunction = MXF_SET_LEVEL;
|
function[1].iFunction = MXF_SET_LEVEL;
|
||||||
} else if (type == B_MIX_MUTE) {
|
} 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;
|
function[1].iFunction = MXF_SET_MUTE;
|
||||||
} else {
|
} else {
|
||||||
function[0].Data.iNominal = values[0] == 1.0 ? 4 : -10;
|
function[0].Data.iNominal = values[0] == 1.0 ? 4 : -10;
|
||||||
function[0].iFunction = MXF_SET_NOMINAL;
|
function[0].iFunction = MXF_SET_NOMINAL;
|
||||||
function[1].Data.iNominal = values[0] == 1.0 ? 4 : -10;
|
function[1].Data.iNominal = values[0] == 1.0 ? 4 : -10;
|
||||||
function[1].iFunction = MXF_SET_NOMINAL;
|
function[1].iFunction = MXF_SET_NOMINAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
multi_function[0].iCount = 2;
|
multi_function[0].iCount = 2;
|
||||||
dev->pEG->ProcessMixerMultiFunction(multi_function, size);
|
dev->pEG->ProcessMixerMultiFunction(multi_function, size);
|
||||||
|
|
||||||
if (function[0].RtnStatus == ECHOSTATUS_OK) {
|
if (function[0].RtnStatus == ECHOSTATUS_OK) {
|
||||||
PRINT(("echo_channel_set_mix OK: %ld, %d, %ld\n", function[0].Data.iLevel, channel.wChannel, channel.dwType));
|
PRINT(("echo_channel_set_mix OK: %ld, %d, %ld\n", function[0].Data.iLevel,
|
||||||
}
|
channel.wChannel, channel.dwType));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int32
|
static int32
|
||||||
echo_create_group_control(multi_dev *multi, uint32 *index, int32 parent,
|
echo_create_group_control(multi_dev *multi, uint32 *index, int32 parent,
|
||||||
enum strind_id string, const char* name) {
|
enum strind_id string, const char* name) {
|
||||||
uint32 i = *index;
|
uint32 i = *index;
|
||||||
(*index)++;
|
(*index)++;
|
||||||
multi->controls[i].mix_control.id = MULTI_CONTROL_FIRSTID + i;
|
multi->controls[i].mix_control.id = MULTI_CONTROL_FIRSTID + i;
|
||||||
multi->controls[i].mix_control.parent = parent;
|
multi->controls[i].mix_control.parent = 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 = MULTI_CONTROL_MASTERID;
|
multi->controls[i].mix_control.master = 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -216,7 +219,7 @@ echo_create_controls_list(multi_dev *multi)
|
|||||||
channel.wChannel = i * 2;
|
channel.wChannel = i * 2;
|
||||||
|
|
||||||
parent2 = echo_create_group_control(multi, &index, parent, S_null, "Input");
|
parent2 = echo_create_group_control(multi, &index, parent, S_null, "Input");
|
||||||
|
|
||||||
echo_create_channel_control(multi, &index, parent2, 0, channel,
|
echo_create_channel_control(multi, &index, parent2, 0, channel,
|
||||||
card->caps.dwBusInCaps[i*2] & ECHOCAPS_NOMINAL_LEVEL);
|
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;
|
int32 i;
|
||||||
uint32 id;
|
uint32 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 - MULTI_CONTROL_FIRSTID;
|
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));
|
PRINT(("echo_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->channel, control->type, values);
|
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];
|
MMVI->values[i].gain = values[0];
|
||||||
else
|
else
|
||||||
MMVI->values[i].gain = values[1];
|
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];
|
float values[1];
|
||||||
control->get(card, control->channel, control->type, values);
|
control->get(card, control->channel, control->type, values);
|
||||||
MMVI->values[i].enable = (values[0] == 1.0);
|
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];
|
float values[1];
|
||||||
control->get(card, control->channel, control->type, values);
|
control->get(card, control->channel, control->type, values);
|
||||||
MMVI->values[i].mux = (int32)values[0];
|
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;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
echo_set_mix(echo_dev *card, multi_mix_value_info * MMVI)
|
echo_set_mix(echo_dev *card, multi_mix_value_info * MMVI)
|
||||||
{
|
{
|
||||||
int32 i;
|
int32 i;
|
||||||
uint32 id;
|
uint32 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 - MULTI_CONTROL_FIRSTID;
|
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));
|
PRINT(("echo_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 - MULTI_CONTROL_FIRSTID;
|
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));
|
PRINT(("echo_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 == MULTI_CONTROL_MASTERID)
|
if (control->mix_control.master == MULTI_CONTROL_MASTERID)
|
||||||
values[0] = MMVI->values[i].gain;
|
values[0] = MMVI->values[i].gain;
|
||||||
else
|
else
|
||||||
values[1] = MMVI->values[i].gain;
|
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;
|
values[1] = MMVI->values[i+1].gain;
|
||||||
|
|
||||||
control->set(card, control->channel, control->type, values);
|
control->set(card, control->channel, 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].enable ? 1.0 : 0.0;
|
values[0] = MMVI->values[i].enable ? 1.0 : 0.0;
|
||||||
control->set(card, control->channel, control->type, values);
|
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];
|
float values[1];
|
||||||
|
|
||||||
values[0] = (float)MMVI->values[i].mux;
|
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;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
echo_list_mix_controls(echo_dev *card, multi_mix_control_info * MMCI)
|
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;
|
uint32 i;
|
||||||
|
|
||||||
MMC = MMCI->controls;
|
MMC = MMCI->controls;
|
||||||
if(MMCI->control_count < 24)
|
if (MMCI->control_count < 24)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
if(echo_create_controls_list(&card->multi) < B_OK)
|
if (echo_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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,12 +355,14 @@ echo_list_mix_controls(echo_dev *card, multi_mix_control_info * MMCI)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
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;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
echo_list_mix_channels(echo_dev *card, multi_mix_channel_info *data)
|
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;
|
chans = multi->chans;
|
||||||
index = 0;
|
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) {
|
mode = (mode == ECHO_USE_PLAY) ? ECHO_USE_RECORD : -1) {
|
||||||
LIST_FOREACH(stream, &((echo_dev*)multi->card)->streams, next) {
|
LIST_FOREACH(stream, &((echo_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 == ECHO_USE_PLAY) ? B_MULTI_OUTPUT_CHANNEL : B_MULTI_INPUT_CHANNEL;
|
chans[index].kind = (mode == ECHO_USE_PLAY) ? B_MULTI_OUTPUT_CHANNEL : B_MULTI_INPUT_CHANNEL;
|
||||||
chans[index].designations = designations | chan_designations[i];
|
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;
|
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;
|
||||||
@@ -618,8 +625,8 @@ echo_get_buffers(echo_dev *card, multi_buffer_list *data)
|
|||||||
if (data->request_playback_channels < data->return_playback_channels) {
|
if (data->request_playback_channels < data->return_playback_channels) {
|
||||||
LOG(("not enough channels\n"));
|
LOG(("not enough channels\n"));
|
||||||
}
|
}
|
||||||
for(i=0; i<current_settings.buffer_count; i++)
|
for (i=0; i<current_settings.buffer_count; i++)
|
||||||
for(j=0; j<stream->channels; j++)
|
for (j=0; j<stream->channels; j++)
|
||||||
echo_stream_get_nth_buffer(stream, j, i,
|
echo_stream_get_nth_buffer(stream, j, i,
|
||||||
&data->playback_buffers[i][channels+j].base,
|
&data->playback_buffers[i][channels+j].base,
|
||||||
&data->playback_buffers[i][channels+j].stride);
|
&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) {
|
if (data->request_record_channels < data->return_record_channels) {
|
||||||
LOG(("not enough channels\n"));
|
LOG(("not enough channels\n"));
|
||||||
}
|
}
|
||||||
for(i=0; i<current_settings.buffer_count; i++)
|
for (i=0; i<current_settings.buffer_count; i++)
|
||||||
for(j=0; j<stream->channels; j++)
|
for (j=0; j<stream->channels; j++)
|
||||||
echo_stream_get_nth_buffer(stream, j, i,
|
echo_stream_get_nth_buffer(stream, j, i,
|
||||||
&data->record_buffers[i][channels+j].base,
|
&data->record_buffers[i][channels+j].base,
|
||||||
&data->record_buffers[i][channels+j].stride);
|
&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);
|
(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) {
|
== B_TIMED_OUT) {
|
||||||
LOG(("buffer_exchange timeout ff\n"));
|
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 ||
|
if ((pstream->use & ECHO_USE_PLAY) == 0 ||
|
||||||
(pstream->state & ECHO_STATE_STARTED) == 0)
|
(pstream->state & ECHO_STATE_STARTED) == 0)
|
||||||
continue;
|
continue;
|
||||||
if(pstream->update_needed)
|
if (pstream->update_needed)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -725,13 +732,13 @@ echo_buffer_exchange(echo_dev *card, multi_buffer_info *data)
|
|||||||
if ((rstream->use & ECHO_USE_RECORD) == 0 ||
|
if ((rstream->use & ECHO_USE_RECORD) == 0 ||
|
||||||
(rstream->state & ECHO_STATE_STARTED) == 0)
|
(rstream->state & ECHO_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 */
|
||||||
@@ -753,6 +760,7 @@ echo_buffer_exchange(echo_dev *card, multi_buffer_info *data)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
echo_buffer_force_stop(echo_dev *card)
|
echo_buffer_force_stop(echo_dev *card)
|
||||||
{
|
{
|
||||||
@@ -760,6 +768,7 @@ echo_buffer_force_stop(echo_dev *card)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
echo_multi_control(void *cookie, uint32 op, void *data, size_t length)
|
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
|
#endif
|
||||||
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case B_MULTI_GET_DESCRIPTION:
|
case B_MULTI_GET_DESCRIPTION:
|
||||||
LOG(("B_MULTI_GET_DESCRIPTION\n"));
|
LOG(("B_MULTI_GET_DESCRIPTION\n"));
|
||||||
return echo_get_description(card, (multi_description *)data);
|
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;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static status_t echo_open(const char *name, uint32 flags, void** cookie);
|
static status_t echo_open(const char *name, uint32 flags, void** cookie);
|
||||||
static status_t echo_close(void* cookie);
|
static status_t echo_close(void* cookie);
|
||||||
static status_t echo_free(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_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);
|
static status_t echo_write(void* cookie, off_t position, const void* buffer, size_t* num_bytes);
|
||||||
|
|
||||||
|
|
||||||
device_hooks multi_hooks = {
|
device_hooks multi_hooks = {
|
||||||
echo_open, /* -> open entry point */
|
echo_open, /* -> open entry point */
|
||||||
echo_close, /* -> close entry point */
|
echo_close, /* -> close entry point */
|
||||||
@@ -861,6 +872,7 @@ device_hooks multi_hooks = {
|
|||||||
NULL /* scatter-gather write to the device */
|
NULL /* scatter-gather write to the device */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
echo_open(const char *name, uint32 flags, void** cookie)
|
echo_open(const char *name, uint32 flags, void** cookie)
|
||||||
{
|
{
|
||||||
@@ -884,7 +896,7 @@ echo_open(const char *name, uint32 flags, void** cookie)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(card == NULL) {
|
if (card == NULL) {
|
||||||
LOG(("open() card not found %s\n", name));
|
LOG(("open() card not found %s\n", name));
|
||||||
#ifdef CARDBUS
|
#ifdef CARDBUS
|
||||||
LIST_FOREACH(card, &devices, next) {
|
LIST_FOREACH(card, &devices, next) {
|
||||||
@@ -963,6 +975,7 @@ echo_open(const char *name, uint32 flags, void** cookie)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
echo_close(void* cookie)
|
echo_close(void* cookie)
|
||||||
{
|
{
|
||||||
@@ -975,6 +988,7 @@ echo_close(void* cookie)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
echo_free(void* cookie)
|
echo_free(void* cookie)
|
||||||
{
|
{
|
||||||
@@ -999,12 +1013,14 @@ echo_free(void* cookie)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
echo_control(void* cookie, uint32 op, void* arg, size_t len)
|
echo_control(void* cookie, uint32 op, void* arg, size_t len)
|
||||||
{
|
{
|
||||||
return echo_multi_control(cookie, op, arg, len);
|
return echo_multi_control(cookie, op, arg, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
echo_read(void* cookie, off_t position, void *buf, size_t* num_bytes)
|
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;
|
return B_IO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
echo_write(void* cookie, off_t position, const void* buffer, size_t* num_bytes)
|
echo_write(void* cookie, off_t position, const void* buffer, size_t* num_bytes)
|
||||||
{
|
{
|
||||||
*num_bytes = 0; /* tell caller nothing was written */
|
*num_bytes = 0; /* tell caller nothing was written */
|
||||||
return B_IO_ERROR;
|
return B_IO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,15 +93,10 @@ alloc_mem(void **phy, void **log, size_t size, const char *name)
|
|||||||
*phy = 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 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
|
area_id
|
||||||
map_mem(void **log, void *phy, size_t size, const char *name)
|
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);
|
offset = (uint32)phy & (B_PAGE_SIZE - 1);
|
||||||
phyadr = (void*)((uint32)phy - offset);
|
phyadr = (void*)((uint32)phy - offset);
|
||||||
size = round_to_pagesize(size + 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 = (void*) ((uint32)mapadr + offset);
|
||||||
|
|
||||||
LOG(("physical = %p, logical = %p, offset = %#x, phyadr = %p, mapadr = %p, size = %#x, area = %#x\n",
|
LOG(("physical = %p, logical = %p, offset = %#x, phyadr = %p, mapadr = %p, size = %#x, area = %#x\n",
|
||||||
|
|||||||
Reference in New Issue
Block a user