linux-user: Add support for getting/setting selected alsa timer parameters using...
commitfe333025c6bff41eabb7bf420492f22cc5710e1b
authorFilip Bozuta <Filip.Bozuta@rt-rk.com>
Wed, 15 Jan 2020 19:36:45 +0000 (15 20:36 +0100)
committerLaurent Vivier <laurent@vivier.eu>
Wed, 19 Feb 2020 10:17:40 +0000 (19 11:17 +0100)
tree9c2e353f4f3cddec48647ffbcf9f5fc58865867c
parentd22edf0adfbfb5e5d583b51d274e9fbcb285bb02
linux-user: Add support for getting/setting selected alsa timer parameters using ioctls

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 <laurent@vivier.eu>
Signed-off-by: Filip Bozuta <Filip.Bozuta@rt-rk.com>
Message-Id: <1579117007-7565-12-git-send-email-Filip.Bozuta@rt-rk.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
linux-user/ioctls.h
linux-user/syscall_defs.h
linux-user/syscall_types.h