From: "Frank Schäfer" <fschaefer.oss@googlemail.com>
To: mchehab@redhat.com
Cc: linux-media@vger.kernel.org,
"Frank Schäfer" <fschaefer.oss@googlemail.com>
Subject: [PATCH 4/6] em28xx: fix/improve frame field handling in em28xx_urb_data_copy_vbi()
Date: Sun, 25 Nov 2012 11:37:35 +0100 [thread overview]
Message-ID: <1353839857-2990-5-git-send-email-fschaefer.oss@googlemail.com> (raw)
In-Reply-To: <1353839857-2990-1-git-send-email-fschaefer.oss@googlemail.com>
The current code doesn't set the frame field when a normal video header is
received. This bug didn't cause any trouble, because this type of header is
never received in vbi mode.
Fix it, because we want to use this function with disabled vbi in the future.
Also simplifiy the code.
Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
---
drivers/media/usb/em28xx/em28xx-video.c | 24 ++++++++----------------
drivers/media/usb/em28xx/em28xx.h | 2 +-
2 Dateien geändert, 9 Zeilen hinzugefügt(+), 17 Zeilen entfernt(-)
diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
index b170476..12e4b0a 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -593,7 +593,7 @@ static inline int em28xx_urb_data_copy_vbi(struct em28xx *dev, struct urb *urb)
dev->capture_type = 0;
dev->vbi_read = 0;
em28xx_usbdbg("VBI START HEADER!!!\n");
- dev->cur_field = p[2];
+ dev->top_field = !(p[2] & 1);
p += 4;
len -= 4;
} else if (p[0] == 0x88 && p[1] == 0x88 &&
@@ -604,6 +604,7 @@ static inline int em28xx_urb_data_copy_vbi(struct em28xx *dev, struct urb *urb)
} else if (p[0] == 0x22 && p[1] == 0x5a) {
/* start video */
dev->capture_type = 1;
+ dev->top_field = !(p[2] & 1);
p += 4;
len -= 4;
}
@@ -620,8 +621,7 @@ static inline int em28xx_urb_data_copy_vbi(struct em28xx *dev, struct urb *urb)
em28xx_usbdbg("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->cur_field & 1))) {
+ if (dev->vbi_read == 0 && dev->top_field) {
/* Brand new frame */
if (vbi_buf != NULL)
vbi_buffer_filled(dev,
@@ -637,12 +637,8 @@ static inline int em28xx_urb_data_copy_vbi(struct em28xx *dev, struct urb *urb)
if (dev->vbi_read == 0) {
vbi_dma_q->pos = 0;
- if (vbi_buf != NULL) {
- if (dev->cur_field & 1)
- vbi_buf->top_field = 0;
- else
- vbi_buf->top_field = 1;
- }
+ if (vbi_buf != NULL)
+ vbi_buf->top_field = dev->top_field;
}
dev->vbi_read += len;
@@ -663,7 +659,7 @@ static inline int em28xx_urb_data_copy_vbi(struct em28xx *dev, struct urb *urb)
if (dev->capture_type == 1) {
dev->capture_type = 2;
- if (dev->progressive || !(dev->cur_field & 1)) {
+ if (dev->progressive || dev->top_field) {
if (buf != NULL)
buffer_filled(dev, dma_q, buf);
get_next_buf(dma_q, &buf);
@@ -672,12 +668,8 @@ static inline int em28xx_urb_data_copy_vbi(struct em28xx *dev, struct urb *urb)
else
outp = videobuf_to_vmalloc(&buf->vb);
}
- if (buf != NULL) {
- if (dev->cur_field & 1)
- buf->top_field = 0;
- else
- buf->top_field = 1;
- }
+ if (buf != NULL)
+ buf->top_field = dev->top_field;
dma_q->pos = 0;
}
diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h
index aa413bd..09df56a 100644
--- a/drivers/media/usb/em28xx/em28xx.h
+++ b/drivers/media/usb/em28xx/em28xx.h
@@ -563,7 +563,7 @@ struct em28xx {
/* vbi related state tracking */
int capture_type;
int vbi_read;
- unsigned char cur_field;
+ unsigned char top_field:1;
unsigned int vbi_width;
unsigned int vbi_height; /* lines per field */
--
1.7.10.4
next prev parent reply other threads:[~2012-11-25 10:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-25 10:37 [PATCH 0/6] em28xx: use common urb data copying function for vbi and non-vbi data streams Frank Schäfer
2012-11-25 10:37 ` [PATCH 1/6] em28xx: fix video data start position calculation in em28xx_urb_data_copy_vbi() Frank Schäfer
2012-11-25 10:37 ` [PATCH 2/6] em28xx: make sure the packet size is >= 4 before checking for headers " Frank Schäfer
2012-11-25 10:37 ` [PATCH 3/6] em28xx: fix capture type setting " Frank Schäfer
2012-11-25 10:37 ` Frank Schäfer [this message]
2012-11-25 10:37 ` [PATCH 5/6] em28xx: em28xx_urb_data_copy_vbi(): calculate vbi_size only if needed Frank Schäfer
2012-11-25 10:37 ` [PATCH 6/6] em28xx: use common urb data copying function for vbi and non-vbi data streams Frank Schäfer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1353839857-2990-5-git-send-email-fschaefer.oss@googlemail.com \
--to=fschaefer.oss@googlemail.com \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox