Commit 151335ea authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] v4l: saa7134 driver update

From: Gerd Knorr <kraxel@bytesex.org>

This is a saa7134 driver update.  Changes:

* add infrared remote support.

* add support for more TV cards.

* misc minor fixes.

This patch depends on the ir-input patch.
parent 2aae415e
saa7134-objs := saa7134-cards.o saa7134-core.o saa7134-i2c.o \
saa7134-oss.o saa7134-ts.o saa7134-tvaudio.o \
saa7134-vbi.o saa7134-video.o
saa7134-vbi.o saa7134-video.o saa7134-input.o
obj-$(CONFIG_VIDEO_SAA7134) += saa7134.o
......
......@@ -168,13 +168,13 @@ static int saa6752hs_chip_command(struct i2c_client* client,
}
// wait a bit
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(1);
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(HZ/100);
}
// delay a bit to let encoder settle
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(5);
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(HZ/20);
// done
return status;
......@@ -230,6 +230,7 @@ static int saa6752hs_set_bitrate(struct i2c_client* client,
static int saa6752hs_init(struct i2c_client* client, struct mpeg_params* params)
{
unsigned char buf[3];
void *data;
// check the bitrate parameters first
if (params != NULL) {
......@@ -281,12 +282,13 @@ static int saa6752hs_init(struct i2c_client* client, struct mpeg_params* params)
i2c_master_send(client,buf,3);
// setup bitrate settings
data = i2c_get_clientdata(client);
if (params) {
saa6752hs_set_bitrate(client, params);
memcpy(client->data, params, sizeof(struct mpeg_params));
memcpy(data, params, sizeof(struct mpeg_params));
} else {
// parameters were not supplied. use the previous set
saa6752hs_set_bitrate(client, (struct mpeg_params*) client->data);
saa6752hs_set_bitrate(client, (struct mpeg_params*) data);
}
// Send SI tables
......@@ -324,7 +326,7 @@ static int saa6752hs_attach(struct i2c_adapter *adap, int addr, int kind)
if (NULL == (params = kmalloc(sizeof(struct mpeg_params), GFP_KERNEL)))
return -ENOMEM;
memcpy(params,&mpeg_params_template,sizeof(struct mpeg_params));
client->data = params;
i2c_set_clientdata(client, params);
i2c_attach_client(client);
......@@ -341,8 +343,11 @@ static int saa6752hs_probe(struct i2c_adapter *adap)
static int saa6752hs_detach(struct i2c_client *client)
{
void *data;
data = i2c_get_clientdata(client);
i2c_detach_client(client);
kfree(client->data);
kfree(data);
kfree(client);
return 0;
}
......
This diff is collapsed.
......@@ -599,12 +599,10 @@ static irqreturn_t saa7134_irq(int irq, void *dev_id, struct pt_regs *regs)
if ((report & SAA7134_IRQ_REPORT_DONE_RA3))
saa7134_irq_oss_done(dev,status);
#ifdef CONFIG_VIDEO_IR
if ((report & (SAA7134_IRQ_REPORT_GPIO16 |
SAA7134_IRQ_REPORT_GPIO18)) &&
dev->remote)
saa7134_input_irq(dev);
#endif
};
if (10 == loop) {
......@@ -636,9 +634,7 @@ static int saa7134_hwinit1(struct saa7134_dev *dev)
saa7134_vbi_init1(dev);
if (card_has_ts(dev))
saa7134_ts_init1(dev);
#ifdef CONFIG_VIDEO_IR
saa7134_input_init1(dev);
#endif
switch (dev->pci->device) {
case PCI_DEVICE_ID_PHILIPS_SAA7134:
......@@ -714,9 +710,7 @@ static int saa7134_hwfini(struct saa7134_dev *dev)
}
if (card_has_ts(dev))
saa7134_ts_fini(dev);
#ifdef CONFIG_VIDEO_IR
saa7134_input_fini(dev);
#endif
saa7134_vbi_fini(dev);
saa7134_video_fini(dev);
saa7134_tvaudio_fini(dev);
......@@ -907,7 +901,7 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
}
/* wait a bit, register i2c bus */
current->state = TASK_INTERRUPTIBLE;
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(HZ/10);
saa7134_i2c_register(dev);
......@@ -922,6 +916,10 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
if (card_has_ts(dev))
request_module("saa6752hs");
#ifdef VIDIOC_G_PRIORITY
v4l2_prio_init(&dev->prio);
#endif
/* register v4l devices */
dev->video_dev = vdev_init(dev,&saa7134_video_template,"video");
err = video_register_device(dev->video_dev,VFL_TYPE_GRABBER,
......@@ -1041,18 +1039,7 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
saa_writel(SAA7134_MAIN_CTRL,0);
/* shutdown subsystems */
switch (dev->pci->device) {
case PCI_DEVICE_ID_PHILIPS_SAA7134:
case PCI_DEVICE_ID_PHILIPS_SAA7133:
case PCI_DEVICE_ID_PHILIPS_SAA7135:
saa7134_oss_fini(dev);
break;
}
if (card_has_ts(dev))
saa7134_ts_fini(dev);
saa7134_vbi_fini(dev);
saa7134_video_fini(dev);
saa7134_tvaudio_fini(dev);
saa7134_hwfini(dev);
/* unregister */
saa7134_i2c_unregister(dev);
......@@ -1099,6 +1086,10 @@ static int saa7134_init(void)
(SAA7134_VERSION_CODE >> 16) & 0xff,
(SAA7134_VERSION_CODE >> 8) & 0xff,
SAA7134_VERSION_CODE & 0xff);
#ifdef SNAPSHOT
printk(KERN_INFO "saa7130/34: snapshot date %04d-%02d-%02d\n",
SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
#endif
return pci_module_init(&saa7134_pci_driver);
}
......
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Should you need to contact me, the author, you can do so either by
* e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
* Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/input.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/input.h>
#include "saa7134-reg.h"
#include "saa7134.h"
/* ---------------------------------------------------------------------- */
static IR_KEYTAB_TYPE flyvideo_codes[IR_KEYTAB_SIZE] = {
[ 15 ] = KEY_KP0,
[ 3 ] = KEY_KP1,
[ 4 ] = KEY_KP2,
[ 5 ] = KEY_KP3,
[ 7 ] = KEY_KP4,
[ 8 ] = KEY_KP5,
[ 9 ] = KEY_KP6,
[ 11 ] = KEY_KP7,
[ 12 ] = KEY_KP8,
[ 13 ] = KEY_KP9,
[ 14 ] = KEY_TUNER, // Air/Cable
[ 17 ] = KEY_VIDEO, // Video
[ 21 ] = KEY_AUDIO, // Audio
[ 0 ] = KEY_POWER, // Pover
[ 2 ] = KEY_ZOOM, // Fullscreen
[ 27 ] = KEY_MUTE, // Mute
[ 20 ] = KEY_VOLUMEUP,
[ 23 ] = KEY_VOLUMEDOWN,
[ 18 ] = KEY_CHANNELUP, // Channel +
[ 19 ] = KEY_CHANNELDOWN, // Channel -
[ 6 ] = KEY_AGAIN, // Recal
[ 16 ] = KEY_KPENTER, // Enter
#if 1 /* FIXME */
[ 26 ] = KEY_F22, // Stereo
[ 24 ] = KEY_EDIT, // AV Source
#endif
};
static IR_KEYTAB_TYPE cinergy_codes[IR_KEYTAB_SIZE] = {
[ 0 ] = KEY_KP0,
[ 1 ] = KEY_KP1,
[ 2 ] = KEY_KP2,
[ 3 ] = KEY_KP3,
[ 4 ] = KEY_KP4,
[ 5 ] = KEY_KP5,
[ 6 ] = KEY_KP6,
[ 7 ] = KEY_KP7,
[ 8 ] = KEY_KP8,
[ 9 ] = KEY_KP9,
[ 0x0a ] = KEY_POWER,
[ 0x0b ] = KEY_PROG1, // app
[ 0x0c ] = KEY_ZOOM, // zoom/fullscreen
[ 0x0d ] = KEY_CHANNELUP, // channel
[ 0x0e ] = KEY_CHANNELDOWN, // channel-
[ 0x0f ] = KEY_VOLUMEUP,
[ 0x10 ] = KEY_VOLUMEDOWN,
[ 0x11 ] = KEY_TUNER, // AV
[ 0x12 ] = KEY_NUMLOCK, // -/--
[ 0x13 ] = KEY_AUDIO, // audio
[ 0x14 ] = KEY_MUTE,
[ 0x15 ] = KEY_UP,
[ 0x16 ] = KEY_DOWN,
[ 0x17 ] = KEY_LEFT,
[ 0x18 ] = KEY_RIGHT,
[ 0x19 ] = BTN_LEFT,
[ 0x1a ] = BTN_RIGHT,
[ 0x1b ] = KEY_WWW, // text
[ 0x1c ] = KEY_REWIND,
[ 0x1d ] = KEY_FORWARD,
[ 0x1e ] = KEY_RECORD,
[ 0x1f ] = KEY_PLAY,
[ 0x20 ] = KEY_PREVIOUSSONG,
[ 0x21 ] = KEY_NEXTSONG,
[ 0x22 ] = KEY_PAUSE,
[ 0x23 ] = KEY_STOP,
};
/* ---------------------------------------------------------------------- */
static int build_key(struct saa7134_dev *dev)
{
struct saa7134_ir *ir = dev->remote;
u32 gpio, data;
/* rising SAA7134_GPIO_GPRESCAN reads the status */
saa_clearb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN);
saa_setb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN);
gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2);
data = ir_extract_bits(gpio, ir->mask_keycode);
printk("%s: build_key gpio=0x%x mask=0x%x data=%d\n",
dev->name, gpio, ir->mask_keycode, data);
if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) ||
(ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) {
ir_input_keydown(&ir->dev,&ir->ir,data,data);
} else {
ir_input_nokey(&ir->dev,&ir->ir);
}
return 0;
}
/* ---------------------------------------------------------------------- */
void saa7134_input_irq(struct saa7134_dev *dev)
{
build_key(dev);
}
int saa7134_input_init1(struct saa7134_dev *dev)
{
struct saa7134_ir *ir;
IR_KEYTAB_TYPE *ir_codes = NULL;
u32 mask_keycode = 0;
u32 mask_keydown = 0;
u32 mask_keyup = 0;
int ir_type = IR_TYPE_OTHER;
/* detect & configure */
if (!dev->has_remote)
return -ENODEV;
switch (dev->board) {
case SAA7134_BOARD_FLYVIDEO2000:
case SAA7134_BOARD_FLYVIDEO3000:
ir_codes = flyvideo_codes;
mask_keycode = 0xEC00000;
mask_keydown = 0x0040000;
break;
case SAA7134_BOARD_CINERGY400:
case SAA7134_BOARD_CINERGY600:
ir_codes = cinergy_codes;
mask_keycode = 0x00003f;
mask_keyup = 0x040000;
break;
}
if (NULL == ir_codes) {
printk("%s: Oops: IR config error [card=%d]\n",
dev->name, dev->board);
return -ENODEV;
}
ir = kmalloc(sizeof(*ir),GFP_KERNEL);
if (NULL == ir)
return -ENOMEM;
memset(ir,0,sizeof(*ir));
/* init hardware-specific stuff */
ir->mask_keycode = mask_keycode;
ir->mask_keydown = mask_keydown;
ir->mask_keyup = mask_keyup;
/* init input device */
snprintf(ir->name, sizeof(ir->name), "saa7134 IR (%s)",
saa7134_boards[dev->board].name);
snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
pci_name(dev->pci));
ir_input_init(&ir->dev, &ir->ir, ir_type, ir_codes);
ir->dev.name = ir->name;
ir->dev.phys = ir->phys;
ir->dev.id.bustype = BUS_PCI;
ir->dev.id.version = 1;
if (dev->pci->subsystem_vendor) {
ir->dev.id.vendor = dev->pci->subsystem_vendor;
ir->dev.id.product = dev->pci->subsystem_device;
} else {
ir->dev.id.vendor = dev->pci->vendor;
ir->dev.id.product = dev->pci->device;
}
/* all done */
dev->remote = ir;
input_register_device(&dev->remote->dev);
printk("%s: registered input device for IR\n",dev->name);
return 0;
}
void saa7134_input_fini(struct saa7134_dev *dev)
{
if (NULL == dev->remote)
return;
input_unregister_device(&dev->remote->dev);
kfree(dev->remote);
dev->remote = NULL;
}
/* ----------------------------------------------------------------------
* Local variables:
* c-basic-offset: 8
* End:
*/
......@@ -40,7 +40,7 @@ MODULE_PARM(oss_rate,"i");
MODULE_PARM_DESC(oss_rate,"sample rate (valid are: 32000,48000)");
#define dprintk(fmt, arg...) if (oss_debug) \
printk(KERN_DEBUG "%s/oss: " fmt, dev->name, ## arg)
printk(KERN_DEBUG "%s/oss: " fmt, dev->name , ## arg)
/* ------------------------------------------------------------------ */
......@@ -295,8 +295,10 @@ static ssize_t dsp_read(struct file *file, char *buffer,
break;
}
up(&dev->oss.lock);
current->state = TASK_INTERRUPTIBLE;
set_current_state(TASK_INTERRUPTIBLE);
if (0 == dev->oss.read_count)
schedule();
set_current_state(TASK_RUNNING);
down(&dev->oss.lock);
if (signal_pending(current)) {
if (0 == ret)
......@@ -328,7 +330,6 @@ static ssize_t dsp_read(struct file *file, char *buffer,
}
up(&dev->oss.lock);
remove_wait_queue(&dev->oss.wq, &wait);
current->state = TASK_RUNNING;
return ret;
}
......@@ -777,7 +778,7 @@ void saa7134_irq_oss_done(struct saa7134_dev *dev, unsigned long status)
spin_lock(&dev->slock);
if (UNSET == dev->oss.dma_blk) {
dprintk("irq: recording stopped%s\n","");
dprintk("irq: recording stopped\n");
goto done;
}
if (0 != (status & 0x0f000000))
......
......@@ -45,7 +45,7 @@ MODULE_PARM_DESC(tsbufs,"number of ts buffers, range 2-32");
#define TS_NR_PACKETS 312
#define dprintk(fmt, arg...) if (ts_debug) \
printk(KERN_DEBUG "%s/ts: " fmt, dev->name, ## arg)
printk(KERN_DEBUG "%s/ts: " fmt, dev->name , ## arg)
/* ------------------------------------------------------------------ */
......@@ -173,7 +173,7 @@ static void ts_reset_encoder(struct saa7134_dev* dev)
saa_writeb(SAA7134_SPECIAL_MODE, 0x00);
mdelay(10);
saa_writeb(SAA7134_SPECIAL_MODE, 0x01);
current->state = TASK_INTERRUPTIBLE;
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(HZ/10);
}
......@@ -196,7 +196,7 @@ static int ts_open(struct inode *inode, struct file *file)
list_for_each(list,&saa7134_devlist) {
h = list_entry(list, struct saa7134_dev, devlist);
if (h->ts_dev->minor == minor)
if (h->ts_dev && h->ts_dev->minor == minor)
dev = h;
}
if (NULL == dev)
......
......@@ -41,8 +41,16 @@ 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");
static int audio_clock_tweak = 0;
MODULE_PARM(audio_clock_tweak, "i");
MODULE_PARM_DESC(audio_clock_tweak, "Audio clock tick fine tuning for cards with audio crystal that's slightly off (range [-1024 .. 1024])");
#define dprintk(fmt, arg...) if (audio_debug) \
printk(KERN_DEBUG "%s/audio: " fmt, dev->name, ## arg)
printk(KERN_DEBUG "%s/audio: " fmt, dev->name , ## arg)
#define d2printk(fmt, arg...) if (audio_debug > 1) \
printk(KERN_DEBUG "%s/audio: " fmt, dev->name, ## arg)
......@@ -50,7 +58,7 @@ MODULE_PARM_DESC(audio_carrier,"audio carrier location");
dev->name,(SAA7134_##reg),(#reg),saa_readb((SAA7134_##reg)))
#define SCAN_INITIAL_DELAY (HZ)
#define SCAN_SAMPLE_DELAY (HZ/10)
#define SCAN_SAMPLE_DELAY (HZ/5)
/* ------------------------------------------------------------------ */
/* saa7134 code */
......@@ -186,8 +194,11 @@ static void mute_input_7134(struct saa7134_dev *dev)
in = &card(dev).mute;
}
if (dev->hw_mute == mute &&
dev->hw_input == in)
dev->hw_input == in) {
dprintk("mute/input: nothing to do [mute=%d,input=%s]\n",
mute,in->name);
return;
}
dprintk("ctl_mute=%d automute=%d input=%s => mute=%d input=%s\n",
dev->ctl_mute,dev->automute,dev->input->name,mute,in->name);
......@@ -221,21 +232,27 @@ static void tvaudio_setmode(struct saa7134_dev *dev,
struct saa7134_tvaudio *audio,
char *note)
{
if (note)
dprintk("tvaudio_setmode: %s %s [%d.%03d/%d.%03d MHz]\n",
note,audio->name,
audio->carr1 / 1000, audio->carr1 % 1000,
audio->carr2 / 1000, audio->carr2 % 1000);
int acpf, tweak = 0;
if (dev->tvnorm->id == V4L2_STD_NTSC) {
saa_writeb(SAA7134_AUDIO_CLOCKS_PER_FIELD0, 0xde);
saa_writeb(SAA7134_AUDIO_CLOCKS_PER_FIELD1, 0x15);
saa_writeb(SAA7134_AUDIO_CLOCKS_PER_FIELD2, 0x02);
acpf = 0x19066;
} else {
saa_writeb(SAA7134_AUDIO_CLOCKS_PER_FIELD0, 0x00);
saa_writeb(SAA7134_AUDIO_CLOCKS_PER_FIELD1, 0x80);
saa_writeb(SAA7134_AUDIO_CLOCKS_PER_FIELD2, 0x02);
acpf = 0x1e000;
}
if (audio_clock_tweak > -1024 && audio_clock_tweak < 1024)
tweak = audio_clock_tweak;
if (note)
dprintk("tvaudio_setmode: %s %s [%d.%03d/%d.%03d MHz] acpf=%d%+d\n",
note,audio->name,
audio->carr1 / 1000, audio->carr1 % 1000,
audio->carr2 / 1000, audio->carr2 % 1000,
acpf, tweak);
acpf += tweak;
saa_writeb(SAA7134_AUDIO_CLOCKS_PER_FIELD0, (acpf & 0x0000ff) >> 0);
saa_writeb(SAA7134_AUDIO_CLOCKS_PER_FIELD1, (acpf & 0x00ff00) >> 8);
saa_writeb(SAA7134_AUDIO_CLOCKS_PER_FIELD2, (acpf & 0x030000) >> 16);
tvaudio_setcarrier(dev,audio->carr1,audio->carr2);
switch (audio->mode) {
......@@ -259,18 +276,19 @@ static void tvaudio_setmode(struct saa7134_dev *dev,
saa_writeb(SAA7134_DCXO_IDENT_CTRL, 0x00);
saa_writeb(SAA7134_FM_DEEMPHASIS, 0x44);
saa_writeb(SAA7134_STEREO_DAC_OUTPUT_SELECT, 0xa1);
saa_writeb(SAA7134_NICAM_CONFIG, 0x00);
break;
case TVAUDIO_NICAM_AM:
saa_writeb(SAA7134_DEMODULATOR, 0x12);
saa_writeb(SAA7134_DCXO_IDENT_CTRL, 0x00);
saa_writeb(SAA7134_FM_DEEMPHASIS, 0x44);
saa_writeb(SAA7134_STEREO_DAC_OUTPUT_SELECT, 0xa1);
saa_writeb(SAA7134_NICAM_CONFIG, 0x00);
break;
case TVAUDIO_FM_SAT_STEREO:
/* not implemented (yet) */
break;
}
saa_writel(0x174 >> 2, 0x0001e000); /* FIXME */
}
static int tvaudio_sleep(struct saa7134_dev *dev, int timeout)
......@@ -278,7 +296,7 @@ static int tvaudio_sleep(struct saa7134_dev *dev, int timeout)
DECLARE_WAITQUEUE(wait, current);
add_wait_queue(&dev->thread.wq, &wait);
current->state = TASK_INTERRUPTIBLE;
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(timeout);
remove_wait_queue(&dev->thread.wq, &wait);
return dev->thread.scan1 != dev->thread.scan2;
......@@ -437,7 +455,7 @@ static int tvaudio_thread(void *data)
const int *carr_scan;
int carr_vals[4];
unsigned int i, audio;
int max1,max2,carrier,rx,mode;
int max1,max2,carrier,rx,mode,lastmode;
lock_kernel();
daemonize("%s", dev->name);
......@@ -535,7 +553,7 @@ static int tvaudio_thread(void *data)
if (UNSET == audio)
audio = i;
tvaudio_setmode(dev,&tvaudio[i],"trying");
if (tvaudio_sleep(dev,HZ))
if (tvaudio_sleep(dev,HZ*2))
goto restart;
if (-1 != tvaudio_getstereo(dev,&tvaudio[i])) {
audio = i;
......@@ -549,8 +567,9 @@ static int tvaudio_thread(void *data)
tvaudio_setstereo(dev,&tvaudio[audio],V4L2_TUNER_MODE_MONO);
dev->tvaudio = &tvaudio[audio];
lastmode = 42;
for (;;) {
if (tvaudio_sleep(dev,3*HZ))
if (tvaudio_sleep(dev,5*HZ))
goto restart;
if (dev->thread.exit || signal_pending(current))
break;
......@@ -560,7 +579,10 @@ static int tvaudio_thread(void *data)
} else {
mode = dev->thread.mode;
}
if (lastmode != mode) {
tvaudio_setstereo(dev,&tvaudio[audio],mode);
lastmode = mode;
}
}
}
......@@ -602,8 +624,8 @@ static char *stdres[0x20] = {
[0x1f] = "??? [in progress]",
};
#define DSP_RETRY 30
#define DSP_DELAY 10
#define DSP_RETRY 32
#define DSP_DELAY 16
static inline int saa_dsp_wait_bit(struct saa7134_dev *dev, int bit)
{
......@@ -721,15 +743,34 @@ static int tvaudio_thread_ddep(void *data)
dev->thread.scan1 = dev->thread.scan2;
dprintk("tvaudio thread scan start [%d]\n",dev->thread.scan1);
if (audio_ddep >= 0x04 && audio_ddep <= 0x0e) {
/* insmod option override */
norms = (audio_ddep << 2) | 0x01;
dprintk("ddep override: %s\n",stdres[audio_ddep]);
} else{
/* (let chip) scan for sound carrier */
norms = 0;
if (dev->tvnorm->id & V4L2_STD_PAL)
if (dev->tvnorm->id & V4L2_STD_PAL) {
dprintk("PAL scan\n");
norms |= 0x2c; /* B/G + D/K + I */
if (dev->tvnorm->id & V4L2_STD_NTSC)
}
if (dev->tvnorm->id & V4L2_STD_NTSC) {
dprintk("NTSC scan\n");
norms |= 0x40; /* M */
if (dev->tvnorm->id & V4L2_STD_SECAM)
}
if (dev->tvnorm->id & V4L2_STD_SECAM) {
dprintk("SECAM scan\n");
norms |= 0x18; /* L + D/K */
}
if (0 == norms)
norms = 0x0000007c;
norms = 0x7c; /* all */
dprintk("scanning:%s%s%s%s%s\n",
(norms & 0x04) ? " B/G" : "",
(norms & 0x08) ? " D/K" : "",
(norms & 0x10) ? " L/L'" : "",
(norms & 0x20) ? " I" : "",
(norms & 0x40) ? " M" : "");
}
/* quick & dirty -- to be fixed up later ... */
saa_dsp_writel(dev, 0x454 >> 2, 0);
......@@ -856,17 +897,12 @@ int saa7134_tvaudio_init2(struct saa7134_dev *dev)
/* enable I2S audio output */
if (saa7134_boards[dev->board].i2s_rate) {
int rate = (32000 == saa7134_boards[dev->board].i2s_rate)
? 0x01 : 0x03;
/* set rate */
saa_andorb(SAA7134_SIF_SAMPLE_FREQ, 0x03, rate);
int i2sform = (32000 == saa7134_boards[dev->board].i2s_rate) ? 0x00 : 0x01;
/* enable I2S output */
saa_writeb(SAA7134_DSP_OUTPUT_SELECT, 0x80);
saa_writeb(SAA7134_I2S_OUTPUT_SELECT, 0x80);
saa_writeb(SAA7134_I2S_OUTPUT_FORMAT, 0x01);
saa_writeb(SAA7134_I2S_OUTPUT_LEVEL, 0x00);
saa_writeb(SAA7134_I2S_OUTPUT_FORMAT, i2sform);
saa_writeb(SAA7134_I2S_OUTPUT_LEVEL, 0x0F);
saa_writeb(SAA7134_I2S_AUDIO_OUTPUT, 0x01);
}
......
......@@ -39,7 +39,7 @@ MODULE_PARM(vbibufs,"i");
MODULE_PARM_DESC(vbibufs,"number of vbi buffers, range 2-32");
#define dprintk(fmt, arg...) if (vbi_debug) \
printk(KERN_DEBUG "%s/vbi: " fmt, dev->name, ## arg)
printk(KERN_DEBUG "%s/vbi: " fmt, dev->name , ## arg)
/* ------------------------------------------------------------------ */
......
......@@ -40,7 +40,7 @@ MODULE_PARM(gbuffers,"i");
MODULE_PARM_DESC(gbuffers,"number of capture buffers, range 2-32");
#define dprintk(fmt, arg...) if (video_debug) \
printk(KERN_DEBUG "%s/video: " fmt, dev->name, ## arg)
printk(KERN_DEBUG "%s/video: " fmt, dev->name , ## arg)
/* ------------------------------------------------------------------ */
/* data structs for video */
......@@ -82,6 +82,12 @@ static struct saa7134_format formats[] = {
.fourcc = V4L2_PIX_FMT_BGR24,
.depth = 24,
.pm = 0x11,
},{
.name = "24 bpp RGB, be",
.fourcc = V4L2_PIX_FMT_RGB24,
.depth = 24,
.pm = 0x11,
.bswap = 1,
},{
.name = "32 bpp RGB, le",
.fourcc = V4L2_PIX_FMT_BGR32,
......@@ -125,6 +131,16 @@ static struct saa7134_format formats[] = {
.planar = 1,
.hshift = 1,
.vshift = 1,
},{
.name = "4:2:0 planar, Y-Cb-Cr",
.fourcc = V4L2_PIX_FMT_YVU420,
.depth = 12,
.pm = 0x0a,
.yuv = 1,
.planar = 1,
.uvswap = 1,
.hshift = 1,
.vshift = 1,
}
};
#define FORMATS ARRAY_SIZE(formats)
......@@ -788,7 +804,7 @@ static int buffer_activate(struct saa7134_dev *dev,
struct saa7134_buf *next)
{
unsigned long base,control,bpl;
unsigned long bpl_uv,lines_uv,base2,base3; /* planar */
unsigned long bpl_uv,lines_uv,base2,base3,tmp; /* planar */
dprintk("buffer_activate buf=%p\n",buf);
buf->vb.state = STATE_ACTIVE;
......@@ -834,6 +850,8 @@ static int buffer_activate(struct saa7134_dev *dev,
lines_uv = buf->vb.height >> buf->fmt->vshift;
base2 = base + bpl * buf->vb.height;
base3 = base2 + bpl_uv * lines_uv;
if (buf->fmt->uvswap)
tmp = base2, base2 = base3, base3 = tmp;
dprintk("uv: bpl=%ld lines=%ld base2/3=%ld/%ld\n",
bpl_uv,lines_uv,base2,base3);
if (V4L2_FIELD_HAS_BOTH(buf->vb.field)) {
......@@ -1160,6 +1178,9 @@ static int video_open(struct inode *inode, struct file *file)
fh->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24);
fh->width = 768;
fh->height = 576;
#ifdef VIDIOC_G_PRIORITY
v4l2_prio_open(&dev->prio,&fh->prio);
#endif
videobuf_queue_init(&fh->cap, &video_qops,
dev->pci, &dev->slock,
......@@ -1268,7 +1289,7 @@ static int video_release(struct inode *inode, struct file *file)
/* stop video capture */
if (res_check(fh, RESOURCE_VIDEO)) {
videobuf_queue_cancel(file,&fh->cap);
videobuf_streamoff(file,&fh->cap);
res_free(dev,fh,RESOURCE_VIDEO);
}
if (fh->cap.read_buf) {
......@@ -1288,6 +1309,9 @@ static int video_release(struct inode *inode, struct file *file)
saa7134_pgtable_free(dev->pci,&fh->pt_cap);
saa7134_pgtable_free(dev->pci,&fh->pt_vbi);
#ifdef VIDIOC_G_PRIORITY
v4l2_prio_close(&dev->prio,&fh->prio);
#endif
file->private_data = NULL;
kfree(fh);
return 0;
......@@ -1568,6 +1592,20 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
if (video_debug > 1)
saa7134_print_ioctl(dev->name,cmd);
#ifdef VIDIOC_G_PRIORITY
switch (cmd) {
case VIDIOC_S_CTRL:
case VIDIOC_S_STD:
case VIDIOC_S_INPUT:
case VIDIOC_S_TUNER:
case VIDIOC_S_FREQUENCY:
err = v4l2_prio_check(&dev->prio,&fh->prio);
if (0 != err)
return err;
}
#endif
switch (cmd) {
case VIDIOC_QUERYCAP:
{
......@@ -1697,6 +1735,7 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
down(&dev->lock);
dev->ctl_freq = f->frequency;
saa7134_i2c_call_clients(dev,VIDIOCSFREQ,&dev->ctl_freq);
saa7134_tvaudio_do_scan(dev);
up(&dev->lock);
return 0;
}
......@@ -1727,6 +1766,22 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
return 0;
}
#ifdef VIDIOC_G_PRIORITY
case VIDIOC_G_PRIORITY:
{
enum v4l2_priority *p = arg;
*p = v4l2_prio_max(&dev->prio);
return 0;
}
case VIDIOC_S_PRIORITY:
{
enum v4l2_priority *prio = arg;
return v4l2_prio_change(&dev->prio, &fh->prio, *prio);
}
#endif
/* --- preview ioctls ---------------------------------------- */
case VIDIOC_ENUM_FMT:
{
......@@ -2148,8 +2203,8 @@ void saa7134_irq_video_done(struct saa7134_dev *dev, unsigned long status)
spin_lock(&dev->slock);
if (dev->video_q.curr) {
dev->video_fieldcount++;
field = dev->video_q.curr->vb.field;
if (V4L2_FIELD_HAS_BOTH(field)) {
/* make sure we have seen both fields */
if ((status & 0x10) == 0x00) {
......@@ -2165,6 +2220,7 @@ void saa7134_irq_video_done(struct saa7134_dev *dev, unsigned long status)
if ((status & 0x10) != 0x00)
goto done;
}
dev->video_q.curr->vb.field_count = dev->video_fieldcount;
saa7134_buffer_finish(dev,&dev->video_q,STATE_DONE);
}
saa7134_buffer_next(dev,&dev->video_q);
......
......@@ -29,14 +29,11 @@
#include <asm/io.h>
#ifdef CONFIG_VIDEO_IR
#include "ir-common.h"
#endif
#include <media/video-buf.h>
#include <media/tuner.h>
#include <media/audiochip.h>
#include <media/id.h>
#include <media/ir-common.h>
#ifndef TRUE
# define TRUE (1==1)
......@@ -116,6 +113,7 @@ struct saa7134_format {
unsigned int wswap:1;
unsigned int yuv:1;
unsigned int planar:1;
unsigned int uvswap:1;
};
/* ----------------------------------------------------------- */
......@@ -143,6 +141,16 @@ struct saa7134_format {
#define SAA7134_BOARD_BMK_MPEX_NOTUNER 18
#define SAA7134_BOARD_VIDEOMATE_TV 19
#define SAA7134_BOARD_CRONOS_PLUS 20
#define SAA7134_BOARD_10MOONSTVMASTER 21
#define SAA7134_BOARD_MD2819 22
#define SAA7134_BOARD_BMK_MPEX_TUNER 23
#define SAA7134_BOARD_TVSTATION_DVR 24
#define SAA7134_BOARD_ASUSTEK_TVFM7133 25
#define SAA7134_BOARD_PINNACLE_PCTV_STEREO 26
#define SAA7134_BOARD_MANLI_MTV002 27
#define SAA7134_BOARD_MANLI_MTV001 28
#define SAA7134_BOARD_TG3000TV 29
#define SAA7134_BOARD_ECS_TVP3XP 30
#define SAA7134_INPUT_MAX 8
......@@ -242,11 +250,15 @@ struct saa7134_fh {
struct saa7134_dev *dev;
unsigned int radio;
enum v4l2_buf_type type;
unsigned int resources;
#ifdef VIDIOC_G_PRIORITY
enum v4l2_priority prio;
#endif
/* video overlay */
struct v4l2_window win;
struct v4l2_clip clips[8];
unsigned int nclips;
unsigned int resources;
/* video capture */
struct saa7134_format *fmt;
......@@ -298,7 +310,6 @@ struct saa7134_oss {
unsigned int read_count;
};
#ifdef CONFIG_VIDEO_IR
/* IR input */
struct saa7134_ir {
struct input_dev dev;
......@@ -307,14 +318,17 @@ struct saa7134_ir {
char phys[32];
u32 mask_keycode;
u32 mask_keydown;
u32 mask_keyup;
};
#endif
/* global device status */
struct saa7134_dev {
struct list_head devlist;
struct semaphore lock;
spinlock_t slock;
#ifdef VIDIOC_G_PRIORITY
struct v4l2_prio_state prio;
#endif
/* various device info */
unsigned int resources;
......@@ -327,9 +341,7 @@ struct saa7134_dev {
/* infrared remote */
int has_remote;
#ifdef CONFIG_VIDEO_IR
struct saa7134_ir *remote;
#endif
/* pci i/o */
char name[32];
......@@ -358,6 +370,7 @@ struct saa7134_dev {
struct saa7134_dmaqueue video_q;
struct saa7134_dmaqueue ts_q;
struct saa7134_dmaqueue vbi_q;
unsigned int video_fieldcount;
unsigned int vbi_fieldcount;
/* various v4l controls */
......@@ -403,9 +416,7 @@ struct saa7134_dev {
#define saa_setb(reg,bit) saa_andorb((reg),(bit),(bit))
#define saa_clearb(reg,bit) saa_andorb((reg),(bit),0)
//#define saa_wait(d) { if (need_resched()) schedule(); else udelay(d);}
#define saa_wait(d) { udelay(d); }
//#define saa_wait(d) { schedule_timeout(HZ*d/1000 ?:1); }
/* ----------------------------------------------------------- */
/* saa7134-core.c */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment