Track the LED intensity, and emit a trace event when it changes. Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org> --- include/hw/misc/led.h | 1 + hw/misc/led.c | 5 +++++ hw/misc/trace-events | 1 + 3 files changed, 7 insertions(+)
diff --git a/include/hw/misc/led.h b/include/hw/misc/led.h index 883006bb8f..df5b32a2db 100644 --- a/include/hw/misc/led.h +++ b/include/hw/misc/led.h @@ -35,6 +35,7 @@ typedef struct LEDState { DeviceState parent_obj; /* Public */ + uint16_t current_intensity; qemu_irq irq; /* Properties */ diff --git a/hw/misc/led.c b/hw/misc/led.c index 8503dde777..37d9f1f3d2 100644 --- a/hw/misc/led.c +++ b/hw/misc/led.c @@ -32,6 +32,11 @@ void led_set_intensity(LEDState *s, uint16_t new_intensity) { trace_led_set_intensity(s->description ? s->description : "n/a", s->color, new_intensity); + if (new_intensity != s->current_intensity) { + trace_led_change_intensity(s->description ? s->description : "n/a", + s->color, + s->current_intensity, new_intensity); + } s->current_intensity = new_intensity; } diff --git a/hw/misc/trace-events b/hw/misc/trace-events index f58853d367..57d39bf9b9 100644 --- a/hw/misc/trace-events +++ b/hw/misc/trace-events @@ -209,6 +209,7 @@ grlib_apb_pnp_read(uint64_t addr, uint32_t value) "APB PnP read addr:0x%03"PRIx6 # led.c led_set_intensity(const char *color, const char *desc, uint16_t intensity) "LED desc:'%s' color:%s intensity: 0x%04"PRIx16 +led_change_intensity(const char *color, const char *desc, uint16_t old_intensity, uint16_t new_intensity) "LED desc:'%s' color:%s intensity 0x%04"PRIx16" -> 0x%04"PRIx16"" # pca9552.c pca9552_gpio_status(const char *description, const char *buf) "%s GPIOs 0-15 [%s]" -- 2.21.3