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