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

@ -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;