@@ -127,9 +127,48 @@ out:
return -EINVAL;
}
+static struct ir_raw_timings_manchester ir_rc5_sz_timings = {
+ .pulse_space_start = 0,
+ .clock = RC5_UNIT,
+ .trailer_space = RC5_UNIT * 10,
+};
+
+/*
+ * ir_rc5_sz_encode() - Encode a scancode as a stream of raw events
+ *
+ * @protocols: allowed protocols
+ * @scancode: scancode filter describing scancode (helps distinguish between
+ * protocol subtypes when scancode is ambiguous)
+ * @events: array of raw ir events to write into
+ * @max: maximum size of @events
+ *
+ * This function returns -EINVAL if the scancode filter is invalid or matches
+ * multiple scancodes. Otherwise the number of ir_raw_events generated is
+ * returned.
+ */
+static int ir_rc5_sz_encode(u64 protocols,
+ const struct rc_scancode_filter *scancode,
+ struct ir_raw_event *events, unsigned int max)
+{
+ int ret;
+ struct ir_raw_event *e = events;
+
+ if (scancode->mask != 0xffff)
+ return -EINVAL;
+
+ /* RC5-SZ scancode is raw enough for manchester as it is */
+ ret = ir_raw_gen_manchester(&e, max, &ir_rc5_sz_timings, RC5_SZ_NBITS,
+ scancode->data);
+ if (ret < 0)
+ return ret;
+
+ return e - events;
+}
+
static struct ir_raw_handler rc5_sz_handler = {
.protocols = RC_BIT_RC5_SZ,
.decode = ir_rc5_sz_decode,
+ .encode = ir_rc5_sz_encode,
};
static int __init ir_rc5_sz_decode_init(void)
The encoding in rc5-sz first inserts a pulse and then simply utilizes the generic Manchester encoder available in rc-core. Signed-off-by: Antti Seppälä <a.seppala@gmail.com> --- drivers/media/rc/ir-rc5-sz-decoder.c | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)