From: "Antti Seppälä" <a.seppala@gmail.com>
To: James Hogan <james.hogan@imgtec.com>
Cc: "Mauro Carvalho Chehab" <m.chehab@samsung.com>,
linux-media@vger.kernel.org,
"Antti Seppälä" <a.seppala@gmail.com>
Subject: [RFC PATCH 1/3] rc-core: Add Manchester encoder (phase encoder) support to rc-core
Date: Sat, 8 Feb 2014 14:07:28 +0200 [thread overview]
Message-ID: <1391861250-26068-2-git-send-email-a.seppala@gmail.com> (raw)
In-Reply-To: <1391861250-26068-1-git-send-email-a.seppala@gmail.com>
Adding a simple Manchester encoder to rc-core.
Manchester coding is used by at least RC-5 protocol and its variants.
Signed-off-by: Antti Seppälä <a.seppala@gmail.com>
---
drivers/media/rc/ir-raw.c | 44 +++++++++++++++++++++++++++++++++++++++++
drivers/media/rc/rc-core-priv.h | 14 +++++++++++++
2 files changed, 58 insertions(+)
diff --git a/drivers/media/rc/ir-raw.c b/drivers/media/rc/ir-raw.c
index 9d734dd..7fea9ac 100644
--- a/drivers/media/rc/ir-raw.c
+++ b/drivers/media/rc/ir-raw.c
@@ -240,6 +240,50 @@ ir_raw_get_allowed_protocols(void)
return protocols;
}
+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)
+{
+ bool need_pulse;
+ int i, count = 0;
+ i = 1 << (n - 1);
+
+ if (n > max || max < 2)
+ return -EINVAL;
+
+ if (timings->pulse_space_start) {
+ init_ir_raw_event_duration((*ev)++, 1, timings->clock);
+ init_ir_raw_event_duration((*ev), 0, timings->clock);
+ count += 2;
+ } else {
+ init_ir_raw_event_duration((*ev), 1, timings->clock);
+ count++;
+ }
+ i >>= 1;
+
+ while (i > 0) {
+ if (count > max)
+ return -EINVAL;
+
+ need_pulse = !(data & i);
+ if (need_pulse == !!(*ev)->pulse) {
+ (*ev)->duration += timings->clock;
+ } else {
+ init_ir_raw_event_duration(++(*ev), need_pulse,
+ timings->clock);
+ count++;
+ }
+
+ init_ir_raw_event_duration(++(*ev), !need_pulse,
+ timings->clock);
+ count++;
+ i >>= 1;
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL(ir_raw_gen_manchester);
+
int ir_raw_gen_pd(struct ir_raw_event **ev, unsigned int max,
const struct ir_raw_timings_pd *timings,
unsigned int n, unsigned int data)
diff --git a/drivers/media/rc/rc-core-priv.h b/drivers/media/rc/rc-core-priv.h
index 3bf8c7b..4a2e2b8 100644
--- a/drivers/media/rc/rc-core-priv.h
+++ b/drivers/media/rc/rc-core-priv.h
@@ -173,6 +173,20 @@ static inline void ir_raw_gen_pulse_space(struct ir_raw_event **ev,
}
/**
+ * struct ir_raw_timings_manchester - manchester coding timings
+ * @pulse_space_start: 1 for starting with pulse (0 for starting with space)
+ * @clock: duration of each pulse/space in ns
+ */
+struct ir_raw_timings_manchester {
+ unsigned int pulse_space_start:1;
+ unsigned int clock;
+};
+
+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);
+
+/**
* 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
--
1.8.3.2
next prev parent reply other threads:[~2014-02-08 12:07 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-06 19:59 [RFC 0/4] rc: ir-raw: Add encode, implement NEC encode James Hogan
2014-02-06 19:59 ` [RFC 1/4] rc: ir-raw: add scancode encoder callback James Hogan
2014-02-06 19:59 ` [RFC 2/4] rc: ir-raw: add modulation helpers James Hogan
2014-02-06 19:59 ` [RFC 3/4] rc: ir-nec-decoder: add encode capability James Hogan
2014-02-06 19:59 ` [RFC 4/4] DEBUG: rc: img-ir: raw: Add loopback on s_filter James Hogan
2014-02-08 11:30 ` [RFC 0/4] rc: ir-raw: Add encode, implement NEC encode Antti Seppälä
2014-02-08 12:07 ` [RFC PATCH 0/3] rc: add RC5-SZ encoder and utilize encoders in nuvoton-cir Antti Seppälä
2014-02-08 12:07 ` Antti Seppälä [this message]
2014-02-10 10:25 ` [RFC PATCH 1/3] rc-core: Add Manchester encoder (phase encoder) support to rc-core James Hogan
2014-02-10 19:56 ` Antti Seppälä
2014-02-08 12:07 ` [RFC PATCH 2/3] ir-rc5-sz: Add ir encoding support Antti Seppälä
2014-02-10 10:30 ` James Hogan
2014-02-10 20:09 ` Antti Seppälä
2014-02-10 20:50 ` James Hogan
2014-02-11 18:14 ` Antti Seppälä
2014-02-11 23:39 ` James Hogan
2014-02-16 17:04 ` Antti Seppälä
2014-02-27 22:43 ` James Hogan
2014-02-16 16:45 ` [RFCv2 PATCH 0/3] rc: add RC5-SZ encoder and utilize encoders in nuvoton-cir Antti Seppälä
2014-02-16 16:45 ` [RFCv2 PATCH 1/3] rc-core: Add Manchester encoder (phase encoder) support to rc-core Antti Seppälä
2014-02-16 16:45 ` [RFCv2 PATCH 2/3] ir-rc5-sz: Add ir encoding support Antti Seppälä
2014-02-16 16:45 ` [RFCv2 PATCH 3/3] nuvoton-cir: Add support for writing wakeup samples via sysfs filter callback Antti Seppälä
2014-02-08 12:07 ` [RFC " Antti Seppälä
2014-02-10 9:58 ` [RFC 0/4] rc: ir-raw: Add encode, implement NEC encode James Hogan
2014-02-10 19:45 ` Antti Seppälä
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1391861250-26068-2-git-send-email-a.seppala@gmail.com \
--to=a.seppala@gmail.com \
--cc=james.hogan@imgtec.com \
--cc=linux-media@vger.kernel.org \
--cc=m.chehab@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox