aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJean-Francois Moine <moinejf@free.fr>2009-01-23 12:42:03 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:42:34 -0400
commita5df5c14335988317da4ba9aec64b7eb971a6ffc (patch)
tree57d3c3fd322a7099a749719f7ecb24505f430912 /drivers
parent16631aedb23bac40332549dcaed90c804271cc5b (diff)
V4L/DVB (10384): gspca - spca505: Simplify and add the brightness in start.
Signed-off-by: Jean-Francois Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/gspca/spca505.c81
1 files changed, 34 insertions, 47 deletions
diff --git a/drivers/media/video/gspca/spca505.c b/drivers/media/video/gspca/spca505.c
index c99bf62614f3..b9139b1edac9 100644
--- a/drivers/media/video/gspca/spca505.c
+++ b/drivers/media/video/gspca/spca505.c
@@ -64,12 +64,12 @@ static const struct v4l2_pix_format vga_mode[] = {
64 .bytesperline = 160, 64 .bytesperline = 160,
65 .sizeimage = 160 * 120 * 3 / 2, 65 .sizeimage = 160 * 120 * 3 / 2,
66 .colorspace = V4L2_COLORSPACE_SRGB, 66 .colorspace = V4L2_COLORSPACE_SRGB,
67 .priv = 5}, 67 .priv = 4},
68 {176, 144, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE, 68 {176, 144, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
69 .bytesperline = 176, 69 .bytesperline = 176,
70 .sizeimage = 176 * 144 * 3 / 2, 70 .sizeimage = 176 * 144 * 3 / 2,
71 .colorspace = V4L2_COLORSPACE_SRGB, 71 .colorspace = V4L2_COLORSPACE_SRGB,
72 .priv = 4}, 72 .priv = 3},
73 {320, 240, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE, 73 {320, 240, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
74 .bytesperline = 320, 74 .bytesperline = 320,
75 .sizeimage = 320 * 240 * 3 / 2, 75 .sizeimage = 320 * 240 * 3 / 2,
@@ -93,6 +93,7 @@ static const struct v4l2_pix_format vga_mode[] = {
93 93
94#define SPCA50X_USB_CTRL 0x00 /* spca505 */ 94#define SPCA50X_USB_CTRL 0x00 /* spca505 */
95#define SPCA50X_CUSB_ENABLE 0x01 /* spca505 */ 95#define SPCA50X_CUSB_ENABLE 0x01 /* spca505 */
96
96#define SPCA50X_REG_GLOBAL 0x03 /* spca505 */ 97#define SPCA50X_REG_GLOBAL 0x03 /* spca505 */
97#define SPCA50X_GMISC0_IDSEL 0x01 /* Global control device ID select spca505 */ 98#define SPCA50X_GMISC0_IDSEL 0x01 /* Global control device ID select spca505 */
98#define SPCA50X_GLOBAL_MISC0 0x00 /* Global control miscellaneous 0 spca505 */ 99#define SPCA50X_GLOBAL_MISC0 0x00 /* Global control miscellaneous 0 spca505 */
@@ -101,6 +102,9 @@ static const struct v4l2_pix_format vga_mode[] = {
101#define SPCA50X_GLOBAL_MISC3 0x03 /* 505 */ 102#define SPCA50X_GLOBAL_MISC3 0x03 /* 505 */
102#define SPCA50X_GMISC3_SAA7113RST 0x20 /* Not sure about this one spca505 */ 103#define SPCA50X_GMISC3_SAA7113RST 0x20 /* Not sure about this one spca505 */
103 104
105/* Image format and compression control */
106#define SPCA50X_REG_COMPRESS 0x04
107
104/* 108/*
105 * Data to initialize a SPCA505. Common to the CCD and external modes 109 * Data to initialize a SPCA505. Common to the CCD and external modes
106 */ 110 */
@@ -670,55 +674,48 @@ static int sd_init(struct gspca_dev *gspca_dev)
670 ret = reg_write(gspca_dev->dev, 0x06, 0x16, 0x0a); 674 ret = reg_write(gspca_dev->dev, 0x06, 0x16, 0x0a);
671 if (ret < 0) 675 if (ret < 0)
672 return ret; 676 return ret;
673 reg_write(gspca_dev->dev, 0x05, 0xc2, 18); 677 reg_write(gspca_dev->dev, 0x05, 0xc2, 0x12);
674 return 0; 678 return 0;
675} 679}
676 680
681static void setbrightness(struct gspca_dev *gspca_dev)
682{
683 struct sd *sd = (struct sd *) gspca_dev;
684 u8 brightness = sd->brightness;
685
686 reg_write(gspca_dev->dev, 0x05, 0x00, (255 - brightness) >> 6);
687 reg_write(gspca_dev->dev, 0x05, 0x01, (255 - brightness) << 2);
688}
689
677static int sd_start(struct gspca_dev *gspca_dev) 690static int sd_start(struct gspca_dev *gspca_dev)
678{ 691{
679 struct usb_device *dev = gspca_dev->dev; 692 struct usb_device *dev = gspca_dev->dev;
680 int ret; 693 int ret, mode;
694 static u8 mode_tb[][3] = {
695 /* r00 r06 r07 */
696 {0x00, 0x10, 0x10}, /* 640x480 */
697 {0x01, 0x1a, 0x1a}, /* 352x288 */
698 {0x02, 0x1c, 0x1d}, /* 320x240 */
699 {0x04, 0x34, 0x34}, /* 176x144 */
700 {0x05, 0x40, 0x40} /* 160x120 */
701 };
681 702
682 /* necessary because without it we can see stream 703 /* necessary because without it we can see stream
683 * only once after loading module */ 704 * only once after loading module */
684 /* stopping usb registers Tomasz change */ 705 /* stopping usb registers Tomasz change */
685 reg_write(dev, 0x02, 0x0, 0x0); 706 reg_write(dev, 0x02, 0x00, 0x00);
686 switch (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv) { 707
687 case 0: 708 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
688 reg_write(dev, 0x04, 0x00, 0x00); 709 reg_write(dev, SPCA50X_REG_COMPRESS, 0x00, mode_tb[mode][0]);
689 reg_write(dev, 0x04, 0x06, 0x10); 710 reg_write(dev, SPCA50X_REG_COMPRESS, 0x06, mode_tb[mode][1]);
690 reg_write(dev, 0x04, 0x07, 0x10); 711 reg_write(dev, SPCA50X_REG_COMPRESS, 0x07, mode_tb[mode][2]);
691 break; 712
692 case 1:
693 reg_write(dev, 0x04, 0x00, 0x01);
694 reg_write(dev, 0x04, 0x06, 0x1a);
695 reg_write(dev, 0x04, 0x07, 0x1a);
696 break;
697 case 2:
698 reg_write(dev, 0x04, 0x00, 0x02);
699 reg_write(dev, 0x04, 0x06, 0x1c);
700 reg_write(dev, 0x04, 0x07, 0x1d);
701 break;
702 case 4:
703 reg_write(dev, 0x04, 0x00, 0x04);
704 reg_write(dev, 0x04, 0x06, 0x34);
705 reg_write(dev, 0x04, 0x07, 0x34);
706 break;
707 default:
708/* case 5: */
709 reg_write(dev, 0x04, 0x00, 0x05);
710 reg_write(dev, 0x04, 0x06, 0x40);
711 reg_write(dev, 0x04, 0x07, 0x40);
712 break;
713 }
714/* Enable ISO packet machine - should we do this here or in ISOC init ? */
715 ret = reg_write(dev, SPCA50X_REG_USB, 713 ret = reg_write(dev, SPCA50X_REG_USB,
716 SPCA50X_USB_CTRL, 714 SPCA50X_USB_CTRL,
717 SPCA50X_CUSB_ENABLE); 715 SPCA50X_CUSB_ENABLE);
718 716
719/* reg_write(dev, 0x5, 0x0, 0x0); */ 717 setbrightness(gspca_dev);
720/* reg_write(dev, 0x5, 0x0, 0x1); */ 718
721/* reg_write(dev, 0x5, 0x11, 0x2); */
722 return ret; 719 return ret;
723} 720}
724 721
@@ -767,16 +764,6 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
767 } 764 }
768} 765}
769 766
770static void setbrightness(struct gspca_dev *gspca_dev)
771{
772 struct sd *sd = (struct sd *) gspca_dev;
773 u8 brightness = sd->brightness;
774
775 reg_write(gspca_dev->dev, 0x05, 0x00, (255 - brightness) >> 6);
776 reg_write(gspca_dev->dev, 0x05, 0x01, (255 - brightness) << 2);
777
778}
779
780static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) 767static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
781{ 768{
782 struct sd *sd = (struct sd *) gspca_dev; 769 struct sd *sd = (struct sd *) gspca_dev;