aboutsummaryrefslogtreecommitdiff
path: root/hw/wm8750.c
diff options
context:
space:
mode:
authorbalrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162>2008-04-24 21:01:40 +0000
committerbalrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162>2008-04-24 21:01:40 +0000
commit523111e7efb8ad61e1d91edebee1702a45873b04 (patch)
tree7c1f8157670869410d4e60e16947526619b15921 /hw/wm8750.c
parent24859b68ee5178881abf13621477898417c0b6e3 (diff)
downloadqemu-523111e7efb8ad61e1d91edebee1702a45873b04.zip
qemu-523111e7efb8ad61e1d91edebee1702a45873b04.tar.gz
qemu-523111e7efb8ad61e1d91edebee1702a45873b04.tar.bz2
Improve audio api use in WM8750.
These are changes from http://svn.openmoko.org/trunk/src/host/qemu-neo1973/hw/wm8753.c that I forgot to push to WM8750. Some were suggested by malc. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4249 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw/wm8750.c')
-rw-r--r--hw/wm8750.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/hw/wm8750.c b/hw/wm8750.c
index 7d7f08b..c26961a 100644
--- a/hw/wm8750.c
+++ b/hw/wm8750.c
@@ -55,10 +55,10 @@ static inline void wm8750_in_load(struct wm8750_s *s)
static inline void wm8750_out_flush(struct wm8750_s *s)
{
- int sent;
- if (!s->idx_out)
- return;
- sent = AUD_write(*s->out[0], s->data_out, s->idx_out);
+ int sent = 0;
+ while (sent < s->idx_out)
+ sent += AUD_write(*s->out[0], s->data_out + sent, s->idx_out - sent)
+ ?: s->idx_out;
s->idx_out = 0;
}
@@ -67,19 +67,20 @@ static void wm8750_audio_in_cb(void *opaque, int avail_b)
struct wm8750_s *s = (struct wm8750_s *) opaque;
s->req_in = avail_b;
s->data_req(s->opaque, s->req_out >> 2, avail_b >> 2);
-
-#if 0
- wm8750_in_load(s);
-#endif
}
static void wm8750_audio_out_cb(void *opaque, int free_b)
{
struct wm8750_s *s = (struct wm8750_s *) opaque;
- s->req_out = free_b;
- s->data_req(s->opaque, free_b >> 2, s->req_in >> 2);
- wm8750_out_flush(s);
+ if (s->idx_out >= free_b) {
+ s->idx_out = free_b;
+ s->req_out = 0;
+ wm8750_out_flush(s);
+ } else
+ s->req_out = free_b - s->idx_out;
+
+ s->data_req(s->opaque, s->req_out >> 2, s->req_in >> 2);
}
struct wm_rate_s {
@@ -121,7 +122,7 @@ static const struct wm_rate_s wm_rate_table[] = {
{ 512, 24000, 512, 24000 }, /* SR: 11100 */
{ 768, 24000, 768, 24000 }, /* SR: 11101 */
{ 128, 88200, 128, 88200 }, /* SR: 11110 */
- { 192, 88200, 128, 88200 }, /* SR: 11111 */
+ { 192, 88200, 192, 88200 }, /* SR: 11111 */
};
static void wm8750_set_format(struct wm8750_s *s)
@@ -597,6 +598,7 @@ i2c_slave *wm8750_init(i2c_bus *bus, AudioState *audio)
return &s->i2c;
}
+#if 0
static void wm8750_fini(i2c_slave *i2c)
{
struct wm8750_s *s = (struct wm8750_s *) i2c;
@@ -604,6 +606,7 @@ static void wm8750_fini(i2c_slave *i2c)
AUD_remove_card(&s->card);
qemu_free(s);
}
+#endif
void wm8750_data_req_set(i2c_slave *i2c,
void (*data_req)(void *, int, int), void *opaque)