sim-card
/
qemu
Archived
10
0
Fork 0

Let WM8750 users write to audio buffer directly.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4254 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
balrog 2008-04-26 12:00:18 +00:00
parent c21c583a1d
commit 662caa6f91
3 changed files with 30 additions and 8 deletions

View File

@ -67,6 +67,8 @@ void wm8750_data_req_set(i2c_slave *i2c,
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);

View File

@ -254,7 +254,7 @@ typedef struct musicpal_audio_state {
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 @@ static void audio_callback(void *opaque, int free_out, int free_in)
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;

View File

@ -627,6 +627,24 @@ void wm8750_dac_dat(void *opaque, uint32_t sample)
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;