diff options
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/em28xx/em28xx-core.c | 4 | ||||
-rw-r--r-- | drivers/media/video/em28xx/em28xx-video.c | 43 | ||||
-rw-r--r-- | 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 95bc18d0e780..97635abb916e 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) | |||
396 | { | 396 | { |
397 | int errCode, prev_alt = dev->alt; | 397 | int errCode, prev_alt = dev->alt; |
398 | int i; | 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 | /* When image size is bigger than a certain value, | 401 | /* When image size is bigger than a certain value, |
402 | the frame size should be increased, otherwise, only | 402 | the frame size should be increased, otherwise, only |
403 | green screen will be received. | 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 | min_pkt_size *= 2; | 406 | min_pkt_size *= 2; |
407 | 407 | ||
408 | for (i = 0; i < dev->num_alt; i++) { | 408 | 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 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; |
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h index 6d62357a038f..0080a09860d9 100644 --- a/drivers/media/video/em28xx/em28xx.h +++ b/drivers/media/video/em28xx/em28xx.h | |||
@@ -128,8 +128,6 @@ struct em28xx_buffer { | |||
128 | /* common v4l buffer stuff -- must be first */ | 128 | /* common v4l buffer stuff -- must be first */ |
129 | struct videobuf_buffer vb; | 129 | struct videobuf_buffer vb; |
130 | 130 | ||
131 | struct em28xx_fmt *fmt; | ||
132 | |||
133 | struct list_head frame; | 131 | struct list_head frame; |
134 | int top_field; | 132 | int top_field; |
135 | int receiving; | 133 | int receiving; |
@@ -294,9 +292,6 @@ struct em28xx { | |||
294 | /* frame properties */ | 292 | /* frame properties */ |
295 | int width; /* current frame width */ | 293 | int width; /* current frame width */ |
296 | int height; /* current frame height */ | 294 | int height; /* current frame height */ |
297 | int frame_size; /* current frame size */ | ||
298 | int field_size; /* current field size */ | ||
299 | int bytesperline; | ||
300 | int hscale; /* horizontal scale factor (see datasheet) */ | 295 | int hscale; /* horizontal scale factor (see datasheet) */ |
301 | int vscale; /* vertical scale factor (see datasheet) */ | 296 | int vscale; /* vertical scale factor (see datasheet) */ |
302 | int interlaced; /* 1=interlace fileds, 0=just top fileds */ | 297 | int interlaced; /* 1=interlace fileds, 0=just top fileds */ |
@@ -352,9 +347,7 @@ struct em28xx_fh { | |||
352 | unsigned int stream_on:1; /* Locks streams */ | 347 | unsigned int stream_on:1; /* Locks streams */ |
353 | int radio; | 348 | int radio; |
354 | 349 | ||
355 | unsigned int width, height; | ||
356 | struct videobuf_queue vb_vidq; | 350 | struct videobuf_queue vb_vidq; |
357 | struct em28xx_fmt *fmt; | ||
358 | 351 | ||
359 | enum v4l2_buf_type type; | 352 | enum v4l2_buf_type type; |
360 | }; | 353 | }; |