Commit 9d8a5eb8 authored by Linus Torvalds's avatar Linus Torvalds

Merge bk://kernel.bkbits.net/davem/sparc-2.5

into home.osdl.org:/home/torvalds/v2.5/linux
parents a11c692b 7cfb5e64
......@@ -53,6 +53,11 @@ void __init fpu_init(void)
*/
void init_fpu(struct task_struct *child)
{
if (child->used_math) {
if (child == current)
unlazy_fpu(child);
return;
}
memset(&child->thread.i387.fxsave, 0, sizeof(struct i387_fxsave_struct));
child->thread.i387.fxsave.cwd = 0x37f;
child->thread.i387.fxsave.mxcsr = 0x1f80;
......
......@@ -235,7 +235,7 @@ static int buffer_prepare(struct file *file, struct videobuf_buffer *vb,enum v4l
saa7146_pgtable_free(dev->pci, &buf->pt[2]);
saa7146_pgtable_alloc(dev->pci, &buf->pt[2]);
err = videobuf_iolock(dev->pci,&buf->vb);
err = videobuf_iolock(dev->pci,&buf->vb,NULL);
if (err)
goto oops;
saa7146_pgtable_build_single(dev->pci, &buf->pt[2], buf->vb.dma.sglist, buf->vb.dma.sglen);
......
......@@ -1090,7 +1090,8 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
q = &fh->video_q;
down(&q->lock);
err = videobuf_mmap_setup(file,q,gbuffers,gbufsize); // ,V4L2_MEMORY_MMAP);
err = videobuf_mmap_setup(file,q,gbuffers,gbufsize,
V4L2_MEMORY_MMAP);
if (err < 0) {
up(&q->lock);
return err;
......@@ -1185,7 +1186,7 @@ static int buffer_prepare(struct file *file, struct videobuf_buffer *vb, enum v4
saa7146_pgtable_alloc(dev->pci, &buf->pt[0]);
}
err = videobuf_iolock(dev->pci,&buf->vb);
err = videobuf_iolock(dev->pci,&buf->vb,NULL);
if (err)
goto oops;
err = saa7146_pgtable_build(dev,buf);
......
......@@ -282,13 +282,16 @@
#define BT848_GPIO_DMA_CTL_FIFO_ENABLE (1<<0)
#define BT848_I2C 0x110
#define BT878_I2C_MODE (1<<7)
#define BT878_I2C_RATE (1<<6)
#define BT878_I2C_NOSTOP (1<<5)
#define BT878_I2C_NOSTART (1<<4)
#define BT848_I2C_DIV (0xf<<4)
#define BT848_I2C_SYNC (1<<3)
#define BT848_I2C_W3B (1<<2)
#define BT848_I2C_SCL (1<<1)
#define BT848_I2C_SDA (1<<0)
#define BT848_RISC_STRT_ADD 0x114
#define BT848_GPIO_OUT_EN 0x118
#define BT848_GPIO_REG_INP 0x11C
......
......@@ -44,39 +44,6 @@ MODULE_PARM_DESC(debug,"debug messages, default is 0 (no)");
static int memcnt;
int btcx_riscmem_alloc(struct pci_dev *pci,
struct btcx_riscmem *risc,
unsigned int size)
{
u32 *cpu;
dma_addr_t dma;
cpu = pci_alloc_consistent(pci, size, &dma);
if (NULL == cpu)
return -ENOMEM;
memset(cpu,0,size);
#if 0
if (risc->cpu && risc->size < size) {
/* realloc (enlarge buffer) -- copy old stuff */
memcpy(cpu,risc->cpu,risc->size);
btcx_riscmem_free(pci,risc);
}
#else
BUG_ON(NULL != risc->cpu);
#endif
risc->cpu = cpu;
risc->dma = dma;
risc->size = size;
if (debug) {
memcnt++;
printk("btcx: riscmem alloc size=%d [%d]\n",size,memcnt);
}
return 0;
}
void btcx_riscmem_free(struct pci_dev *pci,
struct btcx_riscmem *risc)
{
......@@ -90,6 +57,31 @@ void btcx_riscmem_free(struct pci_dev *pci,
}
}
int btcx_riscmem_alloc(struct pci_dev *pci,
struct btcx_riscmem *risc,
unsigned int size)
{
u32 *cpu;
dma_addr_t dma;
if (NULL != risc->cpu && risc->size < size)
btcx_riscmem_free(pci,risc);
if (NULL == risc->cpu) {
cpu = pci_alloc_consistent(pci, size, &dma);
if (NULL == cpu)
return -ENOMEM;
risc->cpu = cpu;
risc->dma = dma;
risc->size = size;
if (debug) {
memcnt++;
printk("btcx: riscmem alloc size=%d [%d]\n",size,memcnt);
}
}
memset(risc->cpu,0,risc->size);
return 0;
}
/* ---------------------------------------------------------- */
/* screen overlay helpers */
......
This diff is collapsed.
This diff is collapsed.
......@@ -27,15 +27,23 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <asm/io.h>
#include "bttvp.h"
static struct i2c_algo_bit_data bttv_i2c_algo_template;
static struct i2c_adapter bttv_i2c_adap_template;
static struct i2c_algo_bit_data bttv_i2c_algo_bit_template;
static struct i2c_adapter bttv_i2c_adap_sw_template;
static struct i2c_adapter bttv_i2c_adap_hw_template;
static struct i2c_client bttv_i2c_client_template;
#ifndef I2C_PEC
static void bttv_inc_use(struct i2c_adapter *adap);
static void bttv_dec_use(struct i2c_adapter *adap);
#endif
static int attach_inform(struct i2c_client *client);
EXPORT_SYMBOL(bttv_get_cardinfo);
EXPORT_SYMBOL(bttv_get_pcidev);
EXPORT_SYMBOL(bttv_get_id);
......@@ -45,6 +53,11 @@ EXPORT_SYMBOL(bttv_write_gpio);
EXPORT_SYMBOL(bttv_get_gpio_queue);
EXPORT_SYMBOL(bttv_i2c_call);
static int i2c_debug = 0;
static int i2c_hw = 0;
MODULE_PARM(i2c_debug,"i");
MODULE_PARM(i2c_hw,"i");
/* ----------------------------------------------------------------------- */
/* Exported functions - for other modules which want to access the */
/* gpio ports (IR for example) */
......@@ -76,6 +89,7 @@ int bttv_get_id(unsigned int card)
return bttvs[card].type;
}
int bttv_gpio_enable(unsigned int card, unsigned long mask, unsigned long data)
{
struct bttv *btv;
......@@ -146,7 +160,7 @@ wait_queue_head_t* bttv_get_gpio_queue(unsigned int card)
/* ----------------------------------------------------------------------- */
/* I2C functions */
/* I2C functions - bitbanging adapter (software i2c) */
void bttv_bit_setscl(void *data, int state)
{
......@@ -190,6 +204,222 @@ static int bttv_bit_getsda(void *data)
return state;
}
static struct i2c_algo_bit_data bttv_i2c_algo_bit_template = {
.setsda = bttv_bit_setsda,
.setscl = bttv_bit_setscl,
.getsda = bttv_bit_getsda,
.getscl = bttv_bit_getscl,
.udelay = 16,
.mdelay = 10,
.timeout = 200,
};
static struct i2c_adapter bttv_i2c_adap_sw_template = {
#ifdef I2C_PEC
.owner = THIS_MODULE,
#else
.inc_use = bttv_inc_use,
.dec_use = bttv_dec_use,
#endif
#ifdef I2C_ADAP_CLASS_TV_ANALOG
.class = I2C_ADAP_CLASS_TV_ANALOG,
#endif
I2C_DEVNAME("bt848"),
.id = I2C_HW_B_BT848,
.client_register = attach_inform,
};
/* ----------------------------------------------------------------------- */
/* I2C functions - hardware i2c */
static int algo_control(struct i2c_adapter *adapter,
unsigned int cmd, unsigned long arg)
{
return 0;
}
static u32 functionality(struct i2c_adapter *adap)
{
return I2C_FUNC_SMBUS_EMUL;
}
static int
bttv_i2c_wait_done(struct bttv *btv)
{
u32 stat;
int timeout;
timeout = jiffies + HZ/100 + 1; /* 10ms */
for (;;) {
stat = btread(BT848_INT_STAT);
if (stat & BT848_INT_I2CDONE)
break;
if (time_after(jiffies,timeout))
return -EIO;
udelay(10);
}
btwrite(BT848_INT_I2CDONE|BT848_INT_RACK, BT848_INT_STAT);
return ((stat & BT848_INT_RACK) ? 1 : 0);
}
#define I2C_HW (BT878_I2C_MODE | BT848_I2C_SYNC |\
BT848_I2C_SCL | BT848_I2C_SDA)
static int
bttv_i2c_sendbytes(struct bttv *btv, const struct i2c_msg *msg, int last)
{
u32 xmit;
int retval,cnt;
/* start, address + first byte */
xmit = (msg->addr << 25) | (msg->buf[0] << 16) | I2C_HW;
if (msg->len > 1 || !last)
xmit |= BT878_I2C_NOSTOP;
btwrite(xmit, BT848_I2C);
retval = bttv_i2c_wait_done(btv);
if (retval < 0)
goto err;
if (retval == 0)
goto eio;
if (i2c_debug) {
printk(" <W %02x %02x", msg->addr << 1, msg->buf[0]);
if (!(xmit & BT878_I2C_NOSTOP))
printk(" >\n");
}
for (cnt = 1; cnt < msg->len; cnt++ ) {
/* following bytes */
xmit = (msg->buf[cnt] << 24) | I2C_HW | BT878_I2C_NOSTART;
if (cnt < msg->len-1 || !last)
xmit |= BT878_I2C_NOSTOP;
btwrite(xmit, BT848_I2C);
retval = bttv_i2c_wait_done(btv);
if (retval < 0)
goto err;
if (retval == 0)
goto eio;
if (i2c_debug) {
printk(" %02x", msg->buf[cnt]);
if (!(xmit & BT878_I2C_NOSTOP))
printk(" >\n");
}
}
return msg->len;
eio:
retval = -EIO;
err:
if (i2c_debug)
printk(" ERR: %d\n",retval);
return retval;
}
static int
bttv_i2c_readbytes(struct bttv *btv, const struct i2c_msg *msg, int last)
{
u32 xmit;
u32 cnt;
int retval;
for(cnt = 0; cnt < msg->len; cnt++) {
xmit = (msg->addr << 25) | (1 << 24) | I2C_HW;
if (cnt < msg->len-1)
xmit |= BT848_I2C_W3B;
if (cnt < msg->len-1 || !last)
xmit |= BT878_I2C_NOSTOP;
if (cnt)
xmit |= BT878_I2C_NOSTART;
btwrite(xmit, BT848_I2C);
retval = bttv_i2c_wait_done(btv);
if (retval < 0)
goto err;
if (retval == 0)
goto eio;
msg->buf[cnt] = ((u32)btread(BT848_I2C) >> 8) & 0xff;
if (i2c_debug) {
if (!(xmit & BT878_I2C_NOSTART))
printk(" <R %02x", (msg->addr << 1) +1);
printk(" =%02x", msg->buf[cnt]);
if (!(xmit & BT878_I2C_NOSTOP))
printk(" >\n");
}
}
return msg->len;
eio:
retval = -EIO;
err:
if (i2c_debug)
printk(" ERR: %d\n",retval);
return retval;
}
int bttv_i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[], int num)
{
struct bttv *btv = i2c_get_adapdata(i2c_adap);
int retval = 0;
int i;
if (i2c_debug)
printk("bt-i2c:");
btwrite(BT848_INT_I2CDONE|BT848_INT_RACK, BT848_INT_STAT);
for (i = 0 ; i < num; i++) {
if (msgs[i].flags & I2C_M_RD) {
/* read */
retval = bttv_i2c_readbytes(btv, &msgs[i], i+1 == num);
if (retval < 0)
goto err;
} else {
/* write */
retval = bttv_i2c_sendbytes(btv, &msgs[i], i+1 == num);
if (retval < 0)
goto err;
}
}
return num;
err:
return retval;
}
static struct i2c_algorithm bttv_algo = {
.name = "bt878",
.id = I2C_ALGO_BIT | I2C_HW_B_BT848 /* FIXME */,
.master_xfer = bttv_i2c_xfer,
.algo_control = algo_control,
.functionality = functionality,
};
static struct i2c_adapter bttv_i2c_adap_hw_template = {
#ifdef I2C_PEC
.owner = THIS_MODULE,
#else
.inc_use = bttv_inc_use,
.dec_use = bttv_dec_use,
#endif
#ifdef I2C_ADAP_CLASS_TV_ANALOG
.class = I2C_ADAP_CLASS_TV_ANALOG,
#endif
I2C_DEVNAME("bt878"),
.id = I2C_ALGO_BIT | I2C_HW_B_BT848 /* FIXME */,
.algo = &bttv_algo,
.client_register = attach_inform,
};
/* ----------------------------------------------------------------------- */
/* I2C functions - common stuff */
#ifndef I2C_PEC
static void bttv_inc_use(struct i2c_adapter *adap)
{
MOD_INC_USE_COUNT;
}
static void bttv_dec_use(struct i2c_adapter *adap)
{
MOD_DEC_USE_COUNT;
}
#endif
static int attach_inform(struct i2c_client *client)
{
......@@ -221,24 +451,6 @@ void bttv_i2c_call(unsigned int card, unsigned int cmd, void *arg)
bttv_call_i2c_clients(&bttvs[card], cmd, arg);
}
static struct i2c_algo_bit_data bttv_i2c_algo_template = {
.setsda = bttv_bit_setsda,
.setscl = bttv_bit_setscl,
.getsda = bttv_bit_getsda,
.getscl = bttv_bit_getscl,
.udelay = 16,
.mdelay = 10,
.timeout = 200,
};
static struct i2c_adapter bttv_i2c_adap_template = {
.owner = THIS_MODULE,
.class = I2C_ADAP_CLASS_TV_ANALOG,
I2C_DEVNAME("bt848"),
.id = I2C_HW_B_BT848,
.client_register = attach_inform,
};
static struct i2c_client bttv_i2c_client_template = {
I2C_DEVNAME("bttv internal"),
.id = -1,
......@@ -308,28 +520,56 @@ void __devinit bttv_readee(struct bttv *btv, unsigned char *eedata, int addr)
/* init + register i2c algo-bit adapter */
int __devinit init_bttv_i2c(struct bttv *btv)
{
memcpy(&btv->i2c_adap, &bttv_i2c_adap_template,
sizeof(struct i2c_adapter));
memcpy(&btv->i2c_algo, &bttv_i2c_algo_template,
sizeof(struct i2c_algo_bit_data));
int use_hw = (btv->id == 878) && i2c_hw;
memcpy(&btv->i2c_client, &bttv_i2c_client_template,
sizeof(struct i2c_client));
sizeof(bttv_i2c_client_template));
if (use_hw) {
/* bt878 */
memcpy(&btv->i2c_adap, &bttv_i2c_adap_hw_template,
sizeof(bttv_i2c_adap_hw_template));
} else {
/* bt848 */
memcpy(&btv->i2c_adap, &bttv_i2c_adap_sw_template,
sizeof(bttv_i2c_adap_sw_template));
memcpy(&btv->i2c_algo, &bttv_i2c_algo_bit_template,
sizeof(bttv_i2c_algo_bit_template));
btv->i2c_algo.data = btv;
btv->i2c_adap.algo_data = &btv->i2c_algo;
}
sprintf(btv->i2c_adap.name, "bt848 #%d", btv->nr);
btv->i2c_adap.dev.parent = &btv->dev->dev;
snprintf(btv->i2c_adap.name, sizeof(btv->i2c_adap.name),
"bt%d #%d [%s]", btv->id, btv->nr, use_hw ? "hw" : "sw");
btv->i2c_algo.data = btv;
i2c_set_adapdata(&btv->i2c_adap, btv);
btv->i2c_adap.algo_data = &btv->i2c_algo;
btv->i2c_client.adapter = &btv->i2c_adap;
bttv_bit_setscl(btv,1);
bttv_bit_setsda(btv,1);
btv->i2c_rc = i2c_bit_add_bus(&btv->i2c_adap);
if (use_hw) {
btv->i2c_rc = i2c_add_adapter(&btv->i2c_adap);
} else {
bttv_bit_setscl(btv,1);
bttv_bit_setsda(btv,1);
btv->i2c_rc = i2c_bit_add_bus(&btv->i2c_adap);
}
return btv->i2c_rc;
}
int __devexit fini_bttv_i2c(struct bttv *btv)
{
int use_hw = (btv->id == 878) && i2c_hw;
if (0 != btv->i2c_rc)
return 0;
if (use_hw) {
return i2c_del_adapter(&btv->i2c_adap);
} else {
return i2c_bit_del_bus(&btv->i2c_adap);
}
}
/*
* Local variables:
* c-basic-offset: 8
......
......@@ -33,6 +33,8 @@
#include "bttvp.h"
#define VCR_HACK_LINES 4
/* ---------------------------------------------------------- */
/* risc code generators */
......@@ -62,6 +64,9 @@ bttv_risc_packed(struct bttv *btv, struct btcx_riscmem *risc,
/* scan lines */
sg = sglist;
for (line = 0; line < lines; line++) {
if ((btv->opt_vcr_hack) &&
(line >= (lines - VCR_HACK_LINES)))
continue;
while (offset >= sg_dma_len(sg)) {
offset -= sg_dma_len(sg);
sg++;
......@@ -136,6 +141,9 @@ bttv_risc_planar(struct bttv *btv, struct btcx_riscmem *risc,
usg = sglist;
vsg = sglist;
for (line = 0; line < ylines; line++) {
if ((btv->opt_vcr_hack) &&
(line >= (ylines - VCR_HACK_LINES)))
continue;
switch (vshift) {
case 0: chroma = 1; break;
case 1: chroma = !(line & 1); break;
......@@ -219,8 +227,10 @@ bttv_risc_overlay(struct bttv *btv, struct btcx_riscmem *risc,
instructions = (ov->nclips + 1) *
((skip_even || skip_odd) ? ov->w.height>>1 : ov->w.height);
instructions += 2;
if ((rc = btcx_riscmem_alloc(btv->dev,risc,instructions*8)) < 0)
if ((rc = btcx_riscmem_alloc(btv->dev,risc,instructions*8)) < 0) {
kfree(skips);
return rc;
}
/* sync instruction */
rp = risc->cpu;
......@@ -228,12 +238,18 @@ bttv_risc_overlay(struct bttv *btv, struct btcx_riscmem *risc,
*(rp++) = cpu_to_le32(0);
addr = (unsigned long)btv->fbuf.base;
addr += btv->fbuf.bytesperline * ov->w.top;
addr += ((btv->fbuf.depth+7) >> 3) * ov->w.left;
addr += btv->fbuf.fmt.bytesperline * ov->w.top;
addr += (fmt->depth >> 3) * ov->w.left;
/* scan lines */
for (maxy = -1, line = 0; line < ov->w.height;
line++, addr += btv->fbuf.bytesperline) {
line++, addr += btv->fbuf.fmt.bytesperline) {
if ((btv->opt_vcr_hack) &&
(line >= (ov->w.height - VCR_HACK_LINES)))
continue;
if ((line%2) == 0 && skip_even)
continue;
if ((line%2) == 1 && skip_odd)
if ((line%2) == 0 && skip_even)
continue;
if ((line%2) == 1 && skip_odd)
......
......@@ -87,7 +87,7 @@ static int vbi_buffer_prepare(struct file *file, struct videobuf_buffer *vb,
return -EINVAL;
if (STATE_NEEDS_INIT == buf->vb.state) {
if (0 != (rc = videobuf_iolock(btv->dev,&buf->vb)))
if (0 != (rc = videobuf_iolock(btv->dev, &buf->vb, NULL)))
goto fail;
if (0 != (rc = vbi_buffer_risc(btv,buf,fh->lines)))
goto fail;
......
......@@ -115,6 +115,8 @@
#define BTTV_XGUARD 0x67
#define BTTV_NEBULA_DIGITV 0x68
#define BTTV_PV143 0x69
#define BTTV_IVC100 0x6e
#define BTTV_IVC120 0x6f
/* i2c address list */
#define I2C_TSA5522 0xc2
......@@ -170,6 +172,9 @@ struct tvcard
unsigned int needs_tvaudio:1;
unsigned int msp34xx_alt:1;
/* flag: video pci function is unused */
unsigned int no_video;
/* other settings */
unsigned int pll;
#define PLL_NONE 0
......
......@@ -24,9 +24,8 @@
#ifndef _BTTVP_H_
#define _BTTVP_H_
#include <linux/version.h>
#define BTTV_VERSION_CODE KERNEL_VERSION(0,9,11)
#define BTTV_VERSION_CODE KERNEL_VERSION(0,9,12)
#include <linux/types.h>
#include <linux/wait.h>
......@@ -34,9 +33,11 @@
#include <linux/i2c-algo-bit.h>
#include <linux/videodev.h>
#include <linux/pci.h>
#include <linux/input.h>
#include <asm/scatterlist.h>
#include <asm/io.h>
#include <linux/device.h>
#include <media/video-buf.h>
#include <media/audiochip.h>
#include <media/tuner.h>
......@@ -44,6 +45,9 @@
#include "bt848.h"
#include "bttv.h"
#include "btcx-risc.h"
#ifdef CONFIG_VIDEO_IR
#include "ir-common.h"
#endif
#ifdef __KERNEL__
......@@ -142,6 +146,9 @@ struct bttv_overlay {
struct bttv_fh {
struct bttv *btv;
int resources;
#ifdef VIDIOC_G_PRIORITY
enum v4l2_priority prio;
#endif
enum v4l2_buf_type type;
/* video capture */
......@@ -211,6 +218,12 @@ void bttv_vbi_setlines(struct bttv_fh *fh, struct bttv *btv, int lines);
extern struct videobuf_queue_ops bttv_vbi_qops;
/* ---------------------------------------------------------- */
/* bttv-input.c */
int bttv_input_init(struct bttv *btv);
void bttv_input_fini(struct bttv *btv);
void bttv_input_irq(struct bttv *btv);
/* ---------------------------------------------------------- */
/* bttv-driver.c */
......@@ -221,6 +234,7 @@ extern unsigned int bttv_debug;
extern unsigned int bttv_gpio;
extern void bttv_gpio_tracking(struct bttv *btv, char *comment);
extern int init_bttv_i2c(struct bttv *btv);
extern int fini_bttv_i2c(struct bttv *btv);
extern int pvr_boot(struct bttv *btv);
extern int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg);
......@@ -249,6 +263,18 @@ struct bttv_pll_info {
unsigned int pll_current; /* Currently programmed ofreq */
};
#ifdef CONFIG_VIDEO_IR
/* for gpio-connected remote control */
struct bttv_input {
struct input_dev dev;
struct ir_input_state ir;
char name[32];
char phys[32];
u32 mask_keycode;
u32 mask_keydown;
};
#endif
struct bttv {
/* pci device config */
struct pci_dev *dev;
......@@ -263,6 +289,7 @@ struct bttv {
unsigned int type; /* card type (pointer into tvcards[]) */
unsigned int tuner_type; /* tuner chip type */
unsigned int pinnacle_id;
unsigned int svhs;
struct bttv_pll_info pll;
int triton1;
......@@ -278,22 +305,31 @@ struct bttv {
int i2c_state, i2c_rc;
/* video4linux (1) */
struct video_device video_dev;
struct video_device radio_dev;
struct video_device vbi_dev;
struct video_device *video_dev;
struct video_device *radio_dev;
struct video_device *vbi_dev;
/* infrared remote */
int has_remote;
#ifdef CONFIG_VIDEO_IR
struct bttv_input *remote;
#endif
/* locking */
spinlock_t s_lock;
struct semaphore lock;
int resources;
struct semaphore reslock;
#ifdef VIDIOC_G_PRIORITY
struct v4l2_prio_state prio;
#endif
/* video state */
unsigned int input;
unsigned int audio;
unsigned long freq;
int tvnorm,hue,contrast,bright,saturation;
struct video_buffer fbuf;
struct v4l2_framebuffer fbuf;
unsigned int field_count;
/* various options */
......@@ -302,6 +338,7 @@ struct bttv {
int opt_automute;
int opt_chroma_agc;
int opt_adc_crush;
int opt_vcr_hack;
/* radio data/state */
int has_radio;
......@@ -329,6 +366,7 @@ struct bttv {
struct list_head capture; /* video capture queue */
struct list_head vcapture; /* vbi capture queue */
struct bttv_buffer_set curr; /* active buffers */
int new_input;
unsigned long cap_ctl;
unsigned long dma_on;
......
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/string.h>
#include <linux/timer.h>
#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/poll.h>
#include <linux/i2c.h>
#include <linux/types.h>
#include <linux/videodev.h>
#include <linux/init.h>
#include <media/id.h>
#include <media/saa6752hs.h>
/* Addresses to scan */
static unsigned short normal_i2c[] = {0x20, I2C_CLIENT_END};
static unsigned short normal_i2c_range[] = {I2C_CLIENT_END};
I2C_CLIENT_INSMOD;
MODULE_DESCRIPTION("device driver for saa6752hs MPEG2 encoder");
MODULE_AUTHOR("Andrew de Quincey");
MODULE_LICENSE("GPL");
static struct i2c_driver driver;
static struct i2c_client client_template;
enum saa6752hs_command {
SAA6752HS_COMMAND_RESET = 0,
SAA6752HS_COMMAND_STOP = 1,
SAA6752HS_COMMAND_START = 2,
SAA6752HS_COMMAND_PAUSE = 3,
SAA6752HS_COMMAND_RECONFIGURE = 4,
SAA6752HS_COMMAND_SLEEP = 5,
SAA6752HS_COMMAND_RECONFIGURE_FORCE = 6,
SAA6752HS_COMMAND_MAX
};
/* ---------------------------------------------------------------------- */
static u8 PAT[] = {
0xc2, // i2c register
0x00, // table number for encoder
0x47, // sync
0x40, 0x00, // transport_error_indicator(0), payload_unit_start(1), transport_priority(0), pid(0)
0x10, // transport_scrambling_control(00), adaptation_field_control(01), continuity_counter(0)
0x00, // PSI pointer to start of table
0x00, // tid(0)
0xb0, 0x0d, // section_syntax_indicator(1), section_length(13)
0x00, 0x01, // transport_stream_id(1)
0xc1, // version_number(0), current_next_indicator(1)
0x00, 0x00, // section_number(0), last_section_number(0)
0x00, 0x01, // program_number(1)
0xe0, 0x10, // PMT PID(0x10)
0x76, 0xf1, 0x44, 0xd1 // CRC32
};
static u8 PMT[] = {
0xc2, // i2c register
0x01, // table number for encoder
0x47, // sync
0x40, 0x10, // transport_error_indicator(0), payload_unit_start(1), transport_priority(0), pid(0x10)
0x10, // transport_scrambling_control(00), adaptation_field_control(01), continuity_counter(0)
0x00, // PSI pointer to start of table
0x02, // tid(2)
0xb0, 0x17, // section_syntax_indicator(1), section_length(23)
0x00, 0x01, // program_number(1)
0xc1, // version_number(0), current_next_indicator(1)
0x00, 0x00, // section_number(0), last_section_number(0)
0xe1, 0x04, // PCR_PID (0x104)
0xf0, 0x00, // program_info_length(0)
0x02, 0xe1, 0x00, 0xf0, 0x00, // video stream type(2), pid(0x100)
0x04, 0xe1, 0x03, 0xf0, 0x00, // audio stream type(4), pid(0x103)
0xa1, 0xca, 0x0f, 0x82 // CRC32
};
static struct mpeg_params mpeg_params_template =
{
.bitrate_mode = MPEG_BITRATE_MODE_CBR,
.video_target_bitrate = 5000,
.audio_bitrate = MPEG_AUDIO_BITRATE_256,
.total_bitrate = 6000,
};
/* ---------------------------------------------------------------------- */
static int saa6752hs_chip_command(struct i2c_client* client,
enum saa6752hs_command command)
{
unsigned char buf[3];
unsigned long timeout;
int status = 0;
// execute the command
switch(command) {
case SAA6752HS_COMMAND_RESET:
buf[0] = 0x00;
break;
case SAA6752HS_COMMAND_STOP:
buf[0] = 0x03;
break;
case SAA6752HS_COMMAND_START:
buf[0] = 0x02;
break;
case SAA6752HS_COMMAND_PAUSE:
buf[0] = 0x04;
break;
case SAA6752HS_COMMAND_RECONFIGURE:
buf[0] = 0x05;
break;
case SAA6752HS_COMMAND_SLEEP:
buf[0] = 0x06;
break;
case SAA6752HS_COMMAND_RECONFIGURE_FORCE:
buf[0] = 0x07;
break;
default:
return -EINVAL;
}
// set it and wait for it to be so
i2c_master_send(client, buf, 1);
timeout = jiffies + HZ * 3;
for (;;) {
// get the current status
buf[0] = 0x10;
i2c_master_send(client, buf, 1);
i2c_master_recv(client, buf, 1);
if (!(buf[0] & 0x20))
break;
if (time_after(jiffies,timeout)) {
status = -ETIMEDOUT;
break;
}
// wait a bit
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(1);
}
// delay a bit to let encoder settle
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(5);
// done
return status;
}
static int saa6752hs_set_bitrate(struct i2c_client* client,
struct mpeg_params* params)
{
u8 buf[3];
// set the bitrate mode
buf[0] = 0x71;
buf[1] = params->bitrate_mode;
i2c_master_send(client, buf, 2);
// set the video bitrate
if (params->bitrate_mode == MPEG_BITRATE_MODE_VBR) {
// set the target bitrate
buf[0] = 0x80;
buf[1] = params->video_target_bitrate >> 8;
buf[2] = params->video_target_bitrate & 0xff;
i2c_master_send(client, buf, 3);
// set the max bitrate
buf[0] = 0x81;
buf[1] = params->video_max_bitrate >> 8;
buf[2] = params->video_max_bitrate & 0xff;
i2c_master_send(client, buf, 3);
} else {
// set the target bitrate (no max bitrate for CBR)
buf[0] = 0x81;
buf[1] = params->video_target_bitrate >> 8;
buf[2] = params->video_target_bitrate & 0xff;
i2c_master_send(client, buf, 3);
}
// set the audio bitrate
buf[0] = 0x94;
buf[1] = params->audio_bitrate;
i2c_master_send(client, buf, 2);
// set the total bitrate
buf[0] = 0xb1;
buf[1] = params->total_bitrate >> 8;
buf[2] = params->total_bitrate & 0xff;
i2c_master_send(client, buf, 3);
return 0;
}
static int saa6752hs_init(struct i2c_client* client, struct mpeg_params* params)
{
unsigned char buf[3];
// check the bitrate parameters first
if (params != NULL) {
if (params->bitrate_mode >= MPEG_BITRATE_MODE_MAX)
return -EINVAL;
if (params->video_target_bitrate >= MPEG_VIDEO_TARGET_BITRATE_MAX)
return -EINVAL;
if (params->video_max_bitrate >= MPEG_VIDEO_MAX_BITRATE_MAX)
return -EINVAL;
if (params->audio_bitrate >= MPEG_AUDIO_BITRATE_MAX)
return -EINVAL;
if (params->total_bitrate >= MPEG_TOTAL_BITRATE_MAX)
return -EINVAL;
if (params->bitrate_mode == MPEG_BITRATE_MODE_MAX &&
params->video_target_bitrate <= params->video_max_bitrate)
return -EINVAL;
}
// Set GOP structure {3, 13}
buf[0] = 0x72;
buf[1] = 0x03;
buf[2] = 0x0D;
i2c_master_send(client,buf,3);
// Set minimum Q-scale {4}
buf[0] = 0x82;
buf[1] = 0x04;
i2c_master_send(client,buf,2);
// Set maximum Q-scale {12}
buf[0] = 0x83;
buf[1] = 0x0C;
i2c_master_send(client,buf,2);
// Set Output Protocol
buf[0] = 0xD0;
buf[1] = 0x01;
i2c_master_send(client,buf,2);
// Set video output stream format {TS}
buf[0] = 0xB0;
buf[1] = 0x05;
i2c_master_send(client,buf,2);
// Set Audio PID {0x103}
buf[0] = 0xC1;
buf[1] = 0x01;
buf[2] = 0x03;
i2c_master_send(client,buf,3);
// setup bitrate settings
if (params) {
saa6752hs_set_bitrate(client, params);
memcpy(client->data, params, sizeof(struct mpeg_params));
} else {
// parameters were not supplied. use the previous set
saa6752hs_set_bitrate(client, (struct mpeg_params*) client->data);
}
// Send SI tables
i2c_master_send(client,PAT,sizeof(PAT));
i2c_master_send(client,PMT,sizeof(PMT));
// mute then unmute audio. This removes buzzing artefacts
buf[0] = 0xa4;
buf[1] = 1;
i2c_master_send(client, buf, 2);
buf[1] = 0;
i2c_master_send(client, buf, 2);
// start it going
saa6752hs_chip_command(client, SAA6752HS_COMMAND_START);
return 0;
}
static int saa6752hs_attach(struct i2c_adapter *adap, int addr, int kind)
{
struct i2c_client *client;
struct mpeg_params* params;
client_template.adapter = adap;
client_template.addr = addr;
printk("saa6752hs: chip found @ 0x%x\n", addr<<1);
if (NULL == (client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL)))
return -ENOMEM;
memcpy(client,&client_template,sizeof(struct i2c_client));
strlcpy(client->name, "saa6752hs", sizeof(client->name));
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_attach_client(client);
return 0;
}
static int saa6752hs_probe(struct i2c_adapter *adap)
{
if (adap->class & I2C_ADAP_CLASS_TV_ANALOG)
return i2c_probe(adap, &addr_data, saa6752hs_attach);
return 0;
}
static int saa6752hs_detach(struct i2c_client *client)
{
i2c_detach_client(client);
kfree(client->data);
kfree(client);
return 0;
}
static int
saa6752hs_command(struct i2c_client *client, unsigned int cmd, void *arg)
{
struct mpeg_params* init_arg = arg;
switch (cmd) {
case MPEG_SETPARAMS:
return saa6752hs_init(client, init_arg);
default:
/* nothing */
break;
}
return 0;
}
/* ----------------------------------------------------------------------- */
static struct i2c_driver driver = {
.owner = THIS_MODULE,
.name = "i2c saa6752hs MPEG encoder",
.id = I2C_DRIVERID_SAA6752HS,
.flags = I2C_DF_NOTIFY,
.attach_adapter = saa6752hs_probe,
.detach_client = saa6752hs_detach,
.command = saa6752hs_command,
};
static struct i2c_client client_template =
{
I2C_DEVNAME("(saa6752hs unset)"),
.flags = I2C_CLIENT_ALLOW_USE,
.driver = &driver,
};
static int saa6752hs_init_module(void)
{
i2c_add_driver(&driver);
return 0;
}
static void saa6752hs_cleanup_module(void)
{
i2c_del_driver(&driver);
}
module_init(saa6752hs_init_module);
module_exit(saa6752hs_cleanup_module);
/*
* Overrides for Emacs so that we follow Linus's tabbing style.
* ---------------------------------------------------------------------------
* Local variables:
* c-basic-offset: 8
* End:
*/
......@@ -32,6 +32,8 @@ static char name_tv[] = "Television";
static char name_tv_mono[] = "TV (mono only)";
static char name_comp1[] = "Composite1";
static char name_comp2[] = "Composite2";
static char name_comp3[] = "Composite3";
static char name_comp4[] = "Composite4";
static char name_svideo[] = "S-Video";
/* ------------------------------------------------------------------ */
......@@ -361,14 +363,16 @@ struct saa7134_board saa7134_boards[] = {
},
[SAA7134_BOARD_MD7134] = {
.name = "Medion 7134",
.audio_clock = 0x00200000,
//.audio_clock = 0x00200000,
.audio_clock = 0x00187de7,
.tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
.need_tda9887 = 1,
.inputs = {{
.name = name_tv,
.vmux = 1,
.amux = LINE2,
.amux = TV,
.tv = 1,
#if 0
},{
.name = name_comp1,
.vmux = 0,
......@@ -381,6 +385,7 @@ struct saa7134_board saa7134_boards[] = {
.name = name_svideo,
.vmux = 8,
.amux = LINE2,
#endif
}},
.radio = {
.name = name_radio,
......@@ -388,9 +393,12 @@ struct saa7134_board saa7134_boards[] = {
},
},
[SAA7134_BOARD_TYPHOON_90031] = {
/* Christian Rothl�nder <Christian@Rothlaender.net> */
.name = "Typhoon TV+Radio 90031",
.audio_clock = 0x00200000,
.tuner_type = TUNER_PHILIPS_PAL,
//.tuner_type = TUNER_PHILIPS_PAL,
.tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
.need_tda9887 = 1,
.inputs = {{
.name = name_tv,
.vmux = 1,
......@@ -409,7 +417,7 @@ struct saa7134_board saa7134_boards[] = {
.name = name_radio,
.amux = LINE2,
},
},
},
[SAA7134_BOARD_ELSA] = {
.name = "ELSA EX-VISION 300TV",
.audio_clock = 0x00187de7,
......@@ -444,14 +452,123 @@ struct saa7134_board saa7134_boards[] = {
.tv = 1,
}},
},
[SAA7134_BOARD_ASUSTeK_TVFM7134] = {
.name = "ASUS TV-FM 7134",
.audio_clock = 0x00187de7,
.tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
.need_tda9887 = 1,
.inputs = {{
.name = name_tv,
.vmux = 1,
.amux = TV,
.tv = 1,
#if 0 /* untested */
},{
.name = name_comp1,
.vmux = 4,
.amux = LINE2,
},{
.name = name_comp2,
.vmux = 2,
.amux = LINE2,
},{
.name = name_svideo,
.vmux = 6,
.amux = LINE2,
},{
.name = "S-Video2",
.vmux = 7,
.amux = LINE2,
#endif
}},
.radio = {
.name = name_radio,
.amux = LINE1,
},
},
[SAA7134_BOARD_VA1000POWER] = {
.name = "AOPEN VA1000 POWER",
.audio_clock = 0x00187de7,
.tuner_type = TUNER_PHILIPS_NTSC,
.inputs = {{
.name = name_svideo,
.vmux = 8,
.amux = LINE1,
},{
.name = name_comp1,
.vmux = 3,
.amux = LINE1,
},{
.name = name_tv,
.vmux = 1,
.amux = LINE2,
.tv = 1,
}},
},
[SAA7134_BOARD_BMK_MPEX_NOTUNER] = {
/* "Andrew de Quincey" <adq@lidskialf.net> */
.name = "BMK MPEX No Tuner",
.audio_clock = 0x200000,
.tuner_type = TUNER_ABSENT,
.inputs = {{
.name = name_comp1,
.vmux = 4,
.amux = LINE1,
},{
.name = name_comp2,
.vmux = 3,
.amux = LINE1,
},{
.name = name_comp3,
.vmux = 0,
.amux = LINE1,
},{
.name = name_comp4,
.vmux = 1,
.amux = LINE1,
},{
.name = name_svideo,
.vmux = 8,
.amux = LINE1,
}},
.i2s_rate = 48000,
.has_ts = 1,
.video_out = CCIR656,
},
[SAA7134_BOARD_VIDEOMATE_TV] = {
.name = "Compro VideoMate TV",
.audio_clock = 0x00187de7,
.tuner_type = TUNER_PHILIPS_NTSC_M,
.inputs = {{
.name = name_svideo,
.vmux = 8,
.amux = LINE1,
},{
.name = name_comp1,
.vmux = 3,
.amux = LINE1,
},{
.name = name_tv,
.vmux = 1,
.amux = LINE2,
.tv = 1,
}},
},
[SAA7134_BOARD_CRONOS_PLUS] = {
.name = "Matrox CronosPlus",
.tuner_type = TUNER_ABSENT,
.inputs = {{
.name = name_comp1,
.vmux = 0,
}},
},
};
const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards);
/* ------------------------------------------------------------------ */
/* PCI ids + subsystem IDs */
struct pci_device_id __devinitdata saa7134_pci_tbl[] = {
struct pci_device_id saa7134_pci_tbl[] = {
{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7134,
......@@ -519,6 +636,42 @@ struct pci_device_id __devinitdata saa7134_pci_tbl[] = {
.subdevice = 0x226b,
.driver_data = SAA7134_BOARD_ELSA_500TV,
},{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7134,
.subvendor = PCI_VENDOR_ID_ASUSTEK,
.subdevice = 0x4842,
.driver_data = SAA7134_BOARD_ASUSTeK_TVFM7134,
},{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7134,
.subvendor = PCI_VENDOR_ID_ASUSTEK,
.subdevice = 0x4830,
.driver_data = SAA7134_BOARD_ASUSTeK_TVFM7134,
},{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7134,
.subvendor = PCI_VENDOR_ID_PHILIPS,
.subdevice = 0xfe01,
.driver_data = SAA7134_BOARD_TYPHOON_90031,
},{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7134,
.subvendor = 0x1131,
.subdevice = 0x7133,
.driver_data = SAA7134_BOARD_VA1000POWER,
},{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7133,
.subvendor = 0x185b,
.subdevice = 0xc100,
.driver_data = SAA7134_BOARD_VIDEOMATE_TV,
},{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7130,
.subvendor = PCI_VENDOR_ID_MATROX,
.subdevice = 0x48d0,
.driver_data = SAA7134_BOARD_CRONOS_PLUS,
},{
/* --- boards without eeprom + subsystem ID --- */
.vendor = PCI_VENDOR_ID_PHILIPS,
......@@ -595,22 +748,16 @@ static struct {
static void board_flyvideo(struct saa7134_dev *dev)
{
#if 0
u32 value;
int index;
saa_writel(SAA7134_GPIO_GPMODE0 >> 2, 0);
value = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2);
#if 0
{
int index = (value & 0x1f00) >> 8;
printk(KERN_INFO "%s: flyvideo: gpio is 0x%x "
"[model=%s,tuner=%d]\n",
dev->name, value, fly_list[index].model,
fly_list[index].tuner_type);
dev->tuner_type = fly_list[index].tuner_type;
}
#else
printk(KERN_INFO "%s: flyvideo: gpio is 0x%x\n",
dev->name, value);
value = dev->gpio_value;
index = (value & 0x1f00) >> 8;
printk(KERN_INFO "%s: flyvideo: gpio is 0x%x [model=%s,tuner=%d]\n",
dev->name, value, fly_list[index].model,
fly_list[index].tuner_type);
dev->tuner_type = fly_list[index].tuner_type;
#endif
}
......@@ -618,10 +765,19 @@ static void board_flyvideo(struct saa7134_dev *dev)
int saa7134_board_init(struct saa7134_dev *dev)
{
// Always print gpio, often manufacturers encode tuner type and other info.
saa_writel(SAA7134_GPIO_GPMODE0 >> 2, 0);
dev->gpio_value = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2);
printk(KERN_INFO "%s: board init: gpio is %x\n", dev->name, dev->gpio_value);
switch (dev->board) {
case SAA7134_BOARD_FLYVIDEO2000:
case SAA7134_BOARD_FLYVIDEO3000:
board_flyvideo(dev);
dev->has_remote = 1;
break;
case SAA7134_BOARD_CINERGY400:
dev->has_remote = 1;
break;
}
return 0;
......
This diff is collapsed.
......@@ -311,6 +311,17 @@ static u32 functionality(struct i2c_adapter *adap)
return I2C_FUNC_SMBUS_EMUL;
}
#ifndef I2C_PEC
static void inc_use(struct i2c_adapter *adap)
{
MOD_INC_USE_COUNT;
}
static void dec_use(struct i2c_adapter *adap)
{
MOD_DEC_USE_COUNT;
}
#endif
static int attach_inform(struct i2c_client *client)
{
......@@ -330,8 +341,15 @@ static struct i2c_algorithm saa7134_algo = {
};
static struct i2c_adapter saa7134_adap_template = {
#ifdef I2C_PEC
.owner = THIS_MODULE,
#else
.inc_use = inc_use,
.dec_use = dec_use,
#endif
#ifdef I2C_ADAP_CLASS_TV_ANALOG
.class = I2C_ADAP_CLASS_TV_ANALOG,
#endif
I2C_DEVNAME("saa7134"),
.id = I2C_ALGO_SAA7134,
.algo = &saa7134_algo,
......@@ -393,12 +411,14 @@ saa7134_i2c_scan(struct saa7134_dev *dev)
void saa7134_i2c_call_clients(struct saa7134_dev *dev,
unsigned int cmd, void *arg)
{
BUG_ON(NULL == dev->i2c_adap.algo_data);
i2c_clients_command(&dev->i2c_adap, cmd, arg);
}
int saa7134_i2c_register(struct saa7134_dev *dev)
{
dev->i2c_adap = saa7134_adap_template;
dev->i2c_adap.dev.parent = &dev->pci->dev;
strcpy(dev->i2c_adap.name,dev->name);
dev->i2c_adap.algo_data = dev;
i2c_add_adapter(&dev->i2c_adap);
......
......@@ -732,7 +732,7 @@ struct file_operations saa7134_mixer_fops = {
/* ------------------------------------------------------------------ */
int saa7134_oss_init(struct saa7134_dev *dev)
int saa7134_oss_init1(struct saa7134_dev *dev)
{
/* general */
init_MUTEX(&dev->oss.lock);
......
......@@ -101,7 +101,15 @@
#define SAA7134_IRQ1_INTE_RA0_2 (1 << 2)
#define SAA7134_IRQ1_INTE_RA0_1 (1 << 1)
#define SAA7134_IRQ1_INTE_RA0_0 (1 << 0)
#define SAA7134_IRQ2 (0x2c8 >> 2)
#define SAA7134_IRQ2_INTE_GPIO23A (1 << 17)
#define SAA7134_IRQ2_INTE_GPIO23 (1 << 16)
#define SAA7134_IRQ2_INTE_GPIO22A (1 << 15)
#define SAA7134_IRQ2_INTE_GPIO22 (1 << 14)
#define SAA7134_IRQ2_INTE_GPIO18A (1 << 13)
#define SAA7134_IRQ2_INTE_GPIO18 (1 << 12)
#define SAA7134_IRQ2_INTE_GPIO16 (1 << 11) /* not certain */
#define SAA7134_IRQ2_INTE_SC2 (1 << 10)
#define SAA7134_IRQ2_INTE_SC1 (1 << 9)
#define SAA7134_IRQ2_INTE_SC0 (1 << 8)
......@@ -113,7 +121,12 @@
#define SAA7134_IRQ2_INTE_DEC0 (1 << 2)
#define SAA7134_IRQ2_INTE_PE (1 << 1)
#define SAA7134_IRQ2_INTE_AR (1 << 0)
#define SAA7134_IRQ_REPORT (0x2cc >> 2)
#define SAA7134_IRQ_REPORT_GPIO23 (1 << 17)
#define SAA7134_IRQ_REPORT_GPIO22 (1 << 16)
#define SAA7134_IRQ_REPORT_GPIO18 (1 << 15)
#define SAA7134_IRQ_REPORT_GPIO16 (1 << 14) /* not certain */
#define SAA7134_IRQ_REPORT_LOAD_ERR (1 << 13)
#define SAA7134_IRQ_REPORT_CONF_ERR (1 << 12)
#define SAA7134_IRQ_REPORT_TRIG_ERR (1 << 11)
......
......@@ -24,10 +24,13 @@
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/delay.h>
#include "saa7134-reg.h"
#include "saa7134.h"
#include <media/saa6752hs.h>
/* ------------------------------------------------------------------ */
static unsigned int ts_debug = 0;
......@@ -109,7 +112,7 @@ static int buffer_prepare(struct file *file, struct videobuf_buffer *vb,
buf->vb.size = size;
buf->pt = &dev->ts.pt_ts;
err = videobuf_iolock(dev->pci,&buf->vb);
err = videobuf_iolock(dev->pci,&buf->vb,NULL);
if (err)
goto oops;
err = saa7134_pgtable_build(dev->pci,buf->pt,
......@@ -162,6 +165,26 @@ static struct videobuf_queue_ops ts_qops = {
.buf_release = buffer_release,
};
/* ------------------------------------------------------------------ */
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;
schedule_timeout(HZ/10);
}
static int ts_init_encoder(struct saa7134_dev* dev, void* arg)
{
ts_reset_encoder(dev);
saa7134_i2c_call_clients(dev, MPEG_SETPARAMS, arg);
return 0;
}
/* ------------------------------------------------------------------ */
static int ts_open(struct inode *inode, struct file *file)
......@@ -173,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->minor == minor)
dev = h;
}
if (NULL == dev)
......@@ -185,9 +208,11 @@ static int ts_open(struct inode *inode, struct file *file)
if (dev->ts.users)
goto done;
dev->ts.started = 0;
dev->ts.users++;
file->private_data = dev;
err = 0;
done:
up(&dev->ts.ts.lock);
return err;
......@@ -203,6 +228,11 @@ static int ts_release(struct inode *inode, struct file *file)
if (dev->ts.ts.reading)
videobuf_read_stop(file,&dev->ts.ts);
dev->ts.users--;
/* stop the encoder */
if (dev->ts.started)
ts_reset_encoder(dev);
up(&dev->ts.ts.lock);
return 0;
}
......@@ -212,6 +242,11 @@ ts_read(struct file *file, char *data, size_t count, loff_t *ppos)
{
struct saa7134_dev *dev = file->private_data;
if (!dev->ts.started) {
ts_init_encoder(dev, NULL);
dev->ts.started = 1;
}
return videobuf_read_stream(file, &dev->ts.ts, data, count, ppos, 0);
}
......@@ -345,6 +380,7 @@ static int ts_do_ioctl(struct inode *inode, struct file *file,
f->fmt.pix.height = 576;
f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
f->fmt.pix.sizeimage = TS_PACKET_SIZE*TS_NR_PACKETS;
return 0;
}
case VIDIOC_REQBUFS:
......@@ -365,6 +401,14 @@ static int ts_do_ioctl(struct inode *inode, struct file *file,
case VIDIOC_STREAMOFF:
return videobuf_streamoff(file,&dev->ts.ts);
case VIDIOC_QUERYCTRL:
case VIDIOC_G_CTRL:
case VIDIOC_S_CTRL:
return saa7134_common_ioctl(dev, cmd, arg);
case MPEG_SETPARAMS:
return ts_init_encoder(dev, arg);
default:
return -ENOIOCTLCMD;
}
......@@ -404,7 +448,7 @@ struct video_device saa7134_ts_template =
.minor = -1,
};
int saa7134_ts_init(struct saa7134_dev *dev)
int saa7134_ts_init1(struct saa7134_dev *dev)
{
/* sanitycheck insmod options */
if (tsbufs < 2)
......
......@@ -2,7 +2,7 @@
* device driver for philips saa7134 based TV cards
* tv audio decoder (fm stereo, nicam, ...)
*
* (c) 2001,02 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
* (c) 2001-03 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
*
* 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
......@@ -172,7 +172,7 @@ static void mute_input_7134(struct saa7134_dev *dev)
{
unsigned int mute;
struct saa7134_input *in;
int reg = 0;
int ausel=0, ics=0, ocs=0;
int mask;
/* look what is to do ... */
......@@ -200,11 +200,13 @@ static void mute_input_7134(struct saa7134_dev *dev)
/* switch internal audio mux */
switch (in->amux) {
case TV: reg = 0x02; break;
case LINE1: reg = 0x00; break;
case LINE2: reg = 0x01; break;
case TV: ausel=0xc0; ics=0x00; ocs=0x02; break;
case LINE1: ausel=0x80; ics=0x00; ocs=0x00; break;
case LINE2: ausel=0x80; ics=0x08; ocs=0x01; break;
}
saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x07, reg);
saa_andorb(SAA7134_AUDIO_FORMAT_CTRL, 0xc0, ausel);
saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x08, ics);
saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x07, ocs);
/* switch gpio-connected external audio mux */
if (0 == card(dev).gpiomask)
......@@ -547,11 +549,19 @@ static int tvaudio_thread(void *data)
tvaudio_setstereo(dev,&tvaudio[audio],V4L2_TUNER_MODE_MONO);
dev->tvaudio = &tvaudio[audio];
if (tvaudio_sleep(dev,3*HZ))
goto restart;
rx = tvaudio_getstereo(dev,&tvaudio[i]);
mode = saa7134_tvaudio_rx2mode(rx);
tvaudio_setstereo(dev,&tvaudio[audio],mode);
for (;;) {
if (tvaudio_sleep(dev,3*HZ))
goto restart;
if (dev->thread.exit || signal_pending(current))
break;
if (UNSET == dev->thread.mode) {
rx = tvaudio_getstereo(dev,&tvaudio[i]);
mode = saa7134_tvaudio_rx2mode(rx);
} else {
mode = dev->thread.mode;
}
tvaudio_setstereo(dev,&tvaudio[audio],mode);
}
}
done:
......@@ -592,8 +602,8 @@ static char *stdres[0x20] = {
[0x1f] = "??? [in progress]",
};
#define DSP_RETRY 16
#define DSP_DELAY 16
#define DSP_RETRY 30
#define DSP_DELAY 10
static inline int saa_dsp_wait_bit(struct saa7134_dev *dev, int bit)
{
......@@ -838,10 +848,11 @@ int saa7134_tvaudio_getstereo(struct saa7134_dev *dev)
return retval;
}
int saa7134_tvaudio_init(struct saa7134_dev *dev)
int saa7134_tvaudio_init2(struct saa7134_dev *dev)
{
DECLARE_MUTEX_LOCKED(sem);
int (*my_thread)(void *data) = NULL;
int rc;
/* enable I2S audio output */
if (saa7134_boards[dev->board].i2s_rate) {
......@@ -872,8 +883,12 @@ int saa7134_tvaudio_init(struct saa7134_dev *dev)
/* start tvaudio thread */
init_waitqueue_head(&dev->thread.wq);
dev->thread.notify = &sem;
kernel_thread(my_thread,dev,0);
down(&sem);
rc = kernel_thread(my_thread,dev,0);
if (rc < 0)
printk(KERN_WARNING "%s: kernel_thread() failed\n",
dev->name);
else
down(&sem);
dev->thread.notify = NULL;
wake_up_interruptible(&dev->thread.wq);
}
......@@ -900,6 +915,7 @@ int saa7134_tvaudio_fini(struct saa7134_dev *dev)
int saa7134_tvaudio_do_scan(struct saa7134_dev *dev)
{
if (dev->thread.task) {
dev->thread.mode = UNSET;
dev->thread.scan2++;
wake_up_interruptible(&dev->thread.wq);
} else {
......
......@@ -146,7 +146,7 @@ static int buffer_prepare(struct file *file, struct videobuf_buffer *vb,
buf->vb.size = size;
buf->pt = &fh->pt_vbi;
err = videobuf_iolock(dev->pci,&buf->vb);
err = videobuf_iolock(dev->pci,&buf->vb,NULL);
if (err)
goto oops;
err = saa7134_pgtable_build(dev->pci,buf->pt,
......@@ -215,7 +215,7 @@ struct videobuf_queue_ops saa7134_vbi_qops = {
/* ------------------------------------------------------------------ */
int saa7134_vbi_init(struct saa7134_dev *dev)
int saa7134_vbi_init1(struct saa7134_dev *dev)
{
INIT_LIST_HEAD(&dev->vbi_q.queue);
init_timer(&dev->vbi_q.timeout);
......
......@@ -578,21 +578,12 @@ static void set_size(struct saa7134_dev *dev, int task,
saa_writeb(SAA7134_VIDEO_LINES2(task), height/div >> 8);
/* deinterlace y offsets */
if (interlace) {
y_odd = dev->ctl_y_odd;
y_even = dev->ctl_y_even;
saa_writeb(SAA7134_V_PHASE_OFFSET0(task), y_odd);
saa_writeb(SAA7134_V_PHASE_OFFSET1(task), y_even);
saa_writeb(SAA7134_V_PHASE_OFFSET2(task), y_odd);
saa_writeb(SAA7134_V_PHASE_OFFSET3(task), y_even);
} else {
y_odd = dev->ctl_y_odd;
y_even = dev->ctl_y_even;
saa_writeb(SAA7134_V_PHASE_OFFSET0(task), y_odd);
saa_writeb(SAA7134_V_PHASE_OFFSET1(task), y_even);
saa_writeb(SAA7134_V_PHASE_OFFSET2(task), y_odd);
saa_writeb(SAA7134_V_PHASE_OFFSET3(task), y_even);
}
y_odd = dev->ctl_y_odd;
y_even = dev->ctl_y_even;
saa_writeb(SAA7134_V_PHASE_OFFSET0(task), y_odd);
saa_writeb(SAA7134_V_PHASE_OFFSET1(task), y_even);
saa_writeb(SAA7134_V_PHASE_OFFSET2(task), y_odd);
saa_writeb(SAA7134_V_PHASE_OFFSET3(task), y_even);
}
/* ------------------------------------------------------------------ */
......@@ -912,7 +903,7 @@ static int buffer_prepare(struct file *file, struct videobuf_buffer *vb,
buf->fmt = fh->fmt;
buf->pt = &fh->pt_cap;
err = videobuf_iolock(dev->pci,&buf->vb);
err = videobuf_iolock(dev->pci,&buf->vb,&dev->ovbuf);
if (err)
goto oops;
err = saa7134_pgtable_build(dev->pci,buf->pt,
......@@ -1084,7 +1075,7 @@ static int set_control(struct saa7134_dev *dev, struct saa7134_fh *fh,
default:
return -EINVAL;
}
if (restart_overlay && res_check(fh, RESOURCE_OVERLAY)) {
if (restart_overlay && fh && res_check(fh, RESOURCE_OVERLAY)) {
spin_lock_irqsave(&dev->slock,flags);
stop_preview(dev,fh);
start_preview(dev,fh);
......@@ -1140,13 +1131,13 @@ static int video_open(struct inode *inode, struct file *file)
list_for_each(list,&saa7134_devlist) {
h = list_entry(list, struct saa7134_dev, devlist);
if (h->video_dev.minor == minor)
if (h->video_dev && (h->video_dev->minor == minor))
dev = h;
if (h->radio_dev.minor == minor) {
if (h->radio_dev && (h->radio_dev->minor == minor)) {
radio = 1;
dev = h;
}
if (h->vbi_dev.minor == minor) {
if (h->vbi_dev && (h->vbi_dev->minor == minor)) {
type = V4L2_BUF_TYPE_VBI_CAPTURE;
dev = h;
}
......@@ -1188,13 +1179,10 @@ static int video_open(struct inode *inode, struct file *file)
if (fh->radio) {
/* switch to radio mode */
u32 v = 400*16;
saa7134_tvaudio_setinput(dev,&card(dev).radio);
saa7134_i2c_call_clients(dev,VIDIOCSFREQ,&v);
saa7134_i2c_call_clients(dev,AUDC_SET_RADIO,NULL);
} else {
/* switch to video/vbi mode */
set_tvnorm(dev,dev->tvnorm);
video_mux(dev,dev->ctl_input);
}
return 0;
......@@ -1327,7 +1315,7 @@ void saa7134_vbi_fmt(struct saa7134_dev *dev, struct v4l2_format *f)
f->fmt.vbi.count[0] = norm->vbi_v_stop - norm->vbi_v_start +1;
f->fmt.vbi.start[1] = norm->video_v_stop + norm->vbi_v_start +1;
f->fmt.vbi.count[1] = f->fmt.vbi.count[0];
f->fmt.vbi.flags = 0; /* VBI_UNSYNC VBI_INTERLACED */;
f->fmt.vbi.flags = 0; /* VBI_UNSYNC VBI_INTERLACED */
#if 0
if (V4L2_STD_PAL == norm->id) {
......@@ -1479,6 +1467,92 @@ int saa7134_s_fmt(struct saa7134_dev *dev, struct saa7134_fh *fh,
}
}
int saa7134_common_ioctl(struct saa7134_dev *dev,
unsigned int cmd, void *arg)
{
int err;
switch (cmd) {
case VIDIOC_QUERYCTRL:
{
const struct v4l2_queryctrl *ctrl;
struct v4l2_queryctrl *c = arg;
if ((c->id < V4L2_CID_BASE ||
c->id >= V4L2_CID_LASTP1) &&
(c->id < V4L2_CID_PRIVATE_BASE ||
c->id >= V4L2_CID_PRIVATE_LASTP1))
return -EINVAL;
ctrl = ctrl_by_id(c->id);
*c = (NULL != ctrl) ? *ctrl : no_ctrl;
return 0;
}
case VIDIOC_G_CTRL:
return get_control(dev,arg);
case VIDIOC_S_CTRL:
{
down(&dev->lock);
err = set_control(dev,NULL,arg);
up(&dev->lock);
return err;
}
/* --- input switching --------------------------------------- */
case VIDIOC_ENUMINPUT:
{
struct v4l2_input *i = arg;
unsigned int n;
n = i->index;
if (n >= SAA7134_INPUT_MAX)
return -EINVAL;
if (NULL == card_in(dev,i->index).name)
return -EINVAL;
memset(i,0,sizeof(*i));
i->index = n;
i->type = V4L2_INPUT_TYPE_CAMERA;
strcpy(i->name,card_in(dev,n).name);
if (card_in(dev,n).tv)
i->type = V4L2_INPUT_TYPE_TUNER;
i->audioset = 1;
if (n == dev->ctl_input) {
int v1 = saa_readb(SAA7134_STATUS_VIDEO1);
int v2 = saa_readb(SAA7134_STATUS_VIDEO2);
if (0 != (v1 & 0x40))
i->status |= V4L2_IN_ST_NO_H_LOCK;
if (0 != (v2 & 0x40))
i->status |= V4L2_IN_ST_NO_SYNC;
if (0 != (v2 & 0x0e))
i->status |= V4L2_IN_ST_MACROVISION;
}
for (n = 0; n < TVNORMS; n++)
i->std |= tvnorms[n].id;
return 0;
}
case VIDIOC_G_INPUT:
{
int *i = arg;
*i = dev->ctl_input;
return 0;
}
case VIDIOC_S_INPUT:
{
int *i = arg;
if (*i < 0 || *i >= SAA7134_INPUT_MAX)
return -EINVAL;
if (NULL == card_in(dev,*i).name)
return -EINVAL;
down(&dev->lock);
video_mux(dev,*i);
up(&dev->lock);
return 0;
}
}
return 0;
}
/*
* This function is _not_ called directly, but from
* video_generic_ioctl (and maybe others). userspace
......@@ -1562,59 +1636,6 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
return 0;
}
/* --- input switching --------------------------------------- */
case VIDIOC_ENUMINPUT:
{
struct v4l2_input *i = arg;
unsigned int n;
n = i->index;
if (n >= SAA7134_INPUT_MAX)
return -EINVAL;
if (NULL == card_in(dev,i->index).name)
return -EINVAL;
memset(i,0,sizeof(*i));
i->index = n;
i->type = V4L2_INPUT_TYPE_CAMERA;
strcpy(i->name,card_in(dev,n).name);
if (card_in(dev,n).tv)
i->type = V4L2_INPUT_TYPE_TUNER;
i->audioset = 1;
if (n == dev->ctl_input) {
int v1 = saa_readb(SAA7134_STATUS_VIDEO1);
int v2 = saa_readb(SAA7134_STATUS_VIDEO2);
if (0 != (v1 & 0x40))
i->status |= V4L2_IN_ST_NO_H_LOCK;
if (0 != (v2 & 0x40))
i->status |= V4L2_IN_ST_NO_SYNC;
if (0 != (v2 & 0x0e))
i->status |= V4L2_IN_ST_MACROVISION;
}
for (n = 0; n < TVNORMS; n++)
i->std |= tvnorms[n].id;
return 0;
}
case VIDIOC_G_INPUT:
{
int *i = arg;
*i = dev->ctl_input;
return 0;
}
case VIDIOC_S_INPUT:
{
int *i = arg;
if (*i < 0 || *i >= SAA7134_INPUT_MAX)
return -EINVAL;
if (NULL == card_in(dev,*i).name)
return -EINVAL;
down(&dev->lock);
video_mux(dev,*i);
up(&dev->lock);
return 0;
}
/* --- tuner ioctls ------------------------------------------ */
case VIDIOC_G_TUNER:
{
......@@ -1643,9 +1664,17 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
}
case VIDIOC_S_TUNER:
{
#if 0
struct v4l2_tuner *t = arg;
#endif
int rx,mode;
mode = dev->thread.mode;
if (UNSET == mode) {
rx = saa7134_tvaudio_getstereo(dev);
mode = saa7134_tvaudio_rx2mode(t->rxsubchans);
}
if (mode != t->audmode) {
dev->thread.mode = t->audmode;
}
return 0;
}
case VIDIOC_G_FREQUENCY:
......@@ -1673,29 +1702,14 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
}
/* --- control ioctls ---------------------------------------- */
case VIDIOC_ENUMINPUT:
case VIDIOC_G_INPUT:
case VIDIOC_S_INPUT:
case VIDIOC_QUERYCTRL:
{
const struct v4l2_queryctrl *ctrl;
struct v4l2_queryctrl *c = arg;
if ((c->id < V4L2_CID_BASE ||
c->id >= V4L2_CID_LASTP1) &&
(c->id < V4L2_CID_PRIVATE_BASE ||
c->id >= V4L2_CID_PRIVATE_LASTP1))
return -EINVAL;
ctrl = ctrl_by_id(c->id);
*c = (NULL != ctrl) ? *ctrl : no_ctrl;
return 0;
}
case VIDIOC_G_CTRL:
return get_control(dev,arg);
case VIDIOC_S_CTRL:
{
down(&dev->lock);
err = set_control(dev,fh,arg);
up(&dev->lock);
return err;
}
return saa7134_common_ioctl(dev, cmd, arg);
case VIDIOC_G_AUDIO:
{
struct v4l2_audio *a = arg;
......@@ -1828,8 +1842,9 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
q = saa7134_queue(fh);
memset(&req,0,sizeof(req));
req.type = q->type;
req.count = gbuffers;
req.type = q->type;
req.count = gbuffers;
req.memory = V4L2_MEMORY_MMAP;
err = videobuf_reqbufs(file,q,&req);
if (err < 0)
return err;
......@@ -1913,6 +1928,9 @@ static int radio_do_ioctl(struct inode *inode, struct file *file,
struct v4l2_tuner *t = arg;
struct video_tuner vt;
if (0 != t->index)
return -EINVAL;
memset(t,0,sizeof(*t));
strcpy(t->name, "Radio");
t->rangelow = (int)(65*16);
......@@ -2046,7 +2064,7 @@ struct video_device saa7134_radio_template =
.minor = -1,
};
int saa7134_video_init(struct saa7134_dev *dev)
int saa7134_video_init1(struct saa7134_dev *dev)
{
/* sanitycheck insmod options */
if (gbuffers < 2 || gbuffers > VIDEO_MAX_FRAME)
......@@ -2072,12 +2090,6 @@ int saa7134_video_init(struct saa7134_dev *dev)
dev->video_q.timeout.data = (unsigned long)(&dev->video_q);
dev->video_q.dev = dev;
/* init video hw */
set_tvnorm(dev,&tvnorms[0]);
video_mux(dev,0);
saa7134_tvaudio_setmute(dev);
saa7134_tvaudio_setvolume(dev,dev->ctl_volume);
if (saa7134_boards[dev->board].video_out) {
/* enable video output */
int vo = saa7134_boards[dev->board].video_out;
......@@ -2095,6 +2107,16 @@ int saa7134_video_init(struct saa7134_dev *dev)
return 0;
}
int saa7134_video_init2(struct saa7134_dev *dev)
{
/* init video hw */
set_tvnorm(dev,&tvnorms[0]);
video_mux(dev,0);
saa7134_tvaudio_setmute(dev);
saa7134_tvaudio_setvolume(dev,dev->ctl_volume);
return 0;
}
int saa7134_video_fini(struct saa7134_dev *dev)
{
/* nothing */
......
......@@ -19,20 +19,25 @@
*/
#include <linux/version.h>
#define SAA7134_VERSION_CODE KERNEL_VERSION(0,2,9)
#include <linux/pci.h>
#include <linux/i2c.h>
#include <linux/videodev.h>
#include <linux/kdev_t.h>
#include <linux/input.h>
#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>
#define SAA7134_VERSION_CODE KERNEL_VERSION(0,2,8)
#ifndef TRUE
# define TRUE (1==1)
#endif
......@@ -133,6 +138,11 @@ struct saa7134_format {
#define SAA7134_BOARD_TYPHOON_90031 13
#define SAA7134_BOARD_ELSA 14
#define SAA7134_BOARD_ELSA_500TV 15
#define SAA7134_BOARD_ASUSTeK_TVFM7134 16
#define SAA7134_BOARD_VA1000POWER 17
#define SAA7134_BOARD_BMK_MPEX_NOTUNER 18
#define SAA7134_BOARD_VIDEOMATE_TV 19
#define SAA7134_BOARD_CRONOS_PLUS 20
#define SAA7134_INPUT_MAX 8
......@@ -200,6 +210,7 @@ struct saa7134_thread {
unsigned int exit;
unsigned int scan1;
unsigned int scan2;
unsigned int mode;
};
/* buffer for one video/vbi/ts frame */
......@@ -255,6 +266,7 @@ struct saa7134_ts {
/* TS capture */
struct videobuf_queue ts;
struct saa7134_pgtable pt_ts;
int started;
};
/* oss dsp status */
......@@ -286,6 +298,18 @@ struct saa7134_oss {
unsigned int read_count;
};
#ifdef CONFIG_VIDEO_IR
/* IR input */
struct saa7134_ir {
struct input_dev dev;
struct ir_input_state ir;
char name[32];
char phys[32];
u32 mask_keycode;
u32 mask_keydown;
};
#endif
/* global device status */
struct saa7134_dev {
struct list_head devlist;
......@@ -294,13 +318,19 @@ struct saa7134_dev {
/* various device info */
unsigned int resources;
struct video_device video_dev;
struct video_device ts_dev;
struct video_device radio_dev;
struct video_device vbi_dev;
struct video_device *video_dev;
struct video_device *ts_dev;
struct video_device *radio_dev;
struct video_device *vbi_dev;
struct saa7134_oss oss;
struct saa7134_ts ts;
/* infrared remote */
int has_remote;
#ifdef CONFIG_VIDEO_IR
struct saa7134_ir *remote;
#endif
/* pci i/o */
char name[32];
struct pci_dev *pci;
......@@ -311,6 +341,7 @@ struct saa7134_dev {
/* config info */
unsigned int board;
unsigned int tuner_type;
unsigned int gpio_value;
/* i2c i/o */
struct i2c_adapter i2c_adap;
......@@ -372,7 +403,9 @@ 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) { 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 */
......@@ -433,7 +466,8 @@ extern struct video_device saa7134_radio_template;
int saa7134_common_ioctl(struct saa7134_dev *dev,
unsigned int cmd, void *arg);
int saa7134_video_init(struct saa7134_dev *dev);
int saa7134_video_init1(struct saa7134_dev *dev);
int saa7134_video_init2(struct saa7134_dev *dev);
int saa7134_video_fini(struct saa7134_dev *dev);
void saa7134_irq_video_intl(struct saa7134_dev *dev);
void saa7134_irq_video_done(struct saa7134_dev *dev, unsigned long status);
......@@ -443,7 +477,7 @@ void saa7134_irq_video_done(struct saa7134_dev *dev, unsigned long status);
/* saa7134-ts.c */
extern struct video_device saa7134_ts_template;
int saa7134_ts_init(struct saa7134_dev *dev);
int saa7134_ts_init1(struct saa7134_dev *dev);
int saa7134_ts_fini(struct saa7134_dev *dev);
void saa7134_irq_ts_done(struct saa7134_dev *dev, unsigned long status);
......@@ -454,7 +488,7 @@ void saa7134_irq_ts_done(struct saa7134_dev *dev, unsigned long status);
extern struct videobuf_queue_ops saa7134_vbi_qops;
extern struct video_device saa7134_vbi_template;
int saa7134_vbi_init(struct saa7134_dev *dev);
int saa7134_vbi_init1(struct saa7134_dev *dev);
int saa7134_vbi_fini(struct saa7134_dev *dev);
void saa7134_irq_vbi_done(struct saa7134_dev *dev, unsigned long status);
......@@ -470,7 +504,7 @@ void saa7134_tvaudio_setinput(struct saa7134_dev *dev,
void saa7134_tvaudio_setvolume(struct saa7134_dev *dev, int level);
int saa7134_tvaudio_getstereo(struct saa7134_dev *dev);
int saa7134_tvaudio_init(struct saa7134_dev *dev);
int saa7134_tvaudio_init2(struct saa7134_dev *dev);
int saa7134_tvaudio_fini(struct saa7134_dev *dev);
int saa7134_tvaudio_do_scan(struct saa7134_dev *dev);
......@@ -482,10 +516,16 @@ int saa_dsp_writel(struct saa7134_dev *dev, int reg, u32 value);
extern struct file_operations saa7134_dsp_fops;
extern struct file_operations saa7134_mixer_fops;
int saa7134_oss_init(struct saa7134_dev *dev);
int saa7134_oss_init1(struct saa7134_dev *dev);
int saa7134_oss_fini(struct saa7134_dev *dev);
void saa7134_irq_oss_done(struct saa7134_dev *dev, unsigned long status);
/* ----------------------------------------------------------- */
/* saa7134-input.c */
int saa7134_input_init1(struct saa7134_dev *dev);
void saa7134_input_fini(struct saa7134_dev *dev);
void saa7134_input_irq(struct saa7134_dev *dev);
/*
* Local variables:
......
This diff is collapsed.
......@@ -33,7 +33,6 @@
#include <linux/sched.h>
#include <linux/stat.h>
#include <linux/string.h>
#include <linux/smp_lock.h>
#include <linux/blkdev.h>
#include <linux/init.h>
......
......@@ -37,7 +37,6 @@
#include <linux/fs.h>
#include <linux/stat.h>
#include <linux/errno.h>
#include <linux/smp_lock.h>
#include <linux/slab.h>
#include <asm/segment.h>
#include <asm/uaccess.h>
......
......@@ -23,10 +23,9 @@
*/
#include <asm/bitops.h>
#include <asm/ioctls.h>
#include <asm/termios.h>
#include <asm/uaccess.h>
#include <asm/system.h>
#include <linux/smp_lock.h>
#include <linux/errno.h>
#include <linux/fs.h>
......@@ -55,7 +54,7 @@ static inline void presto_relock_other(struct inode *dir)
{
/* vfs_mkdir locks */
// down(&dir->i_zombie);
lock_kernel();
//lock_kernel();
}
static inline void presto_fulllock(struct inode *dir)
......@@ -64,13 +63,13 @@ static inline void presto_fulllock(struct inode *dir)
down(&dir->i_sem);
/* vfs_mkdir locks */
// down(&dir->i_zombie);
lock_kernel();
//lock_kernel();
}
static inline void presto_unlock(struct inode *dir)
{
/* vfs_mkdir locks */
unlock_kernel();
//unlock_kernel();
// up(&dir->i_zombie);
/* the lock from sys_mkdir / lookup_create */
up(&dir->i_sem);
......
......@@ -28,14 +28,12 @@
#include <linux/string.h>
#include <linux/stat.h>
#include <linux/errno.h>
#include <linux/smp_lock.h>
#include <linux/unistd.h>
#include <asm/system.h>
#include <asm/uaccess.h>
#include <linux/fs.h>
#include <linux/smp_lock.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <asm/segment.h>
......
......@@ -41,7 +41,6 @@
#include <linux/sched.h>
#include <linux/stat.h>
#include <linux/string.h>
#include <linux/smp_lock.h>
#include <linux/blkdev.h>
#include <linux/init.h>
#include <linux/module.h>
......
......@@ -35,7 +35,6 @@
#include <linux/sched.h>
#include <linux/stat.h>
#include <linux/string.h>
#include <linux/smp_lock.h>
#include <linux/blkdev.h>
#include <linux/init.h>
#include <linux/module.h>
......
......@@ -30,7 +30,6 @@
#include <linux/string.h>
#include <linux/stat.h>
#include <linux/errno.h>
#include <linux/smp_lock.h>
#include <linux/unistd.h>
#include <asm/system.h>
......
......@@ -33,7 +33,6 @@
#include <linux/vmalloc.h>
#include <linux/time.h>
#include <linux/errno.h>
#include <linux/smp_lock.h>
#include <asm/segment.h>
#include <asm/uaccess.h>
#include <linux/string.h>
......
......@@ -27,7 +27,6 @@
#include <linux/vmalloc.h>
#include <linux/stat.h>
#include <linux/errno.h>
#include <linux/smp_lock.h>
#include <asm/segment.h>
#include <asm/uaccess.h>
#include <linux/string.h>
......
......@@ -33,7 +33,6 @@
#include <linux/vmalloc.h>
#include <linux/stat.h>
#include <linux/errno.h>
#include <linux/smp_lock.h>
#include <asm/segment.h>
#include <asm/uaccess.h>
#include <linux/string.h>
......
......@@ -32,7 +32,6 @@
#include <linux/vmalloc.h>
#include <linux/stat.h>
#include <linux/errno.h>
#include <linux/smp_lock.h>
#include <asm/segment.h>
#include <asm/uaccess.h>
#include <linux/string.h>
......
......@@ -31,7 +31,6 @@
#include <linux/vmalloc.h>
#include <linux/stat.h>
#include <linux/errno.h>
#include <linux/smp_lock.h>
#include <asm/segment.h>
#include <asm/uaccess.h>
#include <linux/string.h>
......
......@@ -33,7 +33,6 @@
#include <linux/vmalloc.h>
#include <linux/stat.h>
#include <linux/errno.h>
#include <linux/smp_lock.h>
#include <asm/segment.h>
#include <asm/uaccess.h>
#include <linux/string.h>
......
......@@ -27,7 +27,6 @@
#include <linux/vmalloc.h>
#include <linux/stat.h>
#include <linux/errno.h>
#include <linux/smp_lock.h>
#include <asm/segment.h>
#include <asm/uaccess.h>
#include <linux/string.h>
......
#include <linux/list.h>
#include <linux/mm.h>
#include <linux/smp_lock.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
......
......@@ -37,7 +37,6 @@
#include <linux/sched.h>
#include <linux/stat.h>
#include <linux/string.h>
#include <linux/smp_lock.h>
#include <linux/blkdev.h>
#include <linux/init.h>
#include <linux/module.h>
......
......@@ -31,7 +31,6 @@
#include <linux/errno.h>
#include <linux/vmalloc.h>
#include <linux/slab.h>
#include <linux/smp_lock.h>
#include <asm/segment.h>
#include <asm/uaccess.h>
#include <linux/string.h>
......
......@@ -102,8 +102,7 @@ int izo_psdev_setpid(int minor)
struct list_head *lh;
struct upc_req *req;
CERROR("WARNING: setpid & processing not empty!\n");
lh = &channel->uc_processing;
while ( (lh = lh->next) != &channel->uc_processing) {
list_for_each(lh, &channel->uc_processing) {
req = list_entry(lh, struct upc_req, rq_chain);
/* freeing of req and data is done by the sleeper */
wake_up(&req->rq_sleep);
......@@ -208,8 +207,7 @@ static ssize_t presto_psdev_write(struct file *file, const char *buf,
spin_lock(&channel->uc_lock);
/* Look for the message on the processing queue. */
lh = &channel->uc_processing;
while ( (lh = lh->next) != &channel->uc_processing ) {
list_for_each(lh, &channel->uc_processing) {
tmp = list_entry(lh, struct upc_req , rq_chain);
if (tmp->rq_unique == hdr.unique) {
req = tmp;
......@@ -337,8 +335,7 @@ static int presto_psdev_release(struct inode * inode, struct file * file)
/* Wake up clients so they can return. */
CDEBUG(D_PSDEV, "Wake up clients sleeping for pending.\n");
spin_lock(&channel->uc_lock);
lh = &channel->uc_pending;
while ( (lh = lh->next) != &channel->uc_pending) {
list_for_each(lh, &channel->uc_pending) {
req = list_entry(lh, struct upc_req, rq_chain);
/* Async requests stay around for a new lento */
......@@ -351,8 +348,7 @@ static int presto_psdev_release(struct inode * inode, struct file * file)
}
CDEBUG(D_PSDEV, "Wake up clients sleeping for processing\n");
lh = &channel->uc_processing;
while ( (lh = lh->next) != &channel->uc_processing) {
list_for_each(lh, &channel->uc_processing) {
req = list_entry(lh, struct upc_req, rq_chain);
/* freeing of req and data is done by the sleeper */
req->rq_flags |= REQ_DEAD;
......@@ -419,7 +415,7 @@ void presto_psdev_cleanup(void)
for ( i = 0 ; i < MAX_CHANNEL ; i++ ) {
struct upc_channel *channel = &(izo_channels[i]);
struct list_head *lh;
struct list_head *lh, *next;
spin_lock(&channel->uc_lock);
if ( ! list_empty(&channel->uc_pending)) {
......@@ -431,12 +427,10 @@ void presto_psdev_cleanup(void)
if ( ! list_empty(&channel->uc_cache_list)) {
CERROR("Weird, tell Peter: module cleanup and cache listnot empty dev %d\n", i);
}
lh = channel->uc_pending.next;
while ( lh != &channel->uc_pending) {
list_for_each_safe(lh, next, &channel->uc_pending) {
struct upc_req *req;
req = list_entry(lh, struct upc_req, rq_chain);
lh = lh->next;
if ( req->rq_flags & REQ_ASYNC ) {
list_del(&(req->rq_chain));
CDEBUG(D_UPCALL, "free pending upcall type %d\n",
......@@ -448,8 +442,7 @@ void presto_psdev_cleanup(void)
wake_up(&req->rq_sleep);
}
}
lh = &channel->uc_processing;
while ( (lh = lh->next) != &channel->uc_processing ) {
list_for_each(lh, &channel->uc_processing) {
struct upc_req *req;
req = list_entry(lh, struct upc_req, rq_chain);
list_del(&(req->rq_chain));
......@@ -562,6 +555,10 @@ int izo_upc_upcall(int minor, int *size, struct izo_upcall_hdr *buffer,
buffer->u_uniq = req->rq_unique;
buffer->u_async = async;
/* Remove potential datarace possibility*/
if ( async )
req->rq_flags = REQ_ASYNC;
spin_lock(&channel->uc_lock);
/* Append msg to pending queue and poke Lento. */
list_add(&req->rq_chain, channel->uc_pending.prev);
......@@ -574,7 +571,7 @@ int izo_upc_upcall(int minor, int *size, struct izo_upcall_hdr *buffer,
if ( async ) {
/* req, rq_data are freed in presto_psdev_read for async */
req->rq_flags = REQ_ASYNC;
/* req->rq_flags = REQ_ASYNC;*/
EXIT;
return 0;
}
......@@ -645,5 +642,6 @@ int izo_upc_upcall(int minor, int *size, struct izo_upcall_hdr *buffer,
exit_req:
PRESTO_FREE(req, sizeof(struct upc_req));
exit_buf:
PRESTO_FREE(buffer,*size);
return error;
}
......@@ -97,11 +97,10 @@ izo_rep_cache_clean(struct presto_file_set *fset)
struct izo_offset_rec *
izo_rep_cache_find(struct presto_file_set *fset, char *uuid)
{
struct list_head *buck = izo_rep_hash(fset->fset_clients, uuid);
struct list_head *tmp = buck;
struct list_head *tmp, *buck = izo_rep_hash(fset->fset_clients, uuid);
struct izo_offset_rec *rec = NULL;
while ( (tmp = tmp->next) != buck ) {
list_for_each(tmp, buck) {
rec = list_entry(tmp, struct izo_offset_rec, or_list);
if ( memcmp(rec->or_uuid, uuid, sizeof(rec->or_uuid)) == 0 )
return rec;
......
......@@ -38,7 +38,6 @@ static char rcsid[] __attribute ((unused)) = "$Id: super.c,v 1.4 2002/10/12 02:1
#include <linux/sched.h>
#include <linux/stat.h>
#include <linux/string.h>
#include <linux/smp_lock.h>
#include <linux/blkdev.h>
#include <linux/init.h>
#include <linux/devfs_fs_kernel.h>
......
......@@ -39,7 +39,6 @@
#include <linux/fs.h>
#include <linux/stat.h>
#include <linux/errno.h>
#include <linux/smp_lock.h>
#include <linux/string.h>
#include <asm/uaccess.h>
......
......@@ -55,7 +55,6 @@
#include <linux/mm.h>
#include <linux/proc_fs.h>
#include <linux/smp_lock.h>
#include <linux/quotaops.h>
#include <asm/uaccess.h>
......
......@@ -21,7 +21,7 @@ static void v1_disk2mem_dqblk(struct mem_dqblk *m, struct v1_disk_dqblk *d)
m->dqb_curinodes = d->dqb_curinodes;
m->dqb_bhardlimit = d->dqb_bhardlimit;
m->dqb_bsoftlimit = d->dqb_bsoftlimit;
m->dqb_curspace = d->dqb_curblocks << QUOTABLOCK_BITS;
m->dqb_curspace = ((qsize_t)d->dqb_curblocks) << QUOTABLOCK_BITS;
m->dqb_itime = d->dqb_itime;
m->dqb_btime = d->dqb_btime;
}
......
......@@ -218,19 +218,22 @@ do { \
#define ELF_CORE_EXTRA_PHDRS (GATE_EHDR->e_phnum)
#define ELF_CORE_WRITE_EXTRA_PHDRS \
do { \
const struct elf_phdr *const vsyscall_phdrs = \
const struct elf_phdr *const gate_phdrs = \
(const struct elf_phdr *) (GATE_ADDR + GATE_EHDR->e_phoff); \
int i; \
Elf32_Off ofs = 0; \
Elf64_Off ofs = 0; \
for (i = 0; i < GATE_EHDR->e_phnum; ++i) { \
struct elf_phdr phdr = vsyscall_phdrs[i]; \
struct elf_phdr phdr = gate_phdrs[i]; \
if (phdr.p_type == PT_LOAD) { \
BUG_ON(ofs != 0); \
ofs = phdr.p_offset = offset; \
phdr.p_memsz = PAGE_ALIGN(phdr.p_memsz); \
phdr.p_filesz = phdr.p_memsz; \
if (ofs == 0) { \
ofs = phdr.p_offset = offset; \
offset += phdr.p_filesz; \
} \
else \
phdr.p_offset = ofs; \
} \
else \
phdr.p_offset += ofs; \
phdr.p_paddr = 0; /* match other core phdrs */ \
......@@ -239,13 +242,15 @@ do { \
} while (0)
#define ELF_CORE_WRITE_EXTRA_DATA \
do { \
const struct elf_phdr *const vsyscall_phdrs = \
const struct elf_phdr *const gate_phdrs = \
(const struct elf_phdr *) (GATE_ADDR + GATE_EHDR->e_phoff); \
int i; \
for (i = 0; i < GATE_EHDR->e_phnum; ++i) { \
if (vsyscall_phdrs[i].p_type == PT_LOAD) \
DUMP_WRITE((void *) vsyscall_phdrs[i].p_vaddr, \
PAGE_ALIGN(vsyscall_phdrs[i].p_memsz)); \
if (gate_phdrs[i].p_type == PT_LOAD) { \
DUMP_WRITE((void *) gate_phdrs[i].p_vaddr, \
PAGE_ALIGN(gate_phdrs[i].p_memsz)); \
break; \
} \
} \
} while (0)
......
......@@ -419,7 +419,6 @@ struct task_struct {
char comm[16];
/* file system info */
int link_count, total_link_count;
unsigned int locks; /* How many file locks are being held */
/* ipc stuff */
struct sysv_sem sysvsem;
/* CPU-specific state of this task */
......
/*
saa6752hs.h - definition for saa6752hs MPEG encoder
Copyright (C) 2003 Andrew de Quincey <adq@lidskialf.net>
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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _SAA6752HS_H
#define _SAA6752HS_H
enum mpeg_bitrate_mode {
MPEG_BITRATE_MODE_VBR = 0, /* Variable bitrate */
MPEG_BITRATE_MODE_CBR = 1, /* Constant bitrate */
MPEG_BITRATE_MODE_MAX
};
enum mpeg_audio_bitrate {
MPEG_AUDIO_BITRATE_256 = 0, /* 256 kBit/sec */
MPEG_AUDIO_BITRATE_384 = 1, /* 384 kBit/sec */
MPEG_AUDIO_BITRATE_MAX
};
#define MPEG_VIDEO_TARGET_BITRATE_MAX 27000
#define MPEG_VIDEO_MAX_BITRATE_MAX 27000
#define MPEG_TOTAL_BITRATE_MAX 27000
struct mpeg_params {
enum mpeg_bitrate_mode bitrate_mode;
unsigned int video_target_bitrate;
unsigned int video_max_bitrate; // only used for VBR
enum mpeg_audio_bitrate audio_bitrate;
unsigned int total_bitrate;
};
#define MPEG_SETPARAMS _IOW('6',100,struct mpeg_params)
#endif // _SAA6752HS_H
/*
* Local variables:
* c-basic-offset: 8
* End:
*/
......@@ -43,17 +43,17 @@ int videobuf_unlock(struct page **pages, int nr_pages);
* A small set of helper functions to manage buffers (both userland
* and kernel) for DMA.
*
* videobuf_init_*_dmabuf()
* videobuf_dma_init_*()
* creates a buffer. The userland version takes a userspace
* pointer + length. The kernel version just wants the size and
* does memory allocation too using vmalloc_32().
*
* videobuf_pci_*_dmabuf()
* videobuf_dma_pci_*()
* see Documentation/DMA-mapping.txt, these functions to
* basically the same. The map function does also build a
* scatterlist for the buffer (and unmap frees it ...)
*
* videobuf_free_dmabuf()
* videobuf_dma_free()
* no comment ...
*
*/
......@@ -66,6 +66,9 @@ struct videobuf_dmabuf {
/* for kernel buffers */
void *vmalloc;
/* for overlay buffers (pci-pci dma) */
dma_addr_t bus_addr;
/* common */
struct scatterlist *sglist;
int sglen;
......@@ -77,6 +80,8 @@ int videobuf_dma_init_user(struct videobuf_dmabuf *dma, int direction,
unsigned long data, unsigned long size);
int videobuf_dma_init_kernel(struct videobuf_dmabuf *dma, int direction,
int nr_pages);
int videobuf_dma_init_overlay(struct videobuf_dmabuf *dma, int direction,
dma_addr_t addr, int nr_pages);
int videobuf_dma_pci_map(struct pci_dev *dev, struct videobuf_dmabuf *dma);
int videobuf_dma_pci_sync(struct pci_dev *dev,
struct videobuf_dmabuf *dma);
......@@ -133,6 +138,7 @@ struct videobuf_buffer {
/* info about the buffer */
unsigned int width;
unsigned int height;
unsigned int bytesperline; /* use only if != 0 */
unsigned long size;
enum v4l2_field field;
enum videobuf_state state;
......@@ -140,7 +146,8 @@ struct videobuf_buffer {
struct list_head stream; /* QBUF/DQBUF list */
/* for mmap'ed buffers */
size_t boff; /* buffer offset (mmap) */
enum v4l2_memory memory;
size_t boff; /* buffer offset (mmap + overlay) */
size_t bsize; /* buffer size */
unsigned long baddr; /* buffer addr (userland ptr!) */
struct videobuf_mapping *map;
......@@ -185,7 +192,8 @@ struct videobuf_queue {
void* videobuf_alloc(unsigned int size);
int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr);
int videobuf_iolock(struct pci_dev *pci, struct videobuf_buffer *vb);
int videobuf_iolock(struct pci_dev *pci, struct videobuf_buffer *vb,
struct v4l2_framebuffer *fbuf);
void videobuf_queue_init(struct videobuf_queue *q,
struct videobuf_queue_ops *ops,
......@@ -221,7 +229,8 @@ unsigned int videobuf_poll_stream(struct file *file,
poll_table *wait);
int videobuf_mmap_setup(struct file *file, struct videobuf_queue *q,
unsigned int bcount, unsigned int bsize);
unsigned int bcount, unsigned int bsize,
enum v4l2_memory memory);
int videobuf_mmap_free(struct file *file, struct videobuf_queue *q);
int videobuf_mmap_mapper(struct vm_area_struct *vma,
struct videobuf_queue *q);
......
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