Commit ab93ce06 authored by Sifan Naeem's avatar Sifan Naeem Committed by Mauro Carvalho Chehab

[media] rc: img-ir: add scancode requests to a struct

The information being requested of hardware decode callbacks through
the img-ir-hw scancode API is mounting up, so combine it into a struct
which can be passed in with a single pointer rather than multiple
pointer arguments. This allows it to be extended more easily without
touching all the hardware decode callbacks.
Signed-off-by: default avatarSifan Naeem <sifan.naeem@imgtec.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 32e63f03
...@@ -806,20 +806,22 @@ static void img_ir_handle_data(struct img_ir_priv *priv, u32 len, u64 raw) ...@@ -806,20 +806,22 @@ static void img_ir_handle_data(struct img_ir_priv *priv, u32 len, u64 raw)
struct img_ir_priv_hw *hw = &priv->hw; struct img_ir_priv_hw *hw = &priv->hw;
const struct img_ir_decoder *dec = hw->decoder; const struct img_ir_decoder *dec = hw->decoder;
int ret = IMG_IR_SCANCODE; int ret = IMG_IR_SCANCODE;
u32 scancode; struct img_ir_scancode_req request;
enum rc_type protocol = RC_TYPE_UNKNOWN;
request.protocol = RC_TYPE_UNKNOWN;
if (dec->scancode) if (dec->scancode)
ret = dec->scancode(len, raw, &protocol, &scancode, hw->enabled_protocols); ret = dec->scancode(len, raw, hw->enabled_protocols, &request);
else if (len >= 32) else if (len >= 32)
scancode = (u32)raw; request.scancode = (u32)raw;
else if (len < 32) else if (len < 32)
scancode = (u32)raw & ((1 << len)-1); request.scancode = (u32)raw & ((1 << len)-1);
dev_dbg(priv->dev, "data (%u bits) = %#llx\n", dev_dbg(priv->dev, "data (%u bits) = %#llx\n",
len, (unsigned long long)raw); len, (unsigned long long)raw);
if (ret == IMG_IR_SCANCODE) { if (ret == IMG_IR_SCANCODE) {
dev_dbg(priv->dev, "decoded scan code %#x\n", scancode); dev_dbg(priv->dev, "decoded scan code %#x\n",
rc_keydown(hw->rdev, protocol, scancode, 0); request.scancode);
rc_keydown(hw->rdev, request.protocol, request.scancode, 0);
img_ir_end_repeat(priv); img_ir_end_repeat(priv);
} else if (ret == IMG_IR_REPEATCODE) { } else if (ret == IMG_IR_REPEATCODE) {
if (hw->mode == IMG_IR_M_REPEATING) { if (hw->mode == IMG_IR_M_REPEATING) {
......
...@@ -132,6 +132,18 @@ struct img_ir_timing_regvals { ...@@ -132,6 +132,18 @@ struct img_ir_timing_regvals {
#define IMG_IR_SCANCODE 0 /* new scancode */ #define IMG_IR_SCANCODE 0 /* new scancode */
#define IMG_IR_REPEATCODE 1 /* repeat the previous code */ #define IMG_IR_REPEATCODE 1 /* repeat the previous code */
/**
* struct img_ir_scancode_req - Scancode request data.
* @protocol: Protocol code of received message (defaults to
* RC_TYPE_UNKNOWN).
* @scancode: Scan code of received message (must be written by
* handler if IMG_IR_SCANCODE is returned).
*/
struct img_ir_scancode_req {
enum rc_type protocol;
u32 scancode;
};
/** /**
* struct img_ir_decoder - Decoder settings for an IR protocol. * struct img_ir_decoder - Decoder settings for an IR protocol.
* @type: Protocol types bitmap. * @type: Protocol types bitmap.
...@@ -162,8 +174,8 @@ struct img_ir_decoder { ...@@ -162,8 +174,8 @@ struct img_ir_decoder {
struct img_ir_control control; struct img_ir_control control;
/* scancode logic */ /* scancode logic */
int (*scancode)(int len, u64 raw, enum rc_type *protocol, int (*scancode)(int len, u64 raw, u64 enabled_protocols,
u32 *scancode, u64 enabled_protocols); struct img_ir_scancode_req *request);
int (*filter)(const struct rc_scancode_filter *in, int (*filter)(const struct rc_scancode_filter *in,
struct img_ir_filter *out, u64 protocols); struct img_ir_filter *out, u64 protocols);
}; };
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
#include "img-ir-hw.h" #include "img-ir-hw.h"
/* Convert JVC data to a scancode */ /* Convert JVC data to a scancode */
static int img_ir_jvc_scancode(int len, u64 raw, enum rc_type *protocol, static int img_ir_jvc_scancode(int len, u64 raw, u64 enabled_protocols,
u32 *scancode, u64 enabled_protocols) struct img_ir_scancode_req *request)
{ {
unsigned int cust, data; unsigned int cust, data;
...@@ -23,8 +23,8 @@ static int img_ir_jvc_scancode(int len, u64 raw, enum rc_type *protocol, ...@@ -23,8 +23,8 @@ static int img_ir_jvc_scancode(int len, u64 raw, enum rc_type *protocol,
cust = (raw >> 0) & 0xff; cust = (raw >> 0) & 0xff;
data = (raw >> 8) & 0xff; data = (raw >> 8) & 0xff;
*protocol = RC_TYPE_JVC; request->protocol = RC_TYPE_JVC;
*scancode = cust << 8 | data; request->scancode = cust << 8 | data;
return IMG_IR_SCANCODE; return IMG_IR_SCANCODE;
} }
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
#include <linux/bitrev.h> #include <linux/bitrev.h>
/* Convert NEC data to a scancode */ /* Convert NEC data to a scancode */
static int img_ir_nec_scancode(int len, u64 raw, enum rc_type *protocol, static int img_ir_nec_scancode(int len, u64 raw, u64 enabled_protocols,
u32 *scancode, u64 enabled_protocols) struct img_ir_scancode_req *request)
{ {
unsigned int addr, addr_inv, data, data_inv; unsigned int addr, addr_inv, data, data_inv;
/* a repeat code has no data */ /* a repeat code has no data */
...@@ -30,23 +30,23 @@ static int img_ir_nec_scancode(int len, u64 raw, enum rc_type *protocol, ...@@ -30,23 +30,23 @@ static int img_ir_nec_scancode(int len, u64 raw, enum rc_type *protocol,
if ((data_inv ^ data) != 0xff) { if ((data_inv ^ data) != 0xff) {
/* 32-bit NEC (used by Apple and TiVo remotes) */ /* 32-bit NEC (used by Apple and TiVo remotes) */
/* scan encoding: as transmitted, MSBit = first received bit */ /* scan encoding: as transmitted, MSBit = first received bit */
*scancode = bitrev8(addr) << 24 | request->scancode = bitrev8(addr) << 24 |
bitrev8(addr_inv) << 16 | bitrev8(addr_inv) << 16 |
bitrev8(data) << 8 | bitrev8(data) << 8 |
bitrev8(data_inv); bitrev8(data_inv);
} else if ((addr_inv ^ addr) != 0xff) { } else if ((addr_inv ^ addr) != 0xff) {
/* Extended NEC */ /* Extended NEC */
/* scan encoding: AAaaDD */ /* scan encoding: AAaaDD */
*scancode = addr << 16 | request->scancode = addr << 16 |
addr_inv << 8 | addr_inv << 8 |
data; data;
} else { } else {
/* Normal NEC */ /* Normal NEC */
/* scan encoding: AADD */ /* scan encoding: AADD */
*scancode = addr << 8 | request->scancode = addr << 8 |
data; data;
} }
*protocol = RC_TYPE_NEC; request->protocol = RC_TYPE_NEC;
return IMG_IR_SCANCODE; return IMG_IR_SCANCODE;
} }
......
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
#include "img-ir-hw.h" #include "img-ir-hw.h"
/* Convert Sanyo data to a scancode */ /* Convert Sanyo data to a scancode */
static int img_ir_sanyo_scancode(int len, u64 raw, enum rc_type *protocol, static int img_ir_sanyo_scancode(int len, u64 raw, u64 enabled_protocols,
u32 *scancode, u64 enabled_protocols) struct img_ir_scancode_req *request)
{ {
unsigned int addr, addr_inv, data, data_inv; unsigned int addr, addr_inv, data, data_inv;
/* a repeat code has no data */ /* a repeat code has no data */
...@@ -44,8 +44,8 @@ static int img_ir_sanyo_scancode(int len, u64 raw, enum rc_type *protocol, ...@@ -44,8 +44,8 @@ static int img_ir_sanyo_scancode(int len, u64 raw, enum rc_type *protocol,
return -EINVAL; return -EINVAL;
/* Normal Sanyo */ /* Normal Sanyo */
*protocol = RC_TYPE_SANYO; request->protocol = RC_TYPE_SANYO;
*scancode = addr << 8 | data; request->scancode = addr << 8 | data;
return IMG_IR_SCANCODE; return IMG_IR_SCANCODE;
} }
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
#include "img-ir-hw.h" #include "img-ir-hw.h"
/* Convert Sharp data to a scancode */ /* Convert Sharp data to a scancode */
static int img_ir_sharp_scancode(int len, u64 raw, enum rc_type *protocol, static int img_ir_sharp_scancode(int len, u64 raw, u64 enabled_protocols,
u32 *scancode, u64 enabled_protocols) struct img_ir_scancode_req *request)
{ {
unsigned int addr, cmd, exp, chk; unsigned int addr, cmd, exp, chk;
...@@ -32,8 +32,8 @@ static int img_ir_sharp_scancode(int len, u64 raw, enum rc_type *protocol, ...@@ -32,8 +32,8 @@ static int img_ir_sharp_scancode(int len, u64 raw, enum rc_type *protocol,
/* probably the second half of the message */ /* probably the second half of the message */
return -EINVAL; return -EINVAL;
*protocol = RC_TYPE_SHARP; request->protocol = RC_TYPE_SHARP;
*scancode = addr << 8 | cmd; request->scancode = addr << 8 | cmd;
return IMG_IR_SCANCODE; return IMG_IR_SCANCODE;
} }
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
#include "img-ir-hw.h" #include "img-ir-hw.h"
/* Convert Sony data to a scancode */ /* Convert Sony data to a scancode */
static int img_ir_sony_scancode(int len, u64 raw, enum rc_type *protocol, static int img_ir_sony_scancode(int len, u64 raw, u64 enabled_protocols,
u32 *scancode, u64 enabled_protocols) struct img_ir_scancode_req *request)
{ {
unsigned int dev, subdev, func; unsigned int dev, subdev, func;
...@@ -25,7 +25,7 @@ static int img_ir_sony_scancode(int len, u64 raw, enum rc_type *protocol, ...@@ -25,7 +25,7 @@ static int img_ir_sony_scancode(int len, u64 raw, enum rc_type *protocol,
raw >>= 7; raw >>= 7;
dev = raw & 0x1f; /* next 5 bits */ dev = raw & 0x1f; /* next 5 bits */
subdev = 0; subdev = 0;
*protocol = RC_TYPE_SONY12; request->protocol = RC_TYPE_SONY12;
break; break;
case 15: case 15:
if (!(enabled_protocols & RC_BIT_SONY15)) if (!(enabled_protocols & RC_BIT_SONY15))
...@@ -34,7 +34,7 @@ static int img_ir_sony_scancode(int len, u64 raw, enum rc_type *protocol, ...@@ -34,7 +34,7 @@ static int img_ir_sony_scancode(int len, u64 raw, enum rc_type *protocol,
raw >>= 7; raw >>= 7;
dev = raw & 0xff; /* next 8 bits */ dev = raw & 0xff; /* next 8 bits */
subdev = 0; subdev = 0;
*protocol = RC_TYPE_SONY15; request->protocol = RC_TYPE_SONY15;
break; break;
case 20: case 20:
if (!(enabled_protocols & RC_BIT_SONY20)) if (!(enabled_protocols & RC_BIT_SONY20))
...@@ -44,12 +44,12 @@ static int img_ir_sony_scancode(int len, u64 raw, enum rc_type *protocol, ...@@ -44,12 +44,12 @@ static int img_ir_sony_scancode(int len, u64 raw, enum rc_type *protocol,
dev = raw & 0x1f; /* next 5 bits */ dev = raw & 0x1f; /* next 5 bits */
raw >>= 5; raw >>= 5;
subdev = raw & 0xff; /* next 8 bits */ subdev = raw & 0xff; /* next 8 bits */
*protocol = RC_TYPE_SONY20; request->protocol = RC_TYPE_SONY20;
break; break;
default: default:
return -EINVAL; return -EINVAL;
} }
*scancode = dev << 16 | subdev << 8 | func; request->scancode = dev << 16 | subdev << 8 | func;
return IMG_IR_SCANCODE; return IMG_IR_SCANCODE;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment