summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--linux/drivers/media/video/saa7134/saa7134-input.c9
-rw-r--r--linux/drivers/media/video/saa7134/saa7134-tvaudio.c147
-rw-r--r--linux/drivers/media/video/saa7134/saa7134-video.c127
3 files changed, 159 insertions, 124 deletions
diff --git a/linux/drivers/media/video/saa7134/saa7134-input.c b/linux/drivers/media/video/saa7134/saa7134-input.c
index f0d1ecc13..38ae3899f 100644
--- a/linux/drivers/media/video/saa7134/saa7134-input.c
+++ b/linux/drivers/media/video/saa7134/saa7134-input.c
@@ -27,6 +27,10 @@
#include "saa7134-reg.h"
#include "saa7134.h"
+static unsigned int disable_ir = 0;
+MODULE_PARM(disable_ir,"i");
+MODULE_PARM_DESC(disable_ir,"disable infrared remote support");
+
/* ---------------------------------------------------------------------- */
static IR_KEYTAB_TYPE flyvideo_codes[IR_KEYTAB_SIZE] = {
@@ -260,9 +264,12 @@ int saa7134_input_init1(struct saa7134_dev *dev)
int polling = 0;
int ir_type = IR_TYPE_OTHER;
- /* detect & configure */
if (!dev->has_remote)
return -ENODEV;
+ if (disable_ir)
+ return -ENODEV;
+
+ /* detect & configure */
switch (dev->board) {
case SAA7134_BOARD_FLYVIDEO2000:
case SAA7134_BOARD_FLYVIDEO3000:
diff --git a/linux/drivers/media/video/saa7134/saa7134-tvaudio.c b/linux/drivers/media/video/saa7134/saa7134-tvaudio.c
index a300717ea..c5950ba28 100644
--- a/linux/drivers/media/video/saa7134/saa7134-tvaudio.c
+++ b/linux/drivers/media/video/saa7134/saa7134-tvaudio.c
@@ -37,10 +37,6 @@ static unsigned int audio_debug = 0;
MODULE_PARM(audio_debug,"i");
MODULE_PARM_DESC(audio_debug,"enable debug messages [tv audio]");
-static unsigned int audio_carrier = 0;
-MODULE_PARM(audio_carrier,"i");
-MODULE_PARM_DESC(audio_carrier,"audio carrier location");
-
static unsigned int audio_ddep = 0;
MODULE_PARM(audio_ddep,"i");
MODULE_PARM_DESC(audio_ddep,"audio ddep overwrite");
@@ -67,6 +63,30 @@ MODULE_PARM_DESC(audio_clock_tweak, "Audio clock tick fine tuning for cards with
/* ------------------------------------------------------------------ */
/* saa7134 code */
+static struct mainscan {
+ char *name;
+ v4l2_std_id std;
+ int carr;
+} mainscan[] = {
+ {
+ .name = "M",
+ .std = V4L2_STD_NTSC | V4L2_STD_PAL_M,
+ .carr = 4500,
+ },{
+ .name = "BG",
+ .std = V4L2_STD_PAL_BG,
+ .carr = 5500,
+ },{
+ .name = "I",
+ .std = V4L2_STD_PAL_I,
+ .carr = 6000,
+ },{
+ .name = "DKL",
+ .std = V4L2_STD_PAL_DK | V4L2_STD_SECAM,
+ .carr = 6500,
+ }
+};
+
static struct saa7134_tvaudio tvaudio[] = {
{
.name = "PAL-B/G FM-stereo",
@@ -314,15 +334,15 @@ static int tvaudio_sleep(struct saa7134_dev *dev, int timeout)
return dev->thread.scan1 != dev->thread.scan2;
}
-static int tvaudio_checkcarrier(struct saa7134_dev *dev, int carrier)
+static int tvaudio_checkcarrier(struct saa7134_dev *dev, struct mainscan *scan)
{
__s32 left,right,value;
if (audio_debug > 1) {
int i;
- dprintk("debug %d:",carrier);
+ dprintk("debug %d:",scan->carr);
for (i = -150; i <= 150; i += 30) {
- tvaudio_setcarrier(dev,carrier+i,carrier+i);
+ tvaudio_setcarrier(dev,scan->carr+i,scan->carr+i);
saa_readl(SAA7134_LEVEL_READOUT1 >> 2);
if (tvaudio_sleep(dev,SCAN_SAMPLE_DELAY))
return -1;
@@ -334,24 +354,31 @@ static int tvaudio_checkcarrier(struct saa7134_dev *dev, int carrier)
}
printk("\n");
}
-
- tvaudio_setcarrier(dev,carrier-90,carrier-90);
- saa_readl(SAA7134_LEVEL_READOUT1 >> 2);
- if (tvaudio_sleep(dev,SCAN_SAMPLE_DELAY))
- return -1;
- left = saa_readl(SAA7134_LEVEL_READOUT1 >> 2);
-
- tvaudio_setcarrier(dev,carrier+90,carrier+90);
- saa_readl(SAA7134_LEVEL_READOUT1 >> 2);
- if (tvaudio_sleep(dev,SCAN_SAMPLE_DELAY))
- return -1;
- right = saa_readl(SAA7134_LEVEL_READOUT1 >> 2);
-
- left >>= 16;
- right >>= 16;
- value = left > right ? left - right : right - left;
- dprintk("scanning %d.%03d MHz => dc is %5d [%d/%d]\n",
- carrier/1000,carrier%1000,value,left,right);
+
+ if (dev->tvnorm->id & scan->std) {
+ tvaudio_setcarrier(dev,scan->carr-90,scan->carr-90);
+ saa_readl(SAA7134_LEVEL_READOUT1 >> 2);
+ if (tvaudio_sleep(dev,SCAN_SAMPLE_DELAY))
+ return -1;
+ left = saa_readl(SAA7134_LEVEL_READOUT1 >> 2);
+
+ tvaudio_setcarrier(dev,scan->carr+90,scan->carr+90);
+ saa_readl(SAA7134_LEVEL_READOUT1 >> 2);
+ if (tvaudio_sleep(dev,SCAN_SAMPLE_DELAY))
+ return -1;
+ right = saa_readl(SAA7134_LEVEL_READOUT1 >> 2);
+
+ left >>= 16;
+ right >>= 16;
+ value = left > right ? left - right : right - left;
+ dprintk("scanning %d.%03d MHz [%4s] => dc is %5d [%d/%d]\n",
+ scan->carr / 1000, scan->carr % 1000,
+ scan->name, value, left, right);
+ } else {
+ value = 0;
+ dprintk("skipping %d.%03d MHz [%4s]\n",
+ scan->carr / 1000, scan->carr % 1000, scan->name);
+ }
return value;
}
@@ -460,16 +487,10 @@ static int tvaudio_setstereo(struct saa7134_dev *dev, struct saa7134_tvaudio *au
static int tvaudio_thread(void *data)
{
-#define MAX_SCAN 4
- static const int carr_pal[MAX_SCAN] = { 5500, 6000, 6500 };
- static const int carr_ntsc[MAX_SCAN] = { 4500 };
- static const int carr_secam[MAX_SCAN] = { 6500 };
- static const int carr_default[MAX_SCAN] = { 4500, 5500, 6000, 6500 };
struct saa7134_dev *dev = data;
- const int *carr_scan;
- int carr_vals[4];
- unsigned int i, audio, retries;
- int max1,max2,carrier,rx,mode,lastmode;
+ int carr_vals[ARRAY_SIZE(mainscan)];
+ unsigned int i, audio, nscan;
+ int max1,max2,carrier,rx,mode,lastmode,default_carrier;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,61)
lock_kernel();
@@ -498,33 +519,37 @@ static int tvaudio_thread(void *data)
if (tvaudio_sleep(dev,SCAN_INITIAL_DELAY))
goto restart;
- /* find the main carrier */
- carr_scan = carr_default;
- if (dev->tvnorm->id & V4L2_STD_PAL)
- carr_scan = carr_pal;
- if (dev->tvnorm->id & V4L2_STD_NTSC)
- carr_scan = carr_ntsc;
- if (dev->tvnorm->id & V4L2_STD_SECAM)
- carr_scan = carr_secam;
- saa_writeb(SAA7134_MONITOR_SELECT,0x00);
- tvaudio_setmode(dev,&tvaudio[0],NULL);
-
+ max1 = 0;
+ max2 = 0;
+ nscan = 0;
carrier = 0;
- for (retries = 3; retries > 0 && 0 == carrier; retries--) {
- for (i = 0; i < MAX_SCAN; i++) {
- if (!carr_scan[i])
- continue;
- carr_vals[i] = tvaudio_checkcarrier(dev,carr_scan[i]);
+ default_carrier = 0;
+ for (i = 0; i < ARRAY_SIZE(mainscan); i++) {
+ if (!(dev->tvnorm->id & mainscan[i].std))
+ continue;
+ if (!default_carrier)
+ default_carrier = mainscan[i].carr;
+ nscan++;
+ }
+
+ if (1 == nscan) {
+ /* only one candidate -- skip scan ;) */
+ max1 = 12345;
+ carrier = default_carrier;
+ } else {
+ /* scan for the main carrier */
+ saa_writeb(SAA7134_MONITOR_SELECT,0x00);
+ tvaudio_setmode(dev,&tvaudio[0],NULL);
+ for (i = 0; i < ARRAY_SIZE(mainscan); i++) {
+ carr_vals[i] = tvaudio_checkcarrier(dev, mainscan+i);
if (dev->thread.scan1 != dev->thread.scan2)
goto restart;
}
- for (max1 = 0, max2 = 0, i = 0; i < MAX_SCAN; i++) {
- if (!carr_scan[i])
- continue;
+ for (max1 = 0, max2 = 0, i = 0; i < ARRAY_SIZE(mainscan); i++) {
if (max1 < carr_vals[i]) {
max2 = max1;
max1 = carr_vals[i];
- carrier = carr_scan[i];
+ carrier = mainscan[i].carr;
} else if (max2 < carr_vals[i]) {
max2 = carr_vals[i];
}
@@ -537,21 +562,17 @@ static int tvaudio_thread(void *data)
dev->tvnorm->name, carrier/1000, carrier%1000,
max1, max2);
dev->last_carrier = carrier;
- } else if (0 != audio_carrier) {
- /* no carrier -- try insmod option as fallback */
- carrier = audio_carrier;
- printk(KERN_WARNING "%s/audio: audio carrier scan failed, "
- "using %d.%03d MHz [insmod option]\n",
- dev->name, carrier/1000, carrier%1000);
+
} else if (0 != dev->last_carrier) {
/* no carrier -- try last detected one as fallback */
carrier = dev->last_carrier;
printk(KERN_WARNING "%s/audio: audio carrier scan failed, "
"using %d.%03d MHz [last detected]\n",
dev->name, carrier/1000, carrier%1000);
+
} else {
- /* no carrier + no fallback -- try first in list */
- carrier = carr_scan[0];
+ /* no carrier + no fallback -- use default */
+ carrier = default_carrier;
printk(KERN_WARNING "%s/audio: audio carrier scan failed, "
"using %d.%03d MHz [default]\n",
dev->name, carrier/1000, carrier%1000);
@@ -564,7 +585,7 @@ static int tvaudio_thread(void *data)
/* find the exact tv audio norm */
for (audio = UNSET, i = 0; i < TVAUDIO; i++) {
if (dev->tvnorm->id != UNSET &&
- dev->tvnorm->id != tvaudio[i].std)
+ !(dev->tvnorm->id & tvaudio[i].std))
continue;
if (tvaudio[i].carr1 != carrier)
continue;
diff --git a/linux/drivers/media/video/saa7134/saa7134-video.c b/linux/drivers/media/video/saa7134/saa7134-video.c
index a6eeddb3d..e6e8b1eff 100644
--- a/linux/drivers/media/video/saa7134/saa7134-video.c
+++ b/linux/drivers/media/video/saa7134/saa7134-video.c
@@ -150,10 +150,65 @@ static struct saa7134_format formats[] = {
};
#define FORMATS ARRAY_SIZE(formats)
+#define NORM_625_50 \
+ .h_start = 0, \
+ .h_stop = 719, \
+ .video_v_start = 24, \
+ .video_v_stop = 311, \
+ .vbi_v_start = 7, \
+ .vbi_v_stop = 22, \
+ .src_timing = 4
+
+#define NORM_525_60 \
+ .h_start = 0, \
+ .h_stop = 703, \
+ .video_v_start = 22, \
+ .video_v_stop = 22+239, \
+ .vbi_v_start = 10, /* FIXME */ \
+ .vbi_v_stop = 21, /* FIXME */ \
+ .src_timing = 1
+
static struct saa7134_tvnorm tvnorms[] = {
{
- .name = "PAL",
+ .name = "PAL", /* autodetect */
.id = V4L2_STD_PAL,
+ NORM_625_50,
+
+ .sync_control = 0x18,
+ .luma_control = 0x40,
+ .chroma_ctrl1 = 0x81,
+ .chroma_gain = 0x2a,
+ .chroma_ctrl2 = 0x06,
+ .vgate_misc = 0x1c,
+
+ },{
+ .name = "PAL-BG",
+ .id = V4L2_STD_PAL_BG,
+ NORM_625_50,
+
+ .sync_control = 0x18,
+ .luma_control = 0x40,
+ .chroma_ctrl1 = 0x81,
+ .chroma_gain = 0x2a,
+ .chroma_ctrl2 = 0x06,
+ .vgate_misc = 0x1c,
+
+ },{
+ .name = "PAL-I",
+ .id = V4L2_STD_PAL_I,
+ NORM_625_50,
+
+ .sync_control = 0x18,
+ .luma_control = 0x40,
+ .chroma_ctrl1 = 0x81,
+ .chroma_gain = 0x2a,
+ .chroma_ctrl2 = 0x06,
+ .vgate_misc = 0x1c,
+
+ },{
+ .name = "PAL-DK",
+ .id = V4L2_STD_PAL_DK,
+ NORM_625_50,
.sync_control = 0x18,
.luma_control = 0x40,
@@ -162,16 +217,10 @@ static struct saa7134_tvnorm tvnorms[] = {
.chroma_ctrl2 = 0x06,
.vgate_misc = 0x1c,
- .h_start = 0,
- .h_stop = 719,
- .video_v_start = 24,
- .video_v_stop = 311,
- .vbi_v_start = 7,
- .vbi_v_stop = 22,
- .src_timing = 4,
},{
.name = "NTSC",
.id = V4L2_STD_NTSC,
+ NORM_525_60,
.sync_control = 0x59,
.luma_control = 0x40,
@@ -180,16 +229,10 @@ static struct saa7134_tvnorm tvnorms[] = {
.chroma_ctrl2 = 0x0e,
.vgate_misc = 0x18,
- .h_start = 0,
- .h_stop = 703,
- .video_v_start = 22,
- .video_v_stop = 22+239,
- .vbi_v_start = 10, /* FIXME */
- .vbi_v_stop = 21, /* FIXME */
- .src_timing = 1,
},{
.name = "SECAM",
.id = V4L2_STD_SECAM,
+ NORM_625_50,
.sync_control = 0x18, /* old: 0x58, */
.luma_control = 0x1b,
@@ -198,16 +241,10 @@ static struct saa7134_tvnorm tvnorms[] = {
.chroma_ctrl2 = 0x00,
.vgate_misc = 0x1c,
- .h_start = 0,
- .h_stop = 719,
- .video_v_start = 24,
- .video_v_stop = 311,
- .vbi_v_start = 7,
- .vbi_v_stop = 22,
- .src_timing = 4,
},{
.name = "PAL-M",
.id = V4L2_STD_PAL_M,
+ NORM_525_60,
.sync_control = 0x59,
.luma_control = 0x40,
@@ -216,16 +253,10 @@ static struct saa7134_tvnorm tvnorms[] = {
.chroma_ctrl2 = 0x0e,
.vgate_misc = 0x18,
- .h_start = 0,
- .h_stop = 719,
- .video_v_start = 22,
- .video_v_stop = 22+240,
- .vbi_v_start = 10, /* FIXME */
- .vbi_v_stop = 21, /* FIXME */
- .src_timing = 1,
},{
.name = "PAL-Nc",
.id = V4L2_STD_PAL_Nc,
+ NORM_625_50,
.sync_control = 0x18,
.luma_control = 0x40,
@@ -234,35 +265,6 @@ static struct saa7134_tvnorm tvnorms[] = {
.chroma_ctrl2 = 0x06,
.vgate_misc = 0x1c,
- .h_start = 0,
- .h_stop = 719,
- .video_v_start = 24,
- .video_v_stop = 311,
- .vbi_v_start = 7,
- .vbi_v_stop = 22,
- .src_timing = 4,
-#if 0
- },{
- .name = "AUTO",
- .id = V4L2_STD_PAL|V4L2_STD_NTSC|V4L2_STD_SECAM,
- .width = 768,
- .height = 576,
-
- .sync_control = 0x98,
- .luma_control = 0x40,
- .chroma_ctrl1 = 0x8b,
- .chroma_gain = 0x00,
- .chroma_ctrl2 = 0x00,
- .vgate_misc = 0x18,
-
- .h_start = 0,
- .h_stop = 719,
- .video_v_start = 24,
- .video_v_stop = 311,
- .vbi_v_start = 7,
- .vbi_v_stop = 22,
- .src_timing = 4,
-#endif
}
};
#define TVNORMS ARRAY_SIZE(tvnorms)
@@ -1680,10 +1682,14 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
v4l2_std_id *id = arg;
unsigned int i;
- for(i = 0; i < TVNORMS; i++)
- if (*id & tvnorms[i].id)
+ for (i = 0; i < TVNORMS; i++)
+ if (*id == tvnorms[i].id)
break;
if (i == TVNORMS)
+ for (i = 0; i < TVNORMS; i++)
+ if (*id & tvnorms[i].id)
+ break;
+ if (i == TVNORMS)
return -EINVAL;
down(&dev->lock);
@@ -1695,6 +1701,7 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
spin_unlock_irqrestore(&dev->slock,flags);
} else
set_tvnorm(dev,&tvnorms[i]);
+ saa7134_tvaudio_do_scan(dev);
up(&dev->lock);
return 0;
}