V4L/DVB (8906): v4l-dvb: fix assorted sparse warnings
[safe/jmp/linux-2.6] / 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/ovcamchip.h>
20
21 #ifdef DEBUG
22 extern int ovcamchip_debug;
23 #endif
24
25 #define PDEBUG(level, fmt, args...) \
26         if (ovcamchip_debug >= (level)) pr_debug("[%s:%d] " fmt "\n", \
27                 __func__, __LINE__ , ## args)
28
29 #define DDEBUG(level, dev, fmt, args...) \
30         if (ovcamchip_debug >= (level)) dev_dbg(dev, "[%s:%d] " fmt "\n", \
31                 __func__, __LINE__ , ## args)
32
33 /* Number of times to retry chip detection. Increase this if you are getting
34  * "Failed to init camera chip" */
35 #define I2C_DETECT_RETRIES      10
36
37 struct ovcamchip_regvals {
38         unsigned char reg;
39         unsigned char val;
40 };
41
42 struct ovcamchip_ops {
43         int (*init)(struct i2c_client *);
44         int (*free)(struct i2c_client *);
45         int (*command)(struct i2c_client *, unsigned int, void *);
46 };
47
48 struct ovcamchip {
49         struct ovcamchip_ops *sops;
50         void *spriv;               /* Private data for OV7x10.c etc... */
51         int subtype;               /* = SEN_OV7610 etc... */
52         int mono;                  /* Monochrome chip? (invalid until init) */
53         int initialized;           /* OVCAMCHIP_CMD_INITIALIZE was successful */
54 };
55
56 extern struct ovcamchip_ops ov6x20_ops;
57 extern struct ovcamchip_ops ov6x30_ops;
58 extern struct ovcamchip_ops ov7x10_ops;
59 extern struct ovcamchip_ops ov7x20_ops;
60 extern struct ovcamchip_ops ov76be_ops;
61
62 /* --------------------------------- */
63 /*              I2C I/O              */
64 /* --------------------------------- */
65
66 static inline int ov_read(struct i2c_client *c, unsigned char reg,
67                           unsigned char *value)
68 {
69         int rc;
70
71         rc = i2c_smbus_read_byte_data(c, reg);
72         *value = (unsigned char) rc;
73         return rc;
74 }
75
76 static inline int ov_write(struct i2c_client *c, unsigned char reg,
77                            unsigned char value )
78 {
79         return i2c_smbus_write_byte_data(c, reg, value);
80 }
81
82 /* --------------------------------- */
83 /*        FUNCTION PROTOTYPES        */
84 /* --------------------------------- */
85
86 /* Functions in ovcamchip_core.c */
87
88 extern int ov_write_regvals(struct i2c_client *c,
89                             struct ovcamchip_regvals *rvals);
90
91 extern int ov_write_mask(struct i2c_client *c, unsigned char reg,
92                          unsigned char value, unsigned char mask);
93
94 #endif