]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - drivers/media/video/cx231xx/cx231xx-input.c
2 * cx231xx IR glue driver
4 * Copyright (C) 2010 Mauro Carvalho Chehab <mchehab@redhat.com>
6 * Polaris (cx231xx) has its support for IR's with a design close to MCE.
7 * however, a few designs are using an external I2C chip for IR, instead
8 * of using the one provided by the chip.
9 * This driver provides support for those extra devices
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation version 2.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
22 #include <linux/usb.h>
23 #include <linux/slab.h>
25 #define MODULE_NAME "cx231xx-input"
27 static int get_key_isdbt(struct IR_i2c
*ir
, u32
*ir_key
,
33 if (1 != i2c_master_recv(ir
->c
, &cmd
, 1))
36 /* it seems that 0xFE indicates that a button is still hold
37 down, while 0xff indicates that no button is hold
38 down. 0xfe sequences are sometimes interrupted by 0xFF */
43 dev_dbg(&ir
->input
->dev
, "scancode = %02x\n", cmd
);
50 int cx231xx_ir_init(struct cx231xx
*dev
)
52 struct input_dev
*input_dev
;
53 struct i2c_board_info info
;
57 dev_dbg(&dev
->udev
->dev
, "%s\n", __func__
);
59 /* Only initialize if a rc keycode map is defined */
60 if (!cx231xx_boards
[dev
->model
].rc_map
)
63 input_dev
= input_allocate_device();
67 request_module("ir-kbd-i2c");
69 memset(&info
, 0, sizeof(struct i2c_board_info
));
70 memset(&dev
->ir
.init_data
, 0, sizeof(dev
->ir
.init_data
));
72 dev
->ir
.input_dev
= input_dev
;
73 dev
->ir
.init_data
.name
= cx231xx_boards
[dev
->model
].name
;
74 dev
->ir
.props
.priv
= dev
;
75 dev
->ir
.props
.allowed_protos
= IR_TYPE_NEC
;
76 snprintf(dev
->ir
.name
, sizeof(dev
->ir
.name
),
77 "cx231xx IR (%s)", cx231xx_boards
[dev
->model
].name
);
78 usb_make_path(dev
->udev
, dev
->ir
.phys
, sizeof(dev
->ir
.phys
));
79 strlcat(dev
->ir
.phys
, "/input0", sizeof(dev
->ir
.phys
));
81 strlcpy(info
.type
, "ir_video", I2C_NAME_SIZE
);
82 info
.platform_data
= &dev
->ir
.init_data
;
84 input_dev
->name
= dev
->ir
.name
;
85 input_dev
->phys
= dev
->ir
.phys
;
86 input_dev
->dev
.parent
= &dev
->udev
->dev
;
87 input_dev
->id
.bustype
= BUS_USB
;
88 input_dev
->id
.version
= 1;
89 input_dev
->id
.vendor
= le16_to_cpu(dev
->udev
->descriptor
.idVendor
);
90 input_dev
->id
.product
= le16_to_cpu(dev
->udev
->descriptor
.idProduct
);
93 * Board-dependent values
95 * For now, there's just one type of hardware design using
98 dev
->ir
.init_data
.get_key
= get_key_isdbt
;
99 dev
->ir
.init_data
.ir_codes
= cx231xx_boards
[dev
->model
].rc_map
;
100 /* The i2c micro-controller only outputs the cmd part of NEC protocol */
101 dev
->ir
.props
.scanmask
= 0xff;
104 rc
= ir_input_register(input_dev
, cx231xx_boards
[dev
->model
].rc_map
,
105 &dev
->ir
.props
, MODULE_NAME
);
109 /* Load and bind ir-kbd-i2c */
110 ir_i2c_bus
= cx231xx_boards
[dev
->model
].ir_i2c_master
;
111 i2c_new_device(&dev
->i2c_bus
[ir_i2c_bus
].i2c_adap
, &info
);
116 void cx231xx_ir_exit(struct cx231xx
*dev
)
118 if (dev
->ir
.input_dev
) {
119 ir_input_unregister(dev
->ir
.input_dev
);
120 dev
->ir
.input_dev
= NULL
;