From 44dc733cd9edac53402d705cd2f720accd0b3e2c Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 13 Apr 2008 15:11:08 -0300 Subject: [PATCH] V4L/DVB (7567): em28xx: Some cleanups Removes some fields from data structs. There are some fields that are just caching some calculus for buffer size. The calculus were moved to the places it were needed and the now unused fields were removed. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/em28xx/em28xx-core.c | 4 +-- drivers/media/video/em28xx/em28xx-video.c | 43 ++++++----------------- drivers/media/video/em28xx/em28xx.h | 7 ---- 3 files changed, 13 insertions(+), 41 deletions(-) diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c index 95bc18d0e78..97635abb916 100644 --- a/drivers/media/video/em28xx/em28xx-core.c +++ b/drivers/media/video/em28xx/em28xx-core.c @@ -396,13 +396,13 @@ int em28xx_set_alternate(struct em28xx *dev) { int errCode, prev_alt = dev->alt; int i; - unsigned int min_pkt_size = dev->bytesperline + 4; + unsigned int min_pkt_size = dev->width * 2 + 4; /* When image size is bigger than a certain value, the frame size should be increased, otherwise, only green screen will be received. */ - if (dev->frame_size > 720*240*2) + if (dev->width * 2 * dev->height > 720 * 240 * 2) min_pkt_size *= 2; for (i = 0; i < dev->num_alt; i++) { diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c index f8bbf397d3a..6084f8452b2 100644 --- a/drivers/media/video/em28xx/em28xx-video.c +++ b/drivers/media/video/em28xx/em28xx-video.c @@ -154,12 +154,7 @@ static void em28xx_copy_video(struct em28xx *dev, { void *fieldstart, *startwrite, *startread; int linesdone, currlinedone, offset, lencopy, remain; - - if (dev->frame_size != buf->vb.size) { - em28xx_errdev("size %i and buf.length %lu are different!\n", - dev->frame_size, buf->vb.size); - return; - } + int bytesperline = dev->width << 1; if (dma_q->pos + len > buf->vb.size) len = buf->vb.size - dma_q->pos; @@ -177,13 +172,13 @@ static void em28xx_copy_video(struct em28xx *dev, if (buf->top_field) fieldstart = outp; else - fieldstart = outp + dev->bytesperline; + fieldstart = outp + bytesperline; - linesdone = dma_q->pos / dev->bytesperline; - currlinedone = dma_q->pos % dev->bytesperline; - offset = linesdone * dev->bytesperline * 2 + currlinedone; + linesdone = dma_q->pos / bytesperline; + currlinedone = dma_q->pos % bytesperline; + offset = linesdone * bytesperline * 2 + currlinedone; startwrite = fieldstart + offset; - lencopy = dev->bytesperline - currlinedone; + lencopy = bytesperline - currlinedone; lencopy = lencopy > remain ? remain : lencopy; if ((char *)startwrite + lencopy > (char *)outp + buf->vb.size) { @@ -199,12 +194,12 @@ static void em28xx_copy_video(struct em28xx *dev, remain -= lencopy; while (remain > 0) { - startwrite += lencopy + dev->bytesperline; + startwrite += lencopy + bytesperline; startread += lencopy; - if (dev->bytesperline > remain) + if (bytesperline > remain) lencopy = remain; else - lencopy = dev->bytesperline; + lencopy = bytesperline; if ((char *)startwrite + lencopy > (char *)outp + buf->vb.size) { em28xx_isocdbg("Overflow of %zi bytes past buffer end (2)\n", @@ -617,8 +612,6 @@ buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb, struct em28xx_dmaqueue *vidq = &dev->vidq; int rc = 0, urb_init = 0; - /* BUG_ON(NULL == fh->fmt); */ - /* FIXME: It assumes depth = 16 */ /* The only currently supported format is 16 bits/pixel */ buf->vb.size = 16 * dev->width * dev->height >> 3; @@ -626,7 +619,6 @@ buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb, if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) return -EINVAL; - buf->fmt = fh->fmt; buf->vb.width = dev->width; buf->vb.height = dev->height; buf->vb.field = field; @@ -877,8 +869,8 @@ static int vidioc_g_fmt_cap(struct file *file, void *priv, f->fmt.pix.width = dev->width; f->fmt.pix.height = dev->height; f->fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV; - f->fmt.pix.bytesperline = dev->bytesperline; - f->fmt.pix.sizeimage = dev->frame_size; + f->fmt.pix.bytesperline = dev->width * 2; + f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * dev->height; f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; /* FIXME: TOP? NONE? BOTTOM? ALTENATE? */ @@ -979,9 +971,6 @@ static int vidioc_s_fmt_cap(struct file *file, void *priv, /* set new image size */ dev->width = f->fmt.pix.width; dev->height = f->fmt.pix.height; - dev->frame_size = dev->width * dev->height * 2; - dev->field_size = dev->frame_size >> 1; - dev->bytesperline = dev->width * 2; get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale); em28xx_set_alternate(dev); @@ -1019,9 +1008,6 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *norm) /* set new image size */ dev->width = f.fmt.pix.width; dev->height = f.fmt.pix.height; - dev->frame_size = dev->width * dev->height * 2; - dev->field_size = dev->frame_size >> 1; - dev->bytesperline = dev->width * 2; get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale); em28xx_resolution_set(dev); @@ -1736,9 +1722,6 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp) if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && dev->users == 0) { dev->width = norm_maxw(dev); dev->height = norm_maxh(dev); - dev->frame_size = dev->width * dev->height * 2; - dev->field_size = dev->frame_size >> 1; /*both_fileds ? dev->frame_size>>1 : dev->frame_size; */ - dev->bytesperline = dev->width * 2; dev->hscale = 0; dev->vscale = 0; @@ -2152,10 +2135,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, dev->width = maxw; dev->height = maxh; dev->interlaced = EM28XX_INTERLACED_DEFAULT; - dev->field_size = dev->width * dev->height; - dev->frame_size = - dev->interlaced ? dev->field_size << 1 : dev->field_size; - dev->bytesperline = dev->width * 2; dev->hscale = 0; dev->vscale = 0; dev->ctl_input = 2; diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h index 6d62357a038..0080a09860d 100644 --- a/drivers/media/video/em28xx/em28xx.h +++ b/drivers/media/video/em28xx/em28xx.h @@ -128,8 +128,6 @@ struct em28xx_buffer { /* common v4l buffer stuff -- must be first */ struct videobuf_buffer vb; - struct em28xx_fmt *fmt; - struct list_head frame; int top_field; int receiving; @@ -294,9 +292,6 @@ struct em28xx { /* frame properties */ int width; /* current frame width */ int height; /* current frame height */ - int frame_size; /* current frame size */ - int field_size; /* current field size */ - int bytesperline; int hscale; /* horizontal scale factor (see datasheet) */ int vscale; /* vertical scale factor (see datasheet) */ int interlaced; /* 1=interlace fileds, 0=just top fileds */ @@ -352,9 +347,7 @@ struct em28xx_fh { unsigned int stream_on:1; /* Locks streams */ int radio; - unsigned int width, height; struct videobuf_queue vb_vidq; - struct em28xx_fmt *fmt; enum v4l2_buf_type type; }; -- 2.41.1