qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] no mmap for alsa
@ 2007-07-03 17:41 Alexander Graf
  2007-07-03 18:17 ` Alexander Graf
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Graf @ 2007-07-03 17:41 UTC (permalink / raw)
  To: qemu-devel

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

Hi,

this is the last patch necessary to get pcm alsa running for i386-apps
on ppc.

Alsa does some fancy magic with mmap to share information with the
kernel. This is completely fine as long as we're talking about
arch(kernel) == arch(userspace), which apparently is not the case when
using qemu-user.
As a more or less hacky workaround on that I just disabled the mmap
calls alsa-lib uses to initiate communication with the kernel. If these
fail, alsa reverts to other means of communication which get converted.

Alex

[-- Attachment #2: alsa_mmap --]
[-- Type: text/plain, Size: 1136 bytes --]

Index: qemu/linux-user/mmap.c
===================================================================
--- qemu.orig/linux-user/mmap.c
+++ qemu/linux-user/mmap.c
@@ -152,6 +152,9 @@ static int mmap_frag(target_ulong real_s
     return 0;
 }
 
+#define SNDRV_PCM_MMAP_OFFSET_STATUS  0x80000000;
+#define SNDRV_PCM_MMAP_OFFSET_CONTROL 0x81000000;
+
 /* NOTE: all the constants are the HOST ones */
 long target_mmap(target_ulong start, target_ulong len, int prot, 
                  int flags, int fd, target_ulong offset)
@@ -192,6 +195,17 @@ long target_mmap(target_ulong start, tar
     }
 #endif
 
+    /* Alsa tries to communcate with the kernel via mmap. This usually
+     * is a good idea when user- and kernelspace are running on the 
+     * same architecture but does not work out when not. To make alsa
+     * not to use mmap, we can just have it fail on the mmap calls that
+     * would initiate this.
+     */
+    if(offset == SNDRV_PCM_MMAP_OFFSET_STATUS || offset == SNDRV_PCM_MMAP_OFFSET_CONTROL) {
+	errno = EINVAL;
+	return -1;
+    }
+
     if (offset & ~TARGET_PAGE_MASK) {
         errno = EINVAL;
         return -1;

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

* Re: [Qemu-devel] [PATCH] no mmap for alsa
  2007-07-03 17:41 [Qemu-devel] [PATCH] no mmap for alsa Alexander Graf
@ 2007-07-03 18:17 ` Alexander Graf
  0 siblings, 0 replies; 2+ messages in thread
From: Alexander Graf @ 2007-07-03 18:17 UTC (permalink / raw)
  To: qemu-devel

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

Oops, the patch did not compile. This is the updated version.

Alex

[-- Attachment #2: alsa_mmap --]
[-- Type: text/plain, Size: 1134 bytes --]

Index: qemu/linux-user/mmap.c
===================================================================
--- qemu.orig/linux-user/mmap.c
+++ qemu/linux-user/mmap.c
@@ -152,6 +152,9 @@ static int mmap_frag(target_ulong real_s
     return 0;
 }
 
+#define SNDRV_PCM_MMAP_OFFSET_STATUS  0x80000000
+#define SNDRV_PCM_MMAP_OFFSET_CONTROL 0x81000000
+
 /* NOTE: all the constants are the HOST ones */
 long target_mmap(target_ulong start, target_ulong len, int prot, 
                  int flags, int fd, target_ulong offset)
@@ -192,6 +195,17 @@ long target_mmap(target_ulong start, tar
     }
 #endif
 
+    /* Alsa tries to communcate with the kernel via mmap. This usually
+     * is a good idea when user- and kernelspace are running on the 
+     * same architecture but does not work out when not. To make alsa
+     * not to use mmap, we can just have it fail on the mmap calls that
+     * would initiate this.
+     */
+    if(offset == SNDRV_PCM_MMAP_OFFSET_STATUS || offset == SNDRV_PCM_MMAP_OFFSET_CONTROL) {
+	errno = EINVAL;
+	return -1;
+    }
+
     if (offset & ~TARGET_PAGE_MASK) {
         errno = EINVAL;
         return -1;

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

end of thread, other threads:[~2007-07-03 18:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-03 17:41 [Qemu-devel] [PATCH] no mmap for alsa Alexander Graf
2007-07-03 18:17 ` Alexander Graf

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).