Line data Source code
1 1 : /**
2 : * @file
3 : *
4 : * @brief Public APIs for Video.
5 : */
6 :
7 : /*
8 : * Copyright (c) 2019 Linaro Limited.
9 : * Copyright 2025 NXP
10 : * Copyright (c) 2025 STMicroelectronics
11 : *
12 : * SPDX-License-Identifier: Apache-2.0
13 : */
14 : #ifndef ZEPHYR_INCLUDE_VIDEO_H_
15 : #define ZEPHYR_INCLUDE_VIDEO_H_
16 :
17 : /**
18 : * @brief Video Interface
19 : * @defgroup video_interface Video Interface
20 : * @since 2.1
21 : * @version 1.1.0
22 : * @ingroup io_interfaces
23 : * @{
24 : */
25 :
26 : #include <zephyr/device.h>
27 : #include <stddef.h>
28 : #include <zephyr/kernel.h>
29 :
30 : #include <zephyr/types.h>
31 :
32 : #ifdef __cplusplus
33 : extern "C" {
34 : #endif
35 :
36 : /*
37 : * Flag used by @ref video_caps structure to indicate endpoint operates on
38 : * buffers the size of the video frame
39 : */
40 0 : #define LINE_COUNT_HEIGHT (-1)
41 :
42 : struct video_control;
43 :
44 : /**
45 : * @brief video_buf_type enum
46 : *
47 : * Supported video buffer types of a video device.
48 : * The direction (input or output) is defined from the device's point of view.
49 : * Devices like cameras support only output type, encoders support only input
50 : * types while m2m devices like ISP, PxP support both input and output types.
51 : */
52 1 : enum video_buf_type {
53 : /** input buffer type */
54 : VIDEO_BUF_TYPE_INPUT,
55 : /** output buffer type */
56 : VIDEO_BUF_TYPE_OUTPUT,
57 : };
58 :
59 : /**
60 : * @brief Video format structure
61 : *
62 : * Used to configure frame format.
63 : */
64 1 : struct video_format {
65 : /** type of the buffer */
66 1 : enum video_buf_type type;
67 : /** FourCC pixel format value (\ref video_pixel_formats) */
68 1 : uint32_t pixelformat;
69 : /** frame width in pixels. */
70 1 : uint32_t width;
71 : /** frame height in pixels. */
72 1 : uint32_t height;
73 : /**
74 : * @brief line stride.
75 : *
76 : * This is the number of bytes that needs to be added to the address in the
77 : * first pixel of a row in order to go to the address of the first pixel of
78 : * the next row (>=width).
79 : */
80 1 : uint32_t pitch;
81 : };
82 :
83 : /**
84 : * @brief Video format capability
85 : *
86 : * Used to describe a video endpoint format capability.
87 : */
88 1 : struct video_format_cap {
89 : /** FourCC pixel format value (\ref video_pixel_formats). */
90 1 : uint32_t pixelformat;
91 : /** minimum supported frame width in pixels. */
92 1 : uint32_t width_min;
93 : /** maximum supported frame width in pixels. */
94 1 : uint32_t width_max;
95 : /** minimum supported frame height in pixels. */
96 1 : uint32_t height_min;
97 : /** maximum supported frame height in pixels. */
98 1 : uint32_t height_max;
99 : /** width step size in pixels. */
100 1 : uint16_t width_step;
101 : /** height step size in pixels. */
102 1 : uint16_t height_step;
103 : };
104 :
105 : /**
106 : * @brief Video format capabilities
107 : *
108 : * Used to describe video endpoint capabilities.
109 : */
110 1 : struct video_caps {
111 : /** type of the buffer */
112 1 : enum video_buf_type type;
113 : /** list of video format capabilities (zero terminated). */
114 1 : const struct video_format_cap *format_caps;
115 : /** minimal count of video buffers to enqueue before being able to start
116 : * the stream.
117 : */
118 1 : uint8_t min_vbuf_count;
119 : /** Denotes minimum line count of a video buffer that this endpoint
120 : * can fill or process. Each line is expected to consume the number
121 : * of bytes the selected video format's pitch uses, so the video
122 : * buffer must be at least `pitch` * `min_line_count` bytes.
123 : * `LINE_COUNT_HEIGHT` is a special value, indicating the endpoint
124 : * only supports video buffers with at least enough bytes to store
125 : * a full video frame
126 : */
127 1 : int16_t min_line_count;
128 : /**
129 : * Denotes maximum line count of a video buffer that this endpoint
130 : * can fill or process. Similar constraints to `min_line_count`,
131 : * but `LINE_COUNT_HEIGHT` indicates that the endpoint will never
132 : * fill or process more than a full video frame in one video buffer.
133 : */
134 1 : int16_t max_line_count;
135 : };
136 :
137 : /**
138 : * @brief Video buffer structure
139 : *
140 : * Represents a video frame.
141 : */
142 1 : struct video_buffer {
143 : /** Pointer to driver specific data. */
144 : /* It must be kept as first field of the struct if used for @ref k_fifo APIs. */
145 1 : void *driver_data;
146 : /** type of the buffer */
147 1 : enum video_buf_type type;
148 : /** pointer to the start of the buffer. */
149 1 : uint8_t *buffer;
150 : /** index of the buffer, optionally set by the application */
151 1 : uint8_t index;
152 : /** size of the buffer in bytes. */
153 1 : uint32_t size;
154 : /** number of bytes occupied by the valid data in the buffer. */
155 1 : uint32_t bytesused;
156 : /** time reference in milliseconds at which the last data byte was
157 : * actually received for input endpoints or to be consumed for output
158 : * endpoints.
159 : */
160 1 : uint32_t timestamp;
161 : /** Line offset within frame this buffer represents, from the
162 : * beginning of the frame. This offset is given in pixels,
163 : * so `line_offset` * `pitch` provides offset from the start of
164 : * the frame in bytes.
165 : */
166 1 : uint16_t line_offset;
167 : };
168 :
169 : /**
170 : * @brief Supported frame interval type of a video device.
171 : */
172 1 : enum video_frmival_type {
173 : /** discrete frame interval type */
174 : VIDEO_FRMIVAL_TYPE_DISCRETE = 1,
175 : /** stepwise frame interval type */
176 : VIDEO_FRMIVAL_TYPE_STEPWISE = 2,
177 : };
178 :
179 : /**
180 : * @brief Video frame interval structure
181 : *
182 : * Used to describe a video frame interval.
183 : */
184 1 : struct video_frmival {
185 : /** numerator of the frame interval */
186 1 : uint32_t numerator;
187 : /** denominator of the frame interval */
188 1 : uint32_t denominator;
189 : };
190 :
191 : /**
192 : * @brief Video frame interval stepwise structure
193 : *
194 : * Used to describe the video frame interval stepwise type.
195 : */
196 1 : struct video_frmival_stepwise {
197 : /** minimum frame interval in seconds */
198 1 : struct video_frmival min;
199 : /** maximum frame interval in seconds */
200 1 : struct video_frmival max;
201 : /** frame interval step size in seconds */
202 1 : struct video_frmival step;
203 : };
204 :
205 : /**
206 : * @brief Video frame interval enumeration structure
207 : *
208 : * Used to describe the supported video frame intervals of a given video format.
209 : */
210 1 : struct video_frmival_enum {
211 : /** frame interval index during enumeration */
212 1 : uint32_t index;
213 : /** video format for which the query is made */
214 1 : const struct video_format *format;
215 : /** frame interval type the device supports */
216 1 : enum video_frmival_type type;
217 : /** the actual frame interval */
218 : union {
219 0 : struct video_frmival discrete;
220 0 : struct video_frmival_stepwise stepwise;
221 1 : };
222 : };
223 :
224 : /**
225 : * @brief Video signal result
226 : *
227 : * Identify video event.
228 : */
229 1 : enum video_signal_result {
230 : VIDEO_BUF_DONE, /**< Buffer is done */
231 : VIDEO_BUF_ABORTED, /**< Buffer is aborted */
232 : VIDEO_BUF_ERROR, /**< Buffer is in error */
233 : };
234 :
235 : /**
236 : * @brief Video selection target
237 : *
238 : * Used to indicate which selection to query or set on a video device
239 : */
240 1 : enum video_selection_target {
241 : /** Current crop setting */
242 : VIDEO_SEL_TGT_CROP,
243 : /** Crop bound (aka the maximum crop achievable) */
244 : VIDEO_SEL_TGT_CROP_BOUND,
245 : /** Native size of the input frame */
246 : VIDEO_SEL_TGT_NATIVE_SIZE,
247 : /** Current compose setting */
248 : VIDEO_SEL_TGT_COMPOSE,
249 : /** Compose bound (aka the maximum compose achievable) */
250 : VIDEO_SEL_TGT_COMPOSE_BOUND,
251 : };
252 :
253 : /**
254 : * @brief Description of a rectangle area.
255 : *
256 : * Used for crop/compose and possibly within drivers as well
257 : */
258 1 : struct video_rect {
259 : /** left offset of selection rectangle */
260 1 : uint32_t left;
261 : /** top offset of selection rectangle */
262 1 : uint32_t top;
263 : /** width of selection rectangle */
264 1 : uint32_t width;
265 : /** height of selection rectangle */
266 1 : uint32_t height;
267 : };
268 :
269 : /**
270 : * @brief Video selection (crop / compose) structure
271 : *
272 : * Used to describe the query and set selection target on a video device
273 : */
274 1 : struct video_selection {
275 : /** buffer type, allow to select for device having both input and output */
276 1 : enum video_buf_type type;
277 : /** selection target enum */
278 1 : enum video_selection_target target;
279 : /** selection target rectangle */
280 1 : struct video_rect rect;
281 : };
282 :
283 : /**
284 : * @typedef video_api_format_t
285 : * @brief Function pointer type for video_set/get_format()
286 : *
287 : * See video_set/get_format() for argument descriptions.
288 : */
289 1 : typedef int (*video_api_format_t)(const struct device *dev, struct video_format *fmt);
290 :
291 : /**
292 : * @typedef video_api_frmival_t
293 : * @brief Function pointer type for video_set/get_frmival()
294 : *
295 : * See video_set/get_frmival() for argument descriptions.
296 : */
297 1 : typedef int (*video_api_frmival_t)(const struct device *dev, struct video_frmival *frmival);
298 :
299 : /**
300 : * @typedef video_api_enum_frmival_t
301 : * @brief List all supported frame intervals of a given format
302 : *
303 : * See video_enum_frmival() for argument descriptions.
304 : */
305 1 : typedef int (*video_api_enum_frmival_t)(const struct device *dev, struct video_frmival_enum *fie);
306 :
307 : /**
308 : * @typedef video_api_enqueue_t
309 : * @brief Enqueue a buffer in the driver’s incoming queue.
310 : *
311 : * See video_enqueue() for argument descriptions.
312 : */
313 1 : typedef int (*video_api_enqueue_t)(const struct device *dev, struct video_buffer *buf);
314 :
315 : /**
316 : * @typedef video_api_dequeue_t
317 : * @brief Dequeue a buffer from the driver’s outgoing queue.
318 : *
319 : * See video_dequeue() for argument descriptions.
320 : */
321 1 : typedef int (*video_api_dequeue_t)(const struct device *dev, struct video_buffer **buf,
322 : k_timeout_t timeout);
323 :
324 : /**
325 : * @typedef video_api_flush_t
326 : * @brief Flush endpoint buffers, buffer are moved from incoming queue to
327 : * outgoing queue.
328 : *
329 : * See video_flush() for argument descriptions.
330 : */
331 1 : typedef int (*video_api_flush_t)(const struct device *dev, bool cancel);
332 :
333 : /**
334 : * @typedef video_api_set_stream_t
335 : * @brief Start or stop streaming on the video device.
336 : *
337 : * Start (enable == true) or stop (enable == false) streaming on the video device.
338 : *
339 : * @param dev Pointer to the device structure.
340 : * @param enable If true, start streaming, otherwise stop streaming.
341 : * @param type The type of the buffers stream to start or stop.
342 : *
343 : * @retval 0 on success, otherwise a negative errno code.
344 : */
345 1 : typedef int (*video_api_set_stream_t)(const struct device *dev, bool enable,
346 : enum video_buf_type type);
347 :
348 : /**
349 : * @typedef video_api_ctrl_t
350 : * @brief Set/Get a video control value.
351 : *
352 : * @param dev Pointer to the device structure.
353 : * @param cid Id of the control to set/get its value.
354 : */
355 1 : typedef int (*video_api_ctrl_t)(const struct device *dev, uint32_t cid);
356 :
357 : /**
358 : * @typedef video_api_get_caps_t
359 : * @brief Get capabilities of a video endpoint.
360 : *
361 : * See video_get_caps() for argument descriptions.
362 : */
363 1 : typedef int (*video_api_get_caps_t)(const struct device *dev, struct video_caps *caps);
364 :
365 : /**
366 : * @typedef video_api_set_signal_t
367 : * @brief Register/Unregister poll signal for buffer events.
368 : *
369 : * See video_set_signal() for argument descriptions.
370 : */
371 1 : typedef int (*video_api_set_signal_t)(const struct device *dev, struct k_poll_signal *sig);
372 :
373 : /**
374 : * @typedef video_api_selection_t
375 : * @brief Get/Set video selection (crop / compose)
376 : *
377 : * See @ref video_set_selection and @ref video_get_selection for argument descriptions.
378 : */
379 1 : typedef int (*video_api_selection_t)(const struct device *dev, struct video_selection *sel);
380 :
381 0 : __subsystem struct video_driver_api {
382 : /* mandatory callbacks */
383 0 : video_api_format_t set_format;
384 0 : video_api_format_t get_format;
385 0 : video_api_set_stream_t set_stream;
386 0 : video_api_get_caps_t get_caps;
387 : /* optional callbacks */
388 0 : video_api_enqueue_t enqueue;
389 0 : video_api_dequeue_t dequeue;
390 0 : video_api_flush_t flush;
391 0 : video_api_ctrl_t set_ctrl;
392 0 : video_api_ctrl_t get_volatile_ctrl;
393 0 : video_api_set_signal_t set_signal;
394 0 : video_api_frmival_t set_frmival;
395 0 : video_api_frmival_t get_frmival;
396 0 : video_api_enum_frmival_t enum_frmival;
397 0 : video_api_selection_t set_selection;
398 0 : video_api_selection_t get_selection;
399 : };
400 :
401 : /**
402 : * @brief Set video format.
403 : *
404 : * Configure video device with a specific format.
405 : *
406 : * @param dev Pointer to the device structure for the driver instance.
407 : * @param fmt Pointer to a video format struct.
408 : *
409 : * @retval 0 Is successful.
410 : * @retval -EINVAL If parameters are invalid.
411 : * @retval -ENOTSUP If format is not supported.
412 : * @retval -EIO General input / output error.
413 : */
414 1 : static inline int video_set_format(const struct device *dev, struct video_format *fmt)
415 : {
416 : const struct video_driver_api *api;
417 :
418 : __ASSERT_NO_MSG(dev != NULL);
419 : __ASSERT_NO_MSG(fmt != NULL);
420 :
421 : api = (const struct video_driver_api *)dev->api;
422 : if (api->set_format == NULL) {
423 : return -ENOSYS;
424 : }
425 :
426 : return api->set_format(dev, fmt);
427 : }
428 :
429 : /**
430 : * @brief Get video format.
431 : *
432 : * Get video device current video format.
433 : *
434 : * @param dev Pointer to the device structure for the driver instance.
435 : * @param fmt Pointer to video format struct.
436 : *
437 : * @retval pointer to video format
438 : */
439 1 : static inline int video_get_format(const struct device *dev, struct video_format *fmt)
440 : {
441 : const struct video_driver_api *api;
442 :
443 : __ASSERT_NO_MSG(dev != NULL);
444 : __ASSERT_NO_MSG(fmt != NULL);
445 :
446 : api = (const struct video_driver_api *)dev->api;
447 : if (api->get_format == NULL) {
448 : return -ENOSYS;
449 : }
450 :
451 : return api->get_format(dev, fmt);
452 : }
453 :
454 : /**
455 : * @brief Set video frame interval.
456 : *
457 : * Configure video device with a specific frame interval.
458 : *
459 : * Drivers must not return an error solely because the requested interval doesn’t match the device
460 : * capabilities. They must instead modify the interval to match what the hardware can provide.
461 : *
462 : * @param dev Pointer to the device structure for the driver instance.
463 : * @param frmival Pointer to a video frame interval struct.
464 : *
465 : * @retval 0 If successful.
466 : * @retval -ENOSYS If API is not implemented.
467 : * @retval -EINVAL If parameters are invalid.
468 : * @retval -EIO General input / output error.
469 : */
470 1 : static inline int video_set_frmival(const struct device *dev, struct video_frmival *frmival)
471 : {
472 : const struct video_driver_api *api;
473 :
474 : __ASSERT_NO_MSG(dev != NULL);
475 : __ASSERT_NO_MSG(frmival != NULL);
476 :
477 : if (frmival->numerator == 0 || frmival->denominator == 0) {
478 : return -EINVAL;
479 : }
480 :
481 : api = (const struct video_driver_api *)dev->api;
482 : if (api->set_frmival == NULL) {
483 : return -ENOSYS;
484 : }
485 :
486 : return api->set_frmival(dev, frmival);
487 : }
488 :
489 : /**
490 : * @brief Get video frame interval.
491 : *
492 : * Get current frame interval of the video device.
493 : *
494 : * @param dev Pointer to the device structure for the driver instance.
495 : * @param frmival Pointer to a video frame interval struct.
496 : *
497 : * @retval 0 If successful.
498 : * @retval -ENOSYS If API is not implemented.
499 : * @retval -EINVAL If parameters are invalid.
500 : * @retval -EIO General input / output error.
501 : */
502 1 : static inline int video_get_frmival(const struct device *dev, struct video_frmival *frmival)
503 : {
504 : const struct video_driver_api *api;
505 :
506 : __ASSERT_NO_MSG(dev != NULL);
507 : __ASSERT_NO_MSG(frmival != NULL);
508 :
509 : api = (const struct video_driver_api *)dev->api;
510 : if (api->get_frmival == NULL) {
511 : return -ENOSYS;
512 : }
513 :
514 : return api->get_frmival(dev, frmival);
515 : }
516 :
517 : /**
518 : * @brief List video frame intervals.
519 : *
520 : * List all supported video frame intervals of a given format.
521 : *
522 : * Applications should fill the pixelformat, width and height fields of the
523 : * video_frmival_enum struct first to form a query. Then, the index field is
524 : * used to iterate through the supported frame intervals list.
525 : *
526 : * @param dev Pointer to the device structure for the driver instance.
527 : * @param fie Pointer to a video frame interval enumeration struct.
528 : *
529 : * @retval 0 If successful.
530 : * @retval -ENOSYS If API is not implemented.
531 : * @retval -EINVAL If parameters are invalid.
532 : * @retval -EIO General input / output error.
533 : */
534 1 : static inline int video_enum_frmival(const struct device *dev, struct video_frmival_enum *fie)
535 : {
536 : const struct video_driver_api *api;
537 :
538 : __ASSERT_NO_MSG(dev != NULL);
539 : __ASSERT_NO_MSG(fie != NULL);
540 : __ASSERT_NO_MSG(fie->format != NULL);
541 :
542 : api = (const struct video_driver_api *)dev->api;
543 : if (api->enum_frmival == NULL) {
544 : return -ENOSYS;
545 : }
546 :
547 : return api->enum_frmival(dev, fie);
548 : }
549 :
550 : /**
551 : * @brief Enqueue a video buffer.
552 : *
553 : * Enqueue an empty (capturing) or filled (output) video buffer in the driver’s
554 : * endpoint incoming queue.
555 : *
556 : * @param dev Pointer to the device structure for the driver instance.
557 : * @param buf Pointer to the video buffer.
558 : *
559 : * @retval 0 Is successful.
560 : * @retval -EINVAL If parameters are invalid.
561 : * @retval -EIO General input / output error.
562 : */
563 1 : static inline int video_enqueue(const struct device *dev, struct video_buffer *buf)
564 : {
565 : const struct video_driver_api *api = (const struct video_driver_api *)dev->api;
566 :
567 : __ASSERT_NO_MSG(dev != NULL);
568 : __ASSERT_NO_MSG(buf != NULL);
569 : __ASSERT_NO_MSG(buf->buffer != NULL);
570 :
571 : api = (const struct video_driver_api *)dev->api;
572 : if (api->enqueue == NULL) {
573 : return -ENOSYS;
574 : }
575 :
576 : return api->enqueue(dev, buf);
577 : }
578 :
579 : /**
580 : * @brief Dequeue a video buffer.
581 : *
582 : * Dequeue a filled (capturing) or displayed (output) buffer from the driver’s
583 : * endpoint outgoing queue.
584 : *
585 : * @param dev Pointer to the device structure for the driver instance.
586 : * @param buf Pointer a video buffer pointer.
587 : * @param timeout Timeout
588 : *
589 : * @retval 0 Is successful.
590 : * @retval -EINVAL If parameters are invalid.
591 : * @retval -EIO General input / output error.
592 : */
593 1 : static inline int video_dequeue(const struct device *dev, struct video_buffer **buf,
594 : k_timeout_t timeout)
595 : {
596 : const struct video_driver_api *api;
597 :
598 : __ASSERT_NO_MSG(dev != NULL);
599 : __ASSERT_NO_MSG(buf != NULL);
600 :
601 : api = (const struct video_driver_api *)dev->api;
602 : if (api->dequeue == NULL) {
603 : return -ENOSYS;
604 : }
605 :
606 : return api->dequeue(dev, buf, timeout);
607 : }
608 :
609 : /**
610 : * @brief Flush endpoint buffers.
611 : *
612 : * A call to flush finishes when all endpoint buffers have been moved from
613 : * incoming queue to outgoing queue. Either because canceled or fully processed
614 : * through the video function.
615 : *
616 : * @param dev Pointer to the device structure for the driver instance.
617 : * @param cancel If true, cancel buffer processing instead of waiting for
618 : * completion.
619 : *
620 : * @retval 0 Is successful, -ERRNO code otherwise.
621 : */
622 1 : static inline int video_flush(const struct device *dev, bool cancel)
623 : {
624 : const struct video_driver_api *api;
625 :
626 : __ASSERT_NO_MSG(dev != NULL);
627 :
628 : api = (const struct video_driver_api *)dev->api;
629 : if (api->flush == NULL) {
630 : return -ENOSYS;
631 : }
632 :
633 : return api->flush(dev, cancel);
634 : }
635 :
636 : /**
637 : * @brief Start the video device function.
638 : *
639 : * video_stream_start is called to enter ‘streaming’ state (capture, output...).
640 : * The driver may receive buffers with video_enqueue() before video_stream_start
641 : * is called. If driver/device needs a minimum number of buffers before being
642 : * able to start streaming, then driver set the min_vbuf_count to the related
643 : * endpoint capabilities.
644 : *
645 : * @param dev Pointer to the device structure.
646 : * @param type The type of the buffers stream to start.
647 : *
648 : * @retval 0 Is successful.
649 : * @retval -EIO General input / output error.
650 : */
651 1 : static inline int video_stream_start(const struct device *dev, enum video_buf_type type)
652 : {
653 : const struct video_driver_api *api;
654 :
655 : __ASSERT_NO_MSG(dev != NULL);
656 :
657 : api = (const struct video_driver_api *)dev->api;
658 : if (api->set_stream == NULL) {
659 : return -ENOSYS;
660 : }
661 :
662 : return api->set_stream(dev, true, type);
663 : }
664 :
665 : /**
666 : * @brief Stop the video device function.
667 : *
668 : * On video_stream_stop, driver must stop any transactions or wait until they
669 : * finish.
670 : *
671 : * @param dev Pointer to the device structure.
672 : * @param type The type of the buffers stream to stop.
673 : *
674 : * @retval 0 Is successful.
675 : * @retval -EIO General input / output error.
676 : */
677 1 : static inline int video_stream_stop(const struct device *dev, enum video_buf_type type)
678 : {
679 : const struct video_driver_api *api;
680 : int ret;
681 :
682 : __ASSERT_NO_MSG(dev != NULL);
683 :
684 : api = (const struct video_driver_api *)dev->api;
685 : if (api->set_stream == NULL) {
686 : return -ENOSYS;
687 : }
688 :
689 : ret = api->set_stream(dev, false, type);
690 : video_flush(dev, true);
691 :
692 : return ret;
693 : }
694 :
695 : /**
696 : * @brief Get the capabilities of a video endpoint.
697 : *
698 : * @param dev Pointer to the device structure for the driver instance.
699 : * @param caps Pointer to the video_caps struct to fill.
700 : *
701 : * @retval 0 Is successful, -ERRNO code otherwise.
702 : */
703 1 : static inline int video_get_caps(const struct device *dev, struct video_caps *caps)
704 : {
705 : const struct video_driver_api *api;
706 :
707 : __ASSERT_NO_MSG(dev != NULL);
708 : __ASSERT_NO_MSG(caps != NULL);
709 :
710 : api = (const struct video_driver_api *)dev->api;
711 : if (api->get_caps == NULL) {
712 : return -ENOSYS;
713 : }
714 :
715 : return api->get_caps(dev, caps);
716 : }
717 :
718 : /**
719 : * @brief Set the value of a control.
720 : *
721 : * This set the value of a video control, value type depends on control ID, and
722 : * must be interpreted accordingly.
723 : *
724 : * @param dev Pointer to the device structure for the driver instance.
725 : * @param control Pointer to the video control struct.
726 : *
727 : * @retval 0 Is successful.
728 : * @retval -EINVAL If parameters are invalid.
729 : * @retval -ENOTSUP If format is not supported.
730 : * @retval -EIO General input / output error.
731 : */
732 1 : int video_set_ctrl(const struct device *dev, struct video_control *control);
733 :
734 : /**
735 : * @brief Get the current value of a control.
736 : *
737 : * This retrieve the value of a video control, value type depends on control ID,
738 : * and must be interpreted accordingly.
739 : *
740 : * @param dev Pointer to the device structure.
741 : * @param control Pointer to the video control struct.
742 : *
743 : * @retval 0 Is successful.
744 : * @retval -EINVAL If parameters are invalid.
745 : * @retval -ENOTSUP If format is not supported.
746 : * @retval -EIO General input / output error.
747 : */
748 1 : int video_get_ctrl(const struct device *dev, struct video_control *control);
749 :
750 : struct video_ctrl_query;
751 :
752 : /**
753 : * @brief Query information about a control.
754 : *
755 : * Applications set the id field of the query structure, the function fills the rest of this
756 : * structure. It is possible to enumerate base class controls (i.e., VIDEO_CID_BASE + x) by calling
757 : * this function with successive id values starting from VIDEO_CID_BASE up to and exclusive
758 : * VIDEO_CID_LASTP1. The function may return -ENOTSUP if a control in this range is not supported.
759 : * Applications can also enumerate private controls by starting at VIDEO_CID_PRIVATE_BASE and
760 : * incrementing the id until the driver returns -ENOTSUP. For other control classes, it's a bit more
761 : * difficult. Hence, the best way to enumerate all kinds of device's supported controls is to
762 : * iterate with VIDEO_CTRL_FLAG_NEXT_CTRL.
763 : *
764 : * @param cq Pointer to the control query struct.
765 : *
766 : * @retval 0 If successful.
767 : * @retval -EINVAL If the control id is invalid.
768 : * @retval -ENOTSUP If the control id is not supported.
769 : */
770 1 : int video_query_ctrl(struct video_ctrl_query *cq);
771 :
772 : /**
773 : * @brief Print all the information of a control.
774 : *
775 : * Print all the information of a control including its name, type, flag, range,
776 : * menu (if any) and current value, i.e. by invoking the video_get_ctrl(), in a
777 : * human readble format.
778 : *
779 : * @param cq Pointer to the control query struct.
780 : */
781 1 : void video_print_ctrl(const struct video_ctrl_query *const cq);
782 :
783 : /**
784 : * @brief Register/Unregister k_poll signal for a video endpoint.
785 : *
786 : * Register a poll signal to the endpoint, which will be signaled on frame
787 : * completion (done, aborted, error). Registering a NULL poll signal
788 : * unregisters any previously registered signal.
789 : *
790 : * @param dev Pointer to the device structure for the driver instance.
791 : * @param sig Pointer to k_poll_signal
792 : *
793 : * @retval 0 Is successful, -ERRNO code otherwise.
794 : */
795 1 : static inline int video_set_signal(const struct device *dev, struct k_poll_signal *sig)
796 : {
797 : const struct video_driver_api *api;
798 :
799 : __ASSERT_NO_MSG(dev != NULL);
800 : __ASSERT_NO_MSG(sig != NULL);
801 :
802 : api = (const struct video_driver_api *)dev->api;
803 : if (api->set_signal == NULL) {
804 : return -ENOSYS;
805 : }
806 :
807 : return api->set_signal(dev, sig);
808 : }
809 :
810 : /**
811 : * @brief Set video selection (crop/compose).
812 : *
813 : * Configure the optional crop and compose feature of a video device.
814 : * Crop is first applied on the input frame, and the result of that crop is applied
815 : * to the compose. The result of the compose (width/height) is equal to the format
816 : * width/height given to the @ref video_set_format function.
817 : *
818 : * Some targets are inter-dependents. For instance, setting a @ref VIDEO_SEL_TGT_CROP will
819 : * reset @ref VIDEO_SEL_TGT_COMPOSE to the same size.
820 : *
821 : * @param dev Pointer to the device structure for the driver instance.
822 : * @param sel Pointer to a video selection structure
823 : *
824 : * @retval 0 Is successful.
825 : * @retval -EINVAL If parameters are invalid.
826 : * @retval -ENOTSUP If format is not supported.
827 : * @retval -EIO General input / output error.
828 : */
829 1 : static inline int video_set_selection(const struct device *dev, struct video_selection *sel)
830 : {
831 : const struct video_driver_api *api;
832 :
833 : __ASSERT_NO_MSG(dev != NULL);
834 : __ASSERT_NO_MSG(sel != NULL);
835 :
836 : api = (const struct video_driver_api *)dev->api;
837 : if (api->set_selection == NULL) {
838 : return -ENOSYS;
839 : }
840 :
841 : return api->set_selection(dev, sel);
842 : }
843 :
844 : /**
845 : * @brief Get video selection (crop/compose).
846 : *
847 : * Retrieve the current settings related to the crop and compose of the video device.
848 : * This can also be used to read the native size of the input stream of the video
849 : * device.
850 : * This function can be used to read crop / compose capabilities of the device prior
851 : * to performing configuration via the @ref video_set_selection api.
852 : *
853 : * @param dev Pointer to the device structure for the driver instance.
854 : * @param sel Pointer to a video selection structure, @c type and @c target set by the caller
855 : *
856 : * @retval 0 Is successful.
857 : * @retval -EINVAL If parameters are invalid.
858 : * @retval -ENOTSUP If format is not supported.
859 : * @retval -EIO General input / output error.
860 : */
861 1 : static inline int video_get_selection(const struct device *dev, struct video_selection *sel)
862 : {
863 : const struct video_driver_api *api;
864 :
865 : __ASSERT_NO_MSG(dev != NULL);
866 : __ASSERT_NO_MSG(sel != NULL);
867 :
868 : api = (const struct video_driver_api *)dev->api;
869 : if (api->get_selection == NULL) {
870 : return -ENOSYS;
871 : }
872 :
873 : return api->get_selection(dev, sel);
874 : }
875 :
876 : /**
877 : * @brief Allocate aligned video buffer.
878 : *
879 : * @param size Size of the video buffer (in bytes).
880 : * @param align Alignment of the requested memory, must be a power of two.
881 : * @param timeout Timeout duration or K_NO_WAIT
882 : *
883 : * @retval pointer to allocated video buffer
884 : */
885 1 : struct video_buffer *video_buffer_aligned_alloc(size_t size, size_t align, k_timeout_t timeout);
886 :
887 : /**
888 : * @brief Allocate video buffer.
889 : *
890 : * @param size Size of the video buffer (in bytes).
891 : * @param timeout Timeout duration or K_NO_WAIT
892 : *
893 : * @retval pointer to allocated video buffer
894 : */
895 1 : struct video_buffer *video_buffer_alloc(size_t size, k_timeout_t timeout);
896 :
897 : /**
898 : * @brief Release a video buffer.
899 : *
900 : * @param buf Pointer to the video buffer to release.
901 : */
902 1 : void video_buffer_release(struct video_buffer *buf);
903 :
904 : /**
905 : * @brief Search for a format that matches in a list of capabilities
906 : *
907 : * @param fmts The format capability list to search.
908 : * @param fmt The format to find in the list.
909 : * @param idx The pointer to a number of the first format that matches.
910 : *
911 : * @return 0 when a format is found.
912 : * @return -ENOENT when no matching format is found.
913 : */
914 1 : int video_format_caps_index(const struct video_format_cap *fmts, const struct video_format *fmt,
915 : size_t *idx);
916 :
917 : /**
918 : * @brief Compute the difference between two frame intervals
919 : *
920 : * @param frmival Frame interval to turn into microseconds.
921 : *
922 : * @return The frame interval value in microseconds.
923 : */
924 1 : static inline uint64_t video_frmival_nsec(const struct video_frmival *frmival)
925 : {
926 : __ASSERT_NO_MSG(frmival != NULL);
927 : __ASSERT_NO_MSG(frmival->denominator != 0);
928 :
929 : return (uint64_t)NSEC_PER_SEC * frmival->numerator / frmival->denominator;
930 : }
931 :
932 : /**
933 : * @brief Find the closest match to a frame interval value within a stepwise frame interval.
934 : *
935 : * @param stepwise The stepwise frame interval range to search
936 : * @param desired The frame interval for which find the closest match
937 : * @param match The resulting frame interval closest to @p desired
938 : */
939 1 : void video_closest_frmival_stepwise(const struct video_frmival_stepwise *stepwise,
940 : const struct video_frmival *desired,
941 : struct video_frmival *match);
942 :
943 : /**
944 : * @brief Find the closest match to a frame interval value within a video device.
945 : *
946 : * To compute the closest match, fill @p match with the following fields:
947 : *
948 : * - @c match->format to the @ref video_format of interest.
949 : * - @c match->type to @ref VIDEO_FRMIVAL_TYPE_DISCRETE.
950 : * - @c match->discrete to the desired frame interval.
951 : *
952 : * The result will be loaded into @p match, with the following fields set:
953 : *
954 : * - @c match->discrete to the value of the closest frame interval.
955 : * - @c match->index to the index of the closest frame interval.
956 : *
957 : * @param dev Video device to query.
958 : * @param match Frame interval enumerator with the query, and loaded with the result.
959 : */
960 1 : void video_closest_frmival(const struct device *dev, struct video_frmival_enum *match);
961 :
962 : /**
963 : * @brief Return the link-frequency advertised by a device
964 : *
965 : * Device exposing a CSI link should advertise at least one of the following two controls:
966 : * - @ref VIDEO_CID_LINK_FREQ
967 : * - @ref VIDEO_CID_PIXEL_RATE
968 : *
969 : * At first the helper will try read the @ref VIDEO_CID_LINK_FREQ and if not available will
970 : * approximate the link-frequency from the @ref VIDEO_CID_PIXEL_RATE value, taking into
971 : * consideration the bits per pixel of the format and the number of lanes.
972 : *
973 : * @param dev Video device to query.
974 : * @param bpp Amount of bits per pixel of the pixel format produced by the device
975 : * @param lane_nb Number of CSI-2 lanes used
976 : */
977 1 : int64_t video_get_csi_link_freq(const struct device *dev, uint8_t bpp, uint8_t lane_nb);
978 :
979 : /**
980 : * @defgroup video_pixel_formats Video pixel formats
981 : * The '|' characters separate the pixels or logical blocks, and spaces separate the bytes.
982 : * The uppercase letter represents the most significant bit.
983 : * The lowercase letters represent the rest of the bits.
984 : * @{
985 : */
986 :
987 : /**
988 : * @brief Four-character-code uniquely identifying the pixel format
989 : */
990 1 : #define VIDEO_FOURCC(a, b, c, d) \
991 : ((uint32_t)(a) | ((uint32_t)(b) << 8) | ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
992 :
993 : /**
994 : * @brief Convert a four-character-string to a four-character-code
995 : *
996 : * Convert a string literal or variable into a four-character-code
997 : * as defined by @ref VIDEO_FOURCC.
998 : *
999 : * @param str String to be converted
1000 : * @return Four-character-code.
1001 : */
1002 1 : #define VIDEO_FOURCC_FROM_STR(str) VIDEO_FOURCC((str)[0], (str)[1], (str)[2], (str)[3])
1003 :
1004 : /**
1005 : * @brief Convert a four-character-code to a four-character-string
1006 : *
1007 : * Convert a four-character code as defined by @ref VIDEO_FOURCC into a string that can be used
1008 : * anywhere, such as in debug logs with the %s print formatter.
1009 : *
1010 : * @param fourcc The 32-bit four-character-code integer to be converted, in CPU-native endinaness.
1011 : * @return Four-character-string built out of it.
1012 : */
1013 1 : #define VIDEO_FOURCC_TO_STR(fourcc) \
1014 : ((char[]){ \
1015 : (char)((fourcc) & 0xFF), \
1016 : (char)(((fourcc) >> 8) & 0xFF), \
1017 : (char)(((fourcc) >> 16) & 0xFF), \
1018 : (char)(((fourcc) >> 24) & 0xFF), \
1019 : '\0' \
1020 : })
1021 :
1022 : /**
1023 : * @name Bayer formats (R, G, B channels).
1024 : *
1025 : * The full color information is spread over multiple pixels.
1026 : *
1027 : * When the format includes more than 8-bit per pixel, a strategy becomes needed to pack
1028 : * the bits over multiple bytes, as illustrated for each format.
1029 : *
1030 : * The number above the 'R', 'r', 'G', 'g', 'B', 'b' are hints about which pixel number the
1031 : * following bits belong to.
1032 : *
1033 : * @{
1034 : */
1035 :
1036 : /**
1037 : * @code{.unparsed}
1038 : * 0 1 2 3
1039 : * | Bbbbbbbb | Gggggggg | Bbbbbbbb | Gggggggg | ...
1040 : * | Gggggggg | Rrrrrrrr | Gggggggg | Rrrrrrrr | ...
1041 : * @endcode
1042 : */
1043 1 : #define VIDEO_PIX_FMT_SBGGR8 VIDEO_FOURCC('B', 'A', '8', '1')
1044 :
1045 : /**
1046 : * @code{.unparsed}
1047 : * 0 1 2 3
1048 : * | Gggggggg | Bbbbbbbb | Gggggggg | Bbbbbbbb | ...
1049 : * | Rrrrrrrr | Gggggggg | Rrrrrrrr | Gggggggg | ...
1050 : * @endcode
1051 : */
1052 1 : #define VIDEO_PIX_FMT_SGBRG8 VIDEO_FOURCC('G', 'B', 'R', 'G')
1053 :
1054 : /**
1055 : * @code{.unparsed}
1056 : * 0 1 2 3
1057 : * | Gggggggg | Rrrrrrrr | Gggggggg | Rrrrrrrr | ...
1058 : * | Bbbbbbbb | Gggggggg | Bbbbbbbb | Gggggggg | ...
1059 : * @endcode
1060 : */
1061 1 : #define VIDEO_PIX_FMT_SGRBG8 VIDEO_FOURCC('G', 'R', 'B', 'G')
1062 :
1063 : /**
1064 : * @code{.unparsed}
1065 : * 0 1 2 3
1066 : * | Rrrrrrrr | Gggggggg | Rrrrrrrr | Gggggggg | ...
1067 : * | Gggggggg | Bbbbbbbb | Gggggggg | Bbbbbbbb | ...
1068 : * @endcode
1069 : */
1070 1 : #define VIDEO_PIX_FMT_SRGGB8 VIDEO_FOURCC('R', 'G', 'G', 'B')
1071 :
1072 : /**
1073 : * @code{.unparsed}
1074 : * 0 1 2 3 3 2 1 0
1075 : * | Bbbbbbbb | Gggggggg | Bbbbbbbb | Gggggggg | ggbbggbb | ...
1076 : * | Gggggggg | Rrrrrrrr | Gggggggg | Rrrrrrrr | rrggrrgg | ...
1077 : * @endcode
1078 : */
1079 1 : #define VIDEO_PIX_FMT_SBGGR10P VIDEO_FOURCC('p', 'B', 'A', 'A')
1080 :
1081 : /**
1082 : * @code{.unparsed}
1083 : * 0 1 2 3 3 2 1 0
1084 : * | Gggggggg | Bbbbbbbb | Gggggggg | Bbbbbbbb | bbggbbgg | ...
1085 : * | Rrrrrrrr | Gggggggg | Rrrrrrrr | Gggggggg | ggrrggrr | ...
1086 : * @endcode
1087 : */
1088 1 : #define VIDEO_PIX_FMT_SGBRG10P VIDEO_FOURCC('p', 'G', 'A', 'A')
1089 :
1090 : /**
1091 : * @code{.unparsed}
1092 : * 0 1 2 3 3 2 1 0
1093 : * | Gggggggg | Rrrrrrrr | Gggggggg | Rrrrrrrr | rrggrrgg | ...
1094 : * | Bbbbbbbb | Gggggggg | Bbbbbbbb | Gggggggg | ggbbggbb | ...
1095 : * @endcode
1096 : */
1097 1 : #define VIDEO_PIX_FMT_SGRBG10P VIDEO_FOURCC('p', 'g', 'A', 'A')
1098 :
1099 : /**
1100 : * @code{.unparsed}
1101 : * 0 1 2 3 3 2 1 0
1102 : * | Rrrrrrrr | Gggggggg | Rrrrrrrr | Gggggggg | ggrrggrr | ...
1103 : * | Gggggggg | Bbbbbbbb | Gggggggg | Bbbbbbbb | bbggbbgg | ...
1104 : * @endcode
1105 : */
1106 1 : #define VIDEO_PIX_FMT_SRGGB10P VIDEO_FOURCC('p', 'R', 'A', 'A')
1107 :
1108 : /**
1109 : * @code{.unparsed}
1110 : * 0 1 1 0 2 3 3 2
1111 : * | Bbbbbbbb | Gggggggg | ggggbbbb | Bbbbbbbb | Gggggggg | ggggbbbb | ...
1112 : * | Gggggggg | Rrrrrrrr | rrrrgggg | Gggggggg | Rrrrrrrr | rrrrgggg | ...
1113 : * @endcode
1114 : */
1115 1 : #define VIDEO_PIX_FMT_SBGGR12P VIDEO_FOURCC('p', 'B', 'C', 'C')
1116 :
1117 : /**
1118 : * @code{.unparsed}
1119 : * 0 1 1 0 2 3 3 2
1120 : * | Gggggggg | Bbbbbbbb | bbbbgggg | Gggggggg | Bbbbbbbb | bbbbgggg | ...
1121 : * | Rrrrrrrr | Gggggggg | ggggrrrr | Rrrrrrrr | Gggggggg | ggggrrrr | ...
1122 : * @endcode
1123 : */
1124 1 : #define VIDEO_PIX_FMT_SGBRG12P VIDEO_FOURCC('p', 'G', 'C', 'C')
1125 :
1126 : /**
1127 : * @code{.unparsed}
1128 : * 0 1 1 0 2 3 3 2
1129 : * | Gggggggg | Rrrrrrrr | rrrrgggg | Gggggggg | Rrrrrrrr | rrrrgggg | ...
1130 : * | Bbbbbbbb | Gggggggg | ggggbbbb | Bbbbbbbb | Gggggggg | ggggbbbb | ...
1131 : * @endcode
1132 : */
1133 1 : #define VIDEO_PIX_FMT_SGRBG12P VIDEO_FOURCC('p', 'g', 'C', 'C')
1134 :
1135 : /**
1136 : * @code{.unparsed}
1137 : * 0 1 1 0 2 3 3 2
1138 : * | Rrrrrrrr | Gggggggg | ggggrrrr | Rrrrrrrr | Gggggggg | ggggrrrr | ...
1139 : * | Gggggggg | Bbbbbbbb | bbbbgggg | Gggggggg | Bbbbbbbb | bbbbgggg | ...
1140 : * @endcode
1141 : */
1142 1 : #define VIDEO_PIX_FMT_SRGGB12P VIDEO_FOURCC('p', 'R', 'C', 'C')
1143 :
1144 : /**
1145 : * @code{.unparsed}
1146 : * 0 1 2 3 1 0 2 1 3 2
1147 : * | Bbbbbbbb | Gggggggg | Bbbbbbbb | Gggggggg | ggbbbbbb bbbbgggg ggggggbb | ...
1148 : * | Gggggggg | Rrrrrrrr | Gggggggg | Rrrrrrrr | rrgggggg ggggrrrr rrrrrrgg | ...
1149 : * @endcode
1150 : */
1151 1 : #define VIDEO_PIX_FMT_SBGGR14P VIDEO_FOURCC('p', 'B', 'E', 'E')
1152 :
1153 : /**
1154 : * @code{.unparsed}
1155 : * 0 1 2 3 1 0 2 1 3 2
1156 : * | Gggggggg | Bbbbbbbb | Gggggggg | Bbbbbbbb | bbgggggg ggggbbbb bbbbbbgg | ...
1157 : * | Rrrrrrrr | Gggggggg | Rrrrrrrr | Gggggggg | ggrrrrrr rrrrgggg ggggggrr | ...
1158 : * @endcode
1159 : */
1160 1 : #define VIDEO_PIX_FMT_SGBRG14P VIDEO_FOURCC('p', 'G', 'E', 'E')
1161 :
1162 : /**
1163 : * @code{.unparsed}
1164 : * 0 1 2 3 1 0 2 1 3 2
1165 : * | Gggggggg | Rrrrrrrr | Gggggggg | Rrrrrrrr | rrgggggg ggggrrrr rrrrrrgg | ...
1166 : * | Bbbbbbbb | Gggggggg | Bbbbbbbb | Gggggggg | ggbbbbbb bbbbgggg ggggggbb | ...
1167 : * @endcode
1168 : */
1169 1 : #define VIDEO_PIX_FMT_SGRBG14P VIDEO_FOURCC('p', 'g', 'E', 'E')
1170 :
1171 : /**
1172 : * @code{.unparsed}
1173 : * 0 1 2 3 1 0 2 1 3 2
1174 : * | Rrrrrrrr | Gggggggg | Rrrrrrrr | Gggggggg | ggrrrrrr rrrrgggg ggggggrr | ...
1175 : * | Gggggggg | Bbbbbbbb | Gggggggg | Bbbbbbbb | bbgggggg ggggbbbb bbbbbbgg | ...
1176 : * @endcode
1177 : */
1178 1 : #define VIDEO_PIX_FMT_SRGGB14P VIDEO_FOURCC('p', 'R', 'E', 'E')
1179 :
1180 : /**
1181 : * @code{.unparsed}
1182 : * | bbbbbbbb 000000Bb | gggggggg 000000Gg | bbbbbbbb 000000Bb | gggggggg 000000Gg | ...
1183 : * | gggggggg 000000Gg | rrrrrrrr 000000Rr | gggggggg 000000Gg | rrrrrrrr 000000Rr | ...
1184 : * @endcode
1185 : */
1186 1 : #define VIDEO_PIX_FMT_SBGGR10 VIDEO_FOURCC('B', 'G', '1', '0')
1187 :
1188 : /**
1189 : * @code{.unparsed}
1190 : * | gggggggg 000000Gg | bbbbbbbb 000000Bb | gggggggg 000000Gg | bbbbbbbb 000000Bb | ...
1191 : * | rrrrrrrr 000000Rr | gggggggg 000000Gg | rrrrrrrr 000000Rr | gggggggg 000000Gg | ...
1192 : * @endcode
1193 : */
1194 1 : #define VIDEO_PIX_FMT_SGBRG10 VIDEO_FOURCC('G', 'B', '1', '0')
1195 :
1196 : /**
1197 : * @code{.unparsed}
1198 : * | gggggggg 000000Gg | rrrrrrrr 000000Rr | gggggggg 000000Gg | rrrrrrrr 000000Rr | ...
1199 : * | bbbbbbbb 000000Bb | gggggggg 000000Gg | bbbbbbbb 000000Bb | gggggggg 000000Gg | ...
1200 : * @endcode
1201 : */
1202 1 : #define VIDEO_PIX_FMT_SGRBG10 VIDEO_FOURCC('B', 'A', '1', '0')
1203 :
1204 : /**
1205 : * @code{.unparsed}
1206 : * | rrrrrrrr 000000Rr | gggggggg 000000Gg | rrrrrrrr 000000Rr | gggggggg 000000Gg | ...
1207 : * | gggggggg 000000Gg | bbbbbbbb 000000Bb | gggggggg 000000Gg | bbbbbbbb 000000Bb | ...
1208 : * @endcode
1209 : */
1210 1 : #define VIDEO_PIX_FMT_SRGGB10 VIDEO_FOURCC('R', 'G', '1', '0')
1211 :
1212 : /**
1213 : * @code{.unparsed}
1214 : * | bbbbbbbb 0000Bbbb | gggggggg 0000Gggg | bbbbbbbb 0000Bbbb | gggggggg 0000Gggg | ...
1215 : * | gggggggg 0000Gggg | rrrrrrrr 0000Rrrr | gggggggg 0000Gggg | rrrrrrrr 0000Rrrr | ...
1216 : * @endcode
1217 : */
1218 1 : #define VIDEO_PIX_FMT_SBGGR12 VIDEO_FOURCC('B', 'G', '1', '2')
1219 :
1220 : /**
1221 : * @code{.unparsed}
1222 : * | gggggggg 0000Gggg | bbbbbbbb 0000Bbbb | gggggggg 0000Gggg | bbbbbbbb 0000Bbbb | ...
1223 : * | rrrrrrrr 0000Rrrr | gggggggg 0000Gggg | rrrrrrrr 0000Rrrr | gggggggg 0000Gggg | ...
1224 : * @endcode
1225 : */
1226 1 : #define VIDEO_PIX_FMT_SGBRG12 VIDEO_FOURCC('G', 'B', '1', '2')
1227 :
1228 : /**
1229 : * @code{.unparsed}
1230 : * | gggggggg 0000Gggg | rrrrrrrr 0000Rrrr | gggggggg 0000Gggg | rrrrrrrr 0000Rrrr | ...
1231 : * | bbbbbbbb 0000Bbbb | gggggggg 0000Gggg | bbbbbbbb 0000Bbbb | gggggggg 0000Gggg | ...
1232 : * @endcode
1233 : */
1234 1 : #define VIDEO_PIX_FMT_SGRBG12 VIDEO_FOURCC('B', 'A', '1', '2')
1235 :
1236 : /**
1237 : * @code{.unparsed}
1238 : * | rrrrrrrr 0000Rrrr | gggggggg 0000Gggg | rrrrrrrr 0000Rrrr | gggggggg 0000Gggg | ...
1239 : * | gggggggg 0000Gggg | bbbbbbbb 0000Bbbb | gggggggg 0000Gggg | bbbbbbbb 0000Bbbb | ...
1240 : * @endcode
1241 : */
1242 1 : #define VIDEO_PIX_FMT_SRGGB12 VIDEO_FOURCC('R', 'G', '1', '2')
1243 :
1244 : /**
1245 : * @code{.unparsed}
1246 : * | bbbbbbbb 00Bbbbbb | gggggggg 00Gggggg | bbbbbbbb 00Bbbbbb | gggggggg 00Gggggg | ...
1247 : * | gggggggg 00Gggggg | rrrrrrrr 00Rrrrrr | gggggggg 00Gggggg | rrrrrrrr 00Rrrrrr | ...
1248 : * @endcode
1249 : */
1250 1 : #define VIDEO_PIX_FMT_SBGGR14 VIDEO_FOURCC('B', 'G', '1', '4')
1251 :
1252 : /**
1253 : * @code{.unparsed}
1254 : * | gggggggg 00Gggggg | bbbbbbbb 00Bbbbbb | gggggggg 00Gggggg | bbbbbbbb 00Bbbbbb | ...
1255 : * | rrrrrrrr 00Rrrrrr | gggggggg 00Gggggg | rrrrrrrr 00Rrrrrr | gggggggg 00Gggggg | ...
1256 : * @endcode
1257 : */
1258 1 : #define VIDEO_PIX_FMT_SGBRG14 VIDEO_FOURCC('G', 'B', '1', '4')
1259 :
1260 : /**
1261 : * @code{.unparsed}
1262 : * | gggggggg 00Gggggg | rrrrrrrr 00Rrrrrr | gggggggg 00Gggggg | rrrrrrrr 00Rrrrrr | ...
1263 : * | bbbbbbbb 00Bbbbbb | gggggggg 00Gggggg | bbbbbbbb 00Bbbbbb | gggggggg 00Gggggg | ...
1264 : * @endcode
1265 : */
1266 1 : #define VIDEO_PIX_FMT_SGRBG14 VIDEO_FOURCC('G', 'R', '1', '4')
1267 :
1268 : /**
1269 : * @code{.unparsed}
1270 : * | rrrrrrrr 00Rrrrrr | gggggggg 00Gggggg | rrrrrrrr 00Rrrrrr | gggggggg 00Gggggg | ...
1271 : * | gggggggg 00Gggggg | bbbbbbbb 00Bbbbbb | gggggggg 00Gggggg | bbbbbbbb 00Bbbbbb | ...
1272 : * @endcode
1273 : */
1274 1 : #define VIDEO_PIX_FMT_SRGGB14 VIDEO_FOURCC('R', 'G', '1', '4')
1275 :
1276 : /**
1277 : * @code{.unparsed}
1278 : * | bbbbbbbb Bbbbbbbb | gggggggg Gggggggg | bbbbbbbb Bbbbbbbb | gggggggg Gggggggg | ...
1279 : * | gggggggg Gggggggg | rrrrrrrr Rrrrrrrr | gggggggg Gggggggg | rrrrrrrr Rrrrrrrr | ...
1280 : * @endcode
1281 : */
1282 1 : #define VIDEO_PIX_FMT_SBGGR16 VIDEO_FOURCC('B', 'Y', 'R', '2')
1283 :
1284 : /**
1285 : * @code{.unparsed}
1286 : * | gggggggg Gggggggg | bbbbbbbb Bbbbbbbb | gggggggg Gggggggg | bbbbbbbb Bbbbbbbb | ...
1287 : * | rrrrrrrr Rrrrrrrr | gggggggg Gggggggg | rrrrrrrr Rrrrrrrr | gggggggg Gggggggg | ...
1288 : * @endcode
1289 : */
1290 1 : #define VIDEO_PIX_FMT_SGBRG16 VIDEO_FOURCC('G', 'B', '1', '6')
1291 :
1292 : /**
1293 : * @code{.unparsed}
1294 : * | gggggggg Gggggggg | rrrrrrrr Rrrrrrrr | gggggggg Gggggggg | rrrrrrrr Rrrrrrrr | ...
1295 : * | bbbbbbbb Bbbbbbbb | gggggggg Gggggggg | bbbbbbbb Bbbbbbbb | gggggggg Gggggggg | ...
1296 : * @endcode
1297 : */
1298 1 : #define VIDEO_PIX_FMT_SGRBG16 VIDEO_FOURCC('G', 'R', '1', '6')
1299 :
1300 : /**
1301 : * @code{.unparsed}
1302 : * | rrrrrrrr Rrrrrrrr | gggggggg Gggggggg | rrrrrrrr Rrrrrrrr | gggggggg Gggggggg | ...
1303 : * | gggggggg Gggggggg | bbbbbbbb Bbbbbbbb | gggggggg Gggggggg | bbbbbbbb Bbbbbbbb | ...
1304 : * @endcode
1305 : */
1306 1 : #define VIDEO_PIX_FMT_SRGGB16 VIDEO_FOURCC('R', 'G', '1', '6')
1307 :
1308 : /**
1309 : * @}
1310 : */
1311 :
1312 : /**
1313 : * @name Grayscale formats
1314 : * Luminance (Y) channel only, in various bit depth and packing.
1315 : *
1316 : * When the format includes more than 8-bit per pixel, a strategy becomes needed to pack
1317 : * the bits over multiple bytes, as illustrated for each format.
1318 : *
1319 : * The number above the 'Y', 'y' are hints about which pixel number the following bits belong to.
1320 : *
1321 : * @{
1322 : */
1323 :
1324 : /**
1325 : * Same as Y8 (8-bit luma-only) following the standard FOURCC naming,
1326 : * or L8 in some graphics libraries.
1327 : *
1328 : * @code{.unparsed}
1329 : * 0 1 2 3
1330 : * | Yyyyyyyy | Yyyyyyyy | Yyyyyyyy | Yyyyyyyy | ...
1331 : * @endcode
1332 : */
1333 1 : #define VIDEO_PIX_FMT_GREY VIDEO_FOURCC('G', 'R', 'E', 'Y')
1334 :
1335 : /**
1336 : * @code{.unparsed}
1337 : * 0 1 2 3 3 2 1 0
1338 : * | Yyyyyyyy | Yyyyyyyy | Yyyyyyyy | Yyyyyyyy | yyyyyyyy | ...
1339 : * @endcode
1340 : */
1341 1 : #define VIDEO_PIX_FMT_Y10P VIDEO_FOURCC('Y', '1', '0', 'P')
1342 :
1343 : /**
1344 : * @code{.unparsed}
1345 : * 0 1 1 0 2 3 3 2
1346 : * | Yyyyyyyy | Yyyyyyyy | yyyyyyyy | Yyyyyyyy | Yyyyyyyy | yyyyyyyy | ...
1347 : * | Yyyyyyyy | Yyyyyyyy | yyyyyyyy | Yyyyyyyy | Yyyyyyyy | yyyyyyyy | ...
1348 : * @endcode
1349 : */
1350 1 : #define VIDEO_PIX_FMT_Y12P VIDEO_FOURCC('Y', '1', '2', 'P')
1351 :
1352 : /**
1353 : * @code{.unparsed}
1354 : * 0 1 2 3 1 0 2 1 3 2
1355 : * | Yyyyyyyy | Yyyyyyyy | Yyyyyyyy | Yyyyyyyy | yyyyyyyy yyyyyyyy yyyyyyyy | ...
1356 : * | Yyyyyyyy | Yyyyyyyy | Yyyyyyyy | Yyyyyyyy | yyyyyyyy yyyyyyyy yyyyyyyy | ...
1357 : * @endcode
1358 : */
1359 1 : #define VIDEO_PIX_FMT_Y14P VIDEO_FOURCC('Y', '1', '4', 'P')
1360 :
1361 : /**
1362 : * Little endian, with the 6 most significant bits set to Zero.
1363 : * @code{.unparsed}
1364 : * 0 1 2 3
1365 : * | yyyyyyyy 000000Yy | yyyyyyyy 000000Yy | yyyyyyyy 000000Yy | yyyyyyyy 000000Yy | ...
1366 : * | yyyyyyyy 000000Yy | yyyyyyyy 000000Yy | yyyyyyyy 000000Yy | yyyyyyyy 000000Yy | ...
1367 : * @endcode
1368 : */
1369 1 : #define VIDEO_PIX_FMT_Y10 VIDEO_FOURCC('Y', '1', '0', ' ')
1370 :
1371 : /**
1372 : * Little endian, with the 4 most significant bits set to Zero.
1373 : * @code{.unparsed}
1374 : * 0 1 2 3
1375 : * | yyyyyyyy 0000Yyyy | yyyyyyyy 0000Yyyy | yyyyyyyy 0000Yyyy | yyyyyyyy 0000Yyyy | ...
1376 : * | yyyyyyyy 0000Yyyy | yyyyyyyy 0000Yyyy | yyyyyyyy 0000Yyyy | yyyyyyyy 0000Yyyy | ...
1377 : * @endcode
1378 : */
1379 1 : #define VIDEO_PIX_FMT_Y12 VIDEO_FOURCC('Y', '1', '2', ' ')
1380 :
1381 : /**
1382 : * Little endian, with the 2 most significant bits set to Zero.
1383 : * @code{.unparsed}
1384 : * 0 1 2 3
1385 : * | yyyyyyyy 00Yyyyyy | yyyyyyyy 00Yyyyyy | yyyyyyyy 00Yyyyyy | yyyyyyyy 00Yyyyyy | ...
1386 : * | yyyyyyyy 00Yyyyyy | yyyyyyyy 00Yyyyyy | yyyyyyyy 00Yyyyyy | yyyyyyyy 00Yyyyyy | ...
1387 : * @endcode
1388 : */
1389 1 : #define VIDEO_PIX_FMT_Y14 VIDEO_FOURCC('Y', '1', '4', ' ')
1390 :
1391 : /**
1392 : * Little endian.
1393 : * @code{.unparsed}
1394 : * 0 1 2 3
1395 : * | yyyyyyyy Yyyyyyyy | yyyyyyyy Yyyyyyyy | yyyyyyyy Yyyyyyyy | yyyyyyyy Yyyyyyyy | ...
1396 : * | yyyyyyyy Yyyyyyyy | yyyyyyyy Yyyyyyyy | yyyyyyyy Yyyyyyyy | yyyyyyyy Yyyyyyyy | ...
1397 : * @endcode
1398 : */
1399 1 : #define VIDEO_PIX_FMT_Y16 VIDEO_FOURCC('Y', '1', '6', ' ')
1400 :
1401 : /**
1402 : * @}
1403 : */
1404 :
1405 : /**
1406 : * @name RGB formats
1407 : * Per-color (R, G, B) channels.
1408 : * @{
1409 : */
1410 :
1411 : /**
1412 : * 5 red bits [15:11], 6 green bits [10:5], 5 blue bits [4:0].
1413 : * This 16-bit integer is then packed in big endian format over two bytes:
1414 : *
1415 : * @code{.unparsed}
1416 : * 15.....8 7......0
1417 : * | RrrrrGgg gggBbbbb | ...
1418 : * @endcode
1419 : */
1420 1 : #define VIDEO_PIX_FMT_RGB565X VIDEO_FOURCC('R', 'G', 'B', 'R')
1421 :
1422 : /**
1423 : * 5 red bits [15:11], 6 green bits [10:5], 5 blue bits [4:0].
1424 : * This 16-bit integer is then packed in little endian format over two bytes:
1425 : *
1426 : * @code{.unparsed}
1427 : * 7......0 15.....8
1428 : * | gggBbbbb RrrrrGgg | ...
1429 : * @endcode
1430 : */
1431 1 : #define VIDEO_PIX_FMT_RGB565 VIDEO_FOURCC('R', 'G', 'B', 'P')
1432 :
1433 : /**
1434 : * 24 bit RGB format with 8 bit per component
1435 : *
1436 : * @code{.unparsed}
1437 : * | Bbbbbbbb Gggggggg Rggggggg | ...
1438 : * @endcode
1439 : */
1440 1 : #define VIDEO_PIX_FMT_BGR24 VIDEO_FOURCC('B', 'G', 'R', '3')
1441 :
1442 : /**
1443 : * 24 bit RGB format with 8 bit per component
1444 : *
1445 : * @code{.unparsed}
1446 : * | Rggggggg Gggggggg Bbbbbbbb | ...
1447 : * @endcode
1448 : */
1449 1 : #define VIDEO_PIX_FMT_RGB24 VIDEO_FOURCC('R', 'G', 'B', '3')
1450 :
1451 : /**
1452 : * @code{.unparsed}
1453 : * | Aaaaaaaa Rrrrrrrr Gggggggg Bbbbbbbb | ...
1454 : * @endcode
1455 : */
1456 :
1457 1 : #define VIDEO_PIX_FMT_ARGB32 VIDEO_FOURCC('B', 'A', '2', '4')
1458 :
1459 : /**
1460 : * @code{.unparsed}
1461 : * | Bbbbbbbb Gggggggg Rrrrrrrr Aaaaaaaa | ...
1462 : * @endcode
1463 : */
1464 :
1465 1 : #define VIDEO_PIX_FMT_ABGR32 VIDEO_FOURCC('A', 'R', '2', '4')
1466 :
1467 : /**
1468 : * @code{.unparsed}
1469 : * | Rrrrrrrr Gggggggg Bbbbbbbb Aaaaaaaa | ...
1470 : * @endcode
1471 : */
1472 :
1473 1 : #define VIDEO_PIX_FMT_RGBA32 VIDEO_FOURCC('A', 'B', '2', '4')
1474 :
1475 : /**
1476 : * @code{.unparsed}
1477 : * | Aaaaaaaa Bbbbbbbb Gggggggg Rrrrrrrr | ...
1478 : * @endcode
1479 : */
1480 :
1481 1 : #define VIDEO_PIX_FMT_BGRA32 VIDEO_FOURCC('R', 'A', '2', '4')
1482 :
1483 : /**
1484 : * The first byte is empty (X) for each pixel.
1485 : *
1486 : * @code{.unparsed}
1487 : * | Xxxxxxxx Rrrrrrrr Gggggggg Bbbbbbbb | ...
1488 : * @endcode
1489 : */
1490 1 : #define VIDEO_PIX_FMT_XRGB32 VIDEO_FOURCC('B', 'X', '2', '4')
1491 :
1492 : /**
1493 : * @}
1494 : */
1495 :
1496 : /**
1497 : * @name YUV formats
1498 : * Luminance (Y) and chrominance (U, V) channels.
1499 : * @{
1500 : */
1501 :
1502 : /**
1503 : * There is either a missing channel per pixel, U or V.
1504 : * The value is to be averaged over 2 pixels to get the value of individual pixel.
1505 : *
1506 : * @code{.unparsed}
1507 : * | Yyyyyyyy Uuuuuuuu | Yyyyyyyy Vvvvvvvv | ...
1508 : * @endcode
1509 : */
1510 1 : #define VIDEO_PIX_FMT_YUYV VIDEO_FOURCC('Y', 'U', 'Y', 'V')
1511 :
1512 : /**
1513 : * @code{.unparsed}
1514 : * | Yyyyyyyy Vvvvvvvv | Yyyyyyyy Uuuuuuuu | ...
1515 : * @endcode
1516 : */
1517 1 : #define VIDEO_PIX_FMT_YVYU VIDEO_FOURCC('Y', 'V', 'Y', 'U')
1518 :
1519 : /**
1520 : * @code{.unparsed}
1521 : * | Vvvvvvvv Yyyyyyyy | Uuuuuuuu Yyyyyyyy | ...
1522 : * @endcode
1523 : */
1524 1 : #define VIDEO_PIX_FMT_VYUY VIDEO_FOURCC('V', 'Y', 'U', 'Y')
1525 :
1526 : /**
1527 : * @code{.unparsed}
1528 : * | Uuuuuuuu Yyyyyyyy | Vvvvvvvv Yyyyyyyy | ...
1529 : * @endcode
1530 : */
1531 1 : #define VIDEO_PIX_FMT_UYVY VIDEO_FOURCC('U', 'Y', 'V', 'Y')
1532 :
1533 : /**
1534 : * The first byte is empty (X) for each pixel.
1535 : *
1536 : * @code{.unparsed}
1537 : * | Xxxxxxxx Yyyyyyyy Uuuuuuuu Vvvvvvvv | ...
1538 : * @endcode
1539 : */
1540 1 : #define VIDEO_PIX_FMT_XYUV32 VIDEO_FOURCC('X', 'Y', 'U', 'V')
1541 :
1542 : /**
1543 : * @}
1544 : */
1545 :
1546 : /**
1547 : * @name Compressed formats
1548 : * @{
1549 : */
1550 :
1551 : /**
1552 : * Both JPEG (single frame) and Motion-JPEG (MJPEG, multiple JPEG frames concatenated)
1553 : */
1554 1 : #define VIDEO_PIX_FMT_JPEG VIDEO_FOURCC('J', 'P', 'E', 'G')
1555 :
1556 : /**
1557 : * @}
1558 : */
1559 :
1560 : /**
1561 : * @brief Get number of bits per pixel of a pixel format
1562 : *
1563 : * @param pixfmt FourCC pixel format value (@ref video_pixel_formats).
1564 : *
1565 : * @retval 0 if the format is unhandled or if it is variable number of bits
1566 : * @retval >0 bit size of one pixel for this format
1567 : */
1568 1 : static inline unsigned int video_bits_per_pixel(uint32_t pixfmt)
1569 : {
1570 : switch (pixfmt) {
1571 : case VIDEO_PIX_FMT_SBGGR8:
1572 : case VIDEO_PIX_FMT_SGBRG8:
1573 : case VIDEO_PIX_FMT_SGRBG8:
1574 : case VIDEO_PIX_FMT_SRGGB8:
1575 : case VIDEO_PIX_FMT_GREY:
1576 : return 8;
1577 : case VIDEO_PIX_FMT_SBGGR10P:
1578 : case VIDEO_PIX_FMT_SGBRG10P:
1579 : case VIDEO_PIX_FMT_SGRBG10P:
1580 : case VIDEO_PIX_FMT_SRGGB10P:
1581 : case VIDEO_PIX_FMT_Y10P:
1582 : return 10;
1583 : case VIDEO_PIX_FMT_SBGGR12P:
1584 : case VIDEO_PIX_FMT_SGBRG12P:
1585 : case VIDEO_PIX_FMT_SGRBG12P:
1586 : case VIDEO_PIX_FMT_SRGGB12P:
1587 : case VIDEO_PIX_FMT_Y12P:
1588 : return 12;
1589 : case VIDEO_PIX_FMT_SBGGR14P:
1590 : case VIDEO_PIX_FMT_SGBRG14P:
1591 : case VIDEO_PIX_FMT_SGRBG14P:
1592 : case VIDEO_PIX_FMT_SRGGB14P:
1593 : case VIDEO_PIX_FMT_Y14P:
1594 : return 14;
1595 : case VIDEO_PIX_FMT_RGB565:
1596 : case VIDEO_PIX_FMT_YUYV:
1597 : case VIDEO_PIX_FMT_YVYU:
1598 : case VIDEO_PIX_FMT_UYVY:
1599 : case VIDEO_PIX_FMT_VYUY:
1600 : case VIDEO_PIX_FMT_SBGGR10:
1601 : case VIDEO_PIX_FMT_SGBRG10:
1602 : case VIDEO_PIX_FMT_SGRBG10:
1603 : case VIDEO_PIX_FMT_SRGGB10:
1604 : case VIDEO_PIX_FMT_SBGGR12:
1605 : case VIDEO_PIX_FMT_SGBRG12:
1606 : case VIDEO_PIX_FMT_SGRBG12:
1607 : case VIDEO_PIX_FMT_SRGGB12:
1608 : case VIDEO_PIX_FMT_SBGGR14:
1609 : case VIDEO_PIX_FMT_SGBRG14:
1610 : case VIDEO_PIX_FMT_SGRBG14:
1611 : case VIDEO_PIX_FMT_SRGGB14:
1612 : case VIDEO_PIX_FMT_SBGGR16:
1613 : case VIDEO_PIX_FMT_SGBRG16:
1614 : case VIDEO_PIX_FMT_SGRBG16:
1615 : case VIDEO_PIX_FMT_SRGGB16:
1616 : case VIDEO_PIX_FMT_Y10:
1617 : case VIDEO_PIX_FMT_Y12:
1618 : case VIDEO_PIX_FMT_Y14:
1619 : case VIDEO_PIX_FMT_Y16:
1620 : return 16;
1621 : case VIDEO_PIX_FMT_BGR24:
1622 : case VIDEO_PIX_FMT_RGB24:
1623 : return 24;
1624 : case VIDEO_PIX_FMT_XRGB32:
1625 : case VIDEO_PIX_FMT_XYUV32:
1626 : case VIDEO_PIX_FMT_ARGB32:
1627 : case VIDEO_PIX_FMT_ABGR32:
1628 : case VIDEO_PIX_FMT_RGBA32:
1629 : case VIDEO_PIX_FMT_BGRA32:
1630 : return 32;
1631 : default:
1632 : /* Variable number of bits per pixel or unknown format */
1633 : return 0;
1634 : }
1635 : }
1636 :
1637 : /**
1638 : * @}
1639 : */
1640 :
1641 : /**
1642 : * @name MIPI CSI-2 Data Types
1643 : * @brief Standard MIPI CSI-2 data type identifiers for camera sensor interfaces
1644 : *
1645 : * These constants define the data type field values used in MIPI CSI-2 packet headers to identify
1646 : * the format and encoding of transmitted image data. The data type field is 6 bits wide, allowing
1647 : * values from 0x00 to 0x3F.
1648 : *
1649 : * @{
1650 : */
1651 :
1652 : /** NULL data type - used for padding or synchronization */
1653 1 : #define VIDEO_MIPI_CSI2_DT_NULL 0x10
1654 : /** Blanking data - horizontal/vertical blanking information */
1655 1 : #define VIDEO_MIPI_CSI2_DT_BLANKING 0x11
1656 : /** Embedded 8-bit data - sensor metadata or configuration data */
1657 1 : #define VIDEO_MIPI_CSI2_DT_EMBEDDED_8 0x12
1658 : /** YUV 4:2:0 format with 8 bits per component */
1659 1 : #define VIDEO_MIPI_CSI2_DT_YUV420_8 0x18
1660 : /** YUV 4:2:0 format with 10 bits per component */
1661 1 : #define VIDEO_MIPI_CSI2_DT_YUV420_10 0x19
1662 : /** YUV 4:2:0 CSPS (Chroma Shifted Pixel Sampling) 8-bit format */
1663 1 : #define VIDEO_MIPI_CSI2_DT_YUV420_CSPS_8 0x1c
1664 : /** YUV 4:2:0 CSPS (Chroma Shifted Pixel Sampling) 10-bit format */
1665 1 : #define VIDEO_MIPI_CSI2_DT_YUV420_CSPS_10 0x1d
1666 : /** YUV 4:2:2 format with 8 bits per component */
1667 1 : #define VIDEO_MIPI_CSI2_DT_YUV422_8 0x1e
1668 : /** YUV 4:2:2 format with 10 bits per component */
1669 1 : #define VIDEO_MIPI_CSI2_DT_YUV422_10 0x1f
1670 : /** RGB format with 4 bits per color component */
1671 1 : #define VIDEO_MIPI_CSI2_DT_RGB444 0x20
1672 : /** RGB format with 5 bits per color component */
1673 1 : #define VIDEO_MIPI_CSI2_DT_RGB555 0x21
1674 : /** RGB format with 5-6-5 bits per R-G-B components */
1675 1 : #define VIDEO_MIPI_CSI2_DT_RGB565 0x22
1676 : /** RGB format with 6 bits per color component */
1677 1 : #define VIDEO_MIPI_CSI2_DT_RGB666 0x23
1678 : /** RGB format with 8 bits per color component */
1679 1 : #define VIDEO_MIPI_CSI2_DT_RGB888 0x24
1680 : /** Raw sensor data with 6 bits per pixel */
1681 1 : #define VIDEO_MIPI_CSI2_DT_RAW6 0x28
1682 : /** Raw sensor data with 7 bits per pixel */
1683 1 : #define VIDEO_MIPI_CSI2_DT_RAW7 0x29
1684 : /** Raw sensor data with 8 bits per pixel */
1685 1 : #define VIDEO_MIPI_CSI2_DT_RAW8 0x2a
1686 : /** Raw sensor data with 10 bits per pixel */
1687 1 : #define VIDEO_MIPI_CSI2_DT_RAW10 0x2b
1688 : /** Raw sensor data with 12 bits per pixel */
1689 1 : #define VIDEO_MIPI_CSI2_DT_RAW12 0x2c
1690 : /** Raw sensor data with 14 bits per pixel */
1691 1 : #define VIDEO_MIPI_CSI2_DT_RAW14 0x2d
1692 :
1693 : /**
1694 : * @brief User-defined data type generator macro
1695 : *
1696 : * Generates user-defined data type identifier for custom or proprietary formats.
1697 : * The MIPI CSI-2 specification reserves data types 0x30 to 0x37 for user-specific implementations.
1698 : *
1699 : * @note Parameter n must be in range 0-7 to generate valid user-defined data types
1700 : *
1701 : * @param n User-defined type index (0-7)
1702 : * @return Data type value in user-defined range (0x30-0x37)
1703 : */
1704 1 : #define VIDEO_MIPI_CSI2_DT_USER(n) (0x30 + (n))
1705 :
1706 : /**
1707 : * @}
1708 : */
1709 :
1710 : #ifdef __cplusplus
1711 : }
1712 : #endif
1713 :
1714 : /**
1715 : * @}
1716 : */
1717 :
1718 : #endif /* ZEPHYR_INCLUDE_VIDEO_H_ */
|