ir: add toshiba protocol support [1/1]

PD#SWPL-3543

Problem:
current driver does not support toshiba ir remote control protocol

Solution:
add register setting and decode code for toshiba protocol
use REMOTE_TYPE_TOSHIBA/REMOTE_TYPE_NEC_TOSHIBA to configure toshiba
only/toshiba and nec.

Verify:
tl1_t962x2_x301

Change-Id: Idad70c3879fad6e8267f0c4d80d2447c34114103
Signed-off-by: Qianggui Song <qianggui.song@amlogic.com>
This commit is contained in:
Qianggui Song
2018-12-24 13:35:17 +08:00
committed by Luke Go
parent d32bf0570d
commit 3dd602667c
3 changed files with 81 additions and 17 deletions

View File

@@ -167,23 +167,27 @@ enum {
};
enum remote_reg {
REG_LDR_ACTIVE = 0x00<<2,
REG_LDR_IDLE = 0x01<<2,
REG_LDR_REPEAT = 0x02<<2,
REG_BIT_0 = 0x03<<2,
REG_REG0 = 0x04<<2,
REG_FRAME = 0x05<<2,
REG_STATUS = 0x06<<2,
REG_REG1 = 0x07<<2,
REG_REG2 = 0x08<<2,
REG_DURATN2 = 0x09<<2,
REG_DURATN3 = 0x0a<<2,
REG_FRAME1 = 0x0b<<2,
REG_STATUS1 = 0x0c<<2,
REG_STATUS2 = 0x0d<<2,
REG_REG3 = 0x0e<<2,
REG_FRAME_RSV0 = 0x0f<<2,
REG_FRAME_RSV1 = 0x10<<2
REG_LDR_ACTIVE = 0x00 << 2,
REG_LDR_IDLE = 0x01 << 2,
REG_LDR_REPEAT = 0x02 << 2,
REG_BIT_0 = 0x03 << 2,
REG_REG0 = 0x04 << 2,
REG_FRAME = 0x05 << 2,
REG_STATUS = 0x06 << 2,
REG_REG1 = 0x07 << 2,
REG_REG2 = 0x08 << 2,
REG_DURATN2 = 0x09 << 2,
REG_DURATN3 = 0x0a << 2,
REG_FRAME1 = 0x0b << 2,
REG_STATUS1 = 0x0c << 2,
REG_STATUS2 = 0x0d << 2,
REG_REG3 = 0x0e << 2,
REG_FRAME_RSV0 = 0x0f << 2,
REG_FRAME_RSV1 = 0x10 << 2,
REG_FILTE = 0x11 << 2,
REG_IRQ_CTL = 0x12 << 2,
REG_WIDTH_NEW = 0x14 << 2,
REG_REPEAT_DET = 0x15 << 2
};
int ir_register_default_config(struct remote_chip *chip, int type);

View File

@@ -134,6 +134,53 @@ static struct remote_reg_map regs_default_rc6[] = {
{REG_DURATN3, ((51 << 16) | (38 << 0))},
};
static struct remote_reg_map regs_default_toshiba[] = {
{ REG_LDR_ACTIVE, (280 << 16) | (180 << 0)},
{ REG_LDR_IDLE, (280 << 16) | (180 << 0)},
{ REG_LDR_REPEAT, (150 << 16) | (60 << 0)},
{ REG_BIT_0, (72 << 16) | (40 << 0)},
{ REG_REG0, (7 << 28) | (0xFA0 << 12) | 0x13},
{ REG_STATUS, (134 << 20) | (90 << 10)},
{ REG_REG1, 0x9f00},
{ REG_REG2, (0x05) | (1 << 24) | (23 << 11)},
{ REG_DURATN2, 0x00},
{ REG_DURATN3, 0x00},
{ REG_REPEAT_DET, (1 << 31) | (0xFA0 << 16) | (10 << 0)},
{ REG_REG3, 0x2AF8},
};
static int ir_toshiba_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);
if (decode_status & 0x01)
status |= REMOTE_REPEAT;
chip->decode_status = status; /*set decode 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 >> 16) & 0xff;
return code;
}
static int ir_toshiba_get_decode_status(struct remote_chip *chip)
{
int status = chip->decode_status;
return status;
}
static u32 ir_toshiba_get_custom_code(struct remote_chip *chip)
{
u32 custom_code;
custom_code = (chip->r_dev->cur_hardcode) & 0xffff;
return custom_code;
}
void set_hardcode(struct remote_chip *chip, int code)
{
remote_dbg(chip->dev, "framecode=0x%x\n", code);
@@ -499,6 +546,15 @@ static struct aml_remote_reg_proto reg_rc6 = {
.get_custom_code = ir_rc6_get_custom_code,
};
static struct aml_remote_reg_proto reg_toshiba = {
.protocol = REMOTE_TYPE_TOSHIBA,
.name = "TOSHIBA",
.reg_map = regs_default_toshiba,
.reg_map_size = ARRAY_SIZE(regs_default_toshiba),
.get_scancode = ir_toshiba_get_scancode,
.get_decode_status = ir_toshiba_get_decode_status,
.get_custom_code = ir_toshiba_get_custom_code,
};
const struct aml_remote_reg_proto *remote_reg_proto[] = {
&reg_nec,
@@ -509,6 +565,7 @@ const struct aml_remote_reg_proto *remote_reg_proto[] = {
&reg_rc5,
&reg_rc6,
&reg_legacy_nec,
&reg_toshiba,
NULL
};

View File

@@ -37,6 +37,7 @@
#define REMOTE_TYPE_XMP_1 0x03
#define REMOTE_TYPE_RC5 0x04
#define REMOTE_TYPE_RC6 0x05
#define REMOTE_TYPE_TOSHIBA 0x06
/*hardware decode one protocol by using legacy IR controller*/
#define REMOTE_TYPE_LEGACY_NEC 0xff
@@ -55,5 +56,7 @@
*2. multi-format IR controller decode other protocol
*/
#define REMOTE_TYPE_NEC_RC6 ((REMOTE_TYPE_LEGACY_NEC << 8) | REMOTE_TYPE_RC6)
#define REMOTE_TYPE_NEC_TOSHIBA ((REMOTE_TYPE_LEGACY_NEC << 8) | \
REMOTE_TYPE_TOSHIBA)
#endif