[media] rc: ir-sony-decoder: Add encode capability
Add the capability to encode Sony scancodes as raw events. Sony uses pulse length rather than pulse distance. Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
This commit is contained in:

committed by
Mauro Carvalho Chehab

parent
d35afc5fe0
commit
103293be9d
@@ -382,6 +382,70 @@ int ir_raw_gen_pd(struct ir_raw_event **ev, unsigned int max,
|
||||
}
|
||||
EXPORT_SYMBOL(ir_raw_gen_pd);
|
||||
|
||||
/**
|
||||
* ir_raw_gen_pl() - Encode data to raw events with pulse-length modulation.
|
||||
* @ev: Pointer to pointer to next free event. *@ev is incremented for
|
||||
* each raw event filled.
|
||||
* @max: Maximum number of raw events to fill.
|
||||
* @timings: Pulse distance modulation timings.
|
||||
* @n: Number of bits of data.
|
||||
* @data: Data bits to encode.
|
||||
*
|
||||
* Encodes the @n least significant bits of @data using space-distance
|
||||
* modulation with the timing characteristics described by @timings, writing up
|
||||
* to @max raw IR events using the *@ev pointer.
|
||||
*
|
||||
* Returns: 0 on success.
|
||||
* -ENOBUFS if there isn't enough space in the array to fit the
|
||||
* full encoded data. In this case all @max events will have been
|
||||
* written.
|
||||
*/
|
||||
int ir_raw_gen_pl(struct ir_raw_event **ev, unsigned int max,
|
||||
const struct ir_raw_timings_pl *timings,
|
||||
unsigned int n, u64 data)
|
||||
{
|
||||
int i;
|
||||
int ret = -ENOBUFS;
|
||||
unsigned int pulse;
|
||||
|
||||
if (!max--)
|
||||
return ret;
|
||||
|
||||
init_ir_raw_event_duration((*ev)++, 1, timings->header_pulse);
|
||||
|
||||
if (timings->msb_first) {
|
||||
for (i = n - 1; i >= 0; --i) {
|
||||
if (!max--)
|
||||
return ret;
|
||||
init_ir_raw_event_duration((*ev)++, 0,
|
||||
timings->bit_space);
|
||||
if (!max--)
|
||||
return ret;
|
||||
pulse = timings->bit_pulse[(data >> i) & 1];
|
||||
init_ir_raw_event_duration((*ev)++, 1, pulse);
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < n; ++i, data >>= 1) {
|
||||
if (!max--)
|
||||
return ret;
|
||||
init_ir_raw_event_duration((*ev)++, 0,
|
||||
timings->bit_space);
|
||||
if (!max--)
|
||||
return ret;
|
||||
pulse = timings->bit_pulse[data & 1];
|
||||
init_ir_raw_event_duration((*ev)++, 1, pulse);
|
||||
}
|
||||
}
|
||||
|
||||
if (!max--)
|
||||
return ret;
|
||||
|
||||
init_ir_raw_event_duration((*ev)++, 0, timings->trailer_space);
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(ir_raw_gen_pl);
|
||||
|
||||
/**
|
||||
* ir_raw_encode_scancode() - Encode a scancode as raw events
|
||||
*
|
||||
|
Reference in New Issue
Block a user