Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3804080ybv; Mon, 10 Feb 2020 06:43:25 -0800 (PST) X-Google-Smtp-Source: APXvYqwcCJSRIJS8yOeGA2soL4f7sBxQx/Xy2ZK8+P0BWsMxHm4U6Uh+WKwLMMOD5u6XmaN80l5V X-Received: by 2002:aca:6749:: with SMTP id b9mr982505oiy.13.1581345805421; Mon, 10 Feb 2020 06:43:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581345805; cv=none; d=google.com; s=arc-20160816; b=M1mEcC0sB6LW5Egf4WZqmome71OJEsEPKwdJRnWzNnZeT4B4k0++TbozNbNB2eD0tE G4oRo2HgfzvqgV1RxJRTkXvbaRahuBlRqy/hmg/2QU7bwrstIs3y+xrqLv2q+dutDpgu zgShgx6TciHyKatT9J0YRlKWEj6W6eUfL87G0tJxzE5J2jaHING1aEzb7qHV/YaoPfb6 bi0FOJXPtmiBctgwl5GXV1crCI1TDnkhATbnbDYGAM5g6uHQWrpsakq0X0aIfcUG+OHa ZeNzPHNplCJueVQfzMWXPhjdSx/HmJ+nMVHOY4Uap0ap0u1gyck8pusEzEZb1bVE72N5 8GRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:authenticated-by; bh=ohxhJnhUyKZgJXxmE2ZvnUAY/LTqx7e1WhbShMjV/GQ=; b=cc0TT3zP3Hnw6U+ipKG0UX8NEtwZEsibLq3XIue2wnm8MaMRmPh0VxIpa6kN/9r7oT gBpg05B0lrtfbKM1E6EWx7L0Xl3amnyxan3758Z0E4vk0gtsWFbxbS/DPMYRUBQwJ3OZ lDoM6rrq71pMharYLaiOEE5w5MPhPsyu0XzM/WLkemmwSawtDp6z/CokrbhYna7a+Pc2 eFjBBkr+13re5iIpSKaW4uL9jrtRHJTR0VVHJYntKQP80iLxcBzhWEpJ0LHJ47ILnmo4 McQQYNtEFdz1T4kJ1BWOSL3eaqQ1oLGB/b+wn/w899hECYk3f5rjTYpuWssCkqF0WWoQ vHBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o20si283451otl.60.2020.02.10.06.43.13; Mon, 10 Feb 2020 06:43:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728377AbgBJOmf (ORCPT + 99 others); Mon, 10 Feb 2020 09:42:35 -0500 Received: from rtits2.realtek.com ([211.75.126.72]:46611 "EHLO rtits2.realtek.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727704AbgBJOmf (ORCPT ); Mon, 10 Feb 2020 09:42:35 -0500 Authenticated-By: X-SpamFilter-By: BOX Solutions SpamTrap 5.62 with qID 01AEfxVY025063, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (RTEXMB06.realtek.com.tw[172.21.6.99]) by rtits2.realtek.com.tw (8.15.2/2.57/5.78) with ESMTPS id 01AEfxVY025063 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 10 Feb 2020 22:41:59 +0800 Received: from RTEXMB05.realtek.com.tw (172.21.6.98) by RTEXMB06.realtek.com.tw (172.21.6.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Mon, 10 Feb 2020 22:41:58 +0800 Received: from RTEXMB05.realtek.com.tw (172.21.6.98) by RTEXMB05.realtek.com.tw (172.21.6.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Mon, 10 Feb 2020 22:41:58 +0800 Received: from james-BS01.localdomain (172.21.190.33) by RTEXMB01.realtek.com.tw (172.21.6.98) with Microsoft SMTP Server id 15.1.1779.2 via Frontend Transport; Mon, 10 Feb 2020 22:41:58 +0800 From: James Tai To: CC: , , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Rob Herring , Mark Rutland , Subject: [PATCH] [DEV_FIX][THOR][B00] Support multiple IR key [REVIEWER] Simon Date: Mon, 10 Feb 2020 22:41:53 +0800 Message-ID: <20200210144153.27184-1-james.tai@realtek.com> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: James Tai --- 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