Blame view

kernel/linux-rt-4.4.41/drivers/media/pci/cx23885/cx23885-ir.c 3.65 KB
5113f6f70   김현기   kernel add
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
  /*
   *  Driver for the Conexant CX23885/7/8 PCIe bridge
   *
   *  Infrared device support routines - non-input, non-vl42_subdev routines
   *
   *  Copyright (C) 2009  Andy Walls <awalls@md.metrocast.net>
   *
   *  This program is free software; you can redistribute it and/or
   *  modify it under the terms of the GNU General Public License
   *  as published by the Free Software Foundation; either version 2
   *  of the License, or (at your option) any later version.
   *
   *  This program is distributed in the hope that it will be useful,
   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   *  GNU General Public License for more details.
   */
  
  #include <media/v4l2-device.h>
  
  #include "cx23885.h"
  #include "cx23885-ir.h"
  #include "cx23885-input.h"
  
  #define CX23885_IR_RX_FIFO_SERVICE_REQ		0
  #define CX23885_IR_RX_END_OF_RX_DETECTED	1
  #define CX23885_IR_RX_HW_FIFO_OVERRUN		2
  #define CX23885_IR_RX_SW_FIFO_OVERRUN		3
  
  #define CX23885_IR_TX_FIFO_SERVICE_REQ		0
  
  
  void cx23885_ir_rx_work_handler(struct work_struct *work)
  {
  	struct cx23885_dev *dev =
  			     container_of(work, struct cx23885_dev, ir_rx_work);
  	u32 events = 0;
  	unsigned long *notifications = &dev->ir_rx_notifications;
  
  	if (test_and_clear_bit(CX23885_IR_RX_SW_FIFO_OVERRUN, notifications))
  		events |= V4L2_SUBDEV_IR_RX_SW_FIFO_OVERRUN;
  	if (test_and_clear_bit(CX23885_IR_RX_HW_FIFO_OVERRUN, notifications))
  		events |= V4L2_SUBDEV_IR_RX_HW_FIFO_OVERRUN;
  	if (test_and_clear_bit(CX23885_IR_RX_END_OF_RX_DETECTED, notifications))
  		events |= V4L2_SUBDEV_IR_RX_END_OF_RX_DETECTED;
  	if (test_and_clear_bit(CX23885_IR_RX_FIFO_SERVICE_REQ, notifications))
  		events |= V4L2_SUBDEV_IR_RX_FIFO_SERVICE_REQ;
  
  	if (events == 0)
  		return;
  
  	if (dev->kernel_ir)
  		cx23885_input_rx_work_handler(dev, events);
  }
  
  void cx23885_ir_tx_work_handler(struct work_struct *work)
  {
  	struct cx23885_dev *dev =
  			     container_of(work, struct cx23885_dev, ir_tx_work);
  	u32 events = 0;
  	unsigned long *notifications = &dev->ir_tx_notifications;
  
  	if (test_and_clear_bit(CX23885_IR_TX_FIFO_SERVICE_REQ, notifications))
  		events |= V4L2_SUBDEV_IR_TX_FIFO_SERVICE_REQ;
  
  	if (events == 0)
  		return;
  
  }
  
  /* Possibly called in an IRQ context */
  void cx23885_ir_rx_v4l2_dev_notify(struct v4l2_subdev *sd, u32 events)
  {
  	struct cx23885_dev *dev = to_cx23885(sd->v4l2_dev);
  	unsigned long *notifications = &dev->ir_rx_notifications;
  
  	if (events & V4L2_SUBDEV_IR_RX_FIFO_SERVICE_REQ)
  		set_bit(CX23885_IR_RX_FIFO_SERVICE_REQ, notifications);
  	if (events & V4L2_SUBDEV_IR_RX_END_OF_RX_DETECTED)
  		set_bit(CX23885_IR_RX_END_OF_RX_DETECTED, notifications);
  	if (events & V4L2_SUBDEV_IR_RX_HW_FIFO_OVERRUN)
  		set_bit(CX23885_IR_RX_HW_FIFO_OVERRUN, notifications);
  	if (events & V4L2_SUBDEV_IR_RX_SW_FIFO_OVERRUN)
  		set_bit(CX23885_IR_RX_SW_FIFO_OVERRUN, notifications);
  
  	/*
  	 * For the integrated AV core, we are already in a workqueue context.
  	 * For the CX23888 integrated IR, we are in an interrupt context.
  	 */
  	if (sd == dev->sd_cx25840)
  		cx23885_ir_rx_work_handler(&dev->ir_rx_work);
  	else
  		schedule_work(&dev->ir_rx_work);
  }
  
  /* Possibly called in an IRQ context */
  void cx23885_ir_tx_v4l2_dev_notify(struct v4l2_subdev *sd, u32 events)
  {
  	struct cx23885_dev *dev = to_cx23885(sd->v4l2_dev);
  	unsigned long *notifications = &dev->ir_tx_notifications;
  
  	if (events & V4L2_SUBDEV_IR_TX_FIFO_SERVICE_REQ)
  		set_bit(CX23885_IR_TX_FIFO_SERVICE_REQ, notifications);
  
  	/*
  	 * For the integrated AV core, we are already in a workqueue context.
  	 * For the CX23888 integrated IR, we are in an interrupt context.
  	 */
  	if (sd == dev->sd_cx25840)
  		cx23885_ir_tx_work_handler(&dev->ir_tx_work);
  	else
  		schedule_work(&dev->ir_tx_work);
  }