Lines Matching +full:encode +full:- +full:only
1 // SPDX-License-Identifier: GPL-2.0-only
2 /* ir-jvc-decoder.c - handle JVC IR Pulse/Space protocol
9 #include "rc-core-priv.h"
13 #define JVC_HEADER_PULSE (16 * JVC_UNIT) /* lack of header -> repeat */
32 * ir_jvc_decode() - Decode one JVC pulse or space
36 * This function returns -EINVAL if the pulse violates the state machine
40 struct jvc_dec *data = &dev->raw->jvc; in ir_jvc_decode()
44 data->state = STATE_INACTIVE; in ir_jvc_decode()
51 dev_dbg(&dev->dev, "JVC decode started at state %d (%uus %s)\n", in ir_jvc_decode()
52 data->state, ev.duration, TO_STR(ev.pulse)); in ir_jvc_decode()
55 switch (data->state) { in ir_jvc_decode()
64 data->count = 0; in ir_jvc_decode()
65 data->first = true; in ir_jvc_decode()
66 data->toggle = !data->toggle; in ir_jvc_decode()
67 data->state = STATE_HEADER_SPACE; in ir_jvc_decode()
77 data->state = STATE_BIT_PULSE; in ir_jvc_decode()
87 data->state = STATE_BIT_SPACE; in ir_jvc_decode()
94 data->bits <<= 1; in ir_jvc_decode()
96 data->bits |= 1; in ir_jvc_decode()
102 data->count++; in ir_jvc_decode()
104 if (data->count == JVC_NBITS) in ir_jvc_decode()
105 data->state = STATE_TRAILER_PULSE; in ir_jvc_decode()
107 data->state = STATE_BIT_PULSE; in ir_jvc_decode()
117 data->state = STATE_TRAILER_SPACE; in ir_jvc_decode()
127 if (data->first) { in ir_jvc_decode()
129 scancode = (bitrev8((data->bits >> 8) & 0xff) << 8) | in ir_jvc_decode()
130 (bitrev8((data->bits >> 0) & 0xff) << 0); in ir_jvc_decode()
131 dev_dbg(&dev->dev, "JVC scancode 0x%04x\n", scancode); in ir_jvc_decode()
132 rc_keydown(dev, RC_PROTO_JVC, scancode, data->toggle); in ir_jvc_decode()
133 data->first = false; in ir_jvc_decode()
134 data->old_bits = data->bits; in ir_jvc_decode()
135 } else if (data->bits == data->old_bits) { in ir_jvc_decode()
136 dev_dbg(&dev->dev, "JVC repeat\n"); in ir_jvc_decode()
139 dev_dbg(&dev->dev, "JVC invalid repeat msg\n"); in ir_jvc_decode()
143 data->count = 0; in ir_jvc_decode()
144 data->state = STATE_CHECK_REPEAT; in ir_jvc_decode()
152 data->state = STATE_INACTIVE; in ir_jvc_decode()
154 data->state = STATE_BIT_PULSE; in ir_jvc_decode()
159 dev_dbg(&dev->dev, "JVC decode failed at state %d (%uus %s)\n", in ir_jvc_decode()
160 data->state, ev.duration, TO_STR(ev.pulse)); in ir_jvc_decode()
161 data->state = STATE_INACTIVE; in ir_jvc_decode()
162 return -EINVAL; in ir_jvc_decode()
177 * ir_jvc_encode() - Encode a scancode as a stream of raw events
179 * @protocol: protocol to encode
180 * @scancode: scancode to encode
185 * -ENOBUFS if there isn't enough space in the array to fit the
200 return e - events; in ir_jvc_encode()
206 .encode = ir_jvc_encode,