Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 114085
b: refs/heads/master
c: c777549
h: refs/heads/master
i:
  114083: 4f6243e
v: v3
  • Loading branch information
Ian Armstrong authored and Mauro Carvalho Chehab committed Oct 13, 2008
1 parent 1ff2b19 commit c890607
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 40 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a8b864354e060dda1000e62d1fea7c1274581caf
refs/heads/master: c777549fc9c5c704707394b0235a9a6794247b83
76 changes: 37 additions & 39 deletions trunk/drivers/media/video/ivtv/ivtvfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ static int ivtvfb_prep_dec_dma_to_device(struct ivtv *itv,
int size_in_bytes)
{
DEFINE_WAIT(wait);
int ret = 0;
int got_sig = 0;

mutex_lock(&itv->udma.lock);
Expand Down Expand Up @@ -316,7 +315,7 @@ static int ivtvfb_prep_dec_dma_to_device(struct ivtv *itv,
return -EINTR;
}

return ret;
return 0;
}

static int ivtvfb_prep_frame(struct ivtv *itv, int cmd, void __user *source,
Expand Down Expand Up @@ -373,6 +372,7 @@ static ssize_t ivtvfb_write(struct fb_info *info, const char __user *buf,
unsigned long p = *ppos;
void *dst;
int err = 0;
int dma_err;
unsigned long total_size;
struct ivtv *itv = (struct ivtv *) info->par;
unsigned long dma_offset =
Expand All @@ -399,7 +399,6 @@ static ssize_t ivtvfb_write(struct fb_info *info, const char __user *buf,
if (count + p > total_size) {
if (!err)
err = -ENOSPC;

count = total_size - p;
}

Expand All @@ -408,39 +407,34 @@ static ssize_t ivtvfb_write(struct fb_info *info, const char __user *buf,
if (info->fbops->fb_sync)
info->fbops->fb_sync(info);

if (!access_ok(VERIFY_READ, buf, count)) {
IVTVFB_WARN("Invalid userspace pointer 0x%08lx\n",
(unsigned long)buf);
err = -EFAULT;
}

if (!err) {
/* If transfer size > threshold and both src/dst
addresses are aligned, use DMA */
if (count >= 4096 &&
((unsigned long)buf & 3) == ((unsigned long)dst & 3)) {
/* Odd address = can't DMA. Align */
if ((unsigned long)dst & 3) {
lead = 4 - ((unsigned long)dst & 3);
memcpy(dst, buf, lead);
buf += lead;
dst += lead;
}
/* DMA resolution is 32 bits */
if ((count - lead) & 3)
tail = (count - lead) & 3;
/* DMA the data */
dma_size = count - lead - tail;
err = ivtvfb_prep_dec_dma_to_device(itv,
p + lead + dma_offset, (void *)buf, dma_size);
dst += dma_size;
buf += dma_size;
/* Copy any leftover data */
if (tail)
memcpy(dst, buf, tail);
} else {
memcpy(dst, buf, count);
/* If transfer size > threshold and both src/dst
addresses are aligned, use DMA */
if (count >= 4096 &&
((unsigned long)buf & 3) == ((unsigned long)dst & 3)) {
/* Odd address = can't DMA. Align */
if ((unsigned long)dst & 3) {
lead = 4 - ((unsigned long)dst & 3);
if (copy_from_user(dst, buf, lead))
return -EFAULT;
buf += lead;
dst += lead;
}
/* DMA resolution is 32 bits */
if ((count - lead) & 3)
tail = (count - lead) & 3;
/* DMA the data */
dma_size = count - lead - tail;
dma_err = ivtvfb_prep_dec_dma_to_device(itv,
p + lead + dma_offset, (void __user *)buf, dma_size);
if (dma_err)
return dma_err;
dst += dma_size;
buf += dma_size;
/* Copy any leftover data */
if (tail && copy_from_user(dst, buf, tail))
return -EFAULT;
} else if (copy_from_user(dst, buf, count)) {
return -EFAULT;
}

if (!err)
Expand All @@ -463,9 +457,12 @@ static int ivtvfb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long ar
vblank.flags = FB_VBLANK_HAVE_COUNT |FB_VBLANK_HAVE_VCOUNT |
FB_VBLANK_HAVE_VSYNC;
trace = read_reg(0x028c0) >> 16;
if (itv->is_50hz && trace > 312) trace -= 312;
else if (itv->is_60hz && trace > 262) trace -= 262;
if (trace == 1) vblank.flags |= FB_VBLANK_VSYNCING;
if (itv->is_50hz && trace > 312)
trace -= 312;
else if (itv->is_60hz && trace > 262)
trace -= 262;
if (trace == 1)
vblank.flags |= FB_VBLANK_VSYNCING;
vblank.count = itv->last_vsync_field;
vblank.vcount = trace;
vblank.hcount = 0;
Expand All @@ -476,7 +473,8 @@ static int ivtvfb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long ar

case FBIO_WAITFORVSYNC:
prepare_to_wait(&itv->vsync_waitq, &wait, TASK_INTERRUPTIBLE);
if (!schedule_timeout(msecs_to_jiffies(50))) rc = -ETIMEDOUT;
if (!schedule_timeout(msecs_to_jiffies(50)))
rc = -ETIMEDOUT;
finish_wait(&itv->vsync_waitq, &wait);
return rc;

Expand Down

0 comments on commit c890607

Please sign in to comment.