* style fixes
* use user_memcpy in buffer exchange for Haiku git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28861 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
*/
|
||||
#include <OS.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <MediaDefs.h>
|
||||
#include "ac97.h"
|
||||
#include "debug.h"
|
||||
|
||||
@@ -111,6 +111,7 @@ auich_mem_new(auich_dev *card, size_t size)
|
||||
return mem;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
auich_mem_delete(auich_mem *mem)
|
||||
{
|
||||
@@ -119,6 +120,7 @@ auich_mem_delete(auich_mem *mem)
|
||||
free(mem);
|
||||
}
|
||||
|
||||
|
||||
static void *
|
||||
auich_mem_alloc(auich_dev *card, size_t size)
|
||||
{
|
||||
@@ -133,6 +135,7 @@ auich_mem_alloc(auich_dev *card, size_t size)
|
||||
return mem;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
auich_mem_free(auich_dev *card, void *ptr)
|
||||
{
|
||||
@@ -181,6 +184,7 @@ auich_stream_set_audioparms(auich_stream *stream, uint8 channels,
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
auich_stream_commit_parms(auich_stream *stream)
|
||||
{
|
||||
@@ -229,6 +233,7 @@ auich_stream_commit_parms(auich_stream *stream)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
auich_stream_get_nth_buffer(auich_stream *stream, uint8 chan, uint8 buf,
|
||||
char** buffer, size_t *stride)
|
||||
@@ -246,6 +251,7 @@ auich_stream_get_nth_buffer(auich_stream *stream, uint8 chan, uint8 buf,
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static uint8
|
||||
auich_stream_curaddr(auich_stream *stream)
|
||||
{
|
||||
@@ -254,6 +260,7 @@ auich_stream_curaddr(auich_stream *stream)
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
auich_stream_start(auich_stream *stream, void (*inth) (void *), void *inthparam)
|
||||
{
|
||||
@@ -284,6 +291,7 @@ auich_stream_start(auich_stream *stream, void (*inth) (void *), void *inthparam)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
auich_stream_halt(auich_stream *stream)
|
||||
{
|
||||
@@ -295,6 +303,7 @@ auich_stream_halt(auich_stream *stream)
|
||||
auich_reg_read_8(&stream->card->config, stream->base + AUICH_REG_X_CR) & ~CR_RPBM);
|
||||
}
|
||||
|
||||
|
||||
auich_stream *
|
||||
auich_stream_new(auich_dev *card, uint8 use, uint32 bufframes, uint8 bufcount)
|
||||
{
|
||||
@@ -350,6 +359,7 @@ auich_stream_new(auich_dev *card, uint8 use, uint32 bufframes, uint8 bufcount)
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
auich_stream_delete(auich_stream *stream)
|
||||
{
|
||||
@@ -504,6 +514,7 @@ map_io_memory(device_config *config)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
unmap_io_memory(device_config *config)
|
||||
{
|
||||
@@ -572,6 +583,7 @@ init_hardware(void)
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
make_device_names(
|
||||
auich_dev * card)
|
||||
@@ -597,6 +609,7 @@ auich_init(auich_dev * card)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auich_setup(auich_dev * card)
|
||||
{
|
||||
|
||||
@@ -103,6 +103,7 @@ auich_ac97_get_mix(void *card, const void *cookie, int32 type, float *values) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
auich_ac97_set_mix(void *card, const void *cookie, int32 type, float *values) {
|
||||
auich_dev *dev = (auich_dev*)card;
|
||||
@@ -175,6 +176,7 @@ auich_ac97_set_mix(void *card, const void *cookie, int32 type, float *values) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
static int32
|
||||
auich_create_group_control(multi_dev *multi, int32 *index, int32 parent,
|
||||
int32 string, const char* name) {
|
||||
@@ -191,6 +193,7 @@ auich_create_group_control(multi_dev *multi, int32 *index, int32 parent,
|
||||
return multi->controls[i].mix_control.id;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auich_create_controls_list(multi_dev *multi)
|
||||
{
|
||||
@@ -382,6 +385,7 @@ auich_create_controls_list(multi_dev *multi)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auich_get_mix(auich_dev *card, multi_mix_value_info * MMVI)
|
||||
{
|
||||
@@ -421,6 +425,7 @@ auich_get_mix(auich_dev *card, multi_mix_value_info * MMVI)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auich_set_mix(auich_dev *card, multi_mix_value_info * MMVI)
|
||||
{
|
||||
@@ -484,6 +489,7 @@ auich_set_mix(auich_dev *card, multi_mix_value_info * MMVI)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auich_list_mix_controls(auich_dev *card, multi_mix_control_info * MMCI)
|
||||
{
|
||||
@@ -504,12 +510,14 @@ auich_list_mix_controls(auich_dev *card, multi_mix_control_info * MMCI)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auich_list_mix_connections(auich_dev *card, multi_mix_connection_info * data)
|
||||
{
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auich_list_mix_channels(auich_dev *card, multi_mix_channel_info *data)
|
||||
{
|
||||
@@ -699,6 +707,7 @@ auich_get_description(auich_dev *card, multi_description *data)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auich_get_enabled_channels(auich_dev *card, multi_channel_enable *data)
|
||||
{
|
||||
@@ -716,6 +725,7 @@ auich_get_enabled_channels(auich_dev *card, multi_channel_enable *data)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auich_set_enabled_channels(auich_dev *card, multi_channel_enable *data)
|
||||
{
|
||||
@@ -726,6 +736,7 @@ auich_set_enabled_channels(auich_dev *card, multi_channel_enable *data)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auich_get_global_format(auich_dev *card, multi_format_info *data)
|
||||
{
|
||||
@@ -746,6 +757,7 @@ auich_get_global_format(auich_dev *card, multi_format_info *data)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auich_get_buffers(auich_dev *card, multi_buffer_list *data)
|
||||
{
|
||||
@@ -827,6 +839,7 @@ auich_play_inth(void* inthparams)
|
||||
release_sem_etc(stream->card->buffer_ready_sem, 1, B_DO_NOT_RESCHEDULE);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
auich_record_inth(void* inthparams)
|
||||
{
|
||||
@@ -848,11 +861,15 @@ auich_record_inth(void* inthparams)
|
||||
release_sem_etc(stream->card->buffer_ready_sem, 1, B_DO_NOT_RESCHEDULE);
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auich_buffer_exchange(auich_dev *card, multi_buffer_info *data)
|
||||
{
|
||||
cpu_status status;
|
||||
auich_stream *pstream, *rstream;
|
||||
bigtime_t played_real_time, recorded_real_time;
|
||||
uint64 played_frames_count, recorded_frames_count;
|
||||
int32 playback_buffer_cycle, record_buffer_cycle, _reserved_0, _reserved_1;
|
||||
|
||||
data->flags = B_MULTI_BUFFER_PLAYBACK | B_MULTI_BUFFER_RECORD;
|
||||
|
||||
@@ -891,24 +908,41 @@ auich_buffer_exchange(auich_dev *card, multi_buffer_info *data)
|
||||
rstream = card->rstream;
|
||||
|
||||
/* do playback */
|
||||
data->playback_buffer_cycle = pstream->buffer_cycle;
|
||||
data->played_real_time = pstream->real_time;
|
||||
data->played_frames_count = pstream->frames_count;
|
||||
data->_reserved_0 = pstream->first_channel;
|
||||
playback_buffer_cycle = pstream->buffer_cycle;
|
||||
played_real_time = pstream->real_time;
|
||||
played_frames_count = pstream->frames_count;
|
||||
_reserved_0 = pstream->first_channel;
|
||||
pstream->update_needed = false;
|
||||
|
||||
/* do record */
|
||||
data->record_buffer_cycle = rstream->buffer_cycle;
|
||||
data->recorded_frames_count = rstream->frames_count;
|
||||
data->recorded_real_time = rstream->real_time;
|
||||
data->_reserved_1 = rstream->first_channel;
|
||||
record_buffer_cycle = rstream->buffer_cycle;
|
||||
recorded_frames_count = rstream->frames_count;
|
||||
recorded_real_time = rstream->real_time;
|
||||
_reserved_1 = rstream->first_channel;
|
||||
rstream->update_needed = false;
|
||||
unlock(status);
|
||||
|
||||
#ifdef __HAIKU__
|
||||
#define copy_to_user(x, y) if (user_memcpy(&x, &y, sizeof(x)) < B_OK) \
|
||||
return B_BAD_ADDRESS
|
||||
#else
|
||||
#define copy_to_user(x, y) x = y
|
||||
#endif
|
||||
|
||||
copy_to_user(data->playback_buffer_cycle, playback_buffer_cycle);
|
||||
copy_to_user(data->played_real_time, played_real_time);
|
||||
copy_to_user(data->played_frames_count, played_frames_count);
|
||||
copy_to_user(data->_reserved_0, _reserved_0);
|
||||
copy_to_user(data->record_buffer_cycle, record_buffer_cycle);
|
||||
copy_to_user(data->recorded_real_time, recorded_real_time);
|
||||
copy_to_user(data->recorded_frames_count, recorded_frames_count);
|
||||
copy_to_user(data->_reserved_1, _reserved_1);
|
||||
|
||||
//TRACE(("buffer_exchange ended\n"));
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auich_buffer_force_stop(auich_dev *card)
|
||||
{
|
||||
@@ -916,6 +950,7 @@ auich_buffer_force_stop(auich_dev *card)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auich_multi_control(void *cookie, uint32 op, void *data, size_t length)
|
||||
{
|
||||
@@ -1009,6 +1044,7 @@ device_hooks multi_hooks = {
|
||||
NULL /* scatter-gather write to the device */
|
||||
};
|
||||
|
||||
|
||||
static status_t
|
||||
auich_open(const char *name, uint32 flags, void** cookie)
|
||||
{
|
||||
@@ -1090,6 +1126,7 @@ auich_open(const char *name, uint32 flags, void** cookie)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auich_close(void* cookie)
|
||||
{
|
||||
@@ -1099,6 +1136,7 @@ auich_close(void* cookie)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auich_free(void* cookie)
|
||||
{
|
||||
@@ -1123,12 +1161,14 @@ auich_free(void* cookie)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auich_control(void* cookie, uint32 op, void* arg, size_t len)
|
||||
{
|
||||
return auich_multi_control(cookie, op, arg, len);
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auich_read(void* cookie, off_t position, void *buf, size_t* num_bytes)
|
||||
{
|
||||
@@ -1136,10 +1176,10 @@ auich_read(void* cookie, off_t position, void *buf, size_t* num_bytes)
|
||||
return B_IO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auich_write(void* cookie, off_t position, const void* buffer, size_t* num_bytes)
|
||||
{
|
||||
*num_bytes = 0; /* tell caller nothing was written */
|
||||
return B_IO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user