]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/media/video/ovcamchip/ovcamchip_priv.h
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
[linux-2.6-omap-h63xx.git] / drivers / media / video / ovcamchip / ovcamchip_priv.h
1 /* OmniVision* camera chip driver private definitions for core code and
2  * chip-specific code
3  *
4  * Copyright (c) 1999-2004 Mark McClelland
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the
8  * Free Software Foundation; either version 2 of the License, or (at your
9  * option) any later version. NO WARRANTY OF ANY KIND is expressed or implied.
10  *
11  * * OmniVision is a trademark of OmniVision Technologies, Inc. This driver
12  * is not sponsored or developed by them.
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
23 extern 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 /* Number of times to retry chip detection. Increase this if you are getting
35  * "Failed to init camera chip" */
36 #define I2C_DETECT_RETRIES      10
37
38 struct ovcamchip_regvals {
39         unsigned char reg;
40         unsigned char val;
41 };
42
43 struct 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
49 struct ovcamchip {
50         struct v4l2_subdev sd;
51         struct ovcamchip_ops *sops;
52         void *spriv;               /* Private data for OV7x10.c etc... */
53         int subtype;               /* = SEN_OV7610 etc... */
54         int mono;                  /* Monochrome chip? (invalid until init) */
55         int initialized;           /* OVCAMCHIP_CMD_INITIALIZE was successful */
56 };
57
58 static inline struct ovcamchip *to_ovcamchip(struct v4l2_subdev *sd)
59 {
60         return container_of(sd, struct ovcamchip, sd);
61 }
62
63 extern struct ovcamchip_ops ov6x20_ops;
64 extern struct ovcamchip_ops ov6x30_ops;
65 extern struct ovcamchip_ops ov7x10_ops;
66 extern struct ovcamchip_ops ov7x20_ops;
67 extern struct ovcamchip_ops ov76be_ops;
68
69 /* --------------------------------- */
70 /*              I2C I/O              */
71 /* --------------------------------- */
72
73 static 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
83 static 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 /*        FUNCTION PROTOTYPES        */
91 /* --------------------------------- */
92
93 /* Functions in ovcamchip_core.c */
94
95 extern int ov_write_regvals(struct i2c_client *c,
96                             struct ovcamchip_regvals *rvals);
97
98 extern int ov_write_mask(struct i2c_client *c, unsigned char reg,
99                          unsigned char value, unsigned char mask);
100
101 #endif