Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

V4L/DVB (5585): SN9C1xx driver updates

* Default color improvements to the OV7660
@ Fix sn9c102_write_reg()
@ Fix sn9c102_i2c_try_raw_read()
@ Fix MI-0343
+ Add support for pair MI0360+SN9C120
+ Add more USB ids

Signed-off-by: Luca Risolia <luca.risolia@studio.unibo.it>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>

authored by

Luca Risolia and committed by
Mauro Carvalho Chehab
480b55c2 b3785596

+354 -233
+10 -8
Documentation/video4linux/sn9c102.txt
··· 355 355 356 356 Vendor ID Product ID 357 357 --------- ---------- 358 + 0x0458 0x7025 359 + 0x045e 0x00f5 360 + 0x045e 0x00f7 358 361 0x0471 0x0327 359 362 0x0471 0x0328 360 363 0x0c45 0x6001 ··· 435 432 HV7131D Hynix Semiconductor | Yes No No No 436 433 HV7131R Hynix Semiconductor | No Yes Yes Yes 437 434 MI-0343 Micron Technology | Yes No No No 438 - MI-0360 Micron Technology | No Yes No No 435 + MI-0360 Micron Technology | No Yes Yes Yes 439 436 OV7630 OmniVision Technologies | Yes Yes No No 440 437 OV7660 OmniVision Technologies | No No Yes Yes 441 438 PAS106B PixArt Imaging | Yes No No No ··· 481 478 This driver supports two different video formats: the first one is the "8-bit 482 479 Sequential Bayer" format and can be used to obtain uncompressed video data 483 480 from the device through the current I/O method, while the second one provides 484 - "raw" compressed video data (without frame headers not related to the 485 - compressed data). The compression quality may vary from 0 to 1 and can be 486 - selected or queried thanks to the VIDIOC_S_JPEGCOMP and VIDIOC_G_JPEGCOMP V4L2 487 - ioctl's. For maximum flexibility, both the default active video format and the 488 - default compression quality depend on how the image sensor being used is 489 - initialized (as described in the documentation of the API for the image sensors 490 - supplied by this driver). 481 + either "raw" compressed video data (without frame headers not related to the 482 + compressed data) or standard JPEG (with frame headers). The compression quality 483 + may vary from 0 to 1 and can be selected or queried thanks to the 484 + VIDIOC_S_JPEGCOMP and VIDIOC_G_JPEGCOMP V4L2 ioctl's. For maximum flexibility, 485 + both the default active video format and the default compression quality 486 + depend on how the image sensor being used is initialized. 491 487 492 488 493 489 11. Video frame formats [1]
+1 -1
drivers/media/video/sn9c102/sn9c102.h
··· 141 141 142 142 void 143 143 sn9c102_attach_sensor(struct sn9c102_device* cam, 144 - struct sn9c102_sensor* sensor) 144 + const struct sn9c102_sensor* sensor) 145 145 { 146 146 memcpy(&cam->sensor, sensor, sizeof(struct sn9c102_sensor)); 147 147 }
+42 -47
drivers/media/video/sn9c102/sn9c102_core.c
··· 48 48 #define SN9C102_MODULE_AUTHOR "(C) 2004-2007 Luca Risolia" 49 49 #define SN9C102_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>" 50 50 #define SN9C102_MODULE_LICENSE "GPL" 51 - #define SN9C102_MODULE_VERSION "1:1.39" 52 - #define SN9C102_MODULE_VERSION_CODE KERNEL_VERSION(1, 1, 39) 51 + #define SN9C102_MODULE_VERSION "1:1.44" 52 + #define SN9C102_MODULE_VERSION_CODE KERNEL_VERSION(1, 1, 44) 53 53 54 54 /*****************************************************************************/ 55 55 ··· 209 209 } 210 210 211 211 /*****************************************************************************/ 212 + 212 213 /* 213 - * Write a sequence of count value/register pairs. Returns -1 after the 214 - * first failed write, or 0 for no errors. 215 - */ 214 + Write a sequence of count value/register pairs. Returns -1 after the first 215 + failed write, or 0 for no errors. 216 + */ 216 217 int sn9c102_write_regs(struct sn9c102_device* cam, const u8 valreg[][2], 217 218 int count) 218 219 { 219 220 struct usb_device* udev = cam->usbdev; 220 - u8* value = cam->control_buffer; /* Needed for DMA'able memory */ 221 + u8* buff = cam->control_buffer; 221 222 int i, res; 222 223 223 224 for (i = 0; i < count; i++) { 224 225 u8 index = valreg[i][1]; 225 226 226 227 /* 227 - * index is a u8, so it must be <256 and can't be out of range. 228 - * If we put in a check anyway, gcc annoys us with a warning 229 - * that our check is useless. People get all uppity when they 230 - * see warnings in the kernel compile. 231 - */ 228 + index is a u8, so it must be <256 and can't be out of range. 229 + If we put in a check anyway, gcc annoys us with a warning 230 + hat our check is useless. People get all uppity when they 231 + see warnings in the kernel compile. 232 + */ 232 233 233 - *value = valreg[i][0]; 234 - res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 235 - 0x08, 0x41, index, 0, 236 - value, 1, SN9C102_CTRL_TIMEOUT); 234 + *buff = valreg[i][0]; 235 + 236 + res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 237 + 0x41, index, 0, buff, 1, 238 + SN9C102_CTRL_TIMEOUT); 239 + 237 240 if (res < 0) { 238 241 DBG(3, "Failed to write a register (value 0x%02X, " 239 - "index 0x%02X, error %d)", *value, index, res); 242 + "index 0x%02X, error %d)", *buff, index, res); 240 243 return -1; 241 244 } 242 245 243 - cam->reg[index] = *value; 246 + cam->reg[index] = *buff; 244 247 } 245 248 246 249 return 0; ··· 275 272 } 276 273 277 274 278 - /* NOTE: reading some registers always returns 0 */ 279 - static int sn9c102_read_reg(struct sn9c102_device* cam, u16 index) 275 + /* NOTE: with the SN9C10[123] reading some registers always returns 0 */ 276 + int sn9c102_read_reg(struct sn9c102_device* cam, u16 index) 280 277 { 281 278 struct usb_device* udev = cam->usbdev; 282 279 u8* buff = cam->control_buffer; ··· 302 299 303 300 304 301 static int 305 - sn9c102_i2c_wait(struct sn9c102_device* cam, struct sn9c102_sensor* sensor) 302 + sn9c102_i2c_wait(struct sn9c102_device* cam, 303 + const struct sn9c102_sensor* sensor) 306 304 { 307 305 int i, r; 308 306 ··· 324 320 325 321 static int 326 322 sn9c102_i2c_detect_read_error(struct sn9c102_device* cam, 327 - struct sn9c102_sensor* sensor) 323 + const struct sn9c102_sensor* sensor) 328 324 { 329 325 int r , err = 0; 330 326 ··· 346 342 347 343 static int 348 344 sn9c102_i2c_detect_write_error(struct sn9c102_device* cam, 349 - struct sn9c102_sensor* sensor) 345 + const struct sn9c102_sensor* sensor) 350 346 { 351 347 int r; 352 348 r = sn9c102_read_reg(cam, 0x08); ··· 356 352 357 353 int 358 354 sn9c102_i2c_try_raw_read(struct sn9c102_device* cam, 359 - struct sn9c102_sensor* sensor, u8 data0, u8 data1, 360 - u8 n, u8 buffer[]) 355 + const struct sn9c102_sensor* sensor, u8 data0, 356 + u8 data1, u8 n, u8 buffer[]) 361 357 { 362 358 struct usb_device* udev = cam->usbdev; 363 359 u8* data = cam->control_buffer; 364 - int err = 0, res; 360 + int i = 0, err = 0, res; 365 361 366 362 /* Write cycle */ 367 363 data[0] = ((sensor->interface == SN9C102_I2C_2WIRES) ? 0x80 : 0) | ··· 406 402 } 407 403 408 404 if (buffer) 409 - memcpy(buffer, data, sizeof(buffer)); 405 + for (i = 0; i < n && i < 5; i++) 406 + buffer[n-i-1] = data[4-i]; 410 407 411 408 return (int)data[4]; 412 409 } ··· 415 410 416 411 int 417 412 sn9c102_i2c_try_raw_write(struct sn9c102_device* cam, 418 - struct sn9c102_sensor* sensor, u8 n, u8 data0, 413 + const struct sn9c102_sensor* sensor, u8 n, u8 data0, 419 414 u8 data1, u8 data2, u8 data3, u8 data4, u8 data5) 420 415 { 421 416 struct usb_device* udev = cam->usbdev; ··· 454 449 455 450 int 456 451 sn9c102_i2c_try_read(struct sn9c102_device* cam, 457 - struct sn9c102_sensor* sensor, u8 address) 452 + const struct sn9c102_sensor* sensor, u8 address) 458 453 { 459 454 return sn9c102_i2c_try_raw_read(cam, sensor, sensor->i2c_slave_id, 460 455 address, 1, NULL); ··· 463 458 464 459 int 465 460 sn9c102_i2c_try_write(struct sn9c102_device* cam, 466 - struct sn9c102_sensor* sensor, u8 address, u8 value) 461 + const struct sn9c102_sensor* sensor, u8 address, u8 value) 467 462 { 468 463 return sn9c102_i2c_try_raw_write(cam, sensor, 3, 469 464 sensor->i2c_slave_id, address, ··· 659 654 *(pos + 567) = 0x21; 660 655 661 656 f->buf.bytesused += sizeof(jpeg_header); 662 - } 663 - 664 - 665 - static void 666 - sn9c102_write_eoimarker(struct sn9c102_device* cam, struct sn9c102_frame_t* f) 667 - { 668 - static const u8 eoi_marker[2] = {0xff, 0xd9}; 669 - 670 - memcpy(f->bufmem + f->buf.bytesused, eoi_marker, sizeof(eoi_marker)); 671 - f->buf.bytesused += sizeof(eoi_marker); 672 657 } 673 658 674 659 ··· 3176 3181 3177 3182 static const struct file_operations sn9c102_fops = { 3178 3183 .owner = THIS_MODULE, 3179 - .open = sn9c102_open, 3184 + .open = sn9c102_open, 3180 3185 .release = sn9c102_release, 3181 - .ioctl = sn9c102_ioctl, 3186 + .ioctl = sn9c102_ioctl, 3182 3187 .compat_ioctl = v4l_compat_ioctl32, 3183 - .read = sn9c102_read, 3184 - .poll = sn9c102_poll, 3185 - .mmap = sn9c102_mmap, 3186 - .llseek = no_llseek, 3188 + .read = sn9c102_read, 3189 + .poll = sn9c102_poll, 3190 + .mmap = sn9c102_mmap, 3191 + .llseek = no_llseek, 3187 3192 }; 3188 3193 3189 3194 /*****************************************************************************/ ··· 3246 3251 break; 3247 3252 } 3248 3253 3249 - for (i = 0; sn9c102_sensor_table[i]; i++) { 3254 + for (i = 0; i < ARRAY_SIZE(sn9c102_sensor_table); i++) { 3250 3255 err = sn9c102_sensor_table[i](cam); 3251 3256 if (!err) 3252 3257 break; ··· 3257 3262 DBG(3, "Support for %s maintained by %s", 3258 3263 cam->sensor.name, cam->sensor.maintainer); 3259 3264 } else { 3260 - DBG(1, "No supported image sensor detected"); 3265 + DBG(1, "No supported image sensor detected for this bridge"); 3261 3266 err = -ENODEV; 3262 3267 goto fail; 3263 3268 }
+3 -1
drivers/media/video/sn9c102/sn9c102_devtable.h
··· 86 86 { SN9C102_USB_DEVICE(0x0c45, 0x60bc, BRIDGE_SN9C103), }, 87 87 { SN9C102_USB_DEVICE(0x0c45, 0x60be, BRIDGE_SN9C103), }, 88 88 /* SN9C105 */ 89 + { SN9C102_USB_DEVICE(0x045e, 0x00f5, BRIDGE_SN9C105), }, 90 + { SN9C102_USB_DEVICE(0x045e, 0x00f7, BRIDGE_SN9C105), }, 89 91 { SN9C102_USB_DEVICE(0x0471, 0x0327, BRIDGE_SN9C105), }, 90 92 { SN9C102_USB_DEVICE(0x0471, 0x0328, BRIDGE_SN9C105), }, 91 93 { SN9C102_USB_DEVICE(0x0c45, 0x60c0, BRIDGE_SN9C105), }, ··· 102 100 { SN9C102_USB_DEVICE(0x0c45, 0x60fc, BRIDGE_SN9C105), }, 103 101 { SN9C102_USB_DEVICE(0x0c45, 0x60fe, BRIDGE_SN9C105), }, 104 102 /* SN9C120 */ 103 + { SN9C102_USB_DEVICE(0x0458, 0x7025, BRIDGE_SN9C120), }, 105 104 { SN9C102_USB_DEVICE(0x0c45, 0x6102, BRIDGE_SN9C120), }, 106 105 { SN9C102_USB_DEVICE(0x0c45, 0x6108, BRIDGE_SN9C120), }, 107 106 { SN9C102_USB_DEVICE(0x0c45, 0x610f, BRIDGE_SN9C120), }, ··· 151 148 &sn9c102_probe_tas5110c1b, /* detection based on USB pid/vid */ 152 149 &sn9c102_probe_tas5110d, /* detection based on USB pid/vid */ 153 150 &sn9c102_probe_tas5130d1b, /* detection based on USB pid/vid */ 154 - NULL, 155 151 }; 156 152 157 153 #endif /* _SN9C102_DEVTABLE_H_ */
+2 -4
drivers/media/video/sn9c102/sn9c102_hv7131d.c
··· 144 144 } 145 145 146 146 147 - static struct sn9c102_sensor hv7131d = { 147 + static const struct sn9c102_sensor hv7131d = { 148 148 .name = "HV7131D", 149 149 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 150 150 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, ··· 248 248 249 249 err = sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01}, 250 250 {0x28, 0x17}); 251 - if (err) 252 - return -EIO; 253 251 254 252 r0 = sn9c102_i2c_try_read(cam, &hv7131d, 0x00); 255 253 r1 = sn9c102_i2c_try_read(cam, &hv7131d, 0x01); 256 - if (r0 < 0 || r1 < 0) 254 + if (err || r0 < 0 || r1 < 0) 257 255 return -EIO; 258 256 259 257 if (r0 != 0x00 || r1 != 0x04)
+2 -6
drivers/media/video/sn9c102/sn9c102_hv7131r.c
··· 44 44 {0xb0, 0x2b}, {0xc0, 0x2c}, 45 45 {0xd0, 0x2d}, {0xe0, 0x2e}, 46 46 {0xf0, 0x2f}, {0xff, 0x30}); 47 - 48 47 break; 49 48 case BRIDGE_SN9C105: 50 49 case BRIDGE_SN9C120: ··· 253 254 } 254 255 255 256 256 - static struct sn9c102_sensor hv7131r = { 257 + static const struct sn9c102_sensor hv7131r = { 257 258 .name = "HV7131R", 258 259 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 259 260 .supported_bridge = BRIDGE_SN9C103 | BRIDGE_SN9C105 | BRIDGE_SN9C120, ··· 349 350 {0x34, 0x01}, {0x20, 0x17}, 350 351 {0x34, 0x01}, {0x46, 0x01}); 351 352 352 - if (err) 353 - return -EIO; 354 - 355 353 devid = sn9c102_i2c_try_read(cam, &hv7131r, 0x00); 356 - if (devid < 0) 354 + if (err || devid < 0) 357 355 return -EIO; 358 356 359 357 if (devid != 0x02)
+24 -27
drivers/media/video/sn9c102/sn9c102_mi0343.c
··· 55 55 struct v4l2_control* ctrl) 56 56 { 57 57 struct sn9c102_sensor* s = sn9c102_get_sensor(cam); 58 - u8 data[5+1]; 58 + u8 data[2]; 59 59 60 60 switch (ctrl->id) { 61 61 case V4L2_CID_EXPOSURE: 62 - if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x09, 63 - 2+1, data) < 0) 62 + if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x09, 2, 63 + data) < 0) 64 64 return -EIO; 65 - ctrl->value = data[2]; 65 + ctrl->value = data[0]; 66 66 return 0; 67 67 case V4L2_CID_GAIN: 68 - if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x35, 69 - 2+1, data) < 0) 68 + if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x35, 2, 69 + data) < 0) 70 70 return -EIO; 71 71 break; 72 72 case V4L2_CID_HFLIP: 73 - if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 74 - 2+1, data) < 0) 73 + if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 2, 74 + data) < 0) 75 75 return -EIO; 76 - ctrl->value = data[3] & 0x20 ? 1 : 0; 76 + ctrl->value = data[1] & 0x20 ? 1 : 0; 77 77 return 0; 78 78 case V4L2_CID_VFLIP: 79 - if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 80 - 2+1, data) < 0) 79 + if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 2, 80 + data) < 0) 81 81 return -EIO; 82 - ctrl->value = data[3] & 0x80 ? 1 : 0; 82 + ctrl->value = data[1] & 0x80 ? 1 : 0; 83 83 return 0; 84 84 case V4L2_CID_RED_BALANCE: 85 - if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2d, 86 - 2+1, data) < 0) 85 + if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2d, 2, 86 + data) < 0) 87 87 return -EIO; 88 88 break; 89 89 case V4L2_CID_BLUE_BALANCE: 90 - if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2c, 91 - 2+1, data) < 0) 90 + if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2c, 2, 91 + data) < 0) 92 92 return -EIO; 93 93 break; 94 94 case SN9C102_V4L2_CID_GREEN_BALANCE: 95 - if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2e, 96 - 2+1, data) < 0) 95 + if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2e, 2, 96 + data) < 0) 97 97 return -EIO; 98 98 break; 99 99 default: ··· 105 105 case V4L2_CID_RED_BALANCE: 106 106 case V4L2_CID_BLUE_BALANCE: 107 107 case SN9C102_V4L2_CID_GREEN_BALANCE: 108 - ctrl->value = data[3] | (data[2] << 8); 108 + ctrl->value = data[1] | (data[0] << 8); 109 109 if (ctrl->value >= 0x10 && ctrl->value <= 0x3f) 110 110 ctrl->value -= 0x10; 111 111 else if (ctrl->value >= 0x60 && ctrl->value <= 0x7f) ··· 223 223 } 224 224 225 225 226 - static struct sn9c102_sensor mi0343 = { 226 + static const struct sn9c102_sensor mi0343 = { 227 227 .name = "MI-0343", 228 228 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 229 229 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, ··· 332 332 333 333 int sn9c102_probe_mi0343(struct sn9c102_device* cam) 334 334 { 335 - u8 data[5+1]; 336 - int err = 0; 335 + u8 data[2]; 337 336 338 - err = sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01}, 339 - {0x28, 0x17}); 340 - 341 - if (err) 337 + if (sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01}, 338 + {0x28, 0x17})) 342 339 return -EIO; 343 340 344 341 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 0x00, 345 342 2, data) < 0) 346 343 return -EIO; 347 344 348 - if (data[4] != 0x32 || data[3] != 0xe3) 345 + if (data[1] != 0x42 || data[0] != 0xe3) 349 346 return -ENODEV; 350 347 351 348 sn9c102_attach_sensor(cam, &mi0343);
+167 -53
drivers/media/video/sn9c102/sn9c102_mi0360.c
··· 27 27 struct sn9c102_sensor* s = sn9c102_get_sensor(cam); 28 28 int err = 0; 29 29 30 - err = sn9c102_write_const_regs(cam, {0x00, 0x10}, {0x00, 0x11}, 31 - {0x0a, 0x14}, {0x40, 0x01}, 32 - {0x20, 0x17}, {0x07, 0x18}, 33 - {0xa0, 0x19}, {0x02, 0x1c}, 34 - {0x03, 0x1d}, {0x0f, 0x1e}, 35 - {0x0c, 0x1f}, {0x00, 0x20}, 36 - {0x10, 0x21}, {0x20, 0x22}, 37 - {0x30, 0x23}, {0x40, 0x24}, 38 - {0x50, 0x25}, {0x60, 0x26}, 39 - {0x70, 0x27}, {0x80, 0x28}, 40 - {0x90, 0x29}, {0xa0, 0x2a}, 41 - {0xb0, 0x2b}, {0xc0, 0x2c}, 42 - {0xd0, 0x2d}, {0xe0, 0x2e}, 43 - {0xf0, 0x2f}, {0xff, 0x30}); 30 + switch (sn9c102_get_bridge(cam)) { 31 + case BRIDGE_SN9C103: 32 + err = sn9c102_write_const_regs(cam, {0x00, 0x10}, {0x00, 0x11}, 33 + {0x0a, 0x14}, {0x40, 0x01}, 34 + {0x20, 0x17}, {0x07, 0x18}, 35 + {0xa0, 0x19}, {0x02, 0x1c}, 36 + {0x03, 0x1d}, {0x0f, 0x1e}, 37 + {0x0c, 0x1f}, {0x00, 0x20}, 38 + {0x10, 0x21}, {0x20, 0x22}, 39 + {0x30, 0x23}, {0x40, 0x24}, 40 + {0x50, 0x25}, {0x60, 0x26}, 41 + {0x70, 0x27}, {0x80, 0x28}, 42 + {0x90, 0x29}, {0xa0, 0x2a}, 43 + {0xb0, 0x2b}, {0xc0, 0x2c}, 44 + {0xd0, 0x2d}, {0xe0, 0x2e}, 45 + {0xf0, 0x2f}, {0xff, 0x30}); 46 + break; 47 + case BRIDGE_SN9C105: 48 + case BRIDGE_SN9C120: 49 + err = sn9c102_write_const_regs(cam, {0x44, 0x01}, {0x40, 0x02}, 50 + {0x00, 0x03}, {0x1a, 0x04}, 51 + {0x50, 0x05}, {0x20, 0x06}, 52 + {0x10, 0x07}, {0x03, 0x10}, 53 + {0x08, 0x14}, {0xa2, 0x17}, 54 + {0x47, 0x18}, {0x00, 0x19}, 55 + {0x1d, 0x1a}, {0x10, 0x1b}, 56 + {0x02, 0x1c}, {0x03, 0x1d}, 57 + {0x0f, 0x1e}, {0x0c, 0x1f}, 58 + {0x00, 0x20}, {0x29, 0x21}, 59 + {0x40, 0x22}, {0x54, 0x23}, 60 + {0x66, 0x24}, {0x76, 0x25}, 61 + {0x85, 0x26}, {0x94, 0x27}, 62 + {0xa1, 0x28}, {0xae, 0x29}, 63 + {0xbb, 0x2a}, {0xc7, 0x2b}, 64 + {0xd3, 0x2c}, {0xde, 0x2d}, 65 + {0xea, 0x2e}, {0xf4, 0x2f}, 66 + {0xff, 0x30}, {0x00, 0x3F}, 67 + {0xC7, 0x40}, {0x01, 0x41}, 68 + {0x44, 0x42}, {0x00, 0x43}, 69 + {0x44, 0x44}, {0x00, 0x45}, 70 + {0x44, 0x46}, {0x00, 0x47}, 71 + {0xC7, 0x48}, {0x01, 0x49}, 72 + {0xC7, 0x4A}, {0x01, 0x4B}, 73 + {0xC7, 0x4C}, {0x01, 0x4D}, 74 + {0x44, 0x4E}, {0x00, 0x4F}, 75 + {0x44, 0x50}, {0x00, 0x51}, 76 + {0x44, 0x52}, {0x00, 0x53}, 77 + {0xC7, 0x54}, {0x01, 0x55}, 78 + {0xC7, 0x56}, {0x01, 0x57}, 79 + {0xC7, 0x58}, {0x01, 0x59}, 80 + {0x44, 0x5A}, {0x00, 0x5B}, 81 + {0x44, 0x5C}, {0x00, 0x5D}, 82 + {0x44, 0x5E}, {0x00, 0x5F}, 83 + {0xC7, 0x60}, {0x01, 0x61}, 84 + {0xC7, 0x62}, {0x01, 0x63}, 85 + {0xC7, 0x64}, {0x01, 0x65}, 86 + {0x44, 0x66}, {0x00, 0x67}, 87 + {0x44, 0x68}, {0x00, 0x69}, 88 + {0x44, 0x6A}, {0x00, 0x6B}, 89 + {0xC7, 0x6C}, {0x01, 0x6D}, 90 + {0xC7, 0x6E}, {0x01, 0x6F}, 91 + {0xC7, 0x70}, {0x01, 0x71}, 92 + {0x44, 0x72}, {0x00, 0x73}, 93 + {0x44, 0x74}, {0x00, 0x75}, 94 + {0x44, 0x76}, {0x00, 0x77}, 95 + {0xC7, 0x78}, {0x01, 0x79}, 96 + {0xC7, 0x7A}, {0x01, 0x7B}, 97 + {0xC7, 0x7C}, {0x01, 0x7D}, 98 + {0x44, 0x7E}, {0x00, 0x7F}, 99 + {0x14, 0x84}, {0x00, 0x85}, 100 + {0x27, 0x86}, {0x00, 0x87}, 101 + {0x07, 0x88}, {0x00, 0x89}, 102 + {0xEC, 0x8A}, {0x0f, 0x8B}, 103 + {0xD8, 0x8C}, {0x0f, 0x8D}, 104 + {0x3D, 0x8E}, {0x00, 0x8F}, 105 + {0x3D, 0x90}, {0x00, 0x91}, 106 + {0xCD, 0x92}, {0x0f, 0x93}, 107 + {0xf7, 0x94}, {0x0f, 0x95}, 108 + {0x0C, 0x96}, {0x00, 0x97}, 109 + {0x00, 0x98}, {0x66, 0x99}, 110 + {0x05, 0x9A}, {0x00, 0x9B}, 111 + {0x04, 0x9C}, {0x00, 0x9D}, 112 + {0x08, 0x9E}, {0x00, 0x9F}, 113 + {0x2D, 0xC0}, {0x2D, 0xC1}, 114 + {0x3A, 0xC2}, {0x05, 0xC3}, 115 + {0x04, 0xC4}, {0x3F, 0xC5}, 116 + {0x00, 0xC6}, {0x00, 0xC7}, 117 + {0x50, 0xC8}, {0x3C, 0xC9}, 118 + {0x28, 0xCA}, {0xD8, 0xCB}, 119 + {0x14, 0xCC}, {0xEC, 0xCD}, 120 + {0x32, 0xCE}, {0xDD, 0xCF}, 121 + {0x32, 0xD0}, {0xDD, 0xD1}, 122 + {0x6A, 0xD2}, {0x50, 0xD3}, 123 + {0x00, 0xD4}, {0x00, 0xD5}, 124 + {0x00, 0xD6}); 125 + break; 126 + default: 127 + break; 128 + } 44 129 45 130 err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, 0x0d, 46 131 0x00, 0x01, 0, 0); ··· 150 65 struct v4l2_control* ctrl) 151 66 { 152 67 struct sn9c102_sensor* s = sn9c102_get_sensor(cam); 153 - u8 data[5+1]; 68 + u8 data[2]; 154 69 155 70 switch (ctrl->id) { 156 71 case V4L2_CID_EXPOSURE: 157 - if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x09, 158 - 2+1, data) < 0) 72 + if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x09, 2, 73 + data) < 0) 159 74 return -EIO; 160 - ctrl->value = data[2]; 75 + ctrl->value = data[0]; 161 76 return 0; 162 77 case V4L2_CID_GAIN: 163 - if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x35, 164 - 2+1, data) < 0) 78 + if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x35, 2, 79 + data) < 0) 165 80 return -EIO; 166 - ctrl->value = data[3]; 81 + ctrl->value = data[1]; 167 82 return 0; 168 83 case V4L2_CID_RED_BALANCE: 169 - if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2c, 170 - 2+1, data) < 0) 84 + if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2c, 2, 85 + data) < 0) 171 86 return -EIO; 172 - ctrl->value = data[3]; 87 + ctrl->value = data[1]; 173 88 return 0; 174 89 case V4L2_CID_BLUE_BALANCE: 175 - if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2d, 176 - 2+1, data) < 0) 90 + if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2d, 2, 91 + data) < 0) 177 92 return -EIO; 178 - ctrl->value = data[3]; 93 + ctrl->value = data[1]; 179 94 return 0; 180 95 case SN9C102_V4L2_CID_GREEN_BALANCE: 181 - if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2e, 182 - 2+1, data) < 0) 96 + if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2e, 2, 97 + data) < 0) 183 98 return -EIO; 184 - ctrl->value = data[3]; 99 + ctrl->value = data[1]; 185 100 return 0; 186 101 case V4L2_CID_HFLIP: 187 - if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 188 - 2+1, data) < 0) 102 + if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 2, 103 + data) < 0) 189 104 return -EIO; 190 - ctrl->value = data[3] & 0x20 ? 1 : 0; 105 + ctrl->value = data[1] & 0x20 ? 1 : 0; 191 106 return 0; 192 107 case V4L2_CID_VFLIP: 193 - if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 194 - 2+1, data) < 0) 108 + if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 2, 109 + data) < 0) 195 110 return -EIO; 196 - ctrl->value = data[3] & 0x80 ? 1 : 0; 111 + ctrl->value = data[1] & 0x80 ? 1 : 0; 197 112 return 0; 198 113 default: 199 114 return -EINVAL; ··· 263 178 { 264 179 struct sn9c102_sensor* s = sn9c102_get_sensor(cam); 265 180 int err = 0; 266 - u8 h_start = (u8)(rect->left - s->cropcap.bounds.left) + 0, 267 - v_start = (u8)(rect->top - s->cropcap.bounds.top) + 1; 181 + u8 h_start = 0, v_start = (u8)(rect->top - s->cropcap.bounds.top) + 1; 182 + 183 + switch (sn9c102_get_bridge(cam)) { 184 + case BRIDGE_SN9C103: 185 + h_start = (u8)(rect->left - s->cropcap.bounds.left) + 0; 186 + break; 187 + case BRIDGE_SN9C105: 188 + case BRIDGE_SN9C120: 189 + h_start = (u8)(rect->left - s->cropcap.bounds.left) + 1; 190 + break; 191 + default: 192 + break; 193 + } 268 194 269 195 err += sn9c102_write_reg(cam, h_start, 0x12); 270 196 err += sn9c102_write_reg(cam, v_start, 0x13); ··· 290 194 struct sn9c102_sensor* s = sn9c102_get_sensor(cam); 291 195 int err = 0; 292 196 293 - if (pix->pixelformat == V4L2_PIX_FMT_SN9C10X) { 294 - err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, 295 - 0x0a, 0x00, 0x02, 0, 0); 296 - err += sn9c102_write_reg(cam, 0x20, 0x19); 297 - } else { 197 + if (pix->pixelformat == V4L2_PIX_FMT_SBGGR8) { 298 198 err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, 299 199 0x0a, 0x00, 0x05, 0, 0); 300 200 err += sn9c102_write_reg(cam, 0x60, 0x19); 201 + if (sn9c102_get_bridge(cam) == BRIDGE_SN9C105 || 202 + sn9c102_get_bridge(cam) == BRIDGE_SN9C120) 203 + err += sn9c102_write_reg(cam, 0xa6, 0x17); 204 + } else { 205 + err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, 206 + 0x0a, 0x00, 0x02, 0, 0); 207 + err += sn9c102_write_reg(cam, 0x20, 0x19); 208 + if (sn9c102_get_bridge(cam) == BRIDGE_SN9C105 || 209 + sn9c102_get_bridge(cam) == BRIDGE_SN9C120) 210 + err += sn9c102_write_reg(cam, 0xa2, 0x17); 301 211 } 302 212 303 213 return err; 304 214 } 305 215 306 216 307 - static struct sn9c102_sensor mi0360 = { 217 + static const struct sn9c102_sensor mi0360 = { 308 218 .name = "MI-0360", 309 219 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 310 - .supported_bridge = BRIDGE_SN9C103, 220 + .supported_bridge = BRIDGE_SN9C103 | BRIDGE_SN9C105 | BRIDGE_SN9C120, 311 221 .frequency = SN9C102_I2C_100KHZ, 312 222 .interface = SN9C102_I2C_2WIRES, 313 223 .i2c_slave_id = 0x5d, ··· 419 317 420 318 int sn9c102_probe_mi0360(struct sn9c102_device* cam) 421 319 { 422 - u8 data[5+1]; 423 - int err; 424 320 425 - err = sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01}, 426 - {0x28, 0x17}); 427 - if (err) 428 - return -EIO; 321 + u8 data[2]; 322 + 323 + switch (sn9c102_get_bridge(cam)) { 324 + case BRIDGE_SN9C103: 325 + if (sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01}, 326 + {0x28, 0x17})) 327 + return -EIO; 328 + break; 329 + case BRIDGE_SN9C105: 330 + case BRIDGE_SN9C120: 331 + if (sn9c102_write_const_regs(cam, {0x01, 0xf1}, {0x00, 0xf1}, 332 + {0x01, 0x01}, {0x00, 0x01}, 333 + {0x28, 0x17})) 334 + return -EIO; 335 + break; 336 + default: 337 + break; 338 + } 429 339 430 340 if (sn9c102_i2c_try_raw_read(cam, &mi0360, mi0360.i2c_slave_id, 0x00, 431 - 2+1, data) < 0) 341 + 2, data) < 0) 432 342 return -EIO; 433 343 434 - if (data[2] != 0x82 || data[3] != 0x43) 344 + if (data[0] != 0x82 || data[1] != 0x43) 435 345 return -ENODEV; 436 346 437 347 sn9c102_attach_sensor(cam, &mi0360);
+10 -15
drivers/media/video/sn9c102/sn9c102_ov7630.c
··· 29 29 switch (sn9c102_get_bridge(cam)) { 30 30 case BRIDGE_SN9C101: 31 31 case BRIDGE_SN9C102: 32 - err = sn9c102_write_const_regs(cam, {0x00, 0x14}, 33 - {0x60, 0x17}, {0x0f, 0x18}, 34 - {0x50, 0x19}); 32 + err = sn9c102_write_const_regs(cam, {0x00, 0x14}, {0x60, 0x17}, 33 + {0x0f, 0x18}, {0x50, 0x19}); 35 34 36 35 err += sn9c102_i2c_write(cam, 0x12, 0x8d); 37 36 err += sn9c102_i2c_write(cam, 0x12, 0x0d); ··· 60 61 err += sn9c102_i2c_write(cam, 0x71, 0x00); 61 62 err += sn9c102_i2c_write(cam, 0x74, 0x21); 62 63 err += sn9c102_i2c_write(cam, 0x7d, 0xf7); 63 - 64 64 break; 65 65 case BRIDGE_SN9C103: 66 66 err = sn9c102_write_const_regs(cam, {0x00, 0x02}, {0x00, 0x03}, ··· 251 253 } 252 254 253 255 254 - static struct sn9c102_sensor ov7630 = { 256 + static const struct sn9c102_sensor ov7630 = { 255 257 .name = "OV7630", 256 258 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 257 259 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102 | BRIDGE_SN9C103, ··· 406 408 switch (sn9c102_get_bridge(cam)) { 407 409 case BRIDGE_SN9C101: 408 410 case BRIDGE_SN9C102: 409 - err = sn9c102_write_const_regs(cam, {0x01, 0x01}, 410 - {0x00, 0x01}, {0x28, 0x17}); 411 - 411 + err = sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01}, 412 + {0x28, 0x17}); 412 413 break; 413 414 case BRIDGE_SN9C103: /* do _not_ change anything! */ 414 - err = sn9c102_write_const_regs(cam, {0x09, 0x01}, 415 - {0x42, 0x01}, {0x28, 0x17}, 416 - {0x44, 0x02}); 415 + err = sn9c102_write_const_regs(cam, {0x09, 0x01}, {0x42, 0x01}, 416 + {0x28, 0x17}, {0x44, 0x02}); 417 417 pid = sn9c102_i2c_try_read(cam, &ov7630, 0x0a); 418 - if (err || pid < 0) { /* try a different initialization */ 419 - err = sn9c102_write_reg(cam, 0x01, 0x01); 420 - err += sn9c102_write_reg(cam, 0x00, 0x01); 421 - } 418 + if (err || pid < 0) /* try a different initialization */ 419 + err += sn9c102_write_const_regs(cam, {0x01, 0x01}, 420 + {0x00, 0x01}); 422 421 break; 423 422 default: 424 423 break;
+43 -20
drivers/media/video/sn9c102/sn9c102_ov7660.c
··· 104 104 err += sn9c102_i2c_write(cam, 0x12, 0x80); 105 105 err += sn9c102_i2c_write(cam, 0x11, 0x09); 106 106 err += sn9c102_i2c_write(cam, 0x00, 0x0A); 107 - err += sn9c102_i2c_write(cam, 0x01, 0x78); 108 - err += sn9c102_i2c_write(cam, 0x02, 0x90); 107 + err += sn9c102_i2c_write(cam, 0x01, 0x80); 108 + err += sn9c102_i2c_write(cam, 0x02, 0x80); 109 109 err += sn9c102_i2c_write(cam, 0x03, 0x00); 110 110 err += sn9c102_i2c_write(cam, 0x04, 0x00); 111 111 err += sn9c102_i2c_write(cam, 0x05, 0x08); ··· 122 122 err += sn9c102_i2c_write(cam, 0x10, 0x20); 123 123 err += sn9c102_i2c_write(cam, 0x11, 0x03); 124 124 err += sn9c102_i2c_write(cam, 0x12, 0x05); 125 - err += sn9c102_i2c_write(cam, 0x13, 0xF8); 125 + err += sn9c102_i2c_write(cam, 0x13, 0xC7); 126 126 err += sn9c102_i2c_write(cam, 0x14, 0x2C); 127 127 err += sn9c102_i2c_write(cam, 0x15, 0x00); 128 128 err += sn9c102_i2c_write(cam, 0x16, 0x02); ··· 162 162 err += sn9c102_i2c_write(cam, 0x38, 0x02); 163 163 err += sn9c102_i2c_write(cam, 0x39, 0x43); 164 164 err += sn9c102_i2c_write(cam, 0x3A, 0x00); 165 - err += sn9c102_i2c_write(cam, 0x3B, 0x02); 165 + err += sn9c102_i2c_write(cam, 0x3B, 0x0A); 166 166 err += sn9c102_i2c_write(cam, 0x3C, 0x6C); 167 167 err += sn9c102_i2c_write(cam, 0x3D, 0x99); 168 168 err += sn9c102_i2c_write(cam, 0x3E, 0x0E); ··· 281 281 return -EIO; 282 282 break; 283 283 case V4L2_CID_DO_WHITE_BALANCE: 284 - ctrl->value = sn9c102_pread_reg(cam, 0x02); 284 + if ((ctrl->value = sn9c102_read_reg(cam, 0x02)) < 0) 285 + return -EIO; 285 286 ctrl->value = (ctrl->value & 0x04) ? 1 : 0; 286 287 break; 287 288 case V4L2_CID_RED_BALANCE: 288 - ctrl->value = sn9c102_pread_reg(cam, 0x05); 289 + if ((ctrl->value = sn9c102_read_reg(cam, 0x05)) < 0) 290 + return -EIO; 289 291 ctrl->value &= 0x7f; 290 292 break; 291 293 case V4L2_CID_BLUE_BALANCE: 292 - ctrl->value = sn9c102_pread_reg(cam, 0x06); 294 + if ((ctrl->value = sn9c102_read_reg(cam, 0x06)) < 0) 295 + return -EIO; 293 296 ctrl->value &= 0x7f; 294 297 break; 295 298 case SN9C102_V4L2_CID_GREEN_BALANCE: 296 - ctrl->value = sn9c102_pread_reg(cam, 0x07); 299 + if ((ctrl->value = sn9c102_read_reg(cam, 0x07)) < 0) 300 + return -EIO; 297 301 ctrl->value &= 0x7f; 302 + break; 303 + case SN9C102_V4L2_CID_BAND_FILTER: 304 + if ((ctrl->value = sn9c102_i2c_read(cam, 0x3b)) < 0) 305 + return -EIO; 306 + ctrl->value &= 0x08; 298 307 break; 299 308 case V4L2_CID_GAIN: 300 309 if ((ctrl->value = sn9c102_i2c_read(cam, 0x00)) < 0) 301 310 return -EIO; 302 - ctrl->value &= 0x7f; 311 + ctrl->value &= 0x1f; 303 312 break; 304 313 case V4L2_CID_AUTOGAIN: 305 314 if ((ctrl->value = sn9c102_i2c_read(cam, 0x13)) < 0) ··· 344 335 case SN9C102_V4L2_CID_GREEN_BALANCE: 345 336 err += sn9c102_write_reg(cam, ctrl->value, 0x07); 346 337 break; 338 + case SN9C102_V4L2_CID_BAND_FILTER: 339 + err += sn9c102_i2c_write(cam, ctrl->value << 3, 0x3b); 340 + break; 347 341 case V4L2_CID_GAIN: 348 - err += sn9c102_i2c_write(cam, 0x00, ctrl->value); 342 + err += sn9c102_i2c_write(cam, 0x00, 0x60 + ctrl->value); 349 343 break; 350 344 case V4L2_CID_AUTOGAIN: 351 - err += sn9c102_i2c_write(cam, 0x13, 0xf0 | ctrl->value | 352 - (ctrl->value << 1)); 345 + err += sn9c102_i2c_write(cam, 0x13, 0xc0 | 346 + (ctrl->value * 0x07)); 353 347 break; 354 348 default: 355 349 return -EINVAL; ··· 398 386 } 399 387 400 388 401 - static struct sn9c102_sensor ov7660 = { 389 + static const struct sn9c102_sensor ov7660 = { 402 390 .name = "OV7660", 403 391 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 404 392 .supported_bridge = BRIDGE_SN9C105 | BRIDGE_SN9C120, ··· 413 401 .type = V4L2_CTRL_TYPE_INTEGER, 414 402 .name = "global gain", 415 403 .minimum = 0x00, 416 - .maximum = 0x7f, 404 + .maximum = 0x1f, 417 405 .step = 0x01, 418 - .default_value = 0x0a, 406 + .default_value = 0x09, 419 407 .flags = 0, 420 408 }, 421 409 { ··· 425 413 .minimum = 0x00, 426 414 .maximum = 0xff, 427 415 .step = 0x01, 428 - .default_value = 0x50, 416 + .default_value = 0x27, 429 417 .flags = 0, 430 418 }, 431 419 { ··· 445 433 .minimum = 0x00, 446 434 .maximum = 0x7f, 447 435 .step = 0x01, 448 - .default_value = 0x1f, 436 + .default_value = 0x14, 449 437 .flags = 0, 450 438 }, 451 439 { ··· 455 443 .minimum = 0x00, 456 444 .maximum = 0x7f, 457 445 .step = 0x01, 458 - .default_value = 0x1e, 446 + .default_value = 0x14, 459 447 .flags = 0, 460 448 }, 461 449 { ··· 465 453 .minimum = 0x00, 466 454 .maximum = 0x01, 467 455 .step = 0x01, 468 - .default_value = 0x00, 456 + .default_value = 0x01, 469 457 .flags = 0, 470 458 }, 471 459 { ··· 475 463 .minimum = 0x00, 476 464 .maximum = 0x7f, 477 465 .step = 0x01, 478 - .default_value = 0x20, 466 + .default_value = 0x14, 467 + .flags = 0, 468 + }, 469 + { 470 + .id = SN9C102_V4L2_CID_BAND_FILTER, 471 + .type = V4L2_CTRL_TYPE_BOOLEAN, 472 + .name = "band filter", 473 + .minimum = 0x00, 474 + .maximum = 0x01, 475 + .step = 0x01, 476 + .default_value = 0x00, 479 477 .flags = 0, 480 478 }, 481 479 }, ··· 530 508 return -EIO; 531 509 if (pid != 0x76 || ver != 0x60) 532 510 return -ENODEV; 511 + 533 512 sn9c102_attach_sensor(cam, &ov7660); 534 513 535 514 return 0;
+6 -8
drivers/media/video/sn9c102/sn9c102_pas106b.c
··· 163 163 } 164 164 165 165 166 - static struct sn9c102_sensor pas106b = { 166 + static const struct sn9c102_sensor pas106b = { 167 167 .name = "PAS106B", 168 168 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 169 169 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, ··· 273 273 274 274 int sn9c102_probe_pas106b(struct sn9c102_device* cam) 275 275 { 276 - int r0 = 0, r1 = 0, err; 276 + int r0 = 0, r1 = 0; 277 277 unsigned int pid = 0; 278 278 279 279 /* 280 280 Minimal initialization to enable the I2C communication 281 281 NOTE: do NOT change the values! 282 282 */ 283 - err = sn9c102_write_const_regs(cam, 284 - {0x01, 0x01}, /* sensor power down */ 285 - {0x00, 0x01}, /* sensor power on */ 286 - {0x28, 0x17});/* sensor clock 24 MHz */ 287 - if (err) 283 + if (sn9c102_write_const_regs(cam, 284 + {0x01, 0x01}, /* sensor power down */ 285 + {0x00, 0x01}, /* sensor power on */ 286 + {0x28, 0x17})) /* sensor clock at 24 MHz */ 288 287 return -EIO; 289 288 290 289 r0 = sn9c102_i2c_try_read(cam, &pas106b, 0x00); 291 290 r1 = sn9c102_i2c_try_read(cam, &pas106b, 0x01); 292 - 293 291 if (r0 < 0 || r1 < 0) 294 292 return -EIO; 295 293
+23 -25
drivers/media/video/sn9c102/sn9c102_pas202bcb.c
··· 35 35 switch (sn9c102_get_bridge(cam)) { 36 36 case BRIDGE_SN9C101: 37 37 case BRIDGE_SN9C102: 38 - err = sn9c102_write_const_regs(cam, {0x00, 0x10}, 39 - {0x00, 0x11}, {0x00, 0x14}, 40 - {0x20, 0x17}, {0x30, 0x19}, 41 - {0x09, 0x18}); 38 + err = sn9c102_write_const_regs(cam, {0x00, 0x10}, {0x00, 0x11}, 39 + {0x00, 0x14}, {0x20, 0x17}, 40 + {0x30, 0x19}, {0x09, 0x18}); 42 41 break; 43 42 case BRIDGE_SN9C103: 44 - err = sn9c102_write_const_regs(cam, {0x00, 0x02}, 45 - {0x00, 0x03}, {0x1a, 0x04}, 46 - {0x20, 0x05}, {0x20, 0x06}, 47 - {0x20, 0x07}, {0x00, 0x10}, 48 - {0x00, 0x11}, {0x00, 0x14}, 49 - {0x20, 0x17}, {0x30, 0x19}, 50 - {0x09, 0x18}, {0x02, 0x1c}, 51 - {0x03, 0x1d}, {0x0f, 0x1e}, 52 - {0x0c, 0x1f}, {0x00, 0x20}, 53 - {0x10, 0x21}, {0x20, 0x22}, 54 - {0x30, 0x23}, {0x40, 0x24}, 55 - {0x50, 0x25}, {0x60, 0x26}, 56 - {0x70, 0x27}, {0x80, 0x28}, 57 - {0x90, 0x29}, {0xa0, 0x2a}, 58 - {0xb0, 0x2b}, {0xc0, 0x2c}, 59 - {0xd0, 0x2d}, {0xe0, 0x2e}, 60 - {0xf0, 0x2f}, {0xff, 0x30}); 43 + err = sn9c102_write_const_regs(cam, {0x00, 0x02}, {0x00, 0x03}, 44 + {0x1a, 0x04}, {0x20, 0x05}, 45 + {0x20, 0x06}, {0x20, 0x07}, 46 + {0x00, 0x10}, {0x00, 0x11}, 47 + {0x00, 0x14}, {0x20, 0x17}, 48 + {0x30, 0x19}, {0x09, 0x18}, 49 + {0x02, 0x1c}, {0x03, 0x1d}, 50 + {0x0f, 0x1e}, {0x0c, 0x1f}, 51 + {0x00, 0x20}, {0x10, 0x21}, 52 + {0x20, 0x22}, {0x30, 0x23}, 53 + {0x40, 0x24}, {0x50, 0x25}, 54 + {0x60, 0x26}, {0x70, 0x27}, 55 + {0x80, 0x28}, {0x90, 0x29}, 56 + {0xa0, 0x2a}, {0xb0, 0x2b}, 57 + {0xc0, 0x2c}, {0xd0, 0x2d}, 58 + {0xe0, 0x2e}, {0xf0, 0x2f}, 59 + {0xff, 0x30}); 61 60 break; 62 61 default: 63 62 break; ··· 196 197 } 197 198 198 199 199 - static struct sn9c102_sensor pas202bcb = { 200 + static const struct sn9c102_sensor pas202bcb = { 200 201 .name = "PAS202BCB", 201 202 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 202 203 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102 | BRIDGE_SN9C103, ··· 312 313 {0x28, 0x17});/* clock 24 MHz */ 313 314 break; 314 315 case BRIDGE_SN9C103: /* do _not_ change anything! */ 315 - err = sn9c102_write_const_regs(cam, {0x09, 0x01}, 316 - {0x44, 0x01}, {0x44, 0x02}, 317 - {0x29, 0x17}); 316 + err = sn9c102_write_const_regs(cam, {0x09, 0x01}, {0x44, 0x01}, 317 + {0x44, 0x02}, {0x29, 0x17}); 318 318 break; 319 319 default: 320 320 break;
+18 -15
drivers/media/video/sn9c102/sn9c102_sensor.h
··· 22 22 #define _SN9C102_SENSOR_H_ 23 23 24 24 #include <linux/usb.h> 25 - #include <linux/videodev.h> 25 + #include <linux/videodev2.h> 26 26 #include <linux/device.h> 27 27 #include <linux/stddef.h> 28 28 #include <linux/errno.h> ··· 74 74 /* Attach a probed sensor to the camera. */ 75 75 extern void 76 76 sn9c102_attach_sensor(struct sn9c102_device* cam, 77 - struct sn9c102_sensor* sensor); 77 + const struct sn9c102_sensor* sensor); 78 78 79 79 /* 80 80 Read/write routines: they always return -1 on error, 0 or the read value ··· 85 85 */ 86 86 87 87 /* The "try" I2C I/O versions are used when probing the sensor */ 88 - extern int sn9c102_i2c_try_write(struct sn9c102_device*,struct sn9c102_sensor*, 89 - u8 address, u8 value); 90 - extern int sn9c102_i2c_try_read(struct sn9c102_device*,struct sn9c102_sensor*, 91 - u8 address); 88 + extern int sn9c102_i2c_try_write(struct sn9c102_device*, 89 + const struct sn9c102_sensor*, u8 address, 90 + u8 value); 91 + extern int sn9c102_i2c_try_read(struct sn9c102_device*, 92 + const struct sn9c102_sensor*, u8 address); 92 93 93 94 /* 94 95 These must be used if and only if the sensor doesn't implement the standard ··· 103 102 byte. 104 103 */ 105 104 extern int sn9c102_i2c_try_raw_write(struct sn9c102_device* cam, 106 - struct sn9c102_sensor* sensor, u8 n, 105 + const struct sn9c102_sensor* sensor, u8 n, 107 106 u8 data0, u8 data1, u8 data2, u8 data3, 108 107 u8 data4, u8 data5); 109 108 extern int sn9c102_i2c_try_raw_read(struct sn9c102_device* cam, 110 - struct sn9c102_sensor* sensor, u8 data0, 111 - u8 data1, u8 n, u8 buffer[]); 109 + const struct sn9c102_sensor* sensor, 110 + u8 data0, u8 data1, u8 n, u8 buffer[]); 112 111 113 112 /* To be used after the sensor struct has been attached to the camera struct */ 114 113 extern int sn9c102_i2c_write(struct sn9c102_device*, u8 address, u8 value); 115 114 extern int sn9c102_i2c_read(struct sn9c102_device*, u8 address); 116 115 117 116 /* I/O on registers in the bridge. Could be used by the sensor methods too */ 117 + extern int sn9c102_read_reg(struct sn9c102_device*, u16 index); 118 118 extern int sn9c102_pread_reg(struct sn9c102_device*, u16 index); 119 119 extern int sn9c102_write_reg(struct sn9c102_device*, u8 value, u16 index); 120 120 extern int sn9c102_write_regs(struct sn9c102_device*, const u8 valreg[][2], 121 121 int count); 122 122 /* 123 - * Write multiple registers with constant values. For example: 124 - * sn9c102_write_const_regs(cam, {0x00, 0x14}, {0x60, 0x17}, {0x0f, 0x18}); 125 - */ 126 - #define sn9c102_write_const_regs(device, data...) \ 127 - ({ const static u8 _data[][2] = {data}; \ 128 - sn9c102_write_regs(device, _data, ARRAY_SIZE(_data)); }) 123 + Write multiple registers with constant values. For example: 124 + sn9c102_write_const_regs(cam, {0x00, 0x14}, {0x60, 0x17}, {0x0f, 0x18}); 125 + Register adresses must be < 256. 126 + */ 127 + #define sn9c102_write_const_regs(sn9c102_device, data...) \ 128 + ({ const static u8 _valreg[][2] = {data}; \ 129 + sn9c102_write_regs(sn9c102_device, _valreg, ARRAY_SIZE(_valreg)); }) 129 130 130 131 /*****************************************************************************/ 131 132
+1 -1
drivers/media/video/sn9c102/sn9c102_tas5110c1b.c
··· 88 88 } 89 89 90 90 91 - static struct sn9c102_sensor tas5110c1b = { 91 + static const struct sn9c102_sensor tas5110c1b = { 92 92 .name = "TAS5110C1B", 93 93 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 94 94 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102,
+1 -1
drivers/media/video/sn9c102/sn9c102_tas5110d.c
··· 68 68 } 69 69 70 70 71 - static struct sn9c102_sensor tas5110d = { 71 + static const struct sn9c102_sensor tas5110d = { 72 72 .name = "TAS5110D", 73 73 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 74 74 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102,
+1 -1
drivers/media/video/sn9c102/sn9c102_tas5130d1b.c
··· 89 89 } 90 90 91 91 92 - static struct sn9c102_sensor tas5130d1b = { 92 + static const struct sn9c102_sensor tas5130d1b = { 93 93 .name = "TAS5130D1B", 94 94 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 95 95 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102,