summaryrefslogtreecommitdiff
path: root/src/ipa/raspberrypi/data/imx477.json
blob: 5bcaac67069b87fda863929ad4e64ab4d2329479 (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
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
{
    "version": 2.0,
    "target": "bcm2835",
    "algorithms": [
        {
            "rpi.black_level":
            {
                "black_level": 4096
            }
        },
        {
            "rpi.dpc": { }
        },
        {
            "rpi.lux":
            {
                "reference_shutter_speed": 27242,
                "reference_gain": 1.0,
                "reference_aperture": 1.0,
                "reference_lux": 830,
                "reference_Y": 17755
            }
        },
        {
            "rpi.noise":
            {
                "reference_constant": 0,
                "reference_slope": 2.767
            }
        },
        {
            "rpi.geq":
            {
                "offset": 204,
                "slope": 0.01078
            }
        },
        {
            "rpi.sdn": { }
        },
        {
            "rpi.awb":
            {
                "priors": [
                    {
                        "lux": 0,
                        "prior":
                        [
                            2000, 1.0,
                            3000, 0.0,
                            13000, 0.0
                        ]
                    },
                    {
                        "lux": 800,
                        "prior":
                        [
                            2000, 0.0,
                            6000, 2.0,
                            13000, 2.0
                        ]
                    },
                    {
                        "lux": 1500,
                        "prior":
                        [
                            2000, 0.0,
                            4000, 1.0,
                            6000, 6.0,
                            6500, 7.0,
                            7000, 1.0,
                            13000, 1.0
                        ]
                    }
                ],
                "modes":
                {
                    "auto":
                    {
                        "lo": 2500,
                        "hi": 8000
                    },
                    "incandescent":
                    {
                        "lo": 2500,
                        "hi": 3000
                    },
                    "tungsten":
                    {
                        "lo": 3000,
                        "hi": 3500
                    },
                    "fluorescent":
                    {
                        "lo": 4000,
                        "hi": 4700
                    },
                    "indoor":
                    {
                        "lo": 3000,
                        "hi": 5000
                    },
                    "daylight":
                    {
                        "lo": 5500,
                        "hi": 6500
                    },
                    "cloudy":
                    {
                        "lo": 7000,
                        "hi": 8600
                    }
                },
                "bayes": 1,
                "ct_curve":
                [
                    2360.0, 0.6009, 0.3093,
                    2870.0, 0.5047, 0.3936,
                    2970.0, 0.4782, 0.4221,
                    3700.0, 0.4212, 0.4923,
                    3870.0, 0.4037, 0.5166,
                    4000.0, 0.3965, 0.5271,
                    4400.0, 0.3703, 0.5666,
                    4715.0, 0.3411, 0.6147,
                    5920.0, 0.3108, 0.6687,
                    9050.0, 0.2524, 0.7856
                ],
                "sensitivity_r": 1.05,
                "sensitivity_b": 1.05,
                "transverse_pos": 0.0238,
                "transverse_neg": 0.04429
            }
        },
        {
            "rpi.agc":
            {
                "metering_modes":
                {
                    "centre-weighted":
                    {
                        "weights": [ 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0 ]
                    },
                    "spot":
                    {
                        "weights": [ 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
                    },
                    "matrix":
                    {
                        "weights": [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
                    }
                },
                "exposure_modes":
                {
                    "normal":
                    {
                        "shutter": [ 100, 10000, 30000, 60000, 66666 ],
                        "gain": [ 1.0, 2.0, 4.0, 6.0, 8.0 ]
                    },
                    "short":
                    {
                        "shutter": [ 100, 5000, 10000, 20000, 33333 ],
                        "gain": [ 1.0, 2.0, 4.0, 6.0, 8.0 ]
                    },
                    "long":
                    {
                        "shutter": [ 100, 10000, 30000, 60000, 120000 ],
                        "gain": [ 1.0, 2.0, 4.0, 6.0, 12.0 ]
                    }
                },
                "constraint_modes":
                {
                    "normal": [
                        {
                            "bound": "LOWER",
                            "q_lo": 0.98,
                            "q_hi": 1.0,
                            "y_target":
                            [
                                0, 0.3,
                                1000, 0.3
                            ]
                        }
                    ],
                    "highlight": [
                        {
                            "bound": "LOWER",
                            "q_lo": 0.98,
                            "q_hi": 1.0,
                            "y_target":
                            [
                                0, 0.3,
                                1000, 0.3
                            ]
                        },
                        {
                            "bound": "UPPER",
                            "q_lo": 0.98,
                            "q_hi": 1.0,
                            "y_target":
                            [
                                0, 0.8,
                                1000, 0.8
                            ]
                        }
                    ],
                    "shadows": [
                        {
                            "bound": "LOWER",
                            "q_lo": 0.0,
                            "q_hi": 0.5,
                            "y_target":
                            [
                                0, 0.17,
                                1000, 0.17
                            ]
                        }
                    ]
                },
                "y_target":
                [
                    0, 0.16,
                    1000, 0.165,
                    10000, 0.17
                ]
            }
        },
        {
            "rpi.alsc":
            {
                "omega": 1.3,
                "n_iter": 100,
                "luminance_strength": 0.5,
                "calibrations_Cr": [
                    {
                        "ct": 2960,
                        "table":
                        [
                            2.088, 2.086, 2.082, 2.081, 2.077, 2.071, 2.068, 2.068, 2.072, 2.073, 2.075, 2.078, 2.084, 2.092, 2.095, 2.098,
                            2.086, 2.084, 2.079, 2.078, 2.075, 2.068, 2.064, 2.063, 2.068, 2.071, 2.072, 2.075, 2.081, 2.089, 2.092, 2.094,
                            2.083, 2.081, 2.077, 2.072, 2.069, 2.062, 2.059, 2.059, 2.063, 2.067, 2.069, 2.072, 2.079, 2.088, 2.089, 2.089,
                            2.081, 2.077, 2.072, 2.068, 2.065, 2.058, 2.055, 2.054, 2.057, 2.062, 2.066, 2.069, 2.077, 2.084, 2.086, 2.086,
                            2.078, 2.075, 2.069, 2.065, 2.061, 2.055, 2.052, 2.049, 2.051, 2.056, 2.062, 2.065, 2.072, 2.079, 2.081, 2.079,
                            2.079, 2.075, 2.069, 2.064, 2.061, 2.053, 2.049, 2.046, 2.049, 2.051, 2.057, 2.062, 2.069, 2.075, 2.077, 2.075,
                            2.082, 2.079, 2.072, 2.065, 2.061, 2.054, 2.049, 2.047, 2.049, 2.051, 2.056, 2.061, 2.066, 2.073, 2.073, 2.069,
                            2.086, 2.082, 2.075, 2.068, 2.062, 2.054, 2.051, 2.049, 2.051, 2.052, 2.056, 2.061, 2.066, 2.073, 2.073, 2.072,
                            2.088, 2.086, 2.079, 2.074, 2.066, 2.057, 2.051, 2.051, 2.054, 2.055, 2.056, 2.061, 2.067, 2.072, 2.073, 2.072,
                            2.091, 2.087, 2.079, 2.075, 2.068, 2.057, 2.052, 2.052, 2.056, 2.055, 2.055, 2.059, 2.066, 2.072, 2.072, 2.072,
                            2.093, 2.088, 2.081, 2.077, 2.069, 2.059, 2.054, 2.054, 2.057, 2.056, 2.056, 2.058, 2.066, 2.072, 2.073, 2.073,
                            2.095, 2.091, 2.084, 2.078, 2.075, 2.067, 2.057, 2.057, 2.059, 2.059, 2.058, 2.059, 2.068, 2.073, 2.075, 2.078
                        ]
                    },
                    {
                        "ct": 4850,
                        "table":
                        [
                            2.973, 2.968, 2.956, 2.943, 2.941, 2.932, 2.923, 2.921, 2.924, 2.929, 2.931, 2.939, 2.953, 2.965, 2.966, 2.976,
                            2.969, 2.962, 2.951, 2.941, 2.934, 2.928, 2.919, 2.918, 2.919, 2.923, 2.927, 2.933, 2.945, 2.957, 2.962, 2.962,
                            2.964, 2.956, 2.944, 2.932, 2.929, 2.924, 2.915, 2.914, 2.915, 2.919, 2.924, 2.928, 2.941, 2.952, 2.958, 2.959,
                            2.957, 2.951, 2.939, 2.928, 2.924, 2.919, 2.913, 2.911, 2.911, 2.915, 2.919, 2.925, 2.936, 2.947, 2.952, 2.953,
                            2.954, 2.947, 2.935, 2.924, 2.919, 2.915, 2.908, 2.906, 2.906, 2.907, 2.914, 2.921, 2.932, 2.941, 2.943, 2.942,
                            2.953, 2.946, 2.932, 2.921, 2.916, 2.911, 2.904, 2.902, 2.901, 2.904, 2.909, 2.919, 2.926, 2.937, 2.939, 2.939,
                            2.953, 2.947, 2.932, 2.918, 2.915, 2.909, 2.903, 2.901, 2.901, 2.906, 2.911, 2.918, 2.924, 2.936, 2.936, 2.932,
                            2.956, 2.948, 2.934, 2.919, 2.916, 2.908, 2.903, 2.901, 2.902, 2.907, 2.909, 2.917, 2.926, 2.936, 2.939, 2.939,
                            2.957, 2.951, 2.936, 2.923, 2.917, 2.907, 2.904, 2.901, 2.902, 2.908, 2.911, 2.919, 2.929, 2.939, 2.942, 2.942,
                            2.961, 2.951, 2.936, 2.922, 2.918, 2.906, 2.904, 2.901, 2.901, 2.907, 2.911, 2.921, 2.931, 2.941, 2.942, 2.944,
                            2.964, 2.954, 2.936, 2.924, 2.918, 2.909, 2.905, 2.905, 2.905, 2.907, 2.912, 2.923, 2.933, 2.942, 2.944, 2.944,
                            2.964, 2.958, 2.943, 2.927, 2.921, 2.914, 2.909, 2.907, 2.907, 2.912, 2.916, 2.928, 2.936, 2.944, 2.947, 2.952
                        ]
                    },
                    {
                        "ct": 5930,
                        "table":
                        [
                            3.312, 3.308, 3.301, 3.294, 3.288, 3.277, 3.268, 3.261, 3.259, 3.261, 3.267, 3.273, 3.285, 3.301, 3.303, 3.312,
                            3.308, 3.304, 3.294, 3.291, 3.283, 3.271, 3.263, 3.259, 3.257, 3.258, 3.261, 3.268, 3.278, 3.293, 3.299, 3.299,
                            3.302, 3.296, 3.288, 3.282, 3.276, 3.267, 3.259, 3.254, 3.252, 3.253, 3.256, 3.261, 3.273, 3.289, 3.292, 3.292,
                            3.296, 3.289, 3.282, 3.276, 3.269, 3.263, 3.256, 3.251, 3.248, 3.249, 3.251, 3.257, 3.268, 3.279, 3.284, 3.284,
                            3.292, 3.285, 3.279, 3.271, 3.264, 3.257, 3.249, 3.243, 3.241, 3.241, 3.246, 3.252, 3.261, 3.274, 3.275, 3.273,
                            3.291, 3.285, 3.276, 3.268, 3.259, 3.251, 3.242, 3.239, 3.236, 3.238, 3.244, 3.248, 3.258, 3.268, 3.269, 3.265,
                            3.294, 3.288, 3.275, 3.266, 3.257, 3.248, 3.239, 3.238, 3.237, 3.238, 3.243, 3.246, 3.255, 3.264, 3.264, 3.257,
                            3.297, 3.293, 3.279, 3.268, 3.258, 3.249, 3.238, 3.237, 3.239, 3.239, 3.243, 3.245, 3.255, 3.264, 3.264, 3.263,
                            3.301, 3.295, 3.281, 3.271, 3.259, 3.248, 3.237, 3.237, 3.239, 3.241, 3.243, 3.246, 3.257, 3.265, 3.266, 3.264,
                            3.306, 3.295, 3.279, 3.271, 3.261, 3.247, 3.235, 3.234, 3.239, 3.239, 3.243, 3.247, 3.258, 3.265, 3.265, 3.264,
                            3.308, 3.297, 3.279, 3.272, 3.261, 3.249, 3.239, 3.239, 3.241, 3.243, 3.245, 3.248, 3.261, 3.265, 3.266, 3.265,
                            3.309, 3.301, 3.286, 3.276, 3.267, 3.256, 3.246, 3.242, 3.244, 3.244, 3.249, 3.253, 3.263, 3.267, 3.271, 3.274
                        ]
                    }
                ],
                "calibrations_Cb": [
                    {
                        "ct": 2960,
                        "table":
                        [
                            2.133, 2.134, 2.139, 2.143, 2.148, 2.155, 2.158, 2.158, 2.158, 2.161, 2.161, 2.162, 2.159, 2.156, 2.152, 2.151,
                            2.132, 2.133, 2.135, 2.142, 2.147, 2.153, 2.158, 2.158, 2.158, 2.158, 2.159, 2.159, 2.157, 2.154, 2.151, 2.148,
                            2.133, 2.133, 2.135, 2.142, 2.149, 2.154, 2.158, 2.158, 2.157, 2.156, 2.158, 2.157, 2.155, 2.153, 2.148, 2.146,
                            2.133, 2.133, 2.138, 2.145, 2.149, 2.154, 2.158, 2.159, 2.158, 2.155, 2.157, 2.156, 2.153, 2.149, 2.146, 2.144,
                            2.133, 2.134, 2.139, 2.146, 2.149, 2.154, 2.158, 2.159, 2.159, 2.156, 2.154, 2.154, 2.149, 2.145, 2.143, 2.139,
                            2.135, 2.135, 2.139, 2.146, 2.151, 2.155, 2.158, 2.159, 2.158, 2.156, 2.153, 2.151, 2.146, 2.143, 2.139, 2.136,
                            2.135, 2.135, 2.138, 2.145, 2.151, 2.154, 2.157, 2.158, 2.157, 2.156, 2.153, 2.151, 2.147, 2.143, 2.141, 2.137,
                            2.135, 2.134, 2.135, 2.141, 2.149, 2.154, 2.157, 2.157, 2.157, 2.157, 2.157, 2.153, 2.149, 2.146, 2.142, 2.139,
                            2.132, 2.133, 2.135, 2.139, 2.148, 2.153, 2.158, 2.159, 2.159, 2.161, 2.161, 2.157, 2.154, 2.149, 2.144, 2.141,
                            2.132, 2.133, 2.135, 2.141, 2.149, 2.155, 2.161, 2.161, 2.162, 2.162, 2.163, 2.159, 2.154, 2.149, 2.144, 2.138,
                            2.136, 2.136, 2.137, 2.143, 2.149, 2.156, 2.162, 2.163, 2.162, 2.163, 2.164, 2.161, 2.157, 2.152, 2.146, 2.138,
                            2.137, 2.137, 2.141, 2.147, 2.152, 2.157, 2.162, 2.162, 2.159, 2.161, 2.162, 2.162, 2.157, 2.152, 2.148, 2.148
                        ]
                    },
                    {
                        "ct": 4850,
                        "table":
                        [
                            1.463, 1.464, 1.471, 1.478, 1.479, 1.483, 1.484, 1.486, 1.486, 1.484, 1.483, 1.481, 1.478, 1.475, 1.471, 1.468,
                            1.463, 1.463, 1.468, 1.476, 1.479, 1.482, 1.484, 1.487, 1.486, 1.484, 1.483, 1.482, 1.478, 1.473, 1.469, 1.468,
                            1.463, 1.464, 1.468, 1.476, 1.479, 1.483, 1.484, 1.486, 1.486, 1.485, 1.484, 1.482, 1.477, 1.473, 1.469, 1.468,
                            1.463, 1.464, 1.469, 1.477, 1.481, 1.483, 1.485, 1.487, 1.487, 1.485, 1.485, 1.482, 1.478, 1.474, 1.469, 1.468,
                            1.465, 1.465, 1.471, 1.478, 1.481, 1.484, 1.486, 1.488, 1.488, 1.487, 1.485, 1.482, 1.477, 1.472, 1.468, 1.467,
                            1.465, 1.466, 1.472, 1.479, 1.482, 1.485, 1.486, 1.488, 1.488, 1.486, 1.484, 1.479, 1.475, 1.472, 1.468, 1.466,
                            1.466, 1.466, 1.472, 1.478, 1.482, 1.484, 1.485, 1.488, 1.487, 1.485, 1.483, 1.479, 1.475, 1.472, 1.469, 1.468,
                            1.465, 1.466, 1.469, 1.476, 1.481, 1.485, 1.485, 1.486, 1.486, 1.485, 1.483, 1.479, 1.477, 1.474, 1.471, 1.469,
                            1.464, 1.465, 1.469, 1.476, 1.481, 1.484, 1.485, 1.487, 1.487, 1.486, 1.485, 1.481, 1.478, 1.475, 1.471, 1.469,
                            1.463, 1.464, 1.469, 1.477, 1.481, 1.485, 1.485, 1.488, 1.488, 1.487, 1.486, 1.481, 1.478, 1.475, 1.471, 1.468,
                            1.464, 1.465, 1.471, 1.478, 1.482, 1.486, 1.486, 1.488, 1.488, 1.487, 1.486, 1.481, 1.478, 1.475, 1.472, 1.468,
                            1.465, 1.466, 1.472, 1.481, 1.483, 1.487, 1.487, 1.488, 1.488, 1.486, 1.485, 1.481, 1.479, 1.476, 1.473, 1.472
                        ]
                    },
                    {
                        "ct": 5930,
                        "table":
                        [
                            1.443, 1.444, 1.448, 1.453, 1.459, 1.463, 1.465, 1.467, 1.469, 1.469, 1.467, 1.466, 1.462, 1.457, 1.454, 1.451,
                            1.443, 1.444, 1.445, 1.451, 1.459, 1.463, 1.465, 1.467, 1.469, 1.469, 1.467, 1.465, 1.461, 1.456, 1.452, 1.451,
                            1.444, 1.444, 1.445, 1.451, 1.459, 1.463, 1.466, 1.468, 1.469, 1.469, 1.467, 1.465, 1.461, 1.456, 1.452, 1.449,
                            1.444, 1.444, 1.447, 1.452, 1.459, 1.464, 1.467, 1.469, 1.471, 1.469, 1.467, 1.466, 1.461, 1.456, 1.452, 1.449,
                            1.444, 1.445, 1.448, 1.452, 1.459, 1.465, 1.469, 1.471, 1.471, 1.471, 1.468, 1.465, 1.461, 1.455, 1.451, 1.449,
                            1.445, 1.446, 1.449, 1.453, 1.461, 1.466, 1.469, 1.471, 1.472, 1.469, 1.467, 1.465, 1.459, 1.455, 1.451, 1.447,
                            1.446, 1.446, 1.449, 1.453, 1.461, 1.466, 1.469, 1.469, 1.469, 1.469, 1.467, 1.465, 1.459, 1.455, 1.452, 1.449,
                            1.446, 1.446, 1.447, 1.451, 1.459, 1.466, 1.469, 1.469, 1.469, 1.469, 1.467, 1.465, 1.461, 1.457, 1.454, 1.451,
                            1.444, 1.444, 1.447, 1.451, 1.459, 1.466, 1.469, 1.469, 1.471, 1.471, 1.468, 1.466, 1.462, 1.458, 1.454, 1.452,
                            1.444, 1.444, 1.448, 1.453, 1.459, 1.466, 1.469, 1.471, 1.472, 1.472, 1.468, 1.466, 1.462, 1.458, 1.454, 1.449,
                            1.446, 1.447, 1.449, 1.454, 1.461, 1.466, 1.471, 1.471, 1.471, 1.471, 1.468, 1.466, 1.462, 1.459, 1.455, 1.449,
                            1.447, 1.447, 1.452, 1.457, 1.462, 1.468, 1.472, 1.472, 1.471, 1.471, 1.468, 1.466, 1.462, 1.459, 1.456, 1.455
                        ]
                    }
                ],
                "luminance_lut":
                [
                    1.548, 1.499, 1.387, 1.289, 1.223, 1.183, 1.164, 1.154, 1.153, 1.169, 1.211, 1.265, 1.345, 1.448, 1.581, 1.619,
                    1.513, 1.412, 1.307, 1.228, 1.169, 1.129, 1.105, 1.098, 1.103, 1.127, 1.157, 1.209, 1.272, 1.361, 1.481, 1.583,
                    1.449, 1.365, 1.257, 1.175, 1.124, 1.085, 1.062, 1.054, 1.059, 1.079, 1.113, 1.151, 1.211, 1.293, 1.407, 1.488,
                    1.424, 1.324, 1.222, 1.139, 1.089, 1.056, 1.034, 1.031, 1.034, 1.049, 1.075, 1.115, 1.164, 1.241, 1.351, 1.446,
                    1.412, 1.297, 1.203, 1.119, 1.069, 1.039, 1.021, 1.016, 1.022, 1.032, 1.052, 1.086, 1.135, 1.212, 1.321, 1.439,
                    1.406, 1.287, 1.195, 1.115, 1.059, 1.028, 1.014, 1.012, 1.015, 1.026, 1.041, 1.074, 1.125, 1.201, 1.302, 1.425,
                    1.406, 1.294, 1.205, 1.126, 1.062, 1.031, 1.013, 1.009, 1.011, 1.019, 1.042, 1.079, 1.129, 1.203, 1.302, 1.435,
                    1.415, 1.318, 1.229, 1.146, 1.076, 1.039, 1.019, 1.014, 1.017, 1.031, 1.053, 1.093, 1.144, 1.219, 1.314, 1.436,
                    1.435, 1.348, 1.246, 1.164, 1.094, 1.059, 1.036, 1.032, 1.037, 1.049, 1.072, 1.114, 1.167, 1.257, 1.343, 1.462,
                    1.471, 1.385, 1.278, 1.189, 1.124, 1.084, 1.064, 1.061, 1.069, 1.078, 1.101, 1.146, 1.207, 1.298, 1.415, 1.496,
                    1.522, 1.436, 1.323, 1.228, 1.169, 1.118, 1.101, 1.094, 1.099, 1.113, 1.146, 1.194, 1.265, 1.353, 1.474, 1.571,
                    1.578, 1.506, 1.378, 1.281, 1.211, 1.156, 1.135, 1.134, 1.139, 1.158, 1.194, 1.251, 1.327, 1.427, 1.559, 1.611
                ],
                "sigma": 0.00121,
                "sigma_Cb": 0.00115
            }
        },
        {
            "rpi.contrast":
            {
                "ce_enable": 1,
                "gamma_curve":
                [
                    0, 0,
                    1024, 5040,
                    2048, 9338,
                    3072, 12356,
                    4096, 15312,
                    5120, 18051,
                    6144, 20790,
                    7168, 23193,
                    8192, 25744,
                    9216, 27942,
                    10240, 30035,
                    11264, 32005,
                    12288, 33975,
                    13312, 35815,
                    14336, 37600,
                    15360, 39168,
                    16384, 40642,
                    18432, 43379,
                    20480, 45749,
                    22528, 47753,
                    24576, 49621,
                    26624, 51253,
                    28672, 52698,
                    30720, 53796,
                    32768, 54876,
                    36864, 57012,
                    40960, 58656,
                    45056, 59954,
                    49152, 61183,
                    53248, 62355,
                    57344, 63419,
                    61440, 64476,
                    65535, 65535
                ]
            }
        },
        {
            "rpi.ccm":
            {
                "ccms": [
                    {
                        "ct": 2360,
                        "ccm":
                        [
                            1.66078, -0.23588, -0.42491,
                            -0.47456, 1.82763, -0.35307,
                            -0.00545, -1.44729, 2.45273
                        ]
                    },
                    {
                        "ct": 2870,
                        "ccm":
                        [
                            1.78373, -0.55344, -0.23029,
                            -0.39951, 1.69701, -0.29751,
                            0.01986, -1.06525, 2.04539
                        ]
                    },
                    {
                        "ct": 2970,
                        "ccm":
                        [
                            1.73511, -0.56973, -0.16537,
                            -0.36338, 1.69878, -0.33539,
                            -0.02354, -0.76813, 1.79168
                        ]
                    },
                    {
                        "ct": 3000,
                        "ccm":
                        [
                            2.06374, -0.92218, -0.14156,
                            -0.41721, 1.69289, -0.27568,
                            -0.00554, -0.92741, 1.93295
                        ]
                    },
                    {
                        "ct": 3700,
                        "ccm":
                        [
                            2.13792, -1.08136, -0.05655,
                            -0.34739, 1.58989, -0.24249,
                            -0.00349, -0.76789, 1.77138
                        ]
                    },
                    {
                        "ct": 3870,
                        "ccm":
                        [
                            1.83834, -0.70528, -0.13307,
                            -0.30499, 1.60523, -0.30024,
                            -0.05701, -0.58313, 1.64014
                        ]
                    },
                    {
                        "ct": 4000,
                        "ccm":
                        [
                            2.15741, -1.10295, -0.05447,
                            -0.34631, 1.61158, -0.26528,
                            -0.02723, -0.70288, 1.73011
                        ]
                    },
                    {
                        "ct": 4400,
                        "ccm":
                        [
                            2.05729, -0.95007, -0.10723,
                            -0.41712, 1.78606, -0.36894,
                            -0.11899, -0.55727, 1.67626
                        ]
                    },
                    {
                        "ct": 4715,
                        "ccm":
                        [
                            1.90255, -0.77478, -0.12777,
                            -0.31338, 1.88197, -0.56858,
                            -0.06001, -0.61785, 1.67786
                        ]
                    },
                    {
                        "ct": 5920,
                        "ccm":
                        [
                            1.98691, -0.84671, -0.14019,
                            -0.26581, 1.70615, -0.44035,
                            -0.09532, -0.47332, 1.56864
                        ]
                    },
                    {
                        "ct": 9050,
                        "ccm":
                        [
                            2.09255, -0.76541, -0.32714,
                            -0.28973, 2.27462, -0.98489,
                            -0.17299, -0.61275, 1.78574
                        ]
                    }
                ]
            }
        },
        {
            "rpi.sharpen": { }
        },
        {
            "rpi.focus": { }
        }
    ]
}
); if (ret < 0) return ret; for (unsigned i = 0; i < count; ++i) { struct v4l2_buffer buf = {}; struct v4l2_plane planes[VIDEO_MAX_PLANES] = {}; buf.index = i; buf.type = bufferType_; buf.memory = memoryType_; buf.length = ARRAY_SIZE(planes); buf.m.planes = planes; ret = ioctl(VIDIOC_QUERYBUF, &buf); if (ret < 0) { LOG(V4L2, Error) << "Unable to query buffer " << i << ": " << strerror(-ret); goto err_buf; } std::unique_ptr<FrameBuffer> buffer = createBuffer(buf); if (!buffer) { LOG(V4L2, Error) << "Unable to create buffer"; ret = -EINVAL; goto err_buf; } buffers->push_back(std::move(buffer)); } cache_ = new V4L2BufferCache(*buffers); return count; err_buf: requestBuffers(0); buffers->clear(); return ret; } std::unique_ptr<FrameBuffer> V4L2VideoDevice::createBuffer(const struct v4l2_buffer &buf) { const bool multiPlanar = V4L2_TYPE_IS_MULTIPLANAR(buf.type); const unsigned int numPlanes = multiPlanar ? buf.length : 1; if (numPlanes == 0 || numPlanes > VIDEO_MAX_PLANES) { LOG(V4L2, Error) << "Invalid number of planes"; return nullptr; } std::vector<FrameBuffer::Plane> planes; for (unsigned int nplane = 0; nplane < numPlanes; nplane++) { FileDescriptor fd = exportDmabufFd(buf.index, nplane); if (!fd.isValid()) return nullptr; FrameBuffer::Plane plane; plane.fd = std::move(fd); plane.length = multiPlanar ? buf.m.planes[nplane].length : buf.length; planes.push_back(std::move(plane)); } return std::make_unique<FrameBuffer>(std::move(planes)); } FileDescriptor V4L2VideoDevice::exportDmabufFd(unsigned int index, unsigned int plane) { struct v4l2_exportbuffer expbuf = {}; int ret; expbuf.type = bufferType_; expbuf.index = index; expbuf.plane = plane; expbuf.flags = O_RDWR; ret = ioctl(VIDIOC_EXPBUF, &expbuf); if (ret < 0) { LOG(V4L2, Error) << "Failed to export buffer: " << strerror(-ret); return FileDescriptor(); } return FileDescriptor(expbuf.fd); } /** * \brief Prepare the device to import \a count buffers * \param[in] count Number of buffers to prepare to import * \return 0 on success or a negative error code otherwise */ int V4L2VideoDevice::importBuffers(unsigned int count) { if (cache_) { LOG(V4L2, Error) << "Buffers already allocated"; return -EINVAL; } memoryType_ = V4L2_MEMORY_DMABUF; int ret = requestBuffers(count); if (ret) return ret; cache_ = new V4L2BufferCache(count); LOG(V4L2, Debug) << "Prepared to import " << count << " buffers"; return 0; } /** * \brief Release all internally allocated buffers */ int V4L2VideoDevice::releaseBuffers() { LOG(V4L2, Debug) << "Releasing buffers"; delete cache_; cache_ = nullptr; return requestBuffers(0); } /** * \brief Queue a buffer to the video device * \param[in] buffer The buffer to be queued * * For capture video devices the \a buffer will be filled with data by the * device. For output video devices the \a buffer shall contain valid data and * will be processed by the device. Once the device has finished processing the * buffer, it will be available for dequeue. * * The best available V4L2 buffer is picked for \a buffer using the V4L2 buffer * cache. * * \return 0 on success or a negative error code otherwise */ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer) { struct v4l2_plane v4l2Planes[VIDEO_MAX_PLANES] = {}; struct v4l2_buffer buf = {}; int ret; ret = cache_->get(*buffer); if (ret < 0) return ret; buf.index = ret; buf.type = bufferType_; buf.memory = memoryType_; buf.field = V4L2_FIELD_NONE; bool multiPlanar = V4L2_TYPE_IS_MULTIPLANAR(buf.type); const std::vector<FrameBuffer::Plane> &planes = buffer->planes(); if (buf.memory == V4L2_MEMORY_DMABUF) { if (multiPlanar) { for (unsigned int p = 0; p < planes.size(); ++p) v4l2Planes[p].m.fd = planes[p].fd.fd(); } else { buf.m.fd = planes[0].fd.fd(); } } if (multiPlanar) { buf.length = planes.size(); buf.m.planes = v4l2Planes; } if (V4L2_TYPE_IS_OUTPUT(buf.type)) { const FrameMetadata &metadata = buffer->metadata(); if (multiPlanar) { unsigned int nplane = 0; for (const FrameMetadata::Plane &plane : metadata.planes) { v4l2Planes[nplane].bytesused = plane.bytesused; v4l2Planes[nplane].length = buffer->planes()[nplane].length; nplane++; } } else { if (metadata.planes.size()) buf.bytesused = metadata.planes[0].bytesused; } buf.sequence = metadata.sequence; buf.timestamp.tv_sec = metadata.timestamp / 1000000000; buf.timestamp.tv_usec = (metadata.timestamp / 1000) % 1000000; } LOG(V4L2, Debug) << "Queueing buffer " << buf.index; ret = ioctl(VIDIOC_QBUF, &buf); if (ret < 0) { LOG(V4L2, Error) << "Failed to queue buffer " << buf.index << ": " << strerror(-ret); return ret; } if (queuedBuffers_.empty()) fdEvent_->setEnabled(true); queuedBuffers_[buf.index] = buffer; return 0; } /** * \brief Slot to handle completed buffer events from the V4L2 video device * \param[in] notifier The event notifier * * When this slot is called, a Buffer has become available from the device, and * will be emitted through the bufferReady Signal. * * For Capture video devices the FrameBuffer will contain valid data. * For Output video devices the FrameBuffer can be considered empty. */ void V4L2VideoDevice::bufferAvailable(EventNotifier *notifier) { FrameBuffer *buffer = dequeueBuffer(); if (!buffer) return; /* Notify anyone listening to the device. */ bufferReady.emit(buffer); } /** * \brief Dequeue the next available buffer from the video device * * This method dequeues the next available buffer from the device. If no buffer * is available to be dequeued it will return nullptr immediately. * * \return A pointer to the dequeued buffer on success, or nullptr otherwise */ FrameBuffer *V4L2VideoDevice::dequeueBuffer() { struct v4l2_buffer buf = {}; struct v4l2_plane planes[VIDEO_MAX_PLANES] = {}; int ret; buf.type = bufferType_; buf.memory = memoryType_; bool multiPlanar = V4L2_TYPE_IS_MULTIPLANAR(buf.type); if (multiPlanar) { buf.length = VIDEO_MAX_PLANES; buf.m.planes = planes; } ret = ioctl(VIDIOC_DQBUF, &buf); if (ret < 0) { LOG(V4L2, Error) << "Failed to dequeue buffer: " << strerror(-ret); return nullptr; } LOG(V4L2, Debug) << "Dequeuing buffer " << buf.index; cache_->put(buf.index); auto it = queuedBuffers_.find(buf.index); FrameBuffer *buffer = it->second; queuedBuffers_.erase(it); if (queuedBuffers_.empty()) fdEvent_->setEnabled(false); buffer->metadata_.status = buf.flags & V4L2_BUF_FLAG_ERROR ? FrameMetadata::FrameError : FrameMetadata::FrameSuccess; buffer->metadata_.sequence = buf.sequence; buffer->metadata_.timestamp = buf.timestamp.tv_sec * 1000000000ULL + buf.timestamp.tv_usec * 1000ULL; buffer->metadata_.planes.clear(); if (multiPlanar) { for (unsigned int nplane = 0; nplane < buf.length; nplane++) buffer->metadata_.planes.push_back({ planes[nplane].bytesused }); } else { buffer->metadata_.planes.push_back({ buf.bytesused }); } return buffer; } /** * \var V4L2VideoDevice::bufferReady * \brief A Signal emitted when a framebuffer completes */ /** * \brief Start the video stream * \return 0 on success or a negative error code otherwise */ int V4L2VideoDevice::streamOn() { int ret; ret = ioctl(VIDIOC_STREAMON, &bufferType_); if (ret < 0) { LOG(V4L2, Error) << "Failed to start streaming: " << strerror(-ret); return ret; } return 0; } /** * \brief Stop the video stream * * Buffers that are still queued when the video stream is stopped are * immediately dequeued with their status set to FrameMetadata::FrameCancelled, * and the bufferReady signal is emitted for them. The order in which those * buffers are dequeued is not specified. * * \return 0 on success or a negative error code otherwise */ int V4L2VideoDevice::streamOff() { int ret; ret = ioctl(VIDIOC_STREAMOFF, &bufferType_); if (ret < 0) { LOG(V4L2, Error) << "Failed to stop streaming: " << strerror(-ret); return ret; } /* Send back all queued buffers. */ for (auto it : queuedBuffers_) { FrameBuffer *buffer = it.second; buffer->metadata_.status = FrameMetadata::FrameCancelled; bufferReady.emit(buffer); } queuedBuffers_.clear(); fdEvent_->setEnabled(false); return 0; } /** * \brief Create a new video device instance from \a entity in media device * \a media * \param[in] media The media device where the entity is registered * \param[in] entity The media entity name * * Releasing memory of the newly created instance is responsibility of the * caller of this function. * * \return A newly created V4L2VideoDevice on success, nullptr otherwise */ V4L2VideoDevice *V4L2VideoDevice::fromEntityName(const MediaDevice *media, const std::string &entity) { MediaEntity *mediaEntity = media->getEntityByName(entity); if (!mediaEntity) return nullptr; return new V4L2VideoDevice(mediaEntity); } /** * \brief Convert a \a v4l2Fourcc to the corresponding PixelFormat * \param[in] v4l2Fourcc The V4L2 pixel format (V4L2_PIX_FORMAT_*) * \return The PixelFormat corresponding to \a v4l2Fourcc */ PixelFormat V4L2VideoDevice::toPixelFormat(uint32_t v4l2Fourcc) { switch (v4l2Fourcc) { /* RGB formats. */ case V4L2_PIX_FMT_RGB24: return PixelFormat(DRM_FORMAT_BGR888); case V4L2_PIX_FMT_BGR24: return PixelFormat(DRM_FORMAT_RGB888); case V4L2_PIX_FMT_ARGB32: return PixelFormat(DRM_FORMAT_BGRA8888); /* YUV packed formats. */ case V4L2_PIX_FMT_YUYV: return PixelFormat(DRM_FORMAT_YUYV); case V4L2_PIX_FMT_YVYU: return PixelFormat(DRM_FORMAT_YVYU); case V4L2_PIX_FMT_UYVY: return PixelFormat(DRM_FORMAT_UYVY); case V4L2_PIX_FMT_VYUY: return PixelFormat(DRM_FORMAT_VYUY); /* YUY planar formats. */ case V4L2_PIX_FMT_NV16: case V4L2_PIX_FMT_NV16M: return PixelFormat(DRM_FORMAT_NV16); case V4L2_PIX_FMT_NV61: case V4L2_PIX_FMT_NV61M: return PixelFormat(DRM_FORMAT_NV61); case V4L2_PIX_FMT_NV12: case V4L2_PIX_FMT_NV12M: return PixelFormat(DRM_FORMAT_NV12); case V4L2_PIX_FMT_NV21: case V4L2_PIX_FMT_NV21M: return PixelFormat(DRM_FORMAT_NV21); /* Compressed formats. */ case V4L2_PIX_FMT_MJPEG: return PixelFormat(DRM_FORMAT_MJPEG); /* V4L2 formats not yet supported by DRM. */ case V4L2_PIX_FMT_GREY: default: /* * \todo We can't use LOG() in a static method of a Loggable * class. Until we fix the logger, work around it. */ libcamera::_log(__FILE__, __LINE__, _LOG_CATEGORY(V4L2)(), LogError).stream() << "Unsupported V4L2 pixel format " << utils::hex(v4l2Fourcc); return PixelFormat(); } } /** * \brief Convert \a PixelFormat to its corresponding V4L2 FourCC * \param[in] pixelFormat The PixelFormat to convert * * For multiplanar formats, the V4L2 format variant (contiguous or * non-contiguous planes) is selected automatically based on the capabilities * of the video device. If the video device supports the V4L2 multiplanar API, * non-contiguous formats are preferred. * * \return The V4L2_PIX_FMT_* pixel format code corresponding to \a pixelFormat */ uint32_t V4L2VideoDevice::toV4L2Fourcc(const PixelFormat &pixelFormat) { return V4L2VideoDevice::toV4L2Fourcc(pixelFormat, caps_.isMultiplanar()); } /** * \brief Convert \a pixelFormat to its corresponding V4L2 FourCC * \param[in] pixelFormat The PixelFormat to convert * \param[in] multiplanar V4L2 Multiplanar API support flag * * Multiple V4L2 formats may exist for one PixelFormat when the format uses * multiple planes, as V4L2 defines separate 4CCs for contiguous and separate * planes formats. Set the \a multiplanar parameter to false to select a format * with contiguous planes, or to true to select a format with non-contiguous * planes. * * \return The V4L2_PIX_FMT_* pixel format code corresponding to \a pixelFormat */ uint32_t V4L2VideoDevice::toV4L2Fourcc(const PixelFormat &pixelFormat, bool multiplanar) { switch (pixelFormat) { /* RGB formats. */ case DRM_FORMAT_BGR888: return V4L2_PIX_FMT_RGB24; case DRM_FORMAT_RGB888: return V4L2_PIX_FMT_BGR24; case DRM_FORMAT_BGRA8888: return V4L2_PIX_FMT_ARGB32; /* YUV packed formats. */ case DRM_FORMAT_YUYV: return V4L2_PIX_FMT_YUYV; case DRM_FORMAT_YVYU: return V4L2_PIX_FMT_YVYU; case DRM_FORMAT_UYVY: return V4L2_PIX_FMT_UYVY; case DRM_FORMAT_VYUY: return V4L2_PIX_FMT_VYUY; /* * YUY planar formats. * \todo Add support for non-contiguous memory planes * \todo Select the format variant not only based on \a multiplanar but * also take into account the formats supported by the device. */ case DRM_FORMAT_NV16: return V4L2_PIX_FMT_NV16; case DRM_FORMAT_NV61: return V4L2_PIX_FMT_NV61; case DRM_FORMAT_NV12: return V4L2_PIX_FMT_NV12; case DRM_FORMAT_NV21: return V4L2_PIX_FMT_NV21; /* Compressed formats. */ case DRM_FORMAT_MJPEG: return V4L2_PIX_FMT_MJPEG; } /* * \todo We can't use LOG() in a static method of a Loggable * class. Until we fix the logger, work around it. */ libcamera::_log(__FILE__, __LINE__, _LOG_CATEGORY(V4L2)(), LogError).stream() << "Unsupported V4L2 pixel format " << pixelFormat.toString(); return 0; } /** * \class V4L2M2MDevice * \brief Memory-to-Memory video device * * The V4L2M2MDevice manages two V4L2VideoDevice instances on the same * deviceNode which operate together using two queues to implement the V4L2 * Memory to Memory API. * * The two devices should be opened by calling open() on the V4L2M2MDevice, and * can be closed by calling close on the V4L2M2MDevice. * * Calling V4L2VideoDevice::open() and V4L2VideoDevice::close() on the capture * or output V4L2VideoDevice is not permitted. */ /** * \fn V4L2M2MDevice::output * \brief Retrieve the output V4L2VideoDevice instance * \return The output V4L2VideoDevice instance */ /** * \fn V4L2M2MDevice::capture * \brief Retrieve the capture V4L2VideoDevice instance * \return The capture V4L2VideoDevice instance */ /** * \brief Create a new V4L2M2MDevice from the \a deviceNode * \param[in] deviceNode The file-system path to the video device node */ V4L2M2MDevice::V4L2M2MDevice(const std::string &deviceNode) : deviceNode_(deviceNode) { output_ = new V4L2VideoDevice(deviceNode); capture_ = new V4L2VideoDevice(deviceNode); } V4L2M2MDevice::~V4L2M2MDevice() { delete capture_; delete output_; } /** * \brief Open a V4L2 Memory to Memory device * * Open the device node and prepare the two V4L2VideoDevice instances to handle * their respective buffer queues. * * \return 0 on success or a negative error code otherwise */ int V4L2M2MDevice::open() { int fd; int ret; /* * The output and capture V4L2VideoDevice instances use the same file * handle for the same device node. The local file handle can be closed * as the V4L2VideoDevice::open() retains a handle by duplicating the * fd passed in. */ fd = syscall(SYS_openat, AT_FDCWD, deviceNode_.c_str(), O_RDWR | O_NONBLOCK); if (fd < 0) { ret = -errno; LOG(V4L2, Error) << "Failed to open V4L2 M2M device: " << strerror(-ret); return ret; } ret = output_->open(fd, V4L2_BUF_TYPE_VIDEO_OUTPUT); if (ret) goto err; ret = capture_->open(fd, V4L2_BUF_TYPE_VIDEO_CAPTURE); if (ret) goto err; ::close(fd); return 0; err: close(); ::close(fd); return ret; } /** * \brief Close the memory-to-memory device, releasing any resources acquired by * open() */ void V4L2M2MDevice::close() { capture_->close(); output_->close(); } } /* namespace libcamera */