/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * Copyright (C) 2019, Google Inc. * * v4l2_camera_proxy.h - Proxy to V4L2 compatibility camera */ #ifndef __V4L2_CAMERA_PROXY_H__ #define __V4L2_CAMERA_PROXY_H__ #include #include #include #include #include #include #include #include #include "v4l2_camera.h" using namespace libcamera; class V4L2CameraFile; class V4L2CameraProxy { public: V4L2CameraProxy(unsigned int index, std::shared_ptr camera); int open(V4L2CameraFile *file); void close(V4L2CameraFile *file); void *mmap(void *addr, size_t length, int prot, int flags, off64_t offset); int munmap(void *addr, size_t length); int ioctl(V4L2CameraFile *file, unsigned long request, void *arg); private: bool validateBufferType(uint32_t type); bool validateMemoryType(uint32_t memory); void setFmtFromConfig(const StreamConfiguration &streamConfig); void querycap(std::shared_ptr camera); int tryFormat(struct v4l2_format *arg); enum v4l2_priority maxPriority(); void updateBuffers(); void freeBuffers(); int vidioc_querycap(struct v4l2_capability *arg); int vidioc_enum_framesizes(V4L2CameraFile *file, struct v4l2_frmsizeenum *arg); int vidioc_enum_fmt(V4L2CameraFile *file, struct v4l2_fmtdesc *arg); int vidioc_g_fmt(V4L2CameraFile *file, struct v4l2_format *arg); int vidioc_s_fmt(V4L2CameraFile *file, struct v4l2_format *arg); int vidioc_try_fmt(V4L2CameraFile *file, struct v4l2_format *arg); int vidioc_g_priority(V4L2CameraFile *file, enum v4l2_priority *arg); int vidioc_s_priority(V4L2CameraFile *file, enum v4l2_priority *arg); int vidioc_enuminput(V4L2CameraFile *file, struct v4l2_input *arg); int vidioc_g_input(V4L2CameraFile *file, int *arg); int vidioc_s_input(V4L2CameraFile *file, int *arg); int vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuffers *arg); int vidioc_querybuf(V4L2CameraFile *file, struct v4l2_buffer *arg); int vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg); int vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg, MutexLocker *locker); int vidioc_streamon(V4L2CameraFile *file, int *arg); int vidioc_streamoff(V4L2CameraFile *file, int *arg); bool hasOwnership(V4L2CameraFile *file); int acquire(V4L2CameraFile *file); void release(V4L2CameraFile *file); static const std::set supportedIoctls_; unsigned int refcount_; unsigned int index_; StreamConfiguration streamConfig_; unsigned int bufferCount_; unsigned int currentBuf_; unsigned int sizeimage_; struct v4l2_capability capabilities_; struct v4l2_pix_format v4l2PixFormat_; std::vector buffers_; std::map mmaps_; std::set files_; std::unique_ptr vcam_; /* * This is the exclusive owner of this V4L2CameraProxy instance. * When there is no owner, anybody can call any ioctl before reqbufs. * The first file to call reqbufs with count > 0 or s_fmt will become * the owner, and when the owner calls reqbufs with count = 0 it will * release ownership. Any buffer-related ioctl (except querybuf) or * s_fmt that is called by a non-owner while there exists an owner * will return -EBUSY. */ V4L2CameraFile *owner_; /* This mutex is to serialize access to the proxy. */ Mutex proxyMutex_; }; #endif /* __V4L2_CAMERA_PROXY_H__ */ /commit/src/ipa/raspberrypi/data/imx477_noir.json?h=jmondi/device-match-generalize&id=46aefed208fef4bc8d6f6e8882b92b9af710a60b'>commitdiff
blob: 52d7f072d0cee86290688845d2633ad5f3733d22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429