Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <mchehab@infradead.org>

+13 -41
+2 -2
drivers/media/video/em28xx/em28xx-core.c
··· 396 396 { 397 397 int errCode, prev_alt = dev->alt; 398 398 int i; 399 - unsigned int min_pkt_size = dev->bytesperline + 4; 399 + unsigned int min_pkt_size = dev->width * 2 + 4; 400 400 401 401 /* When image size is bigger than a certain value, 402 402 the frame size should be increased, otherwise, only 403 403 green screen will be received. 404 404 */ 405 - if (dev->frame_size > 720*240*2) 405 + if (dev->width * 2 * dev->height > 720 * 240 * 2) 406 406 min_pkt_size *= 2; 407 407 408 408 for (i = 0; i < dev->num_alt; i++) {
+11 -32
drivers/media/video/em28xx/em28xx-video.c
··· 154 154 { 155 155 void *fieldstart, *startwrite, *startread; 156 156 int linesdone, currlinedone, offset, lencopy, remain; 157 - 158 - if (dev->frame_size != buf->vb.size) { 159 - em28xx_errdev("size %i and buf.length %lu are different!\n", 160 - dev->frame_size, buf->vb.size); 161 - return; 162 - } 157 + int bytesperline = dev->width << 1; 163 158 164 159 if (dma_q->pos + len > buf->vb.size) 165 160 len = buf->vb.size - dma_q->pos; ··· 172 177 if (buf->top_field) 173 178 fieldstart = outp; 174 179 else 175 - fieldstart = outp + dev->bytesperline; 180 + fieldstart = outp + bytesperline; 176 181 177 - linesdone = dma_q->pos / dev->bytesperline; 178 - currlinedone = dma_q->pos % dev->bytesperline; 179 - offset = linesdone * dev->bytesperline * 2 + currlinedone; 182 + linesdone = dma_q->pos / bytesperline; 183 + currlinedone = dma_q->pos % bytesperline; 184 + offset = linesdone * bytesperline * 2 + currlinedone; 180 185 startwrite = fieldstart + offset; 181 - lencopy = dev->bytesperline - currlinedone; 186 + lencopy = bytesperline - currlinedone; 182 187 lencopy = lencopy > remain ? remain : lencopy; 183 188 184 189 if ((char *)startwrite + lencopy > (char *)outp + buf->vb.size) { ··· 194 199 remain -= lencopy; 195 200 196 201 while (remain > 0) { 197 - startwrite += lencopy + dev->bytesperline; 202 + startwrite += lencopy + bytesperline; 198 203 startread += lencopy; 199 - if (dev->bytesperline > remain) 204 + if (bytesperline > remain) 200 205 lencopy = remain; 201 206 else 202 - lencopy = dev->bytesperline; 207 + lencopy = bytesperline; 203 208 204 209 if ((char *)startwrite + lencopy > (char *)outp + buf->vb.size) { 205 210 em28xx_isocdbg("Overflow of %zi bytes past buffer end (2)\n", ··· 612 617 struct em28xx_dmaqueue *vidq = &dev->vidq; 613 618 int rc = 0, urb_init = 0; 614 619 615 - /* BUG_ON(NULL == fh->fmt); */ 616 - 617 620 /* FIXME: It assumes depth = 16 */ 618 621 /* The only currently supported format is 16 bits/pixel */ 619 622 buf->vb.size = 16 * dev->width * dev->height >> 3; ··· 619 626 if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) 620 627 return -EINVAL; 621 628 622 - buf->fmt = fh->fmt; 623 629 buf->vb.width = dev->width; 624 630 buf->vb.height = dev->height; 625 631 buf->vb.field = field; ··· 869 877 f->fmt.pix.width = dev->width; 870 878 f->fmt.pix.height = dev->height; 871 879 f->fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV; 872 - f->fmt.pix.bytesperline = dev->bytesperline; 873 - f->fmt.pix.sizeimage = dev->frame_size; 880 + f->fmt.pix.bytesperline = dev->width * 2; 881 + f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * dev->height; 874 882 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 875 883 876 884 /* FIXME: TOP? NONE? BOTTOM? ALTENATE? */ ··· 971 979 /* set new image size */ 972 980 dev->width = f->fmt.pix.width; 973 981 dev->height = f->fmt.pix.height; 974 - dev->frame_size = dev->width * dev->height * 2; 975 - dev->field_size = dev->frame_size >> 1; 976 - dev->bytesperline = dev->width * 2; 977 982 get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale); 978 983 979 984 em28xx_set_alternate(dev); ··· 1008 1019 /* set new image size */ 1009 1020 dev->width = f.fmt.pix.width; 1010 1021 dev->height = f.fmt.pix.height; 1011 - dev->frame_size = dev->width * dev->height * 2; 1012 - dev->field_size = dev->frame_size >> 1; 1013 - dev->bytesperline = dev->width * 2; 1014 1022 get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale); 1015 1023 1016 1024 em28xx_resolution_set(dev); ··· 1722 1736 if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && dev->users == 0) { 1723 1737 dev->width = norm_maxw(dev); 1724 1738 dev->height = norm_maxh(dev); 1725 - dev->frame_size = dev->width * dev->height * 2; 1726 - dev->field_size = dev->frame_size >> 1; /*both_fileds ? dev->frame_size>>1 : dev->frame_size; */ 1727 - dev->bytesperline = dev->width * 2; 1728 1739 dev->hscale = 0; 1729 1740 dev->vscale = 0; 1730 1741 ··· 2135 2152 dev->width = maxw; 2136 2153 dev->height = maxh; 2137 2154 dev->interlaced = EM28XX_INTERLACED_DEFAULT; 2138 - dev->field_size = dev->width * dev->height; 2139 - dev->frame_size = 2140 - dev->interlaced ? dev->field_size << 1 : dev->field_size; 2141 - dev->bytesperline = dev->width * 2; 2142 2155 dev->hscale = 0; 2143 2156 dev->vscale = 0; 2144 2157 dev->ctl_input = 2;
-7
drivers/media/video/em28xx/em28xx.h
··· 128 128 /* common v4l buffer stuff -- must be first */ 129 129 struct videobuf_buffer vb; 130 130 131 - struct em28xx_fmt *fmt; 132 - 133 131 struct list_head frame; 134 132 int top_field; 135 133 int receiving; ··· 292 294 /* frame properties */ 293 295 int width; /* current frame width */ 294 296 int height; /* current frame height */ 295 - int frame_size; /* current frame size */ 296 - int field_size; /* current field size */ 297 - int bytesperline; 298 297 int hscale; /* horizontal scale factor (see datasheet) */ 299 298 int vscale; /* vertical scale factor (see datasheet) */ 300 299 int interlaced; /* 1=interlace fileds, 0=just top fileds */ ··· 347 352 unsigned int stream_on:1; /* Locks streams */ 348 353 int radio; 349 354 350 - unsigned int width, height; 351 355 struct videobuf_queue vb_vidq; 352 - struct em28xx_fmt *fmt; 353 356 354 357 enum v4l2_buf_type type; 355 358 };