[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 12/13] linux-user: Add support for getting/setting selected alsa t
From: |
Laurent Vivier |
Subject: |
[PULL 12/13] linux-user: Add support for getting/setting selected alsa timer parameters using ioctls |
Date: |
Thu, 20 Feb 2020 10:20:52 +0100 |
From: Filip Bozuta <address@hidden>
This patch implements functionalities of following ioctls:
SNDRV_TIMER_IOCTL_INFO - Getting information about selected timer
Read information about the selected timer. The information is returned in
the following structure:
struct snd_timer_info {
unsigned int flags; /* timer flags - SNDRV_TIMER_FLG_* */
int card; /* card number */
unsigned char id[64]; /* timer identificator */
unsigned char name[80]; /* timer name */
unsigned long reserved0; /* reserved for future use */
unsigned long resolution; /* average period resolution in ns */
unsigned char reserved[64]; /* reserved for future use */
};
A pointer to this structure should be passed as the third ioctl's argument.
Before calling this ioctl, the ioctl "SNDRV_TIMER_IOCTL_SELECT" should be
called first to select the timer which information is to be obtained. If no
timer is selected, the error EBADFD ("File descriptor in bad shape") is
returned.
SNDRV_TIMER_IOCTL_PARAMS - Setting parameters for selected timer
Sets parameters for the selected timer. The paramaters are set in the
following structure:
struct snd_timer_params {
unsigned int flags; /* flags - SNDRV_TIMER_PSFLG_* */
unsigned int ticks; /* requested resolution in ticks */
unsigned int queue_size; /* total size of queue (32-1024) */
unsigned int reserved0; /* reserved, was: failure locations */
unsigned int filter; /* event filter */
unsigned char reserved[60]; /* reserved */
};
A pointer to this structure should be passed as the third ioctl's argument.
Before calling this ioctl, the ioctl "SNDRV_TIMER_IOCTL_SELECT" should be
called first to select the timer which parameters are to be set. If no
timer is selected, the error EBADFD ("File descriptor in bad shape") is
returned.
SNDRV_TIMER_IOCTL_STATUS - Getting status of selected timer
Read status of the selected timer. The status of the timer is returned in
the following structure:
struct snd_timer_status {
struct timespec tstamp; /* Timestamp - last update */
unsigned int resolution; /* current period resolution in ns */
unsigned int lost; /* counter of master tick lost */
unsigned int overrun; /* count of read queue overruns */
unsigned int queue; /* used queue size */
unsigned char reserved[64]; /* reserved */
};
A pointer to this structure should be passed as the third ioctl's argument.
Before calling this ioctl, the ioctl "SNDRV_TIMER_IOCTL_SELECT" should be
called first to select the timer which status is to be obtained. If no
timer is selected, the error EBADFD ("File descriptor in bad shape") is
returned.
Implementation notes:
All ioctls in this patch have pointer to some kind of a structure
as their third argument. That is the reason why corresponding
definitions were added in 'linux-user/syscall_types.h'. Structure
'snd_timer_status' has field of type 'struct timespec' which is why
a corresponding definition of that structure was also added in
'linux-user/syscall_types.h'. All of these strucutures have some
fields that are of type 'unsigned long'. That is the reason why
separate target structures were defined in 'linux-user/syscall_defs.h'.
Structure 'struct timespec' already had a separate target definition
so that definition was used to define a target structure for
'snd_timer_status'. The rest of the implementation was straightforward.
Reviewed-by: Laurent Vivier <address@hidden>
Signed-off-by: Filip Bozuta <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Laurent Vivier <address@hidden>
---
linux-user/ioctls.h | 5 +++++
linux-user/syscall_defs.h | 25 +++++++++++++++++++++++++
linux-user/syscall_types.h | 29 +++++++++++++++++++++++++++++
3 files changed, 59 insertions(+)
diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index 8313af3672c6..de6948796367 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -472,6 +472,11 @@
MK_PTR(MK_STRUCT(STRUCT_snd_timer_gstatus)))
IOCTL(SNDRV_TIMER_IOCTL_SELECT, IOC_W,
MK_PTR(MK_STRUCT(STRUCT_snd_timer_select)))
+ IOCTL(SNDRV_TIMER_IOCTL_INFO, IOC_R,
MK_PTR(MK_STRUCT(STRUCT_snd_timer_info)))
+ IOCTL(SNDRV_TIMER_IOCTL_PARAMS, IOC_W,
+ MK_PTR(MK_STRUCT(STRUCT_snd_timer_params)))
+ IOCTL(SNDRV_TIMER_IOCTL_STATUS, IOC_R,
+ MK_PTR(MK_STRUCT(STRUCT_snd_timer_status)))
IOCTL(HDIO_GETGEO, IOC_R, MK_PTR(MK_STRUCT(STRUCT_hd_geometry)))
IOCTL(HDIO_GET_UNMASKINTR, IOC_R, MK_PTR(TYPE_INT))
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index cac9228a37d0..cf34129fc3ac 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -2479,6 +2479,25 @@ struct target_snd_timer_select {
unsigned char reserved[32];
};
+struct target_snd_timer_info {
+ unsigned int flags;
+ int card;
+ unsigned char id[64];
+ unsigned char name[80];
+ abi_ulong reserved0;
+ abi_ulong resolution;
+ unsigned char reserved[64];
+};
+
+struct target_snd_timer_status {
+ struct target_timespec tstamp;
+ unsigned int resolution;
+ unsigned int lost;
+ unsigned int overrun;
+ unsigned int queue;
+ unsigned char reserved[64];
+};
+
/* alsa timer ioctls */
#define TARGET_SNDRV_TIMER_IOCTL_PVERSION TARGET_IOR('T', 0x00, int)
#define TARGET_SNDRV_TIMER_IOCTL_NEXT_DEVICE TARGET_IOWR('T', 0x01,
\
@@ -2491,6 +2510,12 @@ struct target_snd_timer_select {
struct
target_snd_timer_gstatus)
#define TARGET_SNDRV_TIMER_IOCTL_SELECT TARGET_IOW('T', 0x10,
\
struct target_snd_timer_select)
+#define TARGET_SNDRV_TIMER_IOCTL_INFO TARGET_IOR('T', 0x11,
\
+ struct target_snd_timer_info)
+#define TARGET_SNDRV_TIMER_IOCTL_PARAMS TARGET_IOW('T', 0x12,
\
+ struct snd_timer_params)
+#define TARGET_SNDRV_TIMER_IOCTL_STATUS TARGET_IOR('T', 0x14,
\
+ struct target_snd_timer_status)
/* vfat ioctls */
#define TARGET_VFAT_IOCTL_READDIR_BOTH TARGET_IORU('r', 1)
diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h
index 81bc71938241..4e12c1661ea6 100644
--- a/linux-user/syscall_types.h
+++ b/linux-user/syscall_types.h
@@ -120,6 +120,35 @@ STRUCT(snd_timer_select,
MK_STRUCT(STRUCT_snd_timer_id), /* id */
MK_ARRAY(TYPE_CHAR, 32)) /* reserved */
+STRUCT(snd_timer_info,
+ TYPE_INT, /* flags */
+ TYPE_INT, /* card */
+ MK_ARRAY(TYPE_CHAR, 64), /* id */
+ MK_ARRAY(TYPE_CHAR, 80), /* name */
+ TYPE_ULONG, /* reserved0 */
+ TYPE_ULONG, /* resolution */
+ MK_ARRAY(TYPE_CHAR, 64)) /* reserved */
+
+STRUCT(snd_timer_params,
+ TYPE_INT, /* flags */
+ TYPE_INT, /* ticks */
+ TYPE_INT, /* queue_size */
+ TYPE_INT, /* reserved0 */
+ TYPE_INT, /* filter */
+ MK_ARRAY(TYPE_CHAR, 60)) /* reserved */
+
+STRUCT(timespec,
+ TYPE_LONG, /* tv_sec */
+ TYPE_LONG) /* tv_nsec */
+
+STRUCT(snd_timer_status,
+ MK_STRUCT(STRUCT_timespec), /* tstamp */
+ TYPE_INT, /* resolution */
+ TYPE_INT, /* lost */
+ TYPE_INT, /* overrun */
+ TYPE_INT, /* queue */
+ MK_ARRAY(TYPE_CHAR, 64)) /* reserved */
+
/* loop device ioctls */
STRUCT(loop_info,
TYPE_INT, /* lo_number */
--
2.24.1
- [PULL 00/13] Linux user for 5.0 patches, Laurent Vivier, 2020/02/20
- [PULL 03/13] configure: linux-user doesn't need neither fdt nor slirp, Laurent Vivier, 2020/02/20
- [PULL 09/13] linux-user: Add support for getting alsa timer version and id, Laurent Vivier, 2020/02/20
- [PULL 05/13] configure: Avoid compiling system tools on user build by default, Laurent Vivier, 2020/02/20
- [PULL 02/13] linux-user: implement getsockopt SO_RCVTIMEO and SO_SNDTIMEO, Laurent Vivier, 2020/02/20
- [PULL 01/13] linux-user: Implement membarrier syscall, Laurent Vivier, 2020/02/20
- [PULL 12/13] linux-user: Add support for getting/setting selected alsa timer parameters using ioctls,
Laurent Vivier <=
- [PULL 08/13] linux-user: remove gemu_log from the linux-user tree, Laurent Vivier, 2020/02/20
- [PULL 04/13] linux-user/strace: Improve output of various syscalls, Laurent Vivier, 2020/02/20
- [PULL 10/13] linux-user: Add support for getting/setting specified alsa timer parameters using ioctls, Laurent Vivier, 2020/02/20
- [PULL 06/13] linux-user: Use `qemu_log' for non-strace logging, Laurent Vivier, 2020/02/20
- [PULL 11/13] linux-user: Add support for selecting alsa timer using ioctl, Laurent Vivier, 2020/02/20
- [PULL 13/13] linux-user: Add support for selected alsa timer instructions using ioctls, Laurent Vivier, 2020/02/20
- [PULL 07/13] linux-user: Use `qemu_log' for strace, Laurent Vivier, 2020/02/20
- Re: [PULL 00/13] Linux user for 5.0 patches, Peter Maydell, 2020/02/21