Browse Source

touch: raydium: glink slate acknowledgement

Implemented Glink Slate acknowledgement response for raydium
Touch driver.

Signed-off-by: Srikanth Katteboina <[email protected]>
Change-Id: Ieba8293d678a0422e6f2caf968312d0c9d96b972
Srikanth Katteboina 1 year ago
parent
commit
7c25ef2f97
4 changed files with 70 additions and 37 deletions
  1. 3 2
      glink_interface_ts/glink_interface.h
  2. 15 8
      raydium/raydium_driver.c
  3. 1 0
      raydium/raydium_driver.h
  4. 51 27
      raydium/raydium_sysfs.c

+ 3 - 2
glink_interface_ts/glink_interface.h

@@ -21,7 +21,7 @@
 #include <linux/rpmsg.h>
 
 
-#define	TOUCH_GLINK_INTENT_SIZE	0x04
+#define	TOUCH_GLINK_INTENT_SIZE	0x0c
 #define TOUCH_MSG_SIZE 0x08
 #define TIMEOUT_MS 2000
 
@@ -61,6 +61,7 @@ struct touch_channel_ops {
 void glink_touch_channel_init(void (*fn1)(bool), void (*fn2)(void *, int));
 
 
+
 #if IS_ENABLED(CONFIG_MSM_SLATERSB_RPMSG)
 int glink_touch_tx_msg(void  *msg, size_t len);
 #else
@@ -70,4 +71,4 @@ static inline int glink_touch_tx_msg(void  *msg, size_t len)
 }
 #endif
 
-#endif
+#endif

+ 15 - 8
raydium/raydium_driver.c

@@ -2112,20 +2112,27 @@ void touch_notify_glink_channel_state(bool state)
 
 void glink_touch_rx_msg(void *data, int len)
 {
-	struct glink_touch_priv *dev =
-		container_of(glink_touch_drv, struct glink_touch_priv, lhndl);
-	LOGD(LOG_INFO, "%s:[touch] TOUCH_RX_MSG Start:\n", __func__);
+	int rc = 0;
+
+	LOGD(LOG_INFO, "%s:[touch]TOUCH_RX_MSG Start:\n", __func__);
 
 	if (len > TOUCH_GLINK_INTENT_SIZE) {
 		LOGD(LOG_ERR, "Invalid TOUCH glink intent size\n");
 		return;
 	}
-	dev->glink_touch_cmplt = true;
-	wake_up(&dev->link_state_wait);
-	memcpy(dev->rx_buf, data, len);
-	LOGD(LOG_INFO, "%s: TOUCH_RX_MSG End:\n", __func__);
-}
 
+	/* check SLATE response */
+	slate_ack_resp = *(uint32_t *)&data[8];
+	LOGD(LOG_INFO, "[touch]slate_ack_resp :%0x\n", slate_ack_resp);
+	if (slate_ack_resp == 0x01) {
+			LOGD(LOG_INFO,"Bad SLATE response\n");
+			rc = -EINVAL;
+			goto err_ret;
+	}
+	LOGD(LOG_INFO, "%s:[touch]TOUCH_RX_MSG End:\n", __func__);
+err_ret:
+return;
+}
 
 static int raydium_set_resolution(void)
 {

+ 1 - 0
raydium/raydium_driver.h

@@ -275,6 +275,7 @@
 #include <drm/drm_panel.h>
 #endif
 
+extern uint32_t slate_ack_resp;
 
 enum raydium_fb_state {
 	FB_ON,

+ 51 - 27
raydium/raydium_sysfs.c

@@ -36,6 +36,8 @@ static void raydium_ts_touch_entry(void);
 static void raydium_ts_touch_exit(void);
 static int raydium_ts_gpio_config(bool on);
 
+uint32_t slate_ack_resp;
+
 static ssize_t raydium_touch_calibration_show(struct device *dev,
 		struct device_attribute *attr,
 		char *p_i8_buf)
@@ -296,62 +298,84 @@ static void raydium_ts_touch_entry(void)
 
 	int glink_touch_enter_prep = TOUCH_ENTER_PREPARE;
 	int glink_touch_enter = TOUCH_ENTER;
+	int rc = 0;
+
+	LOGD(LOG_INFO, "%s[touch] raydium_ts_touch_entry Start\n", __func__);
 
 	/*glink touch enter prepare cmd */
 	glink_send_msg = &glink_touch_enter_prep;
-	LOGD(LOG_INFO, "[touch] glink_send_msg = %d\n", glink_send_msg);
+	LOGD(LOG_INFO, "[touch] glink_send_msg = %0x\n", glink_send_msg);
 	glink_touch_tx_msg(glink_send_msg, TOUCH_MSG_SIZE);
 
+	if (slate_ack_resp != 0) {
+		rc = -EINVAL;
+		goto err_ret;
+	}
 	/*glink touch enter cmd */
 	glink_send_msg = &glink_touch_enter;
-	LOGD(LOG_INFO, "[touch]glink_send_msg = %d\n", glink_send_msg);
+	LOGD(LOG_INFO, "[touch]glink_send_msg = %0x\n", glink_send_msg);
 	glink_touch_tx_msg(glink_send_msg, TOUCH_MSG_SIZE);
 
-	//Release the gpio's
-	if (gpio_is_valid(g_raydium_ts->rst_gpio))
-		gpio_free(g_raydium_ts->rst_gpio);
+	if(slate_ack_resp == 0) {
+		//Release the gpio's
+		if (gpio_is_valid(g_raydium_ts->rst_gpio))
+			gpio_free(g_raydium_ts->rst_gpio);
 
-	if (gpio_is_valid(g_raydium_ts->irq_gpio))
-		gpio_free(g_raydium_ts->irq_gpio);
+		if (gpio_is_valid(g_raydium_ts->irq_gpio))
+			gpio_free(g_raydium_ts->irq_gpio);
 
-	raydium_irq_control(DISABLE);
+		raydium_irq_control(DISABLE);
 
-	if (!cancel_work_sync(&g_raydium_ts->work))
-		LOGD(LOG_DEBUG, "[touch]workqueue is empty!\n");
+		if (!cancel_work_sync(&g_raydium_ts->work))
+			LOGD(LOG_DEBUG, "[touch]workqueue is empty!\n");
 
-	/* release all touches */
-	for (u8_i = 0; u8_i < g_raydium_ts->u8_max_touchs; u8_i++) {
-		pr_err("[touch]%s 1111\n", __func__);
-		input_mt_slot(g_raydium_ts->input_dev, u8_i);
-		input_mt_report_slot_state(g_raydium_ts->input_dev,
+		/* release all touches */
+		for (u8_i = 0; u8_i < g_raydium_ts->u8_max_touchs; u8_i++) {
+			pr_err("[touch]%s 1111\n", __func__);
+			input_mt_slot(g_raydium_ts->input_dev, u8_i);
+			input_mt_report_slot_state(g_raydium_ts->input_dev,
 					   MT_TOOL_FINGER,
 					   false);
-	}
+		}
 
-	input_mt_report_pointer_emulation(g_raydium_ts->input_dev, false);
-	input_sync(g_raydium_ts->input_dev);
+		input_mt_report_pointer_emulation(g_raydium_ts->input_dev, false);
+		input_sync(g_raydium_ts->input_dev);
+	}
 
+	LOGD(LOG_INFO, "%s[touch] raydium_ts_touch_entry Start End\n", __func__);
+err_ret:
+	return;
 }
 
 
 static void raydium_ts_touch_exit(void)
 {
 
-	int ret = 0;
+	int ret = 0, rc = 0;
 	void *glink_send_msg;
 	int glink_touch_exit_prep = TOUCH_EXIT_PREPARE;
 	int glink_touch_exit = TOUCH_EXIT;
 
+
+	LOGD(LOG_INFO, "%s[touch]raydium_ts_touch_exit Start\n", __func__);
+
 	/*glink touch exit prepare cmd */
 	glink_send_msg = &glink_touch_exit_prep;
-	LOGD(LOG_INFO, "[touch]glink_send_msg = %d\n", glink_send_msg);
+	LOGD(LOG_INFO, "[touch]glink_send_msg = %0x\n", glink_send_msg);
 	glink_touch_tx_msg(glink_send_msg, TOUCH_MSG_SIZE);
 
-	//Configure the gpio's
-	ret = raydium_ts_gpio_config(true);
-	if (ret < 0) {
-		LOGD(LOG_ERR, "[touch]failed to configure the gpios\n");
-		goto err_gpio_req;
+	if (slate_ack_resp != 0) {
+		rc = -EINVAL;
+		goto err_ret;
+	}
+
+	else if(slate_ack_resp == 0) {
+		//Configure the gpio's
+		ret = raydium_ts_gpio_config(true);
+		if (ret < 0) {
+			LOGD(LOG_ERR, "[touch]failed to configure the gpios\n");
+			goto err_ret;
+		}
 	}
 
 	/*glink touch exit cmd */
@@ -359,8 +383,8 @@ static void raydium_ts_touch_exit(void)
 	LOGD(LOG_INFO, "[touch]glink_send_msg = %d\n", glink_send_msg);
 	glink_touch_tx_msg(glink_send_msg, TOUCH_MSG_SIZE);
 
-
-err_gpio_req:
+	LOGD(LOG_INFO, "%s[touch] raydium_ts_touch_exit End\n", __func__);
+err_ret:
 	return;
 
 }