aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/usb/gspca
diff options
context:
space:
mode:
authorOndrej Zary <linux@rainbow-software.org>2013-08-30 16:54:25 -0400
committerMauro Carvalho Chehab <m.chehab@samsung.com>2013-09-26 06:21:51 -0400
commit76e059874d3c362797990b4dcd58979b3f26f86f (patch)
tree14312098b9c9fa5e16c97819eca939bdc6be7841 /drivers/media/usb/gspca
parent7d687af4d5148ffb69da5f71c684380a478ad159 (diff)
[media] gspca-stk1135: Add variable resolution support
Add variable resolution support to Syntek STK1135 subdriver. Signed-off-by: Ondrej Zary <linux@rainbow-software.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/usb/gspca')
-rw-r--r--drivers/media/usb/gspca/stk1135.c68
1 files changed, 34 insertions, 34 deletions
diff --git a/drivers/media/usb/gspca/stk1135.c b/drivers/media/usb/gspca/stk1135.c
index 5a6ed4916ed8..8add2f74deda 100644
--- a/drivers/media/usb/gspca/stk1135.c
+++ b/drivers/media/usb/gspca/stk1135.c
@@ -48,42 +48,11 @@ struct sd {
48}; 48};
49 49
50static const struct v4l2_pix_format stk1135_modes[] = { 50static const struct v4l2_pix_format stk1135_modes[] = {
51 {160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, 51 /* default mode (this driver supports variable resolution) */
52 .bytesperline = 160,
53 .sizeimage = 160 * 120,
54 .colorspace = V4L2_COLORSPACE_SRGB},
55 {176, 144, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
56 .bytesperline = 176,
57 .sizeimage = 176 * 144,
58 .colorspace = V4L2_COLORSPACE_SRGB},
59 {320, 240, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
60 .bytesperline = 320,
61 .sizeimage = 320 * 240,
62 .colorspace = V4L2_COLORSPACE_SRGB},
63 {352, 288, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
64 .bytesperline = 352,
65 .sizeimage = 352 * 288,
66 .colorspace = V4L2_COLORSPACE_SRGB},
67 {640, 480, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, 52 {640, 480, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
68 .bytesperline = 640, 53 .bytesperline = 640,
69 .sizeimage = 640 * 480, 54 .sizeimage = 640 * 480,
70 .colorspace = V4L2_COLORSPACE_SRGB}, 55 .colorspace = V4L2_COLORSPACE_SRGB},
71 {720, 576, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
72 .bytesperline = 720,
73 .sizeimage = 720 * 576,
74 .colorspace = V4L2_COLORSPACE_SRGB},
75 {800, 600, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
76 .bytesperline = 800,
77 .sizeimage = 800 * 600,
78 .colorspace = V4L2_COLORSPACE_SRGB},
79 {1024, 768, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
80 .bytesperline = 1024,
81 .sizeimage = 1024 * 768,
82 .colorspace = V4L2_COLORSPACE_SRGB},
83 {1280, 1024, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
84 .bytesperline = 1280,
85 .sizeimage = 1280 * 1024,
86 .colorspace = V4L2_COLORSPACE_SRGB},
87}; 56};
88 57
89/* -- read a register -- */ 58/* -- read a register -- */
@@ -349,14 +318,14 @@ static void stk1135_configure_mt9m112(struct gspca_dev *gspca_dev)
349 /* set output size */ 318 /* set output size */
350 width = gspca_dev->pixfmt.width; 319 width = gspca_dev->pixfmt.width;
351 height = gspca_dev->pixfmt.height; 320 height = gspca_dev->pixfmt.height;
352 if (width <= 640) { /* use context A (half readout speed by default) */ 321 if (width <= 640 && height <= 512) { /* context A (half readout speed)*/
353 sensor_write(gspca_dev, 0x1a7, width); 322 sensor_write(gspca_dev, 0x1a7, width);
354 sensor_write(gspca_dev, 0x1aa, height); 323 sensor_write(gspca_dev, 0x1aa, height);
355 /* set read mode context A */ 324 /* set read mode context A */
356 sensor_write(gspca_dev, 0x0c8, 0x0000); 325 sensor_write(gspca_dev, 0x0c8, 0x0000);
357 /* set resize, read mode, vblank, hblank context A */ 326 /* set resize, read mode, vblank, hblank context A */
358 sensor_write(gspca_dev, 0x2c8, 0x0000); 327 sensor_write(gspca_dev, 0x2c8, 0x0000);
359 } else { /* use context B (full readout speed by default) */ 328 } else { /* context B (full readout speed) */
360 sensor_write(gspca_dev, 0x1a1, width); 329 sensor_write(gspca_dev, 0x1a1, width);
361 sensor_write(gspca_dev, 0x1a4, height); 330 sensor_write(gspca_dev, 0x1a4, height);
362 /* set read mode context B */ 331 /* set read mode context B */
@@ -643,6 +612,35 @@ static int sd_init_controls(struct gspca_dev *gspca_dev)
643 return 0; 612 return 0;
644} 613}
645 614
615void stk1135_try_fmt(struct gspca_dev *gspca_dev, struct v4l2_format *fmt)
616{
617 fmt->fmt.pix.width = clamp(fmt->fmt.pix.width, 32U, 1280U);
618 fmt->fmt.pix.height = clamp(fmt->fmt.pix.height, 32U, 1024U);
619 /* round up to even numbers */
620 fmt->fmt.pix.width += (fmt->fmt.pix.width & 1);
621 fmt->fmt.pix.height += (fmt->fmt.pix.height & 1);
622
623 fmt->fmt.pix.bytesperline = fmt->fmt.pix.width;
624 fmt->fmt.pix.sizeimage = fmt->fmt.pix.width * fmt->fmt.pix.height;
625}
626
627int stk1135_enum_framesizes(struct gspca_dev *gspca_dev,
628 struct v4l2_frmsizeenum *fsize)
629{
630 if (fsize->index != 0 || fsize->pixel_format != V4L2_PIX_FMT_SBGGR8)
631 return -EINVAL;
632
633 fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE;
634 fsize->stepwise.min_width = 32;
635 fsize->stepwise.min_height = 32;
636 fsize->stepwise.max_width = 1280;
637 fsize->stepwise.max_height = 1024;
638 fsize->stepwise.step_width = 2;
639 fsize->stepwise.step_height = 2;
640
641 return 0;
642}
643
646/* sub-driver description */ 644/* sub-driver description */
647static const struct sd_desc sd_desc = { 645static const struct sd_desc sd_desc = {
648 .name = MODULE_NAME, 646 .name = MODULE_NAME,
@@ -653,6 +651,8 @@ static const struct sd_desc sd_desc = {
653 .stopN = sd_stopN, 651 .stopN = sd_stopN,
654 .pkt_scan = sd_pkt_scan, 652 .pkt_scan = sd_pkt_scan,
655 .dq_callback = stk1135_dq_callback, 653 .dq_callback = stk1135_dq_callback,
654 .try_fmt = stk1135_try_fmt,
655 .enum_framesizes = stk1135_enum_framesizes,
656}; 656};
657 657
658/* -- module initialisation -- */ 658/* -- module initialisation -- */