treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / media / i2c / smiapp / smiapp.h
blob4837d80dc453e8c11c739c80f56cdfaacc9a64ca
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * drivers/media/i2c/smiapp/smiapp.h
5 * Generic driver for SMIA/SMIA++ compliant camera modules
7 * Copyright (C) 2010--2012 Nokia Corporation
8 * Contact: Sakari Ailus <sakari.ailus@iki.fi>
9 */
11 #ifndef __SMIAPP_PRIV_H_
12 #define __SMIAPP_PRIV_H_
14 #include <linux/mutex.h>
15 #include <media/v4l2-ctrls.h>
16 #include <media/v4l2-subdev.h>
17 #include <media/i2c/smiapp.h>
19 #include "smiapp-pll.h"
20 #include "smiapp-reg.h"
21 #include "smiapp-regs.h"
22 #include "smiapp-quirk.h"
25 * Standard SMIA++ constants
27 #define SMIA_VERSION_1 10
28 #define SMIAPP_VERSION_0_8 8 /* Draft 0.8 */
29 #define SMIAPP_VERSION_0_9 9 /* Draft 0.9 */
30 #define SMIAPP_VERSION_1 10
32 #define SMIAPP_PROFILE_0 0
33 #define SMIAPP_PROFILE_1 1
34 #define SMIAPP_PROFILE_2 2
36 #define SMIAPP_NVM_PAGE_SIZE 64 /* bytes */
38 #define SMIAPP_RESET_DELAY_CLOCKS 2400
39 #define SMIAPP_RESET_DELAY(clk) \
40 (1000 + (SMIAPP_RESET_DELAY_CLOCKS * 1000 \
41 + (clk) / 1000 - 1) / ((clk) / 1000))
43 #define SMIAPP_COLOUR_COMPONENTS 4
45 #include "smiapp-limits.h"
47 struct smiapp_quirk;
49 #define SMIAPP_MODULE_IDENT_FLAG_REV_LE (1 << 0)
51 struct smiapp_module_ident {
52 u8 manufacturer_id;
53 u16 model_id;
54 u8 revision_number_major;
56 u8 flags;
58 char *name;
59 const struct smiapp_quirk *quirk;
62 struct smiapp_module_info {
63 u32 manufacturer_id;
64 u32 model_id;
65 u32 revision_number_major;
66 u32 revision_number_minor;
68 u32 module_year;
69 u32 module_month;
70 u32 module_day;
72 u32 sensor_manufacturer_id;
73 u32 sensor_model_id;
74 u32 sensor_revision_number;
75 u32 sensor_firmware_version;
77 u32 smia_version;
78 u32 smiapp_version;
80 u32 smiapp_profile;
82 char *name;
83 const struct smiapp_quirk *quirk;
86 #define SMIAPP_IDENT_FQ(manufacturer, model, rev, fl, _name, _quirk) \
87 { .manufacturer_id = manufacturer, \
88 .model_id = model, \
89 .revision_number_major = rev, \
90 .flags = fl, \
91 .name = _name, \
92 .quirk = _quirk, }
94 #define SMIAPP_IDENT_LQ(manufacturer, model, rev, _name, _quirk) \
95 { .manufacturer_id = manufacturer, \
96 .model_id = model, \
97 .revision_number_major = rev, \
98 .flags = SMIAPP_MODULE_IDENT_FLAG_REV_LE, \
99 .name = _name, \
100 .quirk = _quirk, }
102 #define SMIAPP_IDENT_L(manufacturer, model, rev, _name) \
103 { .manufacturer_id = manufacturer, \
104 .model_id = model, \
105 .revision_number_major = rev, \
106 .flags = SMIAPP_MODULE_IDENT_FLAG_REV_LE, \
107 .name = _name, }
109 #define SMIAPP_IDENT_Q(manufacturer, model, rev, _name, _quirk) \
110 { .manufacturer_id = manufacturer, \
111 .model_id = model, \
112 .revision_number_major = rev, \
113 .flags = 0, \
114 .name = _name, \
115 .quirk = _quirk, }
117 #define SMIAPP_IDENT(manufacturer, model, rev, _name) \
118 { .manufacturer_id = manufacturer, \
119 .model_id = model, \
120 .revision_number_major = rev, \
121 .flags = 0, \
122 .name = _name, }
124 struct smiapp_reg_limits {
125 u32 addr;
126 char *what;
129 extern struct smiapp_reg_limits smiapp_reg_limits[];
131 struct smiapp_csi_data_format {
132 u32 code;
133 u8 width;
134 u8 compressed;
135 u8 pixel_order;
138 #define SMIAPP_SUBDEVS 3
140 #define SMIAPP_PA_PAD_SRC 0
141 #define SMIAPP_PAD_SINK 0
142 #define SMIAPP_PAD_SRC 1
143 #define SMIAPP_PADS 2
145 struct smiapp_binning_subtype {
146 u8 horizontal:4;
147 u8 vertical:4;
148 } __packed;
150 struct smiapp_subdev {
151 struct v4l2_subdev sd;
152 struct media_pad pads[SMIAPP_PADS];
153 struct v4l2_rect sink_fmt;
154 struct v4l2_rect crop[SMIAPP_PADS];
155 struct v4l2_rect compose; /* compose on sink */
156 unsigned short sink_pad;
157 unsigned short source_pad;
158 int npads;
159 struct smiapp_sensor *sensor;
160 struct v4l2_ctrl_handler ctrl_handler;
164 * struct smiapp_sensor - Main device structure
166 struct smiapp_sensor {
168 * "mutex" is used to serialise access to all fields here
169 * except v4l2_ctrls at the end of the struct. "mutex" is also
170 * used to serialise access to file handle specific
171 * information.
173 struct mutex mutex;
174 struct smiapp_subdev ssds[SMIAPP_SUBDEVS];
175 u32 ssds_used;
176 struct smiapp_subdev *src;
177 struct smiapp_subdev *binner;
178 struct smiapp_subdev *scaler;
179 struct smiapp_subdev *pixel_array;
180 struct smiapp_hwconfig *hwcfg;
181 struct regulator *vana;
182 struct clk *ext_clk;
183 struct gpio_desc *xshutdown;
184 u32 limits[SMIAPP_LIMIT_LAST];
185 u8 nbinning_subtypes;
186 struct smiapp_binning_subtype binning_subtypes[SMIAPP_BINNING_SUBTYPES];
187 u32 mbus_frame_fmts;
188 const struct smiapp_csi_data_format *csi_format;
189 const struct smiapp_csi_data_format *internal_csi_format;
190 u32 default_mbus_frame_fmts;
191 int default_pixel_order;
193 u8 binning_horizontal;
194 u8 binning_vertical;
196 u8 scale_m;
197 u8 scaling_mode;
199 u8 hvflip_inv_mask; /* H/VFLIP inversion due to sensor orientation */
200 u8 frame_skip;
201 u16 embedded_start; /* embedded data start line */
202 u16 embedded_end;
203 u16 image_start; /* image data start line */
204 u16 visible_pixel_start; /* start pixel of the visible image */
206 bool streaming;
207 bool dev_init_done;
208 u8 compressed_min_bpp;
210 struct smiapp_module_info minfo;
212 struct smiapp_pll pll;
214 /* Is a default format supported for a given BPP? */
215 unsigned long *valid_link_freqs;
217 /* Pixel array controls */
218 struct v4l2_ctrl *analog_gain;
219 struct v4l2_ctrl *exposure;
220 struct v4l2_ctrl *hflip;
221 struct v4l2_ctrl *vflip;
222 struct v4l2_ctrl *vblank;
223 struct v4l2_ctrl *hblank;
224 struct v4l2_ctrl *pixel_rate_parray;
225 /* src controls */
226 struct v4l2_ctrl *link_freq;
227 struct v4l2_ctrl *pixel_rate_csi;
228 /* test pattern colour components */
229 struct v4l2_ctrl *test_data[SMIAPP_COLOUR_COMPONENTS];
232 #define to_smiapp_subdev(_sd) \
233 container_of(_sd, struct smiapp_subdev, sd)
235 #define to_smiapp_sensor(_sd) \
236 (to_smiapp_subdev(_sd)->sensor)
238 #endif /* __SMIAPP_PRIV_H_ */