Manu Abraham | a149735 | 2009-12-11 20:41:07 -0300 | [diff] [blame] | 1 | /* |
| 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. |
Manu Abraham | a149735 | 2009-12-11 20:41:07 -0300 | [diff] [blame] | 15 | */ |
| 16 | |
Mauro Carvalho Chehab | 6bda964 | 2010-11-17 13:28:38 -0300 | [diff] [blame] | 17 | #include <media/rc-core.h> |
Manu Abraham | a149735 | 2009-12-11 20:41:07 -0300 | [diff] [blame] | 18 | #include <linux/pci.h> |
| 19 | |
| 20 | #include "dmxdev.h" |
| 21 | #include "dvbdev.h" |
| 22 | #include "dvb_demux.h" |
| 23 | #include "dvb_frontend.h" |
| 24 | #include "dvb_net.h" |
| 25 | |
| 26 | #include "mantis_common.h" |
Jan Klötzke | a96762d | 2015-06-06 16:58:13 -0300 | [diff] [blame] | 27 | #include "mantis_input.h" |
Manu Abraham | a149735 | 2009-12-11 20:41:07 -0300 | [diff] [blame] | 28 | |
Mauro Carvalho Chehab | 727e625 | 2010-03-12 21:18:14 -0300 | [diff] [blame] | 29 | #define MODULE_NAME "mantis_core" |
| 30 | |
Jan Klötzke | a96762d | 2015-06-06 16:58:13 -0300 | [diff] [blame] | 31 | void mantis_input_process(struct mantis_pci *mantis, int scancode) |
| 32 | { |
| 33 | if (mantis->rc) |
| 34 | rc_keydown(mantis->rc, RC_TYPE_UNKNOWN, scancode, 0); |
| 35 | } |
Manu Abraham | a149735 | 2009-12-11 20:41:07 -0300 | [diff] [blame] | 36 | |
| 37 | int mantis_input_init(struct mantis_pci *mantis) |
| 38 | { |
David Härdeman | d8b4b58 | 2010-10-29 16:08:23 -0300 | [diff] [blame] | 39 | struct rc_dev *dev; |
Manu Abraham | a149735 | 2009-12-11 20:41:07 -0300 | [diff] [blame] | 40 | int err; |
| 41 | |
David Härdeman | d8b4b58 | 2010-10-29 16:08:23 -0300 | [diff] [blame] | 42 | dev = rc_allocate_device(); |
| 43 | if (!dev) { |
| 44 | dprintk(MANTIS_ERROR, 1, "Remote device allocation failed"); |
| 45 | err = -ENOMEM; |
Jan Klötzke | a96762d | 2015-06-06 16:58:13 -0300 | [diff] [blame] | 46 | goto out; |
Manu Abraham | a149735 | 2009-12-11 20:41:07 -0300 | [diff] [blame] | 47 | } |
| 48 | |
Jan Klötzke | a96762d | 2015-06-06 16:58:13 -0300 | [diff] [blame] | 49 | snprintf(mantis->input_name, sizeof(mantis->input_name), |
Mauro Carvalho Chehab | 9d605e6 | 2015-06-10 12:06:34 -0300 | [diff] [blame] | 50 | "Mantis %s IR receiver", mantis->hwconfig->model_name); |
Jan Klötzke | a96762d | 2015-06-06 16:58:13 -0300 | [diff] [blame] | 51 | snprintf(mantis->input_phys, sizeof(mantis->input_phys), |
Mauro Carvalho Chehab | 9d605e6 | 2015-06-10 12:06:34 -0300 | [diff] [blame] | 52 | "pci-%s/ir0", pci_name(mantis->pdev)); |
Manu Abraham | a149735 | 2009-12-11 20:41:07 -0300 | [diff] [blame] | 53 | |
David Härdeman | d8b4b58 | 2010-10-29 16:08:23 -0300 | [diff] [blame] | 54 | dev->input_name = mantis->input_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; |
Jan Klötzke | a96762d | 2015-06-06 16:58:13 -0300 | [diff] [blame] | 61 | dev->map_name = mantis->rc_map_name ? : RC_MAP_EMPTY; |
David Härdeman | d8b4b58 | 2010-10-29 16:08:23 -0300 | [diff] [blame] | 62 | dev->dev.parent = &mantis->pdev->dev; |
Manu Abraham | a149735 | 2009-12-11 20:41:07 -0300 | [diff] [blame] | 63 | |
David Härdeman | d8b4b58 | 2010-10-29 16:08:23 -0300 | [diff] [blame] | 64 | err = rc_register_device(dev); |
Manu Abraham | a149735 | 2009-12-11 20:41:07 -0300 | [diff] [blame] | 65 | if (err) { |
| 66 | dprintk(MANTIS_ERROR, 1, "IR device registration failed, ret = %d", err); |
David Härdeman | d8b4b58 | 2010-10-29 16:08:23 -0300 | [diff] [blame] | 67 | goto out_dev; |
Manu Abraham | a149735 | 2009-12-11 20:41:07 -0300 | [diff] [blame] | 68 | } |
| 69 | |
David Härdeman | d8b4b58 | 2010-10-29 16:08:23 -0300 | [diff] [blame] | 70 | mantis->rc = dev; |
Manu Abraham | a149735 | 2009-12-11 20:41:07 -0300 | [diff] [blame] | 71 | return 0; |
David Härdeman | d8b4b58 | 2010-10-29 16:08:23 -0300 | [diff] [blame] | 72 | |
| 73 | out_dev: |
| 74 | rc_free_device(dev); |
David Härdeman | d8b4b58 | 2010-10-29 16:08:23 -0300 | [diff] [blame] | 75 | out: |
| 76 | return err; |
Manu Abraham | a149735 | 2009-12-11 20:41:07 -0300 | [diff] [blame] | 77 | } |
Jan Klötzke | a96762d | 2015-06-06 16:58:13 -0300 | [diff] [blame] | 78 | EXPORT_SYMBOL_GPL(mantis_input_init); |
Manu Abraham | a149735 | 2009-12-11 20:41:07 -0300 | [diff] [blame] | 79 | |
Jan Klötzke | a96762d | 2015-06-06 16:58:13 -0300 | [diff] [blame] | 80 | void mantis_input_exit(struct mantis_pci *mantis) |
Manu Abraham | a149735 | 2009-12-11 20:41:07 -0300 | [diff] [blame] | 81 | { |
David Härdeman | d8b4b58 | 2010-10-29 16:08:23 -0300 | [diff] [blame] | 82 | rc_unregister_device(mantis->rc); |
Manu Abraham | a149735 | 2009-12-11 20:41:07 -0300 | [diff] [blame] | 83 | } |
Jan Klötzke | a96762d | 2015-06-06 16:58:13 -0300 | [diff] [blame] | 84 | EXPORT_SYMBOL_GPL(mantis_input_exit); |