Lines Matching +full:data +full:- +full:bits
1 // SPDX-License-Identifier: GPL-2.0+
2 // ir-rcmm-decoder.c - A decoder for the RCMM IR protocol
6 #include "rc-core-priv.h"
24 static bool rcmm_mode(const struct rcmm_dec *data) in rcmm_mode() argument
26 return !((0x000c0000 & data->bits) == 0x000c0000); in rcmm_mode()
29 static int rcmm_miscmode(struct rc_dev *dev, struct rcmm_dec *data) in rcmm_miscmode() argument
31 switch (data->count) { in rcmm_miscmode()
33 if (dev->enabled_protocols & RC_PROTO_BIT_RCMM24) { in rcmm_miscmode()
34 rc_keydown(dev, RC_PROTO_RCMM24, data->bits, 0); in rcmm_miscmode()
35 data->state = STATE_INACTIVE; in rcmm_miscmode()
38 return -1; in rcmm_miscmode()
41 if (dev->enabled_protocols & RC_PROTO_BIT_RCMM12) { in rcmm_miscmode()
42 rc_keydown(dev, RC_PROTO_RCMM12, data->bits, 0); in rcmm_miscmode()
43 data->state = STATE_INACTIVE; in rcmm_miscmode()
46 return -1; in rcmm_miscmode()
49 return -1; in rcmm_miscmode()
53 * ir_rcmm_decode() - Decode one RCMM pulse or space
57 * This function returns -EINVAL if the pulse violates the state machine
61 struct rcmm_dec *data = &dev->raw->rcmm; in ir_rcmm_decode() local
66 if (!(dev->enabled_protocols & (RC_PROTO_BIT_RCMM32 | in ir_rcmm_decode()
73 data->state = STATE_INACTIVE; in ir_rcmm_decode()
77 switch (data->state) { in ir_rcmm_decode()
85 data->state = STATE_LOW; in ir_rcmm_decode()
86 data->count = 0; in ir_rcmm_decode()
87 data->bits = 0; in ir_rcmm_decode()
97 data->state = STATE_BUMP; in ir_rcmm_decode()
107 data->state = STATE_VALUE; in ir_rcmm_decode()
123 value = -1; in ir_rcmm_decode()
125 if (value == -1) { in ir_rcmm_decode()
126 if (!rcmm_miscmode(dev, data)) in ir_rcmm_decode()
131 data->bits <<= 2; in ir_rcmm_decode()
132 data->bits |= value; in ir_rcmm_decode()
134 data->count += 2; in ir_rcmm_decode()
136 if (data->count < 32) in ir_rcmm_decode()
137 data->state = STATE_BUMP; in ir_rcmm_decode()
139 data->state = STATE_FINISHED; in ir_rcmm_decode()
150 if (rcmm_mode(data)) { in ir_rcmm_decode()
151 toggle = !!(0x8000 & data->bits); in ir_rcmm_decode()
152 scancode = data->bits & ~0x8000; in ir_rcmm_decode()
155 scancode = data->bits; in ir_rcmm_decode()
158 if (dev->enabled_protocols & RC_PROTO_BIT_RCMM32) { in ir_rcmm_decode()
160 data->state = STATE_INACTIVE; in ir_rcmm_decode()
167 dev_dbg(&dev->dev, "RC-MM decode failed at count %d state %d (%uus %s)\n", in ir_rcmm_decode()
168 data->count, data->state, ev.duration, TO_STR(ev.pulse)); in ir_rcmm_decode()
169 data->state = STATE_INACTIVE; in ir_rcmm_decode()
170 return -EINVAL; in ir_rcmm_decode()
181 unsigned int n, u32 data) in ir_rcmm_rawencoder() argument
190 for (i = n - 2; i >= 0; i -= 2) { in ir_rcmm_rawencoder()
191 const unsigned int space = rcmmspace[(data >> i) & 3]; in ir_rcmm_rawencoder()
218 ret = -EINVAL; in ir_rcmm_encode()
224 return e - events; in ir_rcmm_encode()