diff options
author | David Härdeman <david@hardeman.nu> | 2010-10-29 15:08:23 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-12-29 05:16:37 -0500 |
commit | d8b4b5822f51e2142b731b42c81e3f03eec475b2 (patch) | |
tree | fce9a9b7ca5031adc95fbd6be118352fb2527da5 /drivers/media/dvb/mantis/mantis_input.c | |
parent | 4c7b355df6e7f05304e05f6b7a286e59a5f1cc54 (diff) |
[media] ir-core: make struct rc_dev the primary interface
This patch merges the ir_input_dev and ir_dev_props structs into a single
struct called rc_dev. The drivers and various functions in rc-core used
by the drivers are also changed to use rc_dev as the primary interface
when dealing with rc-core.
This means that the input_dev is abstracted away from the drivers which
is necessary if we ever want to support multiple input devs per rc device.
The new API is similar to what the input subsystem uses, i.e:
rc_device_alloc()
rc_device_free()
rc_device_register()
rc_device_unregister()
[mchehab@redhat.com: Fix compilation on mceusb and cx231xx, due to merge conflicts]
Signed-off-by: David Härdeman <david@hardeman.nu>
Acked-by: Jarod Wilson <jarod@redhat.com>
Tested-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb/mantis/mantis_input.c')
-rw-r--r-- | drivers/media/dvb/mantis/mantis_input.c | 72 |
1 files changed, 42 insertions, 30 deletions
diff --git a/drivers/media/dvb/mantis/mantis_input.c b/drivers/media/dvb/mantis/mantis_input.c index a99489b8418b..209f2110e20c 100644 --- a/drivers/media/dvb/mantis/mantis_input.c +++ b/drivers/media/dvb/mantis/mantis_input.c | |||
@@ -18,7 +18,6 @@ | |||
18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <linux/input.h> | ||
22 | #include <media/ir-core.h> | 21 | #include <media/ir-core.h> |
23 | #include <linux/pci.h> | 22 | #include <linux/pci.h> |
24 | 23 | ||
@@ -33,6 +32,7 @@ | |||
33 | #include "mantis_uart.h" | 32 | #include "mantis_uart.h" |
34 | 33 | ||
35 | #define MODULE_NAME "mantis_core" | 34 | #define MODULE_NAME "mantis_core" |
35 | #define RC_MAP_MANTIS "rc-mantis" | ||
36 | 36 | ||
37 | static struct ir_scancode mantis_ir_table[] = { | 37 | static struct ir_scancode mantis_ir_table[] = { |
38 | { 0x29, KEY_POWER }, | 38 | { 0x29, KEY_POWER }, |
@@ -95,53 +95,65 @@ static struct ir_scancode mantis_ir_table[] = { | |||
95 | { 0x00, KEY_BLUE }, | 95 | { 0x00, KEY_BLUE }, |
96 | }; | 96 | }; |
97 | 97 | ||
98 | struct ir_scancode_table ir_mantis = { | 98 | static struct rc_keymap ir_mantis_map = { |
99 | .scan = mantis_ir_table, | 99 | .map = { |
100 | .size = ARRAY_SIZE(mantis_ir_table), | 100 | .scan = mantis_ir_table, |
101 | .size = ARRAY_SIZE(mantis_ir_table), | ||
102 | .ir_type = IR_TYPE_UNKNOWN, | ||
103 | .name = RC_MAP_MANTIS, | ||
104 | } | ||
101 | }; | 105 | }; |
102 | EXPORT_SYMBOL_GPL(ir_mantis); | ||
103 | 106 | ||
104 | int mantis_input_init(struct mantis_pci *mantis) | 107 | int mantis_input_init(struct mantis_pci *mantis) |
105 | { | 108 | { |
106 | struct input_dev *rc; | 109 | struct rc_dev *dev; |
107 | char name[80], dev[80]; | ||
108 | int err; | 110 | int err; |
109 | 111 | ||
110 | rc = input_allocate_device(); | 112 | err = ir_register_map(&ir_mantis_map); |
111 | if (!rc) { | 113 | if (err) |
112 | dprintk(MANTIS_ERROR, 1, "Input device allocate failed"); | 114 | goto out; |
113 | return -ENOMEM; | ||
114 | } | ||
115 | 115 | ||
116 | sprintf(name, "Mantis %s IR receiver", mantis->hwconfig->model_name); | 116 | dev = rc_allocate_device(); |
117 | sprintf(dev, "pci-%s/ir0", pci_name(mantis->pdev)); | 117 | if (!dev) { |
118 | dprintk(MANTIS_ERROR, 1, "Remote device allocation failed"); | ||
119 | err = -ENOMEM; | ||
120 | goto out_map; | ||
121 | } | ||
118 | 122 | ||
119 | rc->name = name; | 123 | sprintf(mantis->input_name, "Mantis %s IR receiver", mantis->hwconfig->model_name); |
120 | rc->phys = dev; | 124 | sprintf(mantis->input_phys, "pci-%s/ir0", pci_name(mantis->pdev)); |
121 | 125 | ||
122 | rc->id.bustype = BUS_PCI; | 126 | dev->input_name = mantis->input_name; |
123 | rc->id.vendor = mantis->vendor_id; | 127 | dev->input_phys = mantis->input_phys; |
124 | rc->id.product = mantis->device_id; | 128 | dev->input_id.bustype = BUS_PCI; |
125 | rc->id.version = 1; | 129 | dev->input_id.vendor = mantis->vendor_id; |
126 | rc->dev = mantis->pdev->dev; | 130 | dev->input_id.product = mantis->device_id; |
131 | dev->input_id.version = 1; | ||
132 | dev->driver_name = MODULE_NAME; | ||
133 | dev->map_name = RC_MAP_MANTIS; | ||
134 | dev->dev.parent = &mantis->pdev->dev; | ||
127 | 135 | ||
128 | err = __ir_input_register(rc, &ir_mantis, NULL, MODULE_NAME); | 136 | err = rc_register_device(dev); |
129 | if (err) { | 137 | if (err) { |
130 | dprintk(MANTIS_ERROR, 1, "IR device registration failed, ret = %d", err); | 138 | dprintk(MANTIS_ERROR, 1, "IR device registration failed, ret = %d", err); |
131 | input_free_device(rc); | 139 | goto out_dev; |
132 | return -ENODEV; | ||
133 | } | 140 | } |
134 | 141 | ||
135 | mantis->rc = rc; | 142 | mantis->rc = dev; |
136 | |||
137 | return 0; | 143 | return 0; |
144 | |||
145 | out_dev: | ||
146 | rc_free_device(dev); | ||
147 | out_map: | ||
148 | ir_unregister_map(&ir_mantis_map); | ||
149 | out: | ||
150 | return err; | ||
138 | } | 151 | } |
139 | 152 | ||
140 | int mantis_exit(struct mantis_pci *mantis) | 153 | int mantis_exit(struct mantis_pci *mantis) |
141 | { | 154 | { |
142 | struct input_dev *rc = mantis->rc; | 155 | rc_unregister_device(mantis->rc); |
143 | 156 | ir_unregister_map(&ir_mantis_map); | |
144 | ir_input_unregister(rc); | ||
145 | |||
146 | return 0; | 157 | return 0; |
147 | } | 158 | } |
159 | |||