From 7f7a8b2bb818ff7a76cfa592e06b2d271a0f8bcd Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Mon, 16 Oct 2017 12:22:57 +0200 Subject: [PATCH] hda buffer compatibility fluff --- include/hw/compat.h | 4 ++++ hw/audio/hda-codec.c | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/include/hw/compat.h b/include/hw/compat.h index cf389b4e85..22d154035e 100644 --- a/include/hw/compat.h +++ b/include/hw/compat.h @@ -10,6 +10,10 @@ .driver = "virtio-tablet-device",\ .property = "wheel-axis",\ .value = "false",\ + },{\ + .driver = "hda-audio",\ + .property = "use-timer",\ + .value = "false",\ }, #define HW_COMPAT_2_9 \ diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c index ab89158bfc..df7fc87f96 100644 --- a/hw/audio/hda-codec.c +++ b/hw/audio/hda-codec.c @@ -185,6 +185,7 @@ struct HDAAudioState { /* properties */ uint32_t debug; bool mixer; + bool use_timer; }; static inline int64_t hda_bytes_per_second(HDAAudioStream *st) @@ -696,6 +697,26 @@ static void hda_audio_reset(DeviceState *dev) } } +static bool vmstate_hda_audio_stream_buf_needed(void *opaque) +{ + HDAAudioStream *st = opaque; + return st->state->use_timer; +} + +static const VMStateDescription vmstate_hda_audio_stream_buf = { + .name = "hda-audio-stream/buffer", + .version_id = 1, + .needed = vmstate_hda_audio_stream_buf_needed, + .fields = (VMStateField[]) { + VMSTATE_BUFFER(buf, HDAAudioStream), + VMSTATE_INT64(rpos, HDAAudioStream), + VMSTATE_INT64(wpos, HDAAudioStream), + VMSTATE_TIMER_PTR(buft, HDAAudioStream), + VMSTATE_INT64(buft_start, HDAAudioStream), + VMSTATE_END_OF_LIST() + } +}; + static const VMStateDescription vmstate_hda_audio_stream = { .name = "hda-audio-stream", .version_id = 1, @@ -710,6 +731,10 @@ static const VMStateDescription vmstate_hda_audio_stream = { VMSTATE_UINT32(compat_bpos, HDAAudioStream), VMSTATE_BUFFER(compat_buf, HDAAudioStream), VMSTATE_END_OF_LIST() + }, + .subsections = (const VMStateDescription * []) { + &vmstate_hda_audio_stream_buf, + NULL } }; @@ -730,6 +755,7 @@ static const VMStateDescription vmstate_hda_audio = { static Property hda_audio_properties[] = { DEFINE_PROP_UINT32("debug", HDAAudioState, debug, 0), DEFINE_PROP_BOOL("mixer", HDAAudioState, mixer, true), + DEFINE_PROP_BOOL("use-timer", HDAAudioState, use_timer, true), DEFINE_PROP_END_OF_LIST(), }; -- 2.9.3