Skip to content

Commit

Permalink
[media] ati_remote: add support for SnapStream Firefly remote
Browse files Browse the repository at this point in the history
The protocol differs by having two toggle bits in the scancode. Since
one of the bits is otherwise unused, we can safely handle the bits
unconditionally.

[mchehab@redhat.com: Fix some bad whitespacing]
Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Anssi Hannula authored and Mauro Carvalho Chehab committed Sep 22, 2011
1 parent 175fcec commit 999d6bc
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 2 deletions.
15 changes: 13 additions & 2 deletions drivers/media/rc/ati_remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
#define ATI_REMOTE_PRODUCT_ID 0x0004
#define NVIDIA_REMOTE_PRODUCT_ID 0x0005
#define MEDION_REMOTE_PRODUCT_ID 0x0006
#define FIREFLY_REMOTE_PRODUCT_ID 0x0008

#define DRIVER_VERSION "2.2.1"
#define DRIVER_AUTHOR "Torrey Hoffman <thoffman@arnor.net>"
Expand Down Expand Up @@ -156,6 +157,7 @@ static struct usb_device_id ati_remote_table[] = {
{ USB_DEVICE(ATI_REMOTE_VENDOR_ID, ATI_REMOTE_PRODUCT_ID), .driver_info = (unsigned long)RC_MAP_ATI_X10 },
{ USB_DEVICE(ATI_REMOTE_VENDOR_ID, NVIDIA_REMOTE_PRODUCT_ID), .driver_info = (unsigned long)RC_MAP_ATI_X10 },
{ USB_DEVICE(ATI_REMOTE_VENDOR_ID, MEDION_REMOTE_PRODUCT_ID), .driver_info = (unsigned long)RC_MAP_MEDION_X10 },
{ USB_DEVICE(ATI_REMOTE_VENDOR_ID, FIREFLY_REMOTE_PRODUCT_ID), .driver_info = (unsigned long)RC_MAP_SNAPSTREAM_FIREFLY },
{} /* Terminating entry */
};

Expand Down Expand Up @@ -482,7 +484,15 @@ static void ati_remote_input_report(struct urb *urb)

scancode[0] = (((data[1] - ((remote_num + 1) << 4)) & 0xf0) | (data[1] & 0x0f));

scancode[1] = data[2];
/*
* Some devices (e.g. SnapStream Firefly) use 8080 as toggle code,
* so we have to clear them. The first bit is a bit tricky as the
* "non-toggled" state depends on remote_num, so we xor it with the
* second bit which is only used for toggle.
*/
scancode[0] ^= (data[2] & 0x80);

scancode[1] = data[2] & ~0x80;

/* Look up event code index in mouse translation table. */
index = ati_remote_event_lookup(remote_num, scancode[0], scancode[1]);
Expand Down Expand Up @@ -546,7 +556,8 @@ static void ati_remote_input_report(struct urb *urb)
* it would cause ghost repeats which would be a
* regression for this driver.
*/
rc_keydown_notimeout(ati_remote->rdev, rc_code, 0);
rc_keydown_notimeout(ati_remote->rdev, rc_code,
data[2]);
rc_keyup(ati_remote->rdev);
return;
}
Expand Down
1 change: 1 addition & 0 deletions drivers/media/rc/keymaps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \
rc-hauppauge.o \
rc-rc6-mce.o \
rc-real-audio-220-32-keys.o \
rc-snapstream-firefly.o \
rc-streamzap.o \
rc-tbs-nec.o \
rc-technisat-usb2.o \
Expand Down
106 changes: 106 additions & 0 deletions drivers/media/rc/keymaps/rc-snapstream-firefly.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
* SnapStream Firefly X10 RF remote keytable
*
* Copyright (C) 2011 Anssi Hannula <anssi.hannula@?ki.fi>
*
* 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; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include <media/rc-map.h>

static struct rc_map_table snapstream_firefly[] = {
{ 0xf12c, KEY_ZOOM }, /* Maximize */
{ 0xc702, KEY_CLOSE },

{ 0xd20d, KEY_1 },
{ 0xd30e, KEY_2 },
{ 0xd40f, KEY_3 },
{ 0xd510, KEY_4 },
{ 0xd611, KEY_5 },
{ 0xd712, KEY_6 },
{ 0xd813, KEY_7 },
{ 0xd914, KEY_8 },
{ 0xda15, KEY_9 },
{ 0xdc17, KEY_0 },
{ 0xdb16, KEY_BACK },
{ 0xdd18, KEY_KPENTER }, /* ent */

{ 0xce09, KEY_VOLUMEUP },
{ 0xcd08, KEY_VOLUMEDOWN },
{ 0xcf0a, KEY_MUTE },
{ 0xd00b, KEY_CHANNELUP },
{ 0xd10c, KEY_CHANNELDOWN },
{ 0xc500, KEY_VENDOR }, /* firefly */

{ 0xf32e, KEY_INFO },
{ 0xf42f, KEY_OPTION },

{ 0xe21d, KEY_LEFT },
{ 0xe41f, KEY_RIGHT },
{ 0xe722, KEY_DOWN },
{ 0xdf1a, KEY_UP },
{ 0xe31e, KEY_OK },

{ 0xe11c, KEY_MENU },
{ 0xe520, KEY_EXIT },

{ 0xec27, KEY_RECORD },
{ 0xea25, KEY_PLAY },
{ 0xed28, KEY_STOP },
{ 0xe924, KEY_REWIND },
{ 0xeb26, KEY_FORWARD },
{ 0xee29, KEY_PAUSE },
{ 0xf02b, KEY_PREVIOUS },
{ 0xef2a, KEY_NEXT },

{ 0xcb06, KEY_AUDIO }, /* Music */
{ 0xca05, KEY_IMAGES }, /* Photos */
{ 0xc904, KEY_DVD },
{ 0xc803, KEY_TV },
{ 0xcc07, KEY_VIDEO },

{ 0xc601, KEY_HELP },
{ 0xf22d, KEY_MODE }, /* Mouse */

{ 0xde19, KEY_A },
{ 0xe01b, KEY_B },
{ 0xe621, KEY_C },
{ 0xe823, KEY_D },
};

static struct rc_map_list snapstream_firefly_map = {
.map = {
.scan = snapstream_firefly,
.size = ARRAY_SIZE(snapstream_firefly),
.rc_type = RC_TYPE_OTHER,
.name = RC_MAP_SNAPSTREAM_FIREFLY,
}
};

static int __init init_rc_map_snapstream_firefly(void)
{
return rc_map_register(&snapstream_firefly_map);
}

static void __exit exit_rc_map_snapstream_firefly(void)
{
rc_map_unregister(&snapstream_firefly_map);
}

module_init(init_rc_map_snapstream_firefly)
module_exit(exit_rc_map_snapstream_firefly)

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Anssi Hannula <anssi.hannula@iki.fi>");
1 change: 1 addition & 0 deletions include/media/rc-map.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ void rc_map_init(void);
#define RC_MAP_RC5_TV "rc-rc5-tv"
#define RC_MAP_RC6_MCE "rc-rc6-mce"
#define RC_MAP_REAL_AUDIO_220_32_KEYS "rc-real-audio-220-32-keys"
#define RC_MAP_SNAPSTREAM_FIREFLY "rc-snapstream-firefly"
#define RC_MAP_STREAMZAP "rc-streamzap"
#define RC_MAP_TBS_NEC "rc-tbs-nec"
#define RC_MAP_TECHNISAT_USB2 "rc-technisat-usb2"
Expand Down

0 comments on commit 999d6bc

Please sign in to comment.