30
30
* Forum: Art103 <r_tay@hotmail.com>
34
37
#include <linux/version.h>
35
38
#include <linux/module.h>
41
39
#include <linux/autoconf.h>
44
40
#include <linux/sched.h>
45
41
#include <linux/errno.h>
46
42
#include <linux/signal.h>
48
44
#include <linux/interrupt.h>
49
45
#include <linux/ioport.h>
50
46
#include <linux/kernel.h>
51
#include <linux/major.h>
52
47
#include <linux/serial_reg.h>
53
48
#include <linux/time.h>
54
49
#include <linux/string.h>
145
138
static int lirc_ioctl(struct inode *node, struct file *filep,
146
139
unsigned int cmd, unsigned long arg);
147
140
static void add_read_queue(int flag, unsigned long val);
149
141
static int init_chrdev(void);
150
142
static void drop_chrdev(void);
153
144
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
154
145
static irqreturn_t it87_interrupt(int irq, void *dev_id,
162
153
static void terminate_send(unsigned long len);
163
154
static int init_hardware(void);
164
155
static void drop_hardware(void);
166
157
static int init_port(void);
167
158
static void drop_port(void);
168
int init_module(void);
169
void cleanup_module(void);
172
161
/* SECTION: Communication with user-space */
334
323
newval = val & PULSE_MASK;
336
/* statistically pulses are ~TIME_CONST/2 too long: we could
337
maybe make this more exactly but this is good enough */
326
* statistically, pulses are ~TIME_CONST/2 too long. we could
327
* maybe make this more exact, but this is good enough
340
331
if (newval > TIME_CONST / 2)
367
359
static int set_use_inc(void *data)
369
#if WE_DONT_USE_LOCAL_OPEN_CLOSE
375
364
static void set_use_dec(void *data)
377
#if WE_DONT_USE_LOCAL_OPEN_CLOSE
381
static struct lirc_plugin plugin = {
368
static struct lirc_driver driver = {
382
369
.name = LIRC_DRIVER_NAME,
384
371
.code_length = 1,
385
372
.sample_rate = 0,
387
374
.add_to_buf = NULL,
375
#ifndef LIRC_REMOVE_DURING_EXPORT
388
376
.get_queue = NULL,
389
378
.set_use_inc = set_use_inc,
390
379
.set_use_dec = set_use_dec,
391
380
.fops = &lirc_fops,
435
422
spin_lock_irqsave(&timer_lock, flags);
437
424
if (digimatrix) {
438
/* We have timed out.
439
Disable the RX mechanism.
425
/* We have timed out. Disable the RX mechanism. */
442
427
outb((inb(io + IT87_CIR_RCR) & ~IT87_CIR_RCR_RXEN) |
443
428
IT87_CIR_RCR_RXACT, io + IT87_CIR_RCR);
452
437
io+IT87_CIR_TCR1);
455
/* if last received signal was a pulse, but receiving
456
stopped within the 9 bit frame, we need to finish
457
this pulse and simulate a signal change to from
458
pulse to space. Otherwise upper layers will receive
459
two sequences next time. */
441
* if last received signal was a pulse, but receiving stopped
442
* within the 9 bit frame, we need to finish this pulse and
443
* simulate a signal change to from pulse to space. Otherwise
444
* upper layers will receive two sequences next time.
461
447
if (last_value) {
462
448
unsigned long pulse_end;
561
549
dprintk("t %lu , d %d\n",
562
550
deltintrtv, (int)data);
564
/* if nothing came in last 2 cycles,
553
* if nothing came in last 2 cycles,
566
556
if (deltintrtv > TIME_CONST * 2) {
567
557
if (last_value) {
568
558
dprintk("GAP\n");
583
573
if (data ^ last_value) {
584
/* deltintrtv > 2*TIME_CONST,
586
/* the other case is timeout */
575
* deltintrtv > 2*TIME_CONST,
576
* remember ? the other case is
587
579
add_read_queue(last_value,
588
580
deltv-TIME_CONST);
589
581
last_value = data;
636
630
static unsigned char byte_out;
637
631
unsigned long hw_flags;
639
dprintk("%s: len=%ld, sb=%d\n", __FUNCTION__, len, send_byte);
633
dprintk("%s: len=%ld, sb=%d\n", __func__, len, send_byte);
641
635
time_left = (long)len - (long)count * (long)stime;
642
636
count += ((2 * time_left) / stime);
711
701
while (last == it87_send_counter)
713
703
/* wait until all data sent */
714
while ((inb(io + IT87_CIR_TSR) & IT87_CIR_TSR_TXFBC) != 0);
715
/* then reenable receiver */
704
while ((inb(io + IT87_CIR_TSR) & IT87_CIR_TSR_TXFBC) != 0)
706
/* then re-enable receiver */
716
707
spin_lock_irqsave(&hardware_lock, flags);
717
708
it87_RXEN_mask = IT87_CIR_RCR_RXEN;
718
709
outb(inb(io + IT87_CIR_RCR) | IT87_CIR_RCR_RXEN,
749
740
outb(inb(io + IT87_CIR_TCR1) | 0x00,
750
741
io + IT87_CIR_TCR1);
752
/* TX: it87_freq (36kHz),
753
'reserved' sensitivity setting (0x00) */
744
* TX: it87_freq (36kHz), 'reserved' sensitivity
754
747
outb(((it87_freq - IT87_CIR_FREQ_MIN) << 3) | 0x00,
755
748
io + IT87_CIR_TCR2);
757
/* TX: 38kHz, 13,3us (pulse-width */
750
/* TX: 38kHz, 13,3us (pulse-width) */
758
751
outb(((it87_freq - IT87_CIR_FREQ_MIN) << 3) | 0x06,
759
752
io + IT87_CIR_TCR2);
913
906
static void drop_port(void)
916
unsigned char init_bytes[4] = {IT87_INIT};
909
unsigned char init_bytes[4] = IT87_INIT;
918
911
/ * Enter MB PnP Mode * /
919
912
outb(init_bytes[0], IT87_ADRPORT);
974
965
printk(KERN_INFO LIRC_DRIVER_NAME ": Uninstalled.\n");
968
module_init(lirc_it87_init);
969
module_exit(lirc_it87_exit);
977
971
MODULE_DESCRIPTION("LIRC driver for ITE IT8712/IT8705 CIR port");
978
972
MODULE_AUTHOR("Hans-G�nter L�tke Uphues");
979
973
MODULE_LICENSE("GPL");
981
module_param(io, int, 0444);
975
module_param(io, int, S_IRUGO);
982
976
MODULE_PARM_DESC(io, "I/O base address (default: 0x310)");
984
module_param(irq, int, 0444);
978
module_param(irq, int, S_IRUGO);
985
979
#ifdef LIRC_IT87_DIGIMATRIX
986
980
MODULE_PARM_DESC(irq, "Interrupt (1,3-12) (default: 9)");
988
982
MODULE_PARM_DESC(irq, "Interrupt (1,3-12) (default: 7)");
991
module_param(it87_enable_demodulator, bool, 0444);
985
module_param(it87_enable_demodulator, bool, S_IRUGO);
992
986
MODULE_PARM_DESC(it87_enable_demodulator,
993
987
"Receiver demodulator enable/disable (1/0), default: 0");
995
module_param(debug, bool, 0644);
989
module_param(debug, bool, S_IRUGO | S_IWUSR);
996
990
MODULE_PARM_DESC(debug, "Enable debugging messages");
998
module_param(digimatrix, bool, 0644);
992
module_param(digimatrix, bool, S_IRUGO | S_IWUSR);
999
993
#ifdef LIRC_IT87_DIGIMATRIX
1000
994
MODULE_PARM_DESC(digimatrix,
1001
995
"Asus Digimatrix it87 compat. enable/disable (1/0), default: 1");
1008
module_param(it87_freq, int, 0444);
1002
module_param(it87_freq, int, S_IRUGO);
1009
1003
#ifdef LIRC_IT87_DIGIMATRIX
1010
1004
MODULE_PARM_DESC(it87_freq,
1011
1005
"Carrier demodulator frequency (kHz), (default: 36)");
1013
1007
MODULE_PARM_DESC(it87_freq,
1014
1008
"Carrier demodulator frequency (kHz), (default: 38)");
1017
1010
EXPORT_NO_SYMBOLS;
1023
* Overrides for Emacs so that we follow Linus's tabbing style.
1024
* ---------------------------------------------------------------------------