Lines Matching +full:encode +full:- +full:only
1 // SPDX-License-Identifier: GPL-2.0-only
2 /* ir-sony-decoder.c - handle Sony IR Pulse/Space protocol
9 #include "rc-core-priv.h"
28 * ir_sony_decode() - Decode one Sony pulse or space
32 * This function returns -EINVAL if the pulse violates the state machine
36 struct sony_dec *data = &dev->raw->sony; in ir_sony_decode()
43 data->state = STATE_INACTIVE; in ir_sony_decode()
50 dev_dbg(&dev->dev, "Sony decode started at state %d (%uus %s)\n", in ir_sony_decode()
51 data->state, ev.duration, TO_STR(ev.pulse)); in ir_sony_decode()
53 switch (data->state) { in ir_sony_decode()
62 data->count = 0; in ir_sony_decode()
63 data->state = STATE_HEADER_SPACE; in ir_sony_decode()
73 data->state = STATE_BIT_PULSE; in ir_sony_decode()
80 data->bits <<= 1; in ir_sony_decode()
82 data->bits |= 1; in ir_sony_decode()
86 data->count++; in ir_sony_decode()
87 data->state = STATE_BIT_SPACE; in ir_sony_decode()
100 data->state = STATE_BIT_PULSE; in ir_sony_decode()
104 data->state = STATE_FINISHED; in ir_sony_decode()
114 switch (data->count) { in ir_sony_decode()
116 if (!(dev->enabled_protocols & RC_PROTO_BIT_SONY12)) in ir_sony_decode()
119 device = bitrev8((data->bits << 3) & 0xF8); in ir_sony_decode()
121 function = bitrev8((data->bits >> 4) & 0xFE); in ir_sony_decode()
125 if (!(dev->enabled_protocols & RC_PROTO_BIT_SONY15)) in ir_sony_decode()
128 device = bitrev8((data->bits >> 0) & 0xFF); in ir_sony_decode()
130 function = bitrev8((data->bits >> 7) & 0xFE); in ir_sony_decode()
134 if (!(dev->enabled_protocols & RC_PROTO_BIT_SONY20)) in ir_sony_decode()
137 device = bitrev8((data->bits >> 5) & 0xF8); in ir_sony_decode()
138 subdevice = bitrev8((data->bits >> 0) & 0xFF); in ir_sony_decode()
139 function = bitrev8((data->bits >> 12) & 0xFE); in ir_sony_decode()
143 dev_dbg(&dev->dev, "Sony invalid bitcount %u\n", in ir_sony_decode()
144 data->count); in ir_sony_decode()
149 dev_dbg(&dev->dev, "Sony(%u) scancode 0x%05x\n", data->count, in ir_sony_decode()
156 dev_dbg(&dev->dev, "Sony decode failed at state %d (%uus %s)\n", in ir_sony_decode()
157 data->state, ev.duration, TO_STR(ev.pulse)); in ir_sony_decode()
158 data->state = STATE_INACTIVE; in ir_sony_decode()
159 return -EINVAL; in ir_sony_decode()
162 data->state = STATE_INACTIVE; in ir_sony_decode()
176 * ir_sony_encode() - Encode a scancode as a stream of raw events
178 * @protocol: protocol to encode
179 * @scancode: scancode to encode
184 * -ENOBUFS if there isn't enough space in the array to fit the
210 return e - events; in ir_sony_encode()
217 .encode = ir_sony_encode,