From b55ee717d17633fb289d022f88af3ae2d49c7f43 Mon Sep 17 00:00:00 2001 From: seife Date: Sun, 19 Jun 2011 11:00:05 +0000 Subject: [PATCH] drivertool: add shortcuts to switch TD and CS remote * add shortcut options for TD and CS remotes * use nevis_ir.h if present Needs testing frontpanel driver to work properly. git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@1547 e54a6e83-5905-42d5-8d5c-058d10e6a962 --- configure.ac | 1 + src/drivertool.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/configure.ac b/configure.ac index 29a52f0f9..03f8a8095 100644 --- a/configure.ac +++ b/configure.ac @@ -90,6 +90,7 @@ if test "$enable_flac" = "yes"; then AC_DEFINE(ENABLE_FLAC,1,[include FLAC support]) fi +AC_CHECK_HEADERS(coolstream/nevis_ir.h) # # Check for libtdservicedb - the new one - for testing only diff --git a/src/drivertool.c b/src/drivertool.c index 74b106731..13575dd1c 100644 --- a/src/drivertool.c +++ b/src/drivertool.c @@ -17,6 +17,7 @@ * right now the frontpanel and the IR remote drivers are implemented */ +#include #include #include #include @@ -29,6 +30,10 @@ #include +#ifdef HAVE_COOLSTREAM_NEVIS_IR_H +#include +#endif + #ifndef IOC_IR_SET_PRI_PROTOCOL /* unfortunately, the shipped headers seem to be still incomplete... * documented here: @@ -115,6 +120,10 @@ static struct ioctl_list n[] = { { 1, "IR_SET_X_DELAY", IOC_IR_SET_X_DELAY, TYPE_UINT }, { 1, "IR_SET_FP_MODE", IOC_IR_SET_FP_MODE, TYPE_UINT }, { 1, "IR_GET_PROTOCOLS", IOC_IR_GET_PROTOCOLS, TYPE_UINT_GET }, +#ifdef HAVE_COOLSTREAM_NEVIS_IR_H + { 1, "IOC_IR_SET_PRI_KEYMAP", IOC_IR_SET_PRI_KEYMAP, TYPE_UNSUPP }, + { 1, "IOC_IR_SET_SEC_KEYMAP", IOC_IR_SET_SEC_KEYMAP, TYPE_UNSUPP }, +#endif { -1, NULL, 0, TYPE_UNSUPP } }; @@ -154,6 +163,8 @@ void usage(void) printf("\t%-20s %s\n", n[i++].text, arg); } printf("\n"); + printf("shortcuts:\n\t-c\tswitch primary remote to coolstream\n" + "\t-t \tswitch primary remote to Tripledragon addr \n\n"); exit(0); } @@ -168,6 +179,52 @@ int main(int argc, char **argv) if (argc < 2 || (argc > 1 && strcmp(argv[1], "-h") == 0)) usage(); + if (argv[1][0] == '-') + { + ir_protocol_t p; + + switch (argv[1][1]) + { + case 't': + if (argc < 3) + usage(); /* does not return */ + p = IR_PROTOCOL_RMAP_E; + a = (unsigned int) strtoll(argv[2], NULL, 0); + a <<= 16; + a |= 0x0A; + break; + case 'c': + p = IR_PROTOCOL_NECE; + a = 0xFF80; + break; + default: + usage(); + } + + fd = open(devices[1], O_RDONLY); + if (fd < 0) + { + perror(devices[1]); + return 1; + } + ret = ioctl(fd, IOC_IR_SET_PRI_PROTOCOL, p); + if (ret) + { + perror("IOC_IR_SET_PRI_PROTOCOL"); + ret = errno; + close(fd); + return ret; + } + ret = ioctl(fd, IOC_IR_SET_PRI_ADDRESS, a); + if (ret) + { + perror("IOC_IR_SET_PRI_ADDRESS"); + ret = errno; + } + close(fd); + return ret; + } + ret = 0; while (n[i].text != NULL && strcmp(n[i].text, argv[1]) != 0) i++;