Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
smiapp.h
Go to the documentation of this file.
1 /*
2  * drivers/media/i2c/smiapp/smiapp.h
3  *
4  * Generic driver for SMIA/SMIA++ compliant camera modules
5  *
6  * Copyright (C) 2010--2012 Nokia Corporation
7  * Contact: Sakari Ailus <[email protected]>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * version 2 as published by the Free Software Foundation.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  */
24 
25 #ifndef __SMIAPP_PRIV_H_
26 #define __SMIAPP_PRIV_H_
27 
28 #include <linux/mutex.h>
29 #include <media/v4l2-ctrls.h>
30 #include <media/v4l2-subdev.h>
31 #include <media/smiapp.h>
32 
33 #include "smiapp-pll.h"
34 #include "smiapp-reg.h"
35 #include "smiapp-regs.h"
36 #include "smiapp-quirk.h"
37 
38 /*
39  * Standard SMIA++ constants
40  */
41 #define SMIA_VERSION_1 10
42 #define SMIAPP_VERSION_0_8 8 /* Draft 0.8 */
43 #define SMIAPP_VERSION_0_9 9 /* Draft 0.9 */
44 #define SMIAPP_VERSION_1 10
45 
46 #define SMIAPP_PROFILE_0 0
47 #define SMIAPP_PROFILE_1 1
48 #define SMIAPP_PROFILE_2 2
49 
50 #define SMIAPP_NVM_PAGE_SIZE 64 /* bytes */
51 
52 #define SMIAPP_RESET_DELAY_CLOCKS 2400
53 #define SMIAPP_RESET_DELAY(clk) \
54  (1000 + (SMIAPP_RESET_DELAY_CLOCKS * 1000 \
55  + (clk) / 1000 - 1) / ((clk) / 1000))
56 
57 #include "smiapp-limits.h"
58 
59 struct smiapp_quirk;
60 
61 #define SMIAPP_MODULE_IDENT_FLAG_REV_LE (1 << 0)
62 
67 
69 
70  char *name;
71  const struct smiapp_quirk *quirk;
72 };
73 
79 
83 
88 
91 
93 
94  char *name;
95  const struct smiapp_quirk *quirk;
96 };
97 
98 #define SMIAPP_IDENT_FQ(manufacturer, model, rev, fl, _name, _quirk) \
99  { .manufacturer_id = manufacturer, \
100  .model_id = model, \
101  .revision_number_major = rev, \
102  .flags = fl, \
103  .name = _name, \
104  .quirk = _quirk, }
105 
106 #define SMIAPP_IDENT_LQ(manufacturer, model, rev, _name, _quirk) \
107  { .manufacturer_id = manufacturer, \
108  .model_id = model, \
109  .revision_number_major = rev, \
110  .flags = SMIAPP_MODULE_IDENT_FLAG_REV_LE, \
111  .name = _name, \
112  .quirk = _quirk, }
113 
114 #define SMIAPP_IDENT_L(manufacturer, model, rev, _name) \
115  { .manufacturer_id = manufacturer, \
116  .model_id = model, \
117  .revision_number_major = rev, \
118  .flags = SMIAPP_MODULE_IDENT_FLAG_REV_LE, \
119  .name = _name, }
120 
121 #define SMIAPP_IDENT_Q(manufacturer, model, rev, _name, _quirk) \
122  { .manufacturer_id = manufacturer, \
123  .model_id = model, \
124  .revision_number_major = rev, \
125  .flags = 0, \
126  .name = _name, \
127  .quirk = _quirk, }
128 
129 #define SMIAPP_IDENT(manufacturer, model, rev, _name) \
130  { .manufacturer_id = manufacturer, \
131  .model_id = model, \
132  .revision_number_major = rev, \
133  .flags = 0, \
134  .name = _name, }
135 
138  char *what;
139 };
140 
141 extern struct smiapp_reg_limits smiapp_reg_limits[];
142 
148 };
149 
150 #define SMIAPP_SUBDEVS 3
151 
152 #define SMIAPP_PA_PAD_SRC 0
153 #define SMIAPP_PAD_SINK 0
154 #define SMIAPP_PAD_SRC 1
155 #define SMIAPP_PADS 2
156 
160 } __packed;
161 
163  struct v4l2_subdev sd;
164  struct media_pad pads[2];
166  struct v4l2_rect crop[2];
167  struct v4l2_rect compose; /* compose on sink */
168  unsigned short sink_pad;
169  unsigned short source_pad;
170  int npads;
173 };
174 
175 /*
176  * struct smiapp_sensor - Main device structure
177  */
179  /*
180  * "mutex" is used to serialise access to all fields here
181  * except v4l2_ctrls at the end of the struct. "mutex" is also
182  * used to serialise access to file handle specific
183  * information. The exception to this rule is the power_mutex
184  * below.
185  */
186  struct mutex mutex;
187  /*
188  * power_mutex is used to serialise power management related
189  * activities. Acquiring "mutex" at that time isn't necessary
190  * since there are no other users anyway.
191  */
200  struct regulator *vana;
201  struct clk *ext_clk;
210 
213 
216 
217  u8 hvflip_inv_mask; /* H/VFLIP inversion due to sensor orientation */
220 
222 
223  bool streaming;
225 
226  u8 *nvm; /* nvm memory buffer */
227  unsigned int nvm_size; /* bytes */
228 
230 
231  struct smiapp_pll pll;
232 
233  /* Pixel array controls */
236  struct v4l2_ctrl *hflip;
237  struct v4l2_ctrl *vflip;
238  struct v4l2_ctrl *vblank;
239  struct v4l2_ctrl *hblank;
241  /* src controls */
244 };
245 
246 #define to_smiapp_subdev(_sd) \
247  container_of(_sd, struct smiapp_subdev, sd)
248 
249 #define to_smiapp_sensor(_sd) \
250  (to_smiapp_subdev(_sd)->sensor)
251 
252 #endif /* __SMIAPP_PRIV_H_ */