mirror of
https://github.com/CTCaer/hekate
synced 2024-12-22 11:21:23 +00:00
nyx: Add touch panel info
This can probably also show if the panel is paired to the firmware. In case it's not, an error will show up.
This commit is contained in:
parent
31baf3d19a
commit
0959dc3a2d
3 changed files with 109 additions and 28 deletions
|
@ -33,6 +33,16 @@
|
||||||
#include <gfx_utils.h>
|
#include <gfx_utils.h>
|
||||||
#define DPRINTF(...) gfx_printf(__VA_ARGS__)
|
#define DPRINTF(...) gfx_printf(__VA_ARGS__)
|
||||||
|
|
||||||
|
static touch_panel_info_t _panels[] =
|
||||||
|
{
|
||||||
|
{ 0, 1, 1, 1, "NISSHA NFT-K12D" },
|
||||||
|
{ 1, 0, 1, 1, "GiS GGM6 B2X" },
|
||||||
|
{ 2, 0, 0, 0, "NISSHA NBF-K9A" },
|
||||||
|
{ 3, 1, 0, 0, "GiS 5.5\"" },
|
||||||
|
{ 4, 0, 0, 1, "Unknown" },
|
||||||
|
{ -1, 1, 0, 1, "GiS VA 6.2\"" }
|
||||||
|
};
|
||||||
|
|
||||||
static int touch_command(u8 cmd, u8 *buf, u8 size)
|
static int touch_command(u8 cmd, u8 *buf, u8 size)
|
||||||
{
|
{
|
||||||
int res = i2c_send_buf_small(I2C_3, STMFTS_I2C_ADDR, cmd, buf, size);
|
int res = i2c_send_buf_small(I2C_3, STMFTS_I2C_ADDR, cmd, buf, size);
|
||||||
|
@ -52,7 +62,7 @@ static int touch_read_reg(u8 *cmd, u32 csize, u8 *buf, u32 size)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int touch_wait_event(u8 event, u8 status, u32 timeout)
|
static int touch_wait_event(u8 event, u8 status, u32 timeout, u8 *buf)
|
||||||
{
|
{
|
||||||
u32 timer = get_tmr_ms() + timeout;
|
u32 timer = get_tmr_ms() + timeout;
|
||||||
while (true)
|
while (true)
|
||||||
|
@ -60,7 +70,11 @@ static int touch_wait_event(u8 event, u8 status, u32 timeout)
|
||||||
u8 tmp[8] = {0};
|
u8 tmp[8] = {0};
|
||||||
i2c_recv_buf_small(tmp, 8, I2C_3, STMFTS_I2C_ADDR, STMFTS_READ_ONE_EVENT);
|
i2c_recv_buf_small(tmp, 8, I2C_3, STMFTS_I2C_ADDR, STMFTS_READ_ONE_EVENT);
|
||||||
if (tmp[1] == event && tmp[2] == status)
|
if (tmp[1] == event && tmp[2] == status)
|
||||||
|
{
|
||||||
|
if (buf)
|
||||||
|
memcpy(buf, &tmp[3], 5);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (get_tmr_ms() > timer)
|
if (get_tmr_ms() > timer)
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -146,10 +160,10 @@ static void _touch_parse_event(touch_event *event)
|
||||||
event->type = STMFTS_EV_MULTI_TOUCH_LEAVE;
|
event->type = STMFTS_EV_MULTI_TOUCH_LEAVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// gfx_con_setpos(&gfx_con, 0, 300);
|
// gfx_con_setpos(0, 300);
|
||||||
// DPRINTF("x = %d \ny = %d \nz = %d \n", event->x, event->y, event->z);
|
// DPRINTF("x = %d \ny = %d \nz = %d \n", event->x, event->y, event->z);
|
||||||
// DPRINTF("0 = %02X\n1 = %02x\n2 = %02x\n3 = %02x\n", event->raw[0], event->raw[1], event->raw[2], event->raw[3]);
|
// DPRINTF("0 = %02X\n1 = %02X\n2 = %02X\n3 = %02X\n", event->raw[0], event->raw[1], event->raw[2], event->raw[3]);
|
||||||
// DPRINTF("4 = %02X\n5 = %02x\n6 = %02x\n7 = %02x\n", event->raw[4], event->raw[5], event->raw[6], event->raw[7]);
|
// DPRINTF("4 = %02X\n5 = %02X\n6 = %02X\n7 = %02X\n", event->raw[4], event->raw[5], event->raw[6], event->raw[7]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void touch_poll(touch_event *event)
|
void touch_poll(touch_event *event)
|
||||||
|
@ -182,12 +196,33 @@ touch_info touch_get_info()
|
||||||
info.config_id = buf[4];
|
info.config_id = buf[4];
|
||||||
info.config_ver = buf[5];
|
info.config_ver = buf[5];
|
||||||
|
|
||||||
//DPRINTF("ID: %04X, FW Ver: %d.%02d\nCfg ID: %02x, Cfg Ver: %d\n",
|
//DPRINTF("ID: %04X, FW Ver: %d.%02d\nCfg ID: %02X, Cfg Ver: %d\n",
|
||||||
// info.chip_id, info.fw_ver >> 8, info.fw_ver & 0xFF, info.config_id, info.config_ver);
|
// info.chip_id, info.fw_ver >> 8, info.fw_ver & 0xFF, info.config_id, info.config_ver);
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
touch_panel_info_t *touch_get_panel_vendor()
|
||||||
|
{
|
||||||
|
u8 buf[5] = {0};
|
||||||
|
u8 cmd = STMFTS_VENDOR_GPIO_STATE;
|
||||||
|
|
||||||
|
if (touch_command(STMFTS_VENDOR, &cmd, 1))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (touch_wait_event(STMFTS_EV_VENDOR, STMFTS_VENDOR_GPIO_STATE, 2000, buf))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (u32 i = 0; i < ARRAY_SIZE(_panels); i++)
|
||||||
|
{
|
||||||
|
touch_panel_info_t *panel = &_panels[i];
|
||||||
|
if (buf[0] == panel->gpio0 && buf[1] == panel->gpio1 && buf[2] == panel->gpio2)
|
||||||
|
return panel;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
int touch_get_fw_info(touch_fw_info_t *fw)
|
int touch_get_fw_info(touch_fw_info_t *fw)
|
||||||
{
|
{
|
||||||
u8 buf[8] = {0};
|
u8 buf[8] = {0};
|
||||||
|
@ -226,7 +261,7 @@ int touch_sys_reset()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
msleep(10);
|
msleep(10);
|
||||||
if (touch_wait_event(STMFTS_EV_CONTROLLER_READY, 0, 20))
|
if (touch_wait_event(STMFTS_EV_CONTROLLER_READY, 0, 20, NULL))
|
||||||
continue;
|
continue;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -300,9 +335,9 @@ int touch_get_fb_info(u8 *buf)
|
||||||
|
|
||||||
int touch_sense_enable()
|
int touch_sense_enable()
|
||||||
{
|
{
|
||||||
// Enable auto tuning calibration and multi-touch sensing.
|
// Switch sense mode and enable multi-touch sensing.
|
||||||
u8 cmd = 1;
|
u8 cmd = STMFTS_FINGER_MODE;
|
||||||
if (touch_command(STMFTS_AUTO_CALIBRATION, &cmd, 1))
|
if (touch_command(STMFTS_SWITCH_SENSE_MODE, &cmd, 1))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (touch_command(STMFTS_MS_MT_SENSE_ON, NULL, 0))
|
if (touch_command(STMFTS_MS_MT_SENSE_ON, NULL, 0))
|
||||||
|
@ -328,19 +363,19 @@ int touch_execute_autotune()
|
||||||
// Apply Mutual Sense Compensation tuning.
|
// Apply Mutual Sense Compensation tuning.
|
||||||
if (touch_command(STMFTS_MS_CX_TUNING, NULL, 0))
|
if (touch_command(STMFTS_MS_CX_TUNING, NULL, 0))
|
||||||
return 0;
|
return 0;
|
||||||
if (touch_wait_event(STMFTS_EV_STATUS, STMFTS_EV_STATUS_MS_CX_TUNING_DONE, 2000))
|
if (touch_wait_event(STMFTS_EV_STATUS, STMFTS_EV_STATUS_MS_CX_TUNING_DONE, 2000, NULL))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Apply Self Sense Compensation tuning.
|
// Apply Self Sense Compensation tuning.
|
||||||
if (touch_command(STMFTS_SS_CX_TUNING, NULL, 0))
|
if (touch_command(STMFTS_SS_CX_TUNING, NULL, 0))
|
||||||
return 0;
|
return 0;
|
||||||
if (touch_wait_event(STMFTS_EV_STATUS, STMFTS_EV_STATUS_SS_CX_TUNING_DONE, 2000))
|
if (touch_wait_event(STMFTS_EV_STATUS, STMFTS_EV_STATUS_SS_CX_TUNING_DONE, 2000, NULL))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Save Compensation data to EEPROM.
|
// Save Compensation data to EEPROM.
|
||||||
if (touch_command(STMFTS_SAVE_CX_TUNING, NULL, 0))
|
if (touch_command(STMFTS_SAVE_CX_TUNING, NULL, 0))
|
||||||
return 0;
|
return 0;
|
||||||
if (touch_wait_event(STMFTS_EV_STATUS, STMFTS_EV_STATUS_WRITE_CX_TUNE_DONE, 2000))
|
if (touch_wait_event(STMFTS_EV_STATUS, STMFTS_EV_STATUS_WRITE_CX_TUNE_DONE, 2000, NULL))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return touch_sense_enable();
|
return touch_sense_enable();
|
||||||
|
@ -383,7 +418,7 @@ int touch_power_on()
|
||||||
i2c_init(I2C_3);
|
i2c_init(I2C_3);
|
||||||
|
|
||||||
// Wait for the touchscreen module to get ready.
|
// Wait for the touchscreen module to get ready.
|
||||||
touch_wait_event(STMFTS_EV_CONTROLLER_READY, 0, 20);
|
touch_wait_event(STMFTS_EV_CONTROLLER_READY, 0, 20, NULL);
|
||||||
|
|
||||||
// Check for forced boot time calibration.
|
// Check for forced boot time calibration.
|
||||||
if (btn_read_vol() == (BTN_VOL_UP | BTN_VOL_DOWN))
|
if (btn_read_vol() == (BTN_VOL_UP | BTN_VOL_DOWN))
|
||||||
|
|
|
@ -47,19 +47,26 @@
|
||||||
#define STMFTS_ITO_CHECK 0xA7
|
#define STMFTS_ITO_CHECK 0xA7
|
||||||
#define STMFTS_RELEASEINFO 0xAA
|
#define STMFTS_RELEASEINFO 0xAA
|
||||||
#define STMFTS_WRITE_REG 0xB6
|
#define STMFTS_WRITE_REG 0xB6
|
||||||
#define STMFTS_AUTO_CALIBRATION 0xC3
|
#define STMFTS_SWITCH_SENSE_MODE 0xC3
|
||||||
#define STMFTS_NOISE_WRITE 0xC7
|
#define STMFTS_NOISE_WRITE 0xC7
|
||||||
#define STMFTS_NOISE_READ 0xC8
|
#define STMFTS_NOISE_READ 0xC8
|
||||||
#define STMFTS_RW_FRAMEBUFFER_REG 0xD0
|
#define STMFTS_RW_FRAMEBUFFER_REG 0xD0
|
||||||
#define STMFTS_SAVE_CX_TUNING 0xFC
|
#define STMFTS_SAVE_CX_TUNING 0xFC
|
||||||
|
|
||||||
#define STMFTS_UNK0 0xB8 //Request compensation
|
#define STMFTS_REQU_COMP_DATA 0xB8
|
||||||
#define STMFTS_UNK1 0xCF
|
#define STMFTS_VENDOR 0xCF
|
||||||
#define STMFTS_UNK2 0xF7
|
#define STMFTS_FLASH_UNLOCK 0xF7
|
||||||
#define STMFTS_UNK3 0xFA
|
#define STMFTS_FLASH_WRITE_64K 0xF8
|
||||||
#define STMFTS_UNK4 0xF9
|
#define STMFTS_FLASH_STATUS 0xF9
|
||||||
|
#define STMFTS_FLASH_OP 0xFA
|
||||||
#define STMFTS_UNK5 0x62
|
#define STMFTS_UNK5 0x62
|
||||||
|
|
||||||
|
/* cmd parameters */
|
||||||
|
#define STMFTS_VENDOR_GPIO_STATE 0x01
|
||||||
|
#define STMFTS_VENDOR_SENSE_MODE 0x02
|
||||||
|
#define STMFTS_STYLUS_MODE 0x00
|
||||||
|
#define STMFTS_FINGER_MODE 0x01
|
||||||
|
#define STMFTS_HOVER_MODE 0x02
|
||||||
|
|
||||||
/* events */
|
/* events */
|
||||||
#define STMFTS_EV_NO_EVENT 0x00
|
#define STMFTS_EV_NO_EVENT 0x00
|
||||||
|
@ -74,6 +81,7 @@
|
||||||
#define STMFTS_EV_ERROR 0x0f
|
#define STMFTS_EV_ERROR 0x0f
|
||||||
#define STMFTS_EV_NOISE_READ 0x17
|
#define STMFTS_EV_NOISE_READ 0x17
|
||||||
#define STMFTS_EV_NOISE_WRITE 0x18
|
#define STMFTS_EV_NOISE_WRITE 0x18
|
||||||
|
#define STMFTS_EV_VENDOR 0x20
|
||||||
|
|
||||||
#define STMFTS_EV_CONTROLLER_READY 0x10
|
#define STMFTS_EV_CONTROLLER_READY 0x10
|
||||||
#define STMFTS_EV_STATUS 0x16
|
#define STMFTS_EV_STATUS 0x16
|
||||||
|
@ -131,6 +139,15 @@ typedef struct _touch_event {
|
||||||
bool touch;
|
bool touch;
|
||||||
} touch_event;
|
} touch_event;
|
||||||
|
|
||||||
|
typedef struct _touch_panel_info_t
|
||||||
|
{
|
||||||
|
u8 idx;
|
||||||
|
u8 gpio0;
|
||||||
|
u8 gpio1;
|
||||||
|
u8 gpio2;
|
||||||
|
char *vendor;
|
||||||
|
} touch_panel_info_t;
|
||||||
|
|
||||||
typedef struct _touch_info {
|
typedef struct _touch_info {
|
||||||
u16 chip_id;
|
u16 chip_id;
|
||||||
u16 fw_ver;
|
u16 fw_ver;
|
||||||
|
@ -146,6 +163,7 @@ typedef struct _touch_fw_info_t {
|
||||||
|
|
||||||
void touch_poll(touch_event *event);
|
void touch_poll(touch_event *event);
|
||||||
touch_event touch_poll_wait();
|
touch_event touch_poll_wait();
|
||||||
|
touch_panel_info_t *touch_get_panel_vendor();
|
||||||
int touch_get_fw_info(touch_fw_info_t *fw);
|
int touch_get_fw_info(touch_fw_info_t *fw);
|
||||||
touch_info touch_get_info();
|
touch_info touch_get_info();
|
||||||
int touch_panel_ito_test(u8 *err);
|
int touch_panel_ito_test(u8 *err);
|
||||||
|
|
|
@ -909,37 +909,65 @@ static lv_res_t _create_window_fuses_info_status(lv_obj_t *btn)
|
||||||
nyx_str->info.disp_id & 0xFF, (nyx_str->info.disp_id >> 8) & 0xFF, (nyx_str->info.disp_id >> 16) & 0xFF);
|
nyx_str->info.disp_id & 0xFF, (nyx_str->info.disp_id >> 8) & 0xFF, (nyx_str->info.disp_id >> 16) & 0xFF);
|
||||||
|
|
||||||
touch_fw_info_t touch_fw;
|
touch_fw_info_t touch_fw;
|
||||||
|
touch_panel_info_t *touch_panel;
|
||||||
|
bool panel_ic_paired = false;
|
||||||
|
|
||||||
if (!touch_get_fw_info(&touch_fw))
|
if (!touch_get_fw_info(&touch_fw))
|
||||||
{
|
{
|
||||||
strcat(txt_buf, "\n\n#00DDFF Touch Panel:#\n#FF8000 Model:# ");
|
strcat(txt_buf, "\n\n#00DDFF Touch Panel:#\n#FF8000 Model:# ");
|
||||||
|
|
||||||
|
touch_panel = touch_get_panel_vendor();
|
||||||
|
if (touch_panel)
|
||||||
|
strcat(txt_buf, touch_panel->vendor);
|
||||||
|
else
|
||||||
|
strcat(txt_buf, "Unknown #FFDD00 Contact me!#");
|
||||||
|
|
||||||
|
s_printf(txt_buf + strlen(txt_buf), "\n#FF8000 ID:# %08X (", touch_fw.fw_id);
|
||||||
|
|
||||||
switch (touch_fw.fw_id)
|
switch (touch_fw.fw_id)
|
||||||
{
|
{
|
||||||
case 0x100100:
|
case 0x00100100:
|
||||||
strcat(txt_buf, "NTD 4CD 1601");
|
strcat(txt_buf, "4CD 1601");
|
||||||
|
if (touch_panel)
|
||||||
|
panel_ic_paired = touch_panel->idx == -1;
|
||||||
break;
|
break;
|
||||||
case 0x00120100:
|
case 0x00120100:
|
||||||
case 0x32000001:
|
case 0x32000001:
|
||||||
strcat(txt_buf, "NTD 4CD 1801");
|
strcat(txt_buf, "4CD 1801");
|
||||||
|
if (touch_panel)
|
||||||
|
panel_ic_paired = touch_panel->idx == 0;
|
||||||
break;
|
break;
|
||||||
case 0x001A0300:
|
case 0x001A0300:
|
||||||
case 0x32000102:
|
case 0x32000102:
|
||||||
strcat(txt_buf, "NTD 4CD 2602");
|
strcat(txt_buf, "4CD 2602");
|
||||||
|
if (touch_panel)
|
||||||
|
panel_ic_paired = touch_panel->idx == 1;
|
||||||
break;
|
break;
|
||||||
case 0x00290100:
|
case 0x00290100:
|
||||||
case 0x32000302:
|
case 0x32000302:
|
||||||
strcat(txt_buf, "NTD 4CD 3801");
|
strcat(txt_buf, "4CD 3801");
|
||||||
|
if (touch_panel)
|
||||||
|
panel_ic_paired = touch_panel->idx == 2;
|
||||||
break;
|
break;
|
||||||
case 0x31051820:
|
case 0x31051820:
|
||||||
case 0x32000402:
|
case 0x32000402:
|
||||||
strcat(txt_buf, "NTD 4CD XXXX");
|
strcat(txt_buf, "4CD XXXX");
|
||||||
|
if (touch_panel)
|
||||||
|
panel_ic_paired = touch_panel->idx == 3;
|
||||||
|
break;
|
||||||
|
case 0x32000501:
|
||||||
|
case 0x33000502:
|
||||||
|
strcat(txt_buf, "4CD UNKN");
|
||||||
|
if (touch_panel)
|
||||||
|
panel_ic_paired = touch_panel->idx == 4;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
strcat(txt_buf, "Unknown");
|
strcat(txt_buf, "#FF8000 Unknown#");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
s_printf(txt_buf + strlen(txt_buf), "\n#FF8000 ID:# %X\n#FF8000 FTB ver:# %04X\n#FF8000 FW rev:# %04X",
|
s_printf(txt_buf + strlen(txt_buf), " - %s)\n#FF8000 FTB ver:# %04X\n#FF8000 FW rev:# %04X",
|
||||||
touch_fw.fw_id, touch_fw.ftb_ver, touch_fw.fw_rev);
|
panel_ic_paired ? "Paired" : "#FFDD00 Error#", touch_fw.ftb_ver, touch_fw.fw_rev);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if patched unit.
|
// Check if patched unit.
|
||||||
|
|
Loading…
Reference in a new issue