From nobody Mon Feb 9 15:46:01 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1578575553; cv=none; d=zohomail.com; s=zohoarc; b=YwHJPO2vx9gKFPq5UJc0OIsUsefhFqfdHGJDGqVtkTsIBH/WP4aEqsipU0nbVtg2TdE8lBMaFHdqjfSKgapCByraJNduL4GZMXbpmYKricuWa7xnzKmd1gqAyKRtEf8e6Cf0baKVtkCkE2y4UErilVnE54viq74OmWleO51UQ4M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578575553; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=AG+SGJCJN0f96/Dip9puDYSASMtBBcz9YB4mKy1SmUg=; b=jULOGTalNhlQXr9x+tTJLwuNLegs331BD0aqoqzVrTbmKF0xb6NAbuVERYjYNoIA4x1rd6bBKHiNS5JodgTlVoCQMcdrETSdpmfKE5+T/LcXSine4SPmjp4skDL3AhW92jHXqhGhbX1+S4g4m+/bDyRmQUd5N9EvwXj8wIR6/Ks= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578575553781236.50146681304852; Thu, 9 Jan 2020 05:12:33 -0800 (PST) Received: from localhost ([::1]:60164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipXc0-0001AK-7m for importer@patchew.org; Thu, 09 Jan 2020 08:12:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36580) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipXQd-0003KH-Ig for qemu-devel@nongnu.org; Thu, 09 Jan 2020 08:00:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipXQb-0003BW-8N for qemu-devel@nongnu.org; Thu, 09 Jan 2020 08:00:47 -0500 Received: from mx2.rt-rk.com ([89.216.37.149]:42185 helo=mail.rt-rk.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ipXQa-00036w-Ep for qemu-devel@nongnu.org; Thu, 09 Jan 2020 08:00:44 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 5E55B1A2136; Thu, 9 Jan 2020 13:59:34 +0100 (CET) Received: from rtrkw493-lin.domain.local (rtrkw493-lin.domain.local [10.10.14.93]) by mail.rt-rk.com (Postfix) with ESMTPSA id 406A71A2151; Thu, 9 Jan 2020 13:59:34 +0100 (CET) X-Virus-Scanned: amavisd-new at rt-rk.com From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH 11/12] linux-user: Add support for getting/setting selected alsa timer parameters using ioctls Date: Thu, 9 Jan 2020 13:59:22 +0100 Message-Id: <1578574763-8327-12-git-send-email-Filip.Bozuta@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1578574763-8327-1-git-send-email-Filip.Bozuta@rt-rk.com> References: <1578574763-8327-1-git-send-email-Filip.Bozuta@rt-rk.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 89.216.37.149 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: riku.voipio@iki.fi, laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 argum= ent. Before calling this ioctl, the ioctl "SNDRV_TIMER_IOCTL_SELECT" should = be called first to select the timer which information is to be obtained. I= f 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 argum= ent. 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 argum= ent. 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. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier --- 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 7652117..43e7e5d 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -461,6 +461,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_i= nfo))) + 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))) =20 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 9a33b71..d76124d 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -2467,6 +2467,25 @@ struct target_snd_timer_select { unsigned char reserved[32]; }; =20 +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, = \ @@ -2480,6 +2499,12 @@ struct target_snd_timer_select { struct target_sn= d_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) =20 /* 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 767632d..fbc4be7 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 */ =20 +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 */ --=20 2.7.4