blob: abf0ddfef0cba6c07ede54cba65353e1f7ebf653 [file] [log] [blame]
Manu Abrahama1497352009-12-11 20:41:07 -03001/*
2 Mantis PCI bridge driver
3
4 Copyright (C) Manu Abraham (abraham.manu@gmail.com)
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/
20
Mauro Carvalho Chehab6bda9642010-11-17 13:28:38 -030021#include <media/rc-core.h>
Manu Abrahama1497352009-12-11 20:41:07 -030022#include <linux/pci.h>
23
24#include "dmxdev.h"
25#include "dvbdev.h"
26#include "dvb_demux.h"
27#include "dvb_frontend.h"
28#include "dvb_net.h"
29
30#include "mantis_common.h"
Jan Klötzkea96762d2015-06-06 16:58:13 -030031#include "mantis_input.h"
Manu Abrahama1497352009-12-11 20:41:07 -030032
Mauro Carvalho Chehab727e6252010-03-12 21:18:14 -030033#define MODULE_NAME "mantis_core"
34
Jan Klötzkea96762d2015-06-06 16:58:13 -030035void mantis_input_process(struct mantis_pci *mantis, int scancode)
36{
37 if (mantis->rc)
38 rc_keydown(mantis->rc, RC_TYPE_UNKNOWN, scancode, 0);
39}
Manu Abrahama1497352009-12-11 20:41:07 -030040
41int mantis_input_init(struct mantis_pci *mantis)
42{
David Härdemand8b4b582010-10-29 16:08:23 -030043 struct rc_dev *dev;
Manu Abrahama1497352009-12-11 20:41:07 -030044 int err;
45
David Härdemand8b4b582010-10-29 16:08:23 -030046 dev = rc_allocate_device();
47 if (!dev) {
48 dprintk(MANTIS_ERROR, 1, "Remote device allocation failed");
49 err = -ENOMEM;
Jan Klötzkea96762d2015-06-06 16:58:13 -030050 goto out;
Manu Abrahama1497352009-12-11 20:41:07 -030051 }
52
Jan Klötzkea96762d2015-06-06 16:58:13 -030053 snprintf(mantis->input_name, sizeof(mantis->input_name),
54 "Mantis %s IR receiver", mantis->hwconfig->model_name);
55 snprintf(mantis->input_phys, sizeof(mantis->input_phys),
56 "pci-%s/ir0", pci_name(mantis->pdev));
Manu Abrahama1497352009-12-11 20:41:07 -030057
David Härdemand8b4b582010-10-29 16:08:23 -030058 dev->input_name = mantis->input_name;
59 dev->input_phys = mantis->input_phys;
60 dev->input_id.bustype = BUS_PCI;
61 dev->input_id.vendor = mantis->vendor_id;
62 dev->input_id.product = mantis->device_id;
63 dev->input_id.version = 1;
64 dev->driver_name = MODULE_NAME;
Jan Klötzkea96762d2015-06-06 16:58:13 -030065 dev->map_name = mantis->rc_map_name ? : RC_MAP_EMPTY;
David Härdemand8b4b582010-10-29 16:08:23 -030066 dev->dev.parent = &mantis->pdev->dev;
Manu Abrahama1497352009-12-11 20:41:07 -030067
David Härdemand8b4b582010-10-29 16:08:23 -030068 err = rc_register_device(dev);
Manu Abrahama1497352009-12-11 20:41:07 -030069 if (err) {
70 dprintk(MANTIS_ERROR, 1, "IR device registration failed, ret = %d", err);
David Härdemand8b4b582010-10-29 16:08:23 -030071 goto out_dev;
Manu Abrahama1497352009-12-11 20:41:07 -030072 }
73
David Härdemand8b4b582010-10-29 16:08:23 -030074 mantis->rc = dev;
Manu Abrahama1497352009-12-11 20:41:07 -030075 return 0;
David Härdemand8b4b582010-10-29 16:08:23 -030076
77out_dev:
78 rc_free_device(dev);
David Härdemand8b4b582010-10-29 16:08:23 -030079out:
80 return err;
Manu Abrahama1497352009-12-11 20:41:07 -030081}
Jan Klötzkea96762d2015-06-06 16:58:13 -030082EXPORT_SYMBOL_GPL(mantis_input_init);
Manu Abrahama1497352009-12-11 20:41:07 -030083
Jan Klötzkea96762d2015-06-06 16:58:13 -030084void mantis_input_exit(struct mantis_pci *mantis)
Manu Abrahama1497352009-12-11 20:41:07 -030085{
David Härdemand8b4b582010-10-29 16:08:23 -030086 rc_unregister_device(mantis->rc);
Manu Abrahama1497352009-12-11 20:41:07 -030087}
Jan Klötzkea96762d2015-06-06 16:58:13 -030088EXPORT_SYMBOL_GPL(mantis_input_exit);