Fixed Haiku coding style violations mostly pointed by FuncHaikuCheck.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36991 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Siarzhuk Zharski 2010-06-01 18:50:04 +00:00
parent 8b5a01bb4d
commit a5bc5bb66d
6 changed files with 111 additions and 101 deletions

View File

@ -62,35 +62,35 @@ extern pci_module_info *gPCI;
static uint32
io_read32(ali_dev *card, ulong offset)
{
return (*gPCI->read_io_32)(card->io_base+offset);
return (*gPCI->read_io_32)(card->io_base + offset);
}
static uint8
io_read8(ali_dev *card, ulong offset)
{
return (*gPCI->read_io_8)(card->io_base+offset);
return (*gPCI->read_io_8)(card->io_base + offset);
}
static void
io_write32(ali_dev *card, ulong offset, uint32 value)
{
(*gPCI->write_io_32)(card->io_base+offset, value);
(*gPCI->write_io_32)(card->io_base + offset, value);
}
static void
io_write16(ali_dev *card, ulong offset, uint16 value)
{
(*gPCI->write_io_16)(card->io_base+offset, value);
(*gPCI->write_io_16)(card->io_base + offset, value);
}
static void
io_write8(ali_dev *card, ulong offset, uint8 value)
{
(*gPCI->write_io_8)(card->io_base+offset, value);
(*gPCI->write_io_8)(card->io_base + offset, value);
}

View File

@ -108,9 +108,8 @@ static status_t
get_description(void *cookie, multi_description *data)
{
multi_description description;
if(user_memcpy(&description, data, sizeof(multi_description)) != B_OK) {
if (user_memcpy(&description, data, sizeof(multi_description)) != B_OK)
return B_BAD_ADDRESS;
}
description.interface_version = B_CURRENT_INTERFACE_VERSION;
description.interface_minimum = B_CURRENT_INTERFACE_VERSION;
@ -137,13 +136,12 @@ get_description(void *cookie, multi_description *data)
strcpy(description.control_panel,"");
if(user_memcpy(data, &description, sizeof(multi_description)) != B_OK) {
if (user_memcpy(data, &description, sizeof(multi_description)) != B_OK)
return B_BAD_ADDRESS;
}
if(description.request_channel_count >=
sizeof(channel_descriptions) / sizeof(channel_descriptions[0])) {
if(user_memcpy(data->channels,
if (description.request_channel_count
>= sizeof(channel_descriptions) / sizeof(channel_descriptions[0])) {
if (user_memcpy(data->channels,
&channel_descriptions, sizeof(channel_descriptions)) != B_OK)
return B_BAD_ADDRESS;
}
@ -232,7 +230,7 @@ get_mix_mixer(ali_dev *card, multi_mix_value *mmv, int32 id)
* ((ac97_reg_cached_read(card->codec, mixer_info->reg)
>> ((gadget_id==ALI_MIX_LEFT_ID)?8:0)) & 0x1f));
mmv->u.gain = ((mixer_info->features&ALI_MIX_FT_GAIN)
? mixer_info->min_gain+val:mixer_info->max_gain-val);
? mixer_info->min_gain + val : mixer_info->max_gain - val);
}
break;
@ -260,7 +258,7 @@ get_mix(ali_dev *card, multi_mix_value_info *mmvi)
for (i = 0; i < mmvi->item_count; i++)
get_mix_mixer(card, &(mmvi->values[i]),
mmvi->values[i].id-MULTI_AUDIO_BASE_ID);
mmvi->values[i].id - MULTI_AUDIO_BASE_ID);
return B_OK;
}
@ -289,10 +287,10 @@ set_mix_mixer(ali_dev *card, multi_mix_value *mmv, int32 id)
val = ac97_reg_cached_read(card->codec, mixer_info->reg);
val &= (gadget_id == ALI_MIX_LEFT_ID) ? 0x805f : 0x9f00;
val |= (uint16) (((mixer_info->features&ALI_MIX_FT_GAIN)
? mixer_info->min_gain+mmv->u.gain
: mixer_info->max_gain-mmv->u.gain)
/ ALI_MIXER_GRANULARITY) <<
((gadget_id == ALI_MIX_LEFT_ID) ? 8 : 0);
? mixer_info->min_gain + mmv->u.gain
: mixer_info->max_gain - mmv->u.gain)
/ ALI_MIXER_GRANULARITY)
<< ((gadget_id == ALI_MIX_LEFT_ID) ? 8 : 0);
ac97_reg_cached_write(card->codec, mixer_info->reg, val);
break;
@ -317,7 +315,7 @@ set_mix(ali_dev *card, multi_mix_value_info *mmvi)
for (i = 0; i < mmvi->item_count; i++)
set_mix_mixer(card, &(mmvi->values[i]),
mmvi->values[i].id-MULTI_AUDIO_BASE_ID);
mmvi->values[i].id - MULTI_AUDIO_BASE_ID);
return B_OK;
}
@ -476,7 +474,7 @@ get_buffers(ali_dev *card, multi_buffer_list *data)
data->return_playback_channels = card->playback_stream->channels;
data->return_playback_buffer_size = card->playback_stream->buf_frames;
for (buf_ndx=0; buf_ndx<card->playback_stream->buf_count; buf_ndx++)
for (buf_ndx = 0; buf_ndx<card->playback_stream->buf_count; buf_ndx++)
for (ch_ndx = 0; ch_ndx < card->playback_stream->channels; ch_ndx++)
ali_stream_get_buffer_part(card->playback_stream, ch_ndx, buf_ndx,
&data->playback_buffers[buf_ndx][ch_ndx].base,
@ -503,9 +501,8 @@ buffer_exchange(ali_dev *card, multi_buffer_info *info)
ali_stream *play_s, *rec_s;
multi_buffer_info buffer_info;
if(user_memcpy(&buffer_info, info, sizeof(multi_buffer_info)) != B_OK) {
if (user_memcpy(&buffer_info, info, sizeof(multi_buffer_info)) != B_OK)
return B_BAD_ADDRESS;
}
play_s = card->playback_stream;
rec_s = card->record_stream;
@ -538,9 +535,8 @@ buffer_exchange(ali_dev *card, multi_buffer_info *info)
UNLOCK(card->lock_sts);
if(user_memcpy(info, &buffer_info, sizeof(multi_buffer_info)) != B_OK) {
if (user_memcpy(info, &buffer_info, sizeof(multi_buffer_info)) != B_OK)
return B_BAD_ADDRESS;
}
return B_OK;
}

View File

@ -62,7 +62,7 @@ ali_stream_new(ali_dev *card, bool rec, uint8 buf_count)
stream->frames_count = 0;
stream->real_time = 0;
stream->buffer_cycle = (rec?buf_count-1:0);
stream->buffer_cycle = (rec ? buf_count - 1 : 0);
LOCK(card->lock_sts);
LIST_INSERT_HEAD(&(card->streams), stream, next);
@ -256,7 +256,7 @@ exit_:
static void
make_device_names(ali_dev *card)
{
sprintf(card->name, DEVFS_PATH_FORMAT, card-gCards+1);
sprintf(card->name, DEVFS_PATH_FORMAT, card - gCards + 1);
}
@ -344,7 +344,7 @@ init_hardware(void)
if (get_module(B_PCI_MODULE_NAME, (module_info**) &gPCI) != B_OK)
return res;
for (i=0; (*gPCI->get_nth_pci_info)(i, &info) == B_OK; i++) {
for (i = 0; (*gPCI->get_nth_pci_info)(i, &info) == B_OK; i++) {
if (info.class_base == PCI_multimedia &&
info.vendor_id == ALI_VENDOR_ID &&
info.device_id == ALI_DEVICE_ID) {
@ -383,7 +383,7 @@ init_driver(void)
memset(&gCards[gCardsCount], 0, sizeof(ali_dev));
gCards[gCardsCount].info = info;
if (ali_setup(&gCards[gCardsCount]))
TRACE("init_driver: setup of ali %ld failed\n", gCardsCount+1);
TRACE("init_driver: setup of ali %ld failed\n", gCardsCount + 1);
else
gCardsCount++;
}
@ -417,7 +417,7 @@ uninit_driver(void)
const char **
publish_devices(void)
{
static const char *names[MAX_CARDS+1];
static const char *names[MAX_CARDS + 1];
int32 i;
for (i = 0; i < gCardsCount; i++)

View File

@ -3,7 +3,7 @@
* Distributed under the terms of the MIT License.
*
* Authors:
* Bek, host.haiku@gmx.de
* Bek, host.haiku@gmx.de
*/
#include "driver.h"
@ -52,7 +52,7 @@ null_audio_open (const char *name, uint32 flags, void** cookie)
{
dprintf("null_audio: %s\n" , __func__ );
*cookie = &device;
return B_OK;
return B_OK;
}
@ -115,12 +115,12 @@ null_audio_free (void* cookie)
device_hooks driver_hooks = {
null_audio_open,
null_audio_close,
null_audio_free,
null_audio_control,
null_audio_read,
null_audio_write
null_audio_open,
null_audio_close,
null_audio_free,
null_audio_control,
null_audio_read,
null_audio_write
};

View File

@ -3,7 +3,7 @@
* Distributed under the terms of the MIT License.
*
* Authors:
* Bek, host.haiku@gmx.de
* Bek, host.haiku@gmx.de
*/
#include "driver.h"
@ -41,8 +41,8 @@ null_hw_create_virtual_buffers(device_stream_t* stream, const char* name)
return result;
}
for (i=0; i < stream->num_buffers; i++) {
stream->buffers[i] = buffer + (i*buffer_size);
for (i = 0; i < stream->num_buffers; i++) {
stream->buffers[i] = buffer + (i * buffer_size);
}
stream->buffer_ready_sem = create_sem(0, name);
@ -76,7 +76,7 @@ null_fake_interrupt(void* cookie)
// The time between until we get a new valid buffer
// from our soundcard: buffer_length / samplerate
sleepTime = (device->playback_stream.buffer_length*1000000LL) / sampleRate;
sleepTime = (device->playback_stream.buffer_length * 1000000LL) / sampleRate;
while (device->running) {
cpu_status status;

View File

@ -3,10 +3,11 @@
* Distributed under the terms of the MIT License.
*
* Authors:
* Bek, host.haiku@gmx.de
* Bek, host.haiku@gmx.de
*/
#include "driver.h"
// Convenience function to determine the byte count
// of a sample for a given format.
// Note: Currently null_audio only supports 16 bit,
@ -50,7 +51,7 @@ get_description(void* cookie, multi_description* data)
dprintf("null_audio: %s\n" , __func__ );
multi_description description;
if(user_memcpy(&description, data, sizeof(multi_description)) != B_OK) {
if (user_memcpy(&description, data, sizeof(multi_description)) != B_OK) {
return B_BAD_ADDRESS;
}
@ -68,7 +69,7 @@ get_description(void* cookie, multi_description* data)
description.output_rates = B_SR_44100;
description.input_rates = B_SR_44100;
description.max_cvsr_rate = 0;
description.min_cvsr_rate = 0;
@ -81,13 +82,12 @@ get_description(void* cookie, multi_description* data)
strcpy(description.control_panel,"");
if(user_memcpy(data, &description, sizeof(multi_description)) != B_OK) {
if (user_memcpy(data, &description, sizeof(multi_description)) != B_OK)
return B_BAD_ADDRESS;
}
if(description.request_channel_count
if (description.request_channel_count
>= sizeof(channel_descriptions) / sizeof(channel_descriptions[0])) {
if(user_memcpy(data->channels,
if (user_memcpy(data->channels,
&channel_descriptions, sizeof(channel_descriptions)) != B_OK)
return B_BAD_ADDRESS;
}
@ -146,17 +146,18 @@ get_global_format(device_t* device, multi_format_info* data)
static int32
create_group_control(multi_mix_control* multi, int32 idx, int32 parent, int32 string, const char* name)
create_group_control(multi_mix_control* multi, int32 idx, int32 parent,
int32 string, const char* name)
{
multi->id = MULTI_AUDIO_BASE_ID + idx;
multi->parent = parent;
multi->flags = B_MULTI_MIX_GROUP;
multi->master = MULTI_AUDIO_MASTER_ID;
multi->string = string;
if(name)
strcpy(multi->name, name);
multi->id = MULTI_AUDIO_BASE_ID + idx;
multi->parent = parent;
multi->flags = B_MULTI_MIX_GROUP;
multi->master = MULTI_AUDIO_MASTER_ID;
multi->string = string;
if (name)
strcpy(multi->name, name);
return multi->id;
return multi->id;
}
@ -193,15 +194,18 @@ list_mix_channels(void* cookie, multi_mix_channel_info* channel_info)
static status_t
get_buffers(device_t* device, multi_buffer_list* data)
{
uint32 playback_sample_size = format_to_sample_size(device->playback_stream.format);
uint32 record_sample_size = format_to_sample_size(device->record_stream.format);
uint32 playback_sample_size
= format_to_sample_size(device->playback_stream.format);
uint32 record_sample_size
= format_to_sample_size(device->record_stream.format);
uint32 cidx, bidx;
status_t result;
dprintf("null_audio: %s\n" , __func__ );
/* Workaround for Haiku multi_audio API, since it prefers to let the driver pick
values, while the BeOS multi_audio actually gives the user's defaults. */
// Workaround for Haiku multi_audio API, since it prefers
// to let the driver pick values, while the BeOS multi_audio
// actually gives the user's defaults.
if (data->request_playback_buffers > STRMAXBUF
|| data->request_playback_buffers < STRMINBUF) {
data->request_playback_buffers = STRMINBUF;
@ -218,7 +222,8 @@ get_buffers(device_t* device, multi_buffer_list* data)
if (data->request_record_buffer_size == 0)
data->request_record_buffer_size = FRAMES_PER_BUFFER;
/* ... from here on, we can assume again that a reasonable request is being made */
// ... from here on, we can assume again that
// a reasonable request is being made
data->flags = 0;
@ -227,16 +232,22 @@ get_buffers(device_t* device, multi_buffer_list* data)
device->playback_stream.num_buffers = data->request_playback_buffers;
device->playback_stream.num_channels = data->request_playback_channels;
device->playback_stream.buffer_length = data->request_playback_buffer_size;
if ((result = null_hw_create_virtual_buffers(&device->playback_stream, "null_audio_playback_sem")) != B_OK) {
dprintf("null_audio %s: Error setting up playback buffers (%s)\n", __func__, strerror(result));
result = null_hw_create_virtual_buffers(&device->playback_stream,
"null_audio_playback_sem");
if (result != B_OK) {
dprintf("null_audio %s: Error setting up playback buffers (%s)\n",
__func__, strerror(result));
return result;
}
device->record_stream.num_buffers = data->request_record_buffers;
device->record_stream.num_channels = data->request_record_channels;
device->record_stream.buffer_length = data->request_record_buffer_size;
if ((result = null_hw_create_virtual_buffers(&device->record_stream, "null_audio_record_sem")) != B_OK) {
dprintf("null_audio %s: Error setting up recording buffers (%s)\n", __func__, strerror(result));
result = null_hw_create_virtual_buffers(&device->record_stream,
"null_audio_record_sem");
if (result != B_OK) {
dprintf("null_audio %s: Error setting up recording buffers (%s)\n",
__func__, strerror(result));
return result;
}
@ -245,10 +256,12 @@ get_buffers(device_t* device, multi_buffer_list* data)
data->return_playback_channels = data->request_playback_channels;
data->return_playback_buffer_size = data->request_playback_buffer_size;
for (bidx=0; bidx < data->return_playback_buffers; bidx++) {
for (cidx=0; cidx < data->return_playback_channels; cidx++) {
data->playback_buffers[bidx][cidx].base = device->playback_stream.buffers[bidx] + (playback_sample_size * cidx);
data->playback_buffers[bidx][cidx].stride = playback_sample_size * data->return_playback_channels;
for (bidx = 0; bidx < data->return_playback_buffers; bidx++) {
for (cidx = 0; cidx < data->return_playback_channels; cidx++) {
data->playback_buffers[bidx][cidx].base
= device->playback_stream.buffers[bidx] + (playback_sample_size * cidx);
data->playback_buffers[bidx][cidx].stride
= playback_sample_size * data->return_playback_channels;
}
}
@ -256,10 +269,12 @@ get_buffers(device_t* device, multi_buffer_list* data)
data->return_record_channels = data->request_record_channels;
data->return_record_buffer_size = data->request_record_buffer_size;
for (bidx=0; bidx < data->return_record_buffers; bidx++) {
for (cidx=0; cidx < data->return_record_channels; cidx++) {
data->record_buffers[bidx][cidx].base = device->record_stream.buffers[bidx] + (record_sample_size * cidx);
data->record_buffers[bidx][cidx].stride = record_sample_size * data->return_record_channels;
for (bidx = 0; bidx < data->return_record_buffers; bidx++) {
for (cidx = 0; cidx < data->return_record_channels; cidx++) {
data->record_buffers[bidx][cidx].base
= device->record_stream.buffers[bidx] + (record_sample_size * cidx);
data->record_buffers[bidx][cidx].stride
= record_sample_size * data->return_record_channels;
}
}
@ -276,9 +291,8 @@ buffer_exchange(device_t* device, multi_buffer_info* info)
status_t result;
multi_buffer_info buffer_info;
if(user_memcpy(&buffer_info, info, sizeof(multi_buffer_info)) != B_OK) {
if (user_memcpy(&buffer_info, info, sizeof(multi_buffer_info)) != B_OK)
return B_BAD_ADDRESS;
}
// On first call, we start our fake hardware.
// Usually one would jump into his interrupt handler now
@ -312,13 +326,13 @@ buffer_exchange(device_t* device, multi_buffer_info* info)
restore_interrupts(status);
debug_buffers_exchanged++;
if (((debug_buffers_exchanged % 5000) == 0) ) { //&& debug_buffers_exchanged < 1111) {
dprintf("null_audio: %s: %d buffers processed\n", __func__, debug_buffers_exchanged);
if (((debug_buffers_exchanged % 5000) == 0) ) {
dprintf("null_audio: %s: %d buffers processed\n",
__func__, debug_buffers_exchanged);
}
if(user_memcpy(info, &buffer_info, sizeof(multi_buffer_info)) != B_OK) {
if (user_memcpy(info, &buffer_info, sizeof(multi_buffer_info)) != B_OK)
return B_BAD_ADDRESS;
}
return B_OK;
}
@ -346,26 +360,26 @@ status_t
multi_audio_control(void* cookie, uint32 op, void* arg, size_t len)
{
switch(op) {
case B_MULTI_GET_DESCRIPTION: return get_description(cookie, arg);
case B_MULTI_GET_EVENT_INFO: return B_ERROR;
case B_MULTI_SET_EVENT_INFO: return B_ERROR;
case B_MULTI_GET_EVENT: return B_ERROR;
case B_MULTI_GET_ENABLED_CHANNELS: return get_enabled_channels(cookie, arg);
case B_MULTI_SET_ENABLED_CHANNELS: return B_OK;
case B_MULTI_GET_GLOBAL_FORMAT: return get_global_format(cookie, arg);
case B_MULTI_SET_GLOBAL_FORMAT: return set_global_format(cookie, arg);
case B_MULTI_GET_CHANNEL_FORMATS: return B_ERROR;
case B_MULTI_SET_CHANNEL_FORMATS: return B_ERROR;
case B_MULTI_GET_MIX: return B_ERROR;
case B_MULTI_SET_MIX: return B_ERROR;
case B_MULTI_LIST_MIX_CHANNELS: return list_mix_channels(cookie, arg);
case B_MULTI_LIST_MIX_CONTROLS: return list_mix_controls(cookie, arg);
case B_MULTI_LIST_MIX_CONNECTIONS: return list_mix_connections(cookie, arg);
case B_MULTI_GET_BUFFERS: return get_buffers(cookie, arg);
case B_MULTI_SET_BUFFERS: return B_ERROR;
case B_MULTI_SET_START_TIME: return B_ERROR;
case B_MULTI_BUFFER_EXCHANGE: return buffer_exchange(cookie, arg);
case B_MULTI_BUFFER_FORCE_STOP: return buffer_force_stop(cookie);
case B_MULTI_GET_DESCRIPTION: return get_description(cookie, arg);
case B_MULTI_GET_EVENT_INFO: return B_ERROR;
case B_MULTI_SET_EVENT_INFO: return B_ERROR;
case B_MULTI_GET_EVENT: return B_ERROR;
case B_MULTI_GET_ENABLED_CHANNELS: return get_enabled_channels(cookie, arg);
case B_MULTI_SET_ENABLED_CHANNELS: return B_OK;
case B_MULTI_GET_GLOBAL_FORMAT: return get_global_format(cookie, arg);
case B_MULTI_SET_GLOBAL_FORMAT: return set_global_format(cookie, arg);
case B_MULTI_GET_CHANNEL_FORMATS: return B_ERROR;
case B_MULTI_SET_CHANNEL_FORMATS: return B_ERROR;
case B_MULTI_GET_MIX: return B_ERROR;
case B_MULTI_SET_MIX: return B_ERROR;
case B_MULTI_LIST_MIX_CHANNELS: return list_mix_channels(cookie, arg);
case B_MULTI_LIST_MIX_CONTROLS: return list_mix_controls(cookie, arg);
case B_MULTI_LIST_MIX_CONNECTIONS: return list_mix_connections(cookie, arg);
case B_MULTI_GET_BUFFERS: return get_buffers(cookie, arg);
case B_MULTI_SET_BUFFERS: return B_ERROR;
case B_MULTI_SET_START_TIME: return B_ERROR;
case B_MULTI_BUFFER_EXCHANGE: return buffer_exchange(cookie, arg);
case B_MULTI_BUFFER_FORCE_STOP: return buffer_force_stop(cookie);
}
dprintf("null_audio: %s - unknown op\n" , __func__);