Merge kernel uapi/sound/asound.h and asequencer.h

Instead of keeping modified asound.h and asequencer.h, copy the files
in the kernel include/uapi/sound as is, and give some renames for
avoiding conflicts with alsa-lib's definitions.

Some structs, unions and typedefs in asound.h and asequencer.h are
once renamed in local.h before inclusion, then renamed back again.

A bonus by this action is that some local codes don't have to refer to
sndrv_xxx any longer.  However, some codes like src/seq/seq.c need
explicit cast because of unavoidable conflicts of struct types.

Another significant change is that now snd_pcm_sw_params.period_event
field is removed.  Instead, try to access the last reserved field
internally.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Takashi Iwai 2012-11-26 17:54:29 +01:00
parent 3fd4ab9be0
commit 9b5beef1dd
12 changed files with 590 additions and 636 deletions

View file

@ -217,7 +217,7 @@ static int snd_ctl_hw_elem_tlv(snd_ctl_t *handle, int op_flag,
{
int inum;
snd_ctl_hw_t *hw = handle->private_data;
struct sndrv_ctl_tlv *xtlv;
struct snd_ctl_tlv *xtlv;
/* we don't support TLV on protocol ver 2.0.3 or earlier */
if (hw->protocol < SNDRV_PROTOCOL_VERSION(2, 0, 4))
@ -229,7 +229,7 @@ static int snd_ctl_hw_elem_tlv(snd_ctl_t *handle, int op_flag,
case 1: inum = SNDRV_CTL_IOCTL_TLV_WRITE; break;
default: return -EINVAL;
}
xtlv = malloc(sizeof(struct sndrv_ctl_tlv) + tlv_size);
xtlv = malloc(sizeof(struct snd_ctl_tlv) + tlv_size);
if (xtlv == NULL)
return -ENOMEM;
xtlv->numid = numid;

View file

@ -895,7 +895,7 @@ int snd_pcm_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t *params)
pcm->tstamp_mode = params->tstamp_mode;
pcm->period_step = params->period_step;
pcm->avail_min = params->avail_min;
pcm->period_event = params->period_event;
pcm->period_event = sw_get_period_event(params);
pcm->start_threshold = params->start_threshold;
pcm->stop_threshold = params->stop_threshold;
pcm->silence_threshold = params->silence_threshold;
@ -5572,7 +5572,7 @@ int snd_pcm_sw_params_current(snd_pcm_t *pcm, snd_pcm_sw_params_t *params)
params->period_step = pcm->period_step;
params->sleep_min = 0;
params->avail_min = pcm->avail_min;
params->period_event = pcm->period_event;
sw_set_period_event(params, pcm->period_event);
params->xfer_align = 1;
params->start_threshold = pcm->start_threshold;
params->stop_threshold = pcm->stop_threshold;
@ -5880,7 +5880,7 @@ int snd_pcm_sw_params_get_avail_min(const snd_pcm_sw_params_t *params, snd_pcm_u
int snd_pcm_sw_params_set_period_event(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, int val)
{
assert(pcm && params);
params->period_event = val;
sw_set_period_event(params, val);
return 0;
}
@ -5893,7 +5893,7 @@ int snd_pcm_sw_params_set_period_event(snd_pcm_t *pcm, snd_pcm_sw_params_t *para
int snd_pcm_sw_params_get_period_event(const snd_pcm_sw_params_t *params, int *val)
{
assert(params && val);
*val = params->period_event;
*val = sw_get_period_event(params);
return 0;
}

View file

@ -63,7 +63,7 @@ struct sndrv_pcm_hw_params_old {
unsigned int flags;
unsigned int masks[SNDRV_PCM_HW_PARAM_SUBFORMAT -
SNDRV_PCM_HW_PARAM_ACCESS + 1];
struct sndrv_interval intervals[SNDRV_PCM_HW_PARAM_TICK_TIME -
struct snd_interval intervals[SNDRV_PCM_HW_PARAM_TICK_TIME -
SNDRV_PCM_HW_PARAM_SAMPLE_BITS + 1];
unsigned int rmask;
unsigned int cmask;
@ -92,9 +92,9 @@ typedef struct {
int fd;
int card, device, subdevice;
int sync_ptr_ioctl;
volatile struct sndrv_pcm_mmap_status * mmap_status;
struct sndrv_pcm_mmap_control *mmap_control;
struct sndrv_pcm_sync_ptr *sync_ptr;
volatile struct snd_pcm_mmap_status * mmap_status;
struct snd_pcm_mmap_control *mmap_control;
struct snd_pcm_sync_ptr *sync_ptr;
snd_pcm_uframes_t hw_ptr;
snd_pcm_uframes_t appl_ptr;
int period_event;
@ -116,7 +116,7 @@ typedef struct {
/* update appl_ptr with driver */
#define FAST_PCM_STATE(hw) \
((enum sndrv_pcm_state) (hw)->mmap_status->state)
((snd_pcm_state_t) (hw)->mmap_status->state)
#define FAST_PCM_TSTAMP(hw) \
((hw)->mmap_status->tstamp)
@ -434,8 +434,8 @@ static int snd_pcm_hw_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params)
{
snd_pcm_hw_t *hw = pcm->private_data;
int fd = hw->fd, err;
int old_period_event = params->period_event;
params->period_event = 0;
int old_period_event = sw_get_period_event(params);
sw_set_period_event(params, 0);
if ((snd_pcm_tstamp_t) params->tstamp_mode == pcm->tstamp_mode &&
params->period_step == pcm->period_step &&
params->start_threshold == pcm->start_threshold &&
@ -451,7 +451,7 @@ static int snd_pcm_hw_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params)
SYSMSG("SNDRV_PCM_IOCTL_SW_PARAMS failed (%i)", err);
return err;
}
params->period_event = old_period_event;
sw_set_period_event(params, old_period_event);
hw->mmap_control->avail_min = params->avail_min;
if (hw->period_event != old_period_event) {
err = snd_pcm_hw_change_timer(pcm, old_period_event);
@ -465,7 +465,7 @@ static int snd_pcm_hw_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params)
static int snd_pcm_hw_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t * info)
{
snd_pcm_hw_t *hw = pcm->private_data;
struct sndrv_pcm_channel_info i;
struct snd_pcm_channel_info i;
int fd = hw->fd, err;
i.channel = info->channel;
if (ioctl(fd, SNDRV_PCM_IOCTL_CHANNEL_INFO, &i) < 0) {
@ -761,7 +761,7 @@ static snd_pcm_sframes_t snd_pcm_hw_writei(snd_pcm_t *pcm, const void *buffer, s
int err;
snd_pcm_hw_t *hw = pcm->private_data;
int fd = hw->fd;
struct sndrv_xferi xferi;
struct snd_xferi xferi;
xferi.buf = (char*) buffer;
xferi.frames = size;
xferi.result = 0; /* make valgrind happy */
@ -780,7 +780,7 @@ static snd_pcm_sframes_t snd_pcm_hw_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_
int err;
snd_pcm_hw_t *hw = pcm->private_data;
int fd = hw->fd;
struct sndrv_xfern xfern;
struct snd_xfern xfern;
memset(&xfern, 0, sizeof(xfern)); /* make valgrind happy */
xfern.bufs = bufs;
xfern.frames = size;
@ -799,7 +799,7 @@ static snd_pcm_sframes_t snd_pcm_hw_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_
int err;
snd_pcm_hw_t *hw = pcm->private_data;
int fd = hw->fd;
struct sndrv_xferi xferi;
struct snd_xferi xferi;
xferi.buf = buffer;
xferi.frames = size;
xferi.result = 0; /* make valgrind happy */
@ -818,7 +818,7 @@ static snd_pcm_sframes_t snd_pcm_hw_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_u
int err;
snd_pcm_hw_t *hw = pcm->private_data;
int fd = hw->fd;
struct sndrv_xfern xfern;
struct snd_xfern xfern;
memset(&xfern, 0, sizeof(xfern)); /* make valgrind happy */
xfern.bufs = bufs;
xfern.frames = size;
@ -835,12 +835,12 @@ static snd_pcm_sframes_t snd_pcm_hw_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_u
static int snd_pcm_hw_mmap_status(snd_pcm_t *pcm)
{
snd_pcm_hw_t *hw = pcm->private_data;
struct sndrv_pcm_sync_ptr sync_ptr;
struct snd_pcm_sync_ptr sync_ptr;
void *ptr;
int err;
ptr = MAP_FAILED;
if (hw->sync_ptr_ioctl == 0)
ptr = mmap(NULL, page_align(sizeof(struct sndrv_pcm_mmap_status)),
ptr = mmap(NULL, page_align(sizeof(struct snd_pcm_mmap_status)),
PROT_READ, MAP_FILE|MAP_SHARED,
hw->fd, SNDRV_PCM_MMAP_OFFSET_STATUS);
if (ptr == MAP_FAILED || ptr == NULL) {
@ -853,7 +853,7 @@ static int snd_pcm_hw_mmap_status(snd_pcm_t *pcm)
SYSMSG("SNDRV_PCM_IOCTL_SYNC_PTR failed (%i)", err);
return err;
}
hw->sync_ptr = calloc(1, sizeof(struct sndrv_pcm_sync_ptr));
hw->sync_ptr = calloc(1, sizeof(struct snd_pcm_sync_ptr));
if (hw->sync_ptr == NULL)
return -ENOMEM;
hw->mmap_status = &hw->sync_ptr->s.status;
@ -862,7 +862,7 @@ static int snd_pcm_hw_mmap_status(snd_pcm_t *pcm)
} else {
hw->mmap_status = ptr;
}
snd_pcm_set_hw_ptr(pcm, &hw->mmap_status->hw_ptr, hw->fd, SNDRV_PCM_MMAP_OFFSET_STATUS + offsetof(struct sndrv_pcm_mmap_status, hw_ptr));
snd_pcm_set_hw_ptr(pcm, &hw->mmap_status->hw_ptr, hw->fd, SNDRV_PCM_MMAP_OFFSET_STATUS + offsetof(struct snd_pcm_mmap_status, hw_ptr));
return 0;
}
@ -872,7 +872,7 @@ static int snd_pcm_hw_mmap_control(snd_pcm_t *pcm)
void *ptr;
int err;
if (hw->sync_ptr == NULL) {
ptr = mmap(NULL, page_align(sizeof(struct sndrv_pcm_mmap_control)),
ptr = mmap(NULL, page_align(sizeof(struct snd_pcm_mmap_control)),
PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED,
hw->fd, SNDRV_PCM_MMAP_OFFSET_CONTROL);
if (ptr == MAP_FAILED || ptr == NULL) {

View file

@ -24,6 +24,7 @@
#include <stdlib.h>
#include <limits.h>
#include <sys/uio.h>
#include <sys/time.h>
#define _snd_mask sndrv_mask
#define _snd_pcm_access_mask _snd_mask
@ -38,7 +39,6 @@
#define SND_MASK_INLINE
#include "mask.h"
typedef enum sndrv_pcm_hw_param snd_pcm_hw_param_t;
#define SND_PCM_HW_PARAM_ACCESS SNDRV_PCM_HW_PARAM_ACCESS
#define SND_PCM_HW_PARAM_FIRST_MASK SNDRV_PCM_HW_PARAM_FIRST_MASK
#define SND_PCM_HW_PARAM_FORMAT SNDRV_PCM_HW_PARAM_FORMAT
@ -578,7 +578,7 @@ static inline int muldiv_near(int a, int b, int c)
}
int snd_pcm_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
int _snd_pcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
int _snd_pcm_hw_params_internal(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
int snd_pcm_hw_refine_soft(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
int snd_pcm_hw_refine_slave(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
int (*cprepare)(snd_pcm_t *pcm,
@ -995,3 +995,13 @@ static inline int snd_pcm_may_wait_for_avail_min(snd_pcm_t *pcm, snd_pcm_uframes
return 1;
}
/* hack to access to internal period_event in snd_pcm_sw_parmams */
static inline int sw_get_period_event(const snd_pcm_sw_params_t *params)
{
return params->reserved[sizeof(params->reserved) / sizeof(params->reserved[0])- 1];
}
static inline void sw_set_period_event(snd_pcm_sw_params_t *params, int val)
{
params->reserved[sizeof(params->reserved) / sizeof(params->reserved[0]) - 1] = val;
}

View file

@ -2309,7 +2309,7 @@ int snd_pcm_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
max periods
Return 0 on success otherwise a negative error code
*/
int _snd_pcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
int _snd_pcm_hw_params_internal(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
{
int err;
snd_pcm_sw_params_t sw;

View file

@ -1899,7 +1899,7 @@ int snd_seq_port_info_get_port(const snd_seq_port_info_t *info)
const snd_seq_addr_t *snd_seq_port_info_get_addr(const snd_seq_port_info_t *info)
{
assert(info);
return &info->addr;
return (const snd_seq_addr_t *) &info->addr;
}
/**
@ -2094,7 +2094,7 @@ void snd_seq_port_info_set_port(snd_seq_port_info_t *info, int port)
void snd_seq_port_info_set_addr(snd_seq_port_info_t *info, const snd_seq_addr_t *addr)
{
assert(info);
info->addr = *addr;
info->addr = *(const struct sndrv_seq_addr *)addr;
}
/**
@ -2444,7 +2444,7 @@ void snd_seq_port_subscribe_copy(snd_seq_port_subscribe_t *dst, const snd_seq_po
const snd_seq_addr_t *snd_seq_port_subscribe_get_sender(const snd_seq_port_subscribe_t *info)
{
assert(info);
return &info->sender;
return (const snd_seq_addr_t *)&info->sender;
}
/**
@ -2456,7 +2456,7 @@ const snd_seq_addr_t *snd_seq_port_subscribe_get_sender(const snd_seq_port_subsc
const snd_seq_addr_t *snd_seq_port_subscribe_get_dest(const snd_seq_port_subscribe_t *info)
{
assert(info);
return &info->dest;
return (const snd_seq_addr_t *)&info->dest;
}
/**
@ -2729,7 +2729,7 @@ int snd_seq_query_subscribe_get_port(const snd_seq_query_subscribe_t *info)
const snd_seq_addr_t *snd_seq_query_subscribe_get_root(const snd_seq_query_subscribe_t *info)
{
assert(info);
return &info->root;
return (const snd_seq_addr_t *)&info->root;
}
/**
@ -2781,7 +2781,7 @@ int snd_seq_query_subscribe_get_num_subs(const snd_seq_query_subscribe_t *info)
const snd_seq_addr_t *snd_seq_query_subscribe_get_addr(const snd_seq_query_subscribe_t *info)
{
assert(info);
return &info->addr;
return (const snd_seq_addr_t *)&info->addr;
}
/**
@ -2872,7 +2872,7 @@ void snd_seq_query_subscribe_set_port(snd_seq_query_subscribe_t *info, int port)
void snd_seq_query_subscribe_set_root(snd_seq_query_subscribe_t *info, const snd_seq_addr_t *addr)
{
assert(info);
info->root = *addr;
info->root = *(const struct snd_seq_addr *)addr;
}
/**
@ -3227,7 +3227,7 @@ int snd_seq_query_named_queue(snd_seq_t *seq, const char *name)
*/
int snd_seq_get_queue_usage(snd_seq_t *seq, int q)
{
struct sndrv_seq_queue_client info;
struct snd_seq_queue_client info;
int err;
assert(seq);
memset(&info, 0, sizeof(info));
@ -3249,7 +3249,7 @@ int snd_seq_get_queue_usage(snd_seq_t *seq, int q)
*/
int snd_seq_set_queue_usage(snd_seq_t *seq, int q, int used)
{
struct sndrv_seq_queue_client info;
struct snd_seq_queue_client info;
assert(seq);
memset(&info, 0, sizeof(info));
info.queue = q;
@ -3351,7 +3351,7 @@ snd_seq_tick_time_t snd_seq_queue_status_get_tick_time(const snd_seq_queue_statu
const snd_seq_real_time_t *snd_seq_queue_status_get_real_time(const snd_seq_queue_status_t *info)
{
assert(info);
return &info->time;
return (const snd_seq_real_time_t *)&info->time;
}
/**
@ -4289,7 +4289,7 @@ int snd_seq_remove_events_get_queue(const snd_seq_remove_events_t *info)
const snd_seq_timestamp_t *snd_seq_remove_events_get_time(const snd_seq_remove_events_t *info)
{
assert(info);
return &info->time;
return (const snd_seq_timestamp_t *)&info->time;
}
/**
@ -4302,7 +4302,7 @@ const snd_seq_timestamp_t *snd_seq_remove_events_get_time(const snd_seq_remove_e
const snd_seq_addr_t *snd_seq_remove_events_get_dest(const snd_seq_remove_events_t *info)
{
assert(info);
return &info->dest;
return (const snd_seq_addr_t *)&info->dest;
}
/**
@ -4380,7 +4380,7 @@ void snd_seq_remove_events_set_queue(snd_seq_remove_events_t *info, int queue)
void snd_seq_remove_events_set_time(snd_seq_remove_events_t *info, const snd_seq_timestamp_t *time)
{
assert(info);
info->time = *time;
info->time = *(const union sndrv_seq_timestamp *)time;
}
/**
@ -4393,7 +4393,7 @@ void snd_seq_remove_events_set_time(snd_seq_remove_events_t *info, const snd_seq
void snd_seq_remove_events_set_dest(snd_seq_remove_events_t *info, const snd_seq_addr_t *addr)
{
assert(info);
info->dest = *addr;
info->dest = *(const struct sndrv_seq_addr *)addr;
}
/**
@ -4475,7 +4475,7 @@ static int remove_match(snd_seq_remove_events_t *info, snd_seq_event_t *ev)
if (info->remove_mode & SNDRV_SEQ_REMOVE_TIME_TICK)
res = snd_seq_compare_tick_time(&ev->time.tick, &info->time.tick);
else
res = snd_seq_compare_real_time(&ev->time.time, &info->time.time);
res = snd_seq_compare_real_time(&ev->time.time, (snd_seq_real_time_t *)&info->time.time);
if (!res)
return 0;
}
@ -4483,7 +4483,7 @@ static int remove_match(snd_seq_remove_events_t *info, snd_seq_event_t *ev)
if (info->remove_mode & SNDRV_SEQ_REMOVE_TIME_TICK)
res = snd_seq_compare_tick_time(&ev->time.tick, &info->time.tick);
else
res = snd_seq_compare_real_time(&ev->time.time, &info->time.time);
res = snd_seq_compare_real_time(&ev->time.time, (snd_seq_real_time_t *)&info->time.time);
if (res)
return 0;
}

View file

@ -518,7 +518,7 @@ int snd_seq_hw_open(snd_seq_t **handle, const char *name, int streams, int mode)
#ifdef SNDRV_SEQ_IOCTL_RUNNING_MODE
{
struct sndrv_seq_running_info run_mode;
struct snd_seq_running_info run_mode;
/* check running mode */
memset(&run_mode, 0, sizeof(run_mode));
run_mode.client = client;

View file

@ -32,7 +32,7 @@
#define SND_SEQ_IBUF_SIZE 500 /* in event_size aligned */
#define DEFAULT_TMPBUF_SIZE 20
typedef struct sndrv_seq_queue_client snd_seq_queue_client_t;
typedef struct snd_seq_queue_client snd_seq_queue_client_t;
typedef struct {

View file

@ -35,7 +35,7 @@ const char *_snd_module_timer_hw = "";
#define SNDRV_FILE_TIMER ALSA_DEVICE_DIRECTORY "timer"
#define SNDRV_TIMER_VERSION_MAX SNDRV_PROTOCOL_VERSION(2, 0, 5)
#define SNDRV_TIMER_IOCTL_STATUS_OLD _IOW('T', 0x14, struct sndrv_timer_status)
#define SNDRV_TIMER_IOCTL_STATUS_OLD _IOW('T', 0x14, struct snd_timer_status)
enum {
SNDRV_TIMER_IOCTL_START_OLD = _IO('T', 0x20),
@ -225,7 +225,7 @@ int snd_timer_hw_open(snd_timer_t **handle, const char *name, int dev_class, int
{
int fd, ver, tmode, ret;
snd_timer_t *tmr;
struct sndrv_timer_select sel;
struct snd_timer_select sel;
*handle = NULL;