mirror of
https://github.com/Creased/RCM-Emulator.git
synced 2026-12-06 02:48:11 +01:00
Add display + touch panel info to HW & Fuses screen
This commit is contained in:
1 parent
91b85f2b57
commit
d0f0f67247
4 files changed
+253
-2
No files matched your search
@@ -79,6 +79,11 @@ void reset_to_defaults(EmuState *s) {
|
|||||||
s->dram_rev_id1 = 2;
|
s->dram_rev_id1 = 2;
|
||||||
s->dram_rev_id2 = 0;
|
s->dram_rev_id2 = 0;
|
||||||
s->dram_density = 0x18; // 4 GB die
|
s->dram_density = 0x18; // 4 GB die
|
||||||
|
s->panel_id_raw = 0x099310; // JDI LAM062M109A rev 0x93
|
||||||
|
s->touch_panel_idx = 0; // NISSHA NFT-K12D
|
||||||
|
s->touch_fw_id = 0x32000001; // 4CD60D/1
|
||||||
|
s->touch_ftb_ver = 0x0123;
|
||||||
|
s->touch_fw_rev = 0x4567;
|
||||||
s->backlight = 100;
|
s->backlight = 100;
|
||||||
s->rotation_override = -1;
|
s->rotation_override = -1;
|
||||||
}
|
}
|
||||||
@@ -383,6 +388,102 @@ void build_ui(EmuState *state) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ImGui::CollapsingHeader("Display panel (DSI)")) {
|
||||||
|
// Decoded ID is `((raw >> 8) & 0xFF00) | (raw & 0xFF)`, which means
|
||||||
|
// the high byte of the decoded ID lives in raw[23:16] (MSB of raw)
|
||||||
|
// and the low byte lives in raw[7:0]. raw[15:8] is the rev byte that
|
||||||
|
// Hekate uses to disambiguate AZ1/AZ2/AZ3 etc.
|
||||||
|
struct PanelEntry { uint32_t raw; const char *name; };
|
||||||
|
static const PanelEntry kPanels[] = {
|
||||||
|
{0x099310, "JDI LAM062M109A (10 93 09)"},
|
||||||
|
{0x269310, "JDI LPM062M326A (10 93 26)"},
|
||||||
|
{0x0F9320, "InnoLux P062CCA-AZ1 (20 93 0F)"},
|
||||||
|
{0x0F9330, "AUO A062TAN00 (30 93 0F)"},
|
||||||
|
{0x109320, "InnoLux 2J055IA-27A (20 93 10)"},
|
||||||
|
{0x109330, "AUO A055TAN01 (30 93 10)"},
|
||||||
|
{0x109340, "Sharp LQ055T1SW10 (40 93 10)"},
|
||||||
|
{0x205050, "Samsung AMS699VC01 (50 50 20)"},
|
||||||
|
{0xCCCCCC, "Failed (sentinel CC CC CC)"},
|
||||||
|
};
|
||||||
|
uint32_t cur = state->panel_id_raw.load() & 0xFFFFFF;
|
||||||
|
const char *match = "Custom";
|
||||||
|
for (const auto &p : kPanels) if (p.raw == cur) { match = p.name; break; }
|
||||||
|
char preview[64];
|
||||||
|
snprintf(preview, sizeof(preview), "%s", match);
|
||||||
|
if (ImGui::BeginCombo("Panel preset", preview)) {
|
||||||
|
for (const auto &p : kPanels) {
|
||||||
|
bool sel = (p.raw == cur);
|
||||||
|
if (ImGui::Selectable(p.name, sel)) state->panel_id_raw.store(p.raw);
|
||||||
|
if (sel) ImGui::SetItemDefaultFocus();
|
||||||
|
}
|
||||||
|
ImGui::EndCombo();
|
||||||
|
}
|
||||||
|
atomic_hex_input("Raw 24-bit", state->panel_id_raw);
|
||||||
|
ImGui::TextDisabled("Hekate prints \"ID: b0 b1 b2\" with b0 = raw & 0xFF, etc.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui::CollapsingHeader("Touch panel (FTS4)")) {
|
||||||
|
// Hekate pairs each FW ID with a specific panel idx. Keeping the two
|
||||||
|
// selectors in sync avoids landing in the "Error" pairing branch.
|
||||||
|
// Index aligns with the panel combo: kPairedFw[idx] is the FW ID
|
||||||
|
// Hekate marks "Paired" for that panel.
|
||||||
|
static constexpr uint32_t kPairedFw[] = {
|
||||||
|
0x32000001, // 0: NISSHA NFT-K12D -> 4CD60D/1
|
||||||
|
0x32000102, // 1: GiS GGM6 B2X -> 4CD60D/2
|
||||||
|
0x32000302, // 2: NISSHA NBF-K9A -> 4CD60D/3
|
||||||
|
0x32000402, // 3: GiS 5.5" -> 4CD60D/4
|
||||||
|
0x32000501, // 4: Samsung TSP -> 4CD60D/5
|
||||||
|
0x00100100, // 5: GiS VA 6.2" -> 4CD60D/0 (Hekate stores idx -1)
|
||||||
|
};
|
||||||
|
const char *kPanelNames[] = {
|
||||||
|
"0 - NISSHA NFT-K12D", "1 - GiS GGM6 B2X",
|
||||||
|
"2 - NISSHA NBF-K9A", "3 - GiS 5.5\"",
|
||||||
|
"4 - Samsung TSP", "5 - GiS VA 6.2\"",
|
||||||
|
};
|
||||||
|
int idx = (int)state->touch_panel_idx.load();
|
||||||
|
if (ImGui::Combo("Panel", &idx, kPanelNames, IM_ARRAYSIZE(kPanelNames))) {
|
||||||
|
state->touch_panel_idx.store((uint8_t)idx);
|
||||||
|
state->touch_fw_id.store(kPairedFw[idx]);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct FwEntry { uint32_t id; const char *label; uint8_t panel_idx; };
|
||||||
|
static const FwEntry kFwIds[] = {
|
||||||
|
{0x00100100, "4CD60D/0 (GiS VA 6.2\")", 5},
|
||||||
|
{0x32000001, "4CD60D/1 (NISSHA NFT-K12D)", 0},
|
||||||
|
{0x32000102, "4CD60D/2 (GiS GGM6 B2X)", 1},
|
||||||
|
{0x32000302, "4CD60D/3 (NISSHA NBF-K9A)", 2},
|
||||||
|
{0x32000402, "4CD60D/4 (GiS 5.5\")", 3},
|
||||||
|
{0x32000501, "4CD60D/5 (Samsung TSP)", 4},
|
||||||
|
};
|
||||||
|
uint32_t cur_fw = state->touch_fw_id.load();
|
||||||
|
const char *fw_match = "Custom";
|
||||||
|
for (const auto &e : kFwIds) if (e.id == cur_fw) { fw_match = e.label; break; }
|
||||||
|
if (ImGui::BeginCombo("FW preset", fw_match)) {
|
||||||
|
for (const auto &e : kFwIds) {
|
||||||
|
bool sel = (e.id == cur_fw);
|
||||||
|
if (ImGui::Selectable(e.label, sel)) {
|
||||||
|
state->touch_fw_id.store(e.id);
|
||||||
|
state->touch_panel_idx.store(e.panel_idx);
|
||||||
|
}
|
||||||
|
if (sel) ImGui::SetItemDefaultFocus();
|
||||||
|
}
|
||||||
|
ImGui::EndCombo();
|
||||||
|
}
|
||||||
|
atomic_hex_input("FW ID raw", state->touch_fw_id);
|
||||||
|
|
||||||
|
uint16_t ftb = state->touch_ftb_ver.load();
|
||||||
|
if (ImGui::InputScalar("FTB ver", ImGuiDataType_U16, &ftb, nullptr, nullptr, "%04X",
|
||||||
|
ImGuiInputTextFlags_CharsHexadecimal))
|
||||||
|
state->touch_ftb_ver.store(ftb);
|
||||||
|
// Hekate prints fw_rev byte-swapped, so we expose the value the user
|
||||||
|
// sees on screen and swap on store. byte_swap_16 is self-inverse.
|
||||||
|
uint16_t raw = state->touch_fw_rev.load();
|
||||||
|
uint16_t shown = (uint16_t)((raw >> 8) | (raw << 8));
|
||||||
|
if (ImGui::InputScalar("FW rev", ImGuiDataType_U16, &shown, nullptr, nullptr, "%04X",
|
||||||
|
ImGuiInputTextFlags_CharsHexadecimal))
|
||||||
|
state->touch_fw_rev.store((uint16_t)((shown >> 8) | (shown << 8)));
|
||||||
|
}
|
||||||
|
|
||||||
if (ImGui::CollapsingHeader("Fuses (advanced)")) {
|
if (ImGui::CollapsingHeader("Fuses (advanced)")) {
|
||||||
atomic_hex_input("FUSE 0x100", state->fuse_0x100);
|
atomic_hex_input("FUSE 0x100", state->fuse_0x100);
|
||||||
atomic_hex_input("FUSE 0x110 (SKU)", state->fuse_0x110);
|
atomic_hex_input("FUSE 0x110 (SKU)", state->fuse_0x110);
|
||||||
|
|||||||
+15
@@ -219,6 +219,21 @@ struct EmuState {
|
|||||||
std::atomic<uint8_t> dram_rev_id1{2}; // MR6 REV_ID1
|
std::atomic<uint8_t> dram_rev_id1{2}; // MR6 REV_ID1
|
||||||
std::atomic<uint8_t> dram_rev_id2{0}; // MR7 REV_ID2
|
std::atomic<uint8_t> dram_rev_id2{0}; // MR7 REV_ID2
|
||||||
std::atomic<uint8_t> dram_density{0x18}; // MR8 DENSITY (bits 5:2 = density code)
|
std::atomic<uint8_t> dram_density{0x18}; // MR8 DENSITY (bits 5:2 = density code)
|
||||||
|
|
||||||
|
// Display panel ID (DSI). Hekate reads MIPI_DCS_GET_DISPLAY_ID (0x04) over
|
||||||
|
// DSI and stores 3 raw bytes; the screen prints them as "ID: b0 b1 b2"
|
||||||
|
// and decodes them as `((raw >> 8) & 0xFF00) | (raw & 0xFF)`. Default
|
||||||
|
// 0x099310 -> JDI LAM062M109A rev 0x93 (a common Erista launch panel).
|
||||||
|
std::atomic<uint32_t> panel_id_raw{0x099310};
|
||||||
|
|
||||||
|
// Touch panel + FW info (FTS4 controller, I2C3 @ 0x49). Idx maps to the
|
||||||
|
// _panels[] table in Hekate's bdk/input/touch.c (0=NISSHA NFT-K12D pairs
|
||||||
|
// with fw_id 4CD60D/1, etc.). Defaults render as "NISSHA NFT-K12D" with
|
||||||
|
// ID "32.00.00.01 (Paired)".
|
||||||
|
std::atomic<uint8_t> touch_panel_idx{0}; // 0..4 -> known panels, 5 -> GiS VA 6.2"
|
||||||
|
std::atomic<uint32_t> touch_fw_id{0x32000001}; // displayed as 4CD60D/<n>
|
||||||
|
std::atomic<uint16_t> touch_ftb_ver{0x0123};
|
||||||
|
std::atomic<uint16_t> touch_fw_rev{0x4567}; // Hekate byte-swaps before printing
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EMU_STATE_H
|
#endif // EMU_STATE_H
|
||||||
+59
-1
@@ -42,8 +42,11 @@ constexpr uint8_t FTS4_CMD_SYSTEM_RESET = 0xA0;
|
|||||||
constexpr uint8_t FTS4_CMD_CLEAR_EVENT_STACK = 0xA1;
|
constexpr uint8_t FTS4_CMD_CLEAR_EVENT_STACK = 0xA1;
|
||||||
constexpr uint8_t FTS4_CMD_HW_REG_READ = 0xB6; // also HW_REG_WRITE
|
constexpr uint8_t FTS4_CMD_HW_REG_READ = 0xB6; // also HW_REG_WRITE
|
||||||
constexpr uint8_t FTS4_CMD_SWITCH_SENSE_MODE = 0xC3;
|
constexpr uint8_t FTS4_CMD_SWITCH_SENSE_MODE = 0xC3;
|
||||||
|
constexpr uint8_t FTS4_CMD_VENDOR = 0xCF;
|
||||||
constexpr uint8_t FTS4_CMD_FB_REG_READ = 0xD0; // also FB_REG_WRITE
|
constexpr uint8_t FTS4_CMD_FB_REG_READ = 0xD0; // also FB_REG_WRITE
|
||||||
|
|
||||||
|
constexpr uint8_t FTS4_VENDOR_GPIO_STATE = 0x01;
|
||||||
|
|
||||||
// ---- FTS4 HW register addresses (accessed via 0xB6) ----
|
// ---- FTS4 HW register addresses (accessed via 0xB6) ----
|
||||||
constexpr uint16_t FTS4_HW_REG_CHIP_ID_INFO_ALT = 0x0002; // returns chip_id at bytes [3..4]
|
constexpr uint16_t FTS4_HW_REG_CHIP_ID_INFO_ALT = 0x0002; // returns chip_id at bytes [3..4]
|
||||||
constexpr uint16_t FTS4_HW_REG_CHIP_ID_INFO = 0x0004; // returns chip_id at bytes [1..2]
|
constexpr uint16_t FTS4_HW_REG_CHIP_ID_INFO = 0x0004; // returns chip_id at bytes [1..2]
|
||||||
@@ -59,6 +62,7 @@ constexpr uint8_t FTS4_EV_MULTI_TOUCH_ENTER = 0x03;
|
|||||||
constexpr uint8_t FTS4_EV_MULTI_TOUCH_LEAVE = 0x04;
|
constexpr uint8_t FTS4_EV_MULTI_TOUCH_LEAVE = 0x04;
|
||||||
constexpr uint8_t FTS4_EV_MULTI_TOUCH_MOTION = 0x05;
|
constexpr uint8_t FTS4_EV_MULTI_TOUCH_MOTION = 0x05;
|
||||||
constexpr uint8_t FTS4_EV_CONTROLLER_READY = 0x10;
|
constexpr uint8_t FTS4_EV_CONTROLLER_READY = 0x10;
|
||||||
|
constexpr uint8_t FTS4_EV_VENDOR = 0x20;
|
||||||
|
|
||||||
// ---- Tegra I²C packet header flags (mmio.h-style bit positions) ----
|
// ---- Tegra I²C packet header flags (mmio.h-style bit positions) ----
|
||||||
constexpr uint32_t I2C_HEADER_CONT_XFER = 1u << 15;
|
constexpr uint32_t I2C_HEADER_CONT_XFER = 1u << 15;
|
||||||
@@ -201,10 +205,64 @@ void execute(EmuState *state, uint32_t expected_rx_size) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FTS4_CMD_FB_REG_READ: { // 0xD0
|
case FTS4_CMD_FB_REG_READ: { // 0xD0
|
||||||
// FB read of FW info etc — return zeros, Hekate just memcpys the result.
|
// touch_get_fw_info() does two reads:
|
||||||
|
// 1. cmd = {0xD0, 0x00, 0x60}; reads 3 bytes. Hekate then forms the
|
||||||
|
// next address as cmd[1] = buf[2]; cmd[2] = buf[1]; — i.e. the
|
||||||
|
// payload of the second read lives at offset (buf[2] << 8) | buf[1].
|
||||||
|
// We hand back {x, 0x70, 0x00} so the second read targets 0x0070.
|
||||||
|
// 2. cmd = {0xD0, 0x00, 0x70}; reads 9 bytes. Hekate decodes it as
|
||||||
|
// fw_id = (buf[1] << 24) | (buf[2] << 16) | (buf[3] << 8) | buf[4]
|
||||||
|
// ftb_ver = (buf[6] << 8) | buf[5]
|
||||||
|
// fw_rev = (buf[8] << 8) | buf[7]
|
||||||
|
if (tx_buf.size() >= 3) {
|
||||||
|
uint16_t fb_off = ((uint16_t)tx_buf[1] << 8) | tx_buf[2];
|
||||||
|
if (fb_off == 0x0060) {
|
||||||
|
rx_buf = {0x00, 0x70, 0x00};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (fb_off == 0x0070) {
|
||||||
|
uint32_t fw = state->touch_fw_id.load();
|
||||||
|
uint16_t ftb = state->touch_ftb_ver.load();
|
||||||
|
uint16_t rev = state->touch_fw_rev.load();
|
||||||
|
rx_buf = {
|
||||||
|
0x00,
|
||||||
|
(uint8_t)((fw >> 24) & 0xFF), (uint8_t)((fw >> 16) & 0xFF),
|
||||||
|
(uint8_t)((fw >> 8) & 0xFF), (uint8_t)(fw & 0xFF),
|
||||||
|
(uint8_t)(ftb & 0xFF), (uint8_t)((ftb >> 8) & 0xFF),
|
||||||
|
(uint8_t)(rev & 0xFF), (uint8_t)((rev >> 8) & 0xFF),
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Anything else: zero-pad to whatever the controller expects.
|
||||||
rx_buf.assign(expected_rx_size ? expected_rx_size : 4, 0);
|
rx_buf.assign(expected_rx_size ? expected_rx_size : 4, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case FTS4_CMD_VENDOR: { // 0xCF
|
||||||
|
// touch_get_panel_vendor() sends one byte (FTS4_VENDOR_GPIO_STATE) and
|
||||||
|
// waits for an FTS4_EV_VENDOR event whose status byte matches. The event
|
||||||
|
// payload (tmp[2..]) carries gpio0/gpio1/gpio2, looked up against the
|
||||||
|
// _panels[] table in Hekate's bdk/input/touch.c. We mirror that table.
|
||||||
|
static constexpr uint8_t kPanelGpios[][3] = {
|
||||||
|
{1, 1, 1}, // 0: NISSHA NFT-K12D
|
||||||
|
{0, 1, 1}, // 1: GiS GGM6 B2X
|
||||||
|
{0, 0, 0}, // 2: NISSHA NBF-K9A
|
||||||
|
{1, 0, 0}, // 3: GiS 5.5"
|
||||||
|
{0, 0, 1}, // 4: Samsung TSP
|
||||||
|
{1, 0, 1}, // 5: GiS VA 6.2" (Hekate stores idx=-1 for this row)
|
||||||
|
};
|
||||||
|
if (tx_buf.size() >= 2 && tx_buf[1] == FTS4_VENDOR_GPIO_STATE) {
|
||||||
|
uint8_t idx = state->touch_panel_idx.load();
|
||||||
|
if (idx >= sizeof(kPanelGpios) / sizeof(kPanelGpios[0])) idx = 0;
|
||||||
|
std::array<uint8_t, 8> ev = {
|
||||||
|
FTS4_EV_VENDOR, FTS4_VENDOR_GPIO_STATE,
|
||||||
|
kPanelGpios[idx][0], kPanelGpios[idx][1], kPanelGpios[idx][2],
|
||||||
|
0, 0, 0,
|
||||||
|
};
|
||||||
|
if (ev_stack.size() < 32) ev_stack.push_back(ev);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case FTS4_CMD_LATEST_EVENT:
|
case FTS4_CMD_LATEST_EVENT:
|
||||||
case FTS4_CMD_READ_ONE_EVENT:
|
case FTS4_CMD_READ_ONE_EVENT:
|
||||||
case FTS4_CMD_READ_ALL_EVENT: {
|
case FTS4_CMD_READ_ALL_EVENT: {
|
||||||
|
|||||||
+78
-1
@@ -534,6 +534,11 @@ void display_write(EmuState *state, uint64_t addr, uint32_t val) {
|
|||||||
// PINMUX read-back cache to satisfy polling
|
// PINMUX read-back cache to satisfy polling
|
||||||
static uint32_t pinmux_reg[0x1000 / 4] = {0};
|
static uint32_t pinmux_reg[0x1000 / 4] = {0};
|
||||||
|
|
||||||
|
// Forward decls — these handlers live further down this file but are reached
|
||||||
|
// from misc_read's catch-all routing for DSI accesses.
|
||||||
|
uint32_t dsi_read(EmuState *state, uint64_t addr);
|
||||||
|
void dsi_write(EmuState *state, uint64_t addr, uint32_t val);
|
||||||
|
|
||||||
uint32_t misc_read(EmuState *state, uint64_t addr) {
|
uint32_t misc_read(EmuState *state, uint64_t addr) {
|
||||||
if (addr >= PINMUX_BASE && addr < PINMUX_BASE + PINMUX_SIZE) {
|
if (addr >= PINMUX_BASE && addr < PINMUX_BASE + PINMUX_SIZE) {
|
||||||
return pinmux_reg[(addr - PINMUX_BASE) / 4];
|
return pinmux_reg[(addr - PINMUX_BASE) / 4];
|
||||||
@@ -556,7 +561,7 @@ uint32_t misc_read(EmuState *state, uint64_t addr) {
|
|||||||
}
|
}
|
||||||
// DSI
|
// DSI
|
||||||
if (addr >= DSI_BASE && addr < DSI_BASE + DSI_SIZE) {
|
if (addr >= DSI_BASE && addr < DSI_BASE + DSI_SIZE) {
|
||||||
return 0;
|
return dsi_read(state, addr);
|
||||||
}
|
}
|
||||||
// MC
|
// MC
|
||||||
if (addr >= MC_BASE && addr < MC_BASE + MC_SIZE) {
|
if (addr >= MC_BASE && addr < MC_BASE + MC_SIZE) {
|
||||||
@@ -1353,6 +1358,76 @@ void emc_write(EmuState *state, uint64_t addr, uint32_t val) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ==================== DSI (display panel ID over MIPI-DSI) ====================
|
||||||
|
//
|
||||||
|
// Hekate's display init calls display_dsi_read(MIPI_DCS_GET_DISPLAY_ID, 3, ...)
|
||||||
|
// to identify the LCD panel. The read sequence:
|
||||||
|
// 1. send (cmd << 8) | MIPI_DSI_DCS_READ to DSI_WR_DATA, then write
|
||||||
|
// DSI_TRIGGER = HOST. We capture the requested DCS reg here.
|
||||||
|
// 2. write DSI_HOST_CONTROL with bit 3 (IMM_BTA) set, then poll until that
|
||||||
|
// bit clears. We auto-clear it on the next read and prep an RX FIFO.
|
||||||
|
// 3. read DSI_STATUS for fifo count, then drain DSI_RD_DATA. We expose
|
||||||
|
// three words: DSI_ESCAPE_CMD, (3 << 8) | DCS_LONG_RD_RES, panel_id_raw.
|
||||||
|
//
|
||||||
|
// On any unrecognized DCS read, _panel_id_raw stays at the 0xCCCCCC sentinel
|
||||||
|
// Hekate seeds, which renders as "Failed to get info!". Default panel reply
|
||||||
|
// matches a JDI LAM062M109A (0x099310 -> decoded 0x0910).
|
||||||
|
|
||||||
|
static constexpr uint32_t DSI_RD_DATA = 0x9 << 2; // 0x024
|
||||||
|
static constexpr uint32_t DSI_WR_DATA = 0xA << 2; // 0x028
|
||||||
|
static constexpr uint32_t DSI_HOST_CONTROL = 0xF << 2; // 0x03C
|
||||||
|
static constexpr uint32_t DSI_TRIGGER = 0x13 << 2; // 0x04C
|
||||||
|
static constexpr uint32_t DSI_STATUS = 0x15 << 2; // 0x054
|
||||||
|
|
||||||
|
static constexpr uint8_t MIPI_DSI_DCS_READ = 0x06;
|
||||||
|
static constexpr uint8_t MIPI_DCS_GET_DISPLAY_ID = 0x04;
|
||||||
|
static constexpr uint8_t DSI_ESCAPE_CMD = 0x87;
|
||||||
|
static constexpr uint8_t DCS_LONG_RD_RES = 0x1C;
|
||||||
|
|
||||||
|
static uint8_t g_dsi_pending_dcs_cmd = 0;
|
||||||
|
static uint32_t g_dsi_rx_fifo[8] = {0};
|
||||||
|
static uint32_t g_dsi_rx_count = 0;
|
||||||
|
static uint32_t g_dsi_rx_pos = 0;
|
||||||
|
|
||||||
|
static void dsi_prepare_response(EmuState *state) {
|
||||||
|
if (g_dsi_pending_dcs_cmd != MIPI_DCS_GET_DISPLAY_ID) {
|
||||||
|
g_dsi_rx_count = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
g_dsi_rx_fifo[0] = DSI_ESCAPE_CMD;
|
||||||
|
g_dsi_rx_fifo[1] = (3u << 8) | DCS_LONG_RD_RES;
|
||||||
|
g_dsi_rx_fifo[2] = state->panel_id_raw.load() & 0xFFFFFF;
|
||||||
|
g_dsi_rx_count = 3;
|
||||||
|
g_dsi_rx_pos = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t dsi_read(EmuState *state, uint64_t addr) {
|
||||||
|
uint32_t offset = (uint32_t)(addr - DSI_BASE);
|
||||||
|
switch (offset) {
|
||||||
|
case DSI_STATUS: {
|
||||||
|
uint32_t left = (g_dsi_rx_pos < g_dsi_rx_count) ? (g_dsi_rx_count - g_dsi_rx_pos) : 0;
|
||||||
|
return left & 0x1F; // DSI_STATUS_RX_FIFO_SIZE mask
|
||||||
|
}
|
||||||
|
case DSI_RD_DATA:
|
||||||
|
if (g_dsi_rx_pos < g_dsi_rx_count)
|
||||||
|
return g_dsi_rx_fifo[g_dsi_rx_pos++];
|
||||||
|
return 0;
|
||||||
|
case DSI_HOST_CONTROL: return 0; // IMM_BTA always clear (we ack instantly)
|
||||||
|
case DSI_TRIGGER: return 0; // trigger always clear
|
||||||
|
default: return 0;
|
||||||
|
}
|
||||||
|
(void)state;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dsi_write(EmuState *state, uint64_t addr, uint32_t val) {
|
||||||
|
uint32_t offset = (uint32_t)(addr - DSI_BASE);
|
||||||
|
if (offset == DSI_WR_DATA && (val & 0xFF) == MIPI_DSI_DCS_READ) {
|
||||||
|
g_dsi_pending_dcs_cmd = (val >> 8) & 0xFF;
|
||||||
|
} else if (offset == DSI_HOST_CONTROL && (val & (1u << 3))) {
|
||||||
|
dsi_prepare_response(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ==================== SE (Security Engine) ====================
|
// ==================== SE (Security Engine) ====================
|
||||||
// Real AES-128 implementation lives in t210/se_engine.cpp. The functions
|
// Real AES-128 implementation lives in t210/se_engine.cpp. The functions
|
||||||
// below are thin shims so the existing dispatcher routing keeps working.
|
// below are thin shims so the existing dispatcher routing keeps working.
|
||||||
@@ -1633,6 +1708,8 @@ static void hook_mmio_write(uc_engine *uc, uc_mem_type type, uint64_t address,
|
|||||||
} else if (address >= DISPLAY_A_BASE &&
|
} else if (address >= DISPLAY_A_BASE &&
|
||||||
address < DISPLAY_A_BASE + DISPLAY_SIZE) {
|
address < DISPLAY_A_BASE + DISPLAY_SIZE) {
|
||||||
display_write(state, address, val);
|
display_write(state, address, val);
|
||||||
|
} else if (address >= DSI_BASE && address < DSI_BASE + DSI_SIZE) {
|
||||||
|
dsi_write(state, address, val);
|
||||||
} else if (address >= PMC_BASE && address < PMC_BASE + PMC_SIZE) {
|
} else if (address >= PMC_BASE && address < PMC_BASE + PMC_SIZE) {
|
||||||
pmc_write(state, address, val);
|
pmc_write(state, address, val);
|
||||||
} else if (address >= 0x60007000 && address < 0x60007000 + 0x1000) {
|
} else if (address >= 0x60007000 && address < 0x60007000 + 0x1000) {
|
||||||
|
|||||||
Reference in new issue
Block a user