~ubuntu-branches/ubuntu/trusty/linux-ti-omap/trusty

« back to all changes in this revision

Viewing changes to ubuntu/lirc/lirc_gpio/lirc_gpio.c

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Bader, Amit Kucheria
  • Date: 2010-03-23 18:05:12 UTC
  • Revision ID: james.westby@ubuntu.com-20100323180512-iavj906ocnphdubp
Tags: 2.6.33-500.3
[ Amit Kucheria ]

* [Config] Fix the debug package name to end in -dbgsym
* SAUCE: Add the ubuntu/ drivers to omap
* SAUCE: Re-export the symbols for aufs
* [Config] Enable AUFS and COMPCACHE

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Remote control driver for the TV-card
 
3
 * key codes are obtained from GPIO port
 
4
 *
 
5
 * (L) by Artur Lipowski <alipowski@interia.pl>
 
6
 *     patch for the AverMedia by Santiago Garcia Mantinan <manty@i.am>
 
7
 *                          and Christoph Bartelmus <lirc@bartelmus.de>
 
8
 *     patch for the BestBuy by Miguel Angel Alvarez <maacruz@navegalia.com>
 
9
 *     patch for the Winfast TV2000 by Juan Toledo
 
10
 *     <toledo@users.sourceforge.net>
 
11
 *     patch for the I-O Data GV-BCTV5/PCI by Jens C. Rasmussen
 
12
 *     <jens.rasmussen@ieee.org>
 
13
 *
 
14
 *  This program is free software; you can redistribute it and/or modify
 
15
 *  it under the terms of the GNU General Public License as published by
 
16
 *  the Free Software Foundation; either version 2 of the License, or
 
17
 *  (at your option) any later version.
 
18
 *
 
19
 *  This program is distributed in the hope that it will be useful,
 
20
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
21
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
22
 *  GNU General Public License for more details.
 
23
 *
 
24
 *  You should have received a copy of the GNU General Public License
 
25
 *  along with this program; if not, write to the Free Software
 
26
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
27
 *
 
28
 * $Id: lirc_gpio.c,v 1.57 2009/02/14 19:35:52 lirc Exp $
 
29
 *
 
30
 */
 
31
 
 
32
#include <linux/version.h>
 
33
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 2, 4)
 
34
#error "*******************************************************"
 
35
#error "Sorry, this driver needs kernel version 2.2.4 or higher"
 
36
#error "*******************************************************"
 
37
#endif
 
38
 
 
39
#include <linux/version.h>
 
40
#include <linux/module.h>
 
41
#include <linux/kmod.h>
 
42
#include <linux/sched.h>
 
43
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
 
44
#include <linux/wrapper.h>
 
45
#endif
 
46
#include <linux/errno.h>
 
47
 
 
48
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 0)
 
49
#include "../drivers/char/bttv.h"
 
50
#include "../drivers/char/bttvp.h"
 
51
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 17)
 
52
#include "../drivers/media/video/bttv.h"
 
53
#include "../drivers/media/video/bttvp.h"
 
54
#else
 
55
#include "../drivers/media/video/bt8xx/bttv.h"
 
56
#include "../drivers/media/video/bt8xx/bttvp.h"
 
57
#endif
 
58
 
 
59
#if BTTV_VERSION_CODE < KERNEL_VERSION(0, 7, 45)
 
60
#error "*******************************************************"
 
61
#error " Sorry, this driver needs bttv version 0.7.45 or       "
 
62
#error " higher. If you are using the bttv package, copy it to "
 
63
#error " the kernel                                         "
 
64
#error "*******************************************************"
 
65
#endif
 
66
 
 
67
#include "../kcompat.h"
 
68
#include "../lirc_dev/lirc_dev.h"
 
69
 
 
70
/* insmod parameters */
 
71
static int debug;
 
72
static int card;
 
73
static int minor = -1;
 
74
static int bttv_id = BTTV_BOARD_UNKNOWN;
 
75
static unsigned long gpio_mask;
 
76
static unsigned long gpio_enable;
 
77
static unsigned long gpio_lock_mask;
 
78
static unsigned long gpio_xor_mask;
 
79
static int soft_gap;
 
80
static int sample_rate = 10;
 
81
 
 
82
#define dprintk(fmt, args...)                                   \
 
83
        do {                                                    \
 
84
                if (debug)                                      \
 
85
                        printk(KERN_DEBUG fmt, ## args);        \
 
86
        } while (0)
 
87
 
 
88
struct rcv_info {
 
89
        int bttv_id;
 
90
        int card_id;
 
91
        unsigned long gpio_mask;
 
92
        unsigned long gpio_enable;
 
93
        unsigned long gpio_lock_mask;
 
94
        unsigned long gpio_xor_mask;
 
95
        int soft_gap;
 
96
        int sample_rate;
 
97
        unsigned char code_length;
 
98
};
 
99
 
 
100
static struct rcv_info rcv_infos[] = {
 
101
        {BTTV_BOARD_UNKNOWN,
 
102
                0, 0, 0, 0, 0, 0, 1, 0},
 
103
        {BTTV_BOARD_PXELVWPLTVPAK,
 
104
                0, 0x00003e00, 0, 0x0010000, 0, 0, 15, 32},
 
105
        {BTTV_BOARD_PXELVWPLTVPRO,
 
106
                0, 0x00001f00, 0, 0x0008000, 0, 500, 12, 32},
 
107
        {BTTV_BOARD_PV_BT878P_9B,
 
108
                0, 0x00001f00, 0, 0x0008000, 0, 500, 12, 32},
 
109
        {BTTV_BOARD_PV_BT878P_PLUS,
 
110
                0, 0x00001f00, 0, 0x0008000, 0, 500, 12, 32},
 
111
#ifdef BTTV_BOARD_PV_M4900
 
112
        {BTTV_BOARD_PV_M4900,
 
113
                0, 0x00001f00, 0, 0x0008000, 0, 500, 12, 32},
 
114
#endif
 
115
        {BTTV_BOARD_AVERMEDIA,
 
116
                0, 0x00f88000, 0, 0x0010000, 0x00010000, 0, 10, 32},
 
117
 
 
118
        /* mapped to Capture98 */
 
119
        {BTTV_BOARD_AVPHONE98,
 
120
                0x00011461, 0x003b8000, 0x00004000,
 
121
                0x0800000, 0x00800000, 0, 10, 0},
 
122
        {BTTV_BOARD_AVERMEDIA98,
 
123
                0x00021461, 0x003b8000, 0x00004000,
 
124
                0x0800000, 0x00800000, 0, 10, 0},
 
125
 
 
126
        /* mapped to Phone98 */
 
127
        {BTTV_BOARD_AVPHONE98,
 
128
                0x00031461, 0x00f88000, 0, 0x0010000, 0x00010000, 0, 10, 32},
 
129
        /* is this one correct? */
 
130
        {BTTV_BOARD_AVERMEDIA98,
 
131
                0x00041461, 0x00f88000, 0, 0x0010000, 0x00010000, 0, 10, 32},
 
132
        /* work-around for VDOMATE */
 
133
        {BTTV_BOARD_AVERMEDIA98,
 
134
                0x03001461, 0x00f88000, 0, 0x0010000, 0x00010000, 0, 10, 32},
 
135
        /* reported by Danijel Korzinek, AVerTV GOw/FM */
 
136
        {BTTV_BOARD_AVERMEDIA98,
 
137
                0x00000000, 0x00f88000, 0, 0x0010000, 0x00010000, 0, 10, 32},
 
138
 
 
139
        {BTTV_BOARD_CHRONOS_VS2,
 
140
                0, 0x000000f8,  0, 0x0000100, 0, 0, 20, 0},
 
141
        /* CPH031 and CPH033 cards (?) */
 
142
        /* MIRO was just a work-around */
 
143
        {BTTV_BOARD_MIRO,
 
144
                0, 0x00001f00, 0, 0x0004000, 0, 0, 10, 32},
 
145
        {BTTV_BOARD_DYNALINK,
 
146
                0, 0x00001f00, 0, 0x0004000, 0, 0, 10, 32},
 
147
#ifdef BTTV_BOARD_ASKEY_CPH03X
 
148
        {BTTV_BOARD_ASKEY_CPH03X,
 
149
                0, 0x00001f00, 0, 0x0004000, 0, 0, 10, 32},
 
150
#endif
 
151
        {BTTV_BOARD_WINVIEW_601,
 
152
                0, 0x00001f00, 0, 0x0004000, 0, 0, 0, 32},
 
153
#ifdef BTTV_BOARD_KWORLD
 
154
        {BTTV_BOARD_KWORLD,
 
155
                0, 0x00007f00, 0, 0x0004000, 0, 0, 12, 32},
 
156
#endif
 
157
        /* just a guess */
 
158
        {BTTV_BOARD_MAGICTVIEW061,
 
159
                0, 0x0028e000, 0, 0x0020000, 0, 0, 20, 32},
 
160
        {BTTV_BOARD_MAGICTVIEW063,
 
161
                0, 0x0028e000, 0, 0x0020000, 0, 0, 20, 32},
 
162
        {BTTV_BOARD_PHOEBE_TVMAS,
 
163
                0, 0x0028e000, 0, 0x0020000, 0, 0, 20, 32},
 
164
#ifdef BTTV_BOARD_BESTBUY_EASYTV2
 
165
        {BTTV_BOARD_BESTBUY_EASYTV,
 
166
                0, 0x00007F00, 0, 0x0004000, 0, 0, 10, 8},
 
167
        {BTTV_BOARD_BESTBUY_EASYTV2,
 
168
                0, 0x00007F00, 0, 0x0008000, 0, 0, 10, 8},
 
169
#endif
 
170
        /* lock_mask probably also 0x100, or maybe it is 0x0 for all others? */
 
171
        {BTTV_BOARD_FLYVIDEO,
 
172
                0, 0x000000f8, 0, 0, 0, 0, 0, 42},
 
173
        {BTTV_BOARD_FLYVIDEO_98,
 
174
                0, 0x000000f8,  0, 0x0000100, 0, 0, 0, 42},
 
175
        {BTTV_BOARD_TYPHOON_TVIEW,
 
176
                0, 0x000000f8, 0, 0x0000100, 0, 0, 0, 42},
 
177
#ifdef BTTV_BOARD_FLYVIDEO_98FM
 
178
        /* smorar@alfonzo.smuts.uct.ac.za */
 
179
        {BTTV_BOARD_FLYVIDEO_98FM,
 
180
                0, 0x000000f8, 0, 0x0000100, 0, 0, 0, 42},
 
181
#endif
 
182
        /* The Leadtek WinFast TV 2000 XP card (id 0x6606107d) uses an
 
183
         * extra gpio bit compared to the original TV 2000 card (id
 
184
         * 0x217d6606); as the bttv-0.7.100 driver does not
 
185
         * distinguish between the two cards, we enable the extra bit
 
186
         * based on the card id: */
 
187
        {BTTV_BOARD_WINFAST2000,
 
188
                0x6606107d, 0x000008f8, 0, 0x0000100, 0, 0, 0, 32},
 
189
        {BTTV_BOARD_WINFAST2000,
 
190
                0x6609107d, 0x000008f8, 0, 0x0000100, 0, 0, 0, 32},
 
191
        {BTTV_BOARD_WINFAST2000,
 
192
                0xff06107d, 0x000008f8, 0, 0x0000100, 0, 0, 0, 32},
 
193
        /* default: */
 
194
        {BTTV_BOARD_WINFAST2000,
 
195
                0, 0x000000f8,  0, 0x0000100, 0, 0, 0, 32},
 
196
#ifdef BTTV_BOARD_GVBCTV5PCI
 
197
        {BTTV_BOARD_GVBCTV5PCI,
 
198
                0, 0x00f0b000, 0, 0, 0, 0, 20, 8},
 
199
#endif
 
200
};
 
201
 
 
202
static unsigned char code_length;
 
203
static unsigned char code_bytes = 1;
 
204
 
 
205
#define MAX_BYTES 8
 
206
 
 
207
#define LOGHEAD "lirc_gpio (%d): "
 
208
 
 
209
/* how many bits GPIO value can be shifted right before processing
 
210
 * it is computed from the value of gpio_mask_parameter
 
211
 */
 
212
static unsigned char gpio_pre_shift;
 
213
 
 
214
static int reverse(int data, int bits)
 
215
{
 
216
        int i;
 
217
        int c;
 
218
 
 
219
        for (c = 0, i = 0; i < bits; i++)
 
220
                c |= (((data & (1<<i)) ? 1:0)) << (bits-1-i);
 
221
 
 
222
        return c;
 
223
}
 
224
 
 
225
static int build_key(unsigned long gpio_val, unsigned char codes[MAX_BYTES])
 
226
{
 
227
        unsigned long mask = gpio_mask;
 
228
        unsigned char shift = 0;
 
229
 
 
230
        dprintk(LOGHEAD "gpio_val is %lx\n", card, (unsigned long) gpio_val);
 
231
 
 
232
        gpio_val ^= gpio_xor_mask;
 
233
 
 
234
        if (gpio_lock_mask && (gpio_val & gpio_lock_mask))
 
235
                return -EBUSY;
 
236
 
 
237
        switch (bttv_id) {
 
238
        case BTTV_BOARD_AVERMEDIA98:
 
239
                if (bttv_write_gpio(card, gpio_enable, gpio_enable)) {
 
240
                        dprintk(LOGHEAD "cannot write to GPIO\n", card);
 
241
                        return -EIO;
 
242
                }
 
243
                if (bttv_read_gpio(card, &gpio_val)) {
 
244
                        dprintk(LOGHEAD "cannot read GPIO\n", card);
 
245
                        return -EIO;
 
246
                }
 
247
                if (bttv_write_gpio(card, gpio_enable, 0)) {
 
248
                        dprintk(LOGHEAD "cannot write to GPIO\n", card);
 
249
                        return -EIO;
 
250
                }
 
251
                break;
 
252
        default:
 
253
                break;
 
254
        }
 
255
 
 
256
        /* extract bits from "raw" GPIO value using gpio_mask */
 
257
        codes[0] = 0;
 
258
        gpio_val >>= gpio_pre_shift;
 
259
        while (mask) {
 
260
                if (mask & 1u)
 
261
                        codes[0] |= (gpio_val & 1u) << shift++;
 
262
                mask >>= 1;
 
263
                gpio_val >>= 1;
 
264
        }
 
265
 
 
266
        dprintk(LOGHEAD "code is %lx\n", card, (unsigned long) codes[0]);
 
267
        switch (bttv_id) {
 
268
        case BTTV_BOARD_AVERMEDIA:
 
269
                codes[2] = (codes[0]<<2)&0xff;
 
270
                codes[3] = (~codes[2])&0xff;
 
271
                codes[0] = 0x02;
 
272
                codes[1] = 0xFD;
 
273
                break;
 
274
        case BTTV_BOARD_AVPHONE98:
 
275
                codes[2] = ((codes[0]&(~0x1))<<2)&0xff;
 
276
                codes[3] = (~codes[2])&0xff;
 
277
                if (codes[0]&0x1) {
 
278
                        codes[0] = 0xc0;
 
279
                        codes[1] = 0x3f;
 
280
                } else {
 
281
                        codes[0] = 0x40;
 
282
                        codes[1] = 0xbf;
 
283
                }
 
284
                break;
 
285
        case BTTV_BOARD_AVERMEDIA98:
 
286
                break;
 
287
        case BTTV_BOARD_FLYVIDEO:
 
288
        case BTTV_BOARD_FLYVIDEO_98:
 
289
        case BTTV_BOARD_TYPHOON_TVIEW:
 
290
#ifdef BTTV_BOARD_FLYVIDEO_98FM
 
291
        case BTTV_BOARD_FLYVIDEO_98FM:
 
292
#endif
 
293
                codes[4] = codes[0]<<3;
 
294
                codes[5] = ((~codes[4])&0xff);
 
295
 
 
296
                codes[0] = 0x00;
 
297
                codes[1] = 0x1A;
 
298
                codes[2] = 0x1F;
 
299
                codes[3] = 0x2F;
 
300
                break;
 
301
        case BTTV_BOARD_MAGICTVIEW061:
 
302
        case BTTV_BOARD_MAGICTVIEW063:
 
303
        case BTTV_BOARD_PHOEBE_TVMAS:
 
304
                codes[0] = (codes[0]&0x01)
 
305
                        | ((codes[0]&0x02)<<1)
 
306
                        | ((codes[0]&0x04)<<2)
 
307
                        | ((codes[0]&0x08)>>2)
 
308
                        | ((codes[0]&0x10)>>1);
 
309
                /* FALLTHROUGH */
 
310
        case BTTV_BOARD_MIRO:
 
311
        case BTTV_BOARD_DYNALINK:
 
312
#ifdef BTTV_BOARD_ASKEY_CPH03X
 
313
        case BTTV_BOARD_ASKEY_CPH03X:
 
314
#endif
 
315
        case BTTV_BOARD_PXELVWPLTVPAK:
 
316
        case BTTV_BOARD_PXELVWPLTVPRO:
 
317
        case BTTV_BOARD_PV_BT878P_9B:
 
318
        case BTTV_BOARD_PV_BT878P_PLUS:
 
319
#ifdef BTTV_BOARD_PV_M4900
 
320
        case BTTV_BOARD_PV_M4900:
 
321
#endif
 
322
#ifdef BTTV_BOARD_KWORLD
 
323
        case BTTV_BOARD_KWORLD:
 
324
#endif
 
325
                codes[2] = reverse(codes[0], 8);
 
326
                codes[3] = (~codes[2])&0xff;
 
327
                codes[0] = 0x61;
 
328
                codes[1] = 0xD6;
 
329
                break;
 
330
#if 0
 
331
                /* derived from e-tech config file */
 
332
                /* 26 + 16 bits */
 
333
                /* won't apply it until it's confirmed with a fly98 */
 
334
        case BTTV_BOARD_FLYVIDEO_98:
 
335
        case BTTV_BOARD_FLYVIDEO_98FM:
 
336
                codes[4] = codes[0]<<3;
 
337
                codes[5] = (~codes[4])&0xff;
 
338
 
 
339
                codes[0] = 0x00;
 
340
                codes[1] = 0x1A;
 
341
                codes[2] = 0x1F;
 
342
                codes[3] = 0x2F;
 
343
                break;
 
344
#endif
 
345
        case BTTV_BOARD_WINFAST2000:
 
346
                /* shift extra bit */
 
347
                codes[0] = (codes[0]&0x1f) | ((codes[0]&0x20) << 1);
 
348
        case BTTV_BOARD_WINVIEW_601:
 
349
                codes[2] = reverse(codes[0], 8);
 
350
                codes[3] = (~codes[2])&0xff;
 
351
                codes[0] = 0xC0;
 
352
                codes[1] = 0x3F;
 
353
                break;
 
354
        default:
 
355
                break;
 
356
        }
 
357
 
 
358
        return 0;
 
359
}
 
360
 
 
361
/* add_to_buf - copy a code to the buffer */
 
362
static int add_to_buf(void *data, struct lirc_buffer *buf)
 
363
{
 
364
        static unsigned long next_time;
 
365
        static unsigned char prev_codes[MAX_BYTES];
 
366
        unsigned long code = 0;
 
367
        unsigned char cur_codes[MAX_BYTES];
 
368
 
 
369
        if (bttv_read_gpio(card, &code)) {
 
370
                dprintk(LOGHEAD "cannot read GPIO\n", card);
 
371
                return -EIO;
 
372
        }
 
373
 
 
374
        if (build_key(code, cur_codes))
 
375
                return -EFAULT;
 
376
 
 
377
        if (soft_gap) {
 
378
                if (!memcmp(prev_codes, cur_codes, code_bytes) &&
 
379
                        jiffies < next_time)
 
380
                        return -EAGAIN;
 
381
 
 
382
                next_time = jiffies + soft_gap;
 
383
        }
 
384
        memcpy(prev_codes, cur_codes, code_bytes);
 
385
 
 
386
        lirc_buffer_write(buf, cur_codes);
 
387
 
 
388
        return 0;
 
389
}
 
390
 
 
391
static int set_use_inc(void *data)
 
392
{
 
393
        MOD_INC_USE_COUNT;
 
394
        return 0;
 
395
}
 
396
 
 
397
static void set_use_dec(void *data)
 
398
{
 
399
        MOD_DEC_USE_COUNT;
 
400
}
 
401
 
 
402
static wait_queue_head_t *get_queue(void *data)
 
403
{
 
404
        return bttv_get_gpio_queue(card);
 
405
}
 
406
 
 
407
static struct lirc_driver driver = {
 
408
        .name           = "lirc_gpio  ",
 
409
        .add_to_buf     = add_to_buf,
 
410
        .get_queue      = get_queue,
 
411
        .set_use_inc    = set_use_inc,
 
412
        .set_use_dec    = set_use_dec,
 
413
        .dev            = NULL,
 
414
        .owner          = THIS_MODULE,
 
415
};
 
416
 
 
417
/*
 
418
 *
 
419
 */
 
420
static int gpio_remote_init(void)
 
421
{
 
422
        int ret;
 
423
        unsigned int mask;
 
424
 
 
425
        /* "normalize" gpio_mask
 
426
         * this means shift it right until first bit is set
 
427
         */
 
428
        while (!(gpio_mask & 1u)) {
 
429
                gpio_pre_shift++;
 
430
                gpio_mask >>= 1;
 
431
        }
 
432
 
 
433
        if (code_length)
 
434
                driver.code_length = code_length;
 
435
        else {
 
436
                /* calculate scan code length in bits if needed */
 
437
                driver.code_length = 1;
 
438
                mask = gpio_mask >> 1;
 
439
                while (mask) {
 
440
                        if (mask & 1u)
 
441
                                driver.code_length++;
 
442
                        mask >>= 1;
 
443
                }
 
444
        }
 
445
 
 
446
        code_bytes = (driver.code_length/8) + (driver.code_length % 8 ? 1 : 0);
 
447
        if (MAX_BYTES < code_bytes) {
 
448
                printk(LOGHEAD "scan code too long (%d bytes)\n",
 
449
                        minor, code_bytes);
 
450
                return -EBADRQC;
 
451
        }
 
452
 
 
453
        if (gpio_enable) {
 
454
                if (bttv_gpio_enable(card, gpio_enable, gpio_enable)) {
 
455
                        printk(LOGHEAD "gpio_enable failure\n", minor);
 
456
                        return -EIO;
 
457
                }
 
458
        }
 
459
 
 
460
 
 
461
        /* translate ms to jiffies */
 
462
        soft_gap = (soft_gap*HZ) / 1000;
 
463
 
 
464
        driver.minor = minor;
 
465
        driver.sample_rate = sample_rate;
 
466
 
 
467
        ret = lirc_register_driver(&driver);
 
468
 
 
469
        if (0 > ret) {
 
470
                printk(LOGHEAD "device registration failed with %d\n",
 
471
                        minor, ret);
 
472
                return ret;
 
473
        }
 
474
 
 
475
        minor = ret;
 
476
        printk(LOGHEAD "driver registered\n", minor);
 
477
 
 
478
        return 0;
 
479
}
 
480
 
 
481
#ifdef MODULE
 
482
/*
 
483
 *
 
484
 */
 
485
int init_module(void)
 
486
{
 
487
        int type, cardid, card_type;
 
488
 
 
489
        if (MAX_IRCTL_DEVICES < minor) {
 
490
                printk(KERN_INFO "lirc_gpio: parameter minor (%d) "
 
491
                       "must be less than %d!\n",
 
492
                       minor, MAX_IRCTL_DEVICES - 1);
 
493
                return -EBADRQC;
 
494
        }
 
495
 
 
496
        /* if gpio_mask not zero then use module parameters
 
497
         * instead of autodetecting TV card
 
498
         */
 
499
        if (gpio_mask) {
 
500
                if (sample_rate != 0 &&
 
501
                    (2 > sample_rate || HZ < sample_rate)) {
 
502
                        printk(LOGHEAD "parameter sample_rate "
 
503
                               "must be between 2 and %d!\n", minor, HZ);
 
504
                        return -EBADRQC;
 
505
                }
 
506
 
 
507
                if (sample_rate != 0 && soft_gap &&
 
508
                    ((2000/sample_rate) > soft_gap || 1000 < soft_gap)) {
 
509
                        printk(LOGHEAD "parameter soft_gap "
 
510
                               "must be between %d and 1000!\n",
 
511
                               minor, 2000/sample_rate);
 
512
                        return -EBADRQC;
 
513
                }
 
514
        } else {
 
515
                if (bttv_get_cardinfo(card, &type, &cardid) == -1) {
 
516
                        printk(LOGHEAD "could not get card type\n", minor);
 
517
                        return -EBADRQC;
 
518
                }
 
519
                printk(LOGHEAD "card type 0x%x, id 0x%x\n", minor,
 
520
                       type, cardid);
 
521
 
 
522
                if (type == BTTV_BOARD_UNKNOWN) {
 
523
                        printk(LOGHEAD "cannot detect TV card nr %d!\n",
 
524
                               minor, card);
 
525
                        return -EBADRQC;
 
526
                }
 
527
                for (card_type = 1;
 
528
                     card_type < sizeof(rcv_infos)/sizeof(struct rcv_info);
 
529
                     card_type++) {
 
530
                        if (rcv_infos[card_type].bttv_id == type &&
 
531
                            (rcv_infos[card_type].card_id == 0 ||
 
532
                             rcv_infos[card_type].card_id == cardid)) {
 
533
                                bttv_id = rcv_infos[card_type].bttv_id;
 
534
                                gpio_mask = rcv_infos[card_type].gpio_mask;
 
535
                                gpio_enable = rcv_infos[card_type].gpio_enable;
 
536
                                gpio_lock_mask =
 
537
                                        rcv_infos[card_type].gpio_lock_mask;
 
538
                                gpio_xor_mask =
 
539
                                        rcv_infos[card_type].gpio_xor_mask;
 
540
                                soft_gap = rcv_infos[card_type].soft_gap;
 
541
                                sample_rate = rcv_infos[card_type].sample_rate;
 
542
                                code_length = rcv_infos[card_type].code_length;
 
543
                                break;
 
544
                        }
 
545
                }
 
546
                if (type == BTTV_BOARD_AVPHONE98 && cardid == 0x00011461)
 
547
                        bttv_id = BTTV_BOARD_AVERMEDIA98;
 
548
 
 
549
                if (type == BTTV_BOARD_AVERMEDIA98 && cardid == 0x00041461)
 
550
                        bttv_id = BTTV_BOARD_AVPHONE98;
 
551
 
 
552
                if (type == BTTV_BOARD_AVERMEDIA98 && cardid == 0x03001461)
 
553
                        bttv_id = BTTV_BOARD_AVPHONE98;
 
554
 
 
555
                if (type == BTTV_BOARD_AVERMEDIA98 && cardid == 0x00000000)
 
556
                        bttv_id = BTTV_BOARD_AVPHONE98;
 
557
 
 
558
                if (card_type == sizeof(rcv_infos)/sizeof(struct rcv_info)) {
 
559
                        printk(LOGHEAD "TV card type 0x%x not supported!\n",
 
560
                               minor, type);
 
561
                        return -EBADRQC;
 
562
                }
 
563
        }
 
564
 
 
565
        return gpio_remote_init();
 
566
}
 
567
 
 
568
/*
 
569
 *
 
570
 */
 
571
void cleanup_module(void)
 
572
{
 
573
        lirc_unregister_driver(minor);
 
574
 
 
575
        dprintk(LOGHEAD "module successfully unloaded\n", minor);
 
576
}
 
577
 
 
578
/* Dont try to use it as a static version !  */
 
579
MODULE_DESCRIPTION("Driver module for remote control (data "
 
580
                   "from bt848 GPIO port)");
 
581
MODULE_AUTHOR("Artur Lipowski");
 
582
MODULE_LICENSE("GPL");
 
583
 
 
584
module_param(minor, int, S_IRUGO);
 
585
MODULE_PARM_DESC(minor, "Preferred minor device number");
 
586
 
 
587
module_param(card, int, S_IRUGO);
 
588
MODULE_PARM_DESC(card, "TV card number to attach to");
 
589
 
 
590
module_param(gpio_mask, long, S_IRUGO);
 
591
MODULE_PARM_DESC(gpio_mask, "gpio_mask");
 
592
 
 
593
module_param(gpio_lock_mask, long, S_IRUGO);
 
594
MODULE_PARM_DESC(gpio_lock_mask, "gpio_lock_mask");
 
595
 
 
596
module_param(gpio_xor_mask, long, S_IRUGO);
 
597
MODULE_PARM_DESC(gpio_xor_mask, "gpio_xor_mask");
 
598
 
 
599
module_param(soft_gap, int, S_IRUGO);
 
600
MODULE_PARM_DESC(soft_gap, "Time between keypresses (in ms)");
 
601
 
 
602
module_param(sample_rate, int, S_IRUGO);
 
603
MODULE_PARM_DESC(sample_rate, "Sample rate (between 2 and HZ)");
 
604
 
 
605
module_param(bttv_id, int, S_IRUGO);
 
606
MODULE_PARM_DESC(bttv_id, "BTTV card type");
 
607
 
 
608
module_param(debug, bool, S_IRUGO | S_IWUSR);
 
609
MODULE_PARM_DESC(debug, "Enable debugging messages");
 
610
 
 
611
EXPORT_NO_SYMBOLS;
 
612
 
 
613
#endif /* MODULE */