aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/rc/nuvoton-cir.c
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2010-10-29 15:08:23 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-12-29 05:16:37 -0500
commitd8b4b5822f51e2142b731b42c81e3f03eec475b2 (patch)
treefce9a9b7ca5031adc95fbd6be118352fb2527da5 /drivers/media/rc/nuvoton-cir.c
parent4c7b355df6e7f05304e05f6b7a286e59a5f1cc54 (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/rc/nuvoton-cir.c')
-rw-r--r--drivers/media/rc/nuvoton-cir.c85
1 files changed, 37 insertions, 48 deletions
diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c
index acc729c79cec..0ce328f9dacf 100644
--- a/drivers/media/rc/nuvoton-cir.c
+++ b/drivers/media/rc/nuvoton-cir.c
@@ -32,7 +32,6 @@
32#include <linux/interrupt.h> 32#include <linux/interrupt.h>
33#include <linux/sched.h> 33#include <linux/sched.h>
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/input.h>
36#include <media/ir-core.h> 35#include <media/ir-core.h>
37#include <linux/pci_ids.h> 36#include <linux/pci_ids.h>
38 37
@@ -476,9 +475,9 @@ static u32 nvt_rx_carrier_detect(struct nvt_dev *nvt)
476 * always set CP as 0x81 475 * always set CP as 0x81
477 * set CC by SPEC, CC = 3MHz/carrier - 1 476 * set CC by SPEC, CC = 3MHz/carrier - 1
478 */ 477 */
479static int nvt_set_tx_carrier(void *data, u32 carrier) 478static int nvt_set_tx_carrier(struct rc_dev *dev, u32 carrier)
480{ 479{
481 struct nvt_dev *nvt = data; 480 struct nvt_dev *nvt = dev->priv;
482 u16 val; 481 u16 val;
483 482
484 nvt_cir_reg_write(nvt, 1, CIR_CP); 483 nvt_cir_reg_write(nvt, 1, CIR_CP);
@@ -509,9 +508,9 @@ static int nvt_set_tx_carrier(void *data, u32 carrier)
509 * number may larger than TXFCONT (0xff). So in interrupt_handler, it has to 508 * number may larger than TXFCONT (0xff). So in interrupt_handler, it has to
510 * set TXFCONT as 0xff, until buf_count less than 0xff. 509 * set TXFCONT as 0xff, until buf_count less than 0xff.
511 */ 510 */
512static int nvt_tx_ir(void *priv, int *txbuf, u32 n) 511static int nvt_tx_ir(struct rc_dev *dev, int *txbuf, u32 n)
513{ 512{
514 struct nvt_dev *nvt = priv; 513 struct nvt_dev *nvt = dev->priv;
515 unsigned long flags; 514 unsigned long flags;
516 size_t cur_count; 515 size_t cur_count;
517 unsigned int i; 516 unsigned int i;
@@ -948,9 +947,9 @@ static void nvt_disable_cir(struct nvt_dev *nvt)
948 nvt_efm_disable(nvt); 947 nvt_efm_disable(nvt);
949} 948}
950 949
951static int nvt_open(void *data) 950static int nvt_open(struct rc_dev *dev)
952{ 951{
953 struct nvt_dev *nvt = (struct nvt_dev *)data; 952 struct nvt_dev *nvt = dev->priv;
954 unsigned long flags; 953 unsigned long flags;
955 954
956 spin_lock_irqsave(&nvt->nvt_lock, flags); 955 spin_lock_irqsave(&nvt->nvt_lock, flags);
@@ -961,9 +960,9 @@ static int nvt_open(void *data)
961 return 0; 960 return 0;
962} 961}
963 962
964static void nvt_close(void *data) 963static void nvt_close(struct rc_dev *dev)
965{ 964{
966 struct nvt_dev *nvt = (struct nvt_dev *)data; 965 struct nvt_dev *nvt = dev->priv;
967 unsigned long flags; 966 unsigned long flags;
968 967
969 spin_lock_irqsave(&nvt->nvt_lock, flags); 968 spin_lock_irqsave(&nvt->nvt_lock, flags);
@@ -975,21 +974,16 @@ static void nvt_close(void *data)
975/* Allocate memory, probe hardware, and initialize everything */ 974/* Allocate memory, probe hardware, and initialize everything */
976static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id) 975static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
977{ 976{
978 struct nvt_dev *nvt = NULL; 977 struct nvt_dev *nvt;
979 struct input_dev *rdev = NULL; 978 struct rc_dev *rdev;
980 struct ir_dev_props *props = NULL;
981 int ret = -ENOMEM; 979 int ret = -ENOMEM;
982 980
983 nvt = kzalloc(sizeof(struct nvt_dev), GFP_KERNEL); 981 nvt = kzalloc(sizeof(struct nvt_dev), GFP_KERNEL);
984 if (!nvt) 982 if (!nvt)
985 return ret; 983 return ret;
986 984
987 props = kzalloc(sizeof(struct ir_dev_props), GFP_KERNEL);
988 if (!props)
989 goto failure;
990
991 /* input device for IR remote (and tx) */ 985 /* input device for IR remote (and tx) */
992 rdev = input_allocate_device(); 986 rdev = rc_allocate_device();
993 if (!rdev) 987 if (!rdev)
994 goto failure; 988 goto failure;
995 989
@@ -1063,41 +1057,38 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
1063 nvt_cir_regs_init(nvt); 1057 nvt_cir_regs_init(nvt);
1064 nvt_cir_wake_regs_init(nvt); 1058 nvt_cir_wake_regs_init(nvt);
1065 1059
1066 /* Set up ir-core props */ 1060 /* Set up the rc device */
1067 props->priv = nvt; 1061 rdev->priv = nvt;
1068 props->driver_type = RC_DRIVER_IR_RAW; 1062 rdev->driver_type = RC_DRIVER_IR_RAW;
1069 props->allowed_protos = IR_TYPE_ALL; 1063 rdev->allowed_protos = IR_TYPE_ALL;
1070 props->open = nvt_open; 1064 rdev->open = nvt_open;
1071 props->close = nvt_close; 1065 rdev->close = nvt_close;
1066 rdev->tx_ir = nvt_tx_ir;
1067 rdev->s_tx_carrier = nvt_set_tx_carrier;
1068 rdev->input_name = "Nuvoton w836x7hg Infrared Remote Transceiver";
1069 rdev->input_id.bustype = BUS_HOST;
1070 rdev->input_id.vendor = PCI_VENDOR_ID_WINBOND2;
1071 rdev->input_id.product = nvt->chip_major;
1072 rdev->input_id.version = nvt->chip_minor;
1073 rdev->driver_name = NVT_DRIVER_NAME;
1074 rdev->map_name = RC_MAP_RC6_MCE;
1072#if 0 1075#if 0
1073 props->min_timeout = XYZ; 1076 rdev->min_timeout = XYZ;
1074 props->max_timeout = XYZ; 1077 rdev->max_timeout = XYZ;
1075 props->timeout = XYZ; 1078 rdev->timeout = XYZ;
1076 /* rx resolution is hardwired to 50us atm, 1, 25, 100 also possible */ 1079 /* rx resolution is hardwired to 50us atm, 1, 25, 100 also possible */
1077 props->rx_resolution = XYZ; 1080 rdev->rx_resolution = XYZ;
1078
1079 /* tx bits */ 1081 /* tx bits */
1080 props->tx_resolution = XYZ; 1082 rdev->tx_resolution = XYZ;
1081#endif 1083#endif
1082 props->tx_ir = nvt_tx_ir;
1083 props->s_tx_carrier = nvt_set_tx_carrier;
1084
1085 rdev->name = "Nuvoton w836x7hg Infrared Remote Transceiver";
1086 rdev->id.bustype = BUS_HOST;
1087 rdev->id.vendor = PCI_VENDOR_ID_WINBOND2;
1088 rdev->id.product = nvt->chip_major;
1089 rdev->id.version = nvt->chip_minor;
1090
1091 nvt->props = props;
1092 nvt->rdev = rdev;
1093 1084
1094 device_set_wakeup_capable(&pdev->dev, 1); 1085 ret = rc_register_device(rdev);
1095 device_set_wakeup_enable(&pdev->dev, 1);
1096
1097 ret = ir_input_register(rdev, RC_MAP_RC6_MCE, props, NVT_DRIVER_NAME);
1098 if (ret) 1086 if (ret)
1099 goto failure; 1087 goto failure;
1100 1088
1089 device_set_wakeup_capable(&pdev->dev, 1);
1090 device_set_wakeup_enable(&pdev->dev, 1);
1091 nvt->rdev = rdev;
1101 nvt_pr(KERN_NOTICE, "driver has been successfully loaded\n"); 1092 nvt_pr(KERN_NOTICE, "driver has been successfully loaded\n");
1102 if (debug) { 1093 if (debug) {
1103 cir_dump_regs(nvt); 1094 cir_dump_regs(nvt);
@@ -1117,8 +1108,7 @@ failure:
1117 if (nvt->cir_wake_addr) 1108 if (nvt->cir_wake_addr)
1118 release_region(nvt->cir_wake_addr, CIR_IOREG_LENGTH); 1109 release_region(nvt->cir_wake_addr, CIR_IOREG_LENGTH);
1119 1110
1120 input_free_device(rdev); 1111 rc_free_device(rdev);
1121 kfree(props);
1122 kfree(nvt); 1112 kfree(nvt);
1123 1113
1124 return ret; 1114 return ret;
@@ -1143,9 +1133,8 @@ static void __devexit nvt_remove(struct pnp_dev *pdev)
1143 release_region(nvt->cir_addr, CIR_IOREG_LENGTH); 1133 release_region(nvt->cir_addr, CIR_IOREG_LENGTH);
1144 release_region(nvt->cir_wake_addr, CIR_IOREG_LENGTH); 1134 release_region(nvt->cir_wake_addr, CIR_IOREG_LENGTH);
1145 1135
1146 ir_input_unregister(nvt->rdev); 1136 rc_unregister_device(nvt->rdev);
1147 1137
1148 kfree(nvt->props);
1149 kfree(nvt); 1138 kfree(nvt);
1150} 1139}
1151 1140