Skip to content

Commit

Permalink
[media] pwc: Replace private buffer management code with videobuf2
Browse files Browse the repository at this point in the history
Looking at the pwc buffer management code has made it clear to me it needed
some serious fixing. Not only was there a ton of code duplication even
internally to pwc (read and mmap wait for frame code was duplicated), the
code also was outright buggy. With the worst offender being dqbuf, which
just round robin returned all the mmap buffers, without paying any attention
to them being queued by the app with qbuf or not. And qbuf itself was a noop.

So I set out to fix this and already had some cleanups in place when
I read Jonathan Corbet's lwn article on videobuf2, this inspired me to just
rip out the buffer management code and replace it with videobuf2, greatly
reducing the amount of code, and fixing all bugs in one go:

Many thanks to Jonathan for the timely article on this !

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Hans de Goede authored and Mauro Carvalho Chehab committed Jul 27, 2011
1 parent 5f40d91 commit 885fe18
Show file tree
Hide file tree
Showing 7 changed files with 275 additions and 808 deletions.
1 change: 1 addition & 0 deletions drivers/media/video/pwc/Kconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
config USB_PWC
tristate "USB Philips Cameras"
depends on VIDEO_V4L2
select VIDEOBUF2_VMALLOC
---help---
Say Y or M here if you want to use one of these Philips & OEM
webcams:
Expand Down
19 changes: 1 addition & 18 deletions drivers/media/video/pwc/pwc-ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,13 +511,9 @@ unsigned int pwc_get_fps(struct pwc_device *pdev, unsigned int index, unsigned i
return ret;
}

#define BLACK_Y 0
#define BLACK_U 128
#define BLACK_V 128

static void pwc_set_image_buffer_size(struct pwc_device *pdev)
{
int i, factor = 0;
int factor = 0;

/* for V4L2_PIX_FMT_YUV420 */
switch (pdev->pixfmt) {
Expand All @@ -541,22 +537,9 @@ static void pwc_set_image_buffer_size(struct pwc_device *pdev)
*/
pdev->offset.x = ((pdev->view.x - pdev->image.x) / 2) & 0xFFFC;
pdev->offset.y = ((pdev->view.y - pdev->image.y) / 2) & 0xFFFE;

/* Fill buffers with black colors */
for (i = 0; i < pwc_mbufs; i++) {
unsigned char *p = pdev->image_data + pdev->images[i].offset;
memset(p, BLACK_Y, pdev->view.x * pdev->view.y);
p += pdev->view.x * pdev->view.y;
memset(p, BLACK_U, pdev->view.x * pdev->view.y/4);
p += pdev->view.x * pdev->view.y/4;
memset(p, BLACK_V, pdev->view.x * pdev->view.y/4);
}
}



/* BRIGHTNESS */

int pwc_get_brightness(struct pwc_device *pdev)
{
char buf;
Expand Down
Loading

0 comments on commit 885fe18

Please sign in to comment.