1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef __LINUX_OVCAMCHIP_PRIV_H
16#define __LINUX_OVCAMCHIP_PRIV_H
17
18#include <linux/i2c.h>
19#include <media/v4l2-subdev.h>
20#include <media/ovcamchip.h>
21
22#ifdef DEBUG
23extern int ovcamchip_debug;
24#endif
25
26#define PDEBUG(level, fmt, args...) \
27 if (ovcamchip_debug >= (level)) pr_debug("[%s:%d] " fmt "\n", \
28 __func__, __LINE__ , ## args)
29
30#define DDEBUG(level, dev, fmt, args...) \
31 if (ovcamchip_debug >= (level)) dev_dbg(dev, "[%s:%d] " fmt "\n", \
32 __func__, __LINE__ , ## args)
33
34
35
36#define I2C_DETECT_RETRIES 10
37
38struct ovcamchip_regvals {
39 unsigned char reg;
40 unsigned char val;
41};
42
43struct ovcamchip_ops {
44 int (*init)(struct i2c_client *);
45 int (*free)(struct i2c_client *);
46 int (*command)(struct i2c_client *, unsigned int, void *);
47};
48
49struct ovcamchip {
50 struct v4l2_subdev sd;
51 struct ovcamchip_ops *sops;
52 void *spriv;
53 int subtype;
54 int mono;
55 int initialized;
56};
57
58static inline struct ovcamchip *to_ovcamchip(struct v4l2_subdev *sd)
59{
60 return container_of(sd, struct ovcamchip, sd);
61}
62
63extern struct ovcamchip_ops ov6x20_ops;
64extern struct ovcamchip_ops ov6x30_ops;
65extern struct ovcamchip_ops ov7x10_ops;
66extern struct ovcamchip_ops ov7x20_ops;
67extern struct ovcamchip_ops ov76be_ops;
68
69
70
71
72
73static inline int ov_read(struct i2c_client *c, unsigned char reg,
74 unsigned char *value)
75{
76 int rc;
77
78 rc = i2c_smbus_read_byte_data(c, reg);
79 *value = (unsigned char) rc;
80 return rc;
81}
82
83static inline int ov_write(struct i2c_client *c, unsigned char reg,
84 unsigned char value )
85{
86 return i2c_smbus_write_byte_data(c, reg, value);
87}
88
89
90
91
92
93
94
95extern int ov_write_regvals(struct i2c_client *c,
96 struct ovcamchip_regvals *rvals);
97
98extern int ov_write_mask(struct i2c_client *c, unsigned char reg,
99 unsigned char value, unsigned char mask);
100
101#endif
102