summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerd Knorr <devnull@localhost>2004-05-13 17:04:39 +0000
committerGerd Knorr <devnull@localhost>2004-05-13 17:04:39 +0000
commit4571ff8b2c77e11cc565b530becff57d0113b226 (patch)
treeed61cbb4005a5519a9bb7156cead6db8c9fac9e2
parent83bd600e397e59c6af4644c507961d91827c9863 (diff)
downloadmediapointer-dvb-s2-4571ff8b2c77e11cc565b530becff57d0113b226.tar.gz
mediapointer-dvb-s2-4571ff8b2c77e11cc565b530becff57d0113b226.tar.bz2
- v4l2 support in tuner + tda9887
- switch over cx88 + saa7134 to use v4l2 for tuning. - misc tweaks.
-rw-r--r--linux/drivers/media/video/cx88/cx88-video.c44
-rw-r--r--linux/drivers/media/video/saa7134/saa7134-ts.c4
-rw-r--r--linux/drivers/media/video/saa7134/saa7134-video.c48
-rw-r--r--linux/drivers/media/video/tda9887.c60
-rw-r--r--v4l/.bp/2.4/34_cx8810
-rw-r--r--v4l/scripts/update6
6 files changed, 124 insertions, 48 deletions
diff --git a/linux/drivers/media/video/cx88/cx88-video.c b/linux/drivers/media/video/cx88/cx88-video.c
index d3303a422..ac15284f3 100644
--- a/linux/drivers/media/video/cx88/cx88-video.c
+++ b/linux/drivers/media/video/cx88/cx88-video.c
@@ -30,6 +30,8 @@
#include "cx88.h"
+#define V4L2_I2C_CLIENTS 1
+
MODULE_DESCRIPTION("v4l2 driver module for cx2388x based TV cards");
MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
MODULE_LICENSE("GPL");
@@ -532,7 +534,6 @@ static int set_tvnorm(struct cx8800_dev *dev, struct cx8800_tvnorm *norm)
u32 vdec_clock;
u64 tmp64;
u32 bdelay,agcdelay,htotal;
- struct video_channel c;
dev->tvnorm = norm;
fsc8 = norm_fsc8(norm);
@@ -598,14 +599,21 @@ static int set_tvnorm(struct cx8800_dev *dev, struct cx8800_tvnorm *norm)
set_tvaudio(dev);
// tell i2c chips
- memset(&c,0,sizeof(c));
- c.channel = dev->input;
- c.norm = VIDEO_MODE_PAL;
- if ((norm->id & (V4L2_STD_NTSC_M|V4L2_STD_NTSC_M_JP)))
- c.norm = VIDEO_MODE_NTSC;
- if (norm->id & V4L2_STD_SECAM)
- c.norm = VIDEO_MODE_SECAM;
- cx8800_call_i2c_clients(dev,VIDIOCSCHAN,&c);
+#ifdef V4L2_I2C_CLIENTS
+ cx8800_call_i2c_clients(dev,VIDIOC_S_STD,&norm->id);
+#else
+ {
+ struct video_channel c;
+ memset(&c,0,sizeof(c));
+ c.channel = dev->input;
+ c.norm = VIDEO_MODE_PAL;
+ if ((norm->id & (V4L2_STD_NTSC_M|V4L2_STD_NTSC_M_JP)))
+ c.norm = VIDEO_MODE_NTSC;
+ if (norm->id & V4L2_STD_SECAM)
+ c.norm = VIDEO_MODE_SECAM;
+ cx8800_call_i2c_clients(dev,VIDIOCSCHAN,&c);
+ }
+#endif
// done
return 0;
@@ -1800,7 +1808,11 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
return -EINVAL;
down(&dev->lock);
dev->freq = f->frequency;
+#ifdef V4L2_I2C_CLIENTS
+ cx8800_call_i2c_clients(dev,VIDIOC_S_FREQUENCY,f);
+#else
cx8800_call_i2c_clients(dev,VIDIOCSFREQ,&dev->freq);
+#endif
up(&dev->lock);
return 0;
}
@@ -1902,7 +1914,6 @@ static int radio_do_ioctl(struct inode *inode, struct file *file,
case VIDIOC_G_TUNER:
{
struct v4l2_tuner *t = arg;
- struct video_tuner vt;
if (t->index > 0)
return -EINVAL;
@@ -1912,9 +1923,16 @@ static int radio_do_ioctl(struct inode *inode, struct file *file,
t->rangelow = (int)(65*16);
t->rangehigh = (int)(108*16);
- memset(&vt,0,sizeof(vt));
- cx8800_call_i2c_clients(dev,VIDIOCGTUNER,&vt);
- t->signal = vt.signal;
+#ifdef V4L2_I2C_CLIENTS
+ cx8800_call_i2c_clients(dev,VIDIOC_G_TUNER,t);
+#else
+ {
+ struct video_tuner vt;
+ memset(&vt,0,sizeof(vt));
+ cx8800_call_i2c_clients(dev,VIDIOCGTUNER,&vt);
+ t->signal = vt.signal;
+ }
+#endif
return 0;
}
case VIDIOC_ENUMINPUT:
diff --git a/linux/drivers/media/video/saa7134/saa7134-ts.c b/linux/drivers/media/video/saa7134/saa7134-ts.c
index a18478bfe..6574793fe 100644
--- a/linux/drivers/media/video/saa7134/saa7134-ts.c
+++ b/linux/drivers/media/video/saa7134/saa7134-ts.c
@@ -46,7 +46,7 @@ MODULE_PARM(tsbufs,"i");
MODULE_PARM_DESC(tsbufs,"number of ts buffers, range 2-32");
#define TS_PACKET_SIZE 188 /* TS packets 188 bytes */
-#define TS_NR_PACKETS 312
+#define TS_NR_PACKETS 312
#define dprintk(fmt, arg...) if (ts_debug) \
printk(KERN_DEBUG "%s/ts: " fmt, dev->name , ## arg)
@@ -100,7 +100,7 @@ static int buffer_prepare(struct file *file, struct videobuf_buffer *vb,
dprintk("buffer_prepare [%p,%s]\n",buf,v4l2_field_names[field]);
llength = TS_PACKET_SIZE;
- lines = TS_NR_PACKETS;
+ lines = TS_NR_PACKETS;
size = lines * llength;
if (0 != buf->vb.baddr && buf->vb.bsize < size)
diff --git a/linux/drivers/media/video/saa7134/saa7134-video.c b/linux/drivers/media/video/saa7134/saa7134-video.c
index 024d443d8..a6eeddb3d 100644
--- a/linux/drivers/media/video/saa7134/saa7134-video.c
+++ b/linux/drivers/media/video/saa7134/saa7134-video.c
@@ -28,6 +28,8 @@
#include "saa7134-reg.h"
#include "saa7134.h"
+#define V4L2_I2C_CLIENTS 1
+
/* ------------------------------------------------------------------ */
static unsigned int video_debug = 0;
@@ -429,7 +431,6 @@ void res_free(struct saa7134_dev *dev, struct saa7134_fh *fh, unsigned int bits)
static void set_tvnorm(struct saa7134_dev *dev, struct saa7134_tvnorm *norm)
{
- struct video_channel c;
int luma_control,sync_control,mux;
dprintk("set tv norm = %s\n",norm->name);
@@ -489,15 +490,22 @@ static void set_tvnorm(struct saa7134_dev *dev, struct saa7134_tvnorm *norm)
saa_writeb(SAA7134_RAW_DATA_GAIN, 0x40);
saa_writeb(SAA7134_RAW_DATA_OFFSET, 0x80);
- /* pass down info to the i2c chips (v4l1) */
- memset(&c,0,sizeof(c));
- c.channel = dev->ctl_input;
- c.norm = VIDEO_MODE_PAL;
- if (norm->id & V4L2_STD_NTSC)
- c.norm = VIDEO_MODE_NTSC;
- if (norm->id & V4L2_STD_SECAM)
- c.norm = VIDEO_MODE_SECAM;
- saa7134_i2c_call_clients(dev,VIDIOCSCHAN,&c);
+#ifdef V4L2_I2C_CLIENTS
+ saa7134_i2c_call_clients(dev,VIDIOC_S_STD,&norm->id);
+#else
+ {
+ /* pass down info to the i2c chips (v4l1) */
+ struct video_channel c;
+ memset(&c,0,sizeof(c));
+ c.channel = dev->ctl_input;
+ c.norm = VIDEO_MODE_PAL;
+ if (norm->id & V4L2_STD_NTSC)
+ c.norm = VIDEO_MODE_NTSC;
+ if (norm->id & V4L2_STD_SECAM)
+ c.norm = VIDEO_MODE_SECAM;
+ saa7134_i2c_call_clients(dev,VIDIOCSCHAN,&c);
+ }
+#endif
}
static void video_mux(struct saa7134_dev *dev, int input)
@@ -1819,7 +1827,11 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
return -EINVAL;
down(&dev->lock);
dev->ctl_freq = f->frequency;
+#ifdef V4L2_I2C_CLIENTS
+ saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,f);
+#else
saa7134_i2c_call_clients(dev,VIDIOCSFREQ,&dev->ctl_freq);
+#endif
saa7134_tvaudio_do_scan(dev);
up(&dev->lock);
return 0;
@@ -2066,7 +2078,6 @@ static int radio_do_ioctl(struct inode *inode, struct file *file,
case VIDIOC_G_TUNER:
{
struct v4l2_tuner *t = arg;
- struct video_tuner vt;
if (0 != t->index)
return -EINVAL;
@@ -2075,10 +2086,17 @@ static int radio_do_ioctl(struct inode *inode, struct file *file,
strcpy(t->name, "Radio");
t->rangelow = (int)(65*16);
t->rangehigh = (int)(108*16);
-
- memset(&vt,0,sizeof(vt));
- saa7134_i2c_call_clients(dev,VIDIOCGTUNER,&vt);
- t->signal = vt.signal;
+
+#ifdef V4L2_I2C_CLIENTS
+ saa7134_i2c_call_clients(dev,VIDIOC_G_TUNER,t);
+#else
+ {
+ struct video_tuner vt;
+ memset(&vt,0,sizeof(vt));
+ saa7134_i2c_call_clients(dev,VIDIOCGTUNER,&vt);
+ t->signal = vt.signal;
+ }
+#endif
return 0;
}
case VIDIOC_ENUMINPUT:
diff --git a/linux/drivers/media/video/tda9887.c b/linux/drivers/media/video/tda9887.c
index ef13d6786..5e6dc55c1 100644
--- a/linux/drivers/media/video/tda9887.c
+++ b/linux/drivers/media/video/tda9887.c
@@ -54,6 +54,7 @@ struct tda9887 {
v4l2_std_id std;
unsigned int radio;
unsigned int pinnacle_id;
+ unsigned int using_v4l2;
};
struct tvnorm {
@@ -482,6 +483,18 @@ static int tda9887_fixup_std(struct tda9887 *t)
return 0;
}
+static int tda9887_status(struct tda9887 *t)
+{
+ unsigned char buf[1];
+ int rc;
+
+ memset(buf,0,sizeof(buf));
+ if (1 != (rc = i2c_master_recv(&t->client,buf,1)))
+ printk(PREFIX "i2c i/o error: rc == %d (should be 1)\n",rc);
+ dump_read_message(buf);
+ return 0;
+}
+
static int tda9887_configure(struct tda9887 *t)
{
unsigned char buf[4];
@@ -501,18 +514,12 @@ static int tda9887_configure(struct tda9887 *t)
if (4 != (rc = i2c_master_send(&t->client,buf,4)))
printk(PREFIX "i2c i/o error: rc == %d (should be 4)\n",rc);
- return 0;
-}
-static int tda9887_status(struct tda9887 *t)
-{
- unsigned char buf[1];
- int rc;
-
- memset(buf,0,sizeof(buf));
- if (1 != (rc = i2c_master_recv(&t->client,buf,1)))
- printk(PREFIX "i2c i/o error: rc == %d (should be 1)\n",rc);
- dump_read_message(buf);
+ if (debug > 2) {
+ set_current_state(TASK_INTERRUPTIBLE);
+ schedule_timeout(HZ);
+ tda9887_status(t);
+ }
return 0;
}
@@ -576,6 +583,13 @@ static int tda9887_detach(struct i2c_client *client)
return 0;
}
+#define SWITCH_V4L2 if (!t->using_v4l2 && debug) \
+ printk(PREFIX "switching to v4l2\n"); \
+ t->using_v4l2 = 1;
+#define CHECK_V4L2 if (t->using_v4l2) { if (debug) \
+ printk(PREFIX "ignore v4l1 call\n"); \
+ return 0; }
+
static int
tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg)
{
@@ -612,28 +626,42 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg)
};
struct video_channel *vc = arg;
+ CHECK_V4L2;
t->radio = 0;
if (vc->norm < ARRAY_SIZE(map))
t->std = map[vc->norm];
tda9887_fixup_std(t);
tda9887_configure(t);
- if (debug > 2) {
- set_current_state(TASK_INTERRUPTIBLE);
- schedule_timeout(HZ);
- tda9887_status(t);
- }
break;
}
case VIDIOC_S_STD:
{
v4l2_std_id *id = arg;
+ SWITCH_V4L2;
t->radio = 0;
t->std = *id;
tda9887_fixup_std(t);
tda9887_configure(t);
break;
}
+ case VIDIOC_S_FREQUENCY:
+ {
+ struct v4l2_frequency *f = arg;
+
+ SWITCH_V4L2;
+ if (V4L2_TUNER_ANALOG_TV == f->type) {
+ if (t->radio == 0)
+ return 0;
+ t->radio = 0;
+ }
+ if (V4L2_TUNER_RADIO == f->type) {
+ if (t->radio == 1)
+ return 0;
+ t->radio = 1;
+ }
+ tda9887_configure(t);
+ }
default:
/* nothing */
break;
diff --git a/v4l/.bp/2.4/34_cx88 b/v4l/.bp/2.4/34_cx88
new file mode 100644
index 000000000..20745d6e0
--- /dev/null
+++ b/v4l/.bp/2.4/34_cx88
@@ -0,0 +1,10 @@
+srcdiff cx88.h drivers/media/video/cx88.h
+srcdiff cx88-reg.h drivers/media/video/cx88-reg.h
+
+srcdiff cx88-cards.c drivers/media/video/cx88-cards.c
+srcdiff cx88-core.c drivers/media/video/cx88-core.c
+srcdiff cx88-i2c.c drivers/media/video/cx88-i2c.c
+srcdiff cx88-tvaudio.c drivers/media/video/cx88-tvaudio.c
+srcdiff cx88-video.c drivers/media/video/cx88-video.c
+srcdiff cx88-vbi.c drivers/media/video/cx88-vbi.c
+
diff --git a/v4l/scripts/update b/v4l/scripts/update
index adfe9f79a..d502262cb 100644
--- a/v4l/scripts/update
+++ b/v4l/scripts/update
@@ -16,6 +16,8 @@ esac
# unload
# bttv
+xrmmod dst
+xrmmod bt878
xrmmod ir-kbd-gpio
xrmmod ir-kbd-i2c
xrmmod bttv
@@ -50,7 +52,7 @@ v4l2basic
xinsmod video-buf debug=2
xinsmod btcx-risc debug=0
xinsmod ir-common debug=0 repeat=0
-xinsmod tuner debug=0
+xinsmod tuner debug=1
xinsmod tda9887 debug=1
xinsmod msp3400 debug=0
@@ -62,7 +64,7 @@ test -f ir-kbd-gpio.ko && xinsmod ir-kbd-gpio debug=0
# cx88
xinsmod cx88xx core_debug=0
-xinsmod cx8800 video_debug=0 audio_debug=1
+xinsmod cx8800 video_debug=0 audio_debug=0
# saa7134
xinsmod saa7134 audio_debug=1 $saopt