diff options
author | Andy Walls <awalls@radix.net> | 2009-09-27 18:51:50 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-12-05 15:40:20 -0500 |
commit | f59ad611acccd4057b8e685c7fd5532ab1a17f66 (patch) | |
tree | 9c48a478ddc9a9f69c64c9e42f3db1f202970b78 /drivers/media/video/cx23885/cx23885-ir.c | |
parent | 1a0b9d89c62ddf0aed12798686fe452e7e97de42 (diff) |
V4L/DVB (13098): cx23885: Add integrated IR subdevice interrupt and notification handling
Add integrated IR subdevice interrupt and notification handling. This is in
preparation of input keypress handling changes for the cx23885 module.
Signed-off-by: Andy Walls <awalls@radix.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/cx23885/cx23885-ir.c')
-rw-r--r-- | drivers/media/video/cx23885/cx23885-ir.c | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/drivers/media/video/cx23885/cx23885-ir.c b/drivers/media/video/cx23885/cx23885-ir.c new file mode 100644 index 000000000000..e84f90c75bf1 --- /dev/null +++ b/drivers/media/video/cx23885/cx23885-ir.c | |||
@@ -0,0 +1,97 @@ | |||
1 | /* | ||
2 | * Driver for the Conexant CX23885/7/8 PCIe bridge | ||
3 | * | ||
4 | * Infrared device support routines - non-input, non-vl42_subdev routines | ||
5 | * | ||
6 | * Copyright (C) 2009 Andy Walls <awalls@radix.net> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License | ||
10 | * as published by the Free Software Foundation; either version 2 | ||
11 | * of the License, or (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
21 | * 02110-1301, USA. | ||
22 | */ | ||
23 | |||
24 | #include <media/v4l2-device.h> | ||
25 | |||
26 | #include "cx23885.h" | ||
27 | |||
28 | #define CX23885_IR_RX_FIFO_SERVICE_REQ 0 | ||
29 | #define CX23885_IR_RX_END_OF_RX_DETECTED 1 | ||
30 | #define CX23885_IR_RX_HW_FIFO_OVERRUN 2 | ||
31 | #define CX23885_IR_RX_SW_FIFO_OVERRUN 3 | ||
32 | |||
33 | #define CX23885_IR_TX_FIFO_SERVICE_REQ 0 | ||
34 | |||
35 | |||
36 | void cx23885_ir_rx_work_handler(struct work_struct *work) | ||
37 | { | ||
38 | struct cx23885_dev *dev = | ||
39 | container_of(work, struct cx23885_dev, ir_rx_work); | ||
40 | u32 events = 0; | ||
41 | unsigned long *notifications = &dev->ir_rx_notifications; | ||
42 | |||
43 | if (test_and_clear_bit(CX23885_IR_RX_SW_FIFO_OVERRUN, notifications)) | ||
44 | events |= V4L2_SUBDEV_IR_RX_SW_FIFO_OVERRUN; | ||
45 | if (test_and_clear_bit(CX23885_IR_RX_HW_FIFO_OVERRUN, notifications)) | ||
46 | events |= V4L2_SUBDEV_IR_RX_HW_FIFO_OVERRUN; | ||
47 | if (test_and_clear_bit(CX23885_IR_RX_END_OF_RX_DETECTED, notifications)) | ||
48 | events |= V4L2_SUBDEV_IR_RX_END_OF_RX_DETECTED; | ||
49 | if (test_and_clear_bit(CX23885_IR_RX_FIFO_SERVICE_REQ, notifications)) | ||
50 | events |= V4L2_SUBDEV_IR_RX_FIFO_SERVICE_REQ; | ||
51 | |||
52 | if (events == 0) | ||
53 | return; | ||
54 | } | ||
55 | |||
56 | void cx23885_ir_tx_work_handler(struct work_struct *work) | ||
57 | { | ||
58 | struct cx23885_dev *dev = | ||
59 | container_of(work, struct cx23885_dev, ir_tx_work); | ||
60 | u32 events = 0; | ||
61 | unsigned long *notifications = &dev->ir_tx_notifications; | ||
62 | |||
63 | if (test_and_clear_bit(CX23885_IR_TX_FIFO_SERVICE_REQ, notifications)) | ||
64 | events |= V4L2_SUBDEV_IR_TX_FIFO_SERVICE_REQ; | ||
65 | |||
66 | if (events == 0) | ||
67 | return; | ||
68 | |||
69 | } | ||
70 | |||
71 | /* Called in an IRQ context */ | ||
72 | void cx23885_ir_rx_v4l2_dev_notify(struct v4l2_subdev *sd, u32 events) | ||
73 | { | ||
74 | struct cx23885_dev *dev = to_cx23885(sd->v4l2_dev); | ||
75 | unsigned long *notifications = &dev->ir_rx_notifications; | ||
76 | |||
77 | if (events & V4L2_SUBDEV_IR_RX_FIFO_SERVICE_REQ) | ||
78 | set_bit(CX23885_IR_RX_FIFO_SERVICE_REQ, notifications); | ||
79 | if (events & V4L2_SUBDEV_IR_RX_END_OF_RX_DETECTED) | ||
80 | set_bit(CX23885_IR_RX_END_OF_RX_DETECTED, notifications); | ||
81 | if (events & V4L2_SUBDEV_IR_RX_HW_FIFO_OVERRUN) | ||
82 | set_bit(CX23885_IR_RX_HW_FIFO_OVERRUN, notifications); | ||
83 | if (events & V4L2_SUBDEV_IR_RX_SW_FIFO_OVERRUN) | ||
84 | set_bit(CX23885_IR_RX_SW_FIFO_OVERRUN, notifications); | ||
85 | schedule_work(&dev->ir_rx_work); | ||
86 | } | ||
87 | |||
88 | /* Called in an IRQ context */ | ||
89 | void cx23885_ir_tx_v4l2_dev_notify(struct v4l2_subdev *sd, u32 events) | ||
90 | { | ||
91 | struct cx23885_dev *dev = to_cx23885(sd->v4l2_dev); | ||
92 | unsigned long *notifications = &dev->ir_tx_notifications; | ||
93 | |||
94 | if (events & V4L2_SUBDEV_IR_TX_FIFO_SERVICE_REQ) | ||
95 | set_bit(CX23885_IR_TX_FIFO_SERVICE_REQ, notifications); | ||
96 | schedule_work(&dev->ir_tx_work); | ||
97 | } | ||