diff --git a/modules/mipi_dsi/mipi_dsi.h b/modules/mipi_dsi/mipi_dsi.h index 49473ef..ed4e9d7 100644 --- a/modules/mipi_dsi/mipi_dsi.h +++ b/modules/mipi_dsi/mipi_dsi.h @@ -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; diff --git a/modules/mipi_dsi/mipi_dsi_drv.c b/modules/mipi_dsi/mipi_dsi_drv.c index 0544c7c..d662785 100644 --- a/modules/mipi_dsi/mipi_dsi_drv.c +++ b/modules/mipi_dsi/mipi_dsi_drv.c @@ -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; diff --git a/modules/mipi_dsi/touch_panel.c b/modules/mipi_dsi/touch_panel.c index e759264..3adff7b 100644 --- a/modules/mipi_dsi/touch_panel.c +++ b/modules/mipi_dsi/touch_panel.c @@ -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; @@ -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); diff --git a/overlays/rpi/reTerminal-overlay.dts b/overlays/rpi/reTerminal-overlay.dts index 14f7104..1f924fc 100644 --- a/overlays/rpi/reTerminal-overlay.dts +++ b/overlays/rpi/reTerminal-overlay.dts @@ -107,6 +107,7 @@ reg = <0x45>; mcu_auto_reset_enable = <0>; + tp_point_rotate = <0>; port { panel_dsi_port: endpoint { @@ -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"; }; };