| 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 | |
| 12 | #ifndef HW_DISPLAY_DM163_H |
| 13 | #define HW_DISPLAY_DM163_H |
| 14 | |
| 15 | #include "qom/object.h" |
| 16 | #include "hw/core/qdev.h" |
| 17 | |
| 18 | #define TYPE_DM163 "dm163" |
| 19 | OBJECT_DECLARE_SIMPLE_TYPE(DM163State, DM163); |
| 20 | |
| 21 | #define RGB_MATRIX_NUM_ROWS 8 |
| 22 | #define RGB_MATRIX_NUM_COLS 8 |
| 23 | #define DM163_NUM_LEDS (RGB_MATRIX_NUM_COLS * 3) |
| 24 | /* The last row is filled with 0 (turned off row) */ |
| 25 | #define COLOR_BUFFER_SIZE (RGB_MATRIX_NUM_ROWS + 1) |
| 26 | |
| 27 | typedef struct DM163State { |
| 28 | DeviceState parent_obj; |
| 29 | |
| 30 | /* DM163 driver */ |
| 31 | uint64_t bank0_shift_register[3]; |
| 32 | uint64_t bank1_shift_register[3]; |
| 33 | uint16_t latched_outputs[DM163_NUM_LEDS]; |
| 34 | uint16_t outputs[DM163_NUM_LEDS]; |
| 35 | qemu_irq sout; |
| 36 | |
| 37 | uint8_t sin; |
| 38 | uint8_t dck; |
| 39 | uint8_t rst_b; |
| 40 | uint8_t lat_b; |
| 41 | uint8_t selbk; |
| 42 | uint8_t en_b; |
| 43 | |
| 44 | /* IM120417002 colors shield */ |
| 45 | uint8_t activated_rows; |
| 46 | |
| 47 | /* 8x8 RGB matrix */ |
| 48 | QemuConsole *console; |
| 49 | uint8_t redraw; |
| 50 | /* Rows currently being displayed on the matrix. */ |
| 51 | /* The last row is filled with 0 (turned off row) */ |
| 52 | uint32_t buffer[COLOR_BUFFER_SIZE][RGB_MATRIX_NUM_COLS]; |
| 53 | uint8_t last_buffer_idx; |
| 54 | uint8_t buffer_idx_of_row[RGB_MATRIX_NUM_ROWS]; |
| 55 | /* Used to simulate retinal persistence of rows */ |
| 56 | uint8_t row_persistence_delay[RGB_MATRIX_NUM_ROWS]; |
| 57 | } DM163State; |
| 58 | |
| 59 | #endif /* HW_DISPLAY_DM163_H */ |