Developer World
Spresense SDK Library v3.2.0-ebc0364
imgdata.h
1/****************************************************************************
2 * include/nuttx/video/imgdata.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_IMGDATA_H
22#define __INCLUDE_NUTTX_VIDEO_IMGDATA_H
23
24/****************************************************************************
25 * Included Files
26 ****************************************************************************/
27
28#include <sys/types.h>
29#include <sys/time.h>
30
31/****************************************************************************
32 * Pre-processor Definitions
33 ****************************************************************************/
34
35/* Format definition for start_capture() and validate_frame_setting */
36
37#define IMGDATA_FMT_MAX (2)
38#define IMGDATA_FMT_MAIN (0)
39#define IMGDATA_FMT_SUB (1)
40#define IMGDATA_PIX_FMT_UYVY (0)
41#define IMGDATA_PIX_FMT_RGB565 (1)
42#define IMGDATA_PIX_FMT_JPEG (2)
43#define IMGDATA_PIX_FMT_JPEG_WITH_SUBIMG (3)
44#define IMGDATA_PIX_FMT_SUBIMG_UYVY (4)
45#define IMGDATA_PIX_FMT_SUBIMG_RGB565 (5)
46#define IMGDATA_PIX_FMT_YUYV (6)
47#define IMGDATA_PIX_FMT_YUV420P (7)
48#define IMGDATA_PIX_FMT_NV12 (8)
49
50/* Method access helper macros */
51
52#define IMGDATA_INIT(d) \
53 ((d)->ops->init ? (d)->ops->init(d) : -ENOTTY)
54#define IMGDATA_UNINIT(d) \
55 ((d)->ops->uninit ? (d)->ops->uninit(d) : -ENOTTY)
56#define IMGDATA_SET_BUF(d, a, s) \
57 ((d)->ops->set_buf ? (d)->ops->set_buf(d, a, s) : NULL)
58#define IMGDATA_VALIDATE_FRAME_SETTING(d, n, f, i) \
59 ((d)->ops->validate_frame_setting ? \
60 (d)->ops->validate_frame_setting(d, n, f, i) : -ENOTTY)
61#define IMGDATA_START_CAPTURE(d, n, f, i, c, a) \
62 ((d)->ops->start_capture ? \
63 (d)->ops->start_capture(d, n, f, i, c, a) : -ENOTTY)
64#define IMGDATA_STOP_CAPTURE(d) \
65 ((d)->ops->stop_capture ? (d)->ops->stop_capture(d) : -ENOTTY)
66
67/****************************************************************************
68 * Public Types
69 ****************************************************************************/
70
71/* Structure for validate_frame_setting() and start_capture() */
72
73typedef struct imgdata_format_s
74{
75 uint16_t width;
76 uint16_t height;
77 uint32_t pixelformat;
79
80typedef struct imgdata_interval_s
81{
82 uint32_t numerator;
83 uint32_t denominator;
85
86typedef int (*imgdata_capture_t)(uint8_t result, uint32_t size,
87 FAR const struct timeval *ts,
88 FAR void *arg);
89
90/* Structure for Data Control I/F */
91
92struct imgdata_s;
94{
95 CODE int (*init)(FAR struct imgdata_s *data);
96 CODE int (*uninit)(FAR struct imgdata_s *data);
97
98 CODE int (*set_buf)(FAR struct imgdata_s *data,
99 uint8_t *addr, uint32_t size);
100
101 CODE int (*validate_frame_setting)(FAR struct imgdata_s *data,
102 uint8_t nr_datafmts,
103 FAR imgdata_format_t *datafmts,
104 FAR imgdata_interval_t *interval);
105 CODE int (*start_capture)(FAR struct imgdata_s *data,
106 uint8_t nr_datafmts,
107 FAR imgdata_format_t *datafmts,
108 FAR imgdata_interval_t *interval,
109 FAR imgdata_capture_t callback,
110 FAR void *arg);
111 CODE int (*stop_capture)(FAR struct imgdata_s *data);
112};
113
114/* Image data private data. This structure only defines the initial fields
115 * of the structure visible to the client. The specific implementation may
116 * add additional, device specific fields after the vtable.
117 */
118
120{
121 FAR const struct imgdata_ops_s *ops;
122};
123
124#ifdef __cplusplus
125#define EXTERN extern "C"
126extern "C"
127{
128#else
129#define EXTERN extern
130#endif
131
132/****************************************************************************
133 * Public Function Prototypes
134 ****************************************************************************/
135
136/* Register image data operations. */
137
138void imgdata_register(FAR struct imgdata_s *data);
139
140#undef EXTERN
141#ifdef __cplusplus
142}
143#endif
144
145#endif /* __INCLUDE_NUTTX_VIDEO_IMGDATA_H */
Definition: imgdata.h:74
Definition: imgdata.h:81
Definition: imgdata.h:94
Definition: imgdata.h:120