2009-09-28 07:55:41 +08:00
|
|
|
/*
|
|
|
|
* Driver for the Conexant CX23885/7/8 PCIe bridge
|
|
|
|
*
|
|
|
|
* Infrared remote control input device
|
|
|
|
*
|
|
|
|
* Most of this file is
|
|
|
|
*
|
2010-05-24 05:53:35 +08:00
|
|
|
* Copyright (C) 2009 Andy Walls <awalls@md.metrocast.net>
|
2009-09-28 07:55:41 +08:00
|
|
|
*
|
|
|
|
* However, the cx23885_input_{init,fini} functions contained herein are
|
|
|
|
* derived from Linux kernel files linux/media/video/.../...-input.c marked as:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 <srinivasa.deevi at conexant dot com>
|
|
|
|
* Copyright (C) 2005 Ludovico Cavedon <cavedon@sssup.it>
|
|
|
|
* Markus Rechberger <mrechberger@gmail.com>
|
|
|
|
* Mauro Carvalho Chehab <mchehab@infradead.org>
|
|
|
|
* Sascha Sommer <saschasommer@freenet.de>
|
|
|
|
* Copyright (C) 2004, 2005 Chris Pascoe
|
|
|
|
* Copyright (C) 2003, 2004 Gerd Knorr
|
|
|
|
* Copyright (C) 2003 Pavel Machek
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2016-11-13 19:46:11 +08:00
|
|
|
#include "cx23885.h"
|
|
|
|
#include "cx23885-input.h"
|
|
|
|
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2010-11-18 00:28:38 +08:00
|
|
|
#include <media/rc-core.h>
|
2009-09-28 07:55:41 +08:00
|
|
|
#include <media/v4l2-subdev.h>
|
|
|
|
|
2010-03-13 08:18:14 +08:00
|
|
|
#define MODULE_NAME "cx23885"
|
|
|
|
|
2010-06-28 10:15:35 +08:00
|
|
|
static void cx23885_input_process_measurements(struct cx23885_dev *dev,
|
|
|
|
bool overrun)
|
2009-09-28 07:55:41 +08:00
|
|
|
{
|
2010-06-28 10:15:35 +08:00
|
|
|
struct cx23885_kernel_ir *kernel_ir = dev->kernel_ir;
|
2009-09-28 07:55:41 +08:00
|
|
|
|
2010-06-28 10:15:35 +08:00
|
|
|
ssize_t num;
|
2009-09-28 07:55:41 +08:00
|
|
|
int count, i;
|
2010-06-28 10:15:35 +08:00
|
|
|
bool handle = false;
|
2010-08-01 13:18:13 +08:00
|
|
|
struct ir_raw_event ir_core_event[64];
|
2009-09-28 07:55:41 +08:00
|
|
|
|
|
|
|
do {
|
2010-06-28 10:15:35 +08:00
|
|
|
num = 0;
|
2010-08-01 13:18:13 +08:00
|
|
|
v4l2_subdev_call(dev->sd_ir, ir, rx_read, (u8 *) ir_core_event,
|
|
|
|
sizeof(ir_core_event), &num);
|
2009-09-28 07:55:41 +08:00
|
|
|
|
2010-08-01 13:18:13 +08:00
|
|
|
count = num / sizeof(struct ir_raw_event);
|
2009-09-28 07:55:41 +08:00
|
|
|
|
2010-06-28 10:15:35 +08:00
|
|
|
for (i = 0; i < count; i++) {
|
2010-10-30 03:08:23 +08:00
|
|
|
ir_raw_event_store(kernel_ir->rc,
|
2010-08-01 13:18:13 +08:00
|
|
|
&ir_core_event[i]);
|
2010-06-28 10:15:35 +08:00
|
|
|
handle = true;
|
2009-09-28 07:55:41 +08:00
|
|
|
}
|
|
|
|
} while (num != 0);
|
2010-06-28 10:15:35 +08:00
|
|
|
|
|
|
|
if (overrun)
|
2010-10-30 03:08:23 +08:00
|
|
|
ir_raw_event_reset(kernel_ir->rc);
|
2010-06-28 10:15:35 +08:00
|
|
|
else if (handle)
|
2010-10-30 03:08:23 +08:00
|
|
|
ir_raw_event_handle(kernel_ir->rc);
|
2009-09-28 07:55:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void cx23885_input_rx_work_handler(struct cx23885_dev *dev, u32 events)
|
|
|
|
{
|
|
|
|
struct v4l2_subdev_ir_parameters params;
|
|
|
|
int overrun, data_available;
|
|
|
|
|
|
|
|
if (dev->sd_ir == NULL || events == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (dev->board) {
|
2011-06-09 08:24:25 +08:00
|
|
|
case CX23885_BOARD_HAUPPAUGE_HVR1270:
|
2009-09-28 07:55:41 +08:00
|
|
|
case CX23885_BOARD_HAUPPAUGE_HVR1850:
|
2009-11-12 02:46:09 +08:00
|
|
|
case CX23885_BOARD_HAUPPAUGE_HVR1290:
|
2012-07-28 20:01:38 +08:00
|
|
|
case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL:
|
2010-07-19 11:41:41 +08:00
|
|
|
case CX23885_BOARD_TEVII_S470:
|
|
|
|
case CX23885_BOARD_HAUPPAUGE_HVR1250:
|
2012-11-09 02:50:25 +08:00
|
|
|
case CX23885_BOARD_MYGICA_X8507:
|
2013-10-02 09:11:35 +08:00
|
|
|
case CX23885_BOARD_TBS_6980:
|
|
|
|
case CX23885_BOARD_TBS_6981:
|
2014-09-29 22:17:36 +08:00
|
|
|
case CX23885_BOARD_DVBSKY_T9580:
|
2014-10-23 18:02:16 +08:00
|
|
|
case CX23885_BOARD_DVBSKY_T980C:
|
|
|
|
case CX23885_BOARD_DVBSKY_S950C:
|
2014-10-31 04:48:27 +08:00
|
|
|
case CX23885_BOARD_TT_CT2_4500_CI:
|
2014-11-05 22:58:07 +08:00
|
|
|
case CX23885_BOARD_DVBSKY_S950:
|
2014-11-05 22:58:38 +08:00
|
|
|
case CX23885_BOARD_DVBSKY_S952:
|
2014-11-12 12:23:12 +08:00
|
|
|
case CX23885_BOARD_DVBSKY_T982:
|
2009-09-28 07:55:41 +08:00
|
|
|
/*
|
2010-07-19 11:41:41 +08:00
|
|
|
* The only boards we handle right now. However other boards
|
2009-09-28 07:55:41 +08:00
|
|
|
* using the CX2388x integrated IR controller should be similar
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
overrun = events & (V4L2_SUBDEV_IR_RX_SW_FIFO_OVERRUN |
|
|
|
|
V4L2_SUBDEV_IR_RX_HW_FIFO_OVERRUN);
|
|
|
|
|
|
|
|
data_available = events & (V4L2_SUBDEV_IR_RX_END_OF_RX_DETECTED |
|
|
|
|
V4L2_SUBDEV_IR_RX_FIFO_SERVICE_REQ);
|
|
|
|
|
|
|
|
if (overrun) {
|
|
|
|
/* If there was a FIFO overrun, stop the device */
|
|
|
|
v4l2_subdev_call(dev->sd_ir, ir, rx_g_parameters, ¶ms);
|
|
|
|
params.enable = false;
|
|
|
|
/* Mitigate race with cx23885_input_ir_stop() */
|
|
|
|
params.shutdown = atomic_read(&dev->ir_input_stopping);
|
|
|
|
v4l2_subdev_call(dev->sd_ir, ir, rx_s_parameters, ¶ms);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data_available)
|
2010-06-28 10:15:35 +08:00
|
|
|
cx23885_input_process_measurements(dev, overrun);
|
2009-09-28 07:55:41 +08:00
|
|
|
|
|
|
|
if (overrun) {
|
|
|
|
/* If there was a FIFO overrun, clear & restart the device */
|
|
|
|
params.enable = true;
|
|
|
|
/* Mitigate race with cx23885_input_ir_stop() */
|
|
|
|
params.shutdown = atomic_read(&dev->ir_input_stopping);
|
|
|
|
v4l2_subdev_call(dev->sd_ir, ir, rx_s_parameters, ¶ms);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-28 10:15:35 +08:00
|
|
|
static int cx23885_input_ir_start(struct cx23885_dev *dev)
|
2009-09-28 07:55:41 +08:00
|
|
|
{
|
|
|
|
struct v4l2_subdev_ir_parameters params;
|
|
|
|
|
|
|
|
if (dev->sd_ir == NULL)
|
2010-06-28 10:15:35 +08:00
|
|
|
return -ENODEV;
|
2009-09-28 07:55:41 +08:00
|
|
|
|
|
|
|
atomic_set(&dev->ir_input_stopping, 0);
|
|
|
|
|
|
|
|
v4l2_subdev_call(dev->sd_ir, ir, rx_g_parameters, ¶ms);
|
|
|
|
switch (dev->board) {
|
2011-06-09 08:24:25 +08:00
|
|
|
case CX23885_BOARD_HAUPPAUGE_HVR1270:
|
2009-09-28 07:55:41 +08:00
|
|
|
case CX23885_BOARD_HAUPPAUGE_HVR1850:
|
2009-11-12 02:46:09 +08:00
|
|
|
case CX23885_BOARD_HAUPPAUGE_HVR1290:
|
2010-07-19 11:41:41 +08:00
|
|
|
case CX23885_BOARD_HAUPPAUGE_HVR1250:
|
2012-11-09 02:50:25 +08:00
|
|
|
case CX23885_BOARD_MYGICA_X8507:
|
2014-09-29 22:17:36 +08:00
|
|
|
case CX23885_BOARD_DVBSKY_T9580:
|
2014-10-23 18:02:16 +08:00
|
|
|
case CX23885_BOARD_DVBSKY_T980C:
|
|
|
|
case CX23885_BOARD_DVBSKY_S950C:
|
2014-10-31 04:48:27 +08:00
|
|
|
case CX23885_BOARD_TT_CT2_4500_CI:
|
2014-11-05 22:58:07 +08:00
|
|
|
case CX23885_BOARD_DVBSKY_S950:
|
2014-11-05 22:58:38 +08:00
|
|
|
case CX23885_BOARD_DVBSKY_S952:
|
2014-11-12 12:23:12 +08:00
|
|
|
case CX23885_BOARD_DVBSKY_T982:
|
2009-09-28 07:55:41 +08:00
|
|
|
/*
|
|
|
|
* The IR controller on this board only returns pulse widths.
|
|
|
|
* Any other mode setting will fail to set up the device.
|
|
|
|
*/
|
|
|
|
params.mode = V4L2_SUBDEV_IR_MODE_PULSE_WIDTH;
|
|
|
|
params.enable = true;
|
|
|
|
params.interrupt_enable = true;
|
|
|
|
params.shutdown = false;
|
|
|
|
|
|
|
|
/* Setup for baseband compatible with both RC-5 and RC-6A */
|
|
|
|
params.modulation = false;
|
|
|
|
/* RC-5: 2,222,222 ns = 1/36 kHz * 32 cycles * 2 marks * 1.25*/
|
|
|
|
/* RC-6A: 3,333,333 ns = 1/36 kHz * 16 cycles * 6 marks * 1.25*/
|
|
|
|
params.max_pulse_width = 3333333; /* ns */
|
|
|
|
/* RC-5: 666,667 ns = 1/36 kHz * 32 cycles * 1 mark * 0.75 */
|
|
|
|
/* RC-6A: 333,333 ns = 1/36 kHz * 16 cycles * 1 mark * 0.75 */
|
|
|
|
params.noise_filter_min_width = 333333; /* ns */
|
|
|
|
/*
|
|
|
|
* This board has inverted receive sense:
|
|
|
|
* mark is received as low logic level;
|
|
|
|
* falling edges are detected as rising edges; etc.
|
|
|
|
*/
|
2010-07-19 06:57:25 +08:00
|
|
|
params.invert_level = true;
|
2009-09-28 07:55:41 +08:00
|
|
|
break;
|
2012-07-28 20:01:38 +08:00
|
|
|
case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL:
|
2010-07-19 11:41:41 +08:00
|
|
|
case CX23885_BOARD_TEVII_S470:
|
2013-10-02 09:11:35 +08:00
|
|
|
case CX23885_BOARD_TBS_6980:
|
|
|
|
case CX23885_BOARD_TBS_6981:
|
2010-07-19 11:41:41 +08:00
|
|
|
/*
|
|
|
|
* The IR controller on this board only returns pulse widths.
|
|
|
|
* Any other mode setting will fail to set up the device.
|
|
|
|
*/
|
|
|
|
params.mode = V4L2_SUBDEV_IR_MODE_PULSE_WIDTH;
|
|
|
|
params.enable = true;
|
|
|
|
params.interrupt_enable = true;
|
|
|
|
params.shutdown = false;
|
|
|
|
|
|
|
|
/* Setup for a standard NEC protocol */
|
|
|
|
params.carrier_freq = 37917; /* Hz, 455 kHz/12 for NEC */
|
|
|
|
params.carrier_range_lower = 33000; /* Hz */
|
|
|
|
params.carrier_range_upper = 43000; /* Hz */
|
|
|
|
params.duty_cycle = 33; /* percent, 33 percent for NEC */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NEC max pulse width: (64/3)/(455 kHz/12) * 16 nec_units
|
|
|
|
* (64/3)/(455 kHz/12) * 16 nec_units * 1.375 = 12378022 ns
|
|
|
|
*/
|
|
|
|
params.max_pulse_width = 12378022; /* ns */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NEC noise filter min width: (64/3)/(455 kHz/12) * 1 nec_unit
|
|
|
|
* (64/3)/(455 kHz/12) * 1 nec_units * 0.625 = 351648 ns
|
|
|
|
*/
|
|
|
|
params.noise_filter_min_width = 351648; /* ns */
|
|
|
|
|
|
|
|
params.modulation = false;
|
|
|
|
params.invert_level = true;
|
|
|
|
break;
|
2009-09-28 07:55:41 +08:00
|
|
|
}
|
|
|
|
v4l2_subdev_call(dev->sd_ir, ir, rx_s_parameters, ¶ms);
|
2010-06-28 10:15:35 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-10-30 03:08:23 +08:00
|
|
|
static int cx23885_input_ir_open(struct rc_dev *rc)
|
2010-06-28 10:15:35 +08:00
|
|
|
{
|
2010-10-30 03:08:23 +08:00
|
|
|
struct cx23885_kernel_ir *kernel_ir = rc->priv;
|
2010-06-28 10:15:35 +08:00
|
|
|
|
|
|
|
if (kernel_ir->cx == NULL)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
return cx23885_input_ir_start(kernel_ir->cx);
|
2009-09-28 07:55:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void cx23885_input_ir_stop(struct cx23885_dev *dev)
|
|
|
|
{
|
|
|
|
struct v4l2_subdev_ir_parameters params;
|
|
|
|
|
|
|
|
if (dev->sd_ir == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Stop the sd_ir subdevice from generating notifications and
|
|
|
|
* scheduling work.
|
|
|
|
* It is shutdown this way in order to mitigate a race with
|
|
|
|
* cx23885_input_rx_work_handler() in the overrun case, which could
|
|
|
|
* re-enable the subdevice.
|
|
|
|
*/
|
|
|
|
atomic_set(&dev->ir_input_stopping, 1);
|
|
|
|
v4l2_subdev_call(dev->sd_ir, ir, rx_g_parameters, ¶ms);
|
|
|
|
while (params.shutdown == false) {
|
|
|
|
params.enable = false;
|
|
|
|
params.interrupt_enable = false;
|
|
|
|
params.shutdown = true;
|
|
|
|
v4l2_subdev_call(dev->sd_ir, ir, rx_s_parameters, ¶ms);
|
|
|
|
v4l2_subdev_call(dev->sd_ir, ir, rx_g_parameters, ¶ms);
|
|
|
|
}
|
2012-08-21 05:51:24 +08:00
|
|
|
flush_work(&dev->cx25840_work);
|
|
|
|
flush_work(&dev->ir_rx_work);
|
|
|
|
flush_work(&dev->ir_tx_work);
|
2010-06-28 10:15:35 +08:00
|
|
|
}
|
2009-09-28 07:55:41 +08:00
|
|
|
|
2010-10-30 03:08:23 +08:00
|
|
|
static void cx23885_input_ir_close(struct rc_dev *rc)
|
2010-06-28 10:15:35 +08:00
|
|
|
{
|
2010-10-30 03:08:23 +08:00
|
|
|
struct cx23885_kernel_ir *kernel_ir = rc->priv;
|
2010-06-28 10:15:35 +08:00
|
|
|
|
|
|
|
if (kernel_ir->cx != NULL)
|
|
|
|
cx23885_input_ir_stop(kernel_ir->cx);
|
2009-09-28 07:55:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int cx23885_input_init(struct cx23885_dev *dev)
|
|
|
|
{
|
2010-06-28 10:15:35 +08:00
|
|
|
struct cx23885_kernel_ir *kernel_ir;
|
2010-10-30 03:08:23 +08:00
|
|
|
struct rc_dev *rc;
|
2010-06-28 10:15:35 +08:00
|
|
|
char *rc_map;
|
2015-11-17 14:33:25 +08:00
|
|
|
u64 allowed_protos;
|
2010-06-28 10:15:35 +08:00
|
|
|
|
2009-09-28 07:55:41 +08:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the IR device (hardware registers, chip, GPIO lines, etc.) isn't
|
|
|
|
* encapsulated in a v4l2_subdev, then I'm not going to deal with it.
|
|
|
|
*/
|
|
|
|
if (dev->sd_ir == NULL)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
switch (dev->board) {
|
2011-06-09 08:24:25 +08:00
|
|
|
case CX23885_BOARD_HAUPPAUGE_HVR1270:
|
2009-09-28 07:55:41 +08:00
|
|
|
case CX23885_BOARD_HAUPPAUGE_HVR1850:
|
2009-11-12 02:46:09 +08:00
|
|
|
case CX23885_BOARD_HAUPPAUGE_HVR1290:
|
2010-07-19 11:41:41 +08:00
|
|
|
case CX23885_BOARD_HAUPPAUGE_HVR1250:
|
|
|
|
/* Integrated CX2388[58] IR controller */
|
2017-08-08 04:20:58 +08:00
|
|
|
allowed_protos = RC_PROTO_BIT_ALL_IR_DECODER;
|
2010-06-28 10:15:35 +08:00
|
|
|
/* The grey Hauppauge RC-5 remote */
|
2011-01-24 23:18:47 +08:00
|
|
|
rc_map = RC_MAP_HAUPPAUGE;
|
2009-09-28 07:55:41 +08:00
|
|
|
break;
|
2012-07-28 20:01:38 +08:00
|
|
|
case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL:
|
|
|
|
/* Integrated CX23885 IR controller */
|
2017-08-08 04:20:58 +08:00
|
|
|
allowed_protos = RC_PROTO_BIT_ALL_IR_DECODER;
|
2012-07-28 20:01:38 +08:00
|
|
|
/* The grey Terratec remote with orange buttons */
|
|
|
|
rc_map = RC_MAP_NEC_TERRATEC_CINERGY_XS;
|
|
|
|
break;
|
2010-07-19 11:41:41 +08:00
|
|
|
case CX23885_BOARD_TEVII_S470:
|
|
|
|
/* Integrated CX23885 IR controller */
|
2017-08-08 04:20:58 +08:00
|
|
|
allowed_protos = RC_PROTO_BIT_ALL_IR_DECODER;
|
2010-07-19 11:41:41 +08:00
|
|
|
/* A guess at the remote */
|
|
|
|
rc_map = RC_MAP_TEVII_NEC;
|
|
|
|
break;
|
2012-11-09 02:50:25 +08:00
|
|
|
case CX23885_BOARD_MYGICA_X8507:
|
|
|
|
/* Integrated CX23885 IR controller */
|
2017-08-08 04:20:58 +08:00
|
|
|
allowed_protos = RC_PROTO_BIT_ALL_IR_DECODER;
|
2012-11-09 02:50:25 +08:00
|
|
|
/* A guess at the remote */
|
|
|
|
rc_map = RC_MAP_TOTAL_MEDIA_IN_HAND_02;
|
|
|
|
break;
|
2013-10-02 09:11:35 +08:00
|
|
|
case CX23885_BOARD_TBS_6980:
|
|
|
|
case CX23885_BOARD_TBS_6981:
|
|
|
|
/* Integrated CX23885 IR controller */
|
2017-08-08 04:20:58 +08:00
|
|
|
allowed_protos = RC_PROTO_BIT_ALL_IR_DECODER;
|
2013-10-02 09:11:35 +08:00
|
|
|
/* A guess at the remote */
|
|
|
|
rc_map = RC_MAP_TBS_NEC;
|
|
|
|
break;
|
2014-09-29 22:17:36 +08:00
|
|
|
case CX23885_BOARD_DVBSKY_T9580:
|
2014-10-23 18:02:16 +08:00
|
|
|
case CX23885_BOARD_DVBSKY_T980C:
|
|
|
|
case CX23885_BOARD_DVBSKY_S950C:
|
2014-11-05 22:58:07 +08:00
|
|
|
case CX23885_BOARD_DVBSKY_S950:
|
2014-11-05 22:58:38 +08:00
|
|
|
case CX23885_BOARD_DVBSKY_S952:
|
2014-11-12 12:23:12 +08:00
|
|
|
case CX23885_BOARD_DVBSKY_T982:
|
2014-09-29 22:17:36 +08:00
|
|
|
/* Integrated CX23885 IR controller */
|
2017-08-08 04:20:58 +08:00
|
|
|
allowed_protos = RC_PROTO_BIT_ALL_IR_DECODER;
|
2014-09-29 22:17:36 +08:00
|
|
|
rc_map = RC_MAP_DVBSKY;
|
|
|
|
break;
|
2014-10-31 04:48:27 +08:00
|
|
|
case CX23885_BOARD_TT_CT2_4500_CI:
|
|
|
|
/* Integrated CX23885 IR controller */
|
2017-08-08 04:20:58 +08:00
|
|
|
allowed_protos = RC_PROTO_BIT_ALL_IR_DECODER;
|
2014-10-31 04:48:27 +08:00
|
|
|
rc_map = RC_MAP_TT_1500;
|
|
|
|
break;
|
2010-06-28 10:15:35 +08:00
|
|
|
default:
|
2009-09-28 07:55:41 +08:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2010-06-28 10:15:35 +08:00
|
|
|
/* cx23885 board instance kernel IR state */
|
|
|
|
kernel_ir = kzalloc(sizeof(struct cx23885_kernel_ir), GFP_KERNEL);
|
|
|
|
if (kernel_ir == NULL)
|
|
|
|
return -ENOMEM;
|
2009-09-28 07:55:41 +08:00
|
|
|
|
2010-06-28 10:15:35 +08:00
|
|
|
kernel_ir->cx = dev;
|
|
|
|
kernel_ir->name = kasprintf(GFP_KERNEL, "cx23885 IR (%s)",
|
|
|
|
cx23885_boards[dev->board].name);
|
|
|
|
kernel_ir->phys = kasprintf(GFP_KERNEL, "pci-%s/ir0",
|
|
|
|
pci_name(dev->pci));
|
2009-09-28 07:55:41 +08:00
|
|
|
|
2010-06-28 10:15:35 +08:00
|
|
|
/* input device */
|
2016-12-16 16:50:58 +08:00
|
|
|
rc = rc_allocate_device(RC_DRIVER_IR_RAW);
|
2010-10-30 03:08:23 +08:00
|
|
|
if (!rc) {
|
2010-06-28 10:15:35 +08:00
|
|
|
ret = -ENOMEM;
|
2009-11-29 19:19:59 +08:00
|
|
|
goto err_out_free;
|
2010-06-28 10:15:35 +08:00
|
|
|
}
|
2009-11-29 19:19:59 +08:00
|
|
|
|
2010-10-30 03:08:23 +08:00
|
|
|
kernel_ir->rc = rc;
|
2017-07-02 00:13:19 +08:00
|
|
|
rc->device_name = kernel_ir->name;
|
2010-10-30 03:08:23 +08:00
|
|
|
rc->input_phys = kernel_ir->phys;
|
|
|
|
rc->input_id.bustype = BUS_PCI;
|
|
|
|
rc->input_id.version = 1;
|
2009-09-28 07:55:41 +08:00
|
|
|
if (dev->pci->subsystem_vendor) {
|
2010-10-30 03:08:23 +08:00
|
|
|
rc->input_id.vendor = dev->pci->subsystem_vendor;
|
|
|
|
rc->input_id.product = dev->pci->subsystem_device;
|
2009-09-28 07:55:41 +08:00
|
|
|
} else {
|
2010-10-30 03:08:23 +08:00
|
|
|
rc->input_id.vendor = dev->pci->vendor;
|
|
|
|
rc->input_id.product = dev->pci->device;
|
2009-09-28 07:55:41 +08:00
|
|
|
}
|
2010-10-30 03:08:23 +08:00
|
|
|
rc->dev.parent = &dev->pci->dev;
|
2014-04-04 07:32:21 +08:00
|
|
|
rc->allowed_protocols = allowed_protos;
|
2010-10-30 03:08:23 +08:00
|
|
|
rc->priv = kernel_ir;
|
|
|
|
rc->open = cx23885_input_ir_open;
|
|
|
|
rc->close = cx23885_input_ir_close;
|
|
|
|
rc->map_name = rc_map;
|
|
|
|
rc->driver_name = MODULE_NAME;
|
2010-06-28 10:15:35 +08:00
|
|
|
|
|
|
|
/* Go */
|
|
|
|
dev->kernel_ir = kernel_ir;
|
2010-10-30 03:08:23 +08:00
|
|
|
ret = rc_register_device(rc);
|
2009-09-28 07:55:41 +08:00
|
|
|
if (ret)
|
|
|
|
goto err_out_stop;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err_out_stop:
|
|
|
|
cx23885_input_ir_stop(dev);
|
2010-06-28 10:15:35 +08:00
|
|
|
dev->kernel_ir = NULL;
|
2010-10-30 03:08:23 +08:00
|
|
|
rc_free_device(rc);
|
2009-09-28 07:55:41 +08:00
|
|
|
err_out_free:
|
2010-06-28 10:15:35 +08:00
|
|
|
kfree(kernel_ir->phys);
|
|
|
|
kfree(kernel_ir->name);
|
|
|
|
kfree(kernel_ir);
|
2009-09-28 07:55:41 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cx23885_input_fini(struct cx23885_dev *dev)
|
|
|
|
{
|
|
|
|
/* Always stop the IR hardware from generating interrupts */
|
|
|
|
cx23885_input_ir_stop(dev);
|
|
|
|
|
2010-06-28 10:15:35 +08:00
|
|
|
if (dev->kernel_ir == NULL)
|
2009-09-28 07:55:41 +08:00
|
|
|
return;
|
2010-10-30 03:08:23 +08:00
|
|
|
rc_unregister_device(dev->kernel_ir->rc);
|
2010-06-28 10:15:35 +08:00
|
|
|
kfree(dev->kernel_ir->phys);
|
|
|
|
kfree(dev->kernel_ir->name);
|
|
|
|
kfree(dev->kernel_ir);
|
|
|
|
dev->kernel_ir = NULL;
|
2009-09-28 07:55:41 +08:00
|
|
|
}
|