From 8c22970bd96b69dbc981ef50918360aef20bcde9 Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Sat, 16 Feb 2019 07:20:20 +0000 Subject: [PATCH] New upstream release --- debian/changelog | 8 ++- debian/files | 5 +- debian/rules | 2 +- .../Makefile | 4 +- .../README.txt | 0 .../dkms.conf | 2 +- .../extract_keydefs.sh | 0 .../keymap.default | 0 .../sapphire.c | 54 ++++++++++++--- .../sapphire.h | 65 +------------------ .../sapphire_keymap.sh.part1 | 0 .../sapphire_keymap.sh.part3 | 0 .../sapphire_startup.sh | 17 ++--- 13 files changed, 70 insertions(+), 87 deletions(-) rename {sapphire-remote-6.6 => sapphire-remote-7.1}/Makefile (94%) rename {sapphire-remote-6.6 => sapphire-remote-7.1}/README.txt (100%) rename {sapphire-remote-6.6 => sapphire-remote-7.1}/dkms.conf (94%) rename {sapphire-remote-6.6 => sapphire-remote-7.1}/extract_keydefs.sh (100%) rename {sapphire-remote-6.6 => sapphire-remote-7.1}/keymap.default (100%) rename {sapphire-remote-6.6 => sapphire-remote-7.1}/sapphire.c (95%) rename {sapphire-remote-6.6 => sapphire-remote-7.1}/sapphire.h (58%) rename {sapphire-remote-6.6 => sapphire-remote-7.1}/sapphire_keymap.sh.part1 (100%) rename {sapphire-remote-6.6 => sapphire-remote-7.1}/sapphire_keymap.sh.part3 (100%) rename {sapphire-remote-6.6 => sapphire-remote-7.1}/sapphire_startup.sh (81%) diff --git a/debian/changelog b/debian/changelog index 5c120b4..803fdac 100755 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,12 @@ +sapphire-remote-dkms (7.1) UNRELEASED; urgency=medium + + * New upstream release + + -- Andrew Ruthven Sat, 16 Feb 2019 07:19:10 +0000 + sapphire-remote-dkms (6.6) stable; urgency=low * Automatically packaged by DKMS. - -- Dynamic Kernel Modules Support Team Sun, 21 Aug 2016 21:31:06 +0000 + -- Andrew Ruthven Sun, 21 Aug 2016 21:31:06 +0000 diff --git a/debian/files b/debian/files index e2bfa16..acf6376 100644 --- a/debian/files +++ b/debian/files @@ -1,2 +1,3 @@ -sapphire-remote-dkms_6.6_all.deb misc optional -sapphire-remote_6.6_all.deb misc optional +sapphire-remote-dkms_7.1_all.deb misc optional +sapphire-remote-dkms_7.1_armhf.buildinfo misc optional +sapphire-remote_7.1_all.deb misc optional diff --git a/debian/rules b/debian/rules index 0a2855e..82e59b2 100755 --- a/debian/rules +++ b/debian/rules @@ -6,7 +6,7 @@ DEB_NAME=sapphire-remote NAME=sapphire-remote -VERSION=6.6 +VERSION=7.1 configure: configure-stamp configure-stamp: diff --git a/sapphire-remote-6.6/Makefile b/sapphire-remote-7.1/Makefile similarity index 94% rename from sapphire-remote-6.6/Makefile rename to sapphire-remote-7.1/Makefile index 8fd1233..16d0e14 100644 --- a/sapphire-remote-6.6/Makefile +++ b/sapphire-remote-7.1/Makefile @@ -1,6 +1,6 @@ # # Makefile and (un-)Installer for Sapphire remote control driver, -# by Mark Lord 2012-2015. +# by Mark Lord 2012-2018. # MODNAME=sapphire MODSOURCE=$(MODNAME).c @@ -55,7 +55,7 @@ $(BLACKLIST): modinstall: $(MODNAME).ko $(KEYMAP_SCRIPT) $(MAKE) -C $(KDIR)/build M=$(CWD) modules_install || exit 0 - @[ -e $(KDIR)/extra/sapphire.ko ] || exit 1 + @[ -e $(KDIR)/extra/sapphire.ko -o -e $(KDIR)/extra/sapphire.ko.gz -o -e $(KDIR)/extra/sapphire.ko.xz ] || exit 1 depmod $(KVER) @if [ "$(KVER)" = "$$(uname -r)" ]; then \ rmmod $(MODNAME) 2>/dev/null ;\ diff --git a/sapphire-remote-6.6/README.txt b/sapphire-remote-7.1/README.txt similarity index 100% rename from sapphire-remote-6.6/README.txt rename to sapphire-remote-7.1/README.txt diff --git a/sapphire-remote-6.6/dkms.conf b/sapphire-remote-7.1/dkms.conf similarity index 94% rename from sapphire-remote-6.6/dkms.conf rename to sapphire-remote-7.1/dkms.conf index 7c4066e..1217b3e 100644 --- a/sapphire-remote-6.6/dkms.conf +++ b/sapphire-remote-7.1/dkms.conf @@ -1,4 +1,4 @@ -PACKAGE_VERSION="6.6" +PACKAGE_VERSION="7.1" # Items below here should not have to change with each driver version PACKAGE_NAME="sapphire-remote" diff --git a/sapphire-remote-6.6/extract_keydefs.sh b/sapphire-remote-7.1/extract_keydefs.sh similarity index 100% rename from sapphire-remote-6.6/extract_keydefs.sh rename to sapphire-remote-7.1/extract_keydefs.sh diff --git a/sapphire-remote-6.6/keymap.default b/sapphire-remote-7.1/keymap.default similarity index 100% rename from sapphire-remote-6.6/keymap.default rename to sapphire-remote-7.1/keymap.default diff --git a/sapphire-remote-6.6/sapphire.c b/sapphire-remote-7.1/sapphire.c similarity index 95% rename from sapphire-remote-6.6/sapphire.c rename to sapphire-remote-7.1/sapphire.c index b7414b0..3d1ddb0 100644 --- a/sapphire-remote-6.6/sapphire.c +++ b/sapphire-remote-7.1/sapphire.c @@ -1,7 +1,7 @@ /* * sapphire.c * - * Copyright Mark Lord , 2012-2015. + * Copyright Mark Lord , 2012-2018. * http://rtr.ca/sapphire_remote/ * * This is a HID driver for the TopSeed Cyberlink receiver @@ -38,7 +38,7 @@ #include "sapphire.h" #define SAPPHIRE_NAME "sapphire" -#define SAPPHIRE_VERSION "6.6" +#define SAPPHIRE_VERSION "7.1" /* * "LONGKEY": Any button can be used to generate a second, different keycode, @@ -55,7 +55,7 @@ * EDIT the "keycode" and "repeats" columns below to customize the keymap to your needs: */ #define SAPPHIRE_NUM_BUTTONS 46 /* The Sapphire remote sends 46 unique button codes */ -#define SAPPHIRE_KEYMAP_SIZE (2 * SAPPHIRE_NUM_BUTTONS) /* Extra room for a full XAPPHIRE_* set */ +#define SAPPHIRE_KEYMAP_SIZE (SAPPHIRE_NUM_BUTTONS) static struct sapphire_map { unsigned int button; /* raw data from sensor */ unsigned int keycode; /* keyboard value to pass to mythtv, or "0" for nothing */ @@ -130,6 +130,19 @@ static unsigned int sapphire_macros[8][8] = { /* KEY_MACRO_7 */ {0,} }; +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0) +#define SAPPHIRE_TIMER_ARG_T unsigned long +static inline void sapphire_timer_setup(struct timer_list *timer_p, void *callback) +{ + init_timer(timer_p); + timer_p->function = callback; + timer_p->data = (long)timer_p; +} +#else +#define sapphire_timer_setup(timer_p, callback) timer_setup(timer_p, callback, 0) +#define SAPPHIRE_TIMER_ARG_T struct timer_list * +#endif + static struct sapphire_dev { spinlock_t lock; struct input_dev *idev; @@ -268,7 +281,7 @@ static void sapphire_send_key(unsigned int key, unsigned int repeat_delay) /* * Timer callback function, used to handle repeats and "LONGKEYs". */ -static void sapphire_key_timeout(unsigned long data) +static void sapphire_key_timeout(SAPPHIRE_TIMER_ARG_T arg) { unsigned long flags; @@ -336,7 +349,7 @@ static void sapphire_handle_key (unsigned int key, unsigned int repeats) repeat_delay = (HZ/2) - (HZ/6); next_repeat = (HZ/3) | RAMPING; break; - default: /* LONGKEY or NO_REPEAT */ + default: if (repeats & LONGKEY) { /* * We don't know if it's a short or long press yet. @@ -390,6 +403,28 @@ static void sapphire_event(u32 data) sapphire_save_key(0); /* timestamp the event in /proc/, for shutdown timing.. */ } +/* + * Debouncing, primarily for when multiple receivers are used with a single remote. + */ +static int sapphire_debounce (u32 data) +{ + static u32 debounce_data; + static u64 debounce_time; + u64 now = get_jiffies_64(); + + if (debounce_time && data == debounce_data) { + u64 elapsed = now - debounce_time; + if (elapsed < (HZ/8)) { + //printk(KERN_INFO "d=%08x ld=%08x t=%llu lt=%llu IGNORE\n", data, debounce_data, now, debounce_time); + return 0; /* discard */ + } + } + //printk(KERN_INFO "k=%08x lk=%08x t=%llu lt=%llu\n", data, debounce_data, now, debounce_time); + debounce_data = data; + debounce_time = now; + return 1; /* keep */ +} + /* * This gets called each time the IR receiver "receives" something from a remote control. * The "size" of "raw_data" bytes received varies depending upon the button pressed, @@ -411,7 +446,8 @@ static int sapphire_raw_event(struct hid_device *hdev, struct hid_report *report for (i = size; i > 0; ) data = (data << 8) | raw_data[--i]; spin_lock_irqsave(&dev->lock, flags); - sapphire_event(data); + if (sapphire_debounce(data)) + sapphire_event(data); spin_unlock_irqrestore(&dev->lock, flags); } return -1; /* event was handled (used to return "1" here) */ @@ -639,6 +675,7 @@ static void sapphire_create_proc_entry (void) static int sapphire_probe(struct hid_device *hdev, const struct hid_device_id *id) { int ret = hid_parse(hdev); +printk(KERN_INFO "%s: hdev=%p id=%p\n", __func__, hdev, id); if (ret) return ret; ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); @@ -661,6 +698,7 @@ static int sapphire_probe(struct hid_device *hdev, const struct hid_device_id *i */ static void sapphire_remove(struct hid_device *hdev) { +printk(KERN_INFO "%s: hdev=%p\n", __func__, hdev); /* * We are supposed to do hid_hw_stop() here. * But some Ubuntu kernels (eg. 3.11.x, 3.2.x) totally kill the device @@ -756,9 +794,7 @@ static int sapphire_create (void) memset(dev, 0, sizeof(*dev)); /* paranoia */ spin_lock_init(&dev->lock); - init_timer(&dev->key_timer); - dev->key_timer.function = sapphire_key_timeout; - dev->key_timer.data = (unsigned long)dev; + sapphire_timer_setup(&dev->key_timer, sapphire_key_timeout); dev->idev = input_allocate_device(); if (!dev->idev) { diff --git a/sapphire-remote-6.6/sapphire.h b/sapphire-remote-7.1/sapphire.h similarity index 58% rename from sapphire-remote-6.6/sapphire.h rename to sapphire-remote-7.1/sapphire.h index f6305b4..c794e17 100644 --- a/sapphire-remote-6.6/sapphire.h +++ b/sapphire-remote-7.1/sapphire.h @@ -1,24 +1,16 @@ /* * sapphire.h * - * Copyright Mark Lord , 2012-2015. + * Copyright Mark Lord , 2012-2018. * http://rtr.ca/sapphire_remote/ * * Button definitions shared with sapphire_keymap.sh - * and the external glue driver. + * and other drivers which may use sapphire_relay(). * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; specifically version 2 of the License (GPLv2). */ -#include -#include -#include -#include -#include -#include -#include -#include /* * These enum's are shared with external keymaps and the sapphire_keymap.sh script: @@ -76,59 +68,6 @@ enum { /* SAPPHIRE_CLEAR = 0x004c0000 , /* CLEAR */ SAPPHIRE_GREENMUSIC = 0x00000804 , /* GREEN/MUSIC */ - /* - * A second set of "virtual" sapphire buttons, - * not for normal mapping use. Instead, these are - * intended for use with the external "glue" module. - * If you don't know what that is, then just ignore these! - */ - XAPPHIRE_UP = 0x005200f0 , /* UP */ - XAPPHIRE_DOWN = 0x005100f0 , /* DOWN */ - XAPPHIRE_RIGHT = 0x004f00f0 , /* RIGHT */ - XAPPHIRE_LEFT = 0x005000f0 , /* LEFT */ - XAPPHIRE_ENTEROK = 0x002800f0 , /* ENTER/OK */ - XAPPHIRE_BACK = 0x000400f3 , /* BACK */ - XAPPHIRE_PLAY = 0x400000f3 , /* PLAY */ - XAPPHIRE_PAUSE = 0x800000f3 , /* PAUSE */ - XAPPHIRE_VOLUP = 0x000020f3 , /* VOL+ */ - XAPPHIRE_VOLDOWN = 0x000040f3 , /* VOL- */ - XAPPHIRE_CHUP = 0x000100f3 , /* CH/PG+ */ - XAPPHIRE_CHDOWN = 0x000200f3 , /* CH/PG- */ - XAPPHIRE_MUTE = 0x000010f3 , /* MUTE */ - XAPPHIRE_RECORD = 0x000080f3 , /* RECORD */ - XAPPHIRE_FWD = 0x080000f3 , /* FWD */ - XAPPHIRE_REW = 0x040000f3 , /* REW */ - XAPPHIRE_ANGLE = 0x000100f4 , /* ANGLE */ - XAPPHIRE_SAP = 0x001000f4 , /* SAP */ - XAPPHIRE_DVDMENU = 0x000400f4 , /* DVDMENU */ - XAPPHIRE_INFOEPG = 0x020000f3 , /* INFO/EPG */ - XAPPHIRE_TAB = 0x000001f3 , /* TAB */ - XAPPHIRE_BACKTAB = 0x000002f3 , /* BACKTAB */ - XAPPHIRE_RADIO = 0x000004f3 , /* RADIO */ - XAPPHIRE_LASTCH = 0x004000f4 , /* LASTCH */ - XAPPHIRE_LANGUAGE = 0x000200f4 , /* LANGUAGE */ - XAPPHIRE_TELETEXTCC = 0x002000f4 , /* TELETEXT/CC */ - XAPPHIRE_SUBTITLE = 0x000800f4 , /* SUBTITLE */ - XAPPHIRE_HOMEHOUSE = 0x000001f4 , /* HOME (house) */ - XAPPHIRE_BLUEVIDEOS = 0x000020f4 , /* BLUE/VIDEOS */ - XAPPHIRE_LIVETV = 0x000002f4 , /* LIVETV */ - XAPPHIRE_REDDVDVCD = 0x000080f4 , /* RED/DVD/VCD */ - XAPPHIRE_YELLOWPICTURES = 0x000010f4 , /* YELLOW/PICTURES*/ - XAPPHIRE_1 = 0x001e00f0 , /* 1 */ - XAPPHIRE_2 = 0x001f00f0 , /* 2 */ - XAPPHIRE_3 = 0x002000f0 , /* 3 */ - XAPPHIRE_4 = 0x002100f0 , /* 4 */ - XAPPHIRE_5 = 0x002200f0 , /* 5 */ - XAPPHIRE_6 = 0x002300f0 , /* 6 */ - XAPPHIRE_7 = 0x002400f0 , /* 7 */ - XAPPHIRE_8 = 0x002500f0 , /* 8 */ - XAPPHIRE_9 = 0x002600f0 , /* 9 */ - XAPPHIRE_0 = 0x002700f0 , /* 0 */ - XAPPHIRE_STOP = 0x001000f3 , /* STOP */ - XAPPHIRE_POWER = 0x000002f2 , /* POWER */ - XAPPHIRE_CLEAR = 0x004c00f0 , /* CLEAR */ - XAPPHIRE_GREENMUSIC = 0x000008f4 , /* GREEN/MUSIC */ - /* * Modifier buttons: "OR" these with "regular" KEY_ values as desired: */ diff --git a/sapphire-remote-6.6/sapphire_keymap.sh.part1 b/sapphire-remote-7.1/sapphire_keymap.sh.part1 similarity index 100% rename from sapphire-remote-6.6/sapphire_keymap.sh.part1 rename to sapphire-remote-7.1/sapphire_keymap.sh.part1 diff --git a/sapphire-remote-6.6/sapphire_keymap.sh.part3 b/sapphire-remote-7.1/sapphire_keymap.sh.part3 similarity index 100% rename from sapphire-remote-6.6/sapphire_keymap.sh.part3 rename to sapphire-remote-7.1/sapphire_keymap.sh.part3 diff --git a/sapphire-remote-6.6/sapphire_startup.sh b/sapphire-remote-7.1/sapphire_startup.sh similarity index 81% rename from sapphire-remote-6.6/sapphire_startup.sh rename to sapphire-remote-7.1/sapphire_startup.sh index 96097fb..dc4f8f6 100755 --- a/sapphire-remote-6.6/sapphire_startup.sh +++ b/sapphire-remote-7.1/sapphire_startup.sh @@ -26,15 +26,16 @@ fi # The workaround below seems to restore functionality. # cd $SAPPHIRE || exit 1 -dev="$(/bin/ls -1d [0-9]*[0-9A-F] 2>/dev/null | head -1)" -if [ "$dev" != "" -a -e "$dev" ]; then - if cd -P "$dev/../.." ; then - if [ -e authorized ]; then - echo 0 > authorized - echo 1 > authorized +for dev in [0-9]*[0-9A-F] ; do + if [ -e "$dev" ]; then + if cd -P "$dev/../.." ; then + if [ -e authorized ]; then + echo 0 > authorized + echo 1 > authorized + fi + cd - >/dev/null fi - cd - >/dev/null fi -fi +done [ -e /etc/sapphire.keymap -a -x /usr/local/bin/sapphire_keymap.sh ] && /usr/local/bin/sapphire_keymap.sh exit 0 -- 2.30.2