Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 357151
b: refs/heads/master
c: a483701
h: refs/heads/master
i:
  357149: 4849a6b
  357147: c4cb9d7
  357143: 0dca83e
  357135: ab34d3b
  357119: 23e2d64
v: v3
  • Loading branch information
Frank Schaefer authored and Mauro Carvalho Chehab committed Dec 22, 2012
1 parent f905f78 commit 8f299f2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 42 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8732533b3284ca078e3ea4a4721e43627ff7fa8e
refs/heads/master: a48370158d134807f5b02655287b91cc000c45ca
77 changes: 36 additions & 41 deletions trunk/drivers/media/usb/em28xx/em28xx-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,9 @@ static inline int em28xx_urb_data_copy(struct em28xx *dev, struct urb *urb)
}

/* capture type 0 = vbi start
capture type 1 = video start
capture type 2 = video in progress */
capture type 1 = vbi in progress
capture type 2 = video start
capture type 3 = video in progress */
len = actual_length;
if (len >= 4) {
/* NOTE: headers are always 4 bytes and
Expand All @@ -438,7 +439,7 @@ static inline int em28xx_urb_data_copy(struct em28xx *dev, struct urb *urb)
len -= 4;
} else if (p[0] == 0x22 && p[1] == 0x5a) {
/* start video */
dev->capture_type = 1;
dev->capture_type = 2;
dev->top_field = !(p[2] & 1);
p += 4;
len -= 4;
Expand All @@ -448,51 +449,45 @@ static inline int em28xx_urb_data_copy(struct em28xx *dev, struct urb *urb)
* have no continuation header */

if (dev->capture_type == 0) {
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)
vbioutp = NULL;
else
vbioutp =
videobuf_to_vmalloc(&vbi_buf->vb);
}
if (vbi_buf != NULL) {
vbi_buf->top_field = dev->top_field;
vbi_buf->pos = 0;
}
}

if (dev->capture_type == 1) {
int vbi_size = dev->vbi_width * dev->vbi_height;
if (dev->vbi_read >= vbi_size) {
/* We've already read all the VBI data, so
treat the rest as video */
em28xx_isocdbg("dev->vbi_read > vbi_size\n");
} else if ((dev->vbi_read + len) < vbi_size) {
/* This entire frame is VBI data */
if (dev->vbi_read == 0 && 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)
vbioutp = NULL;
else
vbioutp = videobuf_to_vmalloc(
&vbi_buf->vb);
}

if (dev->vbi_read == 0) {
if (vbi_buf != NULL) {
vbi_buf->top_field
= dev->top_field;
vbi_buf->pos = 0;
}
}

dev->vbi_read += len;
em28xx_copy_vbi(dev, vbi_buf, p, vbioutp, len);
} else {
/* Some of this frame is VBI data and some is
video data */
int vbi_data_len = vbi_size - dev->vbi_read;
dev->vbi_read += vbi_data_len;
int vbi_data_len = ((dev->vbi_read + len) > vbi_size) ?
(vbi_size - dev->vbi_read) : len;

/* Copy VBI data */
if (vbi_buf != NULL)
em28xx_copy_vbi(dev, vbi_buf, p, vbioutp,
vbi_data_len);
dev->capture_type = 1;
dev->vbi_read += vbi_data_len;

if (vbi_data_len < len) {
/* Continue with copying video data */
dev->capture_type = 2;
p += vbi_data_len;
len -= vbi_data_len;
}
}

if (dev->capture_type == 1) {
dev->capture_type = 2;
if (dev->capture_type == 2) {
dev->capture_type = 3;
if (dev->progressive || dev->top_field) {
if (buf != NULL)
finish_buffer(dev, buf);
Expand All @@ -509,7 +504,7 @@ static inline int em28xx_urb_data_copy(struct em28xx *dev, struct urb *urb)
}
}

if (buf != NULL && dev->capture_type == 2 && len > 0)
if (buf != NULL && dev->capture_type == 3 && len > 0)
em28xx_copy_video(dev, buf, p, outp, len);
}
return rc;
Expand Down

0 comments on commit 8f299f2

Please sign in to comment.