Hi Gerd,
2nd patch:
- more container_of as needed + #define
- vc100: correct inputs
- MM20x fix identify_by_eeprom
Regards, Gunther
Gerd Knorr wrote:
struct bttv {
- struct bttv_core c;
-
+ // FIXME: some code silently assumes "&btv == &btv->video_dev", so
+ // this struct has to start with "video_dev" ! else: oopses.
+ // (e.g. see bttv_open vs. init_video_dev)
struct video_device video_dev;
Good catch, thanks. The patch below fixes bttv_(open|close) to not
assume that any more. Untested, but obviously correct :)
Gerd
--- bttv-0.7.108/driver/bttv-driver.c~ Thu Oct 16 12:42:36 2003
+++ bttv-0.7.108/driver/bttv-driver.c Tue Nov 4 09:42:01 2003
@@ -1498,7 +1498,7 @@
static int bttv_open(struct video_device *dev, int flags)
{
- struct bttv *btv = (struct bttv *)dev;
+ struct bttv *btv = container_of(dev, struct bttv, video_dev);
unsigned int i;
int ret;
@@ -1536,7 +1536,7 @@
static void bttv_close(struct video_device *dev)
{
- struct bttv *btv=(struct bttv *)dev;
+ struct bttv *btv = container_of(dev, struct bttv, video_dev);
unsigned long irq_flags;
int need_wait;
diff -ur bttv7-20031024/bttv-cards.c bttv7-20031024gm/bttv-cards.c
--- bttv7-20031024/bttv-cards.c Fri Oct 24 09:55:09 2003
+++ bttv7-20031024gm/bttv-cards.c Tue Nov 4 21:46:05 2003
@@ -160,7 +160,7 @@
{ 0x00031002, BTTV_ATI_TVWONDERVE,"ATI TV Wonder/VE" },
{ 0x6606107d, BTTV_WINFAST2000, "Leadtek WinFast TV 2000" },
- { 0x6607107d, BTTV_WINFAST2000, "Leadtek WinFast VC 100" },
+ { 0x6607107d, BTTV_WINFASTVC100, "Leadtek WinFast VC 100" },
{ 0x263610b4, BTTV_STB2, "STB TV PCI FM, Gateway P/N 6000704" },
{ 0x264510b4, BTTV_STB2, "STB TV PCI FM, Gateway P/N 6000704" },
{ 0x402010fc, BTTV_GVBCTV3PCI, "I-O Data Co. GV-BCTV3/PCI" },
@@ -1885,6 +1885,19 @@
.tuner_type = TUNER_ABSENT,
.no_video = 1,
.has_dvb = 1,
+},{
+ .name = "Winfast VC100",
+ .video_inputs = 3,
+ .audio_inputs = 0,
+ .svhs = 1,
+ .tuner = -1, // no tuner
+ .muxsel = { 3, 1, 1, 3}, // Vid In, SVid In, Vid over SVid in connector
+ .no_msp34xx = 1,
+ .no_tda9875 = 1,
+ .no_tda7432 = 1,
+ .tuner_type = TUNER_ABSENT,
+ .no_video = 1,
+ .pll = PLL_28,
}};
const unsigned int bttv_num_tvcards = ARRAY_SIZE(bttv_tvcards);
@@ -1976,7 +1989,7 @@
{
int type = -1;
- if (0 == strncmp(eeprom_data,"GET.MM20xPCTV",13))
+ if (0 == strncmp(eeprom_data,"GET MM20xPCTV",13))
type = BTTV_MODTEC_205;
else if (0 == strncmp(eeprom_data+20,"Picolo",7))
type = BTTV_EURESYS_PICOLO;
@@ -2496,11 +2509,16 @@
{
if( strncmp(&(eeprom_data[0x1e]),"Temic 4066 FY5",14) ==0) {
btv->tuner_type=TUNER_TEMIC_4066FY5_PAL_I;
- printk("bttv Modtec: Tuner autodetected %s\n",
- &eeprom_data[0x1e]);
+ printk("bttv%d: Modtec: Tuner autodetected by eeprom:%s\n",
+ btv->c.nr,&eeprom_data[0x1e]);
+ } else
+ if (strncmp(&(eeprom_data[0x1e]),"Alps TSBB5",10) ==0) {
+ btv->tuner_type=TUNER_ALPS_TSBB5_PAL_I;
+ printk("bttv%d: Modtec: Tuner autodetected by eeprom:%s\n",
+ btv->c.nr,&eeprom_data[0x1e]);
} else {
- printk("bttv Modtec: Unknown TunerString:%s\n",
- &eeprom_data[0x1e]);
+ printk("bttv%d: Modtec: Unknown TunerString:%s\n",
+ btv->c.nr,&eeprom_data[0x1e]);
}
}
diff -ur bttv7-20031024/bttv-driver.c bttv7-20031024gm/bttv-driver.c
--- bttv7-20031024/bttv-driver.c Thu Oct 16 12:42:36 2003
+++ bttv7-20031024gm/bttv-driver.c Tue Nov 4 21:25:47 2003
@@ -1498,7 +1498,7 @@
static int bttv_open(struct video_device *dev, int flags)
{
- struct bttv *btv = (struct bttv *)dev;
+ struct bttv *btv = container_of(dev,struct bttv,video_dev);
unsigned int i;
int ret;
@@ -1536,7 +1536,7 @@
static void bttv_close(struct video_device *dev)
{
- struct bttv *btv=(struct bttv *)dev;
+ struct bttv *btv=container_of(dev,struct bttv, video_dev);
unsigned long irq_flags;
int need_wait;
@@ -1634,7 +1634,7 @@
static int bttv_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
{
- struct bttv *btv=(struct bttv *)dev;
+ struct bttv *btv=container_of(dev,struct bttv, video_dev);
unsigned long irq_flags;
int ret = 0;
@@ -2202,7 +2202,7 @@
static int bttv_mmap(struct video_device *dev, const char *adr, unsigned long size)
{
- struct bttv *btv=(struct bttv *)dev;
+ struct bttv *btv=container_of(dev, struct bttv, video_dev);
int r;
down(&btv->lock);
@@ -2228,10 +2228,10 @@
};
-static long vbi_read(struct video_device *v, char *buf, unsigned long count,
+static long vbi_read(struct video_device *dev, char *buf, unsigned long count,
int nonblock)
{
- struct bttv *btv=(struct bttv *)(v-2);
+ struct bttv *btv=container_of(dev, struct bttv, vbi_dev);
unsigned long todo;
unsigned int q;
DECLARE_WAITQUEUE(wait, current);
@@ -2287,7 +2287,7 @@
static unsigned int vbi_poll(struct video_device *dev, struct file *file,
poll_table *wait)
{
- struct bttv *btv=(struct bttv *)(dev-2);
+ struct bttv *btv=container_of(dev, struct bttv, vbi_dev);
unsigned int mask = 0;
poll_wait(file, &btv->vbiq, wait);
@@ -2300,7 +2300,7 @@
static int vbi_open(struct video_device *dev, int flags)
{
- struct bttv *btv=(struct bttv *)(dev-2);
+ struct bttv *btv=container_of(dev, struct bttv, vbi_dev);
unsigned long irq_flags;
down(&btv->lock);
@@ -2319,7 +2319,7 @@
static void vbi_close(struct video_device *dev)
{
- struct bttv *btv=(struct bttv *)(dev-2);
+ struct bttv *btv=container_of(dev, struct bttv, vbi_dev);
unsigned long irq_flags;
spin_lock_irqsave(&btv->s_lock, irq_flags);
@@ -2330,7 +2330,7 @@
static int vbi_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
{
- struct bttv *btv=(struct bttv *)(dev-2);
+ struct bttv *btv=container_of(dev, struct bttv, vbi_dev);
switch (cmd) {
case VIDIOCGCAP:
@@ -2383,7 +2383,7 @@
static int radio_open(struct video_device *dev, int flags)
{
- struct bttv *btv = (struct bttv *)(dev-1);
+ struct bttv *btv = container_of(dev, struct bttv, radio_dev);
down(&btv->lock);
if (btv->user)
@@ -2404,7 +2404,7 @@
static void radio_close(struct video_device *dev)
{
- struct bttv *btv=(struct bttv *)(dev-1);
+ struct bttv *btv=container_of(dev, struct bttv, radio_dev);
down(&btv->lock);
btv->user--;
@@ -2419,7 +2419,8 @@
static int radio_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
{
- struct bttv *btv=(struct bttv *)(dev-1);
+ struct bttv *btv=container_of(dev, struct bttv, radio_dev);
+
switch (cmd) {
case VIDIOCGCAP:
{
diff -ur bttv7-20031024/bttv.h bttv7-20031024gm/bttv.h
--- bttv7-20031024/bttv.h Fri Oct 24 09:39:54 2003
+++ bttv7-20031024gm/bttv.h Sun Nov 2 18:43:26 2003
@@ -120,6 +120,7 @@
#define BTTV_IVC120 0x6f
#define BTTV_PC_HDTV 0x70
#define BTTV_TWINHAN_DST 0x71
+#define BTTV_WINFASTVC100 0x72
/* i2c address list */
#define I2C_TSA5522 0xc2
diff -ur bttv7-20031024/bttvp.h bttv7-20031024gm/bttvp.h
--- bttv7-20031024/bttvp.h Sun Nov 2 23:50:34 2003
+++ bttv7-20031024gm/bttvp.h Tue Nov 4 21:52:00 2003
@@ -74,6 +74,16 @@
#define BTTV_MAX_FBUF 0x208000
+/*
+ * container_of - cast a member of a structure out to the containing structure
+ * @ptr: the pointer to the member.
+ * @type: the type of the container struct this is embedded in.
+ * @member: the name of the member within the struct.
+ */
+#define container_of(ptr, type, member) ({ \
+ const typeof( ((type *)0)->member ) *__mptr = (ptr); \
+ (type *)( (char *)__mptr - offsetof(type,member) );})
+
struct bttv_window
{
int x, y;