From patchwork Sun Dec 26 09:14:45 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Henningsson X-Patchwork-Id: 433021 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oBRKCV40025997 for ; Mon, 27 Dec 2010 20:13:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751668Ab0LZJOv (ORCPT ); Sun, 26 Dec 2010 04:14:51 -0500 Received: from adelie.canonical.com ([91.189.90.139]:58210 "EHLO adelie.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751641Ab0LZJOq (ORCPT ); Sun, 26 Dec 2010 04:14:46 -0500 Received: from hutte.canonical.com ([91.189.90.181]) by adelie.canonical.com with esmtp (Exim 4.69 #1 (Debian)) id 1PWmgf-0005Qs-CW; Sun, 26 Dec 2010 09:14:45 +0000 Received: from c-83-233-18-148.cust.bredband2.com ([83.233.18.148] helo=[192.168.8.102]) by hutte.canonical.com with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1PWmgf-0007C1-89; Sun, 26 Dec 2010 09:14:45 +0000 Message-ID: <4D170785.1070306@canonical.com> Date: Sun, 26 Dec 2010 10:14:45 +0100 From: David Henningsson User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7 MIME-Version: 1.0 To: linux-media@vger.kernel.org CC: mchehab@infradead.org Subject: [PATCH] DVB: TechnoTrend CT-3650 IR support Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Mon, 27 Dec 2010 20:13:43 +0000 (UTC) From 705adeab4da152cf24cede069b724765b8a07d55 Mon Sep 17 00:00:00 2001 From: David Henningsson Date: Sun, 26 Dec 2010 07:55:57 +0100 Subject: [PATCH] DVB: TechnoTrend CT-3650 IR support This patch enables IR support on the TechnoTrend CT-3650 device, and is half of Waling Dijkstra's patch posted earlier this year, cleaned up a little. Signed-off-by: David Henningsson --- drivers/media/dvb/dvb-usb/ttusb2.c | 75 ++++++++++++++++++++++++++++++++++++ drivers/media/dvb/dvb-usb/ttusb2.h | 3 + 2 files changed, 78 insertions(+), 0 deletions(-) diff --git a/drivers/media/dvb/dvb-usb/ttusb2.c b/drivers/media/dvb/dvb-usb/ttusb2.c index a6de489..1bacfc8 100644 --- a/drivers/media/dvb/dvb-usb/ttusb2.c +++ b/drivers/media/dvb/dvb-usb/ttusb2.c @@ -128,6 +128,76 @@ static struct i2c_algorithm ttusb2_i2c_algo = { .functionality = ttusb2_i2c_func, }; +/* IR */ +/* Remote Control Stuff for CT-3650 (copied from TT-S1500): */ +static struct dvb_usb_rc_key tt_connect_CT_3650_rc_key[] = { + {0x1501, KEY_POWER}, + {0x1502, KEY_SHUFFLE}, /* ? double-arrow key */ + {0x1503, KEY_1}, + {0x1504, KEY_2}, + {0x1505, KEY_3}, + {0x1506, KEY_4}, + {0x1507, KEY_5}, + {0x1508, KEY_6}, + {0x1509, KEY_7}, + {0x150a, KEY_8}, + {0x150b, KEY_9}, + {0x150c, KEY_0}, + {0x150d, KEY_UP}, + {0x150e, KEY_LEFT}, + {0x150f, KEY_OK}, + {0x1510, KEY_RIGHT}, + {0x1511, KEY_DOWN}, + {0x1512, KEY_INFO}, + {0x1513, KEY_EXIT}, + {0x1514, KEY_RED}, + {0x1515, KEY_GREEN}, + {0x1516, KEY_YELLOW}, + {0x1517, KEY_BLUE}, + {0x1518, KEY_MUTE}, + {0x1519, KEY_TEXT}, + {0x151a, KEY_MODE}, /* ? TV/Radio */ + {0x1521, KEY_OPTION}, + {0x1522, KEY_EPG}, + {0x1523, KEY_CHANNELUP}, + {0x1524, KEY_CHANNELDOWN}, + {0x1525, KEY_VOLUMEUP}, + {0x1526, KEY_VOLUMEDOWN}, + {0x1527, KEY_SETUP}, + {0x153a, KEY_RECORD},/* these keys are only in the black remote */ + {0x153b, KEY_PLAY}, + {0x153c, KEY_STOP}, + {0x153d, KEY_REWIND}, + {0x153e, KEY_PAUSE}, + {0x153f, KEY_FORWARD} +}; + +/* Copy-pasted from dvb-usb-remote.c */ +#define DVB_USB_RC_NEC_KEY_PRESSED 0x01 + +static int tt3650_rc_query(struct dvb_usb_device *d, u32 *keyevent, int *keystate) +{ + u8 keybuf[5]; + int ret; + u8 rx[9]; /* A CMD_GET_IR_CODE reply is 9 bytes long */ + ret = ttusb2_msg(d, CMD_GET_IR_CODE, NULL, 0, rx, sizeof(rx)); + if (ret != 0) + return ret; + + if (rx[8] & 0x01) { + /* got a "press" event */ + deb_info("%s: cmd=0x%02x sys=0x%02x\n", __func__, rx[2], rx[3]); + keybuf[0] = DVB_USB_RC_NEC_KEY_PRESSED; + keybuf[1] = rx[3]; + keybuf[2] = ~keybuf[1]; /* fake checksum */ + keybuf[3] = rx[2]; + keybuf[4] = ~keybuf[3]; /* fake checksum */ + dvb_usb_nec_rc_key_to_event(d, keybuf, keyevent, keystate); + } + return 0; +} + + /* Callbacks for DVB USB */ static int ttusb2_identify_state (struct usb_device *udev, struct dvb_usb_device_properties *props, struct dvb_usb_device_description **desc, @@ -345,6 +415,11 @@ static struct dvb_usb_device_properties ttusb2_properties_ct3650 = { .size_of_priv = sizeof(struct ttusb2_state), + .rc_key_map = tt_connect_CT_3650_rc_key, + .rc_key_map_size = ARRAY_SIZE(tt_connect_CT_3650_rc_key), + .rc_query = tt3650_rc_query, + .rc_interval = 500, + .num_adapters = 1, .adapter = { { diff --git a/drivers/media/dvb/dvb-usb/ttusb2.h b/drivers/media/dvb/dvb-usb/ttusb2.h index 52a63af..1bd5d54 100644 --- a/drivers/media/dvb/dvb-usb/ttusb2.h +++ b/drivers/media/dvb/dvb-usb/ttusb2.h @@ -45,6 +45,9 @@ #define CMD_DISEQC 0x18 /* out data: [cmdlen] */ +/* command to poll IR receiver (copied from pctv452e.c) */ +#define CMD_GET_IR_CODE 0x1b + #define CMD_PID_ENABLE 0x22 /* out data: */ -- 1.7.1