Lines Matching +full:data +full:- +full:bits

1 // SPDX-License-Identifier: GPL-2.0
2 // ir-sanyo-decoder.c - handle SANYO IR Pulse/Space protocol
6 // This protocol uses the NEC protocol timings. However, data is formatted as:
7 // 13 bits Custom Code
8 // 13 bits NOT(Custom Code)
9 // 8 bits Key data
10 // 8 bits NOT(Key data)
17 #include "rc-core-priv.h"
40 * ir_sanyo_decode() - Decode one SANYO pulse or space
44 * This function returns -EINVAL if the pulse violates the state machine
48 struct sanyo_dec *data = &dev->raw->sanyo; in ir_sanyo_decode() local
55 dev_dbg(&dev->dev, "SANYO event overflow received. reset to state 0\n"); in ir_sanyo_decode()
56 data->state = STATE_INACTIVE; in ir_sanyo_decode()
61 dev_dbg(&dev->dev, "SANYO decode started at state %d (%uus %s)\n", in ir_sanyo_decode()
62 data->state, ev.duration, TO_STR(ev.pulse)); in ir_sanyo_decode()
64 switch (data->state) { in ir_sanyo_decode()
71 data->count = 0; in ir_sanyo_decode()
72 data->state = STATE_HEADER_SPACE; in ir_sanyo_decode()
83 data->state = STATE_BIT_PULSE; in ir_sanyo_decode()
96 data->state = STATE_BIT_SPACE; in ir_sanyo_decode()
103 if (!data->count && geq_margin(ev.duration, SANYO_REPEAT_SPACE, SANYO_UNIT / 2)) { in ir_sanyo_decode()
105 dev_dbg(&dev->dev, "SANYO repeat last key\n"); in ir_sanyo_decode()
106 data->state = STATE_INACTIVE; in ir_sanyo_decode()
110 data->bits <<= 1; in ir_sanyo_decode()
112 data->bits |= 1; in ir_sanyo_decode()
115 data->count++; in ir_sanyo_decode()
117 if (data->count == SANYO_NBITS) in ir_sanyo_decode()
118 data->state = STATE_TRAILER_PULSE; in ir_sanyo_decode()
120 data->state = STATE_BIT_PULSE; in ir_sanyo_decode()
131 data->state = STATE_TRAILER_SPACE; in ir_sanyo_decode()
141 address = bitrev16((data->bits >> 29) & 0x1fff) >> 3; in ir_sanyo_decode()
142 /* not_address = bitrev16((data->bits >> 16) & 0x1fff) >> 3; */ in ir_sanyo_decode()
143 command = bitrev8((data->bits >> 8) & 0xff); in ir_sanyo_decode()
144 not_command = bitrev8((data->bits >> 0) & 0xff); in ir_sanyo_decode()
147 dev_dbg(&dev->dev, "SANYO checksum error: received 0x%08llx\n", in ir_sanyo_decode()
148 data->bits); in ir_sanyo_decode()
149 data->state = STATE_INACTIVE; in ir_sanyo_decode()
154 dev_dbg(&dev->dev, "SANYO scancode: 0x%06x\n", scancode); in ir_sanyo_decode()
156 data->state = STATE_INACTIVE; in ir_sanyo_decode()
160 dev_dbg(&dev->dev, "SANYO decode failed at count %d state %d (%uus %s)\n", in ir_sanyo_decode()
161 data->count, data->state, ev.duration, TO_STR(ev.pulse)); in ir_sanyo_decode()
162 data->state = STATE_INACTIVE; in ir_sanyo_decode()
163 return -EINVAL; in ir_sanyo_decode()
178 * ir_sanyo_encode() - Encode a scancode as a stream of raw events
186 * -ENOBUFS if there isn't enough space in the array to fit the
196 raw = ((u64)(bitrev16(scancode >> 8) & 0xfff8) << (8 + 8 + 13 - 3)) | in ir_sanyo_encode()
197 ((u64)(bitrev16(~scancode >> 8) & 0xfff8) << (8 + 8 + 0 - 3)) | in ir_sanyo_encode()
205 return e - events; in ir_sanyo_encode()