dm163.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * QEMU DM163 8x3-channel constant current led driver
  3. * driving columns of associated 8x8 RGB matrix.
  4. *
  5. * Copyright (C) 2024 Samuel Tardieu <sam@rfc1149.net>
  6. * Copyright (C) 2024 Arnaud Minier <arnaud.minier@telecom-paris.fr>
  7. * Copyright (C) 2024 Inès Varhol <ines.varhol@telecom-paris.fr>
  8. *
  9. * SPDX-License-Identifier: GPL-2.0-or-later
  10. */
  11. #ifndef HW_DISPLAY_DM163_H
  12. #define HW_DISPLAY_DM163_H
  13. #include "qom/object.h"
  14. #include "hw/qdev-core.h"
  15. #define TYPE_DM163 "dm163"
  16. OBJECT_DECLARE_SIMPLE_TYPE(DM163State, DM163);
  17. #define RGB_MATRIX_NUM_ROWS 8
  18. #define RGB_MATRIX_NUM_COLS 8
  19. #define DM163_NUM_LEDS (RGB_MATRIX_NUM_COLS * 3)
  20. /* The last row is filled with 0 (turned off row) */
  21. #define COLOR_BUFFER_SIZE (RGB_MATRIX_NUM_ROWS + 1)
  22. typedef struct DM163State {
  23. DeviceState parent_obj;
  24. /* DM163 driver */
  25. uint64_t bank0_shift_register[3];
  26. uint64_t bank1_shift_register[3];
  27. uint16_t latched_outputs[DM163_NUM_LEDS];
  28. uint16_t outputs[DM163_NUM_LEDS];
  29. qemu_irq sout;
  30. uint8_t sin;
  31. uint8_t dck;
  32. uint8_t rst_b;
  33. uint8_t lat_b;
  34. uint8_t selbk;
  35. uint8_t en_b;
  36. /* IM120417002 colors shield */
  37. uint8_t activated_rows;
  38. /* 8x8 RGB matrix */
  39. QemuConsole *console;
  40. uint8_t redraw;
  41. /* Rows currently being displayed on the matrix. */
  42. /* The last row is filled with 0 (turned off row) */
  43. uint32_t buffer[COLOR_BUFFER_SIZE][RGB_MATRIX_NUM_COLS];
  44. uint8_t last_buffer_idx;
  45. uint8_t buffer_idx_of_row[RGB_MATRIX_NUM_ROWS];
  46. /* Used to simulate retinal persistence of rows */
  47. uint8_t row_persistence_delay[RGB_MATRIX_NUM_ROWS];
  48. } DM163State;
  49. #endif /* HW_DISPLAY_DM163_H */