V4L: stk11xx, add a new webcam driver
PATCH 1/1 V4L: stk11xx, add a new webcam driver
Hi,
is it possible to have this driver in the -mm tree for testing purposes until v4l library will be developped and image resize with bayer->rgb conversion will be moved there? (Then, I'll push it through v4l people.)
--
stk11xx, add a new webcam driver
Adds support for stk1125, stk1135 and stkdcnew webcam built-in some notebooks.
---
commit 926af968884e1e153ad2f91892ff71ec33005d22
tree f7d30907d7bd11128cd8f75a0aa2f3873c237980
parent c1b003cd9e5befbc3d915a9e37f46585127f9d1f
author Jiri Slaby <[email protected]> Sun, 26 Aug 2007 16:02:31 +0200 committer Jiri Slaby <[email protected]> Sun, 26 Aug 2007 16:02:31 +0200
MAINTAINERS | 5 drivers/media/video/Kconfig | 9 drivers/media/video/Makefile | 4 drivers/media/video/stk1125.c | 667 +++++++++++++++++++++++++ drivers/media/video/stk1135.c | 549 +++++++++++++++++++++ drivers/media/video/stk11xx-core.c | 962 ++++++++++++++++++++++++++++++++++++ drivers/media/video/stk11xx-v4l.c | 790 ++++++++++++++++++++++++++++++ drivers/media/video/stk11xx.h | 217 ++++++++ drivers/media/video/stkdcnew.c | 669 +++++++++++++++++++++++++ 9 files changed, 3872 insertions(+), 0 deletions(-)
MAINTAINERS +5 -0
@@ -3525,6 +3525,11 @@ M: [email protected] L: [email protected] S: Maintained +STK11XX WEBCAM DRIVER +P: Jiri Slaby +M: [email protected] +S: Maintained + TPM DEVICE DRIVER P: Kylene Hall M: [email protected]
drivers/media/video/Kconfig +9 -0
@@ -809,6 +809,15 @@ config USB_ZR364XX To compile this driver as a module, choose M here: the module will be called zr364xx. +config USB_STK11XX + tristate "Syntek chip based webcams" + depends on VIDEO_V4L2 + ---help--- + This will add support for Syntek webcams such as dc1125, stk1135 and + DC NEW. Some notebooks have these cards built-in in their displays. + + If you choose to build this as module, it will be called stk11xx. + endif # V4L_USB_DRIVERS endif # VIDEO_CAPTURE_DRIVERS
drivers/media/video/Makefile +4 -0
@@ -6,6 +6,8 @@ zr36067-objs := zoran_procfs.o zoran_device.o \ zoran_driver.o zoran_card.o tuner-objs := tuner-core.o tuner-types.o tuner-simple.o \ mt20xx.o tda8290.o tea5767.o tda9887.o +stk11xx-objs := stk11xx-core.o stk11xx-v4l.o stk1125.o stk1135.o \ + stkdcnew.o tuner-$(CONFIG_TUNER_TEA5761) += tea5761.o
@@ -107,6 +109,8 @@ obj-$(CONFIG_USB_STV680) += stv680.o obj-$(CONFIG_USB_W9968CF) += w9968cf.o obj-$(CONFIG_USB_ZR364XX) += zr364xx.o +obj-$(CONFIG_USB_STK11XX) += stk11xx.o + obj-$(CONFIG_USB_SN9C102) += sn9c102/ obj-$(CONFIG_USB_ET61X251) += et61x251/ obj-$(CONFIG_USB_PWC) += pwc/
drivers/media/video/stk1125.c new file +667 -0
667 lines not on this page · raw message
drivers/media/video/stk1135.c new file +549 -0
549 lines not on this page · raw message
drivers/media/video/stk11xx-core.c new file +962 -0
962 lines not on this page · raw message
drivers/media/video/stk11xx-v4l.c new file +790 -0
780 lines not on this page · raw message
drivers/media/video/stk11xx.h new file +217 -0
217 lines not on this page · raw message
drivers/media/video/stkdcnew.c new file +669 -0
669 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Quoted 69 lines · On Sun, 26 Aug 2007 07:09:02 -0700 Jiri Slaby <[email protected]> wrote:
Hi,
is it possible to have this driver in the -mm tree for testing purposes until v4l library will be developped and image resize with
bayer->rgbconversion will be moved there? (Then, I'll push it through v4l people.)--
stk11xx, add a new webcam driverAdds support for stk1125, stk1135 and stkdcnew webcam built-in some notebooks.
...
drivers/media/video/stk1125.c new file +52
-0@@ -0,0 +1,667 @@ +/* +* STK-1125 part +* +* Copyright (c) 2007 Jiri Slaby <[email protected]> +* +* Based on Nicolas VIVIEN's driver +* +* Licences +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +*/ + +#include <linux/usb.h> +#include <linux/types.h> + +#include "stk11xx.h" + +static int stk1125_load_microcode (struct stk11xx *dev) +{ +unsigned int i; +const u8 *values_204, *values_205; +int retok; + +/* From 80x60 to 640x480 */ +const u8 values_1_204[] = { +0x12 ,0x11 ,0x3b ,0x6a ,0x13 ,0x10 ,0x00 ,0x01 ,0x02 ,0x13 , +0x39 ,0x38 ,0x37 ,0x35 ,0x0e ,0x12 ,0x04 ,0x0c ,0x0d ,0x17 , +0x18 ,0x32 ,0x19 ,0x1a ,0x03 ,0x1b ,0x16 ,0x33 ,0x34 ,0x41 , +0x96 ,0x3d ,0x69 ,0x3a ,0x8e ,0x3c ,0x8f ,0x8b ,0x8c ,0x94 , +0x95 ,0x40 ,0x29 ,0x0f ,0xa5 ,0x1e ,0xa9 ,0xaa ,0xab ,0x90 , +0x91 ,0x9f ,0xa0 ,0x24 ,0x25 ,0x26 ,0x14 ,0x2a ,0x2b + }; +const u8 values_1_205[] = { +0x45 ,0x80 ,0x01 ,0x7d ,0x80 ,0x00 ,0x00 ,0x80 ,0x80 ,0x80 , +0x50 ,0x93 ,0x00 ,0x81 ,0x20 ,0x45 ,0x00 ,0x00 ,0x00 ,0x24 , +0xc4 ,0xb6 ,0x00 ,0x3c ,0x36 ,0x00 ,0x07 ,0xe2 ,0xbf ,0x00 , +0x04 ,0x19 ,0x40 ,0x0d ,0x00 ,0x73 ,0xdf ,0x06 ,0x20 ,0x88 , +0x88 ,0xc1 ,0x3f ,0x42 ,0x80 ,0x04 ,0xb8 ,0x92 ,0x0a ,0x00 , +0x00 ,0x00 ,0x00 ,0x68 ,0x5c ,0xc3 ,0x2e ,0x00 ,0x00 + }; + +/* From 800x600 to 1280x1024 */ +const u8 values_2_204[] = { +0x12 ,0x11 ,0x3b ,0x6a ,0x13 ,0x10 ,0x00 ,0x01 ,0x02 ,0x13 , +0x39 ,0x38 ,0x37 ,0x35 ,0x0e ,0x12 ,0x04 ,0x0c ,0x0d ,0x17 , +0x18 ,0x32 ,0x19 ,0x1a ,0x03 ,0x1b ,0x16 ,0x33 ,0x34 ,0x41 , +0x96 ,0x3d ,0x69 ,0x3a ,0x8e ,0x3c ,0x8f ,0x8b ,0x8c ,0x94 , +0x95 ,0x40 ,0x29 ,0x0f ,0xa5 ,0x1e ,0xa9 ,0xaa ,0xab ,0x90 ,
drivers/media/video/stk1125.c line 62
Quoted 10 lines
drivers/media/video/stk1125.c new file +10
-0+0x91 ,0x9f ,0xa0 ,0x24 ,0x25 ,0x26 ,0x14 ,0x2a ,0x2b + }; +const u8 values_2_205[] = { +0x05 ,0x80 ,0x01 ,0x7d ,0x80 ,0x00 ,0x00 ,0x80 ,0x80 ,0x80 , +0x50 ,0x93 ,0x00 ,0x81 ,0x20 ,0x05 ,0x00 ,0x00 ,0x00 ,0x1b , +0xbb ,0xa4 ,0x01 ,0x81 ,0x12 ,0x00 ,0x07 ,0xe2 ,0xbf ,0x00 , +0x04 ,0x19 ,0x40 ,0x0d ,0x00 ,0x73 ,0xdf ,0x06 ,0x20 ,0x88 , +0x88 ,0xc1 ,0x3f ,0x42 ,0x80 ,0x04 ,0xb8 ,0x92 ,0x0a ,0x00 , +0x00 ,0x00 ,0x00 ,0x68 ,0x5c ,0xc3 ,0x2e ,0x00 ,0x00 + };
hm, OK, it seems that even though we've asked the compiler to build these arrays on the stack at runtime it will, as an optimisation, create static storage for them due to the `const'. I don't know that the compielr _has_ to do that, nor do I know if all versions of gcc and other compilers will also do this.
Perhaps it would be safer to put the `static' in there? There are many such sites.
Quoted 10 lines
drivers/media/video/stk1125.c new file +10
-0+/* From the resolution */ +switch (dev->resolution) { +case STK11XX_1280x1024: +case STK11XX_1024x768: +case STK11XX_800x600: + values_204 = values_2_204; + values_205 = values_2_205; +break ; + +case STK11XX_640x480:
drivers/media/video/stk1125.c line 83
Quoted 10 lines
drivers/media/video/stk1125.c new file +10
-0+case STK11XX_320x240: +case STK11XX_160x120: +case STK11XX_80x60: +default : + values_204 = values_1_204; + values_205 = values_1_205; +break ; + } + +for (i =0 ; i <59 ; i++) {
ARRAY_SIZE would be nice, if only for clarity..
+ retok = stk11xx_check_device(dev, 500);
+ if (retok != 1) {
+ dev_err(&dev->udev->dev, "load microcode fail\n");
+ return -EIO;
+ }
Normally we'd use a return value of zero to indicate success. So that the negative return value can tell people _why_ it failed.
Quoted 22 lines
drivers/media/video/stk1125.c new file +22
-0+ +for (i =0 ; i <16 ; i++) { +stk11xx_write_reg (dev,0x0000 ,0x25 ); +stk11xx_write_reg (dev,0x0000 ,0x24 ); +stk11xx_read_reg (dev,0x0000 , &value); + +dev_dbg (&dev->udev->dev,"Loop 1: Read 0x0000 = %02x\n" , value); + } + + ret =stk11xx_process_table (dev, table_2); +if (ret) + goto end; + +for (i =0 ; i <16 ; i++) { +stk11xx_write_reg (dev,0x0000 ,0x25 ); +stk11xx_write_reg (dev,0x0000 ,0x24 ); +stk11xx_read_reg (dev,0x0000 , &value); + +dev_dbg (&dev->udev->dev,"Loop 2: Read 0x0000 = %02x\n" , value); + } + + ret =stk11xx_process_table (dev, table_3);
drivers/media/video/stk1125.c line 642
Quoted 10 lines
drivers/media/video/stk1125.c new file +10
-0+if (ret) + goto end; + +for (i =0 ; i <16 ; i++) { +stk11xx_write_reg (dev,0x0000 ,0x25 ); +stk11xx_write_reg (dev,0x0000 ,0x24 ); +stk11xx_read_reg (dev,0x0000 , &value); + +dev_dbg (&dev->udev->dev,"Loop 3: Read 0x0000 = %02x\n" , value); + }
Again, ARRAY_SIZE() would be clearer here.
Quoted 8 lines
drivers/media/video/stk1125.c new file +8
-0+ ret =stk11xx_process_table (dev, table_4); +if (ret) + goto end; + +stk1125_cam_asleep (dev); + +stk11xx_set_feature (dev,0 ); +
drivers/media/video/stk1125.c
Quoted 10 lines
drivers/media/video/stk1125.c new file +7
-0+end: +return ret; +} + + }; + +for (i =0 ; i <117 ; i++) {
lots of places..
Andrew Morton napsal(a):
Quoted 10 lines
On Sun, 26 Aug 2007 07:09:02 -0700
Jiri Slaby <[email protected]> wrote:drivers/media/video/stk1125.c new file +5
-0+ retok =stk11xx_check_device (dev,500 ); +if (retok !=1 ) { +dev_err (&dev->udev->dev,"load microcode fail\n" ); +return -EIO ; + }Normally we'd use a return value of zero to indicate success. So that the negative return value can tell people _why_ it failed.
it returns-EIO = fail
0 = we succeeded, but the device is not ready
1 = the device is OK
Seems proper to change the 0 -> EBUSY or something and 1 -> 0 anyway, if we check only for 1.
Quoted 26 lines
Quoted 26 lines
drivers/media/video/stk1125.c new file +26
-0+ +for (i =0 ; i <16 ; i++) { +stk11xx_write_reg (dev,0x0000 ,0x25 ); +stk11xx_write_reg (dev,0x0000 ,0x24 ); +stk11xx_read_reg (dev,0x0000 , &value); + +dev_dbg (&dev->udev->dev,"Loop 1: Read 0x0000 = %02x\n" , value); + } + + ret =stk11xx_process_table (dev, table_2); +if (ret) + goto end; + +for (i =0 ; i <16 ; i++) { +stk11xx_write_reg (dev,0x0000 ,0x25 ); +stk11xx_write_reg (dev,0x0000 ,0x24 ); +stk11xx_read_reg (dev,0x0000 , &value); + +dev_dbg (&dev->udev->dev,"Loop 2: Read 0x0000 = %02x\n" , value); + } + + ret =stk11xx_process_table (dev, table_3); +if (ret) + goto end; + +for (i =0 ; i <16 ; i++) {
Quoted 8 lines
drivers/media/video/stk1125.c line 642
Quoted 6 lines
drivers/media/video/stk1125.c new file +6
-0+stk11xx_write_reg (dev,0x0000 ,0x25 ); +stk11xx_write_reg (dev,0x0000 ,0x24 ); +stk11xx_read_reg (dev,0x0000 , &value); + +dev_dbg (&dev->udev->dev,"Loop 3: Read 0x0000 = %02x\n" , value); + }Again,
ARRAY_SIZE()would be clearer here.
No, this is only do this 16 times, no corresponding table :).
thanks for review,
Signature · 2 lines
Jiri Slaby ([email protected]) Faculty of Informatics, Masaryk University
Quoted 3 lines · On Tue, 28 Aug 2007 07:33:08 +0200 Jiri Slaby <[email protected]> wrote:
Quoted 1 line
Again,
ARRAY_SIZE()would be clearer here.No, this is only do this 16 times, no corresponding table :).
OK, poorly chosen example. But there are lots of others, like:
+
+ for (i = 0; i < 59; i++) {
+ stk11xx_read_dummy(dev, 0x02ff);
+ stk11xx_write_reg(dev, 0x02ff, 0x00);
+
+ stk11xx_write_reg(dev, 0x0204, values_204[i]);
+ stk11xx_write_reg(dev, 0x0205, values_205[i]);
Andrew Morton napsal(a):
Quoted 6 lines · On Tue, 28 Aug 2007 07:33:08 +0200 Jiri Slaby <[email protected]> wrote:
Quoted 3 lines
Quoted 2 lines
Again,
ARRAY_SIZE()would be clearer here.No, this is only do this 16 times, no corresponding table :).
OK, poorly chosen example. But there are lots of others, like:
Yes, you mentioned them further in the mail and I'm going to change those. I only commented this one to let you know, that it's not about to change (if you check it later).
thanks,
Signature · 2 lines
Jiri Slaby ([email protected]) Faculty of Informatics, Masaryk University
Quoted 25 lines · Jiri Slaby
drivers/media/video/stk1125.c new file +25
-0+/* From 80x60 to 640x480 */ +const u8 values_1_204[] = { +0x12 ,0x11 ,0x3b ,0x6a ,0x13 ,0x10 ,0x00 ,0x01 ,0x02 ,0x13 , +0x39 ,0x38 ,0x37 ,0x35 ,0x0e ,0x12 ,0x04 ,0x0c ,0x0d ,0x17 , +0x18 ,0x32 ,0x19 ,0x1a ,0x03 ,0x1b ,0x16 ,0x33 ,0x34 ,0x41 , +0x96 ,0x3d ,0x69 ,0x3a ,0x8e ,0x3c ,0x8f ,0x8b ,0x8c ,0x94 , +0x95 ,0x40 ,0x29 ,0x0f ,0xa5 ,0x1e ,0xa9 ,0xaa ,0xab ,0x90 , +0x91 ,0x9f ,0xa0 ,0x24 ,0x25 ,0x26 ,0x14 ,0x2a ,0x2b + }; +const u8 values_1_205[] = { +0x45 ,0x80 ,0x01 ,0x7d ,0x80 ,0x00 ,0x00 ,0x80 ,0x80 ,0x80 , +0x50 ,0x93 ,0x00 ,0x81 ,0x20 ,0x45 ,0x00 ,0x00 ,0x00 ,0x24 , +0xc4 ,0xb6 ,0x00 ,0x3c ,0x36 ,0x00 ,0x07 ,0xe2 ,0xbf ,0x00 , +0x04 ,0x19 ,0x40 ,0x0d ,0x00 ,0x73 ,0xdf ,0x06 ,0x20 ,0x88 , +0x88 ,0xc1 ,0x3f ,0x42 ,0x80 ,0x04 ,0xb8 ,0x92 ,0x0a ,0x00 , +0x00 ,0x00 ,0x00 ,0x68 ,0x5c ,0xc3 ,0x2e ,0x00 ,0x00 + }; + +/* From 800x600 to 1280x1024 */ +const u8 values_2_204[] = { +0x12 ,0x11 ,0x3b ,0x6a ,0x13 ,0x10 ,0x00 ,0x01 ,0x02 ,0x13 , +0x39 ,0x38 ,0x37 ,0x35 ,0x0e ,0x12 ,0x04 ,0x0c ,0x0d ,0x17 , +0x18 ,0x32 ,0x19 ,0x1a ,0x03 ,0x1b ,0x16 ,0x33 ,0x34 ,0x41 , +0x96 ,0x3d ,0x69 ,0x3a ,0x8e ,0x3c ,0x8f ,0x8b ,0x8c ,0x94 , +0x95 ,0x40 ,0x29 ,0x0f ,0xa5 ,0x1e ,0xa9 ,0xaa ,0xab ,0x90 ,
drivers/media/video/stk1125.c line 62
Quoted 10 lines
drivers/media/video/stk1125.c new file +10
-0+0x91 ,0x9f ,0xa0 ,0x24 ,0x25 ,0x26 ,0x14 ,0x2a ,0x2b + }; +const u8 values_2_205[] = { +0x05 ,0x80 ,0x01 ,0x7d ,0x80 ,0x00 ,0x00 ,0x80 ,0x80 ,0x80 , +0x50 ,0x93 ,0x00 ,0x81 ,0x20 ,0x05 ,0x00 ,0x00 ,0x00 ,0x1b , +0xbb ,0xa4 ,0x01 ,0x81 ,0x12 ,0x00 ,0x07 ,0xe2 ,0xbf ,0x00 , +0x04 ,0x19 ,0x40 ,0x0d ,0x00 ,0x73 ,0xdf ,0x06 ,0x20 ,0x88 , +0x88 ,0xc1 ,0x3f ,0x42 ,0x80 ,0x04 ,0xb8 ,0x92 ,0x0a ,0x00 , +0x00 ,0x00 ,0x00 ,0x68 ,0x5c ,0xc3 ,0x2e ,0x00 ,0x00 + };
How does one derive these values? At least Debian kernel people will remove your driver from their tree because of this unexplained binary blob.
Quoted 1 line
+ * We don't know the meaning of these steps! We only replay the USB log.
Maybe it is a good idea to convert this blob, as well as others, into a firmware request.
Signature · 1 line
Alexander E. Patrakov
Quoted 4 lines · On Sun, 26 Aug 2007 07:09:02 -0700 Jiri Slaby <[email protected]> wrote:
stk11xx, add a new webcam driver
Adds support for stk1125, stk1135 and stkdcnew webcam built-in some notebooks.
Seem that something in git-dvb (or mainline) broke this driver:
drivers/media/video/stk11xx-core.c: In function 'show_contrast':drivers/media/video/stk11xx-core.c:707: warning: initialization from incompatible pointer type drivers/media/video/stk11xx-core.c: In function 'show_whitebalance':drivers/media/video/stk11xx-core.c:714: warning: initialization from incompatible pointer type drivers/media/video/stk11xx-core.c: In function 'stk11xx_create_sysfs_file':drivers/media/video/stk11xx-core.c:727: warning: passing argument 1 of 'class_device_create_file' from incompatible pointer type drivers/media/video/stk11xx-core.c: In function 'stk11xx_usb_disconnect':drivers/media/video/stk11xx-core.c:851: warning: passing argument 1 of 'class_device_remove_file' from incompatible pointer type drivers/media/video/stk11xx-core.c:853: warning: passing argument 1 of 'class_device_remove_file' from incompatible pointer type
Also, please ask the v4l/dvb guys to look at this driver - there's not a lot of point in sending it just to me.
Andrew Morton napsal(a):
Quoted 19 lines · On Sun, 26 Aug 2007 07:09:02 -0700 Jiri Slaby <[email protected]> wrote:
Quoted 5 lines
stk11xx, add a new webcam driver
Adds support for stk1125, stk1135 and stkdcnew webcam built-in some notebooks.
Seem that something in git-dvb (or mainline) broke this driver:
drivers/media/video/stk11xx-core.c: In function 'show_contrast':drivers/media/video/stk11xx-core.c:707: warning: initialization from incompatible pointer typedrivers/media/video/stk11xx-core.c: In function 'show_whitebalance':drivers/media/video/stk11xx-core.c:714: warning: initialization from incompatible pointer typedrivers/media/video/stk11xx-core.c: In function 'stk11xx_create_sysfs_file':drivers/media/video/stk11xx-core.c:727: warning: passing argument 1 of 'class_device_create_file' from incompatible pointer typedrivers/media/video/stk11xx-core.c: In function 'stk11xx_usb_disconnect':drivers/media/video/stk11xx-core.c:851: warning: passing argument 1 of 'class_device_remove_file' from incompatible pointer typedrivers/media/video/stk11xx-core.c:853: warning: passing argument 1 of 'class_device_remove_file' from incompatible pointer type
Quoted 2 lines
Also, please ask the v4l/dvb guys to look at this driver - there's not a lot of point in sending it just to me.
Dvb fellows reviewed it some time ago, but the problem is, that it converts one color space to another in kernelspace. We are developping an userspace library for drivers such this one, but it takes longer than I expect. Lets have it dropped, after the library will be done I'll merge it through v4l tree.
thanks,
Signature · 2 lines
http://www.fi.muni.cz/~xslaby/ Jiri Slaby faculty of informatics, masaryk university, brno, cz
Quoted 12 lines
Quoted 12 lines
Seem that something in git-dvb (or mainline) broke this driver:
drivers/media/video/stk11xx-core.c: In function 'show_contrast':drivers/media/video/stk11xx-core.c:707: warning: initialization from incompatible pointer typedrivers/media/video/stk11xx-core.c: In function 'show_whitebalance':drivers/media/video/stk11xx-core.c:714: warning: initialization from incompatible pointer typedrivers/media/video/stk11xx-core.c: In function 'stk11xx_create_sysfs_file':drivers/media/video/stk11xx-core.c:727: warning: passing argument 1 of 'class_device_create_file' from incompatible pointer typedrivers/media/video/stk11xx-core.c: In function 'stk11xx_usb_disconnect':drivers/media/video/stk11xx-core.c:851: warning: passing argument 1 of 'class_device_remove_file' from incompatible pointer typedrivers/media/video/stk11xx-core.c:853: warning: passing argument 1 of 'class_device_remove_file' from incompatible pointer type
Those breakages were caused by some changes at sysfs that happened in mainstream.
Quoted 7 lines
Quoted 2 lines
Also, please ask the v4l/dvb guys to look at this driver - there's not a lot of point in sending it just to me.
Dvb fellows reviewed it some time ago, but the problem is, that it converts one color space to another in kernelspace. We are developping an userspace library for drivers such this one, but it takes longer than I expect. Lets have it dropped, after the library will be done I'll merge it through v4l tree.
Seems the proper way also to me.
Signature · 2 lines
Cheers, Mauro