aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-01-29 15:22:04 -0500
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-01-29 15:25:02 -0500
commit2c794075d420f22ba4280f46ac7d43be0acb3e95 (patch)
tree2c14237e98ae7404352bab718e4c13d214d3403f
parent7cc42d9f75766246faab4a1436eb02b97041fb41 (diff)
[media] gspca/touptek: Fix a few CodingStyle issues
Checkpatch complained about a few issues, like FSF address. Also, multi-line comments are not following the Kernel CodingStyle. While not too late, let's fix those issues. Cc: John McMaster <johndmcmaster@gmail.com> Cc: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r--drivers/media/usb/gspca/touptek.c221
1 files changed, 110 insertions, 111 deletions
diff --git a/drivers/media/usb/gspca/touptek.c b/drivers/media/usb/gspca/touptek.c
index 8b7c01e4b772..7bac6bc96063 100644
--- a/drivers/media/usb/gspca/touptek.c
+++ b/drivers/media/usb/gspca/touptek.c
@@ -17,10 +17,6 @@
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details. 19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */ 20 */
25 21
26#include "gspca.h" 22#include "gspca.h"
@@ -32,80 +28,80 @@ MODULE_DESCRIPTION("ToupTek UCMOS / Amscope MU microscope camera driver");
32MODULE_LICENSE("GPL"); 28MODULE_LICENSE("GPL");
33 29
34/* 30/*
35Exposure reg is linear with exposure time 31 * Exposure reg is linear with exposure time
36Exposure (sec), E (reg) 32 * Exposure (sec), E (reg)
370.000400, 0x0002 33 * 0.000400, 0x0002
380.001000, 0x0005 34 * 0.001000, 0x0005
390.005000, 0x0019 35 * 0.005000, 0x0019
400.020000, 0x0064 36 * 0.020000, 0x0064
410.080000, 0x0190 37 * 0.080000, 0x0190
420.400000, 0x07D0 38 * 0.400000, 0x07D0
431.000000, 0x1388 39 * 1.000000, 0x1388
442.000000, 0x2710 40 * 2.000000, 0x2710
45 41 *
46Three gain stages 42 * Three gain stages
470x1000: master channel enable bit 43 * 0x1000: master channel enable bit
480x007F: low gain bits 44 * 0x007F: low gain bits
490x0080: medium gain bit 45 * 0x0080: medium gain bit
500x0100: high gain bit 46 * 0x0100: high gain bit
51gain = enable * (1 + regH) * (1 + regM) * z * regL 47 * gain = enable * (1 + regH) * (1 + regM) * z * regL
52 48 *
53Gain implementation 49 * Gain implementation
54Want to do something similar to mt9v011.c's set_balance 50 * Want to do something similar to mt9v011.c's set_balance
55 51 *
56Gain does not vary with resolution (checked 640x480 vs 1600x1200) 52 * Gain does not vary with resolution (checked 640x480 vs 1600x1200)
57 53 *
58Constant derivation: 54 * Constant derivation:
59 55 *
60Raw data: 56 * Raw data:
61Gain, GTOP, B, R, GBOT 57 * Gain, GTOP, B, R, GBOT
621.00, 0x105C, 0x1068, 0x10C8, 0x105C 58 * 1.00, 0x105C, 0x1068, 0x10C8, 0x105C
631.20, 0x106E, 0x107E, 0x10D6, 0x106E 59 * 1.20, 0x106E, 0x107E, 0x10D6, 0x106E
641.40, 0x10C0, 0x10CA, 0x10E5, 0x10C0 60 * 1.40, 0x10C0, 0x10CA, 0x10E5, 0x10C0
651.60, 0x10C9, 0x10D4, 0x10F3, 0x10C9 61 * 1.60, 0x10C9, 0x10D4, 0x10F3, 0x10C9
661.80, 0x10D2, 0x10DE, 0x11C1, 0x10D2 62 * 1.80, 0x10D2, 0x10DE, 0x11C1, 0x10D2
672.00, 0x10DC, 0x10E9, 0x11C8, 0x10DC 63 * 2.00, 0x10DC, 0x10E9, 0x11C8, 0x10DC
682.20, 0x10E5, 0x10F3, 0x11CF, 0x10E5 64 * 2.20, 0x10E5, 0x10F3, 0x11CF, 0x10E5
692.40, 0x10EE, 0x10FE, 0x11D7, 0x10EE 65 * 2.40, 0x10EE, 0x10FE, 0x11D7, 0x10EE
702.60, 0x10F7, 0x11C4, 0x11DE, 0x10F7 66 * 2.60, 0x10F7, 0x11C4, 0x11DE, 0x10F7
712.80, 0x11C0, 0x11CA, 0x11E5, 0x11C0 67 * 2.80, 0x11C0, 0x11CA, 0x11E5, 0x11C0
723.00, 0x11C5, 0x11CF, 0x11ED, 0x11C5 68 * 3.00, 0x11C5, 0x11CF, 0x11ED, 0x11C5
73 69 *
74zR = 0.0069605943152454778 70 * zR = 0.0069605943152454778
75 about 3/431 = 0.0069605568445475635 71 * about 3/431 = 0.0069605568445475635
76zB = 0.0095695970695970703 72 * zB = 0.0095695970695970703
77 about 6/627 = 0.0095693779904306216 73 * about 6/627 = 0.0095693779904306216
78zG = 0.010889328063241107 74 * zG = 0.010889328063241107
79 about 6/551 = 0.010889292196007259 75 * about 6/551 = 0.010889292196007259
80about 10 bits for constant + 7 bits for value => at least 17 bit intermediate 76 * about 10 bits for constant + 7 bits for value => at least 17 bit
81with 32 bit ints should be fine for overflow etc 77 * intermediate with 32 bit ints should be fine for overflow etc
82Essentially gains are in range 0-0x001FF 78 * Essentially gains are in range 0-0x001FF
83 79 *
84However, V4L expects a main gain channel + R and B balance 80 * However, V4L expects a main gain channel + R and B balance
85To keep things simple for now saturate the values of balance is too high/low 81 * To keep things simple for now saturate the values of balance is too high/low
86This isn't really ideal but easy way to fit the Linux model 82 * This isn't really ideal but easy way to fit the Linux model
87 83 *
88Converted using gain model turns out to be quite linear: 84 * Converted using gain model turns out to be quite linear:
89Gain, GTOP, B, R, GBOT 85 * Gain, GTOP, B, R, GBOT
901.00, 92, 104, 144, 92 86 * 1.00, 92, 104, 144, 92
911.20, 110, 126, 172, 110 87 * 1.20, 110, 126, 172, 110
921.40, 128, 148, 202, 128 88 * 1.40, 128, 148, 202, 128
931.60, 146, 168, 230, 146 89 * 1.60, 146, 168, 230, 146
941.80, 164, 188, 260, 164 90 * 1.80, 164, 188, 260, 164
952.00, 184, 210, 288, 184 91 * 2.00, 184, 210, 288, 184
962.20, 202, 230, 316, 202 92 * 2.20, 202, 230, 316, 202
972.40, 220, 252, 348, 220 93 * 2.40, 220, 252, 348, 220
982.60, 238, 272, 376, 238 94 * 2.60, 238, 272, 376, 238
992.80, 256, 296, 404, 256 95 * 2.80, 256, 296, 404, 256
1003.00, 276, 316, 436, 276 96 * 3.00, 276, 316, 436, 276
101 97 *
102Maximum gain is 0x7FF * 2 * 2 => 0x1FFC (8188) 98 * Maximum gain is 0x7FF * 2 * 2 => 0x1FFC (8188)
103or about 13 effective bits of gain 99 * or about 13 effective bits of gain
104The highest the commercial driver goes in my setup 436 100 * The highest the commercial driver goes in my setup 436
105However, because could *maybe* damage circuits 101 * However, because could *maybe* damage circuits
106limit the gain until have a reason to go higher 102 * limit the gain until have a reason to go higher
107Solution: gain clipped and warning emitted 103 * Solution: gain clipped and warning emitted
108*/ 104 */
109#define GAIN_MAX 511 105#define GAIN_MAX 511
110 106
111/* Frame sync is a short read */ 107/* Frame sync is a short read */
@@ -189,9 +185,9 @@ static const struct v4l2_pix_format vga_mode[] = {
189}; 185};
190 186
191/* 187/*
192As theres no known frame sync, the only way to keep synced is to try hard 188 * As theres no known frame sync, the only way to keep synced is to try hard
193to never miss any packets 189 * to never miss any packets
194*/ 190 */
195#if MAX_NURBS < 4 191#if MAX_NURBS < 4
196#error "Not enough URBs in the gspca table" 192#error "Not enough URBs in the gspca table"
197#endif 193#endif
@@ -218,7 +214,8 @@ static void reg_w(struct gspca_dev *gspca_dev, u16 value, u16 index)
218 char buff[1]; 214 char buff[1];
219 int rc; 215 int rc;
220 216
221 PDEBUG(D_USBO, "reg_w bReq=0x0B, bReqT=0xC0, wVal=0x%04X, wInd=0x%04X\n", 217 PDEBUG(D_USBO,
218 "reg_w bReq=0x0B, bReqT=0xC0, wVal=0x%04X, wInd=0x%04X\n",
222 value, index); 219 value, index);
223 rc = usb_control_msg(gspca_dev->dev, usb_rcvctrlpipe(gspca_dev->dev, 0), 220 rc = usb_control_msg(gspca_dev->dev, usb_rcvctrlpipe(gspca_dev->dev, 0),
224 0x0B, 0xC0, value, index, buff, 1, 500); 221 0x0B, 0xC0, value, index, buff, 1, 500);
@@ -271,11 +268,11 @@ static void setexposure(struct gspca_dev *gspca_dev, s32 val)
271static int gainify(int in) 268static int gainify(int in)
272{ 269{
273 /* 270 /*
274 TODO: check if there are any issues with corner cases 271 * TODO: check if there are any issues with corner cases
275 0x000 (0):0x07F (127): regL 272 * 0x000 (0):0x07F (127): regL
276 0x080 (128) - 0x0FF (255): regM, regL 273 * 0x080 (128) - 0x0FF (255): regM, regL
277 0x100 (256) - max: regH, regM, regL 274 * 0x100 (256) - max: regH, regM, regL
278 */ 275 */
279 if (in <= 0x7F) 276 if (in <= 0x7F)
280 return 0x1000 | in; 277 return 0x1000 | in;
281 else if (in <= 0xFF) 278 else if (in <= 0xFF)
@@ -446,18 +443,18 @@ static int configure(struct gspca_dev *gspca_dev)
446 PDEBUG(D_STREAM, "configure()\n"); 443 PDEBUG(D_STREAM, "configure()\n");
447 444
448 /* 445 /*
449 First driver sets a sort of encryption key 446 * First driver sets a sort of encryption key
450 A number of futur requests of this type have wValue and wIndex encrypted 447 * A number of futur requests of this type have wValue and wIndex
451 as follows: 448 * encrypted as follows:
452 -Compute key = this wValue rotate left by 4 bits 449 * -Compute key = this wValue rotate left by 4 bits
453 (decrypt.py rotates right because we are decrypting) 450 * (decrypt.py rotates right because we are decrypting)
454 -Later packets encrypt packets by XOR'ing with key 451 * -Later packets encrypt packets by XOR'ing with key
455 XOR encrypt/decrypt is symmetrical 452 * XOR encrypt/decrypt is symmetrical
456 wValue, and wIndex are encrypted 453 * wValue, and wIndex are encrypted
457 bRequest is not and bRequestType is always 0xC0 454 * bRequest is not and bRequestType is always 0xC0
458 This allows resyncing if key is unknown? 455 * This allows resyncing if key is unknown?
459 By setting 0 we XOR with 0 and the shifting and XOR drops out 456 * By setting 0 we XOR with 0 and the shifting and XOR drops out
460 */ 457 */
461 rc = usb_control_msg(gspca_dev->dev, usb_rcvctrlpipe(gspca_dev->dev, 0), 458 rc = usb_control_msg(gspca_dev->dev, usb_rcvctrlpipe(gspca_dev->dev, 0),
462 0x16, 0xC0, 0x0000, 0x0000, buff, 2, 500); 459 0x16, 0xC0, 0x0000, 0x0000, buff, 2, 500);
463 if (val_reply(gspca_dev, buff, rc)) { 460 if (val_reply(gspca_dev, buff, rc)) {
@@ -466,13 +463,14 @@ static int configure(struct gspca_dev *gspca_dev)
466 } 463 }
467 464
468 /* 465 /*
469 Next does some sort of 2 packet challenge / response 466 * Next does some sort of 2 packet challenge / response
470 evidence suggests its an Atmel I2C crypto part but nobody cares to look 467 * evidence suggests its an Atmel I2C crypto part but nobody cares to
471 (to make sure its not cloned hardware?) 468 * look
472 Ignore: I want to work with their hardware, not clone it 469 * (to make sure its not cloned hardware?)
473 16 bytes out challenge, requestType: 0x40 470 * Ignore: I want to work with their hardware, not clone it
474 16 bytes in response, requestType: 0xC0 471 * 16 bytes out challenge, requestType: 0x40
475 */ 472 * 16 bytes in response, requestType: 0xC0
473 */
476 474
477 rc = usb_control_msg(gspca_dev->dev, usb_sndctrlpipe(gspca_dev->dev, 0), 475 rc = usb_control_msg(gspca_dev->dev, usb_sndctrlpipe(gspca_dev->dev, 0),
478 0x01, 0x40, 0x0001, 0x000F, NULL, 0, 500); 476 0x01, 0x40, 0x0001, 0x000F, NULL, 0, 500);
@@ -496,11 +494,12 @@ static int configure(struct gspca_dev *gspca_dev)
496 } 494 }
497 495
498 /* 496 /*
499 Serial number? Doesn't seem to be required 497 * Serial number? Doesn't seem to be required
500 cam1: \xE6\x0D\x00\x00, cam2: \x70\x19\x00\x00 498 * cam1: \xE6\x0D\x00\x00, cam2: \x70\x19\x00\x00
501 rc = usb_control_msg(gspca_dev->dev, usb_rcvctrlpipe(gspca_dev->dev, 0), 499 * rc = usb_control_msg(gspca_dev->dev,
502 0x20, 0xC0, 0x0000, 0x0000, buff, 4, 500); 500 * usb_rcvctrlpipe(gspca_dev->dev, 0),
503 */ 501 * 0x20, 0xC0, 0x0000, 0x0000, buff, 4, 500);
502 */
504 503
505 /* Large (EEPROM?) read, skip it since no idea what to do with it */ 504 /* Large (EEPROM?) read, skip it since no idea what to do with it */
506 gspca_dev->usb_err = 0; 505 gspca_dev->usb_err = 0;