/** * ir_sony_decode() - Decode one Sony pulse or space * @dev: the struct rc_dev descriptor of the device * @ev: the struct ir_raw_event descriptor of the pulse/space * * This function returns -EINVAL if the pulse violates the state machine
*/ staticint ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
{ struct sony_dec *data = &dev->raw->sony; enum rc_proto protocol;
u32 scancode;
u8 device, subdevice, function;
if (!is_timing_event(ev)) { if (ev.overflow)
data->state = STATE_INACTIVE; return 0;
}
if (!geq_margin(ev.duration, SONY_UNIT, SONY_UNIT / 2)) goto out;
dev_dbg(&dev->dev, "Sony decode started at state %d (%uus %s)\n",
data->state, ev.duration, TO_STR(ev.pulse));
switch (data->state) {
case STATE_INACTIVE: if (!ev.pulse) break;
if (!eq_margin(ev.duration, SONY_HEADER_PULSE, SONY_UNIT / 2)) break;
/** * ir_sony_encode() - Encode a scancode as a stream of raw events * * @protocol: protocol to encode * @scancode: scancode to encode * @events: array of raw ir events to write into * @max: maximum size of @events * * Returns: The number of events written. * -ENOBUFS if there isn't enough space in the array to fit the * encoding. In this case all @max events will have been written.
*/ staticint ir_sony_encode(enum rc_proto protocol, u32 scancode, struct ir_raw_event *events, unsignedint max)
{ struct ir_raw_event *e = events;
u32 raw, len; int ret;
if (protocol == RC_PROTO_SONY12) {
raw = (scancode & 0x7f) | ((scancode & 0x1f0000) >> 9);
len = 12;
} elseif (protocol == RC_PROTO_SONY15) {
raw = (scancode & 0x7f) | ((scancode & 0xff0000) >> 9);
len = 15;
} else {
raw = (scancode & 0x7f) | ((scancode & 0x1f0000) >> 9) |
((scancode & 0xff00) << 4);
len = 20;
}
ret = ir_raw_gen_pl(&e, max, &ir_sony_timings, len, raw); if (ret < 0) return ret;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.