Commit 03ff595c authored by Michael Hunold's avatar Michael Hunold Committed by Linus Torvalds

[PATCH] update the generic saa7146 driver

 - update the generic saa7146 driver
 - remove some #if LINUX_VERSION_CODE constructions
 - sync with the interrupt handler changes in 2.5.69
 - add a missing kfree() call which caused the kernel to leak 32kB of
   kmalloc()ed memory.  iieek!
 - fixed the capture code to handle cards that have swapped field order
   (odd and even fields)
 - added and fixed some debug messages
 - changed from kmalloc() to pci_consistent()
 - many small changes necessary to fix warnings/problems for ppc64
   compilation
parent a1c43026
...@@ -20,10 +20,6 @@ ...@@ -20,10 +20,6 @@
#include <media/saa7146.h> #include <media/saa7146.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51)
#define KBUILD_MODNAME saa7146
#endif
/* global variables */ /* global variables */
struct list_head saa7146_devices; struct list_head saa7146_devices;
struct semaphore saa7146_devices_lock; struct semaphore saa7146_devices_lock;
...@@ -207,7 +203,6 @@ static irqreturn_t interrupt_hw(int irq, void *dev_id, struct pt_regs *regs) ...@@ -207,7 +203,6 @@ static irqreturn_t interrupt_hw(int irq, void *dev_id, struct pt_regs *regs)
} }
saa7146_write(dev, ISR, isr); saa7146_write(dev, ISR, isr);
// DEB_INT(("0x%08x\n",isr));
if( 0 != (dev->ext)) { if( 0 != (dev->ext)) {
if( 0 != (dev->ext->irq_mask & isr )) { if( 0 != (dev->ext->irq_mask & isr )) {
...@@ -340,33 +335,33 @@ int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent) ...@@ -340,33 +335,33 @@ int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent)
} }
/* get memory for various stuff */ /* get memory for various stuff */
dev->rps0 = (u32*)kmalloc(SAA7146_RPS_MEM, GFP_KERNEL); dev->d_rps0.cpu_addr = pci_alloc_consistent(dev->pci, SAA7146_RPS_MEM, &dev->d_rps0.dma_handle);
if( NULL == dev->rps0 ) { if( NULL == dev->d_rps0.cpu_addr ) {
err = -ENOMEM; err = -ENOMEM;
goto kmalloc_error_1; goto kmalloc_error_1;
} }
memset(dev->rps0, 0x0, SAA7146_RPS_MEM); memset(dev->d_rps0.cpu_addr, 0x0, SAA7146_RPS_MEM);
dev->rps1 = (u32*)kmalloc(SAA7146_RPS_MEM, GFP_KERNEL); dev->d_rps1.cpu_addr = pci_alloc_consistent(dev->pci, SAA7146_RPS_MEM, &dev->d_rps1.dma_handle);
if( NULL == dev->rps1 ) { if( NULL == dev->d_rps1.cpu_addr ) {
err = -ENOMEM; err = -ENOMEM;
goto kmalloc_error_2; goto kmalloc_error_2;
} }
memset(dev->rps1, 0x0, SAA7146_RPS_MEM); memset(dev->d_rps1.cpu_addr, 0x0, SAA7146_RPS_MEM);
dev->i2c_mem = (u32*)kmalloc(SAA7146_I2C_MEM, GFP_KERNEL); dev->d_i2c.cpu_addr = pci_alloc_consistent(dev->pci, SAA7146_RPS_MEM, &dev->d_i2c.dma_handle);
if( NULL == dev->i2c_mem ) { if( NULL == dev->d_i2c.cpu_addr ) {
err = -ENOMEM; err = -ENOMEM;
goto kmalloc_error_3; goto kmalloc_error_3;
} }
memset(dev->i2c_mem, 0x00, SAA7146_I2C_MEM); memset(dev->d_i2c.cpu_addr, 0x0, SAA7146_RPS_MEM);
/* the rest + print status message */ /* the rest + print status message */
/* create a nice device name */ /* create a nice device name */
sprintf(&dev->name[0], "saa7146 (%d)",saa7146_num); sprintf(&dev->name[0], "saa7146 (%d)",saa7146_num);
INFO(("found saa7146 @ mem 0x%08x (revision %d, irq %d) (0x%04x,0x%04x).\n", (unsigned int)dev->mem, dev->revision,dev->pci->irq,dev->pci->subsystem_vendor,dev->pci->subsystem_device)); INFO(("found saa7146 @ mem %p (revision %d, irq %d) (0x%04x,0x%04x).\n", dev->mem, dev->revision,dev->pci->irq,dev->pci->subsystem_vendor,dev->pci->subsystem_device));
dev->ext = ext; dev->ext = ext;
pci_set_drvdata(pci,dev); pci_set_drvdata(pci,dev);
...@@ -406,11 +401,11 @@ int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent) ...@@ -406,11 +401,11 @@ int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent)
attach_error: attach_error:
probe_error: probe_error:
pci_set_drvdata(pci,NULL); pci_set_drvdata(pci,NULL);
kfree( dev->i2c_mem ); pci_free_consistent(dev->pci, SAA7146_RPS_MEM, dev->d_i2c.cpu_addr, dev->d_i2c.dma_handle);
kmalloc_error_3: kmalloc_error_3:
kfree( dev->rps1 ); pci_free_consistent(dev->pci, SAA7146_RPS_MEM, dev->d_rps1.cpu_addr, dev->d_rps1.dma_handle);
kmalloc_error_2: kmalloc_error_2:
kfree( dev->rps0 ); pci_free_consistent(dev->pci, SAA7146_RPS_MEM, dev->d_rps0.cpu_addr, dev->d_rps0.dma_handle);
kmalloc_error_1: kmalloc_error_1:
free_irq(dev->pci->irq, (void *)dev); free_irq(dev->pci->irq, (void *)dev);
irq_error: irq_error:
...@@ -440,9 +435,9 @@ void saa7146_remove_one(struct pci_dev *pdev) ...@@ -440,9 +435,9 @@ void saa7146_remove_one(struct pci_dev *pdev)
free_irq(dev->pci->irq, (void *)dev); free_irq(dev->pci->irq, (void *)dev);
/* free kernel memory */ /* free kernel memory */
kfree(dev->rps0 ); pci_free_consistent(dev->pci, SAA7146_RPS_MEM, dev->d_i2c.cpu_addr, dev->d_i2c.dma_handle);
kfree(dev->rps1 ); pci_free_consistent(dev->pci, SAA7146_RPS_MEM, dev->d_rps1.cpu_addr, dev->d_rps1.dma_handle);
kfree(dev->i2c_mem); pci_free_consistent(dev->pci, SAA7146_RPS_MEM, dev->d_rps0.cpu_addr, dev->d_rps0.dma_handle);
iounmap(dev->mem); iounmap(dev->mem);
release_mem_region(pci_resource_start(dev->pci,0), pci_resource_len(dev->pci,0)); release_mem_region(pci_resource_start(dev->pci,0), pci_resource_len(dev->pci,0));
......
#include <media/saa7146_vv.h> #include <media/saa7146_vv.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51)
#define KBUILD_MODNAME saa7146
#endif
#define BOARD_CAN_DO_VBI(dev) (dev->revision != 0 && dev->vv_data->vbi_minor != -1) #define BOARD_CAN_DO_VBI(dev) (dev->revision != 0 && dev->vv_data->vbi_minor != -1)
/********************************************************************************/ /********************************************************************************/
...@@ -111,7 +107,7 @@ void saa7146_buffer_next(struct saa7146_dev *dev, ...@@ -111,7 +107,7 @@ void saa7146_buffer_next(struct saa7146_dev *dev,
saa7146_write(dev, PROT_ADDR1, 0); saa7146_write(dev, PROT_ADDR1, 0);
/* write the address of the rps-program */ /* write the address of the rps-program */
saa7146_write(dev, RPS_ADDR0, virt_to_bus(&dev->rps0[ 0])); saa7146_write(dev, RPS_ADDR0, dev->d_rps0.dma_handle);
/* turn on rps */ /* turn on rps */
saa7146_write(dev, MC1, (MASK_12 | MASK_28)); saa7146_write(dev, MC1, (MASK_12 | MASK_28));
} }
...@@ -322,11 +318,11 @@ static ssize_t fops_read(struct file *file, char *data, size_t count, loff_t *pp ...@@ -322,11 +318,11 @@ static ssize_t fops_read(struct file *file, char *data, size_t count, loff_t *pp
switch (fh->type) { switch (fh->type) {
case V4L2_BUF_TYPE_VIDEO_CAPTURE: { case V4L2_BUF_TYPE_VIDEO_CAPTURE: {
DEB_EE(("V4L2_BUF_TYPE_VIDEO_CAPTURE: file:%p, data:%p, count:%d\n",file, data, count)); DEB_EE(("V4L2_BUF_TYPE_VIDEO_CAPTURE: file:%p, data:%p, count:%lun", file, data, (unsigned long)count));
return saa7146_video_uops.read(file,data,count,ppos); return saa7146_video_uops.read(file,data,count,ppos);
} }
case V4L2_BUF_TYPE_VBI_CAPTURE: { case V4L2_BUF_TYPE_VBI_CAPTURE: {
DEB_EE(("V4L2_BUF_TYPE_VBI_CAPTURE: file:%p, data:%p, count:%d\n",file, data, count)); DEB_EE(("V4L2_BUF_TYPE_VBI_CAPTURE: file:%p, data:%p, count:%lu\n", file, data, (unsigned long)count));
return saa7146_vbi_uops.read(file,data,count,ppos); return saa7146_vbi_uops.read(file,data,count,ppos);
} }
break; break;
...@@ -393,13 +389,13 @@ int saa7146_vv_init(struct saa7146_dev* dev) ...@@ -393,13 +389,13 @@ int saa7146_vv_init(struct saa7146_dev* dev)
vv->video_minor = -1; vv->video_minor = -1;
vv->vbi_minor = -1; vv->vbi_minor = -1;
vv->clipping = (u32*)kmalloc(SAA7146_CLIPPING_MEM, GFP_KERNEL); vv->d_clipping.cpu_addr = pci_alloc_consistent(dev->pci, SAA7146_CLIPPING_MEM, &vv->d_clipping.dma_handle);
if( NULL == vv->clipping ) { if( NULL == vv->d_clipping.cpu_addr ) {
ERR(("out of memory. aborting.\n")); ERR(("out of memory. aborting.\n"));
kfree(vv); kfree(vv);
return -1; return -1;
} }
memset(vv->clipping, 0x0, SAA7146_CLIPPING_MEM); memset(vv->d_clipping.cpu_addr, 0x0, SAA7146_CLIPPING_MEM);
saa7146_video_uops.init(dev,vv); saa7146_video_uops.init(dev,vv);
saa7146_vbi_uops.init(dev,vv); saa7146_vbi_uops.init(dev,vv);
...@@ -416,6 +412,7 @@ int saa7146_vv_release(struct saa7146_dev* dev) ...@@ -416,6 +412,7 @@ int saa7146_vv_release(struct saa7146_dev* dev)
DEB_EE(("dev:%p\n",dev)); DEB_EE(("dev:%p\n",dev));
pci_free_consistent(dev->pci, SAA7146_RPS_MEM, vv->d_clipping.cpu_addr, vv->d_clipping.dma_handle);
kfree(vv); kfree(vv);
dev->vv_data = NULL; dev->vv_data = NULL;
dev->vv_callback = NULL; dev->vv_callback = NULL;
......
#include <media/saa7146_vv.h> #include <media/saa7146_vv.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51)
#define KBUILD_MODNAME saa7146
#endif
#define my_min(type,x,y) \ #define my_min(type,x,y) \
({ type __x = (x), __y = (y); __x < __y ? __x: __y; }) ({ type __x = (x), __y = (y); __x < __y ? __x: __y; })
#define my_max(type,x,y) \ #define my_max(type,x,y) \
...@@ -360,7 +356,7 @@ void calculate_clipping_registers_rect(struct saa7146_dev *dev, struct saa7146_f ...@@ -360,7 +356,7 @@ void calculate_clipping_registers_rect(struct saa7146_dev *dev, struct saa7146_f
struct saa7146_video_dma *vdma2, u32* clip_format, u32* arbtr_ctrl, enum v4l2_field field) struct saa7146_video_dma *vdma2, u32* clip_format, u32* arbtr_ctrl, enum v4l2_field field)
{ {
struct saa7146_vv *vv = dev->vv_data; struct saa7146_vv *vv = dev->vv_data;
u32 *clipping = vv->clipping; u32 *clipping = vv->d_clipping.cpu_addr;
int width = fh->ov.win.w.width; int width = fh->ov.win.w.width;
int height = fh->ov.win.w.height; int height = fh->ov.win.w.height;
...@@ -469,9 +465,9 @@ void calculate_clipping_registers_rect(struct saa7146_dev *dev, struct saa7146_f ...@@ -469,9 +465,9 @@ void calculate_clipping_registers_rect(struct saa7146_dev *dev, struct saa7146_f
*arbtr_ctrl &= 0xffff00ff; *arbtr_ctrl &= 0xffff00ff;
*arbtr_ctrl |= 0x00001c00; *arbtr_ctrl |= 0x00001c00;
vdma2->base_even = virt_to_bus(clipping); vdma2->base_even = vv->d_clipping.dma_handle;
vdma2->base_odd = virt_to_bus(clipping); vdma2->base_odd = vv->d_clipping.dma_handle;
vdma2->prot_addr = virt_to_bus(clipping)+((sizeof(u32))*(numdwords)); vdma2->prot_addr = vv->d_clipping.dma_handle+((sizeof(u32))*(numdwords));
vdma2->base_page = 0x04; vdma2->base_page = 0x04;
vdma2->pitch = 0x00; vdma2->pitch = 0x00;
vdma2->num_line_byte = (0 << 16 | (sizeof(u32))*(numdwords-1) ); vdma2->num_line_byte = (0 << 16 | (sizeof(u32))*(numdwords-1) );
...@@ -953,6 +949,8 @@ int calculate_video_dma_grab_planar(struct saa7146_dev* dev, struct saa7146_buf ...@@ -953,6 +949,8 @@ int calculate_video_dma_grab_planar(struct saa7146_dev* dev, struct saa7146_buf
return 0; return 0;
} }
#define WRITE_RPS0(x) dev->d_rps0.cpu_addr[ count++ ] = cpu_to_le32(x)
static static
void program_capture_engine(struct saa7146_dev *dev, int planar) void program_capture_engine(struct saa7146_dev *dev, int planar)
{ {
...@@ -962,58 +960,64 @@ void program_capture_engine(struct saa7146_dev *dev, int planar) ...@@ -962,58 +960,64 @@ void program_capture_engine(struct saa7146_dev *dev, int planar)
unsigned long e_wait = vv->current_hps_sync == SAA7146_HPS_SYNC_PORT_A ? CMD_E_FID_A : CMD_E_FID_B; unsigned long e_wait = vv->current_hps_sync == SAA7146_HPS_SYNC_PORT_A ? CMD_E_FID_A : CMD_E_FID_B;
unsigned long o_wait = vv->current_hps_sync == SAA7146_HPS_SYNC_PORT_A ? CMD_O_FID_A : CMD_O_FID_B; unsigned long o_wait = vv->current_hps_sync == SAA7146_HPS_SYNC_PORT_A ? CMD_O_FID_A : CMD_O_FID_B;
if( 0 != (dev->ext->ext_vv_data->flags & SAA7146_EXT_SWAP_ODD_EVEN)) {
unsigned long tmp = e_wait;
e_wait = o_wait;
o_wait = tmp;
}
/* write beginning of rps-program */ /* write beginning of rps-program */
count = 0; count = 0;
/* wait for o_fid_a/b / e_fid_a/b toggle only if bit 0 is not set*/ /* wait for o_fid_a/b / e_fid_a/b toggle only if bit 0 is not set*/
dev->rps0[ count++ ] = CMD_PAUSE | CMD_OAN | CMD_SIG0 | e_wait; WRITE_RPS0(CMD_PAUSE | CMD_OAN | CMD_SIG0 | e_wait);
dev->rps0[ count++ ] = CMD_PAUSE | CMD_OAN | CMD_SIG0 | o_wait; WRITE_RPS0(CMD_PAUSE | CMD_OAN | CMD_SIG0 | o_wait);
/* set bit 0 */ /* set bit 0 */
dev->rps0[ count++ ] = CMD_WR_REG | (1 << 8) | (MC2/4); WRITE_RPS0(CMD_WR_REG | (1 << 8) | (MC2/4));
dev->rps0[ count++ ] = MASK_27 | MASK_11; WRITE_RPS0(MASK_27 | MASK_11);
/* turn on video-dma1 */ /* turn on video-dma1 */
dev->rps0[ count++ ] = CMD_WR_REG_MASK | (MC1/4); WRITE_RPS0(CMD_WR_REG_MASK | (MC1/4));
dev->rps0[ count++ ] = MASK_06 | MASK_22; /* => mask */ WRITE_RPS0(MASK_06 | MASK_22); /* => mask */
dev->rps0[ count++ ] = MASK_06 | MASK_22; /* => values */ WRITE_RPS0(MASK_06 | MASK_22); /* => values */
if( 0 != planar ) { if( 0 != planar ) {
/* turn on video-dma2 */ /* turn on video-dma2 */
dev->rps0[ count++ ] = CMD_WR_REG_MASK | (MC1/4); WRITE_RPS0(CMD_WR_REG_MASK | (MC1/4));
dev->rps0[ count++ ] = MASK_05 | MASK_21; /* => mask */ WRITE_RPS0(MASK_05 | MASK_21); /* => mask */
dev->rps0[ count++ ] = MASK_05 | MASK_21; /* => values */ WRITE_RPS0(MASK_05 | MASK_21); /* => values */
/* turn on video-dma3 */ /* turn on video-dma3 */
dev->rps0[ count++ ] = CMD_WR_REG_MASK | (MC1/4); WRITE_RPS0(CMD_WR_REG_MASK | (MC1/4));
dev->rps0[ count++ ] = MASK_04 | MASK_20; /* => mask */ WRITE_RPS0(MASK_04 | MASK_20); /* => mask */
dev->rps0[ count++ ] = MASK_04 | MASK_20; /* => values */ WRITE_RPS0(MASK_04 | MASK_20); /* => values */
} }
/* wait for o_fid_a/b / e_fid_a/b toggle */ /* wait for o_fid_a/b / e_fid_a/b toggle */
dev->rps0[ count++ ] = CMD_PAUSE | e_wait; WRITE_RPS0(CMD_PAUSE | e_wait);
dev->rps0[ count++ ] = CMD_PAUSE | o_wait; WRITE_RPS0(CMD_PAUSE | o_wait);
/* turn off video-dma1 */ /* turn off video-dma1 */
dev->rps0[ count++ ] = CMD_WR_REG_MASK | (MC1/4); WRITE_RPS0(CMD_WR_REG_MASK | (MC1/4));
dev->rps0[ count++ ] = MASK_22 | MASK_06; /* => mask */ WRITE_RPS0(MASK_22 | MASK_06); /* => mask */
dev->rps0[ count++ ] = MASK_22; /* => values */ WRITE_RPS0(MASK_22); /* => values */
if( 0 != planar ) { if( 0 != planar ) {
/* turn off video-dma2 */ /* turn off video-dma2 */
dev->rps0[ count++ ] = CMD_WR_REG_MASK | (MC1/4); WRITE_RPS0(CMD_WR_REG_MASK | (MC1/4));
dev->rps0[ count++ ] = MASK_05 | MASK_21; /* => mask */ WRITE_RPS0(MASK_05 | MASK_21); /* => mask */
dev->rps0[ count++ ] = MASK_21; /* => values */ WRITE_RPS0(MASK_21); /* => values */
/* turn off video-dma3 */ /* turn off video-dma3 */
dev->rps0[ count++ ] = CMD_WR_REG_MASK | (MC1/4); WRITE_RPS0(CMD_WR_REG_MASK | (MC1/4));
dev->rps0[ count++ ] = MASK_04 | MASK_20; /* => mask */ WRITE_RPS0(MASK_04 | MASK_20); /* => mask */
dev->rps0[ count++ ] = MASK_20; /* => values */ WRITE_RPS0(MASK_20); /* => values */
} }
/* generate interrupt */ /* generate interrupt */
dev->rps0[ count++ ] = CMD_INTERRUPT; WRITE_RPS0(CMD_INTERRUPT);
/* stop */ /* stop */
dev->rps0[ count++ ] = CMD_STOP; WRITE_RPS0(CMD_STOP);
} }
void saa7146_set_capture(struct saa7146_dev *dev, struct saa7146_buf *buf, struct saa7146_buf *next) void saa7146_set_capture(struct saa7146_dev *dev, struct saa7146_buf *buf, struct saa7146_buf *next)
...@@ -1035,7 +1039,7 @@ void saa7146_set_capture(struct saa7146_dev *dev, struct saa7146_buf *buf, struc ...@@ -1035,7 +1039,7 @@ void saa7146_set_capture(struct saa7146_dev *dev, struct saa7146_buf *buf, struc
} }
/* write the address of the rps-program */ /* write the address of the rps-program */
saa7146_write(dev, RPS_ADDR0, virt_to_bus(&dev->rps0[ 0])); saa7146_write(dev, RPS_ADDR0, dev->d_rps0.dma_handle);
/* turn on rps */ /* turn on rps */
saa7146_write(dev, MC1, (MASK_12 | MASK_28)); saa7146_write(dev, MC1, (MASK_12 | MASK_28));
......
#include <media/saa7146_vv.h> #include <media/saa7146_vv.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51)
#define KBUILD_MODNAME saa7146
#endif
/* helper function */ /* helper function */
static static
void my_wait(struct saa7146_dev *dev, long ms) void my_wait(struct saa7146_dev *dev, long ms)
...@@ -284,7 +280,7 @@ int saa7146_i2c_writeout(struct saa7146_dev *dev, u32* dword) ...@@ -284,7 +280,7 @@ int saa7146_i2c_writeout(struct saa7146_dev *dev, u32* dword)
int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg msgs[], int num, int retries) int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg msgs[], int num, int retries)
{ {
int i = 0, count = 0; int i = 0, count = 0;
u32* buffer = dev->i2c_mem; u32* buffer = dev->d_i2c.cpu_addr;
int err = 0; int err = 0;
int address_err = 0; int address_err = 0;
...@@ -382,8 +378,6 @@ int saa7146_i2c_xfer(struct i2c_adapter* adapter, struct i2c_msg msg[], int num) ...@@ -382,8 +378,6 @@ int saa7146_i2c_xfer(struct i2c_adapter* adapter, struct i2c_msg msg[], int num)
{ {
struct saa7146_dev* dev = i2c_get_adapdata(adapter); struct saa7146_dev* dev = i2c_get_adapdata(adapter);
DEB_I2C(("adapter: '%s'.\n", adapter->dev.name));
/* use helper function to transfer data */ /* use helper function to transfer data */
return saa7146_i2c_transfer(dev, msg, num, adapter->retries); return saa7146_i2c_transfer(dev, msg, num, adapter->retries);
} }
......
#include <media/saa7146_vv.h> #include <media/saa7146_vv.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51)
#define KBUILD_MODNAME saa7146
#endif
static int vbi_pixel_to_capture = 720 * 2; static int vbi_pixel_to_capture = 720 * 2;
#define WRITE_RPS1(x) dev->d_rps1.cpu_addr[ count++ ] = cpu_to_le32(x)
static static
int vbi_workaround(struct saa7146_dev *dev) int vbi_workaround(struct saa7146_dev *dev)
{ {
...@@ -14,7 +12,7 @@ int vbi_workaround(struct saa7146_dev *dev) ...@@ -14,7 +12,7 @@ int vbi_workaround(struct saa7146_dev *dev)
u32 *cpu; u32 *cpu;
dma_addr_t dma_addr; dma_addr_t dma_addr;
int i, index; int i, count;
DECLARE_WAITQUEUE(wait, current); DECLARE_WAITQUEUE(wait, current);
...@@ -49,43 +47,43 @@ int vbi_workaround(struct saa7146_dev *dev) ...@@ -49,43 +47,43 @@ int vbi_workaround(struct saa7146_dev *dev)
saa7146_write(dev, NUM_LINE_BYTE3, (1<<16)|(2<<0)); saa7146_write(dev, NUM_LINE_BYTE3, (1<<16)|(2<<0));
saa7146_write(dev, MC2, MASK_04|MASK_20); saa7146_write(dev, MC2, MASK_04|MASK_20);
index = 0; count = 0;
/* load brs-control register */ /* load brs-control register */
dev->rps1[index++] = CMD_WR_REG | (1 << 8) | (BRS_CTRL/4); WRITE_RPS1(CMD_WR_REG | (1 << 8) | (BRS_CTRL/4));
/* BXO = 1h, BRS to outbound */ /* BXO = 1h, BRS to outbound */
dev->rps1[index++]=0xc000008c; WRITE_RPS1(0xc000008c);
/* wait for vbi_a */ /* wait for vbi_a */
dev->rps1[index++] = CMD_PAUSE | MASK_10; WRITE_RPS1(CMD_PAUSE | MASK_10);
/* upload brs */ /* upload brs */
dev->rps1[index++] = CMD_UPLOAD | MASK_08; WRITE_RPS1(CMD_UPLOAD | MASK_08);
/* load brs-control register */ /* load brs-control register */
dev->rps1[index++] = CMD_WR_REG | (1 << 8) | (BRS_CTRL/4); WRITE_RPS1(CMD_WR_REG | (1 << 8) | (BRS_CTRL/4));
/* BYO = 1, BXO = NQBIL (=1728 for PAL, for NTSC this is 858*2) - NumByte3 (=1440) = 288 */ /* BYO = 1, BXO = NQBIL (=1728 for PAL, for NTSC this is 858*2) - NumByte3 (=1440) = 288 */
dev->rps1[index++] = ((1728-(vbi_pixel_to_capture)) << 7) | MASK_19; WRITE_RPS1(((1728-(vbi_pixel_to_capture)) << 7) | MASK_19);
/* wait for brs_done */ /* wait for brs_done */
dev->rps1[index++] = CMD_PAUSE | MASK_08; WRITE_RPS1(CMD_PAUSE | MASK_08);
/* upload brs */ /* upload brs */
dev->rps1[index++] = CMD_UPLOAD | MASK_08; WRITE_RPS1(CMD_UPLOAD | MASK_08);
/* load video-dma3 NumLines3 and NumBytes3 */ /* load video-dma3 NumLines3 and NumBytes3 */
dev->rps1[index++] = CMD_WR_REG | (1 << 8) | (NUM_LINE_BYTE3/4); WRITE_RPS1(CMD_WR_REG | (1 << 8) | (NUM_LINE_BYTE3/4));
/* dev->vbi_count*2 lines, 720 pixel (= 1440 Bytes) */ /* dev->vbi_count*2 lines, 720 pixel (= 1440 Bytes) */
dev->rps1[index++]= (2 << 16) | (vbi_pixel_to_capture); WRITE_RPS1((2 << 16) | (vbi_pixel_to_capture));
/* load brs-control register */ /* load brs-control register */
dev->rps1[index++] = CMD_WR_REG | (1 << 8) | (BRS_CTRL/4); WRITE_RPS1(CMD_WR_REG | (1 << 8) | (BRS_CTRL/4));
/* Set BRS right: note: this is an experimental value for BXO (=> PAL!) */ /* Set BRS right: note: this is an experimental value for BXO (=> PAL!) */
dev->rps1[index++] = (540 << 7) | (5 << 19); // 5 == vbi_start WRITE_RPS1((540 << 7) | (5 << 19)); // 5 == vbi_start
/* wait for brs_done */ /* wait for brs_done */
dev->rps1[index++] = CMD_PAUSE | MASK_08; WRITE_RPS1(CMD_PAUSE | MASK_08);
/* upload brs and video-dma3*/ /* upload brs and video-dma3*/
dev->rps1[index++] = CMD_UPLOAD | MASK_08 | MASK_04; WRITE_RPS1(CMD_UPLOAD | MASK_08 | MASK_04);
/* load mc2 register: enable dma3 */ /* load mc2 register: enable dma3 */
dev->rps1[index++] = CMD_WR_REG | (1 << 8) | (MC1/4); WRITE_RPS1(CMD_WR_REG | (1 << 8) | (MC1/4));
dev->rps1[index++] = MASK_20 | MASK_04; WRITE_RPS1(MASK_20 | MASK_04);
/* generate interrupt */ /* generate interrupt */
dev->rps1[index++] = CMD_INTERRUPT; WRITE_RPS1(CMD_INTERRUPT);
/* stop rps1 */ /* stop rps1 */
dev->rps1[index++] = CMD_STOP; WRITE_RPS1(CMD_STOP);
/* enable rps1 irqs */ /* enable rps1 irqs */
IER_ENABLE(dev,MASK_28); IER_ENABLE(dev,MASK_28);
...@@ -95,7 +93,7 @@ int vbi_workaround(struct saa7146_dev *dev) ...@@ -95,7 +93,7 @@ int vbi_workaround(struct saa7146_dev *dev)
current->state = TASK_INTERRUPTIBLE; current->state = TASK_INTERRUPTIBLE;
/* start rps1 to enable workaround */ /* start rps1 to enable workaround */
saa7146_write(dev, RPS_ADDR1, virt_to_bus(&dev->rps1[ 0])); saa7146_write(dev, RPS_ADDR1, dev->d_rps1.dma_handle);
saa7146_write(dev, MC1, (MASK_13 | MASK_29)); saa7146_write(dev, MC1, (MASK_13 | MASK_29));
schedule(); schedule();
...@@ -164,33 +162,33 @@ void saa7146_set_vbi_capture(struct saa7146_dev *dev, struct saa7146_buf *buf, s ...@@ -164,33 +162,33 @@ void saa7146_set_vbi_capture(struct saa7146_dev *dev, struct saa7146_buf *buf, s
but by doing this, we can use the whole engine from video-buf.c... */ but by doing this, we can use the whole engine from video-buf.c... */
/* /*
dev->rps1[ count++ ] = CMD_PAUSE | CMD_OAN | CMD_SIG1 | e_wait; WRITE_RPS1(CMD_PAUSE | CMD_OAN | CMD_SIG1 | e_wait);
dev->rps1[ count++ ] = CMD_PAUSE | CMD_OAN | CMD_SIG1 | o_wait; WRITE_RPS1(CMD_PAUSE | CMD_OAN | CMD_SIG1 | o_wait);
*/ */
/* set bit 1 */ /* set bit 1 */
dev->rps1[ count++ ] = CMD_WR_REG | (1 << 8) | (MC2/4); WRITE_RPS1(CMD_WR_REG | (1 << 8) | (MC2/4));
dev->rps1[ count++ ] = MASK_28 | MASK_12; WRITE_RPS1(MASK_28 | MASK_12);
/* turn on video-dma3 */ /* turn on video-dma3 */
dev->rps1[ count++ ] = CMD_WR_REG_MASK | (MC1/4); WRITE_RPS1(CMD_WR_REG_MASK | (MC1/4));
dev->rps1[ count++ ] = MASK_04 | MASK_20; /* => mask */ WRITE_RPS1(MASK_04 | MASK_20); /* => mask */
dev->rps1[ count++ ] = MASK_04 | MASK_20; /* => values */ WRITE_RPS1(MASK_04 | MASK_20); /* => values */
/* wait for o_fid_a/b / e_fid_a/b toggle */ /* wait for o_fid_a/b / e_fid_a/b toggle */
dev->rps1[ count++ ] = CMD_PAUSE | o_wait; WRITE_RPS1(CMD_PAUSE | o_wait);
dev->rps1[ count++ ] = CMD_PAUSE | e_wait; WRITE_RPS1(CMD_PAUSE | e_wait);
/* generate interrupt */ /* generate interrupt */
dev->rps1[ count++ ] = CMD_INTERRUPT; WRITE_RPS1(CMD_INTERRUPT);
/* stop */ /* stop */
dev->rps1[ count++ ] = CMD_STOP; WRITE_RPS1(CMD_STOP);
/* enable rps1 irqs */ /* enable rps1 irqs */
IER_ENABLE(dev, MASK_28); IER_ENABLE(dev, MASK_28);
/* write the address of the rps-program */ /* write the address of the rps-program */
saa7146_write(dev, RPS_ADDR1, virt_to_bus(&dev->rps1[ 0])); saa7146_write(dev, RPS_ADDR1, dev->d_rps1.dma_handle);
/* turn on rps */ /* turn on rps */
saa7146_write(dev, MC1, (MASK_13 | MASK_29)); saa7146_write(dev, MC1, (MASK_13 | MASK_29));
......
#include <media/saa7146_vv.h> #include <media/saa7146_vv.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51)
#define KBUILD_MODNAME saa7146
#endif
static static
int memory = 32; int memory = 32;
...@@ -434,20 +430,25 @@ int get_control(struct saa7146_fh *fh, struct v4l2_control *c) ...@@ -434,20 +430,25 @@ int get_control(struct saa7146_fh *fh, struct v4l2_control *c)
case V4L2_CID_BRIGHTNESS: case V4L2_CID_BRIGHTNESS:
value = saa7146_read(dev, BCS_CTRL); value = saa7146_read(dev, BCS_CTRL);
c->value = 0xff & (value >> 24); c->value = 0xff & (value >> 24);
DEB_D(("V4L2_CID_BRIGHTNESS: %d\n",c->value));
break; break;
case V4L2_CID_CONTRAST: case V4L2_CID_CONTRAST:
value = saa7146_read(dev, BCS_CTRL); value = saa7146_read(dev, BCS_CTRL);
c->value = 0x7f & (value >> 16); c->value = 0x7f & (value >> 16);
DEB_D(("V4L2_CID_CONTRAST: %d\n",c->value));
break; break;
case V4L2_CID_SATURATION: case V4L2_CID_SATURATION:
value = saa7146_read(dev, BCS_CTRL); value = saa7146_read(dev, BCS_CTRL);
c->value = 0x7f & (value >> 0); c->value = 0x7f & (value >> 0);
DEB_D(("V4L2_CID_SATURATION: %d\n",c->value));
break; break;
case V4L2_CID_VFLIP: case V4L2_CID_VFLIP:
c->value = vv->vflip; c->value = vv->vflip;
DEB_D(("V4L2_CID_VFLIP: %d\n",c->value));
break; break;
case V4L2_CID_HFLIP: case V4L2_CID_HFLIP:
c->value = vv->hflip; c->value = vv->hflip;
DEB_D(("V4L2_CID_HFLIP: %d\n",c->value));
break; break;
default: default:
return -EINVAL; return -EINVAL;
...@@ -876,7 +877,7 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int ...@@ -876,7 +877,7 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
return -EINVAL; return -EINVAL;
} }
DEB_EE(("VIDIOC_ENUMSTD: type:%d, index:%d\n",f->type,f->index)); DEB_EE(("VIDIOC_ENUM_FMT: type:%d, index:%d\n",f->type,f->index));
return 0; return 0;
} }
case VIDIOC_QUERYCTRL: case VIDIOC_QUERYCTRL:
...@@ -974,6 +975,8 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int ...@@ -974,6 +975,8 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
struct saa7146_fh *ov_fh = NULL; struct saa7146_fh *ov_fh = NULL;
DEB_EE(("VIDIOC_S_STD\n"));
if( 0 != vv->streaming ) { if( 0 != vv->streaming ) {
return -EBUSY; return -EBUSY;
} }
......
...@@ -12,9 +12,12 @@ ...@@ -12,9 +12,12 @@
#include <linux/i2c.h> /* for i2c subsystem */ #include <linux/i2c.h> /* for i2c subsystem */
#include <asm/io.h> /* for accessing devices */ #include <asm/io.h> /* for accessing devices */
#include <linux/stringify.h> #include <linux/stringify.h>
#include <linux/vmalloc.h> /* for vmalloc() */
#include <linux/mm.h> /* for vmalloc_to_page() */
/* ugly, but necessary to build the dvb stuff under 2.4. */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51) #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51)
#include "compat.h" #include "dvb_functions.h"
#endif #endif
#define SAA7146_VERSION_CODE KERNEL_VERSION(0,5,0) #define SAA7146_VERSION_CODE KERNEL_VERSION(0,5,0)
...@@ -30,7 +33,16 @@ extern unsigned int saa7146_debug; ...@@ -30,7 +33,16 @@ extern unsigned int saa7146_debug;
#define DEBUG_VARIABLE saa7146_debug #define DEBUG_VARIABLE saa7146_debug
#endif #endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51)
#define DEBUG_PROLOG printk("%s: %s(): ",__stringify(KBUILD_BASENAME),__FUNCTION__)
#define INFO(x) { printk("%s: ",__stringify(KBUILD_BASENAME)); printk x; }
#else
#define DEBUG_PROLOG printk("%s: %s(): ",__stringify(KBUILD_MODNAME),__FUNCTION__) #define DEBUG_PROLOG printk("%s: %s(): ",__stringify(KBUILD_MODNAME),__FUNCTION__)
#define INFO(x) { printk("%s: ",__stringify(KBUILD_MODNAME)); printk x; }
#endif
#define ERR(x) { DEBUG_PROLOG; printk x; }
#define DEB_S(x) if (0!=(DEBUG_VARIABLE&0x01)) { DEBUG_PROLOG; printk x; } /* simple debug messages */ #define DEB_S(x) if (0!=(DEBUG_VARIABLE&0x01)) { DEBUG_PROLOG; printk x; } /* simple debug messages */
#define DEB_D(x) if (0!=(DEBUG_VARIABLE&0x02)) { DEBUG_PROLOG; printk x; } /* more detailed debug messages */ #define DEB_D(x) if (0!=(DEBUG_VARIABLE&0x02)) { DEBUG_PROLOG; printk x; } /* more detailed debug messages */
#define DEB_EE(x) if (0!=(DEBUG_VARIABLE&0x04)) { DEBUG_PROLOG; printk x; } /* print enter and exit of functions */ #define DEB_EE(x) if (0!=(DEBUG_VARIABLE&0x04)) { DEBUG_PROLOG; printk x; } /* print enter and exit of functions */
...@@ -39,9 +51,6 @@ extern unsigned int saa7146_debug; ...@@ -39,9 +51,6 @@ extern unsigned int saa7146_debug;
#define DEB_INT(x) if (0!=(DEBUG_VARIABLE&0x20)) { DEBUG_PROLOG; printk x; } /* interrupt debug messages */ #define DEB_INT(x) if (0!=(DEBUG_VARIABLE&0x20)) { DEBUG_PROLOG; printk x; } /* interrupt debug messages */
#define DEB_CAP(x) if (0!=(DEBUG_VARIABLE&0x40)) { DEBUG_PROLOG; printk x; } /* capture debug messages */ #define DEB_CAP(x) if (0!=(DEBUG_VARIABLE&0x40)) { DEBUG_PROLOG; printk x; } /* capture debug messages */
#define ERR(x) { DEBUG_PROLOG; printk x; }
#define INFO(x) { printk("%s: ",__stringify(KBUILD_MODNAME)); printk x; }
#define IER_DISABLE(x,y) \ #define IER_DISABLE(x,y) \
saa7146_write(x, IER, saa7146_read(x, IER) & ~(y)); saa7146_write(x, IER, saa7146_read(x, IER) & ~(y));
#define IER_ENABLE(x,y) \ #define IER_ENABLE(x,y) \
...@@ -97,6 +106,12 @@ struct saa7146_extension ...@@ -97,6 +106,12 @@ struct saa7146_extension
void (*irq_func)(struct saa7146_dev*, u32* irq_mask); void (*irq_func)(struct saa7146_dev*, u32* irq_mask);
}; };
struct saa7146_dma
{
dma_addr_t dma_handle;
u32 *cpu_addr;
};
struct saa7146_dev struct saa7146_dev
{ {
struct module *module; struct module *module;
...@@ -127,13 +142,13 @@ struct saa7146_dev ...@@ -127,13 +142,13 @@ struct saa7146_dev
/* i2c-stuff */ /* i2c-stuff */
struct semaphore i2c_lock; struct semaphore i2c_lock;
u32 i2c_bitrate; u32 i2c_bitrate;
u32 *i2c_mem; /* pointer to i2c memory */ struct saa7146_dma d_i2c; /* pointer to i2c memory */
wait_queue_head_t i2c_wq; wait_queue_head_t i2c_wq;
int i2c_op; int i2c_op;
/* memories */ /* memories */
u32 *rps0; struct saa7146_dma d_rps0;
u32 *rps1; struct saa7146_dma d_rps1;
}; };
/* from saa7146_i2c.c */ /* from saa7146_i2c.c */
......
...@@ -126,7 +126,7 @@ struct saa7146_vv ...@@ -126,7 +126,7 @@ struct saa7146_vv
int current_hps_source; int current_hps_source;
int current_hps_sync; int current_hps_sync;
u32 *clipping; /* pointer to clipping memory */ struct saa7146_dma d_clipping; /* pointer to clipping memory */
}; };
#define SAA7146_EXCLUSIVE 0x1 #define SAA7146_EXCLUSIVE 0x1
......
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