Linux 2.6.34-rc3
[pohmelfs.git] / drivers / media / video / ovcamchip / ovcamchip_priv.h
blob4f07b78c88bc347f8fd5c7ef7214dc748074f9d3
1 /* OmniVision* camera chip driver private definitions for core code and
2 * chip-specific code
4 * Copyright (c) 1999-2004 Mark McClelland
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.
11 * * OmniVision is a trademark of OmniVision Technologies, Inc. This driver
12 * is not sponsored or developed by them.
15 #ifndef __LINUX_OVCAMCHIP_PRIV_H
16 #define __LINUX_OVCAMCHIP_PRIV_H
18 #include <linux/i2c.h>
19 #include <media/v4l2-subdev.h>
20 #include <media/ovcamchip.h>
22 #ifdef DEBUG
23 extern int ovcamchip_debug;
24 #endif
26 #define PDEBUG(level, fmt, args...) \
27 if (ovcamchip_debug >= (level)) pr_debug("[%s:%d] " fmt "\n", \
28 __func__, __LINE__ , ## args)
30 #define DDEBUG(level, dev, fmt, args...) \
31 if (ovcamchip_debug >= (level)) dev_dbg(dev, "[%s:%d] " fmt "\n", \
32 __func__, __LINE__ , ## args)
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
38 struct ovcamchip_regvals {
39 unsigned char reg;
40 unsigned char val;
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 *);
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 */
58 static inline struct ovcamchip *to_ovcamchip(struct v4l2_subdev *sd)
60 return container_of(sd, struct ovcamchip, sd);
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;
69 /* --------------------------------- */
70 /* I2C I/O */
71 /* --------------------------------- */
73 static inline int ov_read(struct i2c_client *c, unsigned char reg,
74 unsigned char *value)
76 int rc;
78 rc = i2c_smbus_read_byte_data(c, reg);
79 *value = (unsigned char) rc;
80 return rc;
83 static inline int ov_write(struct i2c_client *c, unsigned char reg,
84 unsigned char value )
86 return i2c_smbus_write_byte_data(c, reg, value);
89 /* --------------------------------- */
90 /* FUNCTION PROTOTYPES */
91 /* --------------------------------- */
93 /* Functions in ovcamchip_core.c */
95 extern int ov_write_regvals(struct i2c_client *c,
96 struct ovcamchip_regvals *rvals);
98 extern int ov_write_mask(struct i2c_client *c, unsigned char reg,
99 unsigned char value, unsigned char mask);
101 #endif