Commit 523111e7efb8ad61e1d91edebee1702a45873b04
1 parent
24859b68
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
Showing
1 changed file
with
15 additions
and
12 deletions
hw/wm8750.c
... | ... | @@ -55,10 +55,10 @@ static inline void wm8750_in_load(struct wm8750_s *s) |
55 | 55 | |
56 | 56 | static inline void wm8750_out_flush(struct wm8750_s *s) |
57 | 57 | { |
58 | - int sent; | |
59 | - if (!s->idx_out) | |
60 | - return; | |
61 | - sent = AUD_write(*s->out[0], s->data_out, s->idx_out); | |
58 | + int sent = 0; | |
59 | + while (sent < s->idx_out) | |
60 | + sent += AUD_write(*s->out[0], s->data_out + sent, s->idx_out - sent) | |
61 | + ?: s->idx_out; | |
62 | 62 | s->idx_out = 0; |
63 | 63 | } |
64 | 64 | |
... | ... | @@ -67,19 +67,20 @@ static void wm8750_audio_in_cb(void *opaque, int avail_b) |
67 | 67 | struct wm8750_s *s = (struct wm8750_s *) opaque; |
68 | 68 | s->req_in = avail_b; |
69 | 69 | s->data_req(s->opaque, s->req_out >> 2, avail_b >> 2); |
70 | - | |
71 | -#if 0 | |
72 | - wm8750_in_load(s); | |
73 | -#endif | |
74 | 70 | } |
75 | 71 | |
76 | 72 | static void wm8750_audio_out_cb(void *opaque, int free_b) |
77 | 73 | { |
78 | 74 | struct wm8750_s *s = (struct wm8750_s *) opaque; |
79 | 75 | |
80 | - s->req_out = free_b; | |
81 | - s->data_req(s->opaque, free_b >> 2, s->req_in >> 2); | |
82 | - wm8750_out_flush(s); | |
76 | + if (s->idx_out >= free_b) { | |
77 | + s->idx_out = free_b; | |
78 | + s->req_out = 0; | |
79 | + wm8750_out_flush(s); | |
80 | + } else | |
81 | + s->req_out = free_b - s->idx_out; | |
82 | + | |
83 | + s->data_req(s->opaque, s->req_out >> 2, s->req_in >> 2); | |
83 | 84 | } |
84 | 85 | |
85 | 86 | struct wm_rate_s { |
... | ... | @@ -121,7 +122,7 @@ static const struct wm_rate_s wm_rate_table[] = { |
121 | 122 | { 512, 24000, 512, 24000 }, /* SR: 11100 */ |
122 | 123 | { 768, 24000, 768, 24000 }, /* SR: 11101 */ |
123 | 124 | { 128, 88200, 128, 88200 }, /* SR: 11110 */ |
124 | - { 192, 88200, 128, 88200 }, /* SR: 11111 */ | |
125 | + { 192, 88200, 192, 88200 }, /* SR: 11111 */ | |
125 | 126 | }; |
126 | 127 | |
127 | 128 | static void wm8750_set_format(struct wm8750_s *s) |
... | ... | @@ -597,6 +598,7 @@ i2c_slave *wm8750_init(i2c_bus *bus, AudioState *audio) |
597 | 598 | return &s->i2c; |
598 | 599 | } |
599 | 600 | |
601 | +#if 0 | |
600 | 602 | static void wm8750_fini(i2c_slave *i2c) |
601 | 603 | { |
602 | 604 | struct wm8750_s *s = (struct wm8750_s *) i2c; |
... | ... | @@ -604,6 +606,7 @@ static void wm8750_fini(i2c_slave *i2c) |
604 | 606 | AUD_remove_card(&s->card); |
605 | 607 | qemu_free(s); |
606 | 608 | } |
609 | +#endif | |
607 | 610 | |
608 | 611 | void wm8750_data_req_set(i2c_slave *i2c, |
609 | 612 | void (*data_req)(void *, int, int), void *opaque) | ... | ... |