Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 1 | /* |
| 2 | * Driver for the Conexant CX23885/7/8 PCIe bridge |
| 3 | * |
| 4 | * Infrared remote control input device |
| 5 | * |
| 6 | * Most of this file is |
| 7 | * |
Andy Walls | 6afdeaf | 2010-05-23 18:53:35 -0300 | [diff] [blame] | 8 | * Copyright (C) 2009 Andy Walls <awalls@md.metrocast.net> |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 9 | * |
| 10 | * However, the cx23885_input_{init,fini} functions contained herein are |
| 11 | * derived from Linux kernel files linux/media/video/.../...-input.c marked as: |
| 12 | * |
| 13 | * Copyright (C) 2008 <srinivasa.deevi at conexant dot com> |
| 14 | * Copyright (C) 2005 Ludovico Cavedon <cavedon@sssup.it> |
| 15 | * Markus Rechberger <mrechberger@gmail.com> |
| 16 | * Mauro Carvalho Chehab <mchehab@infradead.org> |
| 17 | * Sascha Sommer <saschasommer@freenet.de> |
| 18 | * Copyright (C) 2004, 2005 Chris Pascoe |
| 19 | * Copyright (C) 2003, 2004 Gerd Knorr |
| 20 | * Copyright (C) 2003 Pavel Machek |
| 21 | * |
| 22 | * This program is free software; you can redistribute it and/or |
| 23 | * modify it under the terms of the GNU General Public License |
| 24 | * as published by the Free Software Foundation; either version 2 |
| 25 | * of the License, or (at your option) any later version. |
| 26 | * |
| 27 | * This program is distributed in the hope that it will be useful, |
| 28 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 29 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 30 | * GNU General Public License for more details. |
| 31 | * |
| 32 | * You should have received a copy of the GNU General Public License |
| 33 | * along with this program; if not, write to the Free Software |
| 34 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 35 | * 02110-1301, USA. |
| 36 | */ |
| 37 | |
| 38 | #include <linux/input.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 39 | #include <linux/slab.h> |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 40 | #include <media/ir-core.h> |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 41 | #include <media/v4l2-subdev.h> |
| 42 | |
| 43 | #include "cx23885.h" |
| 44 | |
Mauro Carvalho Chehab | 727e625 | 2010-03-12 21:18:14 -0300 | [diff] [blame] | 45 | #define MODULE_NAME "cx23885" |
| 46 | |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 47 | static void cx23885_input_process_measurements(struct cx23885_dev *dev, |
| 48 | bool overrun) |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 49 | { |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 50 | struct cx23885_kernel_ir *kernel_ir = dev->kernel_ir; |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 51 | |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 52 | ssize_t num; |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 53 | int count, i; |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 54 | bool handle = false; |
Andy Walls | c02e0d1 | 2010-08-01 02:18:13 -0300 | [diff] [blame] | 55 | struct ir_raw_event ir_core_event[64]; |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 56 | |
| 57 | do { |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 58 | num = 0; |
Andy Walls | c02e0d1 | 2010-08-01 02:18:13 -0300 | [diff] [blame] | 59 | v4l2_subdev_call(dev->sd_ir, ir, rx_read, (u8 *) ir_core_event, |
| 60 | sizeof(ir_core_event), &num); |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 61 | |
Andy Walls | c02e0d1 | 2010-08-01 02:18:13 -0300 | [diff] [blame] | 62 | count = num / sizeof(struct ir_raw_event); |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 63 | |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 64 | for (i = 0; i < count; i++) { |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 65 | ir_raw_event_store(kernel_ir->inp_dev, |
Andy Walls | c02e0d1 | 2010-08-01 02:18:13 -0300 | [diff] [blame] | 66 | &ir_core_event[i]); |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 67 | handle = true; |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 68 | } |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 69 | } while (num != 0); |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 70 | |
| 71 | if (overrun) |
| 72 | ir_raw_event_reset(kernel_ir->inp_dev); |
| 73 | else if (handle) |
| 74 | ir_raw_event_handle(kernel_ir->inp_dev); |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | void cx23885_input_rx_work_handler(struct cx23885_dev *dev, u32 events) |
| 78 | { |
| 79 | struct v4l2_subdev_ir_parameters params; |
| 80 | int overrun, data_available; |
| 81 | |
| 82 | if (dev->sd_ir == NULL || events == 0) |
| 83 | return; |
| 84 | |
| 85 | switch (dev->board) { |
| 86 | case CX23885_BOARD_HAUPPAUGE_HVR1850: |
Michael Krufky | 7fec6fe | 2009-11-11 15:46:09 -0300 | [diff] [blame] | 87 | case CX23885_BOARD_HAUPPAUGE_HVR1290: |
Andy Walls | 98d109f | 2010-07-19 00:41:41 -0300 | [diff] [blame] | 88 | case CX23885_BOARD_TEVII_S470: |
| 89 | case CX23885_BOARD_HAUPPAUGE_HVR1250: |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 90 | /* |
Andy Walls | 98d109f | 2010-07-19 00:41:41 -0300 | [diff] [blame] | 91 | * The only boards we handle right now. However other boards |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 92 | * using the CX2388x integrated IR controller should be similar |
| 93 | */ |
| 94 | break; |
| 95 | default: |
| 96 | return; |
| 97 | } |
| 98 | |
| 99 | overrun = events & (V4L2_SUBDEV_IR_RX_SW_FIFO_OVERRUN | |
| 100 | V4L2_SUBDEV_IR_RX_HW_FIFO_OVERRUN); |
| 101 | |
| 102 | data_available = events & (V4L2_SUBDEV_IR_RX_END_OF_RX_DETECTED | |
| 103 | V4L2_SUBDEV_IR_RX_FIFO_SERVICE_REQ); |
| 104 | |
| 105 | if (overrun) { |
| 106 | /* If there was a FIFO overrun, stop the device */ |
| 107 | v4l2_subdev_call(dev->sd_ir, ir, rx_g_parameters, ¶ms); |
| 108 | params.enable = false; |
| 109 | /* Mitigate race with cx23885_input_ir_stop() */ |
| 110 | params.shutdown = atomic_read(&dev->ir_input_stopping); |
| 111 | v4l2_subdev_call(dev->sd_ir, ir, rx_s_parameters, ¶ms); |
| 112 | } |
| 113 | |
| 114 | if (data_available) |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 115 | cx23885_input_process_measurements(dev, overrun); |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 116 | |
| 117 | if (overrun) { |
| 118 | /* If there was a FIFO overrun, clear & restart the device */ |
| 119 | params.enable = true; |
| 120 | /* Mitigate race with cx23885_input_ir_stop() */ |
| 121 | params.shutdown = atomic_read(&dev->ir_input_stopping); |
| 122 | v4l2_subdev_call(dev->sd_ir, ir, rx_s_parameters, ¶ms); |
| 123 | } |
| 124 | } |
| 125 | |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 126 | static int cx23885_input_ir_start(struct cx23885_dev *dev) |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 127 | { |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 128 | struct v4l2_subdev_ir_parameters params; |
| 129 | |
| 130 | if (dev->sd_ir == NULL) |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 131 | return -ENODEV; |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 132 | |
| 133 | atomic_set(&dev->ir_input_stopping, 0); |
| 134 | |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 135 | v4l2_subdev_call(dev->sd_ir, ir, rx_g_parameters, ¶ms); |
| 136 | switch (dev->board) { |
| 137 | case CX23885_BOARD_HAUPPAUGE_HVR1850: |
Michael Krufky | 7fec6fe | 2009-11-11 15:46:09 -0300 | [diff] [blame] | 138 | case CX23885_BOARD_HAUPPAUGE_HVR1290: |
Andy Walls | 98d109f | 2010-07-19 00:41:41 -0300 | [diff] [blame] | 139 | case CX23885_BOARD_HAUPPAUGE_HVR1250: |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 140 | /* |
| 141 | * The IR controller on this board only returns pulse widths. |
| 142 | * Any other mode setting will fail to set up the device. |
| 143 | */ |
| 144 | params.mode = V4L2_SUBDEV_IR_MODE_PULSE_WIDTH; |
| 145 | params.enable = true; |
| 146 | params.interrupt_enable = true; |
| 147 | params.shutdown = false; |
| 148 | |
| 149 | /* Setup for baseband compatible with both RC-5 and RC-6A */ |
| 150 | params.modulation = false; |
| 151 | /* RC-5: 2,222,222 ns = 1/36 kHz * 32 cycles * 2 marks * 1.25*/ |
| 152 | /* RC-6A: 3,333,333 ns = 1/36 kHz * 16 cycles * 6 marks * 1.25*/ |
| 153 | params.max_pulse_width = 3333333; /* ns */ |
| 154 | /* RC-5: 666,667 ns = 1/36 kHz * 32 cycles * 1 mark * 0.75 */ |
| 155 | /* RC-6A: 333,333 ns = 1/36 kHz * 16 cycles * 1 mark * 0.75 */ |
| 156 | params.noise_filter_min_width = 333333; /* ns */ |
| 157 | /* |
| 158 | * This board has inverted receive sense: |
| 159 | * mark is received as low logic level; |
| 160 | * falling edges are detected as rising edges; etc. |
| 161 | */ |
Andy Walls | 5a28d9a | 2010-07-18 19:57:25 -0300 | [diff] [blame] | 162 | params.invert_level = true; |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 163 | break; |
Andy Walls | 98d109f | 2010-07-19 00:41:41 -0300 | [diff] [blame] | 164 | case CX23885_BOARD_TEVII_S470: |
| 165 | /* |
| 166 | * The IR controller on this board only returns pulse widths. |
| 167 | * Any other mode setting will fail to set up the device. |
| 168 | */ |
| 169 | params.mode = V4L2_SUBDEV_IR_MODE_PULSE_WIDTH; |
| 170 | params.enable = true; |
| 171 | params.interrupt_enable = true; |
| 172 | params.shutdown = false; |
| 173 | |
| 174 | /* Setup for a standard NEC protocol */ |
| 175 | params.carrier_freq = 37917; /* Hz, 455 kHz/12 for NEC */ |
| 176 | params.carrier_range_lower = 33000; /* Hz */ |
| 177 | params.carrier_range_upper = 43000; /* Hz */ |
| 178 | params.duty_cycle = 33; /* percent, 33 percent for NEC */ |
| 179 | |
| 180 | /* |
| 181 | * NEC max pulse width: (64/3)/(455 kHz/12) * 16 nec_units |
| 182 | * (64/3)/(455 kHz/12) * 16 nec_units * 1.375 = 12378022 ns |
| 183 | */ |
| 184 | params.max_pulse_width = 12378022; /* ns */ |
| 185 | |
| 186 | /* |
| 187 | * NEC noise filter min width: (64/3)/(455 kHz/12) * 1 nec_unit |
| 188 | * (64/3)/(455 kHz/12) * 1 nec_units * 0.625 = 351648 ns |
| 189 | */ |
| 190 | params.noise_filter_min_width = 351648; /* ns */ |
| 191 | |
| 192 | params.modulation = false; |
| 193 | params.invert_level = true; |
| 194 | break; |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 195 | } |
| 196 | v4l2_subdev_call(dev->sd_ir, ir, rx_s_parameters, ¶ms); |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 197 | return 0; |
| 198 | } |
| 199 | |
| 200 | static int cx23885_input_ir_open(void *priv) |
| 201 | { |
| 202 | struct cx23885_kernel_ir *kernel_ir = priv; |
| 203 | |
| 204 | if (kernel_ir->cx == NULL) |
| 205 | return -ENODEV; |
| 206 | |
| 207 | return cx23885_input_ir_start(kernel_ir->cx); |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | static void cx23885_input_ir_stop(struct cx23885_dev *dev) |
| 211 | { |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 212 | struct v4l2_subdev_ir_parameters params; |
| 213 | |
| 214 | if (dev->sd_ir == NULL) |
| 215 | return; |
| 216 | |
| 217 | /* |
| 218 | * Stop the sd_ir subdevice from generating notifications and |
| 219 | * scheduling work. |
| 220 | * It is shutdown this way in order to mitigate a race with |
| 221 | * cx23885_input_rx_work_handler() in the overrun case, which could |
| 222 | * re-enable the subdevice. |
| 223 | */ |
| 224 | atomic_set(&dev->ir_input_stopping, 1); |
| 225 | v4l2_subdev_call(dev->sd_ir, ir, rx_g_parameters, ¶ms); |
| 226 | while (params.shutdown == false) { |
| 227 | params.enable = false; |
| 228 | params.interrupt_enable = false; |
| 229 | params.shutdown = true; |
| 230 | v4l2_subdev_call(dev->sd_ir, ir, rx_s_parameters, ¶ms); |
| 231 | v4l2_subdev_call(dev->sd_ir, ir, rx_g_parameters, ¶ms); |
| 232 | } |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 233 | } |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 234 | |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 235 | static void cx23885_input_ir_close(void *priv) |
| 236 | { |
| 237 | struct cx23885_kernel_ir *kernel_ir = priv; |
| 238 | |
| 239 | if (kernel_ir->cx != NULL) |
| 240 | cx23885_input_ir_stop(kernel_ir->cx); |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | int cx23885_input_init(struct cx23885_dev *dev) |
| 244 | { |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 245 | struct cx23885_kernel_ir *kernel_ir; |
| 246 | struct input_dev *inp_dev; |
| 247 | struct ir_dev_props *props; |
| 248 | |
| 249 | char *rc_map; |
| 250 | enum rc_driver_type driver_type; |
| 251 | unsigned long allowed_protos; |
| 252 | |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 253 | int ret; |
| 254 | |
| 255 | /* |
| 256 | * If the IR device (hardware registers, chip, GPIO lines, etc.) isn't |
| 257 | * encapsulated in a v4l2_subdev, then I'm not going to deal with it. |
| 258 | */ |
| 259 | if (dev->sd_ir == NULL) |
| 260 | return -ENODEV; |
| 261 | |
| 262 | switch (dev->board) { |
| 263 | case CX23885_BOARD_HAUPPAUGE_HVR1850: |
Michael Krufky | 7fec6fe | 2009-11-11 15:46:09 -0300 | [diff] [blame] | 264 | case CX23885_BOARD_HAUPPAUGE_HVR1290: |
Andy Walls | 98d109f | 2010-07-19 00:41:41 -0300 | [diff] [blame] | 265 | case CX23885_BOARD_HAUPPAUGE_HVR1250: |
| 266 | /* Integrated CX2388[58] IR controller */ |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 267 | driver_type = RC_DRIVER_IR_RAW; |
| 268 | allowed_protos = IR_TYPE_ALL; |
| 269 | /* The grey Hauppauge RC-5 remote */ |
| 270 | rc_map = RC_MAP_RC5_HAUPPAUGE_NEW; |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 271 | break; |
Andy Walls | 98d109f | 2010-07-19 00:41:41 -0300 | [diff] [blame] | 272 | case CX23885_BOARD_TEVII_S470: |
| 273 | /* Integrated CX23885 IR controller */ |
| 274 | driver_type = RC_DRIVER_IR_RAW; |
| 275 | allowed_protos = IR_TYPE_ALL; |
| 276 | /* A guess at the remote */ |
| 277 | rc_map = RC_MAP_TEVII_NEC; |
| 278 | break; |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 279 | default: |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 280 | return -ENODEV; |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 281 | } |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 282 | |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 283 | /* cx23885 board instance kernel IR state */ |
| 284 | kernel_ir = kzalloc(sizeof(struct cx23885_kernel_ir), GFP_KERNEL); |
| 285 | if (kernel_ir == NULL) |
| 286 | return -ENOMEM; |
| 287 | |
| 288 | kernel_ir->cx = dev; |
| 289 | kernel_ir->name = kasprintf(GFP_KERNEL, "cx23885 IR (%s)", |
| 290 | cx23885_boards[dev->board].name); |
| 291 | kernel_ir->phys = kasprintf(GFP_KERNEL, "pci-%s/ir0", |
| 292 | pci_name(dev->pci)); |
| 293 | |
| 294 | /* input device */ |
| 295 | inp_dev = input_allocate_device(); |
| 296 | if (inp_dev == NULL) { |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 297 | ret = -ENOMEM; |
| 298 | goto err_out_free; |
| 299 | } |
| 300 | |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 301 | kernel_ir->inp_dev = inp_dev; |
| 302 | inp_dev->name = kernel_ir->name; |
| 303 | inp_dev->phys = kernel_ir->phys; |
| 304 | inp_dev->id.bustype = BUS_PCI; |
| 305 | inp_dev->id.version = 1; |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 306 | if (dev->pci->subsystem_vendor) { |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 307 | inp_dev->id.vendor = dev->pci->subsystem_vendor; |
| 308 | inp_dev->id.product = dev->pci->subsystem_device; |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 309 | } else { |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 310 | inp_dev->id.vendor = dev->pci->vendor; |
| 311 | inp_dev->id.product = dev->pci->device; |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 312 | } |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 313 | inp_dev->dev.parent = &dev->pci->dev; |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 314 | |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 315 | /* kernel ir device properties */ |
| 316 | props = &kernel_ir->props; |
| 317 | props->driver_type = driver_type; |
| 318 | props->allowed_protos = allowed_protos; |
| 319 | props->priv = kernel_ir; |
| 320 | props->open = cx23885_input_ir_open; |
| 321 | props->close = cx23885_input_ir_close; |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 322 | |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 323 | /* Go */ |
| 324 | dev->kernel_ir = kernel_ir; |
| 325 | ret = ir_input_register(inp_dev, rc_map, props, MODULE_NAME); |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 326 | if (ret) |
| 327 | goto err_out_stop; |
| 328 | |
| 329 | return 0; |
| 330 | |
| 331 | err_out_stop: |
| 332 | cx23885_input_ir_stop(dev); |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 333 | dev->kernel_ir = NULL; |
| 334 | /* TODO: double check clean-up of kernel_ir->inp_dev */ |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 335 | err_out_free: |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 336 | kfree(kernel_ir->phys); |
| 337 | kfree(kernel_ir->name); |
| 338 | kfree(kernel_ir); |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 339 | return ret; |
| 340 | } |
| 341 | |
| 342 | void cx23885_input_fini(struct cx23885_dev *dev) |
| 343 | { |
| 344 | /* Always stop the IR hardware from generating interrupts */ |
| 345 | cx23885_input_ir_stop(dev); |
| 346 | |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 347 | if (dev->kernel_ir == NULL) |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 348 | return; |
Andy Walls | 43c2407 | 2010-06-27 23:15:35 -0300 | [diff] [blame] | 349 | ir_input_unregister(dev->kernel_ir->inp_dev); |
| 350 | kfree(dev->kernel_ir->phys); |
| 351 | kfree(dev->kernel_ir->name); |
| 352 | kfree(dev->kernel_ir); |
| 353 | dev->kernel_ir = NULL; |
Andy Walls | dbda8f7 | 2009-09-27 20:55:41 -0300 | [diff] [blame] | 354 | } |