ir: support rca ir protocol [1/1]
authorQianggui Song <qianggui.song@amlogic.com>
Tue, 30 Apr 2019 11:25:04 +0000 (19:25 +0800)
committerTao Zeng <tao.zeng@amlogic.com>
Mon, 6 May 2019 06:45:25 +0000 (23:45 -0700)
PD#SWPL-8050

Problem:
current driver does not support rca ir protocol

Solution:
add register setting and code for rca use REMOTE_RYPE_RCA to configure.

Verify:
G12b_W400 & tl1 x301

Change-Id: I76d860d66a43071803fb60debeafcbf18f42b283
Signed-off-by: Qianggui Song <qianggui.song@amlogic.com>
drivers/amlogic/input/remote/remote_regmap.c
include/dt-bindings/input/meson_rc.h

index f1b506c..ff75e17 100644 (file)
@@ -149,6 +149,21 @@ static struct remote_reg_map regs_default_toshiba[] = {
        { REG_REG3,             0x2AF8},
 };
 
+static struct remote_reg_map regs_default_rca[] = {
+       { REG_LDR_ACTIVE,   (250 << 16) | (160 << 0)},
+       { REG_LDR_IDLE,     250 << 16 | 160 << 0},
+       { REG_LDR_REPEAT,   250 << 16 | 160 << 0},
+       { REG_BIT_0,        100 << 16 | 48 << 0},
+       { REG_REG0,         7 << 28 | (0xFA0 << 12) | 0x13},
+       { REG_STATUS,       (150 << 20) | (110 << 10)},
+       { REG_REG1,         0x9700},
+       { REG_REG2,         0x104 | (1 << 24) | (23 << 11)},
+       { REG_DURATN2,      0x00},
+       { REG_REPEAT_DET,  (1 << 31) | (0xFA0 << 16) | (10 << 0)},
+       { REG_REG3,        0x1A00},
+       { REG_DURATN3,      0x00}
+};
+
 static int ir_toshiba_get_scancode(struct remote_chip *chip)
 {
        int  code = 0;
@@ -464,6 +479,41 @@ static u32 ir_rc6_get_custom_code(struct remote_chip *chip)
        return custom_code;
 }
 
+static int ir_rca_get_scancode(struct remote_chip *chip)
+{
+       int  code = 0;
+       int decode_status = 0;
+       int status = 0;
+
+       remote_reg_read(chip, MULTI_IR_ID, REG_STATUS, &decode_status);
+       decode_status &= 0xf;
+       if (decode_status & 0x01)
+               status |= REMOTE_REPEAT;
+
+       chip->decode_status = status;
+       remote_reg_read(chip, MULTI_IR_ID, REG_FRAME, &code);
+       remote_dbg(chip->dev, "framecode=0x%x\n", code);
+       chip->r_dev->cur_hardcode = code;
+       code = (code >> 12) & 0xff;
+       return code;
+}
+
+static int ir_rca_get_decode_status(struct remote_chip *chip)
+{
+       int status = chip->decode_status;
+
+       return status;
+}
+
+static u32 ir_rca_get_custom_code(struct remote_chip *chip)
+{
+       u32 custom_code;
+
+       custom_code = (chip->r_dev->cur_hardcode >> 20) & 0x0f;
+       remote_dbg(chip->dev, "custom code=0x%x\n", custom_code);
+       return custom_code;
+}
+
 /*legacy IR controller support protocols*/
 static struct aml_remote_reg_proto reg_legacy_nec = {
        .protocol = REMOTE_TYPE_LEGACY_NEC,
@@ -556,6 +606,16 @@ static struct aml_remote_reg_proto reg_toshiba = {
        .get_custom_code   = ir_toshiba_get_custom_code,
 };
 
+static struct aml_remote_reg_proto reg_rca = {
+       .protocol = REMOTE_TYPE_RCA,
+       .name     = "rca",
+       .reg_map      = regs_default_rca,
+       .reg_map_size = ARRAY_SIZE(regs_default_rca),
+       .get_scancode      = ir_rca_get_scancode,
+       .get_decode_status = ir_rca_get_decode_status,
+       .get_custom_code   = ir_rca_get_custom_code,
+};
+
 const struct aml_remote_reg_proto *remote_reg_proto[] = {
        &reg_nec,
        &reg_duokan,
@@ -566,6 +626,7 @@ const struct aml_remote_reg_proto *remote_reg_proto[] = {
        &reg_rc6,
        &reg_legacy_nec,
        &reg_toshiba,
+       &reg_rca,
        NULL
 };
 
index 82646d5..afc6753 100644 (file)
@@ -38,6 +38,7 @@
 #define     REMOTE_TYPE_RC5          0x04
 #define     REMOTE_TYPE_RC6          0x05
 #define     REMOTE_TYPE_TOSHIBA      0x06
+#define     REMOTE_TYPE_RCA          0x08
 
 /*hardware decode one protocol by using legacy IR controller*/
 #define     REMOTE_TYPE_LEGACY_NEC  0xff
@@ -59,5 +60,5 @@
 #define REMOTE_TYPE_NEC_RC5  ((REMOTE_TYPE_LEGACY_NEC << 8) | REMOTE_TYPE_RC5)
 #define REMOTE_TYPE_NEC_TOSHIBA  ((REMOTE_TYPE_LEGACY_NEC << 8) |           \
                        REMOTE_TYPE_TOSHIBA)
-
+#define REMOTE_TYPE_NEC_RCA  ((REMOTE_TYPE_LEGACY_NEC << 8) | REMOTE_TYPE_RCA)
 #endif