blob: 0be783c203f7e7359c3336e5a2034e99b55f6308 [file] [log] [blame]
Luca Risolia60f78052006-02-06 16:29:35 +00001/***************************************************************************
Luca Risolia7e3a0662007-01-08 11:34:35 -03002 * API for image sensors connected to the ZC0301[P] Image Processor and *
Luca Risolia60f78052006-02-06 16:29:35 +00003 * Control Chip *
4 * *
Luca Risolia7e3a0662007-01-08 11:34:35 -03005 * Copyright (C) 2006-2007 by Luca Risolia <luca.risolia@studio.unibo.it> *
Luca Risolia60f78052006-02-06 16:29:35 +00006 * *
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>
Luca Risolia4052fcc2007-06-13 15:11:15 -030026#include <linux/videodev2.h>
Luca Risolia60f78052006-02-06 16:29:35 +000027#include <linux/device.h>
28#include <linux/stddef.h>
29#include <linux/errno.h>
30#include <asm/types.h>
31
32struct zc0301_device;
33struct zc0301_sensor;
34
35/*****************************************************************************/
36
37extern int zc0301_probe_pas202bcb(struct zc0301_device* cam);
Luca Risolia02301852006-04-24 11:28:23 -030038extern int zc0301_probe_pb0330(struct zc0301_device* cam);
Luca Risolia60f78052006-02-06 16:29:35 +000039
40#define ZC0301_SENSOR_TABLE \
41/* Weak detections must go at the end of the list */ \
42static int (*zc0301_sensor_table[])(struct zc0301_device*) = { \
43 &zc0301_probe_pas202bcb, \
Luca Risolia02301852006-04-24 11:28:23 -030044 &zc0301_probe_pb0330, \
Luca Risolia60f78052006-02-06 16:29:35 +000045 NULL, \
46};
47
Luca Risoliaa8474232006-02-25 06:57:49 +000048extern struct zc0301_device*
49zc0301_match_id(struct zc0301_device* cam, const struct usb_device_id *id);
50
Luca Risolia60f78052006-02-06 16:29:35 +000051extern void
Luca Risoliaa8474232006-02-25 06:57:49 +000052zc0301_attach_sensor(struct zc0301_device* cam, struct zc0301_sensor* sensor);
Luca Risolia60f78052006-02-06 16:29:35 +000053
54#define ZC0301_USB_DEVICE(vend, prod, intclass) \
55 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
Mauro Carvalho Chehabd56410e2006-03-25 09:19:53 -030056 USB_DEVICE_ID_MATCH_INT_CLASS, \
Luca Risolia60f78052006-02-06 16:29:35 +000057 .idVendor = (vend), \
58 .idProduct = (prod), \
59 .bInterfaceClass = (intclass)
60
Jean-François Moinedbad3452010-03-29 03:51:18 -030061#if !defined CONFIG_USB_GSPCA_ZC3XX && !defined CONFIG_USB_GSPCA_ZC3XX_MODULE
Luca Risolia60f78052006-02-06 16:29:35 +000062#define ZC0301_ID_TABLE \
63static const struct usb_device_id zc0301_id_table[] = { \
Luca Risolia02301852006-04-24 11:28:23 -030064 { ZC0301_USB_DEVICE(0x046d, 0x08ae, 0xff), }, /* PAS202 */ \
Luca Risolia02301852006-04-24 11:28:23 -030065 { ZC0301_USB_DEVICE(0x0ac8, 0x303b, 0xff), }, /* PB-0330 */ \
Luca Risolia60f78052006-02-06 16:29:35 +000066 { } \
67};
Jean-Francois Moineef6bc5a2009-01-07 08:00:18 -030068#else
69#define ZC0301_ID_TABLE \
70static const struct usb_device_id zc0301_id_table[] = { \
71 { ZC0301_USB_DEVICE(0x046d, 0x08ae, 0xff), }, /* PAS202 */ \
72 { } \
73};
74#endif
Luca Risolia60f78052006-02-06 16:29:35 +000075
76/*****************************************************************************/
77
78extern int zc0301_write_reg(struct zc0301_device*, u16 index, u16 value);
79extern int zc0301_read_reg(struct zc0301_device*, u16 index);
80extern int zc0301_i2c_write(struct zc0301_device*, u16 address, u16 value);
81extern int zc0301_i2c_read(struct zc0301_device*, u16 address, u8 length);
82
83/*****************************************************************************/
84
Luca Risolia7e3a0662007-01-08 11:34:35 -030085#define ZC0301_MAX_CTRLS (V4L2_CID_LASTP1 - V4L2_CID_BASE + 10)
86#define ZC0301_V4L2_CID_DAC_MAGNITUDE (V4L2_CID_PRIVATE_BASE + 0)
87#define ZC0301_V4L2_CID_GREEN_BALANCE (V4L2_CID_PRIVATE_BASE + 1)
Luca Risolia60f78052006-02-06 16:29:35 +000088
89struct zc0301_sensor {
90 char name[32];
91
92 struct v4l2_queryctrl qctrl[ZC0301_MAX_CTRLS];
93 struct v4l2_cropcap cropcap;
94 struct v4l2_pix_format pix_format;
95
Luca Risoliaa8474232006-02-25 06:57:49 +000096 int (*init)(struct zc0301_device*);
97 int (*get_ctrl)(struct zc0301_device*, struct v4l2_control* ctrl);
98 int (*set_ctrl)(struct zc0301_device*,
Mauro Carvalho Chehabd56410e2006-03-25 09:19:53 -030099 const struct v4l2_control* ctrl);
Luca Risoliaa8474232006-02-25 06:57:49 +0000100 int (*set_crop)(struct zc0301_device*, const struct v4l2_rect* rect);
Luca Risolia60f78052006-02-06 16:29:35 +0000101
102 /* Private */
103 struct v4l2_queryctrl _qctrl[ZC0301_MAX_CTRLS];
104 struct v4l2_rect _rect;
105};
106
107#endif /* _ZC0301_SENSOR_H_ */