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

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
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
config USB_PWC
	tristate "USB Philips Cameras"
	depends on VIDEO_V4L1
	depends on VIDEO_V4L2
	---help---
	  Say Y or M here if you want to use one of these Philips & OEM
	  webcams:
+10 −10
Original line number Diff line number Diff line
@@ -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);
		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);

	pdev->cmd_len = 3;
@@ -321,7 +321,7 @@ static int set_video_mode_Timon(struct pwc_device *pdev, int size, int frames, i
	if (ret < 0)
		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);

	pdev->cmd_len = 13;
@@ -356,7 +356,7 @@ static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int frames, i
	fps = (frames / 5) - 1;

	/* 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
		   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
	if (ret < 0)
		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);

	pdev->cmd_len = 12;
@@ -429,7 +429,7 @@ int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frame
{
	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);
	if (size < 0) {
		PWC_DEBUG_MODULE("Could not find suitable size.\n");
@@ -519,13 +519,13 @@ static void pwc_set_image_buffer_size(struct pwc_device *pdev)
{
	int i, factor = 0;

	/* for PALETTE_YUV420P */
	switch(pdev->vpalette)
	{
	case VIDEO_PALETTE_YUV420P:
	/* for V4L2_PIX_FMT_YUV420 */
	switch (pdev->pixfmt) {
	case V4L2_PIX_FMT_YUV420:
		factor = 6;
		break;
	case VIDEO_PALETTE_RAW:
	case V4L2_PIX_FMT_PWC1:
	case V4L2_PIX_FMT_PWC2:
		factor = 6; /* can be uncompressed YUV420P */
		break;
	}
+12 −11
Original line number Diff line number Diff line
@@ -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");
	if (pdev->vpalette == VIDEO_PALETTE_RAW)
	if (pdev->pixfmt != V4L2_PIX_FMT_YUV420)
		bytes_to_read = pdev->frame_size + sizeof(struct pwc_raw_frame);
	else
		bytes_to_read = pdev->view.size;
@@ -1800,13 +1800,6 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
	}

	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 */
	if (hint < MAX_DEV_HINTS)
@@ -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);
	usb_set_intfdata(intf, pdev);
	rc = pwc_create_sysfs_files(pdev->vdev);
	if (rc)
		goto err_video_unreg;

	/* Set the leds off */
	pwc_set_leds(pdev, 0, 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
	/* register webcam snapshot button input device */
	pdev->button_dev = input_allocate_device();
+2 −2
Original line number Diff line number Diff line
@@ -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,
	   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)
		{
@@ -123,7 +123,7 @@ void pwc_construct(struct pwc_device *pdev)
		pdev->frame_header_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_max.size = pdev->view_max.x * pdev->view_max.y;
	/* length of image, in YUV format; always allocate enough memory. */
+1 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ int pwc_decompress(struct pwc_device *pdev)
	yuv = fbuf->data + pdev->frame_header_size;  /* Skip header */

	/* 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;
		raw_frame->type = cpu_to_le16(pdev->type);
Loading