summaryrefslogtreecommitdiff
path: root/linux
diff options
context:
space:
mode:
authorMichael Hunold <devnull@localhost>2003-05-19 17:33:06 +0000
committerMichael Hunold <devnull@localhost>2003-05-19 17:33:06 +0000
commit1b96056da548c2823012c52a69e671310ff3445b (patch)
treebdacde53ad08265b7713e75f44d2fba881f08591 /linux
parent78fccbe2a473cdf42a87d98fedaa89f4880da05d (diff)
downloadmediapointer-dvb-s2-1b96056da548c2823012c52a69e671310ff3445b.tar.gz
mediapointer-dvb-s2-1b96056da548c2823012c52a69e671310ff3445b.tar.bz2
First try to use pci_consistent_dma() throughout the whole saa7146
driver subsystem.
Diffstat (limited to 'linux')
-rw-r--r--linux/drivers/media/common/saa7146_core.c40
-rw-r--r--linux/drivers/media/common/saa7146_fops.c14
-rw-r--r--linux/drivers/media/common/saa7146_hlp.c64
-rw-r--r--linux/drivers/media/common/saa7146_i2c.c2
-rw-r--r--linux/drivers/media/common/saa7146_vbi.c68
-rw-r--r--linux/drivers/media/dvb/ttpci/budget-patch.c29
-rw-r--r--linux/include/media/saa7146.h14
-rw-r--r--linux/include/media/saa7146_vv.h2
8 files changed, 124 insertions, 109 deletions
diff --git a/linux/drivers/media/common/saa7146_core.c b/linux/drivers/media/common/saa7146_core.c
index 5dfd191f5..55a93a805 100644
--- a/linux/drivers/media/common/saa7146_core.c
+++ b/linux/drivers/media/common/saa7146_core.c
@@ -344,33 +344,33 @@ int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent)
}
/* get memory for various stuff */
- dev->rps0 = (u32*)kmalloc(SAA7146_RPS_MEM, GFP_KERNEL);
- if( NULL == dev->rps0 ) {
+ dev->d_rps0.cpu_addr = pci_alloc_consistent(dev->pci, SAA7146_RPS_MEM, &dev->d_rps0.dma_handle);
+ if( NULL == dev->d_rps0.cpu_addr ) {
err = -ENOMEM;
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);
- if( NULL == dev->rps1 ) {
+ dev->d_rps1.cpu_addr = pci_alloc_consistent(dev->pci, SAA7146_RPS_MEM, &dev->d_rps1.dma_handle);
+ if( NULL == dev->d_rps1.cpu_addr ) {
err = -ENOMEM;
goto kmalloc_error_2;
- }
- memset(dev->rps1, 0x0, SAA7146_RPS_MEM);
-
- dev->i2c_mem = (u32*)kmalloc(SAA7146_I2C_MEM, GFP_KERNEL);
- if( NULL == dev->i2c_mem ) {
+ }
+ memset(dev->d_rps1.cpu_addr, 0x0, SAA7146_RPS_MEM);
+
+ dev->d_i2c.cpu_addr = pci_alloc_consistent(dev->pci, SAA7146_RPS_MEM, &dev->d_i2c.dma_handle);
+ if( NULL == dev->d_i2c.cpu_addr ) {
err = -ENOMEM;
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 */
/* create a nice device name */
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;
pci_set_drvdata(pci,dev);
@@ -410,11 +410,11 @@ int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent)
attach_error:
probe_error:
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:
- kfree( dev->rps1 );
+ pci_free_consistent(dev->pci, SAA7146_RPS_MEM, dev->d_rps1.cpu_addr, dev->d_rps1.dma_handle);
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:
free_irq(dev->pci->irq, (void *)dev);
irq_error:
@@ -444,9 +444,9 @@ void saa7146_remove_one(struct pci_dev *pdev)
free_irq(dev->pci->irq, (void *)dev);
/* free kernel memory */
- kfree(dev->rps0 );
- kfree(dev->rps1 );
- kfree(dev->i2c_mem);
+ pci_free_consistent(dev->pci, SAA7146_RPS_MEM, dev->d_i2c.cpu_addr, dev->d_i2c.dma_handle);
+ pci_free_consistent(dev->pci, SAA7146_RPS_MEM, dev->d_rps1.cpu_addr, dev->d_rps1.dma_handle);
+ pci_free_consistent(dev->pci, SAA7146_RPS_MEM, dev->d_rps0.cpu_addr, dev->d_rps0.dma_handle);
iounmap(dev->mem);
release_mem_region(pci_resource_start(dev->pci,0), pci_resource_len(dev->pci,0));
diff --git a/linux/drivers/media/common/saa7146_fops.c b/linux/drivers/media/common/saa7146_fops.c
index 0284b1327..b428043bd 100644
--- a/linux/drivers/media/common/saa7146_fops.c
+++ b/linux/drivers/media/common/saa7146_fops.c
@@ -107,7 +107,7 @@ void saa7146_buffer_next(struct saa7146_dev *dev,
saa7146_write(dev, PROT_ADDR1, 0);
/* 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 */
saa7146_write(dev, MC1, (MASK_12 | MASK_28));
}
@@ -318,11 +318,11 @@ static ssize_t fops_read(struct file *file, char *data, size_t count, loff_t *pp
switch (fh->type) {
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);
}
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);
}
break;
@@ -389,13 +389,13 @@ int saa7146_vv_init(struct saa7146_dev* dev)
vv->video_minor = -1;
vv->vbi_minor = -1;
- vv->clipping = (u32*)kmalloc(SAA7146_CLIPPING_MEM, GFP_KERNEL);
- if( NULL == vv->clipping ) {
+ vv->d_clipping.cpu_addr = pci_alloc_consistent(dev->pci, SAA7146_CLIPPING_MEM, &vv->d_clipping.dma_handle);
+ if( NULL == vv->d_clipping.cpu_addr ) {
ERR(("out of memory. aborting.\n"));
kfree(vv);
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_vbi_uops.init(dev,vv);
@@ -412,7 +412,7 @@ int saa7146_vv_release(struct saa7146_dev* dev)
DEB_EE(("dev:%p\n",dev));
- kfree(vv->clipping);
+ pci_free_consistent(dev->pci, SAA7146_RPS_MEM, vv->d_clipping.cpu_addr, vv->d_clipping.dma_handle);
kfree(vv);
dev->vv_data = NULL;
dev->vv_callback = NULL;
diff --git a/linux/drivers/media/common/saa7146_hlp.c b/linux/drivers/media/common/saa7146_hlp.c
index cc7180954..1ba897b6f 100644
--- a/linux/drivers/media/common/saa7146_hlp.c
+++ b/linux/drivers/media/common/saa7146_hlp.c
@@ -356,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_vv *vv = dev->vv_data;
- u32 *clipping = vv->clipping;
+ u32 *clipping = vv->d_clipping.cpu_addr;
int width = fh->ov.win.w.width;
int height = fh->ov.win.w.height;
@@ -465,9 +465,9 @@ void calculate_clipping_registers_rect(struct saa7146_dev *dev, struct saa7146_f
*arbtr_ctrl &= 0xffff00ff;
*arbtr_ctrl |= 0x00001c00;
- vdma2->base_even = virt_to_bus(clipping);
- vdma2->base_odd = virt_to_bus(clipping);
- vdma2->prot_addr = virt_to_bus(clipping)+((sizeof(u32))*(numdwords));
+ vdma2->base_even = vv->d_clipping.dma_handle;
+ vdma2->base_odd = vv->d_clipping.dma_handle;
+ vdma2->prot_addr = vv->d_clipping.dma_handle+((sizeof(u32))*(numdwords));
vdma2->base_page = 0x04;
vdma2->pitch = 0x00;
vdma2->num_line_byte = (0 << 16 | (sizeof(u32))*(numdwords-1) );
@@ -949,6 +949,8 @@ int calculate_video_dma_grab_planar(struct saa7146_dev* dev, struct saa7146_buf
return 0;
}
+#define WRITE_RPS0(x) dev->d_rps0.cpu_addr[ count++ ] = cpu_to_le32(x)
+
static
void program_capture_engine(struct saa7146_dev *dev, int planar)
{
@@ -968,54 +970,54 @@ void program_capture_engine(struct saa7146_dev *dev, int planar)
count = 0;
/* 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;
- dev->rps0[ count++ ] = CMD_PAUSE | CMD_OAN | CMD_SIG0 | o_wait;
+ WRITE_RPS0(CMD_PAUSE | CMD_OAN | CMD_SIG0 | e_wait);
+ WRITE_RPS0(CMD_PAUSE | CMD_OAN | CMD_SIG0 | o_wait);
/* set bit 0 */
- dev->rps0[ count++ ] = CMD_WR_REG | (1 << 8) | (MC2/4);
- dev->rps0[ count++ ] = MASK_27 | MASK_11;
+ WRITE_RPS0(CMD_WR_REG | (1 << 8) | (MC2/4));
+ WRITE_RPS0(MASK_27 | MASK_11);
/* turn on video-dma1 */
- dev->rps0[ count++ ] = CMD_WR_REG_MASK | (MC1/4);
- dev->rps0[ count++ ] = MASK_06 | MASK_22; /* => mask */
- dev->rps0[ count++ ] = MASK_06 | MASK_22; /* => values */
+ WRITE_RPS0(CMD_WR_REG_MASK | (MC1/4));
+ WRITE_RPS0(MASK_06 | MASK_22); /* => mask */
+ WRITE_RPS0(MASK_06 | MASK_22); /* => values */
if( 0 != planar ) {
/* turn on video-dma2 */
- dev->rps0[ count++ ] = CMD_WR_REG_MASK | (MC1/4);
- dev->rps0[ count++ ] = MASK_05 | MASK_21; /* => mask */
- dev->rps0[ count++ ] = MASK_05 | MASK_21; /* => values */
+ WRITE_RPS0(CMD_WR_REG_MASK | (MC1/4));
+ WRITE_RPS0(MASK_05 | MASK_21); /* => mask */
+ WRITE_RPS0(MASK_05 | MASK_21); /* => values */
/* turn on video-dma3 */
- dev->rps0[ count++ ] = CMD_WR_REG_MASK | (MC1/4);
- dev->rps0[ count++ ] = MASK_04 | MASK_20; /* => mask */
- dev->rps0[ count++ ] = MASK_04 | MASK_20; /* => values */
+ WRITE_RPS0(CMD_WR_REG_MASK | (MC1/4));
+ WRITE_RPS0(MASK_04 | MASK_20); /* => mask */
+ WRITE_RPS0(MASK_04 | MASK_20); /* => values */
}
/* wait for o_fid_a/b / e_fid_a/b toggle */
- dev->rps0[ count++ ] = CMD_PAUSE | e_wait;
- dev->rps0[ count++ ] = CMD_PAUSE | o_wait;
+ WRITE_RPS0(CMD_PAUSE | e_wait);
+ WRITE_RPS0(CMD_PAUSE | o_wait);
/* turn off video-dma1 */
- dev->rps0[ count++ ] = CMD_WR_REG_MASK | (MC1/4);
- dev->rps0[ count++ ] = MASK_22 | MASK_06; /* => mask */
- dev->rps0[ count++ ] = MASK_22; /* => values */
+ WRITE_RPS0(CMD_WR_REG_MASK | (MC1/4));
+ WRITE_RPS0(MASK_22 | MASK_06); /* => mask */
+ WRITE_RPS0(MASK_22); /* => values */
if( 0 != planar ) {
/* turn off video-dma2 */
- dev->rps0[ count++ ] = CMD_WR_REG_MASK | (MC1/4);
- dev->rps0[ count++ ] = MASK_05 | MASK_21; /* => mask */
- dev->rps0[ count++ ] = MASK_21; /* => values */
+ WRITE_RPS0(CMD_WR_REG_MASK | (MC1/4));
+ WRITE_RPS0(MASK_05 | MASK_21); /* => mask */
+ WRITE_RPS0(MASK_21); /* => values */
/* turn off video-dma3 */
- dev->rps0[ count++ ] = CMD_WR_REG_MASK | (MC1/4);
- dev->rps0[ count++ ] = MASK_04 | MASK_20; /* => mask */
- dev->rps0[ count++ ] = MASK_20; /* => values */
+ WRITE_RPS0(CMD_WR_REG_MASK | (MC1/4));
+ WRITE_RPS0(MASK_04 | MASK_20); /* => mask */
+ WRITE_RPS0(MASK_20); /* => values */
}
/* generate interrupt */
- dev->rps0[ count++ ] = CMD_INTERRUPT;
+ WRITE_RPS0(CMD_INTERRUPT);
/* 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)
@@ -1037,7 +1039,7 @@ void saa7146_set_capture(struct saa7146_dev *dev, struct saa7146_buf *buf, struc
}
/* 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 */
saa7146_write(dev, MC1, (MASK_12 | MASK_28));
diff --git a/linux/drivers/media/common/saa7146_i2c.c b/linux/drivers/media/common/saa7146_i2c.c
index 086774b00..d6b92ac2f 100644
--- a/linux/drivers/media/common/saa7146_i2c.c
+++ b/linux/drivers/media/common/saa7146_i2c.c
@@ -280,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 i = 0, count = 0;
- u32* buffer = dev->i2c_mem;
+ u32* buffer = dev->d_i2c.cpu_addr;
int err = 0;
int address_err = 0;
diff --git a/linux/drivers/media/common/saa7146_vbi.c b/linux/drivers/media/common/saa7146_vbi.c
index 4e3eacb30..f00fd694c 100644
--- a/linux/drivers/media/common/saa7146_vbi.c
+++ b/linux/drivers/media/common/saa7146_vbi.c
@@ -2,6 +2,8 @@
static int vbi_pixel_to_capture = 720 * 2;
+#define WRITE_RPS1(x) dev->d_rps1.cpu_addr[ count++ ] = cpu_to_le32(x)
+
static
int vbi_workaround(struct saa7146_dev *dev)
{
@@ -10,7 +12,7 @@ int vbi_workaround(struct saa7146_dev *dev)
u32 *cpu;
dma_addr_t dma_addr;
- int i, index;
+ int i, count;
DECLARE_WAITQUEUE(wait, current);
@@ -45,43 +47,43 @@ int vbi_workaround(struct saa7146_dev *dev)
saa7146_write(dev, NUM_LINE_BYTE3, (1<<16)|(2<<0));
saa7146_write(dev, MC2, MASK_04|MASK_20);
- index = 0;
+ count = 0;
/* 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 */
- dev->rps1[index++]=0xc000008c;
+ WRITE_RPS1(0xc000008c);
/* wait for vbi_a */
- dev->rps1[index++] = CMD_PAUSE | MASK_10;
+ WRITE_RPS1(CMD_PAUSE | MASK_10);
/* upload brs */
- dev->rps1[index++] = CMD_UPLOAD | MASK_08;
+ WRITE_RPS1(CMD_UPLOAD | MASK_08);
/* 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 */
- 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 */
- dev->rps1[index++] = CMD_PAUSE | MASK_08;
+ WRITE_RPS1(CMD_PAUSE | MASK_08);
/* upload brs */
- dev->rps1[index++] = CMD_UPLOAD | MASK_08;
+ WRITE_RPS1(CMD_UPLOAD | MASK_08);
/* 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->rps1[index++]= (2 << 16) | (vbi_pixel_to_capture);
+ WRITE_RPS1((2 << 16) | (vbi_pixel_to_capture));
/* 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!) */
- dev->rps1[index++] = (540 << 7) | (5 << 19); // 5 == vbi_start
+ WRITE_RPS1((540 << 7) | (5 << 19)); // 5 == vbi_start
/* wait for brs_done */
- dev->rps1[index++] = CMD_PAUSE | MASK_08;
+ WRITE_RPS1(CMD_PAUSE | MASK_08);
/* 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 */
- dev->rps1[index++] = CMD_WR_REG | (1 << 8) | (MC1/4);
- dev->rps1[index++] = MASK_20 | MASK_04;
+ WRITE_RPS1(CMD_WR_REG | (1 << 8) | (MC1/4));
+ WRITE_RPS1(MASK_20 | MASK_04);
/* generate interrupt */
- dev->rps1[index++] = CMD_INTERRUPT;
+ WRITE_RPS1(CMD_INTERRUPT);
/* stop rps1 */
- dev->rps1[index++] = CMD_STOP;
+ WRITE_RPS1(CMD_STOP);
/* enable rps1 irqs */
IER_ENABLE(dev,MASK_28);
@@ -91,7 +93,7 @@ int vbi_workaround(struct saa7146_dev *dev)
current->state = TASK_INTERRUPTIBLE;
/* 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));
schedule();
@@ -160,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... */
/*
- dev->rps1[ count++ ] = 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 | e_wait);
+ WRITE_RPS1(CMD_PAUSE | CMD_OAN | CMD_SIG1 | o_wait);
*/
/* set bit 1 */
- dev->rps1[ count++ ] = CMD_WR_REG | (1 << 8) | (MC2/4);
- dev->rps1[ count++ ] = MASK_28 | MASK_12;
+ WRITE_RPS1(CMD_WR_REG | (1 << 8) | (MC2/4));
+ WRITE_RPS1(MASK_28 | MASK_12);
/* turn on video-dma3 */
- dev->rps1[ count++ ] = CMD_WR_REG_MASK | (MC1/4);
- dev->rps1[ count++ ] = MASK_04 | MASK_20; /* => mask */
- dev->rps1[ count++ ] = MASK_04 | MASK_20; /* => values */
+ WRITE_RPS1(CMD_WR_REG_MASK | (MC1/4));
+ WRITE_RPS1(MASK_04 | MASK_20); /* => mask */
+ WRITE_RPS1(MASK_04 | MASK_20); /* => values */
/* wait for o_fid_a/b / e_fid_a/b toggle */
- dev->rps1[ count++ ] = CMD_PAUSE | o_wait;
- dev->rps1[ count++ ] = CMD_PAUSE | e_wait;
+ WRITE_RPS1(CMD_PAUSE | o_wait);
+ WRITE_RPS1(CMD_PAUSE | e_wait);
/* generate interrupt */
- dev->rps1[ count++ ] = CMD_INTERRUPT;
+ WRITE_RPS1(CMD_INTERRUPT);
/* stop */
- dev->rps1[ count++ ] = CMD_STOP;
+ WRITE_RPS1(CMD_STOP);
/* enable rps1 irqs */
IER_ENABLE(dev, MASK_28);
/* 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 */
saa7146_write(dev, MC1, (MASK_13 | MASK_29));
diff --git a/linux/drivers/media/dvb/ttpci/budget-patch.c b/linux/drivers/media/dvb/ttpci/budget-patch.c
index 1ef2e1022..90ec7afbc 100644
--- a/linux/drivers/media/dvb/ttpci/budget-patch.c
+++ b/linux/drivers/media/dvb/ttpci/budget-patch.c
@@ -194,31 +194,34 @@ int budget_patch_attach (struct saa7146_dev* dev, struct saa7146_pci_extension_d
** (74HCT4040, LVC74) for the generation of this VSYNC signal,
** which seems that can be done perfectly without this :-)).
*/
+
+#define WRITE_RPS1(x) dev->d_rps1.cpu_addr[ cnt++ ] = cpu_to_le32(x)
+
cnt = 0; // Setup RPS1 "program" (p35)
// Wait reset Source Line Counter Threshold (p36)
- dev->rps1[cnt++]=cpu_to_le32(CMD_PAUSE | RPS_INV | EVT_HS);
+ WRITE_RPS1(cpu_to_le32(CMD_PAUSE | RPS_INV | EVT_HS));
// Wait Source Line Counter Threshold (p36)
- dev->rps1[cnt++]=cpu_to_le32(CMD_PAUSE | EVT_HS);
+ WRITE_RPS1(cpu_to_le32(CMD_PAUSE | EVT_HS));
// Set GPIO3=1 (p42)
- dev->rps1[cnt++]=cpu_to_le32(CMD_WR_REG_MASK | (GPIO_CTRL>>2));
- dev->rps1[cnt++]=cpu_to_le32(GPIO3_MSK);
- dev->rps1[cnt++]=cpu_to_le32(SAA7146_GPIO_OUTHI<<24);
+ WRITE_RPS1(cpu_to_le32(CMD_WR_REG_MASK | (GPIO_CTRL>>2)));
+ WRITE_RPS1(cpu_to_le32(GPIO3_MSK));
+ WRITE_RPS1(cpu_to_le32(SAA7146_GPIO_OUTHI<<24));
// Wait reset Source Line Counter Threshold (p36)
- dev->rps1[cnt++]=cpu_to_le32(CMD_PAUSE | RPS_INV | EVT_HS);
+ WRITE_RPS1(cpu_to_le32(CMD_PAUSE | RPS_INV | EVT_HS));
// Wait Source Line Counter Threshold
- dev->rps1[cnt++]=cpu_to_le32(CMD_PAUSE | EVT_HS);
+ WRITE_RPS1(cpu_to_le32(CMD_PAUSE | EVT_HS));
// Set GPIO3=0 (p42)
- dev->rps1[cnt++]=cpu_to_le32(CMD_WR_REG_MASK | (GPIO_CTRL>>2));
- dev->rps1[cnt++]=cpu_to_le32(GPIO3_MSK);
- dev->rps1[cnt++]=cpu_to_le32(SAA7146_GPIO_OUTLO<<24);
+ WRITE_RPS1(cpu_to_le32(CMD_WR_REG_MASK | (GPIO_CTRL>>2)));
+ WRITE_RPS1(cpu_to_le32(GPIO3_MSK));
+ WRITE_RPS1(cpu_to_le32(SAA7146_GPIO_OUTLO<<24));
// Jump to begin of RPS program (p37)
- dev->rps1[cnt++]=cpu_to_le32(CMD_JUMP);
- dev->rps1[cnt++]=cpu_to_le32(virt_to_bus(&dev->rps1[0]));
+ WRITE_RPS1(cpu_to_le32(CMD_JUMP));
+ WRITE_RPS1(cpu_to_le32(dev->d_rps1.dma_handle));
// Fix VSYNC level
saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
// Set RPS1 Address register to point to RPS code (r108 p42)
- saa7146_write(dev, RPS_ADDR1, virt_to_bus(&dev->rps1[0]));
+ saa7146_write(dev, RPS_ADDR1, dev->d_rps1.dma_handle);
// Set Source Line Counter Threshold, using BRS (rCC p43)
saa7146_write(dev, RPS_THRESH1, ((TS_HEIGHT/2) | MASK_12));
// Enable RPS1 (rFC p33)
diff --git a/linux/include/media/saa7146.h b/linux/include/media/saa7146.h
index c369bd0b9..a7c52fdfd 100644
--- a/linux/include/media/saa7146.h
+++ b/linux/include/media/saa7146.h
@@ -12,6 +12,8 @@
#include <linux/i2c.h> /* for i2c subsystem */
#include <asm/io.h> /* for accessing devices */
#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)
@@ -104,6 +106,12 @@ struct saa7146_extension
void (*irq_func)(struct saa7146_dev*, u32* irq_mask);
};
+struct saa7146_dma
+{
+ dma_addr_t dma_handle;
+ u32 *cpu_addr;
+};
+
struct saa7146_dev
{
struct module *module;
@@ -134,13 +142,13 @@ struct saa7146_dev
/* i2c-stuff */
struct semaphore i2c_lock;
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;
int i2c_op;
/* memories */
- u32 *rps0;
- u32 *rps1;
+ struct saa7146_dma d_rps0;
+ struct saa7146_dma d_rps1;
};
/* from saa7146_i2c.c */
diff --git a/linux/include/media/saa7146_vv.h b/linux/include/media/saa7146_vv.h
index f45c32a4c..3534ac56c 100644
--- a/linux/include/media/saa7146_vv.h
+++ b/linux/include/media/saa7146_vv.h
@@ -126,7 +126,7 @@ struct saa7146_vv
int current_hps_source;
int current_hps_sync;
- u32 *clipping; /* pointer to clipping memory */
+ struct saa7146_dma d_clipping; /* pointer to clipping memory */
};
#define SAA7146_EXCLUSIVE 0x1