All of lore.kernel.org
 help / color / mirror / Atom feed
From: Filip Bozuta <Filip.Bozuta@rt-rk.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, berrange@redhat.com, arnd@arndb.de,
	richard.henderson@linaro.org, laurent@vivier.eu,
	jcmvbkbc@gmail.com, amarkovic@wavecomp.com, philmd@redhat.com
Subject: [PATCH 09/12] linux-user: Add support for getting/setting specified alsa timer parameters using ioctls
Date: Wed, 15 Jan 2020 16:53:35 +0100	[thread overview]
Message-ID: <1579103618-20217-10-git-send-email-Filip.Bozuta@rt-rk.com> (raw)
In-Reply-To: <1579103618-20217-1-git-send-email-Filip.Bozuta@rt-rk.com>

This patch implements functionalities of following ioctls:

SNDRV_TIMER_IOCTL_GINFO - Getting information about specified timer

    Read information about the specified timer. The information about the
    timer is returned in the following structure:

        struct snd_timer_ginfo {
            struct snd_timer_id tid;      /* requested timer ID */
            unsigned int flags;           /* timer flags - SNDRV_TIMER_FLG_* */
            int card;                     /* card number */
            unsigned char id[64];         /* timer identification */
            unsigned char name[80];       /* timer name */
            unsigned long reserved0;      /* reserved for future use */
            unsigned long resolution;     /* average period resolution in ns */
            unsigned long resolution_min; /* minimal period resolution in ns */
            unsigned long resolution_max; /* maximal period resolution in ns */
            unsigned int clients;         /* active timer clients */
            unsigned char reserved[32];   /* reserved */
        };

    A pointer to this structure should be passed as the third ioctl's argument.
    Before calling the ioctl, the field "tid" should be initialized with the id
    information for the timer which information is to be obtained. After the
    ioctl call, the rest of the structure fields are filled with values from
    the timer device with the specified id. If there is no device with the
    specified id, the error ENODEV ("No such device") is returned.

SNDRV_TIMER_IOCTL_GPARAMS - Setting precise period duration

    Sets timer precise period duration numerator and denominator in seconds. The
    period duration is set in the following structure:

        struct snd_timer_gparams {
            struct snd_timer_id tid;    /* requested timer ID */
            unsigned long period_num;   /* period duration - numerator */
            unsigned long period_den;   /* period duration - denominator */
            unsigned char reserved[32]; /* reserved */
        };

    A pointer to this structure should be passed as the third ioctl's argument.
    Before calling the ioctl, the field "tid" should be initialized with the id
    information for the timer which period duration is to be set. Also, the
    fileds "period_num" and "period_den" should be filled with the period
    duration numerator and denominator values that are to be set respectively.
    If there is no device with the specified id, the error ENODEV ("No such
    device") is returned.

SNDRV_TIMER_IOCTL_GSTATUS - Getting current period resolution

    Read timer current period resolution in nanoseconds and period resolution
    numerator and denominator in seconds. The period resolution information is
    returned in the following structure:

    struct snd_timer_gstatus {
        struct snd_timer_id tid;        /* requested timer ID */
        unsigned long resolution;       /* current period resolution in ns */
        unsigned long resolution_num;   /* period resolution - numerator */
        unsigned long resolution_den;   /* period resolution - denominator */
        unsigned char reserved[32];     /* reserved for future use */
    };

    A pointer to this structure should be passed as the third ioctl's argument.
    Before calling the ioctl, the field "tid" should be initialized with the id
    information for the timer which period resolution is to be obtained. After
    the ioctl call, the rest of the structure fields are filled with values
    from the timer device with the specified id. If there is no device with the
    specified id, the error ENODEV ("No such device") 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'. All of these strcutures 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'. Also, all of the
    structures have a field with type 'struct snd_timer_id' which is the reason
    why a separate target structure 'struct target_snd_timer_id' was also
    defined. The rest of the implementation was straightforward.

Signed-off-by: Filip Bozuta <Filip.Bozuta@rt-rk.com>
---
 linux-user/ioctls.h        |  6 ++++++
 linux-user/syscall_defs.h  | 43 +++++++++++++++++++++++++++++++++++++++++++
 linux-user/syscall_types.h | 26 ++++++++++++++++++++++++++
 3 files changed, 75 insertions(+)

diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index 9106773..989eb9b 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -453,6 +453,12 @@
   IOCTL(SNDRV_TIMER_IOCTL_NEXT_DEVICE, IOC_RW,
         MK_PTR(MK_STRUCT(STRUCT_snd_timer_id)))
   IOCTL(SNDRV_TIMER_IOCTL_TREAD, IOC_W, MK_PTR(TYPE_INT))
+  IOCTL(SNDRV_TIMER_IOCTL_GINFO, IOC_RW,
+        MK_PTR(MK_STRUCT(STRUCT_snd_timer_ginfo)))
+  IOCTL(SNDRV_TIMER_IOCTL_GPARAMS, IOC_W,
+        MK_PTR(MK_STRUCT(STRUCT_snd_timer_gparams)))
+  IOCTL(SNDRV_TIMER_IOCTL_GSTATUS, IOC_RW,
+        MK_PTR(MK_STRUCT(STRUCT_snd_timer_gstatus)))
 
   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 8d505c1..4d4dad3 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -2425,11 +2425,54 @@ struct target_statfs64 {
 
 #define TARGET_SOUND_MIXER_WRITE_RECSRC	TARGET_MIXER_WRITE(SOUND_MIXER_RECSRC)
 
+struct target_snd_timer_id {
+    int dev_class;
+    int dev_sclass;
+    int card;
+    int device;
+    int subdevice;
+};
+
+struct target_snd_timer_ginfo {
+    struct target_snd_timer_id tid;
+    unsigned int flags;
+    int card;
+    unsigned char id[64];
+    unsigned char name[80];
+    abi_ulong reserved0;
+    abi_ulong resolution;
+    abi_ulong resolution_min;
+    abi_ulong resolution_max;
+    unsigned int clients;
+    unsigned char reserved[32];
+};
+
+struct target_snd_timer_gparams {
+    struct target_snd_timer_id tid;
+    abi_ulong period_num;
+    abi_ulong period_den;
+    unsigned char reserved[32];
+};
+
+struct target_snd_timer_gstatus {
+    struct target_snd_timer_id tid;
+    abi_ulong resolution;
+    abi_ulong resolution_num;
+    abi_ulong resolution_den;
+    unsigned char reserved[32];
+};
+
 /* 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,                     \
                                                           struct snd_timer_id)
 #define TARGET_SNDRV_TIMER_IOCTL_TREAD        TARGET_IOW('T', 0x02, int)
+#define TARGET_SNDRV_TIMER_IOCTL_GINFO        TARGET_IOWR('T', 0x03,                     \
+                                                          struct target_snd_timer_ginfo)
+#define TARGET_SNDRV_TIMER_IOCTL_GPARAMS      TARGET_IOW('T', 0x04,                      \
+                                                         struct target_snd_timer_gparams)
+#define TARGET_SNDRV_TIMER_IOCTL_GSTATUS      TARGET_IOWR('T', 0x05,                     \
+                                                          struct target_snd_timer_gstatus)
 
 /* 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 2f4cd78..4e90716 100644
--- a/linux-user/syscall_types.h
+++ b/linux-user/syscall_types.h
@@ -90,6 +90,32 @@ STRUCT(snd_timer_id,
        TYPE_INT, /* device */
        TYPE_INT) /* subdevice */
 
+STRUCT(snd_timer_ginfo,
+       MK_STRUCT(STRUCT_snd_timer_id), /* tid */
+       TYPE_INT, /* flags */
+       TYPE_INT, /* card */
+       MK_ARRAY(TYPE_CHAR, 64), /* id */
+       MK_ARRAY(TYPE_CHAR, 80), /* name */
+       TYPE_ULONG, /* reserved0 */
+       TYPE_ULONG, /* resolution */
+       TYPE_ULONG, /* resolution_min */
+       TYPE_ULONG, /* resolution_max */
+       TYPE_INT, /* clients */
+       MK_ARRAY(TYPE_CHAR, 32)) /* reserved */
+
+STRUCT(snd_timer_gparams,
+       MK_STRUCT(STRUCT_snd_timer_id), /* tid */
+       TYPE_ULONG, /* period_num */
+       TYPE_ULONG, /* period_den */
+       MK_ARRAY(TYPE_CHAR, 32)) /* reserved */
+
+STRUCT(snd_timer_gstatus,
+       MK_STRUCT(STRUCT_snd_timer_id), /* tid */
+       TYPE_ULONG, /* resolution */
+       TYPE_ULONG, /* resolution_num */
+       TYPE_ULONG, /* resolution_den */
+       MK_ARRAY(TYPE_CHAR, 32)) /* reserved */
+
 /* loop device ioctls */
 STRUCT(loop_info,
        TYPE_INT,                 /* lo_number */
-- 
2.7.4



  parent reply	other threads:[~2020-01-15 16:40 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-15 15:53 [PATCH 00/12] linux-user: Add support for real time clock and Filip Bozuta
2020-01-15 15:53 ` [PATCH 01/12] linux-user: Add support for enabling/disabling RTC features using ioctls Filip Bozuta
2020-01-15 15:53 ` [PATCH 02/12] linux-user: Add support for getting/setting RTC time and alarm " Filip Bozuta
2020-01-15 15:53 ` [PATCH 03/12] linux-user: Add support for getting/setting RTC periodic interrupt and epoch " Filip Bozuta
2020-01-15 16:46   ` Laurent Vivier
2020-01-15 15:53 ` [PATCH 04/12] linux-user: Add support for getting/setting RTC wakeup alarm " Filip Bozuta
2020-01-15 15:53 ` [PATCH 05/12] linux-user: Add support for getting/setting RTC PLL correction " Filip Bozuta
2020-01-15 15:53 ` [PATCH 06/12] linux-user: Add support for read/clear RTC voltage low detector " Filip Bozuta
2020-01-15 15:53 ` [PATCH 07/12] linux-user: Add support for getting alsa timer version and id Filip Bozuta
2020-01-15 15:53 ` [PATCH 08/12] linux-user: Add support for setting alsa timer enhanced read using ioctl Filip Bozuta
2020-01-15 16:18   ` Arnd Bergmann
2020-01-15 16:32     ` Laurent Vivier
2020-01-15 16:37       ` Arnd Bergmann
2020-01-15 19:17         ` Filip Bozuta
2020-01-15 19:51           ` Arnd Bergmann
2020-01-15 21:30             ` Laurent Vivier
2020-01-15 21:52           ` Laurent Vivier
2020-01-16  2:49             ` Aleksandar Markovic
2020-01-16 11:27               ` Aleksandar Markovic
2020-01-16 12:00                 ` Arnd Bergmann
2020-01-16 12:00                   ` Arnd Bergmann
2020-01-17 20:50                   ` Aleksandar Markovic
2020-01-17 20:50                     ` Aleksandar Markovic
2020-01-17 21:45                     ` Arnd Bergmann
2020-01-17 21:45                       ` Arnd Bergmann
2020-01-17 21:54                     ` Alexandre Belloni
2020-01-17 21:54                       ` Alexandre Belloni
2020-01-15 15:53 ` Filip Bozuta [this message]
2020-01-15 15:53 ` [PATCH 10/12] linux-user: Add support for selecting alsa timer " Filip Bozuta
2020-01-15 15:53 ` [PATCH 11/12] linux-user: Add support for getting/setting selected alsa timer parameters using ioctls Filip Bozuta
2020-01-15 15:53 ` [PATCH 12/12] linux-user: Add support for selected alsa timer instructions " Filip Bozuta
2020-01-15 16:35 ` [PATCH 00/12] linux-user: Add support for real time clock and Laurent Vivier
  -- strict thread matches above, loose matches on Subject: below --
2020-01-09 12:59 Filip Bozuta
2020-01-09 12:59 ` [PATCH 09/12] linux-user: Add support for getting/setting specified alsa timer parameters using ioctls Filip Bozuta
2020-01-14 12:52   ` Laurent Vivier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1579103618-20217-10-git-send-email-Filip.Bozuta@rt-rk.com \
    --to=filip.bozuta@rt-rk.com \
    --cc=amarkovic@wavecomp.com \
    --cc=arnd@arndb.de \
    --cc=berrange@redhat.com \
    --cc=jcmvbkbc@gmail.com \
    --cc=laurent@vivier.eu \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.