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:
parent
c21c583a1d
commit
662caa6f91
2
hw/i2c.h
2
hw/i2c.h
|
@ -67,6 +67,8 @@ void wm8750_data_req_set(i2c_slave *i2c,
|
||||||
void (*data_req)(void *, int, int), void *opaque);
|
void (*data_req)(void *, int, int), void *opaque);
|
||||||
void wm8750_dac_dat(void *opaque, uint32_t sample);
|
void wm8750_dac_dat(void *opaque, uint32_t sample);
|
||||||
uint32_t wm8750_adc_dat(void *opaque);
|
uint32_t wm8750_adc_dat(void *opaque);
|
||||||
|
void *wm8750_dac_buffer(void *opaque, int samples);
|
||||||
|
void wm8750_dac_commit(void *opaque);
|
||||||
|
|
||||||
/* ssd0303.c */
|
/* ssd0303.c */
|
||||||
void ssd0303_init(DisplayState *ds, i2c_bus *bus, int address);
|
void ssd0303_init(DisplayState *ds, i2c_bus *bus, int address);
|
||||||
|
|
|
@ -254,7 +254,7 @@ typedef struct musicpal_audio_state {
|
||||||
static void audio_callback(void *opaque, int free_out, int free_in)
|
static void audio_callback(void *opaque, int free_out, int free_in)
|
||||||
{
|
{
|
||||||
musicpal_audio_state *s = opaque;
|
musicpal_audio_state *s = opaque;
|
||||||
int16_t channel[2];
|
int16_t *codec_buffer;
|
||||||
int pos, block_size;
|
int pos, block_size;
|
||||||
|
|
||||||
if (!(s->playback_mode & MP_AUDIO_PLAYBACK_EN))
|
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;
|
return;
|
||||||
|
|
||||||
if (s->playback_mode & MP_AUDIO_16BIT_SAMPLE)
|
if (s->playback_mode & MP_AUDIO_16BIT_SAMPLE)
|
||||||
for (pos = 0; pos < block_size; pos += 4)
|
memcpy(wm8750_dac_buffer(s->wm, block_size >> 2),
|
||||||
wm8750_dac_dat(s->wm,
|
(uint32_t *)(s->target_buffer + s->play_pos),
|
||||||
*(uint32_t *)(s->target_buffer + s->play_pos + pos));
|
block_size);
|
||||||
else
|
else {
|
||||||
|
codec_buffer = wm8750_dac_buffer(s->wm, block_size >> 1);
|
||||||
for (pos = 0; pos < block_size; pos += 2) {
|
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));
|
*(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));
|
*(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;
|
s->last_free = free_out - block_size;
|
||||||
|
|
||||||
|
|
18
hw/wm8750.c
18
hw/wm8750.c
|
@ -627,6 +627,24 @@ void wm8750_dac_dat(void *opaque, uint32_t sample)
|
||||||
wm8750_out_flush(s);
|
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)
|
uint32_t wm8750_adc_dat(void *opaque)
|
||||||
{
|
{
|
||||||
struct wm8750_s *s = (struct wm8750_s *) opaque;
|
struct wm8750_s *s = (struct wm8750_s *) opaque;
|
||||||
|
|
Loading…
Reference in a new issue