qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* ALSA support in qemu-user?
@ 2024-10-14  1:18 Andrew Randrianasulu
  2024-10-14  9:06 ` Peter Maydell
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Randrianasulu @ 2024-10-14  1:18 UTC (permalink / raw)
  To: QEMU

[-- Attachment #1: Type: text/plain, Size: 866 bytes --]

some 8 years ago this patch was sent  to qemu-devel:

https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg05333.html
"[Qemu-devel] [PATCH 7/7] Add ALSA ioctls"

I wonder why it was rejected, may be as part of series?

Right now I use OSS Proxy Daemon providing oss and ALSA output at the same
time, so qemu-i386 /usr/bin/mplayer -ao oss still works, but this is recent
addition to my system and having  normal ALSA output for mplayer and co
will be useful for me, at least.

I can try to reapply it to current  git. But it will be sad if it was
rejected due to some deeper reasons I do not understand (for example I only
recently noted that qemu plugins basically only for observation, not for
altering qemu internals.)

Any comments, memories on this functionality?

PS: please add me to cc, I am not subscribed to qemu-devel (only watch it
via web-interface)

[-- Attachment #2: Type: text/html, Size: 1154 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: ALSA support in qemu-user?
  2024-10-14  1:18 ALSA support in qemu-user? Andrew Randrianasulu
@ 2024-10-14  9:06 ` Peter Maydell
  2024-10-14  9:21   ` Thomas Huth
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Maydell @ 2024-10-14  9:06 UTC (permalink / raw)
  To: Andrew Randrianasulu; +Cc: QEMU

On Mon, 14 Oct 2024 at 02:13, Andrew Randrianasulu
<randrianasulu@gmail.com> wrote:
>
> some 8 years ago this patch was sent  to qemu-devel:
>
> https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg05333.html
> "[Qemu-devel] [PATCH 7/7] Add ALSA ioctls"
>
> I wonder why it was rejected, may be as part of series?

Hard to say from this distance, but looking at the patch
I think it probably was just that it was on the end of
a series that did a bunch of other things and the earlier
patches in the series had issues.

thanks
-- PMM


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: ALSA support in qemu-user?
  2024-10-14  9:06 ` Peter Maydell
@ 2024-10-14  9:21   ` Thomas Huth
  2024-10-14 14:26     ` Andrew Randrianasulu
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Huth @ 2024-10-14  9:21 UTC (permalink / raw)
  To: Peter Maydell, Andrew Randrianasulu; +Cc: QEMU

On 14/10/2024 11.06, Peter Maydell wrote:
> On Mon, 14 Oct 2024 at 02:13, Andrew Randrianasulu
> <randrianasulu@gmail.com> wrote:
>>
>> some 8 years ago this patch was sent  to qemu-devel:
>>
>> https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg05333.html
>> "[Qemu-devel] [PATCH 7/7] Add ALSA ioctls"
>>
>> I wonder why it was rejected, may be as part of series?
> 
> Hard to say from this distance, but looking at the patch
> I think it probably was just that it was on the end of
> a series that did a bunch of other things and the earlier
> patches in the series had issues.

Yes, looks like there were review comments on the series that were not 
addressed:

  https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg05557.html
  https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg05364.html

But mainly one of the problems were that the patches haven't been send in a 
proper threaded way, so it was hard to follow the series:

  https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg05546.html

Anyway, looking at the other patches, it seems most of them were not related 
to ALSA, so you might be fine in just picking that patch, get it to work 
with the latest version of QEMU again and send just that single updated 
patch to this mailing list again. YMMV of course.

  Thomas



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: ALSA support in qemu-user?
  2024-10-14  9:21   ` Thomas Huth
@ 2024-10-14 14:26     ` Andrew Randrianasulu
  2024-10-15 14:06       ` Andrew Randrianasulu
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Randrianasulu @ 2024-10-14 14:26 UTC (permalink / raw)
  To: Thomas Huth; +Cc: Peter Maydell, QEMU


[-- Attachment #1.1: Type: text/plain, Size: 1963 bytes --]

On Mon, Oct 14, 2024 at 12:21 PM Thomas Huth <thuth@redhat.com> wrote:

> On 14/10/2024 11.06, Peter Maydell wrote:
> > On Mon, 14 Oct 2024 at 02:13, Andrew Randrianasulu
> > <randrianasulu@gmail.com> wrote:
> >>
> >> some 8 years ago this patch was sent  to qemu-devel:
> >>
> >> https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg05333.html
> >> "[Qemu-devel] [PATCH 7/7] Add ALSA ioctls"
> >>
> >> I wonder why it was rejected, may be as part of series?
> >
> > Hard to say from this distance, but looking at the patch
> > I think it probably was just that it was on the end of
> > a series that did a bunch of other things and the earlier
> > patches in the series had issues.
>
> Yes, looks like there were review comments on the series that were not
> addressed:
>
>   https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg05557.html
>   https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg05364.html
>
> But mainly one of the problems were that the patches haven't been send in
> a
> proper threaded way, so it was hard to follow the series:
>
>   https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg05546.html
>
> Anyway, looking at the other patches, it seems most of them were not
> related
> to ALSA, so you might be fine in just picking that patch, get it to work
> with the latest version of QEMU again and send just that single updated
> patch to this mailing list again. YMMV of course.
>

I tried  to apply patch but unfortunately mplayer still complain:

[AO_ALSA] alsa-lib: pcm_hw.c:1578:(snd1_pcm_hw_open_fd) USER_PVERSION failed

[AO_ALSA] alsa-lib: pcm_dmix.c:1092:(snd_pcm_dmix_open) unable to open slave
[AO_ALSA] Playback open error: Inappropriate ioctl for device

this is 32-bit mplayer/qemu-i386 on top of 64-bit kernel (x86_64)

qemu git 3860a2a8de56fad71db42f4ad120eb7eff03b51f

./configure --prefix=/usr --target-list=i386-linux-user




>
>   Thomas
>
>

[-- Attachment #1.2: Type: text/html, Size: 3235 bytes --]

[-- Attachment #2: 0001-linux-user-add-reminder-of-ALSA-ioctls.patch --]
[-- Type: text/x-patch, Size: 16581 bytes --]

From c9421b202cb0e02bd8882d5211ef051e9205e4bc Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <randrianasulu@gmail.com>
Date: Mon, 14 Oct 2024 17:09:05 +0300
Subject: [PATCH] linux-user: add reminder of ALSA ioctls

Original patch from Timothy Pearson
---
 linux-user/ioctls.h        |  58 +++++++++++
 linux-user/syscall_defs.h  |  59 +++++++++++
 linux-user/syscall_types.h | 200 +++++++++++++++++++++++++++++++++++--
 3 files changed, 311 insertions(+), 6 deletions(-)

diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index 3b41128fd7..3b0a134d13 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -575,6 +575,64 @@
   IOCTL(SOUND_MIXER_WRITE_LOUD, IOC_W, MK_PTR(TYPE_INT))
   IOCTL(SOUND_MIXER_WRITE_RECSRC, IOC_W, MK_PTR(TYPE_INT))
 
+  IOCTL(SNDRV_CTL_IOCTL_PVERSION, IOC_R, TYPE_INT)
+  IOCTL(SNDRV_CTL_IOCTL_CARD_INFO, IOC_R, MK_PTR(MK_STRUCT(STRUCT_snd_ctl_card_info)))
+  IOCTL(SNDRV_CTL_IOCTL_ELEM_LIST, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_snd_ctl_elem_list)))
+  IOCTL(SNDRV_CTL_IOCTL_ELEM_INFO, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_snd_ctl_elem_info)))
+  IOCTL(SNDRV_CTL_IOCTL_ELEM_READ, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_snd_ctl_elem_value)))
+  IOCTL(SNDRV_CTL_IOCTL_ELEM_WRITE, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_snd_ctl_elem_value)))
+  IOCTL(SNDRV_CTL_IOCTL_ELEM_LOCK, IOC_W, MK_PTR(MK_STRUCT(STRUCT_snd_ctl_elem_id)))
+  IOCTL(SNDRV_CTL_IOCTL_ELEM_UNLOCK, IOC_W, MK_PTR(MK_STRUCT(STRUCT_snd_ctl_elem_id)))
+  IOCTL(SNDRV_CTL_IOCTL_SUBSCRIBE_EVENTS, IOC_RW, TYPE_INT)
+  IOCTL(SNDRV_CTL_IOCTL_ELEM_ADD, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_snd_ctl_elem_info)))
+  IOCTL(SNDRV_CTL_IOCTL_ELEM_REPLACE, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_snd_ctl_elem_info)))
+  IOCTL(SNDRV_CTL_IOCTL_ELEM_REMOVE, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_snd_ctl_elem_id)))
+  IOCTL(SNDRV_CTL_IOCTL_TLV_READ, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_snd_ctl_tlv)))
+  IOCTL(SNDRV_CTL_IOCTL_TLV_WRITE, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_snd_ctl_tlv)))
+  IOCTL(SNDRV_CTL_IOCTL_TLV_COMMAND, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_snd_ctl_tlv)))
+  IOCTL(SNDRV_CTL_IOCTL_HWDEP_NEXT_DEVICE, IOC_RW, TYPE_INT)
+  IOCTL(SNDRV_CTL_IOCTL_HWDEP_INFO, IOC_R, MK_PTR(MK_STRUCT(STRUCT_snd_hwdep_info)))
+  IOCTL(SNDRV_CTL_IOCTL_PCM_NEXT_DEVICE, IOC_R, TYPE_INT)
+  IOCTL(SNDRV_CTL_IOCTL_PCM_INFO, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_snd_pcm_info)))
+  IOCTL(SNDRV_CTL_IOCTL_PCM_PREFER_SUBDEVICE, IOC_W, TYPE_INT)
+  IOCTL(SNDRV_CTL_IOCTL_RAWMIDI_NEXT_DEVICE, IOC_RW, TYPE_INT)
+  IOCTL(SNDRV_CTL_IOCTL_RAWMIDI_INFO, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_snd_rawmidi_info)))
+  IOCTL(SNDRV_CTL_IOCTL_RAWMIDI_PREFER_SUBDEVICE, IOC_W, TYPE_INT)
+  IOCTL(SNDRV_CTL_IOCTL_POWER, IOC_RW, TYPE_INT)
+  IOCTL(SNDRV_CTL_IOCTL_POWER_STATE, IOC_R, TYPE_INT)
+
+/* alsa stuff */
+  IOCTL(SNDRV_PCM_IOCTL_PVERSION        , IOC_R, TYPE_INT)
+  IOCTL(SNDRV_PCM_IOCTL_INFO            , IOC_R,MK_PTR(MK_STRUCT(STRUCT_snd_pcm_info)))
+  IOCTL(SNDRV_PCM_IOCTL_TSTAMP          , IOC_W, TYPE_INT)
+  IOCTL(SNDRV_PCM_IOCTL_TTSTAMP         , IOC_W, TYPE_INT)
+  IOCTL(SNDRV_PCM_IOCTL_HW_REFINE       , IOC_RW, MK_PTR(MK_STRUCT(STRUCT_snd_pcm_hw_params)))
+  IOCTL(SNDRV_PCM_IOCTL_HW_PARAMS       , IOC_RW, MK_PTR(MK_STRUCT(STRUCT_snd_pcm_hw_params)))
+  IOCTL(SNDRV_PCM_IOCTL_HW_FREE         , 0, TYPE_NULL)
+  IOCTL(SNDRV_PCM_IOCTL_SW_PARAMS       , IOC_RW, MK_PTR(MK_STRUCT(STRUCT_snd_pcm_sw_params)))
+  IOCTL(SNDRV_PCM_IOCTL_STATUS          , IOC_R,  MK_PTR(MK_STRUCT(STRUCT_snd_pcm_status)))
+  IOCTL(SNDRV_PCM_IOCTL_DELAY           , IOC_R, TYPE_ULONG)
+  IOCTL(SNDRV_PCM_IOCTL_HWSYNC          , 0, TYPE_NULL)
+  IOCTL(SNDRV_PCM_IOCTL_SYNC_PTR        , IOC_RW, MK_PTR(MK_STRUCT(STRUCT_snd_pcm_sync_ptr)))
+  IOCTL(SNDRV_PCM_IOCTL_STATUS_EXT      , IOC_RW, MK_PTR(MK_STRUCT(STRUCT_snd_pcm_status)))
+  IOCTL(SNDRV_PCM_IOCTL_CHANNEL_INFO    , IOC_R,MK_PTR(MK_STRUCT(STRUCT_snd_pcm_channel_info)))
+  IOCTL(SNDRV_PCM_IOCTL_PREPARE         , 0, TYPE_NULL)
+  IOCTL(SNDRV_PCM_IOCTL_RESET           , 0, TYPE_NULL)
+  IOCTL(SNDRV_PCM_IOCTL_START           , 0, TYPE_NULL)
+  IOCTL(SNDRV_PCM_IOCTL_DROP            , 0, TYPE_NULL)
+  IOCTL(SNDRV_PCM_IOCTL_DRAIN           , 0, TYPE_NULL)
+  IOCTL(SNDRV_PCM_IOCTL_PAUSE           , IOC_W, TYPE_INT)
+  IOCTL(SNDRV_PCM_IOCTL_REWIND          , IOC_W, TYPE_ULONG)
+  IOCTL(SNDRV_PCM_IOCTL_RESUME          , 0, TYPE_NULL)
+  IOCTL(SNDRV_PCM_IOCTL_XRUN            , 0, TYPE_NULL)
+  IOCTL(SNDRV_PCM_IOCTL_FORWARD         , IOC_W, TYPE_ULONG)
+  IOCTL(SNDRV_PCM_IOCTL_WRITEI_FRAMES   , IOC_W, MK_PTR(MK_STRUCT(STRUCT_snd_xferi)))
+  IOCTL(SNDRV_PCM_IOCTL_READI_FRAMES    , IOC_R, MK_PTR(MK_STRUCT(STRUCT_snd_xferi)))
+  IOCTL(SNDRV_PCM_IOCTL_WRITEN_FRAMES   , IOC_W, MK_PTR(MK_STRUCT(STRUCT_snd_xfern)))
+  IOCTL(SNDRV_PCM_IOCTL_READN_FRAMES    , IOC_R, MK_PTR(MK_STRUCT(STRUCT_snd_xfern)))
+  IOCTL(SNDRV_PCM_IOCTL_LINK            , IOC_W, TYPE_INT)
+  IOCTL(SNDRV_PCM_IOCTL_UNLINK          , 0, TYPE_NULL)
+
   IOCTL(SNDRV_TIMER_IOCTL_PVERSION, IOC_R, MK_PTR(TYPE_INT))
   IOCTL(SNDRV_TIMER_IOCTL_NEXT_DEVICE, IOC_RW,
         MK_PTR(MK_STRUCT(STRUCT_snd_timer_id)))
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 0ade83745e..a56dde12e8 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -2668,6 +2668,65 @@ struct target_user_cap_data {
     abi_uint inheritable;
 };
 
+/* asound defines */
+#define TARGET_SNDRV_CTL_IOCTL_PVERSION TARGET_IOR('U', 0x00, int)
+#define TARGET_SNDRV_CTL_IOCTL_CARD_INFO TARGET_IOR('U', 0x01, struct snd_ctl_card_info)
+#define TARGET_SNDRV_CTL_IOCTL_ELEM_LIST TARGET_IOWR('U', 0x10, struct snd_ctl_elem_list)
+#define TARGET_SNDRV_CTL_IOCTL_ELEM_INFO TARGET_IOWR('U', 0x11, struct snd_ctl_elem_info)
+#define TARGET_SNDRV_CTL_IOCTL_ELEM_READ TARGET_IOWR('U', 0x12, struct snd_ctl_elem_value)
+#define TARGET_SNDRV_CTL_IOCTL_ELEM_WRITE TARGET_IOWR('U', 0x13, struct snd_ctl_elem_value)
+#define TARGET_SNDRV_CTL_IOCTL_ELEM_LOCK TARGET_IOW('U', 0x14, struct snd_ctl_elem_id)
+#define TARGET_SNDRV_CTL_IOCTL_ELEM_UNLOCK TARGET_IOW('U', 0x15, struct snd_ctl_elem_id)
+#define TARGET_SNDRV_CTL_IOCTL_SUBSCRIBE_EVENTS TARGET_IOWR('U', 0x16, int)
+#define TARGET_SNDRV_CTL_IOCTL_ELEM_ADD TARGET_IOWR('U', 0x17, struct snd_ctl_elem_info)
+#define TARGET_SNDRV_CTL_IOCTL_ELEM_REPLACE TARGET_IOWR('U', 0x18, struct snd_ctl_elem_info)
+#define TARGET_SNDRV_CTL_IOCTL_ELEM_REMOVE TARGET_IOWR('U', 0x19, struct snd_ctl_elem_id)
+#define TARGET_SNDRV_CTL_IOCTL_TLV_READ TARGET_IOWR('U', 0x1a, struct snd_ctl_tlv)
+#define TARGET_SNDRV_CTL_IOCTL_TLV_WRITE TARGET_IOWR('U', 0x1b, struct snd_ctl_tlv)
+#define TARGET_SNDRV_CTL_IOCTL_TLV_COMMAND TARGET_IOWR('U', 0x1c, struct snd_ctl_tlv)
+#define TARGET_SNDRV_CTL_IOCTL_HWDEP_NEXT_DEVICE TARGET_IOWR('U', 0x20, int)
+#define TARGET_SNDRV_CTL_IOCTL_HWDEP_INFO TARGET_IOR('U', 0x21, struct snd_hwdep_info)
+#define TARGET_SNDRV_CTL_IOCTL_PCM_NEXT_DEVICE TARGET_IOR('U', 0x30, int)
+#define TARGET_SNDRV_CTL_IOCTL_PCM_INFO TARGET_IOWR('U', 0x31, struct snd_pcm_info)
+#define TARGET_SNDRV_CTL_IOCTL_PCM_PREFER_SUBDEVICE TARGET_IOW('U', 0x32, int)
+#define TARGET_SNDRV_CTL_IOCTL_RAWMIDI_NEXT_DEVICE TARGET_IOWR('U', 0x40, int)
+#define TARGET_SNDRV_CTL_IOCTL_RAWMIDI_INFO TARGET_IOWR('U', 0x41, struct snd_rawmidi_info)
+#define TARGET_SNDRV_CTL_IOCTL_RAWMIDI_PREFER_SUBDEVICE TARGET_IOW('U', 0x42, int)
+#define TARGET_SNDRV_CTL_IOCTL_POWER TARGET_IOWR('U', 0xd0, int)
+#define TARGET_SNDRV_CTL_IOCTL_POWER_STATE TARGET_IOR('U', 0xd1, int)
+
+#define TARGET_SNDRV_PCM_IOCTL_PVERSION TARGET_IOR('A', 0x00, int)
+#define TARGET_SNDRV_PCM_IOCTL_INFO TARGET_IOR('A', 0x01, struct snd_pcm_info)
+#define TARGET_SNDRV_PCM_IOCTL_TSTAMP TARGET_IOW('A', 0x02, int)
+#define TARGET_SNDRV_PCM_IOCTL_TTSTAMP TARGET_IOW('A', 0x03, int)
+#define TARGET_SNDRV_PCM_IOCTL_HW_REFINE TARGET_IOWR('A', 0x10, struct snd_pcm_hw_params)
+#define TARGET_SNDRV_PCM_IOCTL_HW_PARAMS TARGET_IOWR('A', 0x11, struct snd_pcm_hw_params)
+#define TARGET_SNDRV_PCM_IOCTL_HW_FREE TARGET_IO('A', 0x12)
+#define TARGET_SNDRV_PCM_IOCTL_SW_PARAMS TARGET_IOWR('A', 0x13, struct snd_pcm_sw_params)
+#define TARGET_SNDRV_PCM_IOCTL_STATUS TARGET_IOR('A', 0x20, struct snd_pcm_status)
+#define TARGET_SNDRV_PCM_IOCTL_DELAY TARGET_IOR('A', 0x21, long)
+#define TARGET_SNDRV_PCM_IOCTL_HWSYNC TARGET_IO('A', 0x22)
+#define TARGET_SNDRV_PCM_IOCTL_SYNC_PTR TARGET_IOWR('A', 0x23, struct snd_pcm_sync_ptr)
+#define TARGET_SNDRV_PCM_IOCTL_STATUS_EXT TARGET_IOWR('A', 0x24, struct snd_pcm_status)
+#define TARGET_SNDRV_PCM_IOCTL_CHANNEL_INFO TARGET_IOR('A', 0x32, struct snd_pcm_channel_info)
+#define TARGET_SNDRV_PCM_IOCTL_PREPARE TARGET_IO('A', 0x40)
+#define TARGET_SNDRV_PCM_IOCTL_RESET TARGET_IO('A', 0x41)
+#define TARGET_SNDRV_PCM_IOCTL_START TARGET_IO('A', 0x42)
+#define TARGET_SNDRV_PCM_IOCTL_DROP TARGET_IO('A', 0x43)
+#define TARGET_SNDRV_PCM_IOCTL_DRAIN TARGET_IO('A', 0x44)
+#define TARGET_SNDRV_PCM_IOCTL_PAUSE TARGET_IOW('A', 0x45, int)
+#define TARGET_SNDRV_PCM_IOCTL_REWIND TARGET_IOW('A', 0x46, unsigned long)
+#define TARGET_SNDRV_PCM_IOCTL_RESUME TARGET_IO('A', 0x47)
+#define TARGET_SNDRV_PCM_IOCTL_XRUN TARGET_IO('A', 0x48)
+#define TARGET_SNDRV_PCM_IOCTL_FORWARD TARGET_IOW('A', 0x49, unsigned long)
+#define TARGET_SNDRV_PCM_IOCTL_WRITEI_FRAMES TARGET_IOW('A', 0x50, struct snd_xferi)
+#define TARGET_SNDRV_PCM_IOCTL_READI_FRAMES TARGET_IOR('A', 0x51, struct snd_xferi)
+#define TARGET_SNDRV_PCM_IOCTL_WRITEN_FRAMES TARGET_IOW('A', 0x52, struct snd_xfern)
+#define TARGET_SNDRV_PCM_IOCTL_READN_FRAMES TARGET_IOR('A', 0x53, struct snd_xfern)
+#define TARGET_SNDRV_PCM_IOCTL_LINK TARGET_IOW('A', 0x60, int)
+#define TARGET_SNDRV_PCM_IOCTL_UNLINK TARGET_IO('A', 0x61)
+
+
 /* from kernel's include/linux/syslog.h */
 
 /* Close the log.  Currently a NOP. */
diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h
index 6dd7a80ce5..2c3048d34b 100644
--- a/linux-user/syscall_types.h
+++ b/linux-user/syscall_types.h
@@ -163,13 +163,201 @@ STRUCT(_kernel_timespec,
        TYPE_LONGLONG, /* tv_sec */
        TYPE_LONGLONG) /* tv_nsec */
 
+STRUCT(snd_ctl_card_info,
+       TYPE_INT, /* card */
+       TYPE_INT, /* pad */
+       MK_ARRAY(TYPE_CHAR, 16), /* id */
+       MK_ARRAY(TYPE_CHAR, 16), /* driver */
+       MK_ARRAY(TYPE_CHAR, 32), /* name */
+       MK_ARRAY(TYPE_CHAR, 80), /* longname */
+       MK_ARRAY(TYPE_CHAR, 16), /* reserved_ */
+       MK_ARRAY(TYPE_CHAR, 80), /* mixername */
+       MK_ARRAY(TYPE_CHAR, 128)) /* components */
+
+STRUCT(snd_ctl_elem_list,
+        TYPE_INT, /* offset */
+        TYPE_INT, /* space */
+        TYPE_INT, /* used */
+        TYPE_INT, /* count */
+        TYPE_PTRVOID, /* pids */
+        MK_ARRAY(TYPE_CHAR, 50)) /* reserved */
+
+STRUCT(snd_ctl_elem_info,
+        /* id struct */
+        TYPE_INT, /* numid */
+        TYPE_INT, /* iface */
+        TYPE_INT, /* device */
+        TYPE_INT, /* subdevice */
+        MK_ARRAY(TYPE_CHAR, SNDRV_CTL_ELEM_ID_NAME_MAXLEN), /* name */
+        TYPE_INT, /* index */
+
+        TYPE_INT, /*type */
+        TYPE_INT, /* access */
+        TYPE_INT, /* count */
+        TYPE_INT, /* owner */
+        MK_ARRAY(TYPE_CHAR, 128),  /* value */
+        MK_ARRAY(TYPE_CHAR, 8),    /* dimen */
+        MK_ARRAY(TYPE_CHAR, 56))   /* reserved */
+
+STRUCT(snd_ctl_elem_value,
+        /* id struct */
+        TYPE_INT, /* numid */
+        TYPE_INT, /* iface */
+        TYPE_INT, /* device */
+        TYPE_INT, /* subdevice */
+        MK_ARRAY(TYPE_CHAR, SNDRV_CTL_ELEM_ID_NAME_MAXLEN), /* name */
+        TYPE_INT, /* index */
+
+        TYPE_INT, /* indirect */
+        MK_ARRAY(TYPE_CHAR, 512), /* value */
+
+        /* timespec struct */
+        TYPE_LONG, /* tv_sec */
+        TYPE_LONG, /* tv_nsec */
+        MK_ARRAY(TYPE_CHAR, 112))   /* reserved */
+
+STRUCT(snd_ctl_elem_id,
+        TYPE_INT, /* numid */
+        TYPE_INT, /* iface */
+        TYPE_INT, /* device */
+        TYPE_INT, /* subdevice */
+        MK_ARRAY(TYPE_CHAR, SNDRV_CTL_ELEM_ID_NAME_MAXLEN), /* name */
+        TYPE_INT) /* index */
+
+STRUCT(snd_ctl_tlv,
+        TYPE_INT, /* numid */
+        TYPE_INT, /* length */
+        TYPE_INT) /* tlv */
+
+STRUCT(snd_hwdep_info,
+        TYPE_INT, /* device */
+        TYPE_INT, /* card */
+        MK_ARRAY(TYPE_CHAR, 64), /* id */
+        MK_ARRAY(TYPE_CHAR, 80), /* name */
+        TYPE_INT, /* iface */
+        MK_ARRAY(TYPE_CHAR, 64)) /* reserved */
+
+STRUCT(snd_pcm_info,
+        TYPE_INT, /* device */
+        TYPE_INT, /* subdevice */
+        TYPE_INT, /* stream */
+        TYPE_INT, /* card */
+        MK_ARRAY(TYPE_CHAR, 64), /* id */
+        MK_ARRAY(TYPE_CHAR, 80), /* name */
+        MK_ARRAY(TYPE_CHAR, 32), /* subname */
+        TYPE_INT, /* dev_class */
+        TYPE_INT, /* dev_subclass */
+        TYPE_INT, /* subdevices_count */
+        TYPE_INT, /* subdevices_avail */
+        MK_ARRAY(TYPE_CHAR, 16), /* sync */
+        MK_ARRAY(TYPE_CHAR, 64)) /* reserved */
+
+STRUCT(snd_rawmidi_info,
+        TYPE_INT, /* device */
+        TYPE_INT, /* subdevice */
+        TYPE_INT, /* stream */
+        TYPE_INT, /* card */
+        TYPE_INT, /* flags */
+        MK_ARRAY(TYPE_CHAR, 64), /* id */
+        MK_ARRAY(TYPE_CHAR, 80), /* name */
+        MK_ARRAY(TYPE_CHAR, 32), /* subname */
+        TYPE_INT, /* subdevices_count */
+        TYPE_INT, /* subdevices_avail */
+        MK_ARRAY(TYPE_CHAR, 64)) /* reserved */
+
+STRUCT(snd_pcm_hw_params,
+        TYPE_INT, /* flags */
+        MK_ARRAY(TYPE_INT, SNDRV_PCM_HW_PARAM_LAST_MASK - SNDRV_PCM_HW_PARAM_FIRST_MASK + 1), /* masks */
+        MK_ARRAY(TYPE_INT, ((SNDRV_MASK_MAX+31)/32) * 5), /* mres */
+        MK_ARRAY(TYPE_INT, 6 * (SNDRV_PCM_HW_PARAM_LAST_INTERVAL - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL + 1)), /* snd_interval */
+        MK_ARRAY(TYPE_INT, 6 * 9), /* ires */
+        TYPE_INT, /* rmask */
+        TYPE_INT, /* cmask */
+        TYPE_INT, /* info */
+        TYPE_INT, /* msbits */
+        TYPE_INT, /* rate_num */
+        TYPE_INT, /* rate_den */
+        TYPE_LONG, /* fifo_size */
+        MK_ARRAY(TYPE_CHAR, 64)) /* reserved */
+
+STRUCT(snd_pcm_sw_params,
+        TYPE_INT, /* tstamp_mode */
+        TYPE_INT, /* period_step */
+        TYPE_INT, /* sleep_min */
+        TYPE_LONG, /* avail_min */
+        TYPE_LONG, /* xfer_align */
+        TYPE_LONG, /* start_threshold */
+        TYPE_LONG, /* stop_threshold */
+        TYPE_LONG, /* silence_threshold */
+        TYPE_LONG, /* silence_size */
+        TYPE_LONG, /* boundary */
+        TYPE_INT, /* proto */
+        TYPE_INT, /* tstamp_type */
+        MK_ARRAY(TYPE_CHAR, 56)) /* reserved */
+
+STRUCT(snd_pcm_status,
+        TYPE_INT, /* state */
+
+        /* timespec struct */
+        TYPE_LONG, /* tv_sec */
+        TYPE_LONG, /* tv_nsec */
+
+        /* timespec struct */
+        TYPE_LONG, /* tv_sec */
+        TYPE_LONG, /* tv_nsec */
+
+        TYPE_LONG, /* appl_ptr */
+        TYPE_LONG, /* hw_ptr */
+        TYPE_LONG, /* delay */
+        TYPE_LONG, /* avail */
+        TYPE_LONG, /* avail_max */
+        TYPE_LONG, /* overrange */
+        TYPE_INT, /* suspended_state */
+        TYPE_INT, /* audio_tstamp_data */
+
+        /* timespec struct */
+        TYPE_LONG, /* tv_sec */
+        TYPE_LONG, /* tv_nsec */
+
+        /* timespec struct */
+        TYPE_LONG, /* tv_sec */
+        TYPE_LONG, /* tv_nsec */
+
+        TYPE_INT, /* audio_tstamp_accuracy */
+        MK_ARRAY(TYPE_CHAR, 36)) /* reserved */
+
+STRUCT(snd_pcm_sync_ptr,
+        TYPE_INT, /* flags */
+        MK_ARRAY(TYPE_CHAR, 64), /* reserved */
+        MK_ARRAY(TYPE_CHAR, 64)) /* reserved */
+
+STRUCT(snd_pcm_channel_info,
+        TYPE_INT, /*  channel */
+        TYPE_ULONGLONG, /*  offset */
+        TYPE_INT, /*  first */
+        TYPE_INT) /*  step */
+
+STRUCT(snd_xferi,
+        TYPE_LONG, /* result */
+        TYPE_PTRVOID, /* buf */
+        TYPE_LONG) /* frames */
+
+STRUCT(snd_xfern,
+        TYPE_LONG, /* result */
+        TYPE_PTRVOID, /* bufs */
+        TYPE_LONG) /* frames */
+
 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 */
+        /* timespec struct */
+        TYPE_LONG, /* tv_sec */
+        TYPE_LONG, /* tv_nsec */
+
+        TYPE_INT, /* resolution */
+        TYPE_INT, /* lost */
+        TYPE_INT, /* overrun */
+        TYPE_INT, /* queue */
+        MK_ARRAY(TYPE_CHAR, 64)) /* reserved */
+
 
 /* loop device ioctls */
 STRUCT(loop_info,
-- 
2.46.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: ALSA support in qemu-user?
  2024-10-14 14:26     ` Andrew Randrianasulu
@ 2024-10-15 14:06       ` Andrew Randrianasulu
  2024-10-15 21:50         ` Andrew Randrianasulu
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Randrianasulu @ 2024-10-15 14:06 UTC (permalink / raw)
  To: Thomas Huth; +Cc: Peter Maydell, QEMU


[-- Attachment #1.1: Type: text/plain, Size: 2999 bytes --]

пн, 14 окт. 2024 г., 17:26 Andrew Randrianasulu <randrianasulu@gmail.com>:

>
>
> On Mon, Oct 14, 2024 at 12:21 PM Thomas Huth <thuth@redhat.com> wrote:
>
>> On 14/10/2024 11.06, Peter Maydell wrote:
>> > On Mon, 14 Oct 2024 at 02:13, Andrew Randrianasulu
>> > <randrianasulu@gmail.com> wrote:
>> >>
>> >> some 8 years ago this patch was sent  to qemu-devel:
>> >>
>> >> https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg05333.html
>> >> "[Qemu-devel] [PATCH 7/7] Add ALSA ioctls"
>> >>
>> >> I wonder why it was rejected, may be as part of series?
>> >
>> > Hard to say from this distance, but looking at the patch
>> > I think it probably was just that it was on the end of
>> > a series that did a bunch of other things and the earlier
>> > patches in the series had issues.
>>
>> Yes, looks like there were review comments on the series that were not
>> addressed:
>>
>>   https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg05557.html
>>   https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg05364.html
>>
>> But mainly one of the problems were that the patches haven't been send in
>> a
>> proper threaded way, so it was hard to follow the series:
>>
>>   https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg05546.html
>>
>> Anyway, looking at the other patches, it seems most of them were not
>> related
>> to ALSA, so you might be fine in just picking that patch, get it to work
>> with the latest version of QEMU again and send just that single updated
>> patch to this mailing list again. YMMV of course.
>>
>
> I tried  to apply patch but unfortunately mplayer still complain:
>
> [AO_ALSA] alsa-lib: pcm_hw.c:1578:(snd1_pcm_hw_open_fd) USER_PVERSION
> failed
>
> [AO_ALSA] alsa-lib: pcm_dmix.c:1092:(snd_pcm_dmix_open) unable to open
> slave
> [AO_ALSA] Playback open error: Inappropriate ioctl for device
>
> this is 32-bit mplayer/qemu-i386 on top of 64-bit kernel (x86_64)
>
> qemu git 3860a2a8de56fad71db42f4ad120eb7eff03b51f
>
> ./configure --prefix=/usr --target-list=i386-linux-user
>
>
so, may be qemu internal changed a bit, I tried to add MK_PTR around
int/long types in ioctl.h like it was done for alsa timer ctl before

but what to do with unsingned long in syscall_defs.h ?

there is abi_int so I changed simple  int to that.

Anyway with attached patch it still fails to play, while arecord -L /aplay
-L show their lists

normal speaker-test run:

strace -e ioctl /usr/bin/speaker-test 2>&1 | grep PVERSION
 ioctl(3, SNDRV_CTL_IOCTL_PVERSION, 0xff8bd008) = 0

   ioctl(4, AGPIOC_INFO or SNDRV_PCM_IOCTL_PVERSION, 0xff8bcefc) = 0

 ioctl(4, AGPIOC_RESERVE or SNDRV_PCM_IOCTL_USER_PVERSION, 0xff8bcf08) = 0

failed run with qemu-i386:

strace -e ioctl qemu-i386 /usr/bin/speaker-test 2>&1 | grep PVERSION
 ioctl(3, SNDRV_CTL_IOCTL_PVERSION, 0xff8410ac) = 0

 ioctl(4, AGPIOC_INFO or SNDRV_PCM_IOCTL_PVERSION, 0xff8410ac) = 0



>
>
>>
>>   Thomas
>>
>>

[-- Attachment #1.2: Type: text/html, Size: 5795 bytes --]

[-- Attachment #2: 0002-linux-user-trying-yo-fix-alsa-ioctls-not-working-yet.patch --]
[-- Type: application/x-patch, Size: 10792 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: ALSA support in qemu-user?
  2024-10-15 14:06       ` Andrew Randrianasulu
@ 2024-10-15 21:50         ` Andrew Randrianasulu
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Randrianasulu @ 2024-10-15 21:50 UTC (permalink / raw)
  To: Thomas Huth; +Cc: Peter Maydell, QEMU

[-- Attachment #1: Type: text/plain, Size: 3539 bytes --]

вт, 15 окт. 2024 г., 17:06 Andrew Randrianasulu <randrianasulu@gmail.com>:

>
>
> пн, 14 окт. 2024 г., 17:26 Andrew Randrianasulu <randrianasulu@gmail.com>:
>
>>
>>
>> On Mon, Oct 14, 2024 at 12:21 PM Thomas Huth <thuth@redhat.com> wrote:
>>
>>> On 14/10/2024 11.06, Peter Maydell wrote:
>>> > On Mon, 14 Oct 2024 at 02:13, Andrew Randrianasulu
>>> > <randrianasulu@gmail.com> wrote:
>>> >>
>>> >> some 8 years ago this patch was sent  to qemu-devel:
>>> >>
>>> >> https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg05333.html
>>> >> "[Qemu-devel] [PATCH 7/7] Add ALSA ioctls"
>>> >>
>>> >> I wonder why it was rejected, may be as part of series?
>>> >
>>> > Hard to say from this distance, but looking at the patch
>>> > I think it probably was just that it was on the end of
>>> > a series that did a bunch of other things and the earlier
>>> > patches in the series had issues.
>>>
>>> Yes, looks like there were review comments on the series that were not
>>> addressed:
>>>
>>>   https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg05557.html
>>>   https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg05364.html
>>>
>>> But mainly one of the problems were that the patches haven't been send
>>> in a
>>> proper threaded way, so it was hard to follow the series:
>>>
>>>   https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg05546.html
>>>
>>> Anyway, looking at the other patches, it seems most of them were not
>>> related
>>> to ALSA, so you might be fine in just picking that patch, get it to work
>>> with the latest version of QEMU again and send just that single updated
>>> patch to this mailing list again. YMMV of course.
>>>
>>
>> I tried  to apply patch but unfortunately mplayer still complain:
>>
>> [AO_ALSA] alsa-lib: pcm_hw.c:1578:(snd1_pcm_hw_open_fd) USER_PVERSION
>> failed
>>
>> [AO_ALSA] alsa-lib: pcm_dmix.c:1092:(snd_pcm_dmix_open) unable to open
>> slave
>> [AO_ALSA] Playback open error: Inappropriate ioctl for device
>>
>> this is 32-bit mplayer/qemu-i386 on top of 64-bit kernel (x86_64)
>>
>> qemu git 3860a2a8de56fad71db42f4ad120eb7eff03b51f
>>
>> ./configure --prefix=/usr --target-list=i386-linux-user
>>
>>
> so, may be qemu internal changed a bit, I tried to add MK_PTR around
> int/long types in ioctl.h like it was done for alsa timer ctl before
>
> but what to do with unsingned long in syscall_defs.h ?
>
> there is abi_int so I changed simple  int to that.
>
> Anyway with attached patch it still fails to play, while arecord -L /aplay
> -L show their lists
>
> normal speaker-test run:
>
> strace -e ioctl /usr/bin/speaker-test 2>&1 | grep PVERSION
>  ioctl(3, SNDRV_CTL_IOCTL_PVERSION, 0xff8bd008) = 0
>
>    ioctl(4, AGPIOC_INFO or SNDRV_PCM_IOCTL_PVERSION, 0xff8bcefc) = 0
>
>  ioctl(4, AGPIOC_RESERVE or SNDRV_PCM_IOCTL_USER_PVERSION, 0xff8bcf08) = 0
>
> failed run with qemu-i386:
>
> strace -e ioctl qemu-i386 /usr/bin/speaker-test 2>&1 | grep PVERSION
>  ioctl(3, SNDRV_CTL_IOCTL_PVERSION, 0xff8410ac) = 0
>
>  ioctl(4, AGPIOC_INFO or SNDRV_PCM_IOCTL_PVERSION, 0xff8410ac) = 0
>


Now, this is strange.

With additional patch aplay/arecord -l show truncated list of hardware
devices.

If I set

IOCTL(SNDRV_CTL_IOCTL_PCM_NEXT_DEVICE, IOC_R, TYPE_INT)

instead ot MK_PTR(TYPE_INT) in

linux-user/iocts.h

with my two patches

then arecord/aplay under qemu-i386 enumerates all host devices again ...



>
>
>>
>>
>>>
>>>   Thomas
>>>
>>>

[-- Attachment #2: Type: text/html, Size: 7328 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-10-15 21:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-14  1:18 ALSA support in qemu-user? Andrew Randrianasulu
2024-10-14  9:06 ` Peter Maydell
2024-10-14  9:21   ` Thomas Huth
2024-10-14 14:26     ` Andrew Randrianasulu
2024-10-15 14:06       ` Andrew Randrianasulu
2024-10-15 21:50         ` Andrew Randrianasulu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).