aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/pwc/pwc-v4l.c
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2012-01-04 14:58:44 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-01-06 07:46:46 -0500
commit795e6eb3262d3b7247ce450835eea6df6571d103 (patch)
tree558c161d69a04a172f54c1edd38c44b2553bf10e /drivers/media/video/pwc/pwc-v4l.c
parenta08d2c727153dc6cea1d5d54a43fd7d69c1467c3 (diff)
[media] pwc: Remove software emulation of arbritary resolutions
The pwc driver claims to support any resolution between 160x120 and 640x480, but emulates this by simply drawing a black border around the image. Userspace can draw its own black border if it really wants one. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/pwc/pwc-v4l.c')
-rw-r--r--drivers/media/video/pwc/pwc-v4l.c52
1 files changed, 22 insertions, 30 deletions
diff --git a/drivers/media/video/pwc/pwc-v4l.c b/drivers/media/video/pwc/pwc-v4l.c
index 87457b53f495..097ec582ee66 100644
--- a/drivers/media/video/pwc/pwc-v4l.c
+++ b/drivers/media/video/pwc/pwc-v4l.c
@@ -398,8 +398,8 @@ int pwc_init_controls(struct pwc_device *pdev)
398static void pwc_vidioc_fill_fmt(const struct pwc_device *pdev, struct v4l2_format *f) 398static void pwc_vidioc_fill_fmt(const struct pwc_device *pdev, struct v4l2_format *f)
399{ 399{
400 memset(&f->fmt.pix, 0, sizeof(struct v4l2_pix_format)); 400 memset(&f->fmt.pix, 0, sizeof(struct v4l2_pix_format));
401 f->fmt.pix.width = pdev->view.x; 401 f->fmt.pix.width = pdev->width;
402 f->fmt.pix.height = pdev->view.y; 402 f->fmt.pix.height = pdev->height;
403 f->fmt.pix.field = V4L2_FIELD_NONE; 403 f->fmt.pix.field = V4L2_FIELD_NONE;
404 if (pdev->pixfmt == V4L2_PIX_FMT_YUV420) { 404 if (pdev->pixfmt == V4L2_PIX_FMT_YUV420) {
405 f->fmt.pix.pixelformat = V4L2_PIX_FMT_YUV420; 405 f->fmt.pix.pixelformat = V4L2_PIX_FMT_YUV420;
@@ -429,6 +429,8 @@ static void pwc_vidioc_fill_fmt(const struct pwc_device *pdev, struct v4l2_forma
429/* ioctl(VIDIOC_TRY_FMT) */ 429/* ioctl(VIDIOC_TRY_FMT) */
430static int pwc_vidioc_try_fmt(struct pwc_device *pdev, struct v4l2_format *f) 430static int pwc_vidioc_try_fmt(struct pwc_device *pdev, struct v4l2_format *f)
431{ 431{
432 int size;
433
432 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { 434 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
433 PWC_DEBUG_IOCTL("Bad video type must be V4L2_BUF_TYPE_VIDEO_CAPTURE\n"); 435 PWC_DEBUG_IOCTL("Bad video type must be V4L2_BUF_TYPE_VIDEO_CAPTURE\n");
434 return -EINVAL; 436 return -EINVAL;
@@ -455,15 +457,9 @@ static int pwc_vidioc_try_fmt(struct pwc_device *pdev, struct v4l2_format *f)
455 457
456 } 458 }
457 459
458 if (f->fmt.pix.width > pdev->view_max.x) 460 size = pwc_get_size(pdev, f->fmt.pix.width, f->fmt.pix.height);
459 f->fmt.pix.width = pdev->view_max.x; 461 f->fmt.pix.width = pwc_image_sizes[size][0];
460 else if (f->fmt.pix.width < pdev->view_min.x) 462 f->fmt.pix.height = pwc_image_sizes[size][1];
461 f->fmt.pix.width = pdev->view_min.x;
462
463 if (f->fmt.pix.height > pdev->view_max.y)
464 f->fmt.pix.height = pdev->view_max.y;
465 else if (f->fmt.pix.height < pdev->view_min.y)
466 f->fmt.pix.height = pdev->view_min.y;
467 463
468 return 0; 464 return 0;
469} 465}
@@ -972,7 +968,7 @@ static int pwc_g_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f)
972 968
973 mutex_lock(&pdev->udevlock); /* To avoid race with s_fmt */ 969 mutex_lock(&pdev->udevlock); /* To avoid race with s_fmt */
974 PWC_DEBUG_IOCTL("ioctl(VIDIOC_G_FMT) return size %dx%d\n", 970 PWC_DEBUG_IOCTL("ioctl(VIDIOC_G_FMT) return size %dx%d\n",
975 pdev->image.x, pdev->image.y); 971 pdev->width, pdev->height);
976 pwc_vidioc_fill_fmt(pdev, f); 972 pwc_vidioc_fill_fmt(pdev, f);
977 mutex_unlock(&pdev->udevlock); 973 mutex_unlock(&pdev->udevlock);
978 return 0; 974 return 0;
@@ -1061,25 +1057,21 @@ static int pwc_enum_framesizes(struct file *file, void *fh,
1061 struct pwc_device *pdev = video_drvdata(file); 1057 struct pwc_device *pdev = video_drvdata(file);
1062 unsigned int i = 0, index = fsize->index; 1058 unsigned int i = 0, index = fsize->index;
1063 1059
1064 if (fsize->pixel_format == V4L2_PIX_FMT_YUV420) { 1060 if (fsize->pixel_format == V4L2_PIX_FMT_YUV420 ||
1061 (fsize->pixel_format == V4L2_PIX_FMT_PWC1 &&
1062 DEVICE_USE_CODEC1(pdev->type)) ||
1063 (fsize->pixel_format == V4L2_PIX_FMT_PWC2 &&
1064 DEVICE_USE_CODEC23(pdev->type))) {
1065 for (i = 0; i < PSZ_MAX; i++) { 1065 for (i = 0; i < PSZ_MAX; i++) {
1066 if (pdev->image_mask & (1UL << i)) { 1066 if (!(pdev->image_mask & (1UL << i)))
1067 if (!index--) { 1067 continue;
1068 fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE; 1068 if (!index--) {
1069 fsize->discrete.width = pwc_image_sizes[i].x; 1069 fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
1070 fsize->discrete.height = pwc_image_sizes[i].y; 1070 fsize->discrete.width = pwc_image_sizes[i][0];
1071 return 0; 1071 fsize->discrete.height = pwc_image_sizes[i][1];
1072 } 1072 return 0;
1073 } 1073 }
1074 } 1074 }
1075 } else if (fsize->index == 0 &&
1076 ((fsize->pixel_format == V4L2_PIX_FMT_PWC1 && DEVICE_USE_CODEC1(pdev->type)) ||
1077 (fsize->pixel_format == V4L2_PIX_FMT_PWC2 && DEVICE_USE_CODEC23(pdev->type)))) {
1078
1079 fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
1080 fsize->discrete.width = pdev->abs_max.x;
1081 fsize->discrete.height = pdev->abs_max.y;
1082 return 0;
1083 } 1075 }
1084 return -EINVAL; 1076 return -EINVAL;
1085} 1077}
@@ -1092,8 +1084,8 @@ static int pwc_enum_frameintervals(struct file *file, void *fh,
1092 unsigned int i; 1084 unsigned int i;
1093 1085
1094 for (i = 0; i < PSZ_MAX; i++) { 1086 for (i = 0; i < PSZ_MAX; i++) {
1095 if (pwc_image_sizes[i].x == fival->width && 1087 if (pwc_image_sizes[i][0] == fival->width &&
1096 pwc_image_sizes[i].y == fival->height) { 1088 pwc_image_sizes[i][1] == fival->height) {
1097 size = i; 1089 size = i;
1098 break; 1090 break;
1099 } 1091 }