summaryrefslogtreecommitdiff
path: root/linux
diff options
context:
space:
mode:
Diffstat (limited to 'linux')
-rw-r--r--linux/drivers/media/common/saa7146.h1
-rw-r--r--linux/drivers/media/common/saa7146_core.c5
-rw-r--r--linux/drivers/media/dvb/ttpci-budget/budget-av.c176
-rw-r--r--linux/drivers/media/dvb/ttpci-budget/budget.c20
-rw-r--r--linux/drivers/media/dvb/ttpci-budget/budget.h6
-rw-r--r--linux/drivers/media/dvb/ttpci/av7110.c14
-rw-r--r--linux/drivers/media/video/mxb.c14
7 files changed, 176 insertions, 60 deletions
diff --git a/linux/drivers/media/common/saa7146.h b/linux/drivers/media/common/saa7146.h
index 907989cfe..b5ee99d64 100644
--- a/linux/drivers/media/common/saa7146.h
+++ b/linux/drivers/media/common/saa7146.h
@@ -89,7 +89,6 @@ struct saa7146_extension
#endif
/* extension functions */
- int (*preinit)(struct saa7146_dev*);
int (*probe)(struct saa7146_dev*, unsigned int subvendor, unsigned int subdevice);
int (*attach)(struct saa7146_dev *, struct saa7146_sub_info *);
int (*detach)(struct saa7146_dev*);
diff --git a/linux/drivers/media/common/saa7146_core.c b/linux/drivers/media/common/saa7146_core.c
index 432fa4f4e..bd079b0e5 100644
--- a/linux/drivers/media/common/saa7146_core.c
+++ b/linux/drivers/media/common/saa7146_core.c
@@ -229,11 +229,6 @@ void try_attach_extension_and_device(struct saa7146_dev *dev, struct saa7146_ext
return;
}
- if( 0 != ext->preinit(dev) ) {
- DEB_S(("ext->preinit() failed for %p. skipping.\n",dev));
- return;
- }
-
if( 0 != ext->probe) {
if( 0 != ext->probe(dev, dev->pci->subsystem_vendor, dev->pci->subsystem_device) ) {
DEB_D(("ext->probe() failed for %p. skipping device.\n",dev));
diff --git a/linux/drivers/media/dvb/ttpci-budget/budget-av.c b/linux/drivers/media/dvb/ttpci-budget/budget-av.c
index 8e6ed0e76..729ac0b35 100644
--- a/linux/drivers/media/dvb/ttpci-budget/budget-av.c
+++ b/linux/drivers/media/dvb/ttpci-budget/budget-av.c
@@ -31,9 +31,13 @@
*/
#include "budget.h"
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51)
+ #define KBUILD_MODNAME budget_av
+#endif
-static int budget_debug = 0;
+#include "saa7146_vv.h"
+static int budget_debug = 0;
static char *knc1 = "KNC1 DVB-S";
static struct saa7146_sub_info sub_data[] = {
@@ -50,6 +54,14 @@ static struct saa7146_sub_info sub_data[] = {
}
};
+struct budget_av_data
+{
+ struct video_device vd;
+ int registered;
+
+ int cur_input;
+};
+
/****************************************************************************
* INITIALIZATION
****************************************************************************/
@@ -124,7 +136,7 @@ static int
init_saa7113(struct budget_s *budget)
{
const u8 *data=saa7113_tab;
-
+
if (i2c_writereg(budget->i2c_bus, 0x4a, 0x01, 0x08)!=1) {
DEB_D(("saa7113: not found on KNC card\n"));
return -1;
@@ -139,28 +151,63 @@ init_saa7113(struct budget_s *budget)
}
static
-int this_budget_detach(struct saa7146_dev* dev)
+int av_detach(struct saa7146_dev* dev)
{
+ struct budget_s *budget = (struct budget_s*)dev->ext_priv;
+ struct budget_av_data *data = budget->priv;
+
+ DEB_EE(("dev: %p\n",dev));
saa7146_setgpio(dev, 0, SAA7146_GPIO_OUTLO);
ddelay(20);
+
+ if( 0 != data->registered ) {
+ saa7146_unregister_device(&data->vd,dev);
+ data->registered = 0;
+ }
+ if( NULL != budget->priv ) {
+ kfree(data);
+ budget->priv = NULL;
+
+ }
return budget_detach(dev);
}
+void knc1_setinput(struct budget_s *budget, int i)
+{
+ if (i) {
+ i2c_writereg(budget->i2c_bus, 0x4a, 0x02, 0xc7);
+ i2c_writereg(budget->i2c_bus, 0x4a, 0x09, 0x80);
+ } else {
+ i2c_writereg(budget->i2c_bus, 0x4a, 0x02, 0xc0);
+ i2c_writereg(budget->i2c_bus, 0x4a, 0x09, 0x00);
+ }
+}
+
static
-int this_budget_attach (struct saa7146_dev* dev, struct saa7146_sub_info *info)
+int av_attach (struct saa7146_dev* dev, struct saa7146_sub_info *info)
{
struct budget_s *budget = NULL;
-
- if (budget->card_type->type==DVB_CARD_KNC1) {
+ struct budget_av_data *data = NULL;
+
+ DEB_EE(("dev: %p\n",dev));
+ if (info->type != DVB_CARD_KNC1) {
return -1;
}
-
+
+ data = kmalloc(sizeof(struct budget_av_data), GFP_KERNEL);
+ if( NULL == data ) {
+ return -ENOMEM;
+ }
+ memset(data,0,sizeof(*data));
+
if( 0 != budget_attach(dev,info)) {
+ kfree(data);
return -1;
}
budget = (struct budget_s*)dev->ext_priv;
-
+ budget->priv = data;
+
/* knc1 initialization */
saa7146_write(dev, DD1_STREAM_B, 0x04000000);
saa7146_write(dev, DD1_INIT, 0x07000600);
@@ -172,10 +219,22 @@ int this_budget_attach (struct saa7146_dev* dev, struct saa7146_sub_info *info)
saa7146_setgpio(dev, 0, SAA7146_GPIO_OUTHI);
ddelay(50);
if( 0 != init_saa7113(budget)) {
- this_budget_detach(dev);
+ av_detach(dev);
return -1;
}
+ saa7146_vv_init(dev);
+ if( 0 != saa7146_register_device(&data->vd, dev, "knc1", VFL_TYPE_GRABBER)) {
+ ERR(("cannot register capture v4l2 device.\n"));
+ av_detach(dev);
+ return -1;
+ }
+ data->registered = 1;
+
+ /* beware: this modifies dev->vv ... */
+ saa7146_set_hps_source_and_sync(dev, SAA7146_HPS_SOURCE_PORT_A, SAA7146_HPS_SYNC_PORT_A);
+ knc1_setinput(budget, 0);
+
/* what is this? since we don't support open()/close()
notifications, we simply put this into the release handler... */
// saa7146_setgpio(dev, 0, SAA7146_GPIO_OUTLO);
@@ -186,9 +245,101 @@ int this_budget_attach (struct saa7146_dev* dev, struct saa7146_sub_info *info)
// FIXME: cope with error here!
budget_register(budget);
- printk(KERN_INFO "budget: found budget card w/ video-in.\n");
+ printk(KERN_INFO "budget: found budget card w/ video-in '%s'.\n",*budget->card->name);
+
+ return 0;
}
+#define KNC1_INPUTS 2
+static struct v4l2_input knc1_inputs[KNC1_INPUTS] = {
+ { 0, "Composite", V4L2_INPUT_TYPE_TUNER, 1, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 },
+ { 1, "S_Video", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 },
+};
+
+static struct saa7146_extension_ioctls ioctls[] = {
+ { VIDIOC_ENUMINPUT, SAA7146_EXCLUSIVE },
+ { VIDIOC_G_INPUT, SAA7146_EXCLUSIVE },
+ { VIDIOC_S_INPUT, SAA7146_EXCLUSIVE },
+ { 0, 0 }
+};
+
+static int av_ioctl(struct saa7146_dev *dev, unsigned int cmd, void *arg)
+{
+ struct budget_s *budget = (struct budget_s*)dev->ext_priv;
+ struct budget_av_data *data = budget->priv;
+/*
+ struct saa7146_vv *vv = dev->vv_data;
+*/
+ switch(cmd) {
+ case VIDIOC_ENUMINPUT:
+ {
+ struct v4l2_input *i = arg;
+
+ DEB_EE(("VIDIOC_ENUMINPUT %d.\n",i->index));
+ if( i->index < 0 || i->index >= KNC1_INPUTS) {
+ return -EINVAL;
+ }
+ if( DVB_CARD_KNC1 == budget->card->type ) {
+ memcpy(i, &knc1_inputs[i->index], sizeof(struct v4l2_input));
+ } else {
+ return -EINVAL;
+ }
+
+ return 0;
+ }
+ case VIDIOC_G_INPUT:
+ {
+ int *input = (int *)arg;
+ *input = data->cur_input;
+
+ DEB_EE(("VIDIOC_G_INPUT %d.\n",*input));
+ return 0;
+ }
+ case VIDIOC_S_INPUT:
+ {
+ int input = *(int *)arg;
+
+ DEB_EE(("VIDIOC_S_INPUT %d.\n",input));
+
+ if (input < 0 || input > 1) {
+ return -EINVAL;
+ }
+
+ if( DVB_CARD_KNC1 == budget->card->type ) {
+ knc1_setinput(budget, input);
+ } else {
+ return -EINVAL;
+ }
+
+ data->cur_input = input;
+
+ return 0;
+ }
+ default:
+/*
+ DEB2(printk("does not handle this ioctl.\n"));
+*/
+ return -ENOIOCTLCMD;
+ }
+ return 0;
+}
+
+static struct saa7146_standard standard[] = {
+ { "PAL", V4L2_STD_PAL, SAA7146_PAL_VALUES },
+ { "NTSC", V4L2_STD_NTSC, SAA7146_NTSC_VALUES },
+};
+
+static
+struct saa7146_ext_vv vv_data = {
+ .inputs = 2,
+ .capabilities = 0, // perhaps later: V4L2_CAP_VBI_CAPTURE, but that need tweaking with the saa7113
+ .flags = 0,
+ .stds = &standard[0],
+ .num_stds = sizeof(standard)/sizeof(struct saa7146_standard),
+ .ioctls = &ioctls[0],
+ .ioctl = av_ioctl,
+};
+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51)
static
void budget_inc_use(struct saa7146_dev* adap)
@@ -208,12 +359,13 @@ struct saa7146_extension budget_extension = {
.name = "budget dvb /w video in\0",
.devices = &sub_data[0],
.module = THIS_MODULE,
+ .ext_vv_data = &vv_data,
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51)
.inc_use = budget_inc_use,
.dec_use = budget_dec_use,
#endif
- .attach = this_budget_attach,
- .detach = this_budget_detach,
+ .attach = av_attach,
+ .detach = av_detach,
.irq_mask = MASK_07,
.irq_func = budget_irq,
};
diff --git a/linux/drivers/media/dvb/ttpci-budget/budget.c b/linux/drivers/media/dvb/ttpci-budget/budget.c
index 20e3a98a3..2334b2222 100644
--- a/linux/drivers/media/dvb/ttpci-budget/budget.c
+++ b/linux/drivers/media/dvb/ttpci-budget/budget.c
@@ -30,6 +30,9 @@
*/
#include "budget.h"
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51)
+ #define KBUILD_MODNAME budget
+#endif
static int budget_debug = 0;
@@ -207,7 +210,6 @@ DiseqcSendBit(struct budget_s *budget, int data)
static void
DiseqcSendByte(struct budget_s *budget, int data)
{
- struct saa7146_dev *dev=budget->dev;
int i, par=1, d;
DEB_EE(("budget: %p\n",budget));
@@ -433,15 +435,9 @@ static char *ttbc = "TT-Budget/WinTV-NOVA-C PCI";
static char *ttbt = "TT-Budget/WinTV-NOVA-T PCI";
static char *ttbci = "TT-Budget/WinTV-NOVA-CI PCI";
static char *satel = "SATELCO Multimedia PCI";
-static char *knc1 = "KNC1 DVB-S";
static struct saa7146_sub_info sub_data[] = {
{
- .subvendor = 0x1131,
- .subdevice = 0x4f56,
- .name = &knc1,
- .type = DVB_CARD_KNC1
- }, {
.subvendor = 0x13c2,
.subdevice = 0x1003,
.name = &ttbs,
@@ -484,6 +480,8 @@ static
int this_budget_attach (struct saa7146_dev* dev, struct saa7146_sub_info *info)
{
struct budget_s *budget = NULL;
+ DEB_EE(("budget: %p\n",budget));
+
if( 0 != budget_attach(dev,info)) {
return -1;
}
@@ -496,7 +494,9 @@ int this_budget_attach (struct saa7146_dev* dev, struct saa7146_sub_info *info)
// FIXME: cope with error here!
budget_register(budget);
- printk(KERN_INFO "budget: found budget card.\n");
+ printk(KERN_INFO "budget: found budget card '%s'.\n",*budget->card->name);
+
+ return 0;
}
int budget_attach (struct saa7146_dev* dev, struct saa7146_sub_info *info)
@@ -516,11 +516,11 @@ int budget_attach (struct saa7146_dev* dev, struct saa7146_sub_info *info)
DEB_EE(("dev: %p, budget: %p\n",dev,budget));
- budget->card_type = info;
+ budget->card = info;
budget->dev=(struct saa7146_dev *)dev;
(struct budget_s*)dev->ext_priv = budget;
- dvb_register_adapter(&budget->dvb_adapter, *budget->card_type->name);
+ dvb_register_adapter(&budget->dvb_adapter, *budget->card->name);
saa7146_i2c_adapter_prepare(dev, NULL, SAA7146_I2C_BUS_BIT_RATE_3200);
budget->i2c_bus = dvb_register_i2c_bus (master_xfer, dev, budget->dvb_adapter, 0);
diff --git a/linux/drivers/media/dvb/ttpci-budget/budget.h b/linux/drivers/media/dvb/ttpci-budget/budget.h
index 939cc375f..57cfcc22c 100644
--- a/linux/drivers/media/dvb/ttpci-budget/budget.h
+++ b/linux/drivers/media/dvb/ttpci-budget/budget.h
@@ -12,9 +12,6 @@
#include "saa7146.h"
#if 1
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51)
- #define KBUILD_MODNAME budget
-#endif
#define DEBUG_PROLOG printk("%s: %s(): ",__stringify(KBUILD_MODNAME),__FUNCTION__)
#define DEB_S(x) if (0!=(budget_debug&0x01)) { DEBUG_PROLOG; printk x; } /* simple debug messages */
#define DEB_D(x) if (0!=(budget_debug&0x02)) { DEBUG_PROLOG; printk x; } /* more detailed debug messages */
@@ -35,7 +32,7 @@ struct budget_s {
struct saa7146_dev *dev;
struct dvb_i2c_bus *i2c_bus;
- struct saa7146_sub_info *card_type;
+ struct saa7146_sub_info *card;
unsigned char *grabbing;
struct saa7146_pgtable pt;
@@ -59,6 +56,7 @@ struct budget_s {
int registered;
struct dvb_adapter *dvb_adapter;
+ void *priv;
};
#define TS_WIDTH (4*188)
diff --git a/linux/drivers/media/dvb/ttpci/av7110.c b/linux/drivers/media/dvb/ttpci/av7110.c
index b5caa33d5..f583af0e7 100644
--- a/linux/drivers/media/dvb/ttpci/av7110.c
+++ b/linux/drivers/media/dvb/ttpci/av7110.c
@@ -4151,18 +4151,6 @@ struct saa7146_extension_ioctls ioctls[] = {
{ 0, 0 }
};
-int av7110_preinit(struct saa7146_dev* dev)
-{
- DEB_EE(("dev: %p\n",dev));
-
- /* the Siemens DVB needs this if you want to have the i2c chips
- get recognized before the main driver is loaded
- */
- saa7146_write(dev, GPIO_CTRL, 0x500000);
-
- return 0;
-}
-
static char *fs_1_5 = { "Siemens cable card PCI rev1.5" };
static char *fs_1_3 = { "Siemens/Technotrend/Hauppauge PCI rev1.3" };
static char *unkwn = { "Technotrend/Hauppauge PCI rev?(unknown0)?"};
@@ -4516,8 +4504,6 @@ struct saa7146_extension av7110_extension = {
.inc_use = av7110_inc_use,
.dec_use = av7110_dec_use,
#endif
-
- .preinit = av7110_preinit,
.attach = av7110_attach,
.detach = av7110_detach,
diff --git a/linux/drivers/media/video/mxb.c b/linux/drivers/media/video/mxb.c
index 6fff101af..38538a0fb 100644
--- a/linux/drivers/media/video/mxb.c
+++ b/linux/drivers/media/video/mxb.c
@@ -201,18 +201,6 @@ static int mxb_vbi_bypass(struct saa7146_dev* dev)
return 0;
}
-/* this function gets called very early in the registration process of
- the extension. it has been reported that some devices need to enable
- the i2c-bus explicitly for example -- this can be done here. please
- note, that you cannot be sure that the device is really the hardware
- you expect, so you should do as little as possible in here, in order
- to avoid confusing the hardware.
-*/
-static int mxb_preinit(struct saa7146_dev* dev)
-{
- return 0;
-}
-
static int mxb_probe(struct saa7146_dev* dev, unsigned int subvendor, unsigned int subdevice)
{
struct mxb* mxb = 0;
@@ -1021,7 +1009,6 @@ static struct saa7146_sub_info sub_data[] = {
static
struct saa7146_ext_vv vv_data = {
.inputs = MXB_INPUTS,
- .audios = MXB_AUDIOS,
.capabilities = V4L2_CAP_TUNER | V4L2_CAP_VBI_CAPTURE,
.flags = 0,
.stds = &standard[0],
@@ -1043,7 +1030,6 @@ struct saa7146_extension extension = {
.dec_use = mxb_dec_use,
#endif
- .preinit = mxb_preinit,
.probe = mxb_probe,
.attach = mxb_attach,
.detach = mxb_detach,