Developer World
Spresense SDK Library v3.3.0-375c679
imgsensor.h
1/****************************************************************************
2 * include/nuttx/video/imgsensor.h
3 *
4 * Licensed to the Apache Software Foundation (ASF) under one or more
5 * contributor license agreements. See the NOTICE file distributed with
6 * this work for additional information regarding copyright ownership. The
7 * ASF licenses this file to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance with the
9 * License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16 * License for the specific language governing permissions and limitations
17 * under the License.
18 *
19 ****************************************************************************/
20
21#ifndef __INCLUDE_NUTTX_VIDEO_IMGSENSOR_H
22#define __INCLUDE_NUTTX_VIDEO_IMGSENSOR_H
23
24/****************************************************************************
25 * Included Files
26 ****************************************************************************/
27
28#include <sys/types.h>
29#include <stdbool.h>
30
31/****************************************************************************
32 * Pre-processor Definitions
33 ****************************************************************************/
34
35/* Camera parameter IDs */
36
37#define IMGSENSOR_ID_BRIGHTNESS (0x00000100)
38#define IMGSENSOR_ID_CONTRAST (0x00000101)
39#define IMGSENSOR_ID_SATURATION (0x00000102)
40#define IMGSENSOR_ID_HUE (0x00000103)
41#define IMGSENSOR_ID_AUTO_WHITE_BALANCE (0x00000104)
42#define IMGSENSOR_ID_RED_BALANCE (0x00000105)
43#define IMGSENSOR_ID_BLUE_BALANCE (0x00000106)
44#define IMGSENSOR_ID_GAMMA (0x00000107)
45#define IMGSENSOR_ID_GAMMA_CURVE (0x00000108)
46#define IMGSENSOR_ID_EXPOSURE (0x00000109)
47#define IMGSENSOR_ID_HFLIP_VIDEO (0x0000010a)
48#define IMGSENSOR_ID_VFLIP_VIDEO (0x0000010b)
49#define IMGSENSOR_ID_HFLIP_STILL (0x0000010c)
50#define IMGSENSOR_ID_VFLIP_STILL (0x0000010d)
51#define IMGSENSOR_ID_SHARPNESS (0x0000010e)
52#define IMGSENSOR_ID_COLOR_KILLER (0x0000010f)
53#define IMGSENSOR_ID_COLORFX (0x00000110)
54#define IMGSENSOR_ID_AUTOBRIGHTNESS (0x00000111)
55#define IMGSENSOR_ID_ROTATE (0x00000112)
56#define IMGSENSOR_ID_EXPOSURE_AUTO (0x00000200)
57#define IMGSENSOR_ID_EXPOSURE_ABSOLUTE (0x00000201)
58#define IMGSENSOR_ID_FOCUS_ABSOLUTE (0x00000202)
59#define IMGSENSOR_ID_FOCUS_RELATIVE (0x00000203)
60#define IMGSENSOR_ID_FOCUS_AUTO (0x00000204)
61#define IMGSENSOR_ID_ZOOM_ABSOLUTE (0x00000205)
62#define IMGSENSOR_ID_ZOOM_RELATIVE (0x00000206)
63#define IMGSENSOR_ID_ZOOM_CONTINUOUS (0x00000207)
64#define IMGSENSOR_ID_IRIS_ABSOLUTE (0x00000208)
65#define IMGSENSOR_ID_IRIS_RELATIVE (0x00000209)
66#define IMGSENSOR_ID_AUTO_N_PRESET_WB (0x0000020a)
67#define IMGSENSOR_ID_WIDE_DYNAMIC_RANGE (0x0000020b)
68#define IMGSENSOR_ID_IMG_STABILIZATION (0x0000020c)
69#define IMGSENSOR_ID_ISO_SENSITIVITY (0x0000020d)
70#define IMGSENSOR_ID_ISO_SENSITIVITY_AUTO (0x0000020e)
71#define IMGSENSOR_ID_EXPOSURE_METERING (0x0000020f)
72#define IMGSENSOR_ID_SPOT_POSITION (0x00000216)
73#define IMGSENSOR_ID_3A_LOCK (0x00000211)
74#define IMGSENSOR_ID_AUTO_FOCUS_START (0x00000212)
75#define IMGSENSOR_ID_AUTO_FOCUS_STOP (0x00000213)
76#define IMGSENSOR_ID_3A_PARAMETER (0x00000214)
77#define IMGSENSOR_ID_3A_STATUS (0x00000215)
78#define IMGSENSOR_ID_FLASH_LED_MODE (0x00000300)
79#define IMGSENSOR_ID_JPEG_QUALITY (0x00000400)
80#define IMGSENSOR_ID_CLIP_VIDEO (0xFFFF0000)
81#define IMGSENSOR_ID_CLIP_STILL (0xFFFF0001)
82
83/* Number of elements in clip data array
84 * in IMGSENSOR_ID_CLIP_VIDEO and IMGSENSOR_ID_CLIP_STILL case
85 */
86
87#define IMGSENSOR_CLIP_NELEM (4)
88
89/* Index of clip information
90 * in IMGSENSOR_ID_CLIP_VIDEO and IMGSENSOR_ID_CLIP_STILL case
91 */
92
93#define IMGSENSOR_CLIP_INDEX_LEFT (0)
94#define IMGSENSOR_CLIP_INDEX_TOP (1)
95#define IMGSENSOR_CLIP_INDEX_WIDTH (2)
96#define IMGSENSOR_CLIP_INDEX_HEIGHT (3)
97
98/* Bit definition for IMGSENSOR_ID_3A_LOCK */
99
100#define IMGSENSOR_LOCK_EXPOSURE (1 << 0)
101#define IMGSENSOR_LOCK_WHITE_BALANCE (1 << 1)
102#define IMGSENSOR_LOCK_FOCUS (1 << 2)
103
104/* Status bit definition for IMGSENSOR_ID_3A_STATUS */
105
106#define IMGSENSOR_3A_STATUS_STABLE (0)
107#define IMGSENSOR_3A_STATUS_AE_OPERATING (1 << 0)
108#define IMGSENSOR_3A_STATUS_AWB_OPERATING (1 << 1)
109#define IMGSENSOR_3A_STATUS_AF_OPERATING (1 << 2)
110
111/* Format definition for start_capture() and validate_frame_setting */
112
113#define IMGSENSOR_FMT_MAX (2)
114#define IMGSENSOR_FMT_MAIN (0)
115#define IMGSENSOR_FMT_SUB (1)
116#define IMGSENSOR_PIX_FMT_UYVY (0)
117#define IMGSENSOR_PIX_FMT_RGB565 (1)
118#define IMGSENSOR_PIX_FMT_JPEG (2)
119#define IMGSENSOR_PIX_FMT_JPEG_WITH_SUBIMG (3)
120#define IMGSENSOR_PIX_FMT_SUBIMG_UYVY (4)
121#define IMGSENSOR_PIX_FMT_SUBIMG_RGB565 (5)
122#define IMGSENSOR_PIX_FMT_YUYV (6)
123#define IMGSENSOR_PIX_FMT_YUV420P (7)
124#define IMGSENSOR_PIX_FMT_NV12 (8)
125
126/* Method access helper macros */
127
128#define IMGSENSOR_IS_AVAILABLE(s) \
129 ((s)->ops->is_available ? (s)->ops->is_available(s) : false)
130#define IMGSENSOR_INIT(s) \
131 ((s)->ops->init ? (s)->ops->init(s) : -ENOTTY)
132#define IMGSENSOR_UNINIT(s) \
133 ((s)->ops->uninit ? (s)->ops->uninit(s) : -ENOTTY)
134#define IMGSENSOR_GET_DRIVER_NAME(s) \
135 ((s)->ops->get_driver_name ? (s)->ops->get_driver_name(s) : NULL)
136#define IMGSENSOR_VALIDATE_FRAME_SETTING(s, t, n, f, i) \
137 ((s)->ops->validate_frame_setting ? \
138 (s)->ops->validate_frame_setting(s, t, n, f, i) : -ENOTTY)
139#define IMGSENSOR_START_CAPTURE(s, t, n, f, i) \
140 ((s)->ops->start_capture ? \
141 (s)->ops->start_capture(s, t, n, f, i) : -ENOTTY)
142#define IMGSENSOR_STOP_CAPTURE(s, t) \
143 ((s)->ops->stop_capture ? (s)->ops->stop_capture(s, t) : -ENOTTY)
144#define IMGSENSOR_GET_FRAME_INTERVAL(s, t, i) \
145 ((s)->ops->get_frame_interval ? \
146 (s)->ops->get_frame_interval(s, t, i) : -ENOTTY)
147#define IMGSENSOR_GET_SUPPORTED_VALUE(s, i, v) \
148 ((s)->ops->get_supported_value ? \
149 (s)->ops->get_supported_value(s, i, v) : -ENOTTY)
150#define IMGSENSOR_GET_VALUE(s, i, l, v) \
151 ((s)->ops->get_value ? (s)->ops->get_value(s, i, l, v) : -ENOTTY)
152#define IMGSENSOR_SET_VALUE(s, i, l, v) \
153 ((s)->ops->set_value ? (s)->ops->set_value(s, i, l, v) : -ENOTTY)
154
155/****************************************************************************
156 * Public Types
157 ****************************************************************************/
158
159/* Enumeration for VIDEO_ID_COLORFX */
160
161typedef enum imgsensor_colorfx_e
162{
163 IMGSENSOR_COLORFX_NONE = 0,
164 IMGSENSOR_COLORFX_BW = 1,
165 IMGSENSOR_COLORFX_SEPIA = 2,
166 IMGSENSOR_COLORFX_NEGATIVE = 3,
167 IMGSENSOR_COLORFX_EMBOSS = 4,
168 IMGSENSOR_COLORFX_SKETCH = 5,
169 IMGSENSOR_COLORFX_SKY_BLUE = 6,
170 IMGSENSOR_COLORFX_GRASS_GREEN = 7,
171 IMGSENSOR_COLORFX_SKIN_WHITEN = 8,
172 IMGSENSOR_COLORFX_VIVID = 9,
173 IMGSENSOR_COLORFX_AQUA = 10,
174 IMGSENSOR_COLORFX_ART_FREEZE = 11,
175 IMGSENSOR_COLORFX_SILHOUETTE = 12,
176 IMGSENSOR_COLORFX_SOLARIZATION = 13,
177 IMGSENSOR_COLORFX_ANTIQUE = 14,
178 IMGSENSOR_COLORFX_SET_CBCR = 15,
179 IMGSENSOR_COLORFX_PASTEL = 16,
180} imgsensor_colorfx_t;
181
182/* Enumeration for IMGSENSOR_ID_EXPOSURE_AUTO */
183
184typedef enum imgsensor_exposure_auto_type_e
185{
186 /* Exposure time:auto, iris aperture:auto */
187
188 IMGSENSOR_EXPOSURE_AUTO = 0,
189
190 /* Exposure time:manual, iris aperture:manual */
191
192 IMGSENSOR_EXPOSURE_MANUAL = 1,
193
194 /* Exposure time:manual, iris aperture:auto */
195
196 IMGSENSOR_EXPOSURE_SHUTTER_PRIORITY = 2,
197
198 /* Exposure time:auto, iris aperture:manual */
199
200 IMGSENSOR_EXPOSURE_APERTURE_PRIORITY = 3
201} imgsensor_exposure_auto_type_t;
202
203/* Enumeration for IMGSENSOR_ID_AUTO_N_PRESET_WHITE_BALANCE */
204
205typedef enum imgsensor_white_balance_e
206{
207 IMGSENSOR_WHITE_BALANCE_MANUAL = 0,
208 IMGSENSOR_WHITE_BALANCE_AUTO = 1,
209 IMGSENSOR_WHITE_BALANCE_INCANDESCENT = 2,
210 IMGSENSOR_WHITE_BALANCE_FLUORESCENT = 3,
211 IMGSENSOR_WHITE_BALANCE_FLUORESCENT_H = 4,
212 IMGSENSOR_WHITE_BALANCE_HORIZON = 5,
213 IMGSENSOR_WHITE_BALANCE_DAYLIGHT = 6,
214 IMGSENSOR_WHITE_BALANCE_FLASH = 7,
215 IMGSENSOR_WHITE_BALANCE_CLOUDY = 8,
216 IMGSENSOR_WHITE_BALANCE_SHADE = 9,
217} imgsensor_white_balance_t;
218
219/* Enumeration for IMGSENSOR_ID_ISO_SENSITIVITY_AUTO */
220
221typedef enum imgsensor_iso_sensitivity_auto_type_e
222{
223 IMGSENSOR_ISO_SENSITIVITY_MANUAL = 0,
224 IMGSENSOR_ISO_SENSITIVITY_AUTO = 1,
225} imgsensor_iso_sensitivity_auto_type_t;
226
227/* Enumeration for IMGSENSOR_ID_EXPOSURE_METERING */
228
229typedef enum imgsensor_exposure_metering_e
230{
231 IMGSENSOR_EXPOSURE_METERING_AVERAGE = 0,
232 IMGSENSOR_EXPOSURE_METERING_CENTER_WEIGHTED = 1,
233 IMGSENSOR_EXPOSURE_METERING_SPOT = 2,
234 IMGSENSOR_EXPOSURE_METERING_MATRIX = 3,
235} imgsensor_exposure_metering_t;
236
237/* Enumeration for IMGSENSOR_ID_FLASH_LED_MODE */
238
239typedef enum imgsensor_flash_led_mode_e
240{
241 IMGSENSOR_FLASH_LED_MODE_NONE = 0,
242 IMGSENSOR_FLASH_LED_MODE_FLASH = 1,
243 IMGSENSOR_FLASH_LED_MODE_TORCH = 2,
244} imgsensor_flash_led_mode_t;
245
246/* Enumeration for get_supported_value() */
247
248typedef enum imgsensor_ctrl_type_e
249{
250 IMGSENSOR_CTRL_TYPE_INTEGER = 1,
251 IMGSENSOR_CTRL_TYPE_BOOLEAN = 2,
252 IMGSENSOR_CTRL_TYPE_INTEGER64 = 5,
253 IMGSENSOR_CTRL_TYPE_BITMASK = 8,
254 IMGSENSOR_CTRL_TYPE_INTEGER_MENU = 9,
255 IMGSENSOR_CTRL_TYPE_U8FIXEDPOINT_Q7 = 10,
256 IMGSENSOR_CTRL_TYPE_U16FIXEDPOINT_Q8 = 11,
257 IMGSENSOR_CTRL_TYPE_INTEGER_TIMES_3 = 12,
258 IMGSENSOR_CTRL_TYPE_U8 = 0x0100,
259 IMGSENSOR_CTRL_TYPE_U16 = 0x0101,
260 IMGSENSOR_CTRL_TYPE_U32 = 0x0102,
261} imgsensor_ctrl_type_t;
262
263/* Enumeration for stream */
264
265typedef enum imgsensor_stream_type_e
266{
267 IMGSENSOR_STREAM_TYPE_VIDEO = 0,
268 IMGSENSOR_STREAM_TYPE_STILL = 1,
269} imgsensor_stream_type_t;
270
271/* Structure for validate_frame_setting() and start_capture() */
272
273typedef struct imgsensor_format_s
274{
275 uint16_t width;
276 uint16_t height;
277 uint32_t pixelformat;
279
281{
282 uint32_t numerator;
283 uint32_t denominator;
285
286/* Structure for get_supported_value() */
287
289{
290 int64_t minimum;
291 int64_t maximum;
292 uint64_t step;
293 int64_t default_value;
295
297{
298 int8_t nr_values;
299 FAR const int32_t *values;
300 int32_t default_value;
302
304{
305 uint32_t nr_elems;
306 int64_t minimum;
307 int64_t maximum;
308 uint64_t step;
310
312{
313 imgsensor_ctrl_type_t type; /* Control type */
314 union
315 {
316 /* Use 'range' member in the following types cases.
317 * IMGSENSOR_CTRL_TYPE_INTEGER
318 * IMGSENSOR_CTRL_TYPE_BOOLEAN
319 * IMGSENSOR_CTRL_TYPE_INTEGER64
320 * IMGSENSOR_CTRL_TYPE_BITMASK
321 * IMGSENSOR_CTRL_TYPE_U8FIXEDPOINT_Q7
322 * IMGSENSOR_CTRL_TYPE_U16FIXEDPOINT_Q8
323 * IMGSENSOR_CTRL_TYPE_INTEGER_TIMES_3
324 */
325
327
328 /* Use 'discrete' member in the following type case.
329 * IMGSENSOR_CTRL_TYPE_INTEGER_MENU
330 */
331
333
334 /* Use 'elems' member in the following types cases.
335 * IMGSENSOR_CTRL_TYPE_U8
336 * IMGSENSOR_CTRL_TYPE_U16
337 * IMGSENSOR_CTRL_TYPE_U32
338 */
339
341 } u;
343
344typedef union imgsensor_value_u
345{
346 int32_t value32;
347 int64_t value64;
348 uint8_t *p_u8;
349 uint16_t *p_u16;
350 uint32_t *p_u32;
352
353/* Structure for Image Sensor I/F */
354
355struct imgsensor_s;
357{
358 CODE bool (*is_available)(FAR struct imgsensor_s *sensor);
359 CODE int (*init)(FAR struct imgsensor_s *sensor);
360 CODE int (*uninit)(FAR struct imgsensor_s *sensor);
361 CODE const char * (*get_driver_name)(FAR struct imgsensor_s *sensor);
362 CODE int (*validate_frame_setting)(FAR struct imgsensor_s *sensor,
363 imgsensor_stream_type_t type,
364 uint8_t nr_datafmts,
365 FAR imgsensor_format_t *datafmts,
366 FAR imgsensor_interval_t *interval);
367 CODE int (*start_capture)(FAR struct imgsensor_s *sensor,
368 imgsensor_stream_type_t type,
369 uint8_t nr_datafmts,
370 FAR imgsensor_format_t *datafmts,
371 FAR imgsensor_interval_t *interval);
372 CODE int (*stop_capture)(FAR struct imgsensor_s *sensor,
373 imgsensor_stream_type_t type);
374 CODE int (*get_frame_interval)(FAR struct imgsensor_s *sensor,
375 imgsensor_stream_type_t type,
376 FAR imgsensor_interval_t *interval);
377 CODE int (*get_supported_value)(FAR struct imgsensor_s *sensor,
378 uint32_t id,
379 FAR imgsensor_supported_value_t *value);
380 CODE int (*get_value)(FAR struct imgsensor_s *sensor,
381 uint32_t id, uint32_t size,
382 FAR imgsensor_value_t *value);
383 CODE int (*set_value)(FAR struct imgsensor_s *sensor,
384 uint32_t id, uint32_t size,
385 imgsensor_value_t value);
386};
387
388/* Image sensor private data. This structure only defines the initial fields
389 * of the structure visible to the client. The specific implementation may
390 * add additional, device specific fields after the vtable.
391 */
392
394{
395 FAR const struct imgsensor_ops_s *ops;
396};
397
398#ifdef __cplusplus
399#define EXTERN extern "C"
400extern "C"
401{
402#else
403#define EXTERN extern
404#endif
405
406/****************************************************************************
407 * Public Function Prototypes
408 ****************************************************************************/
409
410/* Register image sensor operations. */
411
412int imgsensor_register(FAR struct imgsensor_s *sensor);
413
414#undef EXTERN
415#ifdef __cplusplus
416}
417#endif
418
419#endif /* __INCLUDE_NUTTX_VIDEO_HALIF_H */
Definition: imgsensor.h:297
Definition: imgsensor.h:304
Definition: imgsensor.h:289
Definition: imgsensor.h:274
Definition: imgsensor.h:281
Definition: imgsensor.h:357
Definition: imgsensor.h:394
Definition: imgsensor.h:312
Definition: imgsensor.h:345