summaryrefslogtreecommitdiff
path: root/drivers/media/usb/em28xx
diff options
context:
space:
mode:
authorFrank Schaefer <fschaefer.oss@googlemail.com>2012-12-08 14:31:30 (GMT)
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-12-22 22:55:48 (GMT)
commite04c00d985c62a6e1cc6c8048308f3216442f708 (patch)
tree1051d039bc94453b68e9e5fe9307a2c552781362 /drivers/media/usb/em28xx
parent4078d625c9610a362f571f7e5ff2521adadfff2b (diff)
downloadlinux-fsl-qoriq-e04c00d985c62a6e1cc6c8048308f3216442f708.tar.xz
[media] em28xx: em28xx_urb_data_copy(): move duplicate code for capture_type=0 and capture_type=2 to a function
Reduce code duplication by moving the duplicate code for dev->capture_type=0 (vbi start) and dev->capture_type=2 (video start) to a function. The same function will also be called by the (not yet existing) em25xx frame data processing code. Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/usb/em28xx')
-rw-r--r--drivers/media/usb/em28xx/em28xx-video.c45
1 files changed, 25 insertions, 20 deletions
diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
index da59442..a1f6de0 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -358,6 +358,27 @@ static inline struct em28xx_buffer *get_next_buf(struct em28xx *dev,
return buf;
}
+/*
+ * Finish the current buffer if completed and prepare for the next field
+ */
+static struct em28xx_buffer *
+finish_field_prepare_next(struct em28xx *dev,
+ struct em28xx_buffer *buf,
+ struct em28xx_dmaqueue *dma_q)
+{
+ if (dev->progressive || dev->top_field) { /* Brand new frame */
+ if (buf != NULL)
+ finish_buffer(dev, buf);
+ buf = get_next_buf(dev, dma_q);
+ }
+ if (buf != NULL) {
+ buf->top_field = dev->top_field;
+ buf->pos = 0;
+ }
+
+ return buf;
+}
+
/* Processes and copies the URB data content (video and VBI data) */
static inline int em28xx_urb_data_copy(struct em28xx *dev, struct urb *urb)
{
@@ -448,17 +469,9 @@ static inline int em28xx_urb_data_copy(struct em28xx *dev, struct urb *urb)
* have no continuation header */
if (dev->capture_type == 0) {
+ vbi_buf = finish_field_prepare_next(dev, vbi_buf, vbi_dma_q);
+ dev->usb_ctl.vbi_buf = vbi_buf;
dev->capture_type = 1;
- if (dev->top_field) { /* Brand new frame */
- if (vbi_buf != NULL)
- finish_buffer(dev, vbi_buf);
- vbi_buf = get_next_buf(dev, vbi_dma_q);
- dev->usb_ctl.vbi_buf = vbi_buf;
- }
- if (vbi_buf != NULL) {
- vbi_buf->top_field = dev->top_field;
- vbi_buf->pos = 0;
- }
}
if (dev->capture_type == 1) {
@@ -480,17 +493,9 @@ static inline int em28xx_urb_data_copy(struct em28xx *dev, struct urb *urb)
}
if (dev->capture_type == 2) {
+ buf = finish_field_prepare_next(dev, buf, dma_q);
+ dev->usb_ctl.vid_buf = buf;
dev->capture_type = 3;
- if (dev->progressive || dev->top_field) {
- if (buf != NULL)
- finish_buffer(dev, buf);
- buf = get_next_buf(dev, dma_q);
- dev->usb_ctl.vid_buf = buf;
- }
- if (buf != NULL) {
- buf->top_field = dev->top_field;
- buf->pos = 0;
- }
}
if (buf != NULL && dev->capture_type == 3 && len > 0)