linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Tai <james.tai@realtek.com>
To: <james.ttl7447@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, "Andreas Färber" <afaerber@suse.de>,
	"Rob Herring" <robh+dt@kernel.org>,
	"Mark Rutland" <mark.rutland@arm.com>,
	devicetree@vger.kernel.org
Subject: [PATCH] [DEV_FIX][THOR][B00] Support multiple IR key [REVIEWER] Simon
Date: Mon, 10 Feb 2020 22:42:31 +0800	[thread overview]
Message-ID: <20200210144231.27237-1-james.tai@realtek.com> (raw)

Signed-off-by: James Tai <james.tai@realtek.com>
---
 rtd16xx_pm.c | 27 ++++++++++++++++-----------
 rtd16xx_pm.h | 12 ++++++++----
 2 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/rtd16xx_pm.c b/rtd16xx_pm.c
index b34ce94..1779670 100644
--- a/rtd16xx_pm.c
+++ b/rtd16xx_pm.c
@@ -44,7 +44,7 @@ unsigned int IsSuspendToWFI;
 unsigned int suspend_ChipVer;
 
 rtk_pm_event_func_t wakeup_events[RTK_PM_MAX_EVENTS];
-param_pwm_irda_key_t param_wakeup_ir_key[RTK_PM_MAX_IR_KEY];
+param_pwm_irda_key_t param_wakeup_ir_key[MAX_KEY_TBL];
 param_pwm_gpio_key_t Param_PWM_GPIO_Key;
 
 unsigned int bt_wakeup_flag;
@@ -119,7 +119,8 @@ int ir_power_on_check(void)
 	unsigned int key_mask = 0;
 	unsigned int power_key = 0;
 	unsigned int custom_key = 0;
-	int i = 0;
+	unsigned int power_keynum = 0;
+	int i = 0, j = 0;
 
 	sr_value = ACCESS(ISO_IR_SR_reg);
 	if(sr_value & 0x1) {
@@ -131,22 +132,24 @@ int ir_power_on_check(void)
 		if (sr_value & 0x2)
 			return 0;
 
-		for (i = 0 ; i < RTK_PM_MAX_IR_KEY ; i++) {
+		for (i = 0 ; i < MAX_KEY_TBL ; i++) {
 			key_shift = param_wakeup_ir_key[i].key_shift;
 			key_mask = param_wakeup_ir_key[i].key_mask;
 			custom_shift = param_wakeup_ir_key[i].custom_shift;
 			custom_mask = param_wakeup_ir_key[i].custom_mask;
-			power_key = param_wakeup_ir_key[i].power_key;
+			power_keynum = param_wakeup_ir_key[i].power_keynum;
 			custom_key = param_wakeup_ir_key[i].custom_key;
 			tmp1 = ((reg_value & key_mask) >> key_shift);
 			tmp2 = ((reg_value & custom_mask) >> custom_shift);
 
 			if (key_mask == 0 && custom_mask == 0) 
 				return 0;
-
-			if (power_key == tmp1 &&  custom_key == tmp2) {
-				ACCESS(0xD8007640) = 0xea000000 | (RESUME_IR << 16);
-				return 1;
+			for (j = 0; j < power_keynum; j++) {
+				power_key = param_wakeup_ir_key[i].power_key[j];
+				if (power_key == tmp1 &&  custom_key == tmp2) {
+					ACCESS(0xD8007640) = 0xea000000 | (RESUME_IR << 16);
+					return 1;
+				}
 			}
 		}
 	}
@@ -409,7 +412,7 @@ int rtk_power_on_event(void)
 
 void rtk_power_on_event_init(struct suspend_param *scpu_param)
 {
-	int i = 0;
+	int i = 0, j = 0;
 	wakeup_event_int_mask = 0;
 
 	if (7093279 != trace_power)
@@ -422,10 +425,12 @@ void rtk_power_on_event_init(struct suspend_param *scpu_param)
 
 	/* Enable IR Interrupt */
 	if (suspend_wakeup_flag & fWAKEUP_ON_IR) {
-		for (i = 0 ; i< 2; i++) {
+		for (i = 0 ; i < MAX_KEY_TBL ; i++) {
 			param_wakeup_ir_key[i].protocol = scpu_param->irda_info.key_tbl[i].protocol;
 			param_wakeup_ir_key[i].key_mask = scpu_param->irda_info.key_tbl[i].scancode_mask;
-			param_wakeup_ir_key[i].power_key = scpu_param->irda_info.key_tbl[i].wakeup_scancode;
+			param_wakeup_ir_key[i].power_keynum = scpu_param->irda_info.key_tbl[i].wakeup_keynum;
+			for (j = 0; j < param_wakeup_ir_key[i].power_keynum; j++)
+				param_wakeup_ir_key[i].power_key[j] = scpu_param->irda_info.key_tbl[i].wakeup_scancode[j];
 
 			for (param_wakeup_ir_key[i].key_shift = 0; param_wakeup_ir_key[i].key_shift < 32; param_wakeup_ir_key[i].key_shift++) {
 				if ((param_wakeup_ir_key[i].key_mask & (1 << param_wakeup_ir_key[i].key_shift))) {
diff --git a/rtd16xx_pm.h b/rtd16xx_pm.h
index ebebc79..10c1eab 100644
--- a/rtd16xx_pm.h
+++ b/rtd16xx_pm.h
@@ -14,7 +14,6 @@
 #define SUSPEND_ISO_GPIO_BASE 0
 #define SUSPEND_ISO_GPIO_SIZE 86
 
-#define RTK_PM_MAX_IR_KEY 2
 #define RTK_PM_MAX_EVENTS 8
 
 #define RESUME_STATE_ADDR (boot_offset_base+0x118)
@@ -33,10 +32,14 @@
 #define BT_WAKEUP_ACTIVE_HIGH (0x1 << 23)
 #define BT_WAKEUP_MASK 0x00EFFFFF
 
+#define MAX_WAKEUP_CODE 16
+#define MAX_KEY_TBL 2
+
 struct irda_wake_up_key {
 	unsigned int protocol;
 	unsigned int scancode_mask;
-	unsigned int wakeup_scancode;
+	unsigned int wakeup_keynum;
+	unsigned int wakeup_scancode[MAX_WAKEUP_CODE];
 	unsigned int cus_mask;
 	unsigned int cus_code;
 };
@@ -44,7 +47,7 @@ struct irda_wake_up_key {
 struct ipc_shm_irda {
 	unsigned int ipc_shm_ir_magic;
 	unsigned int dev_count;
-	struct irda_wake_up_key key_tbl[2];
+	struct irda_wake_up_key key_tbl[MAX_KEY_TBL];
 };
 
 struct ipc_shm_cec {
@@ -93,7 +96,8 @@ typedef struct param_pwm_irda_key
 {
 	unsigned int is_valid;
 	unsigned int protocol;
-	unsigned int power_key;
+	unsigned int power_keynum;
+	unsigned int power_key[MAX_WAKEUP_CODE];
 	unsigned int key_mask;
 	unsigned int key_shift;
 	unsigned int custom_key;
-- 
2.25.0


             reply	other threads:[~2020-02-10 14:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-10 14:42 James Tai [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-02-10 14:41 [PATCH] [DEV_FIX][THOR][B00] Support multiple IR key [REVIEWER] Simon James Tai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200210144231.27237-1-james.tai@realtek.com \
    --to=james.tai@realtek.com \
    --cc=afaerber@suse.de \
    --cc=devicetree@vger.kernel.org \
    --cc=james.ttl7447@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).