@samitouri / QOSamiQemu / commits / c2c8805742

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>

Philippe Mathieu-Daudé committed May 2, 2025 at 01:01 UTC c2c8805742dcea9e80697971c5f9580c5a7199bd
1 file changed +13 -80
hw/audio/hda-codec.c
+13 -80
@@ -187,7 +187,6 @@ struct HDAAudioState {
187 /* properties */
188 uint32_t debug;
189 bool mixer;
190 - bool use_timer;
190 };
191
192 static inline uint32_t hda_bytes_per_second(HDAAudioStream *st)
@@ -368,60 +367,6 @@ static void hda_audio_output_cb(void *opaque, int avail)
367 hda_timer_sync_adjust(st, (wpos - rpos) - (B_SIZE >> 1));
368 }
369
371 -static void hda_audio_compat_input_cb(void *opaque, int avail)
372 -{
373 - HDAAudioStream *st = opaque;
374 - int recv = 0;
375 - int len;
376 - bool rc;
377 -
378 - while (avail - recv >= sizeof(st->compat_buf)) {
379 - if (st->compat_bpos != sizeof(st->compat_buf)) {
380 - len = audio_be_read(st->state->audio_be, st->voice.in,
381 - st->compat_buf + st->compat_bpos,
382 - sizeof(st->compat_buf) - st->compat_bpos);
383 - st->compat_bpos += len;
384 - recv += len;
385 - if (st->compat_bpos != sizeof(st->compat_buf)) {
386 - break;
387 - }
388 - }
389 - rc = hda_codec_xfer(&st->state->hda, st->stream, false,
390 - st->compat_buf, sizeof(st->compat_buf));
391 - if (!rc) {
392 - break;
393 - }
394 - st->compat_bpos = 0;
395 - }
396 -}
397 -
398 -static void hda_audio_compat_output_cb(void *opaque, int avail)
399 -{
400 - HDAAudioStream *st = opaque;
401 - int sent = 0;
402 - int len;
403 - bool rc;
404 -
405 - while (avail - sent >= sizeof(st->compat_buf)) {
406 - if (st->compat_bpos == sizeof(st->compat_buf)) {
407 - rc = hda_codec_xfer(&st->state->hda, st->stream, true,
408 - st->compat_buf, sizeof(st->compat_buf));
409 - if (!rc) {
410 - break;
411 - }
412 - st->compat_bpos = 0;
413 - }
414 - len = audio_be_write(st->state->audio_be, st->voice.out,
415 - st->compat_buf + st->compat_bpos,
416 - sizeof(st->compat_buf) - st->compat_bpos);
417 - st->compat_bpos += len;
418 - sent += len;
419 - if (st->compat_bpos != sizeof(st->compat_buf)) {
420 - break;
421 - }
422 - }
423 -}
424 -
370 static void hda_audio_set_running(HDAAudioStream *st, bool running)
371 {
372 if (st->node == NULL) {
@@ -432,16 +377,14 @@ static void hda_audio_set_running(HDAAudioStream *st, bool running)
377 }
378 st->running = running;
379 trace_hda_audio_running(st->node->name, st->stream, st->running);
435 - if (st->state->use_timer) {
436 - if (running) {
437 - int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
438 - st->rpos = 0;
439 - st->wpos = 0;
440 - st->buft_start = now;
441 - timer_mod_anticipate_ns(st->buft, now + HDA_TIMER_TICKS);
442 - } else {
443 - timer_del(st->buft);
444 - }
380 + if (running) {
381 + int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
382 + st->rpos = 0;
383 + st->wpos = 0;
384 + st->buft_start = now;
385 + timer_mod_anticipate_ns(st->buft, now + HDA_TIMER_TICKS);
386 + } else {
387 + timer_del(st->buft);
388 }
389 if (st->output) {
390 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)
423
424 static void hda_audio_setup(HDAAudioStream *st)
425 {
483 - bool use_timer = st->state->use_timer;
426 audio_callback_fn cb;
427
428 if (st->node == NULL) {
@@ -491,21 +433,13 @@ static void hda_audio_setup(HDAAudioStream *st)
433 fmt2name[st->as.fmt], st->as.freq);
434
435 if (st->output) {
494 - if (use_timer) {
495 - cb = hda_audio_output_cb;
496 - timer_del(st->buft);
497 - } else {
498 - cb = hda_audio_compat_output_cb;
499 - }
436 + cb = hda_audio_output_cb;
437 + timer_del(st->buft);
438 st->voice.out = audio_be_open_out(st->state->audio_be, st->voice.out,
439 st->node->name, st, cb, &st->as);
440 } else {
503 - if (use_timer) {
504 - cb = hda_audio_input_cb;
505 - timer_del(st->buft);
506 - } else {
507 - cb = hda_audio_compat_input_cb;
508 - }
441 + cb = hda_audio_input_cb;
442 + timer_del(st->buft);
443 st->voice.in = audio_be_open_in(st->state->audio_be, st->voice.in,
444 st->node->name, st, cb, &st->as);
445 }
@@ -810,7 +744,7 @@ static void hda_audio_reset(DeviceState *dev)
744 static bool vmstate_hda_audio_stream_buf_needed(void *opaque)
745 {
746 HDAAudioStream *st = opaque;
813 - return st->state && st->state->use_timer;
747 + return st->state;
748 }
749
750 static const VMStateDescription vmstate_hda_audio_stream_buf = {
@@ -866,7 +800,6 @@ static const Property hda_audio_properties[] = {
800 DEFINE_AUDIO_PROPERTIES(HDAAudioState, audio_be),
801 DEFINE_PROP_UINT32("debug", HDAAudioState, debug, 0),
802 DEFINE_PROP_BOOL("mixer", HDAAudioState, mixer, true),
869 - DEFINE_PROP_BOOL("use-timer", HDAAudioState, use_timer, true),
803 };
804
805 static void hda_audio_init_output(HDACodecDevice *hda, Error **errp)