summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManu Abraham2009-12-04 09:11:14 +0100
committerMauro Carvalho Chehab2010-01-17 14:55:34 +0100
commit6053240f5cc914d40ac9c7afe15008bf3e46359c (patch)
tree5a7cdd5b07c43722945f9cb7e57b527eb732169d
parentV4L/DVB (13742): [Mantis] Implement PCMCIA I/O Rd/Wr operations (diff)
downloadkernel-qcow2-linux-6053240f5cc914d40ac9c7afe15008bf3e46359c.tar.gz
kernel-qcow2-linux-6053240f5cc914d40ac9c7afe15008bf3e46359c.tar.xz
kernel-qcow2-linux-6053240f5cc914d40ac9c7afe15008bf3e46359c.zip
V4L/DVB (13743): [Mantis CA] Use DVB_CA Tuple parser
Signed-off-by: Manu Abraham <manu@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/dvb/mantis/mantis_ca.c129
-rw-r--r--drivers/media/dvb/mantis/mantis_common.h2
-rw-r--r--drivers/media/dvb/mantis/mantis_hif.c10
-rw-r--r--drivers/media/dvb/mantis/mantis_link.h9
4 files changed, 80 insertions, 70 deletions
diff --git a/drivers/media/dvb/mantis/mantis_ca.c b/drivers/media/dvb/mantis/mantis_ca.c
index e6de3c9d3ce4..4be61ca02c20 100644
--- a/drivers/media/dvb/mantis/mantis_ca.c
+++ b/drivers/media/dvb/mantis/mantis_ca.c
@@ -22,96 +22,104 @@
#include "mantis_link.h"
#include "mantis_hif.h"
-
-static int mantis_ca_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long parg)
+static int mantis_ca_read_attr_mem(struct dvb_ca_en50221 *en50221, int slot, int addr)
{
- return 0;
+ struct mantis_ca *ca = en50221->data;
+
+ if (slot != 0)
+ return -EINVAL;
+
+ return mantis_hif_read_mem(ca, addr);
}
-static int mantis_ca_open(struct inode *inode, struct file *file)
+static int mantis_ca_write_attr_mem(struct dvb_ca_en50221 *en50221, int slot, int addr, u8 data)
{
- return 0;
+ struct mantis_ca *ca = en50221->data;
+
+ if (slot != 0)
+ return -EINVAL;
+
+ return mantis_hif_write_mem(ca, addr, data);
}
-static int mantis_ca_release(struct inode *inode, struct file *file)
+static int mantis_ca_read_cam_ctl(struct dvb_ca_en50221 *en50221, int slot, u8 addr)
{
- return 0;
+ struct mantis_ca *ca = en50221->data;
+
+ if (slot != 0)
+ return -EINVAL;
+
+ return mantis_hif_read_iom(ca, addr);
}
-static ssize_t mantis_ca_read(struct file *file, char __user *buffer, size_t count, loff_t *ofset)
+static int mantis_ca_write_cam_ctl(struct dvb_ca_en50221 *en50221, int slot, u8 addr, u8 data)
{
- struct dvb_device *dvbdev = file->private_data;
- struct mantis_ca *ca = dvbdev->priv;
+ struct mantis_ca *ca = en50221->data;
- int status;
+ if (slot != 0)
+ return -EINVAL;
- return 0;
-error:
- return status;
+ return mantis_hif_write_iom(ca, addr, data);
}
-static ssize_t mantis_ca_write(struct file *file, const char __user *buffer, size_t count, loff_t *offset)
+static int mantis_ca_slot_reset(struct dvb_ca_en50221 *en50221, int slot)
{
- struct dvb_device *dvbdev = file->private_data;
- struct mantis_ca *ca = dvbdev->priv;
+ return 0;
+}
- int status;
+static int mantis_ca_slot_shutdown(struct dvb_ca_en50221 *en50221, int slot)
+{
+ return 0;
+}
+static int mantis_ts_control(struct dvb_ca_en50221 *en50221, int slot)
+{
return 0;
-error:
- return status;
}
-static struct file_operations mantis_fops = {
- .owner = THIS_MODULE,
- .ioctl = mantis_ca_ioctl,
- .open = mantis_ca_open,
- .release = mantis_ca_release,
- .read = mantis_ca_read,
- .write = mantis_ca_write,
-};
-
-static struct dvb_device mantis_ca = {
- .priv = NULL,
- .users = 1,
- .readers = 1,
- .writers = 1,
- .fops = &mantis_fops,
-};
-
-struct dvb_device *mantis_ca_init(struct mantis_pci *mantis)
+static int mantis_slot_status(struct dvb_ca_en50221 *en50221, int slot, int open)
{
- int ret;
+ return 0;
+}
- struct dvb_device *dvbdev;
+int mantis_ca_init(struct mantis_pci *mantis)
+{
struct dvb_adapter *dvb_adapter = &mantis->dvb_adapter;
struct mantis_ca *ca;
+ int ca_flags = 0, result;
if (!(ca = kzalloc(sizeof (struct mantis_ca), GFP_KERNEL))) {
dprintk(verbose, MANTIS_ERROR, 1, "Out of memory!, exiting ..");
- return NULL;
+ result = -ENOMEM;
+ goto err;
}
ca->ca_priv = mantis;
-
- dprintk(verbose, MANTIS_ERROR, 0, "CA: Registering Mantis Adapter(%d) Slot(0)\n", mantis->num);
- if (dvb_register_device(dvb_adapter, &dvbdev, &mantis_ca, ca, DVB_DEVICE_CA) == 0) {
- ca->ca_dev = dvbdev;
- mantis->mantis_ca = ca;
- mantis_evmgr_init(ca);
- return ca->ca_dev;
+ mantis->mantis_ca = ca;
+
+ /* register CA interface */
+ ca->en50221.owner = THIS_MODULE;
+ ca->en50221.read_attribute_mem = mantis_ca_read_attr_mem;
+ ca->en50221.write_attribute_mem = mantis_ca_write_attr_mem;
+ ca->en50221.read_cam_control = mantis_ca_read_cam_ctl;
+ ca->en50221.write_cam_control = mantis_ca_write_cam_ctl;
+ ca->en50221.slot_reset = mantis_ca_slot_reset;
+ ca->en50221.slot_shutdown = mantis_ca_slot_shutdown;
+ ca->en50221.slot_ts_enable = mantis_ts_control;
+ ca->en50221.poll_slot_status = mantis_slot_status;
+ ca->en50221.data = ca;
+
+ dprintk(verbose, MANTIS_ERROR, 1, "Registering EN50221 device");
+ if ((result = dvb_ca_en50221_init(dvb_adapter, &ca->en50221, ca_flags, 1)) != 0) {
+ dprintk(verbose, MANTIS_ERROR, 1, "EN50221: Initialization failed");
+ goto err;
}
+ dprintk(verbose, MANTIS_ERROR, 1, "Registered EN50221 device");
+ mantis_evmgr_init(ca);
return 0;
-
-error:
- if (ca != NULL) {
- dprintk(verbose, MANTIS_ERROR, 1, "Error ..");
- if (ca->ca_dev != NULL)
- dvb_unregister_device(ca->ca_dev);
-
- kfree(ca);
- }
- return NULL;
+err:
+ kfree(ca);
+ return result;
}
void mantis_ca_exit(struct mantis_pci *mantis)
@@ -119,9 +127,8 @@ void mantis_ca_exit(struct mantis_pci *mantis)
struct mantis_ca *ca = mantis->mantis_ca;
mantis_evmgr_exit(ca);
- dprintk(verbose, MANTIS_ERROR, 0, "CA: Unregister Mantis Adapter(%d) Slot(0)\n", mantis->num);
- if (ca->ca_dev)
- dvb_unregister_device(ca->ca_dev);
+ dprintk(verbose, MANTIS_ERROR, 1, "Unregistering EN50221 device");
+ dvb_ca_en50221_release(&ca->en50221);
kfree(ca);
}
diff --git a/drivers/media/dvb/mantis/mantis_common.h b/drivers/media/dvb/mantis/mantis_common.h
index 7f1cfad74883..0aa4001dea9c 100644
--- a/drivers/media/dvb/mantis/mantis_common.h
+++ b/drivers/media/dvb/mantis/mantis_common.h
@@ -151,7 +151,7 @@ extern int mantis_dvb_exit(struct mantis_pci *mantis);
extern void mantis_dma_xfer(unsigned long data);
extern void gpio_set_bits(struct mantis_pci *mantis, u32 bitpos, u8 value);
-extern struct dvb_device *mantis_ca_init(struct mantis_pci *mantis);
+extern int mantis_ca_init(struct mantis_pci *mantis);
extern void mantis_ca_exit(struct mantis_pci *mantis);
diff --git a/drivers/media/dvb/mantis/mantis_hif.c b/drivers/media/dvb/mantis/mantis_hif.c
index 42aedf7a0147..6a1ea96c16d9 100644
--- a/drivers/media/dvb/mantis/mantis_hif.c
+++ b/drivers/media/dvb/mantis/mantis_hif.c
@@ -111,10 +111,10 @@ int mantis_hif_write_mem(struct mantis_ca *ca, u32 addr, u8 data)
return 0;
}
-int mantis_hif_read_iom(struct mantis_ca *ca, u32 addr, u32 count, u32 *data)
+int mantis_hif_read_iom(struct mantis_ca *ca, u32 addr)
{
struct mantis_pci *mantis = ca->ca_priv;
- u32 hif_addr = 0;
+ u32 data, hif_addr = 0;
hif_addr &= ~MANTIS_GPIF_PCMCIAREG;
hif_addr |= MANTIS_GPIF_HIFRDWRN;
@@ -131,14 +131,14 @@ int mantis_hif_read_iom(struct mantis_ca *ca, u32 addr, u32 count, u32 *data)
}
udelay(50);
ca->hif_job_queue &= ~MANTIS_HIF_IOMRD;
- *data = mmread(MANTIS_GPIF_HIFDIN);
+ data = mmread(MANTIS_GPIF_HIFDIN);
hif_addr |= MANTIS_GPIF_PCMCIAREG;
mmwrite(hif_addr, MANTIS_GPIF_HIFADDR);
- return 0;
+ return data;
}
-int mantis_hif_write_iom(struct mantis_ca *ca, u32 addr, u32 data)
+int mantis_hif_write_iom(struct mantis_ca *ca, u32 addr, u8 data)
{
struct mantis_pci *mantis = ca->ca_priv;
u32 hif_addr = 0;
diff --git a/drivers/media/dvb/mantis/mantis_link.h b/drivers/media/dvb/mantis/mantis_link.h
index 478900ea184d..23ff2d6aadbc 100644
--- a/drivers/media/dvb/mantis/mantis_link.h
+++ b/drivers/media/dvb/mantis/mantis_link.h
@@ -22,6 +22,7 @@
#define __MANTIS_LINK_H
#include <linux/workqueue.h>
+#include "dvb_ca_en50221.h"
enum mantis_sbuf_status {
MANTIS_SBUF_DATA_AVAIL = 1,
@@ -56,8 +57,10 @@ struct mantis_ca {
enum mantis_slot_state slot_state;
- struct dvb_device *ca_dev;
+// struct dvb_device *ca_dev;
void *ca_priv;
+
+ struct dvb_ca_en50221 en50221;
};
/* CA */
@@ -73,7 +76,7 @@ extern int mantis_hif_init(struct mantis_ca *ca);
extern void mantis_hif_exit(struct mantis_ca *ca);
extern int mantis_hif_read_mem(struct mantis_ca *ca, u32 addr);
extern int mantis_hif_write_mem(struct mantis_ca *ca, u32 addr, u8 data);
-extern int mantis_hif_read_iom(struct mantis_ca *ca, u32 addr, u32 count, u32 *data);
-extern int mantis_hif_write_iom(struct mantis_ca *ca, u32 addr, u32 data);
+extern int mantis_hif_read_iom(struct mantis_ca *ca, u32 addr);
+extern int mantis_hif_write_iom(struct mantis_ca *ca, u32 addr, u8 data);
#endif // __MANTIS_LINK_H