2 * drivers/media/i2c/smiapp/smiapp.h
4 * Generic driver for SMIA/SMIA++ compliant camera modules
6 * Copyright (C) 2010--2012 Nokia Corporation
7 * Contact: Sakari Ailus <sakari.ailus@iki.fi>
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.
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.
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
25 #ifndef __SMIAPP_PRIV_H_
26 #define __SMIAPP_PRIV_H_
28 #include <linux/mutex.h>
29 #include <media/v4l2-ctrls.h>
30 #include <media/v4l2-subdev.h>
31 #include <media/smiapp.h>
33 #include "smiapp-pll.h"
34 #include "smiapp-reg.h"
35 #include "smiapp-regs.h"
36 #include "smiapp-quirk.h"
39 * Standard SMIA++ constants
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
46 #define SMIAPP_PROFILE_0 0
47 #define SMIAPP_PROFILE_1 1
48 #define SMIAPP_PROFILE_2 2
50 #define SMIAPP_NVM_PAGE_SIZE 64 /* bytes */
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))
57 #include "smiapp-limits.h"
61 #define SMIAPP_MODULE_IDENT_FLAG_REV_LE (1 << 0)
63 struct smiapp_module_ident
{
66 u8 revision_number_major
;
71 const struct smiapp_quirk
*quirk
;
74 struct smiapp_module_info
{
77 u32 revision_number_major
;
78 u32 revision_number_minor
;
84 u32 sensor_manufacturer_id
;
86 u32 sensor_revision_number
;
87 u32 sensor_firmware_version
;
95 const struct smiapp_quirk
*quirk
;
98 #define SMIAPP_IDENT_FQ(manufacturer, model, rev, fl, _name, _quirk) \
99 { .manufacturer_id = manufacturer, \
101 .revision_number_major = rev, \
106 #define SMIAPP_IDENT_LQ(manufacturer, model, rev, _name, _quirk) \
107 { .manufacturer_id = manufacturer, \
109 .revision_number_major = rev, \
110 .flags = SMIAPP_MODULE_IDENT_FLAG_REV_LE, \
114 #define SMIAPP_IDENT_L(manufacturer, model, rev, _name) \
115 { .manufacturer_id = manufacturer, \
117 .revision_number_major = rev, \
118 .flags = SMIAPP_MODULE_IDENT_FLAG_REV_LE, \
121 #define SMIAPP_IDENT_Q(manufacturer, model, rev, _name, _quirk) \
122 { .manufacturer_id = manufacturer, \
124 .revision_number_major = rev, \
129 #define SMIAPP_IDENT(manufacturer, model, rev, _name) \
130 { .manufacturer_id = manufacturer, \
132 .revision_number_major = rev, \
136 struct smiapp_reg_limits
{
141 extern struct smiapp_reg_limits smiapp_reg_limits
[];
143 struct smiapp_csi_data_format
{
150 #define SMIAPP_SUBDEVS 3
152 #define SMIAPP_PA_PAD_SRC 0
153 #define SMIAPP_PAD_SINK 0
154 #define SMIAPP_PAD_SRC 1
155 #define SMIAPP_PADS 2
157 struct smiapp_binning_subtype
{
162 struct smiapp_subdev
{
163 struct v4l2_subdev sd
;
164 struct media_pad pads
[2];
165 struct v4l2_rect sink_fmt
;
166 struct v4l2_rect crop
[2];
167 struct v4l2_rect compose
; /* compose on sink */
168 unsigned short sink_pad
;
169 unsigned short source_pad
;
171 struct smiapp_sensor
*sensor
;
172 struct v4l2_ctrl_handler ctrl_handler
;
176 * struct smiapp_sensor - Main device structure
178 struct smiapp_sensor
{
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
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.
192 struct mutex power_mutex
;
193 struct smiapp_subdev ssds
[SMIAPP_SUBDEVS
];
195 struct smiapp_subdev
*src
;
196 struct smiapp_subdev
*binner
;
197 struct smiapp_subdev
*scaler
;
198 struct smiapp_subdev
*pixel_array
;
199 struct smiapp_platform_data
*platform_data
;
200 struct regulator
*vana
;
202 u32 limits
[SMIAPP_LIMIT_LAST
];
203 u8 nbinning_subtypes
;
204 struct smiapp_binning_subtype binning_subtypes
[SMIAPP_BINNING_SUBTYPES
];
206 const struct smiapp_csi_data_format
*csi_format
;
207 const struct smiapp_csi_data_format
*internal_csi_format
;
208 u32 default_mbus_frame_fmts
;
209 int default_pixel_order
;
211 u8 binning_horizontal
;
217 u8 hvflip_inv_mask
; /* H/VFLIP inversion due to sensor orientation */
226 u8
*nvm
; /* nvm memory buffer */
227 unsigned int nvm_size
; /* bytes */
229 struct smiapp_module_info minfo
;
231 struct smiapp_pll pll
;
233 /* Pixel array controls */
234 struct v4l2_ctrl
*analog_gain
;
235 struct v4l2_ctrl
*exposure
;
236 struct v4l2_ctrl
*hflip
;
237 struct v4l2_ctrl
*vflip
;
238 struct v4l2_ctrl
*vblank
;
239 struct v4l2_ctrl
*hblank
;
240 struct v4l2_ctrl
*pixel_rate_parray
;
242 struct v4l2_ctrl
*link_freq
;
243 struct v4l2_ctrl
*pixel_rate_csi
;
246 #define to_smiapp_subdev(_sd) \
247 container_of(_sd, struct smiapp_subdev, sd)
249 #define to_smiapp_sensor(_sd) \
250 (to_smiapp_subdev(_sd)->sensor)
252 #endif /* __SMIAPP_PRIV_H_ */