Commit 6053240f authored by Manu Abraham's avatar Manu Abraham Committed by Mauro Carvalho Chehab

V4L/DVB (13743): [Mantis CA] Use DVB_CA Tuple parser

Signed-off-by: default avatarManu Abraham <manu@linuxtv.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent c9a750c9
......@@ -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);
}
......@@ -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);
......
......@@ -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;
......
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment