1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22#ifndef _ZC0301_SENSOR_H_
23#define _ZC0301_SENSOR_H_
24
25#include <linux/usb.h>
26#include <linux/videodev2.h>
27#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);
38extern int zc0301_probe_pb0330(struct zc0301_device* cam);
39
40#define ZC0301_SENSOR_TABLE \
41 \
42static int (*zc0301_sensor_table[])(struct zc0301_device*) = { \
43 &zc0301_probe_pas202bcb, \
44 &zc0301_probe_pb0330, \
45 NULL, \
46};
47
48extern struct zc0301_device*
49zc0301_match_id(struct zc0301_device* cam, const struct usb_device_id *id);
50
51extern void
52zc0301_attach_sensor(struct zc0301_device* cam, struct zc0301_sensor* sensor);
53
54#define ZC0301_USB_DEVICE(vend, prod, intclass) \
55 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
56 USB_DEVICE_ID_MATCH_INT_CLASS, \
57 .idVendor = (vend), \
58 .idProduct = (prod), \
59 .bInterfaceClass = (intclass)
60
61#if !defined CONFIG_USB_GSPCA && !defined CONFIG_USB_GSPCA_MODULE
62#define ZC0301_ID_TABLE \
63static const struct usb_device_id zc0301_id_table[] = { \
64 { ZC0301_USB_DEVICE(0x046d, 0x08ae, 0xff), }, \
65 { ZC0301_USB_DEVICE(0x0ac8, 0x303b, 0xff), }, \
66 { } \
67};
68#else
69#define ZC0301_ID_TABLE \
70static const struct usb_device_id zc0301_id_table[] = { \
71 { ZC0301_USB_DEVICE(0x046d, 0x08ae, 0xff), }, \
72 { } \
73};
74#endif
75
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
85#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)
88
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
96 int (*init)(struct zc0301_device*);
97 int (*get_ctrl)(struct zc0301_device*, struct v4l2_control* ctrl);
98 int (*set_ctrl)(struct zc0301_device*,
99 const struct v4l2_control* ctrl);
100 int (*set_crop)(struct zc0301_device*, const struct v4l2_rect* rect);
101
102
103 struct v4l2_queryctrl _qctrl[ZC0301_MAX_CTRLS];
104 struct v4l2_rect _rect;
105};
106
107#endif
108