Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * ImgTec IR Decoder setup for Philips RC-5 protocol.
0004  *
0005  * Copyright 2012-2014 Imagination Technologies Ltd.
0006  */
0007 
0008 #include "img-ir-hw.h"
0009 
0010 /* Convert RC5 data to a scancode */
0011 static int img_ir_rc5_scancode(int len, u64 raw, u64 enabled_protocols,
0012                 struct img_ir_scancode_req *request)
0013 {
0014     unsigned int addr, cmd, tgl, start;
0015 
0016     /* Quirk in the decoder shifts everything by 2 to the left. */
0017     raw   >>= 2;
0018 
0019     start   =  (raw >> 13)  & 0x01;
0020     tgl =  (raw >> 11)  & 0x01;
0021     addr    =  (raw >>  6)  & 0x1f;
0022     cmd =   raw     & 0x3f;
0023     /*
0024      * 12th bit is used to extend the command in extended RC5 and has
0025      * no effect on standard RC5.
0026      */
0027     cmd += ((raw >> 12) & 0x01) ? 0 : 0x40;
0028 
0029     if (!start)
0030         return -EINVAL;
0031 
0032     request->protocol = RC_PROTO_RC5;
0033     request->scancode = addr << 8 | cmd;
0034     request->toggle   = tgl;
0035     return IMG_IR_SCANCODE;
0036 }
0037 
0038 /* Convert RC5 scancode to RC5 data filter */
0039 static int img_ir_rc5_filter(const struct rc_scancode_filter *in,
0040                  struct img_ir_filter *out, u64 protocols)
0041 {
0042     /* Not supported by the hw. */
0043     return -EINVAL;
0044 }
0045 
0046 /*
0047  * RC-5 decoder
0048  * see http://www.sbprojects.com/knowledge/ir/rc5.php
0049  */
0050 struct img_ir_decoder img_ir_rc5 = {
0051     .type      = RC_PROTO_BIT_RC5,
0052     .control   = {
0053         .bitoriend2 = 1,
0054         .code_type  = IMG_IR_CODETYPE_BIPHASE,
0055         .decodend2  = 1,
0056     },
0057     /* main timings */
0058     .tolerance  = 16,
0059     .unit       = 888888, /* 1/36k*32=888.888microseconds */
0060     .timings    = {
0061         /* 10 symbol */
0062         .s10 = {
0063             .pulse  = { 1 },
0064             .space  = { 1 },
0065         },
0066 
0067         /* 11 symbol */
0068         .s11 = {
0069             .pulse  = { 1 },
0070             .space  = { 1 },
0071         },
0072 
0073         /* free time */
0074         .ft  = {
0075             .minlen = 14,
0076             .maxlen = 14,
0077             .ft_min = 5,
0078         },
0079     },
0080 
0081     /* scancode logic */
0082     .scancode   = img_ir_rc5_scancode,
0083     .filter     = img_ir_rc5_filter,
0084 };