GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / drivers / media / dvb / siano / smsir.c
blobd1966d02453b51a89015253953c4575a2a440b7b
1 /****************************************************************
3 Siano Mobile Silicon, Inc.
4 MDTV receiver kernel modules.
5 Copyright (C) 2006-2009, Uri Shkolnik
7 Copyright (c) 2010 - Mauro Carvalho Chehab
8 - Ported the driver to use rc-core
9 - IR raw event decoding is now done at rc-core
10 - Code almost re-written
12 This program is free software: you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation, either version 2 of the License, or
15 (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 ****************************************************************/
28 #include <linux/types.h>
29 #include <linux/input.h>
31 #include "smscoreapi.h"
32 #include "smsir.h"
33 #include "sms-cards.h"
35 #define MODULE_NAME "smsmdtv"
37 void sms_ir_event(struct smscore_device_t *coredev, const char *buf, int len)
39 int i;
40 const s32 *samples = (const void *)buf;
42 for (i = 0; i < len >> 2; i++) {
43 struct ir_raw_event ev;
45 ev.duration = abs(samples[i]) * 1000; /* Convert to ns */
46 ev.pulse = (samples[i] > 0) ? false : true;
48 ir_raw_event_store(coredev->ir.input_dev, &ev);
50 ir_raw_event_handle(coredev->ir.input_dev);
53 int sms_ir_init(struct smscore_device_t *coredev)
55 struct input_dev *input_dev;
56 int board_id = smscore_get_board_id(coredev);
58 sms_log("Allocating input device");
59 input_dev = input_allocate_device();
60 if (!input_dev) {
61 sms_err("Not enough memory");
62 return -ENOMEM;
65 coredev->ir.input_dev = input_dev;
67 coredev->ir.controller = 0; /* Todo: vega/nova SPI number */
68 coredev->ir.timeout = IR_DEFAULT_TIMEOUT;
69 sms_log("IR port %d, timeout %d ms",
70 coredev->ir.controller, coredev->ir.timeout);
72 snprintf(coredev->ir.name, sizeof(coredev->ir.name),
73 "SMS IR (%s)", sms_get_board(board_id)->name);
75 strlcpy(coredev->ir.phys, coredev->devpath, sizeof(coredev->ir.phys));
76 strlcat(coredev->ir.phys, "/ir0", sizeof(coredev->ir.phys));
78 input_dev->name = coredev->ir.name;
79 input_dev->phys = coredev->ir.phys;
80 input_dev->dev.parent = coredev->device;
83 coredev->ir.props.priv = coredev;
84 coredev->ir.props.driver_type = RC_DRIVER_IR_RAW;
85 coredev->ir.props.allowed_protos = IR_TYPE_ALL;
87 sms_log("Input device (IR) %s is set for key events", input_dev->name);
89 if (ir_input_register(input_dev, sms_get_board(board_id)->rc_codes,
90 &coredev->ir.props, MODULE_NAME)) {
91 sms_err("Failed to register device");
92 input_free_device(input_dev);
93 return -EACCES;
96 return 0;
99 void sms_ir_exit(struct smscore_device_t *coredev)
101 if (coredev->ir.input_dev)
102 ir_input_unregister(coredev->ir.input_dev);
104 sms_log("");