* 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",
|
||||||
|
|||||||
@@ -418,7 +418,6 @@ 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;
|
||||||
|
|
||||||
|
|||||||
@@ -48,10 +48,7 @@ device_hooks midi_hooks = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
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,11 +131,7 @@ 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;
|
||||||
@@ -158,4 +141,3 @@ midi_write(
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,9 +46,9 @@ typedef enum {
|
|||||||
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;
|
||||||
@@ -80,11 +80,13 @@ 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;
|
||||||
@@ -115,7 +117,8 @@ echo_channel_set_mix(void *card, MIXER_AUDIO_CHANNEL channel, int32 type, float
|
|||||||
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -266,6 +269,7 @@ 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)
|
||||||
{
|
{
|
||||||
@@ -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)
|
||||||
{
|
{
|
||||||
@@ -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)
|
||||||
{
|
{
|
||||||
@@ -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)
|
||||||
{
|
{
|
||||||
@@ -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)
|
||||||
{
|
{
|
||||||
@@ -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