diff options
author | Sean Young <sean@mess.org> | 2016-12-06 17:01:03 -0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-01-30 13:52:57 -0200 |
commit | d8a2ae5cbdc82aca603c366c87920ffaa14571ba (patch) | |
tree | 846dc09277ae44582d9887c8e34170bb747d486b /drivers/media/rc | |
parent | 141cfb1432f5c8e120d49229be52a32c8705afba (diff) |
[media] rc: ir-jvc-decoder: Add encode capability
Add the capability to encode JVC scancodes as raw events.
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/rc')
-rw-r--r-- | drivers/media/rc/ir-jvc-decoder.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/drivers/media/rc/ir-jvc-decoder.c b/drivers/media/rc/ir-jvc-decoder.c index 182402f7b4d1..674bf156edcb 100644 --- a/drivers/media/rc/ir-jvc-decoder.c +++ b/drivers/media/rc/ir-jvc-decoder.c @@ -170,9 +170,48 @@ out: return -EINVAL; } +static const struct ir_raw_timings_pd ir_jvc_timings = { + .header_pulse = JVC_HEADER_PULSE, + .header_space = JVC_HEADER_SPACE, + .bit_pulse = JVC_BIT_PULSE, + .bit_space[0] = JVC_BIT_0_SPACE, + .bit_space[1] = JVC_BIT_1_SPACE, + .trailer_pulse = JVC_TRAILER_PULSE, + .trailer_space = JVC_TRAILER_SPACE, + .msb_first = 1, +}; + +/** + * ir_jvc_encode() - Encode a scancode as a stream of raw events + * + * @protocol: protocol to encode + * @scancode: scancode to encode + * @events: array of raw ir events to write into + * @max: maximum size of @events + * + * Returns: The number of events written. + * -ENOBUFS if there isn't enough space in the array to fit the + * encoding. In this case all @max events will have been written. + */ +static int ir_jvc_encode(enum rc_type protocol, u32 scancode, + struct ir_raw_event *events, unsigned int max) +{ + struct ir_raw_event *e = events; + int ret; + u32 raw = (bitrev8((scancode >> 8) & 0xff) << 8) | + (bitrev8((scancode >> 0) & 0xff) << 0); + + ret = ir_raw_gen_pd(&e, max, &ir_jvc_timings, JVC_NBITS, raw); + if (ret < 0) + return ret; + + return e - events; +} + static struct ir_raw_handler jvc_handler = { .protocols = RC_BIT_JVC, .decode = ir_jvc_decode, + .encode = ir_jvc_encode, }; static int __init ir_jvc_decode_init(void) |