qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [4254] Let WM8750 users write to audio buffer directly.
@ 2008-04-26 12:00 Andrzej Zaborowski
  2008-04-26 13:29 ` Jan Kiszka
  0 siblings, 1 reply; 7+ messages in thread
From: Andrzej Zaborowski @ 2008-04-26 12:00 UTC (permalink / raw)
  To: qemu-devel

Revision: 4254
          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4254
Author:   balrog
Date:     2008-04-26 12:00:18 +0000 (Sat, 26 Apr 2008)

Log Message:
-----------
Let WM8750 users write to audio buffer directly.

Modified Paths:
--------------
    trunk/hw/i2c.h
    trunk/hw/musicpal.c
    trunk/hw/wm8750.c

Modified: trunk/hw/i2c.h
===================================================================
--- trunk/hw/i2c.h	2008-04-26 01:43:07 UTC (rev 4253)
+++ trunk/hw/i2c.h	2008-04-26 12:00:18 UTC (rev 4254)
@@ -67,6 +67,8 @@
                 void (*data_req)(void *, int, int), void *opaque);
 void wm8750_dac_dat(void *opaque, uint32_t sample);
 uint32_t wm8750_adc_dat(void *opaque);
+void *wm8750_dac_buffer(void *opaque, int samples);
+void wm8750_dac_commit(void *opaque);
 
 /* ssd0303.c */
 void ssd0303_init(DisplayState *ds, i2c_bus *bus, int address);

Modified: trunk/hw/musicpal.c
===================================================================
--- trunk/hw/musicpal.c	2008-04-26 01:43:07 UTC (rev 4253)
+++ trunk/hw/musicpal.c	2008-04-26 12:00:18 UTC (rev 4254)
@@ -254,7 +254,7 @@
 static void audio_callback(void *opaque, int free_out, int free_in)
 {
     musicpal_audio_state *s = opaque;
-    int16_t channel[2];
+    int16_t *codec_buffer;
     int pos, block_size;
 
     if (!(s->playback_mode & MP_AUDIO_PLAYBACK_EN))
@@ -270,17 +270,19 @@
         return;
 
     if (s->playback_mode & MP_AUDIO_16BIT_SAMPLE)
-        for (pos = 0; pos < block_size; pos += 4)
-            wm8750_dac_dat(s->wm,
-                    *(uint32_t *)(s->target_buffer + s->play_pos + pos));
-    else
+        memcpy(wm8750_dac_buffer(s->wm, block_size >> 2), 
+               (uint32_t *)(s->target_buffer + s->play_pos),
+               block_size);
+    else {
+        codec_buffer = wm8750_dac_buffer(s->wm, block_size >> 1);
         for (pos = 0; pos < block_size; pos += 2) {
-            channel[0] = cpu_to_le16(2 *
+            *codec_buffer++ = cpu_to_le16(2 *
                     *(int8_t *)(s->target_buffer + s->play_pos + pos));
-            channel[1] = cpu_to_le16(2 *
+            *codec_buffer++ = cpu_to_le16(2 *
                     *(int8_t *)(s->target_buffer + s->play_pos + pos + 1));
-            wm8750_dac_dat(s->wm, channel[0] | (channel[1] << 16));
         }
+    }
+    wm8750_dac_commit(s->wm);
 
     s->last_free = free_out - block_size;
 

Modified: trunk/hw/wm8750.c
===================================================================
--- trunk/hw/wm8750.c	2008-04-26 01:43:07 UTC (rev 4253)
+++ trunk/hw/wm8750.c	2008-04-26 12:00:18 UTC (rev 4254)
@@ -627,6 +627,24 @@
         wm8750_out_flush(s);
 }
 
+void *wm8750_dac_buffer(void *opaque, int samples)
+{
+    struct wm8750_s *s = (struct wm8750_s *) opaque;
+    /* XXX: Should check if there are <i>samples</i> free samples available */
+    void *ret = s->data_out + s->idx_out;
+
+    s->idx_out += samples << 2;
+    s->req_out -= samples << 2;
+    return ret;
+}
+
+void wm8750_dac_commit(void *opaque)
+{
+    struct wm8750_s *s = (struct wm8750_s *) opaque;
+
+    return wm8750_out_flush(s);
+}
+
 uint32_t wm8750_adc_dat(void *opaque)
 {
     struct wm8750_s *s = (struct wm8750_s *) opaque;

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

end of thread, other threads:[~2008-04-27 23:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-26 12:00 [Qemu-devel] [4254] Let WM8750 users write to audio buffer directly Andrzej Zaborowski
2008-04-26 13:29 ` Jan Kiszka
2008-04-26 13:50   ` andrzej zaborowski
2008-04-26 14:11     ` Jan Kiszka
2008-04-26 20:10       ` andrzej zaborowski
2008-04-26 23:31         ` Jan Kiszka
2008-04-27 23:29           ` andrzej zaborowski

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