1
0
mirror of https://github.com/DigitalDevices/dddvb.git synced 2023-10-10 13:37:43 +02:00

allow compilation against kerne dvb_core if KERNEL_DVB_CORE defined

This commit is contained in:
rjkm 2022-02-12 15:14:44 +01:00
parent e0fd8a0f35
commit 9b458a72de
11 changed files with 137 additions and 22 deletions

6
Kbuild
View File

@ -2,6 +2,12 @@
# Makefile for the kernel multimedia device drivers. # Makefile for the kernel multimedia device drivers.
# #
ifeq ($(KERNEL_DVB_CORE),y)
obj-y := ddbridge/ \
frontends/
else
obj-y := dvb-core/ \ obj-y := dvb-core/ \
ddbridge/ \ ddbridge/ \
frontends/ frontends/
endif

View File

@ -1,12 +1,16 @@
EXTRA_CFLAGS += -DCONFIG_DVB_CXD2843 -DCONFIG_DVB_LNBP21 -DCONFIG_DVB_STV090x -DCONFIG_DVB_STV6110x -DCONFIG_DVB_DRXK -DCONFIG_DVB_STV0910 -DCONFIG_DVB_STV6111 -DCONFIG_DVB_LNBH25 -DCONFIG_DVB_MXL5XX -DCONFIG_DVB_CXD2099 -DCONFIG_DVB_NET EXTRA_CFLAGS += -DCONFIG_DVB_CXD2843 -DCONFIG_DVB_LNBP21 -DCONFIG_DVB_STV090x -DCONFIG_DVB_STV6110x -DCONFIG_DVB_DRXK -DCONFIG_DVB_STV0910 -DCONFIG_DVB_STV6111 -DCONFIG_DVB_LNBH25 -DCONFIG_DVB_MXL5XX -DCONFIG_DVB_CXD2099 -DCONFIG_DVB_NET
ddbridge-objs = ddbridge-main.o ddbridge-hw.o ddbridge-i2c.o ddbridge-ns.o ddbridge-modulator.o ddbridge-core.o ddbridge-io.o ddbridge-ci.o ddbridge-max.o ddbridge-mci.o ddbridge-sx8.o ddbridge-m4.o dvb_netstream.o ddbridge-objs = ddbridge-main.o ddbridge-hw.o ddbridge-i2c.o ddbridge-ns.o ddbridge-modulator.o ddbridge-core.o ddbridge-io.o ddbridge-ci.o ddbridge-max.o ddbridge-mci.o ddbridge-sx8.o ddbridge-m4.o dvb_netstream.o
octonet-objs = octonet-main.o ddbridge-hw.o ddbridge-i2c.o ddbridge-ns.o ddbridge-modulator.o ddbridge-core.o ddbridge-io.o ddbridge-ci.o ddbridge-max.o ddbridge-mci.o ddbridge-sx8.o ddbridge-m4.o dvb_netstream.o octonet-objs = octonet-main.o ddbridge-hw.o ddbridge-i2c.o ddbridge-ns.o ddbridge-modulator.o ddbridge-core.o ddbridge-io.o ddbridge-ci.o ddbridge-max.o ddbridge-mci.o ddbridge-sx8.o ddbridge-m4.o dvb_netstream.o
#mci-objs = ddbridge-mci.o ddbridge-sx8.o ddbridge-m4.o ddbridge-io.o #mci-objs = ddbridge-mci.o ddbridge-sx8.o ddbridge-m4.o ddbridge-io.o
obj-$(CONFIG_DVB_DDBRIDGE) += ddbridge.o #mci.o obj-$(CONFIG_DVB_DDBRIDGE) += ddbridge.o #mci.o
ifneq ($(KERNEL_DVB_CORE),y)
obj-$(CONFIG_DVB_OCTONET) += octonet.o obj-$(CONFIG_DVB_OCTONET) += octonet.o
endif
#EXTRA_CFLAGS += -Idrivers/media/dvb/frontends -Idrivers/media/dvb-frontends #EXTRA_CFLAGS += -Idrivers/media/dvb/frontends -Idrivers/media/dvb-frontends
#EXTRA_CFLAGS += -Idrivers/media/common/tuners #EXTRA_CFLAGS += -Idrivers/media/common/tuners

View File

@ -95,6 +95,70 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
/****************************************************************************/ /****************************************************************************/
/****************************************************************************/ /****************************************************************************/
/* copied from dvb-core/dvbdev.c because kernel version does not export it */
int ddb_dvb_usercopy(struct file *file,
unsigned int cmd, unsigned long arg,
int (*func)(struct file *file,
unsigned int cmd, void *arg))
{
char sbuf[128];
void *mbuf = NULL;
void *parg = NULL;
int err = -EINVAL;
/* Copy arguments into temp kernel buffer */
switch (_IOC_DIR(cmd)) {
case _IOC_NONE:
/*
* For this command, the pointer is actually an integer
* argument.
*/
parg = (void *) arg;
break;
case _IOC_READ: /* some v4l ioctls are marked wrong ... */
case _IOC_WRITE:
case (_IOC_WRITE | _IOC_READ):
if (_IOC_SIZE(cmd) <= sizeof(sbuf)) {
parg = sbuf;
} else {
/* too big to allocate from stack */
mbuf = kmalloc(_IOC_SIZE(cmd), GFP_KERNEL);
if (NULL == mbuf)
return -ENOMEM;
parg = mbuf;
}
err = -EFAULT;
if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd)))
goto out;
break;
}
/* call driver */
if ((err = func(file, cmd, parg)) == -ENOIOCTLCMD)
err = -ENOTTY;
if (err < 0)
goto out;
/* Copy results into user buffer */
switch (_IOC_DIR(cmd))
{
case _IOC_READ:
case (_IOC_WRITE | _IOC_READ):
if (copy_to_user((void __user *)arg, parg, _IOC_SIZE(cmd)))
err = -EFAULT;
break;
}
out:
kfree(mbuf);
return err;
}
/****************************************************************************/
struct ddb_irq *ddb_irq_set(struct ddb *dev, u32 link, u32 nr, struct ddb_irq *ddb_irq_set(struct ddb *dev, u32 link, u32 nr,
void (*handler)(void *), void *data) void (*handler)(void *), void *data)
{ {
@ -998,7 +1062,7 @@ static struct dvb_device dvbdev_ci = {
static long mod_ioctl(struct file *file, static long mod_ioctl(struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
return dvb_usercopy(file, cmd, arg, ddbridge_mod_do_ioctl); return ddb_dvb_usercopy(file, cmd, arg, ddbridge_mod_do_ioctl);
} }
static const struct file_operations mod_fops = { static const struct file_operations mod_fops = {
@ -2971,7 +3035,7 @@ static int nsd_do_ioctl(struct file *file, unsigned int cmd, void *parg)
static long nsd_ioctl(struct file *file, static long nsd_ioctl(struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
return dvb_usercopy(file, cmd, arg, nsd_do_ioctl); return ddb_dvb_usercopy(file, cmd, arg, nsd_do_ioctl);
} }
static const struct file_operations nsd_fops = { static const struct file_operations nsd_fops = {

View File

@ -516,7 +516,7 @@ static int base_init(struct mci_base *mci_base)
return 0; return 0;
} }
struct mci_cfg ddb_max_m4_cfg = { static struct mci_cfg ddb_max_m4_cfg = {
.type = 0, .type = 0,
.fe_ops = &m4_ops, .fe_ops = &m4_ops,
.base_size = sizeof(struct m4_base), .base_size = sizeof(struct m4_base),
@ -524,3 +524,8 @@ struct mci_cfg ddb_max_m4_cfg = {
.init = init, .init = init,
.base_init = base_init, .base_init = base_init,
}; };
struct dvb_frontend *ddb_m4_attach(struct ddb_input *input, int nr, int tuner)
{
return ddb_mci_attach(input, &ddb_max_m4_cfg, nr, tuner);
}

View File

@ -472,7 +472,8 @@ int ddb_fe_attach_mxl5xx(struct ddb_input *input)
tuner = demod & 3; tuner = demod & 3;
if (fmode >= 3) if (fmode >= 3)
tuner = 0; tuner = 0;
dvb->fe = dvb_attach(mxl5xx_attach, i2c, &cfg, demod, tuner); dvb->fe = dvb_attach(mxl5xx_attach, i2c, &cfg,
demod, tuner, &dvb->set_input);
if (!dvb->fe) { if (!dvb->fe) {
dev_err(dev->dev, "No MXL5XX found!\n"); dev_err(dev->dev, "No MXL5XX found!\n");
return -ENODEV; return -ENODEV;
@ -490,13 +491,17 @@ int ddb_fe_attach_mxl5xx(struct ddb_input *input)
dvb->fe->ops.diseqc_send_master_cmd = max_send_master_cmd; dvb->fe->ops.diseqc_send_master_cmd = max_send_master_cmd;
dvb->fe->ops.diseqc_send_burst = max_send_burst; dvb->fe->ops.diseqc_send_burst = max_send_burst;
dvb->fe->sec_priv = input; dvb->fe->sec_priv = input;
dvb->set_input = dvb->fe->ops.set_input; #ifndef KERNEL_DVB_CORE
dvb->fe->ops.set_input = max_set_input; dvb->fe->ops.set_input = max_set_input;
#endif
dvb->input = tuner; dvb->input = tuner;
return 0; return 0;
} }
/* MAX MCI related functions */ /* MAX MCI related functions */
struct dvb_frontend *ddb_sx8_attach(struct ddb_input *input, int nr, int tuner,
int (**fn_set_input)(struct dvb_frontend *fe, int input));
struct dvb_frontend *ddb_m4_attach(struct ddb_input *input, int nr, int tuner);
int ddb_fe_attach_mci(struct ddb_input *input, u32 type) int ddb_fe_attach_mci(struct ddb_input *input, u32 type)
{ {
@ -505,25 +510,23 @@ int ddb_fe_attach_mci(struct ddb_input *input, u32 type)
struct ddb_port *port = input->port; struct ddb_port *port = input->port;
struct ddb_link *link = &dev->link[port->lnr]; struct ddb_link *link = &dev->link[port->lnr];
int demod, tuner; int demod, tuner;
struct mci_cfg cfg;
int fm = fmode; int fm = fmode;
demod = input->nr; demod = input->nr;
tuner = demod & 3; tuner = demod & 3;
switch (type) { switch (type) {
case DDB_TUNER_MCI_SX8: case DDB_TUNER_MCI_SX8:
cfg = ddb_max_sx8_cfg;
if (fm >= 3) if (fm >= 3)
tuner = 0; tuner = 0;
dvb->fe = ddb_sx8_attach(input, demod, tuner, &dvb->set_input);
break; break;
case DDB_TUNER_MCI_M4: case DDB_TUNER_MCI_M4:
fm = 0; fm = 0;
cfg = ddb_max_m4_cfg; dvb->fe = ddb_m4_attach(input, demod, tuner);
break; break;
default: default:
return -EINVAL; return -EINVAL;
} }
dvb->fe = ddb_mci_attach(input, &cfg, demod, tuner);
if (!dvb->fe) { if (!dvb->fe) {
dev_err(dev->dev, "No MCI card found!\n"); dev_err(dev->dev, "No MCI card found!\n");
return -ENODEV; return -ENODEV;
@ -545,8 +548,9 @@ int ddb_fe_attach_mci(struct ddb_input *input, u32 type)
case DDB_TUNER_MCI_M4: case DDB_TUNER_MCI_M4:
break; break;
default: default:
dvb->set_input = dvb->fe->ops.set_input; #ifndef KERNEL_DVB_CORE
dvb->fe->ops.set_input = max_set_input; dvb->fe->ops.set_input = max_set_input;
#endif
break; break;
} }
dvb->input = tuner; dvb->input = tuner;

View File

@ -23,8 +23,13 @@
#include "ddbridge.h" #include "ddbridge.h"
#include "ddbridge-io.h" #include "ddbridge-io.h"
#include "ddbridge-ioctl.h"
#ifdef KERNEL_DVB_CORE
#include "../include/linux/dvb/mod.h"
#else
#include <linux/dvb/mod.h> #include <linux/dvb/mod.h>
#endif
#include <linux/gcd.h> #include <linux/gcd.h>
/****************************************************************************/ /****************************************************************************/

View File

@ -23,7 +23,6 @@
#include "ddbridge.h" #include "ddbridge.h"
#include "ddbridge-io.h" #include "ddbridge-io.h"
#include "ddbridge-i2c.h"
#include "ddbridge-mci.h" #include "ddbridge-mci.h"
static int default_mod = 3; static int default_mod = 3;
@ -556,7 +555,10 @@ static int set_input(struct dvb_frontend *fe, int input)
mutex_lock(&state->lock); mutex_lock(&state->lock);
stop_iq(fe); stop_iq(fe);
stop(fe); stop(fe);
state->mci.tuner = p->input = input; state->mci.tuner = input;
#ifndef KERNEL_DVB_CORE
p->input = input;
#endif
mutex_unlock(&state->lock); mutex_unlock(&state->lock);
return 0; return 0;
} }
@ -582,7 +584,6 @@ static int get_frontend(struct dvb_frontend *fe, struct dtv_frontend_properties
static struct dvb_frontend_ops sx8_ops = { static struct dvb_frontend_ops sx8_ops = {
.delsys = { SYS_DVBS, SYS_DVBS2 }, .delsys = { SYS_DVBS, SYS_DVBS2 },
.xbar = { 4, 0, 8 }, /* tuner_max, demod id, demod_max */
.info = { .info = {
.name = "DVB-S/S2X", .name = "DVB-S/S2X",
.frequency_min_hz = 950000000, .frequency_min_hz = 950000000,
@ -602,7 +603,10 @@ static struct dvb_frontend_ops sx8_ops = {
.tune = tune, .tune = tune,
.release = release, .release = release,
.read_status = read_status, .read_status = read_status,
#ifndef KERNEL_DVB_CORE
.xbar = { 4, 0, 8 }, /* tuner_max, demod id, demod_max */
.set_input = set_input, .set_input = set_input,
#endif
.set_lna = set_lna, .set_lna = set_lna,
.sleep = sleep, .sleep = sleep,
}; };
@ -612,8 +616,10 @@ static int init(struct mci *mci)
struct sx8 *state = (struct sx8 *) mci; struct sx8 *state = (struct sx8 *) mci;
state->mci.demod = SX8_DEMOD_NONE; state->mci.demod = SX8_DEMOD_NONE;
#ifndef KERNEL_DVB_CORE
mci->fe.ops.xbar[1] = mci->nr; mci->fe.ops.xbar[1] = mci->nr;
mci->fe.dtv_property_cache.input = mci->tuner; mci->fe.dtv_property_cache.input = mci->tuner;
#endif
mutex_init(&state->lock); mutex_init(&state->lock);
return 0; return 0;
} }
@ -625,7 +631,7 @@ static int base_init(struct mci_base *mci_base)
return 0; return 0;
} }
struct mci_cfg ddb_max_sx8_cfg = { static struct mci_cfg ddb_max_sx8_cfg = {
.type = 0, .type = 0,
.fe_ops = &sx8_ops, .fe_ops = &sx8_ops,
.base_size = sizeof(struct sx8_base), .base_size = sizeof(struct sx8_base),
@ -633,3 +639,10 @@ struct mci_cfg ddb_max_sx8_cfg = {
.init = init, .init = init,
.base_init = base_init, .base_init = base_init,
}; };
struct dvb_frontend *ddb_sx8_attach(struct ddb_input *input, int nr, int tuner,
int (**fn_set_input)(struct dvb_frontend *fe, int input))
{
*fn_set_input = set_input;
return ddb_mci_attach(input, &ddb_max_sx8_cfg, nr, tuner);
}

View File

@ -26,6 +26,9 @@
#include <linux/net.h> #include <linux/net.h>
#include "dvb_netstream.h" #include "dvb_netstream.h"
int ddb_dvb_usercopy(struct file *file, unsigned int cmd, unsigned long arg,
int (*func)(struct file *file, unsigned int cmd, void *arg));
static ssize_t ns_write(struct file *file, const char *buf, static ssize_t ns_write(struct file *file, const char *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
@ -211,7 +214,7 @@ static int do_ioctl(struct file *file, unsigned int cmd, void *parg)
static long ns_ioctl(struct file *file, static long ns_ioctl(struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
return dvb_usercopy(file, cmd, arg, do_ioctl); return ddb_dvb_usercopy(file, cmd, arg, do_ioctl);
} }
static const struct file_operations ns_fops = { static const struct file_operations ns_fops = {

View File

@ -13,4 +13,3 @@ dvb-core-objs := dvbdev.o dmxdev.o dvb_demux.o \
obj-$(CONFIG_DVB_CORE) += dvb-core.o obj-$(CONFIG_DVB_CORE) += dvb-core.o
EXTRA_CFLAGS += -DCONFIG_DVB_DYNAMIC_MINORS -DCONFIG_DVB_NET EXTRA_CFLAGS += -DCONFIG_DVB_DYNAMIC_MINORS -DCONFIG_DVB_NET
#NOSTDINC_FLAGS += -I$(KBUILD_EXTMOD)/include -I$(KBUILD_EXTMOD)/include/linux

View File

@ -825,13 +825,15 @@ static int set_input(struct dvb_frontend *fe, int input)
struct mxl *state = fe->demodulator_priv; struct mxl *state = fe->demodulator_priv;
struct dtv_frontend_properties *p = &fe->dtv_property_cache; struct dtv_frontend_properties *p = &fe->dtv_property_cache;
state->tuner = p->input = input; state->tuner = input;
#ifndef KERNEL_DVB_CORE
p->input = input;
#endif
return 0; return 0;
} }
static struct dvb_frontend_ops mxl_ops = { static struct dvb_frontend_ops mxl_ops = {
.delsys = { SYS_DVBS, SYS_DVBS2, SYS_DSS }, .delsys = { SYS_DVBS, SYS_DVBS2, SYS_DSS },
.xbar = { 4, 0, 8 }, /* tuner_max, demod id, demod_max */
.info = { .info = {
.name = "MXL5XX", .name = "MXL5XX",
.frequency_min_hz = 300000000, .frequency_min_hz = 300000000,
@ -856,7 +858,10 @@ static struct dvb_frontend_ops mxl_ops = {
.read_signal_strength = read_signal_strength, .read_signal_strength = read_signal_strength,
.read_ucblocks = read_ucblocks, .read_ucblocks = read_ucblocks,
.get_frontend = get_frontend, .get_frontend = get_frontend,
#ifndef KERNEL_DVB_CORE
.set_input = set_input, .set_input = set_input,
.xbar = { 4, 0, 8 }, /* tuner_max, demod id, demod_max */
#endif
.diseqc_send_master_cmd = send_master_cmd, .diseqc_send_master_cmd = send_master_cmd,
}; };
@ -1873,7 +1878,8 @@ static int probe(struct mxl *state, struct mxl5xx_cfg *cfg)
struct dvb_frontend *mxl5xx_attach(struct i2c_adapter *i2c, struct dvb_frontend *mxl5xx_attach(struct i2c_adapter *i2c,
struct mxl5xx_cfg *cfg, struct mxl5xx_cfg *cfg,
u32 demod, u32 tuner) u32 demod, u32 tuner,
int (**fn_set_input)(struct dvb_frontend *, int))
{ {
struct mxl *state; struct mxl *state;
struct mxl_base *base; struct mxl_base *base;
@ -1913,9 +1919,12 @@ struct dvb_frontend *mxl5xx_attach(struct i2c_adapter *i2c,
list_add(&base->mxllist, &mxllist); list_add(&base->mxllist, &mxllist);
} }
state->fe.ops = mxl_ops; state->fe.ops = mxl_ops;
#ifndef KERNEL_DVB_CORE
state->fe.ops.xbar[1] = demod; state->fe.ops.xbar[1] = demod;
state->fe.demodulator_priv = state;
state->fe.dtv_property_cache.input = tuner; state->fe.dtv_property_cache.input = tuner;
#endif
state->fe.demodulator_priv = state;
*fn_set_input = set_input;
list_add(&state->mxl, &base->mxls); list_add(&state->mxl, &base->mxls);
return &state->fe; return &state->fe;

View File

@ -23,12 +23,15 @@ struct mxl5xx_cfg {
extern struct dvb_frontend *mxl5xx_attach(struct i2c_adapter *i2c, extern struct dvb_frontend *mxl5xx_attach(struct i2c_adapter *i2c,
struct mxl5xx_cfg *cfg, struct mxl5xx_cfg *cfg,
u32 demod, u32 tuner); u32 demod, u32 tuner,
int (**fn_set_input)(struct dvb_frontend *, int));
#else #else
static inline struct dvb_frontend *mxl5xx_attach(struct i2c_adapter *i2c, static inline struct dvb_frontend *mxl5xx_attach(struct i2c_adapter *i2c,
struct mxl5xx_cfg *cfg, struct mxl5xx_cfg *cfg,
u32 demod, u32 tuner) u32 demod, u32 tuner,
int (**fn_set_input)(struct dvb_frontend *, int))
{ {
pr_warn("%s: driver disabled by Kconfig\n", __func__); pr_warn("%s: driver disabled by Kconfig\n", __func__);
return NULL; return NULL;