Luca Risolia | 60f7805 | 2006-02-06 16:29:35 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
Luca Risolia | 0230185 | 2006-04-24 11:28:23 -0300 | [diff] [blame] | 2 | * API for image sensors connected to the ZC0301 Image Processor and * |
Luca Risolia | 60f7805 | 2006-02-06 16:29:35 +0000 | [diff] [blame] | 3 | * Control Chip * |
| 4 | * * |
| 5 | * Copyright (C) 2006 by Luca Risolia <luca.risolia@studio.unibo.it> * |
| 6 | * * |
| 7 | * This program is free software; you can redistribute it and/or modify * |
| 8 | * it under the terms of the GNU General Public License as published by * |
| 9 | * the Free Software Foundation; either version 2 of the License, or * |
| 10 | * (at your option) any later version. * |
| 11 | * * |
| 12 | * This program is distributed in the hope that it will be useful, * |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 15 | * GNU General Public License for more details. * |
| 16 | * * |
| 17 | * You should have received a copy of the GNU General Public License * |
| 18 | * along with this program; if not, write to the Free Software * |
| 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * |
| 20 | ***************************************************************************/ |
| 21 | |
| 22 | #ifndef _ZC0301_SENSOR_H_ |
| 23 | #define _ZC0301_SENSOR_H_ |
| 24 | |
| 25 | #include <linux/usb.h> |
| 26 | #include <linux/videodev.h> |
| 27 | #include <linux/device.h> |
| 28 | #include <linux/stddef.h> |
| 29 | #include <linux/errno.h> |
| 30 | #include <asm/types.h> |
| 31 | |
| 32 | struct zc0301_device; |
| 33 | struct zc0301_sensor; |
| 34 | |
| 35 | /*****************************************************************************/ |
| 36 | |
| 37 | extern int zc0301_probe_pas202bcb(struct zc0301_device* cam); |
Luca Risolia | 0230185 | 2006-04-24 11:28:23 -0300 | [diff] [blame] | 38 | extern int zc0301_probe_pb0330(struct zc0301_device* cam); |
Luca Risolia | 60f7805 | 2006-02-06 16:29:35 +0000 | [diff] [blame] | 39 | |
| 40 | #define ZC0301_SENSOR_TABLE \ |
| 41 | /* Weak detections must go at the end of the list */ \ |
| 42 | static int (*zc0301_sensor_table[])(struct zc0301_device*) = { \ |
| 43 | &zc0301_probe_pas202bcb, \ |
Luca Risolia | 0230185 | 2006-04-24 11:28:23 -0300 | [diff] [blame] | 44 | &zc0301_probe_pb0330, \ |
Luca Risolia | 60f7805 | 2006-02-06 16:29:35 +0000 | [diff] [blame] | 45 | NULL, \ |
| 46 | }; |
| 47 | |
Luca Risolia | a847423 | 2006-02-25 06:57:49 +0000 | [diff] [blame] | 48 | extern struct zc0301_device* |
| 49 | zc0301_match_id(struct zc0301_device* cam, const struct usb_device_id *id); |
| 50 | |
Luca Risolia | 60f7805 | 2006-02-06 16:29:35 +0000 | [diff] [blame] | 51 | extern void |
Luca Risolia | a847423 | 2006-02-25 06:57:49 +0000 | [diff] [blame] | 52 | zc0301_attach_sensor(struct zc0301_device* cam, struct zc0301_sensor* sensor); |
Luca Risolia | 60f7805 | 2006-02-06 16:29:35 +0000 | [diff] [blame] | 53 | |
| 54 | #define ZC0301_USB_DEVICE(vend, prod, intclass) \ |
| 55 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 56 | USB_DEVICE_ID_MATCH_INT_CLASS, \ |
Luca Risolia | 60f7805 | 2006-02-06 16:29:35 +0000 | [diff] [blame] | 57 | .idVendor = (vend), \ |
| 58 | .idProduct = (prod), \ |
| 59 | .bInterfaceClass = (intclass) |
| 60 | |
| 61 | #define ZC0301_ID_TABLE \ |
| 62 | static const struct usb_device_id zc0301_id_table[] = { \ |
Luca Risolia | 0230185 | 2006-04-24 11:28:23 -0300 | [diff] [blame] | 63 | { ZC0301_USB_DEVICE(0x041e, 0x4017, 0xff), }, /* ICM105 */ \ |
Luca Risolia | 6e0755a | 2006-03-03 09:58:39 +0000 | [diff] [blame] | 64 | { ZC0301_USB_DEVICE(0x041e, 0x401c, 0xff), }, /* PAS106 */ \ |
Luca Risolia | 0230185 | 2006-04-24 11:28:23 -0300 | [diff] [blame] | 65 | { ZC0301_USB_DEVICE(0x041e, 0x401e, 0xff), }, /* HV7131 */ \ |
| 66 | { ZC0301_USB_DEVICE(0x041e, 0x401f, 0xff), }, /* TAS5130 */ \ |
| 67 | { ZC0301_USB_DEVICE(0x041e, 0x4022, 0xff), }, \ |
Luca Risolia | 6e0755a | 2006-03-03 09:58:39 +0000 | [diff] [blame] | 68 | { ZC0301_USB_DEVICE(0x041e, 0x4034, 0xff), }, /* PAS106 */ \ |
| 69 | { ZC0301_USB_DEVICE(0x041e, 0x4035, 0xff), }, /* PAS106 */ \ |
Luca Risolia | 0230185 | 2006-04-24 11:28:23 -0300 | [diff] [blame] | 70 | { ZC0301_USB_DEVICE(0x041e, 0x4036, 0xff), }, /* HV7131 */ \ |
| 71 | { ZC0301_USB_DEVICE(0x041e, 0x403a, 0xff), }, /* HV7131 */ \ |
| 72 | { ZC0301_USB_DEVICE(0x0458, 0x7007, 0xff), }, /* TAS5130 */ \ |
| 73 | { ZC0301_USB_DEVICE(0x0458, 0x700C, 0xff), }, /* TAS5130 */ \ |
| 74 | { ZC0301_USB_DEVICE(0x0458, 0x700f, 0xff), }, /* TAS5130 */ \ |
| 75 | { ZC0301_USB_DEVICE(0x046d, 0x08ae, 0xff), }, /* PAS202 */ \ |
| 76 | { ZC0301_USB_DEVICE(0x055f, 0xd003, 0xff), }, /* TAS5130 */ \ |
| 77 | { ZC0301_USB_DEVICE(0x055f, 0xd004, 0xff), }, /* TAS5130 */ \ |
| 78 | { ZC0301_USB_DEVICE(0x046d, 0x08ae, 0xff), }, /* PAS202 */ \ |
Luca Risolia | a847423 | 2006-02-25 06:57:49 +0000 | [diff] [blame] | 79 | { ZC0301_USB_DEVICE(0x0ac8, 0x0301, 0xff), }, \ |
Luca Risolia | 0230185 | 2006-04-24 11:28:23 -0300 | [diff] [blame] | 80 | { ZC0301_USB_DEVICE(0x0ac8, 0x301b, 0xff), }, /* PB-0330/HV7131 */ \ |
| 81 | { ZC0301_USB_DEVICE(0x0ac8, 0x303b, 0xff), }, /* PB-0330 */ \ |
| 82 | { ZC0301_USB_DEVICE(0x10fd, 0x0128, 0xff), }, /* TAS5130 */ \ |
| 83 | { ZC0301_USB_DEVICE(0x10fd, 0x8050, 0xff), }, /* TAS5130 */ \ |
| 84 | { ZC0301_USB_DEVICE(0x10fd, 0x804e, 0xff), }, /* TAS5130 */ \ |
Luca Risolia | 60f7805 | 2006-02-06 16:29:35 +0000 | [diff] [blame] | 85 | { } \ |
| 86 | }; |
| 87 | |
| 88 | /*****************************************************************************/ |
| 89 | |
| 90 | extern int zc0301_write_reg(struct zc0301_device*, u16 index, u16 value); |
| 91 | extern int zc0301_read_reg(struct zc0301_device*, u16 index); |
| 92 | extern int zc0301_i2c_write(struct zc0301_device*, u16 address, u16 value); |
| 93 | extern int zc0301_i2c_read(struct zc0301_device*, u16 address, u8 length); |
| 94 | |
| 95 | /*****************************************************************************/ |
| 96 | |
| 97 | #define ZC0301_MAX_CTRLS V4L2_CID_LASTP1-V4L2_CID_BASE+10 |
| 98 | #define ZC0301_V4L2_CID_DAC_MAGNITUDE V4L2_CID_PRIVATE_BASE |
| 99 | #define ZC0301_V4L2_CID_GREEN_BALANCE V4L2_CID_PRIVATE_BASE + 1 |
| 100 | |
| 101 | struct zc0301_sensor { |
| 102 | char name[32]; |
| 103 | |
| 104 | struct v4l2_queryctrl qctrl[ZC0301_MAX_CTRLS]; |
| 105 | struct v4l2_cropcap cropcap; |
| 106 | struct v4l2_pix_format pix_format; |
| 107 | |
Luca Risolia | a847423 | 2006-02-25 06:57:49 +0000 | [diff] [blame] | 108 | int (*init)(struct zc0301_device*); |
| 109 | int (*get_ctrl)(struct zc0301_device*, struct v4l2_control* ctrl); |
| 110 | int (*set_ctrl)(struct zc0301_device*, |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 111 | const struct v4l2_control* ctrl); |
Luca Risolia | a847423 | 2006-02-25 06:57:49 +0000 | [diff] [blame] | 112 | int (*set_crop)(struct zc0301_device*, const struct v4l2_rect* rect); |
Luca Risolia | 60f7805 | 2006-02-06 16:29:35 +0000 | [diff] [blame] | 113 | |
| 114 | /* Private */ |
| 115 | struct v4l2_queryctrl _qctrl[ZC0301_MAX_CTRLS]; |
| 116 | struct v4l2_rect _rect; |
| 117 | }; |
| 118 | |
| 119 | #endif /* _ZC0301_SENSOR_H_ */ |