Commit 479567ce authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

V4L/DVB: pwc: fully convert driver to V4L2

Remove the V4L1 API from this driver, making it fully V4L2.

Also fix a bug where the /dev/videoX device was created too early, which led
to initialization problems of the camera, making it unable to capture video.
Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent a1de2e4b
config USB_PWC config USB_PWC
tristate "USB Philips Cameras" tristate "USB Philips Cameras"
depends on VIDEO_V4L1 depends on VIDEO_V4L2
---help--- ---help---
Say Y or M here if you want to use one of these Philips & OEM Say Y or M here if you want to use one of these Philips & OEM
webcams: webcams:
......
...@@ -261,7 +261,7 @@ static int set_video_mode_Nala(struct pwc_device *pdev, int size, int frames) ...@@ -261,7 +261,7 @@ static int set_video_mode_Nala(struct pwc_device *pdev, int size, int frames)
PWC_DEBUG_MODULE("Failed to send video command... %d\n", ret); PWC_DEBUG_MODULE("Failed to send video command... %d\n", ret);
return ret; return ret;
} }
if (pEntry->compressed && pdev->vpalette != VIDEO_PALETTE_RAW) if (pEntry->compressed && pdev->pixfmt == V4L2_PIX_FMT_YUV420)
pwc_dec1_init(pdev->type, pdev->release, buf, pdev->decompress_data); pwc_dec1_init(pdev->type, pdev->release, buf, pdev->decompress_data);
pdev->cmd_len = 3; pdev->cmd_len = 3;
...@@ -321,7 +321,7 @@ static int set_video_mode_Timon(struct pwc_device *pdev, int size, int frames, i ...@@ -321,7 +321,7 @@ static int set_video_mode_Timon(struct pwc_device *pdev, int size, int frames, i
if (ret < 0) if (ret < 0)
return ret; return ret;
if (pChoose->bandlength > 0 && pdev->vpalette != VIDEO_PALETTE_RAW) if (pChoose->bandlength > 0 && pdev->pixfmt == V4L2_PIX_FMT_YUV420)
pwc_dec23_init(pdev, pdev->type, buf); pwc_dec23_init(pdev, pdev->type, buf);
pdev->cmd_len = 13; pdev->cmd_len = 13;
...@@ -356,7 +356,7 @@ static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int frames, i ...@@ -356,7 +356,7 @@ static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int frames, i
fps = (frames / 5) - 1; fps = (frames / 5) - 1;
/* special case: VGA @ 5 fps and snapshot is raw bayer mode */ /* special case: VGA @ 5 fps and snapshot is raw bayer mode */
if (size == PSZ_VGA && frames == 5 && snapshot && pdev->vpalette == VIDEO_PALETTE_RAW) if (size == PSZ_VGA && frames == 5 && snapshot && pdev->pixfmt != V4L2_PIX_FMT_YUV420)
{ {
/* Only available in case the raw palette is selected or /* Only available in case the raw palette is selected or
we have the decompressor available. This mode is we have the decompressor available. This mode is
...@@ -394,7 +394,7 @@ static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int frames, i ...@@ -394,7 +394,7 @@ static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int frames, i
if (ret < 0) if (ret < 0)
return ret; return ret;
if (pChoose->bandlength > 0 && pdev->vpalette != VIDEO_PALETTE_RAW) if (pChoose->bandlength > 0 && pdev->pixfmt == V4L2_PIX_FMT_YUV420)
pwc_dec23_init(pdev, pdev->type, buf); pwc_dec23_init(pdev, pdev->type, buf);
pdev->cmd_len = 12; pdev->cmd_len = 12;
...@@ -429,7 +429,7 @@ int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frame ...@@ -429,7 +429,7 @@ int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frame
{ {
int ret, size; int ret, size;
PWC_DEBUG_FLOW("set_video_mode(%dx%d @ %d, palette %d).\n", width, height, frames, pdev->vpalette); PWC_DEBUG_FLOW("set_video_mode(%dx%d @ %d, pixfmt %08x).\n", width, height, frames, pdev->pixfmt);
size = pwc_decode_size(pdev, width, height); size = pwc_decode_size(pdev, width, height);
if (size < 0) { if (size < 0) {
PWC_DEBUG_MODULE("Could not find suitable size.\n"); PWC_DEBUG_MODULE("Could not find suitable size.\n");
...@@ -519,13 +519,13 @@ static void pwc_set_image_buffer_size(struct pwc_device *pdev) ...@@ -519,13 +519,13 @@ static void pwc_set_image_buffer_size(struct pwc_device *pdev)
{ {
int i, factor = 0; int i, factor = 0;
/* for PALETTE_YUV420P */ /* for V4L2_PIX_FMT_YUV420 */
switch(pdev->vpalette) switch (pdev->pixfmt) {
{ case V4L2_PIX_FMT_YUV420:
case VIDEO_PALETTE_YUV420P:
factor = 6; factor = 6;
break; break;
case VIDEO_PALETTE_RAW: case V4L2_PIX_FMT_PWC1:
case V4L2_PIX_FMT_PWC2:
factor = 6; /* can be uncompressed YUV420P */ factor = 6; /* can be uncompressed YUV420P */
break; break;
} }
......
...@@ -1365,7 +1365,7 @@ static ssize_t pwc_video_read(struct file *file, char __user *buf, ...@@ -1365,7 +1365,7 @@ static ssize_t pwc_video_read(struct file *file, char __user *buf,
} }
PWC_DEBUG_READ("Copying data to user space.\n"); PWC_DEBUG_READ("Copying data to user space.\n");
if (pdev->vpalette == VIDEO_PALETTE_RAW) if (pdev->pixfmt != V4L2_PIX_FMT_YUV420)
bytes_to_read = pdev->frame_size + sizeof(struct pwc_raw_frame); bytes_to_read = pdev->frame_size + sizeof(struct pwc_raw_frame);
else else
bytes_to_read = pdev->view.size; bytes_to_read = pdev->view.size;
...@@ -1800,13 +1800,6 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id ...@@ -1800,13 +1800,6 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
} }
pdev->vdev->release = video_device_release; pdev->vdev->release = video_device_release;
rc = video_register_device(pdev->vdev, VFL_TYPE_GRABBER, video_nr);
if (rc < 0) {
PWC_ERROR("Failed to register as video device (%d).\n", rc);
goto err_video_release;
}
PWC_INFO("Registered as %s.\n", video_device_node_name(pdev->vdev));
/* occupy slot */ /* occupy slot */
if (hint < MAX_DEV_HINTS) if (hint < MAX_DEV_HINTS)
...@@ -1814,14 +1807,22 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id ...@@ -1814,14 +1807,22 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
PWC_DEBUG_PROBE("probe() function returning struct at 0x%p.\n", pdev); PWC_DEBUG_PROBE("probe() function returning struct at 0x%p.\n", pdev);
usb_set_intfdata(intf, pdev); usb_set_intfdata(intf, pdev);
rc = pwc_create_sysfs_files(pdev->vdev);
if (rc)
goto err_video_unreg;
/* Set the leds off */ /* Set the leds off */
pwc_set_leds(pdev, 0, 0); pwc_set_leds(pdev, 0, 0);
pwc_camera_power(pdev, 0); pwc_camera_power(pdev, 0);
rc = video_register_device(pdev->vdev, VFL_TYPE_GRABBER, video_nr);
if (rc < 0) {
PWC_ERROR("Failed to register as video device (%d).\n", rc);
goto err_video_release;
}
rc = pwc_create_sysfs_files(pdev->vdev);
if (rc)
goto err_video_unreg;
PWC_INFO("Registered as %s.\n", video_device_node_name(pdev->vdev));
#ifdef CONFIG_USB_PWC_INPUT_EVDEV #ifdef CONFIG_USB_PWC_INPUT_EVDEV
/* register webcam snapshot button input device */ /* register webcam snapshot button input device */
pdev->button_dev = input_allocate_device(); pdev->button_dev = input_allocate_device();
......
...@@ -47,7 +47,7 @@ int pwc_decode_size(struct pwc_device *pdev, int width, int height) ...@@ -47,7 +47,7 @@ int pwc_decode_size(struct pwc_device *pdev, int width, int height)
you don't have the decompressor loaded or use RAW mode, you don't have the decompressor loaded or use RAW mode,
the maximum viewable size is smaller. the maximum viewable size is smaller.
*/ */
if (pdev->vpalette == VIDEO_PALETTE_RAW) if (pdev->pixfmt != V4L2_PIX_FMT_YUV420)
{ {
if (width > pdev->abs_max.x || height > pdev->abs_max.y) if (width > pdev->abs_max.x || height > pdev->abs_max.y)
{ {
...@@ -123,7 +123,7 @@ void pwc_construct(struct pwc_device *pdev) ...@@ -123,7 +123,7 @@ void pwc_construct(struct pwc_device *pdev)
pdev->frame_header_size = 0; pdev->frame_header_size = 0;
pdev->frame_trailer_size = 0; pdev->frame_trailer_size = 0;
} }
pdev->vpalette = VIDEO_PALETTE_YUV420P; /* default */ pdev->pixfmt = V4L2_PIX_FMT_YUV420; /* default */
pdev->view_min.size = pdev->view_min.x * pdev->view_min.y; pdev->view_min.size = pdev->view_min.x * pdev->view_min.y;
pdev->view_max.size = pdev->view_max.x * pdev->view_max.y; pdev->view_max.size = pdev->view_max.x * pdev->view_max.y;
/* length of image, in YUV format; always allocate enough memory. */ /* length of image, in YUV format; always allocate enough memory. */
......
...@@ -54,7 +54,7 @@ int pwc_decompress(struct pwc_device *pdev) ...@@ -54,7 +54,7 @@ int pwc_decompress(struct pwc_device *pdev)
yuv = fbuf->data + pdev->frame_header_size; /* Skip header */ yuv = fbuf->data + pdev->frame_header_size; /* Skip header */
/* Raw format; that's easy... */ /* Raw format; that's easy... */
if (pdev->vpalette == VIDEO_PALETTE_RAW) if (pdev->pixfmt != V4L2_PIX_FMT_YUV420)
{ {
struct pwc_raw_frame *raw_frame = image; struct pwc_raw_frame *raw_frame = image;
raw_frame->type = cpu_to_le16(pdev->type); raw_frame->type = cpu_to_le16(pdev->type);
......
This diff is collapsed.
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <asm/errno.h> #include <asm/errno.h>
#include <linux/videodev.h> #include <linux/videodev2.h>
#include <media/v4l2-common.h> #include <media/v4l2-common.h>
#include <media/v4l2-ioctl.h> #include <media/v4l2-ioctl.h>
#ifdef CONFIG_USB_PWC_INPUT_EVDEV #ifdef CONFIG_USB_PWC_INPUT_EVDEV
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
#define PWC_MINOR 0 #define PWC_MINOR 0
#define PWC_EXTRAMINOR 12 #define PWC_EXTRAMINOR 12
#define PWC_VERSION_CODE KERNEL_VERSION(PWC_MAJOR,PWC_MINOR,PWC_EXTRAMINOR) #define PWC_VERSION_CODE KERNEL_VERSION(PWC_MAJOR,PWC_MINOR,PWC_EXTRAMINOR)
#define PWC_VERSION "10.0.13" #define PWC_VERSION "10.0.14"
#define PWC_NAME "pwc" #define PWC_NAME "pwc"
#define PFX PWC_NAME ": " #define PFX PWC_NAME ": "
...@@ -180,7 +180,7 @@ struct pwc_device ...@@ -180,7 +180,7 @@ struct pwc_device
int vcinterface; /* video control interface */ int vcinterface; /* video control interface */
int valternate; /* alternate interface needed */ int valternate; /* alternate interface needed */
int vframes, vsize; /* frames-per-second & size (see PSZ_*) */ int vframes, vsize; /* frames-per-second & size (see PSZ_*) */
int vpalette; /* palette: 420P, RAW or RGBBAYER */ int pixfmt; /* pixelformat: V4L2_PIX_FMT_YUV420 or raw: _PWC1, _PWC2 */
int vframe_count; /* received frames */ int vframe_count; /* received frames */
int vframes_dumped; /* counter for dumped frames */ int vframes_dumped; /* counter for dumped frames */
int vframes_error; /* frames received in error */ int vframes_error; /* frames received in error */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment