1
2
3
4
5
6
7
8
9#include <media/rc-core.h>
10#include <linux/pci.h>
11
12#include <media/dmxdev.h>
13#include <media/dvbdev.h>
14#include <media/dvb_demux.h>
15#include <media/dvb_frontend.h>
16#include <media/dvb_net.h>
17
18#include "mantis_common.h"
19#include "mantis_input.h"
20
21#define MODULE_NAME "mantis_core"
22
23void mantis_input_process(struct mantis_pci *mantis, int scancode)
24{
25 if (mantis->rc)
26 rc_keydown(mantis->rc, RC_PROTO_UNKNOWN, scancode, 0);
27}
28
29int mantis_input_init(struct mantis_pci *mantis)
30{
31 struct rc_dev *dev;
32 int err;
33
34 dev = rc_allocate_device(RC_DRIVER_SCANCODE);
35 if (!dev) {
36 dprintk(MANTIS_ERROR, 1, "Remote device allocation failed");
37 err = -ENOMEM;
38 goto out;
39 }
40
41 snprintf(mantis->device_name, sizeof(mantis->device_name),
42 "Mantis %s IR receiver", mantis->hwconfig->model_name);
43 snprintf(mantis->input_phys, sizeof(mantis->input_phys),
44 "pci-%s/ir0", pci_name(mantis->pdev));
45
46 dev->device_name = mantis->device_name;
47 dev->input_phys = mantis->input_phys;
48 dev->input_id.bustype = BUS_PCI;
49 dev->input_id.vendor = mantis->vendor_id;
50 dev->input_id.product = mantis->device_id;
51 dev->input_id.version = 1;
52 dev->driver_name = MODULE_NAME;
53 dev->map_name = mantis->rc_map_name ? : RC_MAP_EMPTY;
54 dev->dev.parent = &mantis->pdev->dev;
55
56 err = rc_register_device(dev);
57 if (err) {
58 dprintk(MANTIS_ERROR, 1, "IR device registration failed, ret = %d", err);
59 goto out_dev;
60 }
61
62 mantis->rc = dev;
63 return 0;
64
65out_dev:
66 rc_free_device(dev);
67out:
68 return err;
69}
70EXPORT_SYMBOL_GPL(mantis_input_init);
71
72void mantis_input_exit(struct mantis_pci *mantis)
73{
74 rc_unregister_device(mantis->rc);
75}
76EXPORT_SYMBOL_GPL(mantis_input_exit);
77