Skip to content

Commit

Permalink
make it able to enable/disable the TP point rotate
Browse files Browse the repository at this point in the history
you can enable it by add "dtoverlay=reTerminal,tp_rotate=1"
or "dtparam=rp_rotate=1" to /boot/config.txt
  • Loading branch information
bigbearishappy committed Aug 10, 2021
1 parent d20b05b commit f972140
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules/mipi_dsi/mipi_dsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ struct i2c_mipi_dsi {
// tp
struct input_dev *input;
struct touchscreen_properties prop;
uint32_t tp_point_rotate;

// backlight
int brightness;
Expand Down
5 changes: 5 additions & 0 deletions modules/mipi_dsi/mipi_dsi_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,11 @@ static int i2c_md_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
}
i2c_md_write(md, REG_MCU_AUTO_RESET, (md->mcu_auto_reset&0xff));

ret = device_property_read_u32(dev, "tp_point_rotate", &md->tp_point_rotate);
if(ret < 0){
dev_err(dev, "Can't get the data of tp_point_rotate!\n");
}

DBG_FUNC("finished.");

return 0;
Expand Down
38 changes: 38 additions & 0 deletions modules/mipi_dsi/touch_panel.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,41 @@ static int goodix_ts_read_input_report(struct i2c_mipi_dsi *md, u8 *data)
return -ENOMSG;
}

//TODO
//need more work for it's compatibility
static void x_y_rotate(int *x, int *y)
{
int temp_x,temp_y;
int temp;

if(*x < 0 || *y < 0) {
printk(KERN_ERR"%s<%d> parameter error\n", __func__, __LINE__);
return ;
}
//1 move rectangle center to (0,0)
temp_x = *x - TP_DEFAULT_WIDTH/2;
temp_y = *y - TP_DEFAULT_HEIGHT/2;

//2 rotate the point anti-clockwise for 90 degree
temp = temp_x;
temp_x = temp_y;
temp_y = temp;

temp_x *= (-1);
temp_y *= 1;

//3 zoom
temp_x = temp_x * TP_DEFAULT_WIDTH / TP_DEFAULT_HEIGHT;
temp_y = temp_y * TP_DEFAULT_HEIGHT / TP_DEFAULT_WIDTH;

//4 move rectangle center back to (TP_DEFAULT_WIDTH/2, TP_DEFAULT_HEIGHT/2)
temp_x += TP_DEFAULT_WIDTH/2;
temp_y += TP_DEFAULT_HEIGHT/2;

*x = temp_x;
*y = temp_y;
}

static void goodix_ts_report_touch_8b(struct i2c_mipi_dsi *md, u8 *coor_data)
{
struct input_dev *input_dev = md->input;
Expand All @@ -62,6 +97,9 @@ static void goodix_ts_report_touch_8b(struct i2c_mipi_dsi *md, u8 *coor_data)
input_y <<= 8;
input_y += coor_data[2];

if(md->tp_point_rotate)
x_y_rotate(&input_x, &input_y);

input_mt_slot(input_dev, id);
input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, true);
touchscreen_report_pos(input_dev, &md->prop, input_x, input_y, true);
Expand Down
2 changes: 2 additions & 0 deletions overlays/rpi/reTerminal-overlay.dts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
reg = <0x45>;

mcu_auto_reset_enable = <0>;
tp_point_rotate = <0>;

port {
panel_dsi_port: endpoint {
Expand Down Expand Up @@ -237,6 +238,7 @@
key3 = <&usr_btn3>,"linux,code:0";

mcu_auto_reset = <&mipi_dsi>,"mcu_auto_reset_enable:0";
tp_rotate = <&mipi_dsi>,"tp_point_rotate:0";
};
};

0 comments on commit f972140

Please sign in to comment.