/* Used to keep track of IR raw clients, protected by ir_raw_handler_lock */ static LIST_HEAD(ir_raw_client_list);
/* Used to handle IR raw handler extensions */
DEFINE_MUTEX(ir_raw_handler_lock); static LIST_HEAD(ir_raw_handler_list); static atomic64_t available_protocols = ATOMIC64_INIT(0);
/* timer could be set to timeout (125ms by default) */ if (!timer_pending(&dev->raw->edge_handle) ||
time_after(dev->raw->edge_handle.expires,
jiffies + msecs_to_jiffies(15))) {
mod_timer(&dev->raw->edge_handle,
jiffies + msecs_to_jiffies(15));
}
spin_unlock(&dev->raw->edge_spinlock);
/** *ir_raw_gen_manchester()-EncodedatawithManchester(bi-phase)modulation. *@ev:Pointertopointertonextfreeevent.*@evisincrementedfor *eachraweventfilled. *@max:Maximumnumberofraweventstofill. *@timings:Manchestermodulationtimings. *@n:Numberofbitsofdata. *@data:Databitstoencode. * *Encodesthe@nleastsignificantbitsof@datausingManchester(bi-phase) *modulationwiththetimingcharacteristicsdescribedby@timings,writingup *to@maxrawIReventsusingthe*@evpointer. * *Returns:0onsuccess. *-ENOBUFSifthereisn'tenoughspaceinthearraytofitthe *fullencodeddata.Inthiscaseall@maxeventswillhavebeen *written.
*/ int ir_raw_gen_manchester(struct ir_raw_event **ev, unsignedint max, conststruct ir_raw_timings_manchester *timings, unsignedint n, u64 data)
{ bool need_pulse;
u64 i; int ret = -ENOBUFS;
i = BIT_ULL(n - 1);
if (timings->leader_pulse) { if (!max--) return ret;
init_ir_raw_event_duration((*ev), 1, timings->leader_pulse); if (timings->leader_space) { if (!max--) return ret;
init_ir_raw_event_duration(++(*ev), 0,
timings->leader_space);
}
} else { /* continue existing signal */
--(*ev);
} /* from here on *ev will point to the last event rather than the next */
while (n && i > 0) {
need_pulse = !(data & i); if (timings->invert)
need_pulse = !need_pulse; if (need_pulse == !!(*ev)->pulse) {
(*ev)->duration += timings->clock;
} else { if (!max--) goto nobufs;
init_ir_raw_event_duration(++(*ev), need_pulse,
timings->clock);
}
if (!max--) goto nobufs;
init_ir_raw_event_duration(++(*ev), !need_pulse,
timings->clock);
i >>= 1;
}
if (timings->trailer_space) { if (!(*ev)->pulse)
(*ev)->duration += timings->trailer_space; elseif (!max--) goto nobufs; else
init_ir_raw_event_duration(++(*ev), 0,
timings->trailer_space);
}
ret = 0;
nobufs: /* point to the next event rather than last event before returning */
++(*ev); return ret;
}
EXPORT_SYMBOL(ir_raw_gen_manchester);
/** *ir_raw_gen_pd()-Encodedatatoraweventswithpulse-distancemodulation. *@ev:Pointertopointertonextfreeevent.*@evisincrementedfor *eachraweventfilled. *@max:Maximumnumberofraweventstofill. *@timings:Pulsedistancemodulationtimings. *@n:Numberofbitsofdata. *@data:Databitstoencode. * *Encodesthe@nleastsignificantbitsof@datausingpulse-distance *modulationwiththetimingcharacteristicsdescribedby@timings,writingup *to@maxrawIReventsusingthe*@evpointer. * *Returns:0onsuccess. *-ENOBUFSifthereisn'tenoughspaceinthearraytofitthe *fullencodeddata.Inthiscaseall@maxeventswillhavebeen *written.
*/ int ir_raw_gen_pd(struct ir_raw_event **ev, unsignedint max, conststruct ir_raw_timings_pd *timings, unsignedint n, u64 data)
{ int i; int ret; unsignedint space;
if (timings->header_pulse) {
ret = ir_raw_gen_pulse_space(ev, &max, timings->header_pulse,
timings->header_space); if (ret) return ret;
}
if (timings->msb_first) { for (i = n - 1; i >= 0; --i) {
space = timings->bit_space[(data >> i) & 1];
ret = ir_raw_gen_pulse_space(ev, &max,
timings->bit_pulse,
space); if (ret) return ret;
}
} else { for (i = 0; i < n; ++i, data >>= 1) {
space = timings->bit_space[data & 1];
ret = ir_raw_gen_pulse_space(ev, &max,
timings->bit_pulse,
space); if (ret) return ret;
}
}
ret = ir_raw_gen_pulse_space(ev, &max, timings->trailer_pulse,
timings->trailer_space); return ret;
}
EXPORT_SYMBOL(ir_raw_gen_pd);
/** *ir_raw_gen_pl()-Encodedatatoraweventswithpulse-lengthmodulation. *@ev:Pointertopointertonextfreeevent.*@evisincrementedfor *eachraweventfilled. *@max:Maximumnumberofraweventstofill. *@timings:Pulsedistancemodulationtimings. *@n:Numberofbitsofdata. *@data:Databitstoencode. * *Encodesthe@nleastsignificantbitsof@datausingspace-distance *modulationwiththetimingcharacteristicsdescribedby@timings,writingup *to@maxrawIReventsusingthe*@evpointer. * *Returns:0onsuccess. *-ENOBUFSifthereisn'tenoughspaceinthearraytofitthe *fullencodeddata.Inthiscaseall@maxeventswillhavebeen *written.
*/ int ir_raw_gen_pl(struct ir_raw_event **ev, unsignedint max, conststruct ir_raw_timings_pl *timings, unsignedint n, u64 data)
{ int i; int ret = -ENOBUFS; unsignedint pulse;
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.