From 06dee51d4c46e88644350d5bfeebaa1d3c7bd62c Mon Sep 17 00:00:00 2001 From: Brian Johnson Date: Mon, 8 Jun 2009 13:41:38 -0400 Subject: [PATCH] Fix SXGA support to enforce bayer format Since bayer is the only format that currently works with SXGA in order to prevent brokeness we only allow setting SXGA in conjunction with bayer Signed-off-by: Brian Johnson --- sn9c20x-bridge.c | 2 +- sn9c20x-v4l2.c | 23 ++++++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/sn9c20x-bridge.c b/sn9c20x-bridge.c index 6263fc9..381442d 100644 --- a/sn9c20x-bridge.c +++ b/sn9c20x-bridge.c @@ -1115,7 +1115,7 @@ int sn9c20x_set_resolution(struct usb_sn9c20x *dev, window[5] = mode->window[3] >> 3; if (dev->camera.set_sxga_mode) { - if (mode->window[2] > 640 && mode->window[3] > 480) { + if (width > 640 && height > 480) { dev->camera.set_sxga_mode(dev, true); scale |= 0xc0; UDIA_DEBUG("Set Sensor to SXGA\n"); diff --git a/sn9c20x-v4l2.c b/sn9c20x-v4l2.c index 5c8aedc..7a01657 100644 --- a/sn9c20x-v4l2.c +++ b/sn9c20x-v4l2.c @@ -725,8 +725,17 @@ int sn9c20x_vidioc_enum_framesizes(struct file *file, void *priv, size->discrete.width = sn9c20x_modes[size->index].width; size->discrete.height = sn9c20x_modes[size->index].height; - UDIA_DEBUG("Framesize: %dx%d\n", size->discrete.width, - size->discrete.height); + if (dev->camera.set_sxga_mode == NULL && + (size->discrete.width > 640 && size->discrete.height > 480)) + return -EINVAL; + + if (size->pixel_format != V4L2_PIX_FMT_SBGGR8 && + (size->discrete.width > 640 && size->discrete.height > 480)) + return -EINVAL; + + UDIA_DEBUG("Framesize: %dx%d, FMT: %X\n", size->discrete.width, + size->discrete.height, + size->pixel_format); return 0; } @@ -1030,6 +1039,13 @@ int sn9c20x_vidioc_try_fmt_cap(struct file *file, void *priv, if (fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_JPEG && dev->jpeg == 0) return -EINVAL; + sn9c20x_get_closest_resolution(dev, &fmt->fmt.pix.width, + &fmt->fmt.pix.height); + + if (fmt->fmt.pix.pixelformat != V4L2_PIX_FMT_SBGGR8 && + (fmt->fmt.pix.width > 640 && fmt->fmt.pix.height > 480)) + fmt->fmt.pix.pixelformat = V4L2_PIX_FMT_SBGGR8; + for (index = 0; index < SN9C20X_N_FMTS; index++) if (sn9c20x_fmts[index].pix_fmt == fmt->fmt.pix.pixelformat) break; @@ -1037,9 +1053,6 @@ int sn9c20x_vidioc_try_fmt_cap(struct file *file, void *priv, if (index >= SN9C20X_N_FMTS) return -EINVAL; - sn9c20x_get_closest_resolution(dev, &fmt->fmt.pix.width, - &fmt->fmt.pix.height); - fmt->fmt.pix.bytesperline = fmt->fmt.pix.width * sn9c20x_fmts[index].depth / 8; -- 2.11.4.GIT