File tree Expand file tree Collapse file tree 3 files changed +21
-18
lines changed Expand file tree Collapse file tree 3 files changed +21
-18
lines changed Original file line number Diff line number Diff line change @@ -114,13 +114,6 @@ int nxcodec_init(FAR nxcodec_t *codec)
114
114
goto err0 ;
115
115
}
116
116
117
- if (codec -> output .fdesc .pixelformat !=
118
- codec -> output .format .fmt .pix .pixelformat )
119
- {
120
- ret = - EINVAL ;
121
- goto err0 ;
122
- }
123
-
124
117
codec -> output .format .type = codec -> output .type ;
125
118
126
119
ret = nxcodec_context_set_format (& codec -> output );
@@ -138,13 +131,6 @@ int nxcodec_init(FAR nxcodec_t *codec)
138
131
goto err0 ;
139
132
}
140
133
141
- if (codec -> capture .fdesc .pixelformat !=
142
- codec -> capture .format .fmt .pix .pixelformat )
143
- {
144
- ret = - EINVAL ;
145
- goto err1 ;
146
- }
147
-
148
134
codec -> capture .format .type = codec -> capture .type ;
149
135
150
136
ret = nxcodec_context_set_format (& codec -> capture );
Original file line number Diff line number Diff line change @@ -265,11 +265,29 @@ int nxcodec_context_dequeue_frame(FAR nxcodec_context_t *ctx)
265
265
int nxcodec_context_get_format (FAR nxcodec_context_t * ctx )
266
266
{
267
267
FAR nxcodec_t * codec = nxcodec_context_to_nxcodec (ctx );
268
+ struct v4l2_fmtdesc fdesc ;
269
+ int ret ;
270
+
271
+ fdesc .type = ctx -> type ;
268
272
269
- memset (& ctx -> fdesc , 0 , sizeof (ctx -> fdesc ));
270
- ctx -> fdesc .type = ctx -> type ;
273
+ while (true)
274
+ {
275
+ ret = ioctl (codec -> fd , VIDIOC_ENUM_FMT , & fdesc );
276
+ if (ret < 0 )
277
+ {
278
+ return - errno ;
279
+ }
280
+
281
+ if (fdesc .pixelformat == ctx -> format .fmt .pix .pixelformat )
282
+ {
283
+ break ;
284
+ }
285
+
286
+ fdesc .index ++ ;
287
+ }
271
288
272
- return ioctl (codec -> fd , VIDIOC_ENUM_FMT , & ctx -> fdesc ) < 0 ? - errno : 0 ;
289
+ ctx -> format .type = ctx -> type ;
290
+ return ioctl (codec -> fd , VIDIOC_TRY_FMT , & ctx -> format ) < 0 ? - errno : 0 ;
273
291
}
274
292
275
293
int nxcodec_context_set_format (FAR nxcodec_context_t * ctx )
Original file line number Diff line number Diff line change @@ -45,7 +45,6 @@ typedef struct nxcodec_context_s
45
45
int fd ;
46
46
enum v4l2_buf_type type ;
47
47
struct v4l2_format format ;
48
- struct v4l2_fmtdesc fdesc ;
49
48
FAR nxcodec_context_buf_t * buf ;
50
49
int nbuffers ;
51
50
} nxcodec_context_t ;
You can’t perform that action at this time.
0 commit comments