mirror of
https://github.com/CTCaer/hekate
synced 2024-11-17 17:39:30 +00:00
touch: Add fw info
This commit is contained in:
parent
8539095bdb
commit
9697067466
2 changed files with 46 additions and 1 deletions
|
@ -41,6 +41,17 @@ static int touch_command(u8 cmd, u8 *buf, u8 size)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int touch_read_reg(u8 *cmd, u32 csize, u8 *buf, u32 size)
|
||||
{
|
||||
int res = i2c_send_buf_small(I2C_3, STMFTS_I2C_ADDR, cmd[0], &cmd[1], csize - 1);
|
||||
if (res)
|
||||
res = i2c_recv_buf(buf, size, I2C_3, STMFTS_I2C_ADDR);
|
||||
if (!res)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define X_REAL_MAX 1264
|
||||
#define Y_REAL_MAX 704
|
||||
#define EDGE_OFFSET 15
|
||||
|
@ -162,6 +173,33 @@ touch_info touch_get_info()
|
|||
return info;
|
||||
}
|
||||
|
||||
int touch_get_fw_info(touch_fw_info_t *fw)
|
||||
{
|
||||
u8 buf[8] = {0};
|
||||
|
||||
// Get fw address info.
|
||||
u8 cmd[3] = { STMFTS_RW_FRAMEBUFFER_REG, 0, 0x60 };
|
||||
int res = touch_read_reg(cmd, 3, buf, 3);
|
||||
if (!res)
|
||||
{
|
||||
// Get fw info.
|
||||
cmd[1] = buf[2]; cmd[2] = buf[1];
|
||||
res = touch_read_reg(cmd, 3, buf, 8);
|
||||
if (!res)
|
||||
{
|
||||
fw->fw_id = (buf[1] << 24) | (buf[2] << 16) | (buf[3] << 8) | buf[4];
|
||||
fw->ftb_ver = (buf[6] << 8) | buf[5];
|
||||
}
|
||||
|
||||
cmd[2]++;
|
||||
res = touch_read_reg(cmd, 3, buf, 8);
|
||||
if (!res)
|
||||
fw->fw_rev = (buf[7] << 8) | buf[6];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
int touch_power_on()
|
||||
{
|
||||
// Configure touchscreen GPIO.
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
#define STMFTS_AUTO_CALIBRATION 0xC3
|
||||
#define STMFTS_NOISE_WRITE 0xC7
|
||||
#define STMFTS_NOISE_READ 0xC8
|
||||
#define STMFTS_RW_FB_REG 0xD0 // read data
|
||||
#define STMFTS_RW_FRAMEBUFFER_REG 0xD0
|
||||
#define STMFTS_SAVE_CX_TUNING 0xFC
|
||||
|
||||
#define STMFTS_UNK0 0xB8 //Request compensation
|
||||
|
@ -113,10 +113,17 @@ typedef struct _touch_info {
|
|||
u16 config_ver;
|
||||
} touch_info;
|
||||
|
||||
typedef struct _touch_fw_info_t {
|
||||
u32 fw_id;
|
||||
u16 ftb_ver;
|
||||
u16 fw_rev;
|
||||
} touch_fw_info_t;
|
||||
|
||||
int touch_power_on();
|
||||
void touch_power_off();
|
||||
void touch_poll(touch_event *event);
|
||||
touch_event touch_poll_wait();
|
||||
int touch_get_fw_info(touch_fw_info_t *fw);
|
||||
touch_info touch_get_info();
|
||||
|
||||
#endif /* __TOUCH_H_ */
|
Loading…
Reference in a new issue