Commit c2c8805742 for qemu.org
commit c2c8805742dcea9e80697971c5f9580c5a7199bd
Author: Philippe Mathieu-Daudé <philmd@linaro.org>
Date: Fri May 2 01:01:27 2025 +0200
hw/audio/hda-codec: Remove HDAAudioState::use_timer field
The HDAAudioState::use_timer boolean was only set in the
hw_compat_2_12[] array, via the 'use-timer=false' property.
We removed all machines using that array, lets remove that
property and all the code around it, like the compatibility
callbacks.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20250501230129.2596-10-philmd@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
[thuth: Rebased the patch to current master branch, fixed conflicts]
Signed-off-by: Thomas Huth <thuth@redhat.com>
diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c
index 984029a8db..173fe56bea 100644
--- a/hw/audio/hda-codec.c
+++ b/hw/audio/hda-codec.c
@@ -187,7 +187,6 @@ struct HDAAudioState {
/* properties */
uint32_t debug;
bool mixer;
- bool use_timer;
};
static inline uint32_t hda_bytes_per_second(HDAAudioStream *st)
@@ -368,60 +367,6 @@ static void hda_audio_output_cb(void *opaque, int avail)
hda_timer_sync_adjust(st, (wpos - rpos) - (B_SIZE >> 1));
}
-static void hda_audio_compat_input_cb(void *opaque, int avail)
-{
- HDAAudioStream *st = opaque;
- int recv = 0;
- int len;
- bool rc;
-
- while (avail - recv >= sizeof(st->compat_buf)) {
- if (st->compat_bpos != sizeof(st->compat_buf)) {
- len = audio_be_read(st->state->audio_be, st->voice.in,
- st->compat_buf + st->compat_bpos,
- sizeof(st->compat_buf) - st->compat_bpos);
- st->compat_bpos += len;
- recv += len;
- if (st->compat_bpos != sizeof(st->compat_buf)) {
- break;
- }
- }
- rc = hda_codec_xfer(&st->state->hda, st->stream, false,
- st->compat_buf, sizeof(st->compat_buf));
- if (!rc) {
- break;
- }
- st->compat_bpos = 0;
- }
-}
-
-static void hda_audio_compat_output_cb(void *opaque, int avail)
-{
- HDAAudioStream *st = opaque;
- int sent = 0;
- int len;
- bool rc;
-
- while (avail - sent >= sizeof(st->compat_buf)) {
- if (st->compat_bpos == sizeof(st->compat_buf)) {
- rc = hda_codec_xfer(&st->state->hda, st->stream, true,
- st->compat_buf, sizeof(st->compat_buf));
- if (!rc) {
- break;
- }
- st->compat_bpos = 0;
- }
- len = audio_be_write(st->state->audio_be, st->voice.out,
- st->compat_buf + st->compat_bpos,
- sizeof(st->compat_buf) - st->compat_bpos);
- st->compat_bpos += len;
- sent += len;
- if (st->compat_bpos != sizeof(st->compat_buf)) {
- break;
- }
- }
-}
-
static void hda_audio_set_running(HDAAudioStream *st, bool running)
{
if (st->node == NULL) {
@@ -432,16 +377,14 @@ static void hda_audio_set_running(HDAAudioStream *st, bool running)
}
st->running = running;
trace_hda_audio_running(st->node->name, st->stream, st->running);
- if (st->state->use_timer) {
- if (running) {
- int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
- st->rpos = 0;
- st->wpos = 0;
- st->buft_start = now;
- timer_mod_anticipate_ns(st->buft, now + HDA_TIMER_TICKS);
- } else {
- timer_del(st->buft);
- }
+ if (running) {
+ int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
+ st->rpos = 0;
+ st->wpos = 0;
+ st->buft_start = now;
+ timer_mod_anticipate_ns(st->buft, now + HDA_TIMER_TICKS);
+ } else {
+ timer_del(st->buft);
}
if (st->output) {
audio_be_set_active_out(st->state->audio_be, st->voice.out, st->running);
@@ -480,7 +423,6 @@ static void hda_audio_set_amp(HDAAudioStream *st)
static void hda_audio_setup(HDAAudioStream *st)
{
- bool use_timer = st->state->use_timer;
audio_callback_fn cb;
if (st->node == NULL) {
@@ -491,21 +433,13 @@ static void hda_audio_setup(HDAAudioStream *st)
fmt2name[st->as.fmt], st->as.freq);
if (st->output) {
- if (use_timer) {
- cb = hda_audio_output_cb;
- timer_del(st->buft);
- } else {
- cb = hda_audio_compat_output_cb;
- }
+ cb = hda_audio_output_cb;
+ timer_del(st->buft);
st->voice.out = audio_be_open_out(st->state->audio_be, st->voice.out,
st->node->name, st, cb, &st->as);
} else {
- if (use_timer) {
- cb = hda_audio_input_cb;
- timer_del(st->buft);
- } else {
- cb = hda_audio_compat_input_cb;
- }
+ cb = hda_audio_input_cb;
+ timer_del(st->buft);
st->voice.in = audio_be_open_in(st->state->audio_be, st->voice.in,
st->node->name, st, cb, &st->as);
}
@@ -810,7 +744,7 @@ static void hda_audio_reset(DeviceState *dev)
static bool vmstate_hda_audio_stream_buf_needed(void *opaque)
{
HDAAudioStream *st = opaque;
- return st->state && st->state->use_timer;
+ return st->state;
}
static const VMStateDescription vmstate_hda_audio_stream_buf = {
@@ -866,7 +800,6 @@ static const Property hda_audio_properties[] = {
DEFINE_AUDIO_PROPERTIES(HDAAudioState, audio_be),
DEFINE_PROP_UINT32("debug", HDAAudioState, debug, 0),
DEFINE_PROP_BOOL("mixer", HDAAudioState, mixer, true),
- DEFINE_PROP_BOOL("use-timer", HDAAudioState, use_timer, true),
};
static void hda_audio_init_output(HDACodecDevice *hda, Error **errp)