summaryrefslogtreecommitdiff
path: root/drivers/media/rc/rc-core-priv.h
diff options
context:
space:
mode:
authorJames Hogan <james@albanarts.com>2014-03-14 20:04:12 -0300
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2017-01-30 13:50:05 -0200
commitcaec098477d228d44ae2266ee78a37bed070441a (patch)
tree829045d0cd56c392845df98b650b30b0d751d2ca /drivers/media/rc/rc-core-priv.h
parent844a4f45f43b6d46b4dd87f61b3e2d2836c822b1 (diff)
[media] rc: rc-ir-raw: Add pulse-distance modulation helper
Add IR encoding helper for pulse-distance modulation as used by the NEC protocol. Signed-off-by: James Hogan <james@albanarts.com> Signed-off-by: Sean Young <sean@mess.org> Cc: Antti Seppälä <a.seppala@gmail.com> Cc: David Härdeman <david@hardeman.nu> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/rc/rc-core-priv.h')
-rw-r--r--drivers/media/rc/rc-core-priv.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/drivers/media/rc/rc-core-priv.h b/drivers/media/rc/rc-core-priv.h
index b8d40e6e6ecf..2471a3ccf931 100644
--- a/drivers/media/rc/rc-core-priv.h
+++ b/drivers/media/rc/rc-core-priv.h
@@ -187,6 +187,58 @@ int ir_raw_gen_manchester(struct ir_raw_event **ev, unsigned int max,
const struct ir_raw_timings_manchester *timings,
unsigned int n, unsigned int data);
+/**
+ * ir_raw_gen_pulse_space() - generate pulse and space raw events.
+ * @ev: Pointer to pointer to next free raw event.
+ * Will be incremented for each raw event written.
+ * @max: Pointer to number of raw events available in buffer.
+ * Will be decremented for each raw event written.
+ * @pulse_width: Width of pulse in ns.
+ * @space_width: Width of space in ns.
+ *
+ * Returns: 0 on success.
+ * -ENOBUFS if there isn't enough buffer space to write both raw
+ * events. In this case @max events will have been written.
+ */
+static inline int ir_raw_gen_pulse_space(struct ir_raw_event **ev,
+ unsigned int *max,
+ unsigned int pulse_width,
+ unsigned int space_width)
+{
+ if (!*max)
+ return -ENOBUFS;
+ init_ir_raw_event_duration((*ev)++, 1, pulse_width);
+ if (!--*max)
+ return -ENOBUFS;
+ init_ir_raw_event_duration((*ev)++, 0, space_width);
+ --*max;
+ return 0;
+}
+
+/**
+ * struct ir_raw_timings_pd - pulse-distance modulation timings
+ * @header_pulse: duration of header pulse in ns (0 for none)
+ * @header_space: duration of header space in ns
+ * @bit_pulse: duration of bit pulse in ns
+ * @bit_space: duration of bit space (for logic 0 and 1) in ns
+ * @trailer_pulse: duration of trailer pulse in ns
+ * @trailer_space: duration of trailer space in ns
+ * @msb_first: 1 if most significant bit is sent first
+ */
+struct ir_raw_timings_pd {
+ unsigned int header_pulse;
+ unsigned int header_space;
+ unsigned int bit_pulse;
+ unsigned int bit_space[2];
+ unsigned int trailer_pulse;
+ unsigned int trailer_space;
+ unsigned int msb_first:1;
+};
+
+int ir_raw_gen_pd(struct ir_raw_event **ev, unsigned int max,
+ const struct ir_raw_timings_pd *timings,
+ unsigned int n, u64 data);
+
/*
* Routines from rc-raw.c to be used internally and by decoders
*/