/* ioctl(VIDIOC_TRY_FMT) */ static int pwc_vidioc_try_fmt(struct pwc_device *pdev, struct v4l2_format *f) { if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { PWC_DEBUG_IOCTL("Bad video type must be V4L2_BUF_TYPE_VIDEO_CAPTURE\n"); return -EINVAL; } switch (f->fmt.pix.pixelformat) { case V4L2_PIX_FMT_YUV420: break; case V4L2_PIX_FMT_PWC1: if (DEVICE_USE_CODEC23(pdev->type)) { PWC_DEBUG_IOCTL("codec1 is only supported for old pwc webcam\n"); return -EINVAL; } break; case V4L2_PIX_FMT_PWC2: if (DEVICE_USE_CODEC1(pdev->type)) { PWC_DEBUG_IOCTL("codec23 is only supported for new pwc webcam\n"); return -EINVAL; } break; default: PWC_DEBUG_IOCTL("Unsupported pixel format\n"); return -EINVAL; } if (f->fmt.pix.width > pdev->view_max.x) f->fmt.pix.width = pdev->view_max.x; else if (f->fmt.pix.width < pdev->view_min.x) f->fmt.pix.width = pdev->view_min.x; if (f->fmt.pix.height > pdev->view_max.y) f->fmt.pix.height = pdev->view_max.y; else if (f->fmt.pix.height < pdev->view_min.y) f->fmt.pix.height = pdev->view_min.y; return 0; }
/* ioctl(VIDIOC_TRY_FMT) */ static int pwc_vidioc_try_fmt(struct pwc_device *pdev, struct v4l2_format *f) { int size; if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { PWC_DEBUG_IOCTL("Bad video type must be V4L2_BUF_TYPE_VIDEO_CAPTURE\n"); return -EINVAL; } switch (f->fmt.pix.pixelformat) { case V4L2_PIX_FMT_YUV420: break; case V4L2_PIX_FMT_PWC1: if (DEVICE_USE_CODEC23(pdev->type)) { PWC_DEBUG_IOCTL("codec1 is only supported for old pwc webcam\n"); return -EINVAL; } break; case V4L2_PIX_FMT_PWC2: if (DEVICE_USE_CODEC1(pdev->type)) { PWC_DEBUG_IOCTL("codec23 is only supported for new pwc webcam\n"); return -EINVAL; } break; default: PWC_DEBUG_IOCTL("Unsupported pixel format\n"); return -EINVAL; } size = pwc_get_size(pdev, f->fmt.pix.width, f->fmt.pix.height); pwc_vidioc_fill_fmt(f, pwc_image_sizes[size][0], pwc_image_sizes[size][1], f->fmt.pix.pixelformat); return 0; }