distribution/packages/sysutils/v4l-utils/patches/v4l-utils-0004-add-power-on-argument-fixup.patch
2022-02-05 09:23:32 -05:00

91 lines
3.3 KiB
Diff

diff --git a/utils/keytable/keytable.c b/utils/keytable/keytable.c
index b45b1fe..1097eb0 100644
--- a/utils/keytable/keytable.c
+++ b/utils/keytable/keytable.c
@@ -115,6 +115,7 @@ enum sysfs_protocols {
SYSFS_IMON = (1 << 14),
SYSFS_RCMM = (1 << 15),
SYSFS_XBOX_DVD = (1 << 16),
+ SYSFS_IRMP = (1 << 17),
SYSFS_INVALID = 0,
};
@@ -151,6 +152,7 @@ const struct protocol_map_entry protocol_map[] = {
{ "imon", NULL, SYSFS_IMON },
{ "rc-mm", NULL, SYSFS_RCMM },
{ "xbox-dvd", NULL, SYSFS_XBOX_DVD },
+ { "irmp", "/irmp_decoder", SYSFS_IRMP },
{ NULL, NULL, SYSFS_INVALID },
};
@@ -234,7 +236,7 @@ static const struct argp_option options[] = {
{"clear", 'c', 0, 0, N_("clears the old table"), 0},
{"sysdev", 's', N_("SYSDEV"), 0, N_("ir class device to control"), 0},
{"test", 't', 0, 0, N_("test if IR is generating events"), 0},
- {"power-key", 'u', 0, 0, N_("will scan for NEC power on code"), 0},
+ {"power-key", 'u', 0, 0, N_("will scan for a compatible power on code"), 0},
{"device", 'd', N_("DEV"), 0, N_("ir device to control"), 0},
{"read", 'r', 0, 0, N_("reads the current scancode/keycode table"), 0},
{"write", 'w', N_("TABLE"), 0, N_("write (adds) the scancodes to the device scancode/keycode table from an specified file"), 0},
@@ -1356,6 +1358,8 @@ static void test_event(struct rc_device *rc_dev, int fd, int power_on)
struct lirc_scancode sc[64];
int rd, i, lircfd = -1;
unsigned mode;
+ unsigned protocol;
+ unsigned undefined;
/* LIRC reports time in monotonic, set event to same */
mode = CLOCK_MONOTONIC;
@@ -1378,7 +1382,7 @@ static void test_event(struct rc_device *rc_dev, int fd, int power_on)
if (!power_on)
printf (_("Testing events. Please, press CTRL-C to abort.\n"));
else
- printf (_("Waiting for NEC decode event. Please, press CTRL-C to abort.\n"));
+ printf (_("Waiting for IRMP decode event. Please, press CTRL-C to abort.\n"));
while (1) {
struct pollfd pollstruct[2] = {
@@ -1471,12 +1475,28 @@ static void test_event(struct rc_device *rc_dev, int fd, int power_on)
switch (ev[i].type) {
case EV_MSC:
if (ev[i].code == MSC_SCAN) {
- unsigned int nec_code =
- ((~ev[i].value & 0xFF) << 24) |
- ((ev[i].value & 0xFF) << 16) |
- ((~(ev[i].value >> 8) & 0xFF) << 8) |
- ((ev[i].value >> 8) & 0xFF);
- printf(_("Received NEC code: 0x%08X\n"), nec_code);
+ if ((ev[i].value & 0xFFFFFF00) == 0xA0A0A000) {
+ protocol = ev[i].value & 0xFF;
+ undefined = 0;
+ mode = 0;
+ }
+ else if ((ev[i].value & 0xFFFFFF00) == 0xB0B0B000) {
+ protocol = ev[i].value & 0xFF;
+ undefined = 1;
+ mode = 0;
+ }
+ else if (!mode) {
+ if (!undefined) {
+ printf(_("Received IRMP code: remotewakeup='0x%08x', decode_type='0x%x', "), ev[i].value, protocol);
+ mode = 1;
+ }
+ else
+ printf(_("Received IRMP code: scancode='0x%08x', IRMP protocol = %d, decode_type is undefined!\n"), ev[i].value, protocol);
+ }
+ else if (mode) {
+ printf(_("remotewakeupmask='0x%08x'\n"), ev[i].value);
+ mode = 0;
+ }
}
break;
}
@@ -1784,7 +1804,7 @@ int main(int argc, char *argv[])
* Third step: change protocol
*/
if (poweron)
- ch_proto = SYSFS_NEC;
+ ch_proto = SYSFS_IRMP;
if (ch_proto) {
rc_dev.current = ch_proto;