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.
19 #ifndef __SMIAPP_PRIV_H_
20 #define __SMIAPP_PRIV_H_
22 #include <linux/mutex.h>
23 #include <media/v4l2-ctrls.h>
24 #include <media/v4l2-subdev.h>
25 #include <media/i2c/smiapp.h>
27 #include "smiapp-pll.h"
28 #include "smiapp-reg.h"
29 #include "smiapp-regs.h"
30 #include "smiapp-quirk.h"
33 * Standard SMIA++ constants
35 #define SMIA_VERSION_1 10
36 #define SMIAPP_VERSION_0_8 8 /* Draft 0.8 */
37 #define SMIAPP_VERSION_0_9 9 /* Draft 0.9 */
38 #define SMIAPP_VERSION_1 10
40 #define SMIAPP_PROFILE_0 0
41 #define SMIAPP_PROFILE_1 1
42 #define SMIAPP_PROFILE_2 2
44 #define SMIAPP_NVM_PAGE_SIZE 64 /* bytes */
46 #define SMIAPP_RESET_DELAY_CLOCKS 2400
47 #define SMIAPP_RESET_DELAY(clk) \
48 (1000 + (SMIAPP_RESET_DELAY_CLOCKS * 1000 \
49 + (clk) / 1000 - 1) / ((clk) / 1000))
51 #define SMIAPP_COLOUR_COMPONENTS 4
53 #include "smiapp-limits.h"
57 #define SMIAPP_MODULE_IDENT_FLAG_REV_LE (1 << 0)
59 struct smiapp_module_ident
{
62 u8 revision_number_major
;
67 const struct smiapp_quirk
*quirk
;
70 struct smiapp_module_info
{
73 u32 revision_number_major
;
74 u32 revision_number_minor
;
80 u32 sensor_manufacturer_id
;
82 u32 sensor_revision_number
;
83 u32 sensor_firmware_version
;
91 const struct smiapp_quirk
*quirk
;
94 #define SMIAPP_IDENT_FQ(manufacturer, model, rev, fl, _name, _quirk) \
95 { .manufacturer_id = manufacturer, \
97 .revision_number_major = rev, \
102 #define SMIAPP_IDENT_LQ(manufacturer, model, rev, _name, _quirk) \
103 { .manufacturer_id = manufacturer, \
105 .revision_number_major = rev, \
106 .flags = SMIAPP_MODULE_IDENT_FLAG_REV_LE, \
110 #define SMIAPP_IDENT_L(manufacturer, model, rev, _name) \
111 { .manufacturer_id = manufacturer, \
113 .revision_number_major = rev, \
114 .flags = SMIAPP_MODULE_IDENT_FLAG_REV_LE, \
117 #define SMIAPP_IDENT_Q(manufacturer, model, rev, _name, _quirk) \
118 { .manufacturer_id = manufacturer, \
120 .revision_number_major = rev, \
125 #define SMIAPP_IDENT(manufacturer, model, rev, _name) \
126 { .manufacturer_id = manufacturer, \
128 .revision_number_major = rev, \
132 struct smiapp_reg_limits
{
137 extern struct smiapp_reg_limits smiapp_reg_limits
[];
139 struct smiapp_csi_data_format
{
146 #define SMIAPP_SUBDEVS 3
148 #define SMIAPP_PA_PAD_SRC 0
149 #define SMIAPP_PAD_SINK 0
150 #define SMIAPP_PAD_SRC 1
151 #define SMIAPP_PADS 2
153 struct smiapp_binning_subtype
{
158 struct smiapp_subdev
{
159 struct v4l2_subdev sd
;
160 struct media_pad pads
[SMIAPP_PADS
];
161 struct v4l2_rect sink_fmt
;
162 struct v4l2_rect crop
[SMIAPP_PADS
];
163 struct v4l2_rect compose
; /* compose on sink */
164 unsigned short sink_pad
;
165 unsigned short source_pad
;
167 struct smiapp_sensor
*sensor
;
168 struct v4l2_ctrl_handler ctrl_handler
;
172 * struct smiapp_sensor - Main device structure
174 struct smiapp_sensor
{
176 * "mutex" is used to serialise access to all fields here
177 * except v4l2_ctrls at the end of the struct. "mutex" is also
178 * used to serialise access to file handle specific
182 struct smiapp_subdev ssds
[SMIAPP_SUBDEVS
];
184 struct smiapp_subdev
*src
;
185 struct smiapp_subdev
*binner
;
186 struct smiapp_subdev
*scaler
;
187 struct smiapp_subdev
*pixel_array
;
188 struct smiapp_hwconfig
*hwcfg
;
189 struct regulator
*vana
;
191 struct gpio_desc
*xshutdown
;
192 u32 limits
[SMIAPP_LIMIT_LAST
];
193 u8 nbinning_subtypes
;
194 struct smiapp_binning_subtype binning_subtypes
[SMIAPP_BINNING_SUBTYPES
];
196 const struct smiapp_csi_data_format
*csi_format
;
197 const struct smiapp_csi_data_format
*internal_csi_format
;
198 u32 default_mbus_frame_fmts
;
199 int default_pixel_order
;
201 u8 binning_horizontal
;
207 u8 hvflip_inv_mask
; /* H/VFLIP inversion due to sensor orientation */
209 u16 embedded_start
; /* embedded data start line */
211 u16 image_start
; /* image data start line */
212 u16 visible_pixel_start
; /* start pixel of the visible image */
216 u8 compressed_min_bpp
;
218 u8
*nvm
; /* nvm memory buffer */
219 unsigned int nvm_size
; /* bytes */
221 struct smiapp_module_info minfo
;
223 struct smiapp_pll pll
;
225 /* Is a default format supported for a given BPP? */
226 unsigned long *valid_link_freqs
;
228 /* Pixel array controls */
229 struct v4l2_ctrl
*analog_gain
;
230 struct v4l2_ctrl
*exposure
;
231 struct v4l2_ctrl
*hflip
;
232 struct v4l2_ctrl
*vflip
;
233 struct v4l2_ctrl
*vblank
;
234 struct v4l2_ctrl
*hblank
;
235 struct v4l2_ctrl
*pixel_rate_parray
;
237 struct v4l2_ctrl
*link_freq
;
238 struct v4l2_ctrl
*pixel_rate_csi
;
239 /* test pattern colour components */
240 struct v4l2_ctrl
*test_data
[SMIAPP_COLOUR_COMPONENTS
];
243 #define to_smiapp_subdev(_sd) \
244 container_of(_sd, struct smiapp_subdev, sd)
246 #define to_smiapp_sensor(_sd) \
247 (to_smiapp_subdev(_sd)->sensor)
249 #endif /* __SMIAPP_PRIV_H_ */