aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/conex.c
diff options
context:
space:
mode:
authorJean-Francois Moine <moinejf@free.fr>2008-07-03 10:09:12 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-07-20 06:16:41 -0400
commitbf7f0b98426b54c29ec8100a3f1963114c2f2ef0 (patch)
treec3d43d2240020fded85674066fd2cb7a5a503f86 /drivers/media/video/gspca/conex.c
parent0d2a722ddae5e736a5c36a1b99ee4ca59a8373bc (diff)
V4L/DVB (8193): gspca: Input buffer may be changed on reg write.
Done for conex, etoms, pac7311, sonixj, t613 and tv8532. Code cleanup for some other subdrivers. Signed-off-by: Jean-Francois Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/gspca/conex.c')
-rw-r--r--drivers/media/video/gspca/conex.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/drivers/media/video/gspca/conex.c b/drivers/media/video/gspca/conex.c
index b0294c9274e..473bea750b5 100644
--- a/drivers/media/video/gspca/conex.c
+++ b/drivers/media/video/gspca/conex.c
@@ -25,8 +25,8 @@
25#define CONEX_CAM 1 /* special JPEG header */ 25#define CONEX_CAM 1 /* special JPEG header */
26#include "jpeg.h" 26#include "jpeg.h"
27 27
28#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 0) 28#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 3)
29static const char version[] = "2.1.0"; 29static const char version[] = "2.1.3";
30 30
31MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 31MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
32MODULE_DESCRIPTION("GSPCA USB Conexant Camera Driver"); 32MODULE_DESCRIPTION("GSPCA USB Conexant Camera Driver");
@@ -114,21 +114,29 @@ static void reg_r(struct usb_device *dev,
114 0, 114 0,
115 index, buffer, length, 115 index, buffer, length,
116 500); 116 500);
117 PDEBUG(D_USBI, "reg read i:%02x -> %02x", index, *buffer); 117 PDEBUG(D_USBI, "reg read [%02x] -> %02x ..", index, *buffer);
118} 118}
119 119
120static void reg_w(struct usb_device *dev, 120static void reg_w(struct usb_device *dev,
121 __u16 index, 121 __u16 index,
122 const __u8 *buffer, __u16 length) 122 const __u8 *buffer, __u16 len)
123{ 123{
124 PDEBUG(D_USBO, "reg write i:%02x = %02x", index, *buffer); 124 __u8 tmpbuf[8];
125
126#ifdef CONFIG_VIDEO_ADV_DEBUG
127 if (len > sizeof tmpbuf) {
128 PDEBUG(D_ERR|D_PACK, "reg_w: buffer overflow");
129 return;
130 }
131 PDEBUG(D_USBO, "reg write [%02x] = %02x..", index, *buffer);
132#endif
133 memcpy(tmpbuf, buffer, len);
125 usb_control_msg(dev, 134 usb_control_msg(dev,
126 usb_sndctrlpipe(dev, 0), 135 usb_sndctrlpipe(dev, 0),
127 0, 136 0,
128 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 137 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
129 0, 138 0,
130 index, (__u8 *) buffer, length, 139 index, tmpbuf, len, 500);
131 500);
132} 140}
133 141
134static const __u8 cx_sensor_init[][4] = { 142static const __u8 cx_sensor_init[][4] = {
@@ -269,7 +277,7 @@ static void cx_sensor(struct gspca_dev*gspca_dev)
269 reg_w(gspca_dev->dev, 0x0071, reg71b, 4); 277 reg_w(gspca_dev->dev, 0x0071, reg71b, 4);
270 break; 278 break;
271 default: 279 default:
272/* case 2: */ 280/* case 2: */
273 reg_w(gspca_dev->dev, 0x0071, reg71c, 4); 281 reg_w(gspca_dev->dev, 0x0071, reg71c, 4);
274 break; 282 break;
275 case 3: 283 case 3:
@@ -662,8 +670,7 @@ static void cx11646_jpeg(struct gspca_dev*gspca_dev)
662 for (i = 0; i < 27; i++) { 670 for (i = 0; i < 27; i++) {
663 if (i == 26) 671 if (i == 26)
664 length = 2; 672 length = 2;
665 reg_w(gspca_dev->dev, 0x0008, 673 reg_w(gspca_dev->dev, 0x0008, cxjpeg_640[i], length);
666 cxjpeg_640[i], length);
667 } 674 }
668 Reg55 = 0x28; 675 Reg55 = 0x28;
669 break; 676 break;
@@ -671,8 +678,7 @@ static void cx11646_jpeg(struct gspca_dev*gspca_dev)
671 for (i = 0; i < 27; i++) { 678 for (i = 0; i < 27; i++) {
672 if (i == 26) 679 if (i == 26)
673 length = 2; 680 length = 2;
674 reg_w(gspca_dev->dev, 0x0008, 681 reg_w(gspca_dev->dev, 0x0008, cxjpeg_352[i], length);
675 cxjpeg_352[i], length);
676 } 682 }
677 Reg55 = 0x16; 683 Reg55 = 0x16;
678 break; 684 break;
@@ -681,8 +687,7 @@ static void cx11646_jpeg(struct gspca_dev*gspca_dev)
681 for (i = 0; i < 27; i++) { 687 for (i = 0; i < 27; i++) {
682 if (i == 26) 688 if (i == 26)
683 length = 2; 689 length = 2;
684 reg_w(gspca_dev->dev, 0x0008, 690 reg_w(gspca_dev->dev, 0x0008, cxjpeg_320[i], length);
685 cxjpeg_320[i], length);
686 } 691 }
687 Reg55 = 0x14; 692 Reg55 = 0x14;
688 break; 693 break;
@@ -690,8 +695,7 @@ static void cx11646_jpeg(struct gspca_dev*gspca_dev)
690 for (i = 0; i < 27; i++) { 695 for (i = 0; i < 27; i++) {
691 if (i == 26) 696 if (i == 26)
692 length = 2; 697 length = 2;
693 reg_w(gspca_dev->dev, 0x0008, 698 reg_w(gspca_dev->dev, 0x0008, cxjpeg_176[i], length);
694 cxjpeg_176[i], length);
695 } 699 }
696 Reg55 = 0x0B; 700 Reg55 = 0x0B;
697 break; 701 break;
@@ -731,8 +735,7 @@ static void cx11646_jpeg(struct gspca_dev*gspca_dev)
731 for (i = 0; i < 18; i++) { 735 for (i = 0; i < 18; i++) {
732 if (i == 17) 736 if (i == 17)
733 length = 2; 737 length = 2;
734 reg_w(gspca_dev->dev, 0x0008, 738 reg_w(gspca_dev->dev, 0x0008, cxjpeg_qtable[i], length);
735 cxjpeg_qtable[i], length);
736 739
737 } 740 }
738 reg_r(gspca_dev->dev, 0x0002, &val, 1); /* 0x00 */ 741 reg_r(gspca_dev->dev, 0x0002, &val, 1); /* 0x00 */
@@ -866,7 +869,7 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
866 reg_w(gspca_dev->dev, 0x0053, &val, 1); 869 reg_w(gspca_dev->dev, 0x0053, &val, 1);
867 870
868 while (retry--) { 871 while (retry--) {
869/* reg_r (gspca_dev->dev,0x00,0x00,0x0002,&val,1);*/ 872/* reg_r(gspca_dev->dev, 0x0002, &val, 1);*/
870 reg_r(gspca_dev->dev, 0x0053, &val, 1); 873 reg_r(gspca_dev->dev, 0x0053, &val, 1);
871 if (val == 0) 874 if (val == 0)
872 break; 875 break;