From cf7d1a606715376d0dfda350652612faaac04d90 Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <randrianasulu@gmail.com>
Date: Tue, 15 Oct 2024 16:52:24 +0300
Subject: [PATCH 2/2] linux-user: trying yo fix alsa ioctls, not working yet

---
 linux-user/ioctls.h       | 36 ++++++++++++++++++------------------
 linux-user/syscall_defs.h | 28 ++++++++++++++--------------
 2 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index 3b0a134d13..f280d76b76 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -575,7 +575,7 @@
   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_PVERSION, IOC_R, MK_PTR(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)))
@@ -583,54 +583,54 @@
   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_SUBSCRIBE_EVENTS, IOC_RW, MK_PTR(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_NEXT_DEVICE, IOC_RW, MK_PTR(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_NEXT_DEVICE, IOC_R, MK_PTR(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_PCM_PREFER_SUBDEVICE, IOC_W, MK_PTR(TYPE_INT))
+  IOCTL(SNDRV_CTL_IOCTL_RAWMIDI_NEXT_DEVICE, IOC_RW, MK_PTR(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_RAWMIDI_PREFER_SUBDEVICE, IOC_W, MK_PTR(TYPE_INT))
+  IOCTL(SNDRV_CTL_IOCTL_POWER, IOC_RW, MK_PTR(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_PVERSION        , IOC_R, MK_PTR(TYPE_INT))
+  IOCTL(SNDRV_PCM_IOCTL_INFO            , IOC_R, MK_PTR(MK_STRUCT(STRUCT_snd_pcm_info)))
+  IOCTL(SNDRV_PCM_IOCTL_TSTAMP          , IOC_W, MK_PTR(TYPE_INT))
+  IOCTL(SNDRV_PCM_IOCTL_TTSTAMP         , IOC_W, MK_PTR(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_DELAY           , IOC_R, MK_PTR(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_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_PAUSE           , IOC_W, MK_PTR(TYPE_INT))
+  IOCTL(SNDRV_PCM_IOCTL_REWIND          , IOC_W, MK_PTR(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_FORWARD         , IOC_W, MK_PTR(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_LINK            , IOC_W, MK_PTR(TYPE_INT))
   IOCTL(SNDRV_PCM_IOCTL_UNLINK          , 0, TYPE_NULL)
 
   IOCTL(SNDRV_TIMER_IOCTL_PVERSION, IOC_R, MK_PTR(TYPE_INT))
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index a56dde12e8..90e1111cd4 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -2669,7 +2669,7 @@ struct target_user_cap_data {
 };
 
 /* asound defines */
-#define TARGET_SNDRV_CTL_IOCTL_PVERSION TARGET_IOR('U', 0x00, int)
+#define TARGET_SNDRV_CTL_IOCTL_PVERSION TARGET_IOR('U', 0x00, abi_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)
@@ -2684,27 +2684,27 @@ struct target_user_cap_data {
 #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_NEXT_DEVICE TARGET_IOWR('U', 0x20, abi_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_NEXT_DEVICE TARGET_IOR('U', 0x30, abi_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_PCM_PREFER_SUBDEVICE TARGET_IOW('U', 0x32, abi_int)
+#define TARGET_SNDRV_CTL_IOCTL_RAWMIDI_NEXT_DEVICE TARGET_IOWR('U', 0x40, abi_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_CTL_IOCTL_RAWMIDI_PREFER_SUBDEVICE TARGET_IOW('U', 0x42, abi_int)
+#define TARGET_SNDRV_CTL_IOCTL_POWER TARGET_IOWR('U', 0xd0, abi_int)
+#define TARGET_SNDRV_CTL_IOCTL_POWER_STATE TARGET_IOR('U', 0xd1, abi_int)
 
-#define TARGET_SNDRV_PCM_IOCTL_PVERSION TARGET_IOR('A', 0x00, int)
+#define TARGET_SNDRV_PCM_IOCTL_PVERSION TARGET_IOR('A', 0x00, abi_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_TSTAMP TARGET_IOW('A', 0x02, abi_int)
+#define TARGET_SNDRV_PCM_IOCTL_TTSTAMP TARGET_IOW('A', 0x03, abi_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_DELAY TARGET_IOR('A', 0x21, abi_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)
@@ -2714,7 +2714,7 @@ struct target_user_cap_data {
 #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_PAUSE TARGET_IOW('A', 0x45, abi_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)
@@ -2723,7 +2723,7 @@ struct target_user_cap_data {
 #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_LINK TARGET_IOW('A', 0x60, abi_int)
 #define TARGET_SNDRV_PCM_IOCTL_UNLINK TARGET_IO('A', 0x61)
 
 
-- 
2.46.2

