aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/em28xx/em28xx-video.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2008-04-13 14:11:08 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-04-24 13:09:39 -0400
commit44dc733cd9edac53402d705cd2f720accd0b3e2c (patch)
tree256c0a7a30b4bed9cbf0c6b5ee809b6905603317 /drivers/media/video/em28xx/em28xx-video.c
parent59d3448995a4c0ca98cbe82f6dac9460323377c1 (diff)
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>
Diffstat (limited to 'drivers/media/video/em28xx/em28xx-video.c')
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c43
1 files changed, 11 insertions, 32 deletions
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index f8bbf397d3a7..6084f8452b2b 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,
154{ 154{
155 void *fieldstart, *startwrite, *startread; 155 void *fieldstart, *startwrite, *startread;
156 int linesdone, currlinedone, offset, lencopy, remain; 156 int linesdone, currlinedone, offset, lencopy, remain;
157 157 int bytesperline = dev->width << 1;
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 }
163 158
164 if (dma_q->pos + len > buf->vb.size) 159 if (dma_q->pos + len > buf->vb.size)
165 len = buf->vb.size - dma_q->pos; 160 len = buf->vb.size - dma_q->pos;
@@ -177,13 +172,13 @@ static void em28xx_copy_video(struct em28xx *dev,
177 if (buf->top_field) 172 if (buf->top_field)
178 fieldstart = outp; 173 fieldstart = outp;
179 else 174 else
180 fieldstart = outp + dev->bytesperline; 175 fieldstart = outp + bytesperline;
181 176
182 linesdone = dma_q->pos / dev->bytesperline; 177 linesdone = dma_q->pos / bytesperline;
183 currlinedone = dma_q->pos % dev->bytesperline; 178 currlinedone = dma_q->pos % bytesperline;
184 offset = linesdone * dev->bytesperline * 2 + currlinedone; 179 offset = linesdone * bytesperline * 2 + currlinedone;
185 startwrite = fieldstart + offset; 180 startwrite = fieldstart + offset;
186 lencopy = dev->bytesperline - currlinedone; 181 lencopy = bytesperline - currlinedone;
187 lencopy = lencopy > remain ? remain : lencopy; 182 lencopy = lencopy > remain ? remain : lencopy;
188 183
189 if ((char *)startwrite + lencopy > (char *)outp + buf->vb.size) { 184 if ((char *)startwrite + lencopy > (char *)outp + buf->vb.size) {
@@ -199,12 +194,12 @@ static void em28xx_copy_video(struct em28xx *dev,
199 remain -= lencopy; 194 remain -= lencopy;
200 195
201 while (remain > 0) { 196 while (remain > 0) {
202 startwrite += lencopy + dev->bytesperline; 197 startwrite += lencopy + bytesperline;
203 startread += lencopy; 198 startread += lencopy;
204 if (dev->bytesperline > remain) 199 if (bytesperline > remain)
205 lencopy = remain; 200 lencopy = remain;
206 else 201 else
207 lencopy = dev->bytesperline; 202 lencopy = bytesperline;
208 203
209 if ((char *)startwrite + lencopy > (char *)outp + buf->vb.size) { 204 if ((char *)startwrite + lencopy > (char *)outp + buf->vb.size) {
210 em28xx_isocdbg("Overflow of %zi bytes past buffer end (2)\n", 205 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,
617 struct em28xx_dmaqueue *vidq = &dev->vidq; 612 struct em28xx_dmaqueue *vidq = &dev->vidq;
618 int rc = 0, urb_init = 0; 613 int rc = 0, urb_init = 0;
619 614
620 /* BUG_ON(NULL == fh->fmt); */
621
622 /* FIXME: It assumes depth = 16 */ 615 /* FIXME: It assumes depth = 16 */
623 /* The only currently supported format is 16 bits/pixel */ 616 /* The only currently supported format is 16 bits/pixel */
624 buf->vb.size = 16 * dev->width * dev->height >> 3; 617 buf->vb.size = 16 * dev->width * dev->height >> 3;
@@ -626,7 +619,6 @@ buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
626 if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) 619 if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size)
627 return -EINVAL; 620 return -EINVAL;
628 621
629 buf->fmt = fh->fmt;
630 buf->vb.width = dev->width; 622 buf->vb.width = dev->width;
631 buf->vb.height = dev->height; 623 buf->vb.height = dev->height;
632 buf->vb.field = field; 624 buf->vb.field = field;
@@ -877,8 +869,8 @@ static int vidioc_g_fmt_cap(struct file *file, void *priv,
877 f->fmt.pix.width = dev->width; 869 f->fmt.pix.width = dev->width;
878 f->fmt.pix.height = dev->height; 870 f->fmt.pix.height = dev->height;
879 f->fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV; 871 f->fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
880 f->fmt.pix.bytesperline = dev->bytesperline; 872 f->fmt.pix.bytesperline = dev->width * 2;
881 f->fmt.pix.sizeimage = dev->frame_size; 873 f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * dev->height;
882 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 874 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
883 875
884 /* FIXME: TOP? NONE? BOTTOM? ALTENATE? */ 876 /* FIXME: TOP? NONE? BOTTOM? ALTENATE? */
@@ -979,9 +971,6 @@ static int vidioc_s_fmt_cap(struct file *file, void *priv,
979 /* set new image size */ 971 /* set new image size */
980 dev->width = f->fmt.pix.width; 972 dev->width = f->fmt.pix.width;
981 dev->height = f->fmt.pix.height; 973 dev->height = f->fmt.pix.height;
982 dev->frame_size = dev->width * dev->height * 2;
983 dev->field_size = dev->frame_size >> 1;
984 dev->bytesperline = dev->width * 2;
985 get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale); 974 get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale);
986 975
987 em28xx_set_alternate(dev); 976 em28xx_set_alternate(dev);
@@ -1019,9 +1008,6 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *norm)
1019 /* set new image size */ 1008 /* set new image size */
1020 dev->width = f.fmt.pix.width; 1009 dev->width = f.fmt.pix.width;
1021 dev->height = f.fmt.pix.height; 1010 dev->height = f.fmt.pix.height;
1022 dev->frame_size = dev->width * dev->height * 2;
1023 dev->field_size = dev->frame_size >> 1;
1024 dev->bytesperline = dev->width * 2;
1025 get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale); 1011 get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale);
1026 1012
1027 em28xx_resolution_set(dev); 1013 em28xx_resolution_set(dev);
@@ -1736,9 +1722,6 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
1736 if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && dev->users == 0) { 1722 if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && dev->users == 0) {
1737 dev->width = norm_maxw(dev); 1723 dev->width = norm_maxw(dev);
1738 dev->height = norm_maxh(dev); 1724 dev->height = norm_maxh(dev);
1739 dev->frame_size = dev->width * dev->height * 2;
1740 dev->field_size = dev->frame_size >> 1; /*both_fileds ? dev->frame_size>>1 : dev->frame_size; */
1741 dev->bytesperline = dev->width * 2;
1742 dev->hscale = 0; 1725 dev->hscale = 0;
1743 dev->vscale = 0; 1726 dev->vscale = 0;
1744 1727
@@ -2152,10 +2135,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
2152 dev->width = maxw; 2135 dev->width = maxw;
2153 dev->height = maxh; 2136 dev->height = maxh;
2154 dev->interlaced = EM28XX_INTERLACED_DEFAULT; 2137 dev->interlaced = EM28XX_INTERLACED_DEFAULT;
2155 dev->field_size = dev->width * dev->height;
2156 dev->frame_size =
2157 dev->interlaced ? dev->field_size << 1 : dev->field_size;
2158 dev->bytesperline = dev->width * 2;
2159 dev->hscale = 0; 2138 dev->hscale = 0;
2160 dev->vscale = 0; 2139 dev->vscale = 0;
2161 dev->ctl_input = 2; 2140 dev->ctl_input = 2;