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
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
//! Generated by `cargo run --bin generate_rust controls`

use std::ops::{Deref, DerefMut};

use num_enum::{IntoPrimitive, TryFromPrimitive};

#[allow(unused_imports)]
use crate::geometry::{Rectangle, Size};
use crate::{
    control::{Control, ControlEntry, DynControlEntry},
    control_value::{ControlValue, ControlValueError},
};

#[derive(Debug, Clone, Copy, Eq, PartialEq, TryFromPrimitive, IntoPrimitive)]
#[repr(u32)]
pub enum ControlId {
    /// Enable or disable the AE.
    ///
    /// \sa ExposureTime AnalogueGain
    AeEnable = 1,
    /// Report the lock status of a running AE algorithm.
    ///
    /// If the AE algorithm is locked the value shall be set to true, if it's
    /// converging it shall be set to false. If the AE algorithm is not
    /// running the control shall not be present in the metadata control list.
    ///
    /// \sa AeEnable
    AeLocked = 2,
    /// Specify a metering mode for the AE algorithm to use. The metering
    /// modes determine which parts of the image are used to determine the
    /// scene brightness. Metering modes may be platform specific and not
    /// all metering modes may be supported.
    AeMeteringMode = 3,
    /// Specify a constraint mode for the AE algorithm to use. These determine
    /// how the measured scene brightness is adjusted to reach the desired
    /// target exposure. Constraint modes may be platform specific, and not
    /// all constraint modes may be supported.
    AeConstraintMode = 4,
    /// Specify an exposure mode for the AE algorithm to use. These specify
    /// how the desired total exposure is divided between the shutter time
    /// and the sensor's analogue gain. The exposure modes are platform
    /// specific, and not all exposure modes may be supported.
    AeExposureMode = 5,
    /// Specify an Exposure Value (EV) parameter. The EV parameter will only be
    /// applied if the AE algorithm is currently enabled.
    ///
    /// By convention EV adjusts the exposure as log2. For example
    /// EV = [-2, -1, 0.5, 0, 0.5, 1, 2] results in an exposure adjustment
    /// of [1/4x, 1/2x, 1/sqrt(2)x, 1x, sqrt(2)x, 2x, 4x].
    ///
    /// \sa AeEnable
    ExposureValue = 6,
    /// Exposure time (shutter speed) for the frame applied in the sensor
    /// device. This value is specified in micro-seconds.
    ///
    /// Setting this value means that it is now fixed and the AE algorithm may
    /// not change it. Setting it back to zero returns it to the control of the
    /// AE algorithm.
    ///
    /// \sa AnalogueGain AeEnable
    ///
    /// \todo Document the interactions between AeEnable and setting a fixed
    /// value for this control. Consider interactions with other AE features,
    /// such as aperture and aperture/shutter priority mode, and decide if
    /// control of which features should be automatically adjusted shouldn't
    /// better be handled through a separate AE mode control.
    ExposureTime = 7,
    /// Analogue gain value applied in the sensor device.
    /// The value of the control specifies the gain multiplier applied to all
    /// colour channels. This value cannot be lower than 1.0.
    ///
    /// Setting this value means that it is now fixed and the AE algorithm may
    /// not change it. Setting it back to zero returns it to the control of the
    /// AE algorithm.
    ///
    /// \sa ExposureTime AeEnable
    ///
    /// \todo Document the interactions between AeEnable and setting a fixed
    /// value for this control. Consider interactions with other AE features,
    /// such as aperture and aperture/shutter priority mode, and decide if
    /// control of which features should be automatically adjusted shouldn't
    /// better be handled through a separate AE mode control.
    AnalogueGain = 8,
    /// Specify a fixed brightness parameter. Positive values (up to 1.0)
    /// produce brighter images; negative values (up to -1.0) produce darker
    /// images and 0.0 leaves pixels unchanged.
    Brightness = 9,
    /// Specify a fixed contrast parameter. Normal contrast is given by the
    /// value 1.0; larger values produce images with more contrast.
    Contrast = 10,
    /// Report an estimate of the current illuminance level in lux. The Lux
    /// control can only be returned in metadata.
    Lux = 11,
    /// Enable or disable the AWB.
    ///
    /// \sa ColourGains
    AwbEnable = 12,
    /// Specify the range of illuminants to use for the AWB algorithm. The modes
    /// supported are platform specific, and not all modes may be supported.
    AwbMode = 13,
    /// Report the lock status of a running AWB algorithm.
    ///
    /// If the AWB algorithm is locked the value shall be set to true, if it's
    /// converging it shall be set to false. If the AWB algorithm is not
    /// running the control shall not be present in the metadata control list.
    ///
    /// \sa AwbEnable
    AwbLocked = 14,
    /// Pair of gain values for the Red and Blue colour channels, in that
    /// order. ColourGains can only be applied in a Request when the AWB is
    /// disabled.
    ///
    /// \sa AwbEnable
    ColourGains = 15,
    /// Report the current estimate of the colour temperature, in kelvin, for this frame. The ColourTemperature control
    /// can only be returned in metadata.
    ColourTemperature = 16,
    /// Specify a fixed saturation parameter. Normal saturation is given by
    /// the value 1.0; larger values produce more saturated colours; 0.0
    /// produces a greyscale image.
    Saturation = 17,
    /// Reports the sensor black levels used for processing a frame, in the
    /// order R, Gr, Gb, B. These values are returned as numbers out of a 16-bit
    /// pixel range (as if pixels ranged from 0 to 65535). The SensorBlackLevels
    /// control can only be returned in metadata.
    SensorBlackLevels = 18,
    /// A value of 0.0 means no sharpening. The minimum value means
    /// minimal sharpening, and shall be 0.0 unless the camera can't
    /// disable sharpening completely. The default value shall give a
    /// "reasonable" level of sharpening, suitable for most use cases.
    /// The maximum value may apply extremely high levels of sharpening,
    /// higher than anyone could reasonably want. Negative values are
    /// not allowed. Note also that sharpening is not applied to raw
    /// streams.
    Sharpness = 19,
    /// Reports a Figure of Merit (FoM) to indicate how in-focus the frame is.
    /// A larger FocusFoM value indicates a more in-focus frame. This control
    /// depends on the IPA to gather ISP statistics from the defined focus
    /// region, and combine them in a suitable way to generate a FocusFoM value.
    /// In this respect, it is not necessarily aimed at providing a way to
    /// implement a focus algorithm by the application, rather an indication of
    /// how in-focus a frame is.
    FocusFoM = 20,
    /// The 3x3 matrix that converts camera RGB to sRGB within the
    /// imaging pipeline. This should describe the matrix that is used
    /// after pixels have been white-balanced, but before any gamma
    /// transformation. The 3x3 matrix is stored in conventional reading
    /// order in an array of 9 floating point values.
    ColourCorrectionMatrix = 21,
    /// Sets the image portion that will be scaled to form the whole of
    /// the final output image. The (x,y) location of this rectangle is
    /// relative to the PixelArrayActiveAreas that is being used. The units
    /// remain native sensor pixels, even if the sensor is being used in
    /// a binning or skipping mode.
    ///
    /// This control is only present when the pipeline supports scaling. Its
    /// maximum valid value is given by the properties::ScalerCropMaximum
    /// property, and the two can be used to implement digital zoom.
    ScalerCrop = 22,
    /// Digital gain value applied during the processing steps applied
    /// to the image as captured from the sensor.
    ///
    /// The global digital gain factor is applied to all the colour channels
    /// of the RAW image. Different pipeline models are free to
    /// specify how the global gain factor applies to each separate
    /// channel.
    ///
    /// If an imaging pipeline applies digital gain in distinct
    /// processing steps, this value indicates their total sum.
    /// Pipelines are free to decide how to adjust each processing
    /// step to respect the received gain factor and shall report
    /// their total value in the request metadata.
    DigitalGain = 23,
    /// The instantaneous frame duration from start of frame exposure to start
    /// of next exposure, expressed in microseconds. This control is meant to
    /// be returned in metadata.
    FrameDuration = 24,
    /// The minimum and maximum (in that order) frame duration,
    /// expressed in microseconds.
    ///
    /// When provided by applications, the control specifies the sensor frame
    /// duration interval the pipeline has to use. This limits the largest
    /// exposure time the sensor can use. For example, if a maximum frame
    /// duration of 33ms is requested (corresponding to 30 frames per second),
    /// the sensor will not be able to raise the exposure time above 33ms.
    /// A fixed frame duration is achieved by setting the minimum and maximum
    /// values to be the same. Setting both values to 0 reverts to using the
    /// IPA provided defaults.
    ///
    /// The maximum frame duration provides the absolute limit to the shutter
    /// speed computed by the AE algorithm and it overrides any exposure mode
    /// setting specified with controls::AeExposureMode. Similarly, when a
    /// manual exposure time is set through controls::ExposureTime, it also
    /// gets clipped to the limits set by this control. When reported in
    /// metadata, the control expresses the minimum and maximum frame
    /// durations used after being clipped to the sensor provided frame
    /// duration limits.
    ///
    /// \sa AeExposureMode
    /// \sa ExposureTime
    ///
    /// \todo Define how to calculate the capture frame rate by
    /// defining controls to report additional delays introduced by
    /// the capture pipeline or post-processing stages (ie JPEG
    /// conversion, frame scaling).
    ///
    /// \todo Provide an explicit definition of default control values, for
    /// this and all other controls.
    FrameDurationLimits = 25,
    /// Temperature measure from the camera sensor in Celsius. This is typically
    /// obtained by a thermal sensor present on-die or in the camera module. The
    /// range of reported temperatures is device dependent.
    ///
    /// The SensorTemperature control will only be returned in metadata if a
    /// themal sensor is present.
    SensorTemperature = 26,
    /// The time when the first row of the image sensor active array is exposed.
    ///
    /// The timestamp, expressed in nanoseconds, represents a monotonically
    /// increasing counter since the system boot time, as defined by the
    /// Linux-specific CLOCK_BOOTTIME clock id.
    ///
    /// The SensorTimestamp control can only be returned in metadata.
    ///
    /// \todo Define how the sensor timestamp has to be used in the reprocessing
    /// use case.
    SensorTimestamp = 27,
    /// Control to set the mode of the AF (autofocus) algorithm.
    ///
    /// An implementation may choose not to implement all the modes.
    AfMode = 28,
    /// Control to set the range of focus distances that is scanned. An
    /// implementation may choose not to implement all the options here.
    AfRange = 29,
    /// Control that determines whether the AF algorithm is to move the lens
    /// as quickly as possible or more steadily. For example, during video
    /// recording it may be desirable not to move the lens too abruptly, but
    /// when in a preview mode (waiting for a still capture) it may be
    /// helpful to move the lens as quickly as is reasonably possible.
    AfSpeed = 30,
    /// Instruct the AF algorithm how it should decide which parts of the image
    /// should be used to measure focus.
    AfMetering = 31,
    /// Sets the focus windows used by the AF algorithm when AfMetering is set
    /// to AfMeteringWindows. The units used are pixels within the rectangle
    /// returned by the ScalerCropMaximum property.
    ///
    /// In order to be activated, a rectangle must be programmed with non-zero
    /// width and height. Internally, these rectangles are intersected with the
    /// ScalerCropMaximum rectangle. If the window becomes empty after this
    /// operation, then the window is ignored. If all the windows end up being
    /// ignored, then the behaviour is platform dependent.
    ///
    /// On platforms that support the ScalerCrop control (for implementing
    /// digital zoom, for example), no automatic recalculation or adjustment of
    /// AF windows is performed internally if the ScalerCrop is changed. If any
    /// window lies outside the output image after the scaler crop has been
    /// applied, it is up to the application to recalculate them.
    ///
    /// The details of how the windows are used are platform dependent. We note
    /// that when there is more than one AF window, a typical implementation
    /// might find the optimal focus position for each one and finally select
    /// the window where the focal distance for the objects shown in that part
    /// of the image are closest to the camera.
    AfWindows = 32,
    /// This control starts an autofocus scan when AfMode is set to AfModeAuto,
    /// and can also be used to terminate a scan early.
    ///
    /// It is ignored if AfMode is set to AfModeManual or AfModeContinuous.
    AfTrigger = 33,
    /// This control has no effect except when in continuous autofocus mode
    /// (AfModeContinuous). It can be used to pause any lens movements while
    /// (for example) images are captured. The algorithm remains inactive
    /// until it is instructed to resume.
    AfPause = 34,
    /// Acts as a control to instruct the lens to move to a particular position
    /// and also reports back the position of the lens for each frame.
    ///
    /// The LensPosition control is ignored unless the AfMode is set to
    /// AfModeManual, though the value is reported back unconditionally in all
    /// modes.
    ///
    /// The units are a reciprocal distance scale like dioptres but normalised
    /// for the hyperfocal distance. That is, for a lens with hyperfocal
    /// distance H, and setting it to a focal distance D, the lens position LP,
    /// which is generally a non-integer, is given by
    ///
    /// \f$LP = \frac{H}{D}\f$
    ///
    /// For example:
    ///
    /// 0 moves the lens to infinity.
    /// 0.5 moves the lens to twice the hyperfocal distance.
    /// 1 moves the lens to the hyperfocal position.
    /// And larger values will focus the lens ever closer.
    ///
    /// \todo Define a property to report the Hyperforcal distance of calibrated
    /// lenses.
    ///
    /// \todo Define a property to report the maximum and minimum positions of
    /// this lens. The minimum value will often be zero (meaning infinity).
    LensPosition = 35,
    /// Reports the current state of the AF algorithm in conjunction with the
    /// reported AfMode value and (in continuous AF mode) the AfPauseState
    /// value. The possible state changes are described below, though we note
    /// the following state transitions that occur when the AfMode is changed.
    ///
    /// If the AfMode is set to AfModeManual, then the AfState will always
    /// report AfStateIdle (even if the lens is subsequently moved). Changing to
    /// the AfModeManual state does not initiate any lens movement.
    ///
    /// If the AfMode is set to AfModeAuto then the AfState will report
    /// AfStateIdle. However, if AfModeAuto and AfTriggerStart are sent together
    /// then AfState will omit AfStateIdle and move straight to AfStateScanning
    /// (and start a scan).
    ///
    /// If the AfMode is set to AfModeContinuous then the AfState will initially
    /// report AfStateScanning.
    AfState = 36,
    /// Only applicable in continuous (AfModeContinuous) mode, this reports
    /// whether the algorithm is currently running, paused or pausing (that is,
    /// will pause as soon as any in-progress scan completes).
    ///
    /// Any change to AfMode will cause AfPauseStateRunning to be reported.
    AfPauseState = 37,
    /// Control for AE metering trigger. Currently identical to
    /// ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER.
    ///
    /// Whether the camera device will trigger a precapture metering sequence
    /// when it processes this request.
    AePrecaptureTrigger = 38,
    /// Control to select the noise reduction algorithm mode. Currently
    /// identical to ANDROID_NOISE_REDUCTION_MODE.
    ///
    ///  Mode of operation for the noise reduction algorithm.
    NoiseReductionMode = 39,
    /// Control to select the color correction aberration mode. Currently
    /// identical to ANDROID_COLOR_CORRECTION_ABERRATION_MODE.
    ///
    ///  Mode of operation for the chromatic aberration correction algorithm.
    ColorCorrectionAberrationMode = 40,
    /// Control to report the current AE algorithm state. Currently identical to
    /// ANDROID_CONTROL_AE_STATE.
    ///
    ///  Current state of the AE algorithm.
    AeState = 41,
    /// Control to report the current AWB algorithm state. Currently identical
    /// to ANDROID_CONTROL_AWB_STATE.
    ///
    ///  Current state of the AWB algorithm.
    AwbState = 42,
    /// Control to report the time between the start of exposure of the first
    /// row and the start of exposure of the last row. Currently identical to
    /// ANDROID_SENSOR_ROLLING_SHUTTER_SKEW
    SensorRollingShutterSkew = 43,
    /// Control to report if the lens shading map is available. Currently
    /// identical to ANDROID_STATISTICS_LENS_SHADING_MAP_MODE.
    LensShadingMapMode = 44,
    /// Control to report the detected scene light frequency. Currently
    /// identical to ANDROID_STATISTICS_SCENE_FLICKER.
    SceneFlicker = 45,
    /// Specifies the number of pipeline stages the frame went through from when
    /// it was exposed to when the final completed result was available to the
    /// framework. Always less than or equal to PipelineMaxDepth. Currently
    /// identical to ANDROID_REQUEST_PIPELINE_DEPTH.
    ///
    /// The typical value for this control is 3 as a frame is first exposed,
    /// captured and then processed in a single pass through the ISP. Any
    /// additional processing step performed after the ISP pass (in example face
    /// detection, additional format conversions etc) count as an additional
    /// pipeline stage.
    PipelineDepth = 46,
    /// The maximum number of frames that can occur after a request (different
    /// than the previous) has been submitted, and before the result's state
    /// becomes synchronized. A value of -1 indicates unknown latency, and 0
    /// indicates per-frame control. Currently identical to
    /// ANDROID_SYNC_MAX_LATENCY.
    MaxLatency = 47,
    /// Control to select the test pattern mode. Currently identical to
    /// ANDROID_SENSOR_TEST_PATTERN_MODE.
    TestPatternMode = 48,
}

/// Enable or disable the AE.
///
/// \sa ExposureTime AnalogueGain
#[derive(Debug, Clone)]
pub struct AeEnable(pub bool);

impl Deref for AeEnable {
    type Target = bool;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for AeEnable {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl TryFrom<ControlValue> for AeEnable {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Ok(Self(<bool>::try_from(value)?))
    }
}

impl From<AeEnable> for ControlValue {
    fn from(val: AeEnable) -> Self {
        ControlValue::from(val.0)
    }
}

impl ControlEntry for AeEnable {
    const ID: u32 = ControlId::AeEnable as _;
}

impl Control for AeEnable {}

/// Report the lock status of a running AE algorithm.
///
/// If the AE algorithm is locked the value shall be set to true, if it's
/// converging it shall be set to false. If the AE algorithm is not
/// running the control shall not be present in the metadata control list.
///
/// \sa AeEnable
#[derive(Debug, Clone)]
pub struct AeLocked(pub bool);

impl Deref for AeLocked {
    type Target = bool;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for AeLocked {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl TryFrom<ControlValue> for AeLocked {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Ok(Self(<bool>::try_from(value)?))
    }
}

impl From<AeLocked> for ControlValue {
    fn from(val: AeLocked) -> Self {
        ControlValue::from(val.0)
    }
}

impl ControlEntry for AeLocked {
    const ID: u32 = ControlId::AeLocked as _;
}

impl Control for AeLocked {}

/// Specify a metering mode for the AE algorithm to use. The metering
/// modes determine which parts of the image are used to determine the
/// scene brightness. Metering modes may be platform specific and not
/// all metering modes may be supported.
#[derive(Debug, Clone, Copy, Eq, PartialEq, TryFromPrimitive, IntoPrimitive)]
#[repr(i32)]
pub enum AeMeteringMode {
    /// Centre-weighted metering mode.
    MeteringCentreWeighted = 0,
    /// Spot metering mode.
    MeteringSpot = 1,
    /// Matrix metering mode.
    MeteringMatrix = 2,
    /// Custom metering mode.
    MeteringCustom = 3,
}

impl TryFrom<ControlValue> for AeMeteringMode {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Self::try_from(i32::try_from(value.clone())?).map_err(|_| ControlValueError::UnknownVariant(value))
    }
}

impl From<AeMeteringMode> for ControlValue {
    fn from(val: AeMeteringMode) -> Self {
        ControlValue::from(<i32>::from(val))
    }
}
impl ControlEntry for AeMeteringMode {
    const ID: u32 = ControlId::AeMeteringMode as _;
}

impl Control for AeMeteringMode {}

/// Specify a constraint mode for the AE algorithm to use. These determine
/// how the measured scene brightness is adjusted to reach the desired
/// target exposure. Constraint modes may be platform specific, and not
/// all constraint modes may be supported.
#[derive(Debug, Clone, Copy, Eq, PartialEq, TryFromPrimitive, IntoPrimitive)]
#[repr(i32)]
pub enum AeConstraintMode {
    /// Default constraint mode. This mode aims to balance the exposure of different parts of the image so as to reach
    /// a reasonable average level. However, highlights in the image may appear over-exposed and lowlights may appear
    /// under-exposed.
    ConstraintNormal = 0,
    /// Highlight constraint mode. This mode adjusts the exposure levels in order to try and avoid over-exposing the
    /// brightest parts (highlights) of an image. Other non-highlight parts of the image may appear under-exposed.
    ConstraintHighlight = 1,
    /// Shadows constraint mode. This mode adjusts the exposure levels in order to try and avoid under-exposing the
    /// dark parts (shadows) of an image. Other normally exposed parts of the image may appear over-exposed.
    ConstraintShadows = 2,
    /// Custom constraint mode.
    ConstraintCustom = 3,
}

impl TryFrom<ControlValue> for AeConstraintMode {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Self::try_from(i32::try_from(value.clone())?).map_err(|_| ControlValueError::UnknownVariant(value))
    }
}

impl From<AeConstraintMode> for ControlValue {
    fn from(val: AeConstraintMode) -> Self {
        ControlValue::from(<i32>::from(val))
    }
}
impl ControlEntry for AeConstraintMode {
    const ID: u32 = ControlId::AeConstraintMode as _;
}

impl Control for AeConstraintMode {}

/// Specify an exposure mode for the AE algorithm to use. These specify
/// how the desired total exposure is divided between the shutter time
/// and the sensor's analogue gain. The exposure modes are platform
/// specific, and not all exposure modes may be supported.
#[derive(Debug, Clone, Copy, Eq, PartialEq, TryFromPrimitive, IntoPrimitive)]
#[repr(i32)]
pub enum AeExposureMode {
    /// Default exposure mode.
    ExposureNormal = 0,
    /// Exposure mode allowing only short exposure times.
    ExposureShort = 1,
    /// Exposure mode allowing long exposure times.
    ExposureLong = 2,
    /// Custom exposure mode.
    ExposureCustom = 3,
}

impl TryFrom<ControlValue> for AeExposureMode {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Self::try_from(i32::try_from(value.clone())?).map_err(|_| ControlValueError::UnknownVariant(value))
    }
}

impl From<AeExposureMode> for ControlValue {
    fn from(val: AeExposureMode) -> Self {
        ControlValue::from(<i32>::from(val))
    }
}
impl ControlEntry for AeExposureMode {
    const ID: u32 = ControlId::AeExposureMode as _;
}

impl Control for AeExposureMode {}

/// Specify an Exposure Value (EV) parameter. The EV parameter will only be
/// applied if the AE algorithm is currently enabled.
///
/// By convention EV adjusts the exposure as log2. For example
/// EV = [-2, -1, 0.5, 0, 0.5, 1, 2] results in an exposure adjustment
/// of [1/4x, 1/2x, 1/sqrt(2)x, 1x, sqrt(2)x, 2x, 4x].
///
/// \sa AeEnable
#[derive(Debug, Clone)]
pub struct ExposureValue(pub f32);

impl Deref for ExposureValue {
    type Target = f32;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for ExposureValue {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl TryFrom<ControlValue> for ExposureValue {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Ok(Self(<f32>::try_from(value)?))
    }
}

impl From<ExposureValue> for ControlValue {
    fn from(val: ExposureValue) -> Self {
        ControlValue::from(val.0)
    }
}

impl ControlEntry for ExposureValue {
    const ID: u32 = ControlId::ExposureValue as _;
}

impl Control for ExposureValue {}

/// Exposure time (shutter speed) for the frame applied in the sensor
/// device. This value is specified in micro-seconds.
///
/// Setting this value means that it is now fixed and the AE algorithm may
/// not change it. Setting it back to zero returns it to the control of the
/// AE algorithm.
///
/// \sa AnalogueGain AeEnable
///
/// \todo Document the interactions between AeEnable and setting a fixed
/// value for this control. Consider interactions with other AE features,
/// such as aperture and aperture/shutter priority mode, and decide if
/// control of which features should be automatically adjusted shouldn't
/// better be handled through a separate AE mode control.
#[derive(Debug, Clone)]
pub struct ExposureTime(pub i32);

impl Deref for ExposureTime {
    type Target = i32;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for ExposureTime {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl TryFrom<ControlValue> for ExposureTime {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Ok(Self(<i32>::try_from(value)?))
    }
}

impl From<ExposureTime> for ControlValue {
    fn from(val: ExposureTime) -> Self {
        ControlValue::from(val.0)
    }
}

impl ControlEntry for ExposureTime {
    const ID: u32 = ControlId::ExposureTime as _;
}

impl Control for ExposureTime {}

/// Analogue gain value applied in the sensor device.
/// The value of the control specifies the gain multiplier applied to all
/// colour channels. This value cannot be lower than 1.0.
///
/// Setting this value means that it is now fixed and the AE algorithm may
/// not change it. Setting it back to zero returns it to the control of the
/// AE algorithm.
///
/// \sa ExposureTime AeEnable
///
/// \todo Document the interactions between AeEnable and setting a fixed
/// value for this control. Consider interactions with other AE features,
/// such as aperture and aperture/shutter priority mode, and decide if
/// control of which features should be automatically adjusted shouldn't
/// better be handled through a separate AE mode control.
#[derive(Debug, Clone)]
pub struct AnalogueGain(pub f32);

impl Deref for AnalogueGain {
    type Target = f32;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for AnalogueGain {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl TryFrom<ControlValue> for AnalogueGain {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Ok(Self(<f32>::try_from(value)?))
    }
}

impl From<AnalogueGain> for ControlValue {
    fn from(val: AnalogueGain) -> Self {
        ControlValue::from(val.0)
    }
}

impl ControlEntry for AnalogueGain {
    const ID: u32 = ControlId::AnalogueGain as _;
}

impl Control for AnalogueGain {}

/// Specify a fixed brightness parameter. Positive values (up to 1.0)
/// produce brighter images; negative values (up to -1.0) produce darker
/// images and 0.0 leaves pixels unchanged.
#[derive(Debug, Clone)]
pub struct Brightness(pub f32);

impl Deref for Brightness {
    type Target = f32;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for Brightness {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl TryFrom<ControlValue> for Brightness {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Ok(Self(<f32>::try_from(value)?))
    }
}

impl From<Brightness> for ControlValue {
    fn from(val: Brightness) -> Self {
        ControlValue::from(val.0)
    }
}

impl ControlEntry for Brightness {
    const ID: u32 = ControlId::Brightness as _;
}

impl Control for Brightness {}

/// Specify a fixed contrast parameter. Normal contrast is given by the
/// value 1.0; larger values produce images with more contrast.
#[derive(Debug, Clone)]
pub struct Contrast(pub f32);

impl Deref for Contrast {
    type Target = f32;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for Contrast {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl TryFrom<ControlValue> for Contrast {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Ok(Self(<f32>::try_from(value)?))
    }
}

impl From<Contrast> for ControlValue {
    fn from(val: Contrast) -> Self {
        ControlValue::from(val.0)
    }
}

impl ControlEntry for Contrast {
    const ID: u32 = ControlId::Contrast as _;
}

impl Control for Contrast {}

/// Report an estimate of the current illuminance level in lux. The Lux
/// control can only be returned in metadata.
#[derive(Debug, Clone)]
pub struct Lux(pub f32);

impl Deref for Lux {
    type Target = f32;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for Lux {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl TryFrom<ControlValue> for Lux {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Ok(Self(<f32>::try_from(value)?))
    }
}

impl From<Lux> for ControlValue {
    fn from(val: Lux) -> Self {
        ControlValue::from(val.0)
    }
}

impl ControlEntry for Lux {
    const ID: u32 = ControlId::Lux as _;
}

impl Control for Lux {}

/// Enable or disable the AWB.
///
/// \sa ColourGains
#[derive(Debug, Clone)]
pub struct AwbEnable(pub bool);

impl Deref for AwbEnable {
    type Target = bool;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for AwbEnable {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl TryFrom<ControlValue> for AwbEnable {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Ok(Self(<bool>::try_from(value)?))
    }
}

impl From<AwbEnable> for ControlValue {
    fn from(val: AwbEnable) -> Self {
        ControlValue::from(val.0)
    }
}

impl ControlEntry for AwbEnable {
    const ID: u32 = ControlId::AwbEnable as _;
}

impl Control for AwbEnable {}

/// Specify the range of illuminants to use for the AWB algorithm. The modes
/// supported are platform specific, and not all modes may be supported.
#[derive(Debug, Clone, Copy, Eq, PartialEq, TryFromPrimitive, IntoPrimitive)]
#[repr(i32)]
pub enum AwbMode {
    /// Search over the whole colour temperature range.
    AwbAuto = 0,
    /// Incandescent AWB lamp mode.
    AwbIncandescent = 1,
    /// Tungsten AWB lamp mode.
    AwbTungsten = 2,
    /// Fluorescent AWB lamp mode.
    AwbFluorescent = 3,
    /// Indoor AWB lighting mode.
    AwbIndoor = 4,
    /// Daylight AWB lighting mode.
    AwbDaylight = 5,
    /// Cloudy AWB lighting mode.
    AwbCloudy = 6,
    /// Custom AWB mode.
    AwbCustom = 7,
}

impl TryFrom<ControlValue> for AwbMode {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Self::try_from(i32::try_from(value.clone())?).map_err(|_| ControlValueError::UnknownVariant(value))
    }
}

impl From<AwbMode> for ControlValue {
    fn from(val: AwbMode) -> Self {
        ControlValue::from(<i32>::from(val))
    }
}
impl ControlEntry for AwbMode {
    const ID: u32 = ControlId::AwbMode as _;
}

impl Control for AwbMode {}

/// Report the lock status of a running AWB algorithm.
///
/// If the AWB algorithm is locked the value shall be set to true, if it's
/// converging it shall be set to false. If the AWB algorithm is not
/// running the control shall not be present in the metadata control list.
///
/// \sa AwbEnable
#[derive(Debug, Clone)]
pub struct AwbLocked(pub bool);

impl Deref for AwbLocked {
    type Target = bool;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for AwbLocked {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl TryFrom<ControlValue> for AwbLocked {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Ok(Self(<bool>::try_from(value)?))
    }
}

impl From<AwbLocked> for ControlValue {
    fn from(val: AwbLocked) -> Self {
        ControlValue::from(val.0)
    }
}

impl ControlEntry for AwbLocked {
    const ID: u32 = ControlId::AwbLocked as _;
}

impl Control for AwbLocked {}

/// Pair of gain values for the Red and Blue colour channels, in that
/// order. ColourGains can only be applied in a Request when the AWB is
/// disabled.
///
/// \sa AwbEnable
#[derive(Debug, Clone)]
pub struct ColourGains(pub [f32; 2]);

impl Deref for ColourGains {
    type Target = [f32; 2];

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for ColourGains {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl TryFrom<ControlValue> for ColourGains {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Ok(Self(<[f32; 2]>::try_from(value)?))
    }
}

impl From<ColourGains> for ControlValue {
    fn from(val: ColourGains) -> Self {
        ControlValue::from(val.0)
    }
}

impl ControlEntry for ColourGains {
    const ID: u32 = ControlId::ColourGains as _;
}

impl Control for ColourGains {}

/// Report the current estimate of the colour temperature, in kelvin, for this frame. The ColourTemperature control can
/// only be returned in metadata.
#[derive(Debug, Clone)]
pub struct ColourTemperature(pub i32);

impl Deref for ColourTemperature {
    type Target = i32;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for ColourTemperature {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl TryFrom<ControlValue> for ColourTemperature {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Ok(Self(<i32>::try_from(value)?))
    }
}

impl From<ColourTemperature> for ControlValue {
    fn from(val: ColourTemperature) -> Self {
        ControlValue::from(val.0)
    }
}

impl ControlEntry for ColourTemperature {
    const ID: u32 = ControlId::ColourTemperature as _;
}

impl Control for ColourTemperature {}

/// Specify a fixed saturation parameter. Normal saturation is given by
/// the value 1.0; larger values produce more saturated colours; 0.0
/// produces a greyscale image.
#[derive(Debug, Clone)]
pub struct Saturation(pub f32);

impl Deref for Saturation {
    type Target = f32;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for Saturation {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl TryFrom<ControlValue> for Saturation {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Ok(Self(<f32>::try_from(value)?))
    }
}

impl From<Saturation> for ControlValue {
    fn from(val: Saturation) -> Self {
        ControlValue::from(val.0)
    }
}

impl ControlEntry for Saturation {
    const ID: u32 = ControlId::Saturation as _;
}

impl Control for Saturation {}

/// Reports the sensor black levels used for processing a frame, in the
/// order R, Gr, Gb, B. These values are returned as numbers out of a 16-bit
/// pixel range (as if pixels ranged from 0 to 65535). The SensorBlackLevels
/// control can only be returned in metadata.
#[derive(Debug, Clone)]
pub struct SensorBlackLevels(pub [i32; 4]);

impl Deref for SensorBlackLevels {
    type Target = [i32; 4];

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for SensorBlackLevels {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl TryFrom<ControlValue> for SensorBlackLevels {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Ok(Self(<[i32; 4]>::try_from(value)?))
    }
}

impl From<SensorBlackLevels> for ControlValue {
    fn from(val: SensorBlackLevels) -> Self {
        ControlValue::from(val.0)
    }
}

impl ControlEntry for SensorBlackLevels {
    const ID: u32 = ControlId::SensorBlackLevels as _;
}

impl Control for SensorBlackLevels {}

/// A value of 0.0 means no sharpening. The minimum value means
/// minimal sharpening, and shall be 0.0 unless the camera can't
/// disable sharpening completely. The default value shall give a
/// "reasonable" level of sharpening, suitable for most use cases.
/// The maximum value may apply extremely high levels of sharpening,
/// higher than anyone could reasonably want. Negative values are
/// not allowed. Note also that sharpening is not applied to raw
/// streams.
#[derive(Debug, Clone)]
pub struct Sharpness(pub f32);

impl Deref for Sharpness {
    type Target = f32;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for Sharpness {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl TryFrom<ControlValue> for Sharpness {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Ok(Self(<f32>::try_from(value)?))
    }
}

impl From<Sharpness> for ControlValue {
    fn from(val: Sharpness) -> Self {
        ControlValue::from(val.0)
    }
}

impl ControlEntry for Sharpness {
    const ID: u32 = ControlId::Sharpness as _;
}

impl Control for Sharpness {}

/// Reports a Figure of Merit (FoM) to indicate how in-focus the frame is.
/// A larger FocusFoM value indicates a more in-focus frame. This control
/// depends on the IPA to gather ISP statistics from the defined focus
/// region, and combine them in a suitable way to generate a FocusFoM value.
/// In this respect, it is not necessarily aimed at providing a way to
/// implement a focus algorithm by the application, rather an indication of
/// how in-focus a frame is.
#[derive(Debug, Clone)]
pub struct FocusFoM(pub i32);

impl Deref for FocusFoM {
    type Target = i32;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for FocusFoM {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl TryFrom<ControlValue> for FocusFoM {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Ok(Self(<i32>::try_from(value)?))
    }
}

impl From<FocusFoM> for ControlValue {
    fn from(val: FocusFoM) -> Self {
        ControlValue::from(val.0)
    }
}

impl ControlEntry for FocusFoM {
    const ID: u32 = ControlId::FocusFoM as _;
}

impl Control for FocusFoM {}

/// The 3x3 matrix that converts camera RGB to sRGB within the
/// imaging pipeline. This should describe the matrix that is used
/// after pixels have been white-balanced, but before any gamma
/// transformation. The 3x3 matrix is stored in conventional reading
/// order in an array of 9 floating point values.
#[derive(Debug, Clone)]
pub struct ColourCorrectionMatrix(pub [[f32; 3]; 3]);

impl Deref for ColourCorrectionMatrix {
    type Target = [[f32; 3]; 3];

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for ColourCorrectionMatrix {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl TryFrom<ControlValue> for ColourCorrectionMatrix {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Ok(Self(<[[f32; 3]; 3]>::try_from(value)?))
    }
}

impl From<ColourCorrectionMatrix> for ControlValue {
    fn from(val: ColourCorrectionMatrix) -> Self {
        ControlValue::from(val.0)
    }
}

impl ControlEntry for ColourCorrectionMatrix {
    const ID: u32 = ControlId::ColourCorrectionMatrix as _;
}

impl Control for ColourCorrectionMatrix {}

/// Sets the image portion that will be scaled to form the whole of
/// the final output image. The (x,y) location of this rectangle is
/// relative to the PixelArrayActiveAreas that is being used. The units
/// remain native sensor pixels, even if the sensor is being used in
/// a binning or skipping mode.
///
/// This control is only present when the pipeline supports scaling. Its
/// maximum valid value is given by the properties::ScalerCropMaximum
/// property, and the two can be used to implement digital zoom.
#[derive(Debug, Clone)]
pub struct ScalerCrop(pub Rectangle);

impl Deref for ScalerCrop {
    type Target = Rectangle;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for ScalerCrop {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl TryFrom<ControlValue> for ScalerCrop {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Ok(Self(<Rectangle>::try_from(value)?))
    }
}

impl From<ScalerCrop> for ControlValue {
    fn from(val: ScalerCrop) -> Self {
        ControlValue::from(val.0)
    }
}

impl ControlEntry for ScalerCrop {
    const ID: u32 = ControlId::ScalerCrop as _;
}

impl Control for ScalerCrop {}

/// Digital gain value applied during the processing steps applied
/// to the image as captured from the sensor.
///
/// The global digital gain factor is applied to all the colour channels
/// of the RAW image. Different pipeline models are free to
/// specify how the global gain factor applies to each separate
/// channel.
///
/// If an imaging pipeline applies digital gain in distinct
/// processing steps, this value indicates their total sum.
/// Pipelines are free to decide how to adjust each processing
/// step to respect the received gain factor and shall report
/// their total value in the request metadata.
#[derive(Debug, Clone)]
pub struct DigitalGain(pub f32);

impl Deref for DigitalGain {
    type Target = f32;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for DigitalGain {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl TryFrom<ControlValue> for DigitalGain {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Ok(Self(<f32>::try_from(value)?))
    }
}

impl From<DigitalGain> for ControlValue {
    fn from(val: DigitalGain) -> Self {
        ControlValue::from(val.0)
    }
}

impl ControlEntry for DigitalGain {
    const ID: u32 = ControlId::DigitalGain as _;
}

impl Control for DigitalGain {}

/// The instantaneous frame duration from start of frame exposure to start
/// of next exposure, expressed in microseconds. This control is meant to
/// be returned in metadata.
#[derive(Debug, Clone)]
pub struct FrameDuration(pub i64);

impl Deref for FrameDuration {
    type Target = i64;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for FrameDuration {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl TryFrom<ControlValue> for FrameDuration {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Ok(Self(<i64>::try_from(value)?))
    }
}

impl From<FrameDuration> for ControlValue {
    fn from(val: FrameDuration) -> Self {
        ControlValue::from(val.0)
    }
}

impl ControlEntry for FrameDuration {
    const ID: u32 = ControlId::FrameDuration as _;
}

impl Control for FrameDuration {}

/// The minimum and maximum (in that order) frame duration,
/// expressed in microseconds.
///
/// When provided by applications, the control specifies the sensor frame
/// duration interval the pipeline has to use. This limits the largest
/// exposure time the sensor can use. For example, if a maximum frame
/// duration of 33ms is requested (corresponding to 30 frames per second),
/// the sensor will not be able to raise the exposure time above 33ms.
/// A fixed frame duration is achieved by setting the minimum and maximum
/// values to be the same. Setting both values to 0 reverts to using the
/// IPA provided defaults.
///
/// The maximum frame duration provides the absolute limit to the shutter
/// speed computed by the AE algorithm and it overrides any exposure mode
/// setting specified with controls::AeExposureMode. Similarly, when a
/// manual exposure time is set through controls::ExposureTime, it also
/// gets clipped to the limits set by this control. When reported in
/// metadata, the control expresses the minimum and maximum frame
/// durations used after being clipped to the sensor provided frame
/// duration limits.
///
/// \sa AeExposureMode
/// \sa ExposureTime
///
/// \todo Define how to calculate the capture frame rate by
/// defining controls to report additional delays introduced by
/// the capture pipeline or post-processing stages (ie JPEG
/// conversion, frame scaling).
///
/// \todo Provide an explicit definition of default control values, for
/// this and all other controls.
#[derive(Debug, Clone)]
pub struct FrameDurationLimits(pub [i64; 2]);

impl Deref for FrameDurationLimits {
    type Target = [i64; 2];

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for FrameDurationLimits {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl TryFrom<ControlValue> for FrameDurationLimits {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Ok(Self(<[i64; 2]>::try_from(value)?))
    }
}

impl From<FrameDurationLimits> for ControlValue {
    fn from(val: FrameDurationLimits) -> Self {
        ControlValue::from(val.0)
    }
}

impl ControlEntry for FrameDurationLimits {
    const ID: u32 = ControlId::FrameDurationLimits as _;
}

impl Control for FrameDurationLimits {}

/// Temperature measure from the camera sensor in Celsius. This is typically
/// obtained by a thermal sensor present on-die or in the camera module. The
/// range of reported temperatures is device dependent.
///
/// The SensorTemperature control will only be returned in metadata if a
/// themal sensor is present.
#[derive(Debug, Clone)]
pub struct SensorTemperature(pub f32);

impl Deref for SensorTemperature {
    type Target = f32;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for SensorTemperature {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl TryFrom<ControlValue> for SensorTemperature {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Ok(Self(<f32>::try_from(value)?))
    }
}

impl From<SensorTemperature> for ControlValue {
    fn from(val: SensorTemperature) -> Self {
        ControlValue::from(val.0)
    }
}

impl ControlEntry for SensorTemperature {
    const ID: u32 = ControlId::SensorTemperature as _;
}

impl Control for SensorTemperature {}

/// The time when the first row of the image sensor active array is exposed.
///
/// The timestamp, expressed in nanoseconds, represents a monotonically
/// increasing counter since the system boot time, as defined by the
/// Linux-specific CLOCK_BOOTTIME clock id.
///
/// The SensorTimestamp control can only be returned in metadata.
///
/// \todo Define how the sensor timestamp has to be used in the reprocessing
/// use case.
#[derive(Debug, Clone)]
pub struct SensorTimestamp(pub i64);

impl Deref for SensorTimestamp {
    type Target = i64;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for SensorTimestamp {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl TryFrom<ControlValue> for SensorTimestamp {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Ok(Self(<i64>::try_from(value)?))
    }
}

impl From<SensorTimestamp> for ControlValue {
    fn from(val: SensorTimestamp) -> Self {
        ControlValue::from(val.0)
    }
}

impl ControlEntry for SensorTimestamp {
    const ID: u32 = ControlId::SensorTimestamp as _;
}

impl Control for SensorTimestamp {}

/// Control to set the mode of the AF (autofocus) algorithm.
///
/// An implementation may choose not to implement all the modes.
#[derive(Debug, Clone, Copy, Eq, PartialEq, TryFromPrimitive, IntoPrimitive)]
#[repr(i32)]
pub enum AfMode {
    /// The AF algorithm is in manual mode. In this mode it will never
    /// perform any action nor move the lens of its own accord, but an
    /// application can specify the desired lens position using the
    /// LensPosition control.
    ///
    /// In this mode the AfState will always report AfStateIdle.
    Manual = 0,
    /// The AF algorithm is in auto mode. This means that the algorithm
    /// will never move the lens or change state unless the AfTrigger
    /// control is used. The AfTrigger control can be used to initiate a
    /// focus scan, the results of which will be reported by AfState.
    ///
    /// If the autofocus algorithm is moved from AfModeAuto to another
    /// mode while a scan is in progress, the scan is cancelled
    /// immediately, without waiting for the scan to finish.
    ///
    /// When first entering this mode the AfState will report
    /// AfStateIdle. When a trigger control is sent, AfState will
    /// report AfStateScanning for a period before spontaneously
    /// changing to AfStateFocused or AfStateFailed, depending on
    /// the outcome of the scan. It will remain in this state until
    /// another scan is initiated by the AfTrigger control. If a scan is
    /// cancelled (without changing to another mode), AfState will return
    /// to AfStateIdle.
    Auto = 1,
    /// The AF algorithm is in continuous mode. This means that the lens can
    /// re-start a scan spontaneously at any moment, without any user
    /// intervention. The AfState still reports whether the algorithm is
    /// currently scanning or not, though the application has no ability to
    /// initiate or cancel scans, nor to move the lens for itself.
    ///
    /// However, applications can pause the AF algorithm from continuously
    /// scanning by using the AfPause control. This allows video or still
    /// images to be captured whilst guaranteeing that the focus is fixed.
    ///
    /// When set to AfModeContinuous, the system will immediately initiate a
    /// scan so AfState will report AfStateScanning, and will settle on one
    /// of AfStateFocused or AfStateFailed, depending on the scan result.
    Continuous = 2,
}

impl TryFrom<ControlValue> for AfMode {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Self::try_from(i32::try_from(value.clone())?).map_err(|_| ControlValueError::UnknownVariant(value))
    }
}

impl From<AfMode> for ControlValue {
    fn from(val: AfMode) -> Self {
        ControlValue::from(<i32>::from(val))
    }
}
impl ControlEntry for AfMode {
    const ID: u32 = ControlId::AfMode as _;
}

impl Control for AfMode {}

/// Control to set the range of focus distances that is scanned. An
/// implementation may choose not to implement all the options here.
#[derive(Debug, Clone, Copy, Eq, PartialEq, TryFromPrimitive, IntoPrimitive)]
#[repr(i32)]
pub enum AfRange {
    /// A wide range of focus distances is scanned, all the way from
    /// infinity down to close distances, though depending on the
    /// implementation, possibly not including the very closest macro
    /// positions.
    Normal = 0,
    /// Only close distances are scanned.
    Macro = 1,
    /// The full range of focus distances is scanned just as with
    /// AfRangeNormal but this time including the very closest macro
    /// positions.
    Full = 2,
}

impl TryFrom<ControlValue> for AfRange {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Self::try_from(i32::try_from(value.clone())?).map_err(|_| ControlValueError::UnknownVariant(value))
    }
}

impl From<AfRange> for ControlValue {
    fn from(val: AfRange) -> Self {
        ControlValue::from(<i32>::from(val))
    }
}
impl ControlEntry for AfRange {
    const ID: u32 = ControlId::AfRange as _;
}

impl Control for AfRange {}

/// Control that determines whether the AF algorithm is to move the lens
/// as quickly as possible or more steadily. For example, during video
/// recording it may be desirable not to move the lens too abruptly, but
/// when in a preview mode (waiting for a still capture) it may be
/// helpful to move the lens as quickly as is reasonably possible.
#[derive(Debug, Clone, Copy, Eq, PartialEq, TryFromPrimitive, IntoPrimitive)]
#[repr(i32)]
pub enum AfSpeed {
    /// Move the lens at its usual speed.
    Normal = 0,
    /// Move the lens more quickly.
    Fast = 1,
}

impl TryFrom<ControlValue> for AfSpeed {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Self::try_from(i32::try_from(value.clone())?).map_err(|_| ControlValueError::UnknownVariant(value))
    }
}

impl From<AfSpeed> for ControlValue {
    fn from(val: AfSpeed) -> Self {
        ControlValue::from(<i32>::from(val))
    }
}
impl ControlEntry for AfSpeed {
    const ID: u32 = ControlId::AfSpeed as _;
}

impl Control for AfSpeed {}

/// Instruct the AF algorithm how it should decide which parts of the image
/// should be used to measure focus.
#[derive(Debug, Clone, Copy, Eq, PartialEq, TryFromPrimitive, IntoPrimitive)]
#[repr(i32)]
pub enum AfMetering {
    /// The AF algorithm should decide for itself where it will measure focus.
    Auto = 0,
    /// The AF algorithm should use the rectangles defined by the AfWindows control to measure focus. If no windows are
    /// specified the behaviour is platform dependent.
    Windows = 1,
}

impl TryFrom<ControlValue> for AfMetering {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Self::try_from(i32::try_from(value.clone())?).map_err(|_| ControlValueError::UnknownVariant(value))
    }
}

impl From<AfMetering> for ControlValue {
    fn from(val: AfMetering) -> Self {
        ControlValue::from(<i32>::from(val))
    }
}
impl ControlEntry for AfMetering {
    const ID: u32 = ControlId::AfMetering as _;
}

impl Control for AfMetering {}

/// Sets the focus windows used by the AF algorithm when AfMetering is set
/// to AfMeteringWindows. The units used are pixels within the rectangle
/// returned by the ScalerCropMaximum property.
///
/// In order to be activated, a rectangle must be programmed with non-zero
/// width and height. Internally, these rectangles are intersected with the
/// ScalerCropMaximum rectangle. If the window becomes empty after this
/// operation, then the window is ignored. If all the windows end up being
/// ignored, then the behaviour is platform dependent.
///
/// On platforms that support the ScalerCrop control (for implementing
/// digital zoom, for example), no automatic recalculation or adjustment of
/// AF windows is performed internally if the ScalerCrop is changed. If any
/// window lies outside the output image after the scaler crop has been
/// applied, it is up to the application to recalculate them.
///
/// The details of how the windows are used are platform dependent. We note
/// that when there is more than one AF window, a typical implementation
/// might find the optimal focus position for each one and finally select
/// the window where the focal distance for the objects shown in that part
/// of the image are closest to the camera.
#[derive(Debug, Clone)]
pub struct AfWindows(pub Vec<Rectangle>);

impl Deref for AfWindows {
    type Target = Vec<Rectangle>;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for AfWindows {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl TryFrom<ControlValue> for AfWindows {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Ok(Self(<Vec<Rectangle>>::try_from(value)?))
    }
}

impl From<AfWindows> for ControlValue {
    fn from(val: AfWindows) -> Self {
        ControlValue::from(val.0)
    }
}

impl ControlEntry for AfWindows {
    const ID: u32 = ControlId::AfWindows as _;
}

impl Control for AfWindows {}

/// This control starts an autofocus scan when AfMode is set to AfModeAuto,
/// and can also be used to terminate a scan early.
///
/// It is ignored if AfMode is set to AfModeManual or AfModeContinuous.
#[derive(Debug, Clone, Copy, Eq, PartialEq, TryFromPrimitive, IntoPrimitive)]
#[repr(i32)]
pub enum AfTrigger {
    /// Start an AF scan. Ignored if a scan is in progress.
    Start = 0,
    /// Cancel an AF scan. This does not cause the lens to move anywhere else. Ignored if no scan is in progress.
    Cancel = 1,
}

impl TryFrom<ControlValue> for AfTrigger {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Self::try_from(i32::try_from(value.clone())?).map_err(|_| ControlValueError::UnknownVariant(value))
    }
}

impl From<AfTrigger> for ControlValue {
    fn from(val: AfTrigger) -> Self {
        ControlValue::from(<i32>::from(val))
    }
}
impl ControlEntry for AfTrigger {
    const ID: u32 = ControlId::AfTrigger as _;
}

impl Control for AfTrigger {}

/// This control has no effect except when in continuous autofocus mode
/// (AfModeContinuous). It can be used to pause any lens movements while
/// (for example) images are captured. The algorithm remains inactive
/// until it is instructed to resume.
#[derive(Debug, Clone, Copy, Eq, PartialEq, TryFromPrimitive, IntoPrimitive)]
#[repr(i32)]
pub enum AfPause {
    /// Pause the continuous autofocus algorithm immediately, whether or not
    /// any kind of scan is underway. AfPauseState will subsequently report
    /// AfPauseStatePaused. AfState may report any of AfStateScanning,
    /// AfStateFocused or AfStateFailed, depending on the algorithm's state
    /// when it received this control.
    Immediate = 0,
    /// This is similar to AfPauseImmediate, and if the AfState is currently
    /// reporting AfStateFocused or AfStateFailed it will remain in that
    /// state and AfPauseState will report AfPauseStatePaused.
    ///
    /// However, if the algorithm is scanning (AfStateScanning),
    /// AfPauseState will report AfPauseStatePausing until the scan is
    /// finished, at which point AfState will report one of AfStateFocused
    /// or AfStateFailed, and AfPauseState will change to
    /// AfPauseStatePaused.
    Deferred = 1,
    /// Resume continuous autofocus operation. The algorithm starts again
    /// from exactly where it left off, and AfPauseState will report
    /// AfPauseStateRunning.
    Resume = 2,
}

impl TryFrom<ControlValue> for AfPause {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Self::try_from(i32::try_from(value.clone())?).map_err(|_| ControlValueError::UnknownVariant(value))
    }
}

impl From<AfPause> for ControlValue {
    fn from(val: AfPause) -> Self {
        ControlValue::from(<i32>::from(val))
    }
}
impl ControlEntry for AfPause {
    const ID: u32 = ControlId::AfPause as _;
}

impl Control for AfPause {}

/// Acts as a control to instruct the lens to move to a particular position
/// and also reports back the position of the lens for each frame.
///
/// The LensPosition control is ignored unless the AfMode is set to
/// AfModeManual, though the value is reported back unconditionally in all
/// modes.
///
/// The units are a reciprocal distance scale like dioptres but normalised
/// for the hyperfocal distance. That is, for a lens with hyperfocal
/// distance H, and setting it to a focal distance D, the lens position LP,
/// which is generally a non-integer, is given by
///
/// \f$LP = \frac{H}{D}\f$
///
/// For example:
///
/// 0 moves the lens to infinity.
/// 0.5 moves the lens to twice the hyperfocal distance.
/// 1 moves the lens to the hyperfocal position.
/// And larger values will focus the lens ever closer.
///
/// \todo Define a property to report the Hyperforcal distance of calibrated
/// lenses.
///
/// \todo Define a property to report the maximum and minimum positions of
/// this lens. The minimum value will often be zero (meaning infinity).
#[derive(Debug, Clone)]
pub struct LensPosition(pub f32);

impl Deref for LensPosition {
    type Target = f32;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for LensPosition {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl TryFrom<ControlValue> for LensPosition {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Ok(Self(<f32>::try_from(value)?))
    }
}

impl From<LensPosition> for ControlValue {
    fn from(val: LensPosition) -> Self {
        ControlValue::from(val.0)
    }
}

impl ControlEntry for LensPosition {
    const ID: u32 = ControlId::LensPosition as _;
}

impl Control for LensPosition {}

/// Reports the current state of the AF algorithm in conjunction with the
/// reported AfMode value and (in continuous AF mode) the AfPauseState
/// value. The possible state changes are described below, though we note
/// the following state transitions that occur when the AfMode is changed.
///
/// If the AfMode is set to AfModeManual, then the AfState will always
/// report AfStateIdle (even if the lens is subsequently moved). Changing to
/// the AfModeManual state does not initiate any lens movement.
///
/// If the AfMode is set to AfModeAuto then the AfState will report
/// AfStateIdle. However, if AfModeAuto and AfTriggerStart are sent together
/// then AfState will omit AfStateIdle and move straight to AfStateScanning
/// (and start a scan).
///
/// If the AfMode is set to AfModeContinuous then the AfState will initially
/// report AfStateScanning.
#[derive(Debug, Clone, Copy, Eq, PartialEq, TryFromPrimitive, IntoPrimitive)]
#[repr(i32)]
pub enum AfState {
    /// The AF algorithm is in manual mode (AfModeManual) or in auto mode
    /// (AfModeAuto) and a scan has not yet been triggered, or an
    /// in-progress scan was cancelled.
    Idle = 0,
    /// The AF algorithm is in auto mode (AfModeAuto), and a scan has been
    /// started using the AfTrigger control. The scan can be cancelled by
    /// sending AfTriggerCancel at which point the algorithm will either
    /// move back to AfStateIdle or, if the scan actually completes before
    /// the cancel request is processed, to one of AfStateFocused or
    /// AfStateFailed.
    ///
    /// Alternatively the AF algorithm could be in continuous mode
    /// (AfModeContinuous) at which point it may enter this state
    /// spontaneously whenever it determines that a rescan is needed.
    Scanning = 1,
    /// The AF algorithm is in auto (AfModeAuto) or continuous
    /// (AfModeContinuous) mode and a scan has completed with the result
    /// that the algorithm believes the image is now in focus.
    Focused = 2,
    /// The AF algorithm is in auto (AfModeAuto) or continuous
    /// (AfModeContinuous) mode and a scan has completed with the result
    /// that the algorithm did not find a good focus position.
    Failed = 3,
}

impl TryFrom<ControlValue> for AfState {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Self::try_from(i32::try_from(value.clone())?).map_err(|_| ControlValueError::UnknownVariant(value))
    }
}

impl From<AfState> for ControlValue {
    fn from(val: AfState) -> Self {
        ControlValue::from(<i32>::from(val))
    }
}
impl ControlEntry for AfState {
    const ID: u32 = ControlId::AfState as _;
}

impl Control for AfState {}

/// Only applicable in continuous (AfModeContinuous) mode, this reports
/// whether the algorithm is currently running, paused or pausing (that is,
/// will pause as soon as any in-progress scan completes).
///
/// Any change to AfMode will cause AfPauseStateRunning to be reported.
#[derive(Debug, Clone, Copy, Eq, PartialEq, TryFromPrimitive, IntoPrimitive)]
#[repr(i32)]
pub enum AfPauseState {
    /// Continuous AF is running and the algorithm may restart a scan
    /// spontaneously.
    Running = 0,
    /// Continuous AF has been sent an AfPauseDeferred control, and will
    /// pause as soon as any in-progress scan completes (and then report
    /// AfPauseStatePaused). No new scans will be start spontaneously until
    /// the AfPauseResume control is sent.
    Pausing = 1,
    /// Continuous AF is paused. No further state changes or lens movements
    /// will occur until the AfPauseResume control is sent.
    Paused = 2,
}

impl TryFrom<ControlValue> for AfPauseState {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Self::try_from(i32::try_from(value.clone())?).map_err(|_| ControlValueError::UnknownVariant(value))
    }
}

impl From<AfPauseState> for ControlValue {
    fn from(val: AfPauseState) -> Self {
        ControlValue::from(<i32>::from(val))
    }
}
impl ControlEntry for AfPauseState {
    const ID: u32 = ControlId::AfPauseState as _;
}

impl Control for AfPauseState {}

/// Control for AE metering trigger. Currently identical to
/// ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER.
///
/// Whether the camera device will trigger a precapture metering sequence
/// when it processes this request.
#[derive(Debug, Clone, Copy, Eq, PartialEq, TryFromPrimitive, IntoPrimitive)]
#[repr(i32)]
pub enum AePrecaptureTrigger {
    /// The trigger is idle.
    Idle = 0,
    /// The pre-capture AE metering is started by the camera.
    Start = 1,
    /// The camera will cancel any active or completed metering sequence.
    /// The AE algorithm is reset to its initial state.
    Cancel = 2,
}

impl TryFrom<ControlValue> for AePrecaptureTrigger {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Self::try_from(i32::try_from(value.clone())?).map_err(|_| ControlValueError::UnknownVariant(value))
    }
}

impl From<AePrecaptureTrigger> for ControlValue {
    fn from(val: AePrecaptureTrigger) -> Self {
        ControlValue::from(<i32>::from(val))
    }
}
impl ControlEntry for AePrecaptureTrigger {
    const ID: u32 = ControlId::AePrecaptureTrigger as _;
}

impl Control for AePrecaptureTrigger {}

/// Control to select the noise reduction algorithm mode. Currently
/// identical to ANDROID_NOISE_REDUCTION_MODE.
///
///  Mode of operation for the noise reduction algorithm.
#[derive(Debug, Clone, Copy, Eq, PartialEq, TryFromPrimitive, IntoPrimitive)]
#[repr(i32)]
pub enum NoiseReductionMode {
    /// No noise reduction is applied
    Off = 0,
    /// Noise reduction is applied without reducing the frame rate.
    Fast = 1,
    /// High quality noise reduction at the expense of frame rate.
    HighQuality = 2,
    /// Minimal noise reduction is applied without reducing the frame rate.
    Minimal = 3,
    /// Noise reduction is applied at different levels to different streams.
    ZSL = 4,
}

impl TryFrom<ControlValue> for NoiseReductionMode {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Self::try_from(i32::try_from(value.clone())?).map_err(|_| ControlValueError::UnknownVariant(value))
    }
}

impl From<NoiseReductionMode> for ControlValue {
    fn from(val: NoiseReductionMode) -> Self {
        ControlValue::from(<i32>::from(val))
    }
}
impl ControlEntry for NoiseReductionMode {
    const ID: u32 = ControlId::NoiseReductionMode as _;
}

impl Control for NoiseReductionMode {}

/// Control to select the color correction aberration mode. Currently
/// identical to ANDROID_COLOR_CORRECTION_ABERRATION_MODE.
///
///  Mode of operation for the chromatic aberration correction algorithm.
#[derive(Debug, Clone, Copy, Eq, PartialEq, TryFromPrimitive, IntoPrimitive)]
#[repr(i32)]
pub enum ColorCorrectionAberrationMode {
    /// No aberration correction is applied.
    ColorCorrectionAberrationOff = 0,
    /// Aberration correction will not slow down the frame rate.
    ColorCorrectionAberrationFast = 1,
    /// High quality aberration correction which might reduce the frame
    /// rate.
    ColorCorrectionAberrationHighQuality = 2,
}

impl TryFrom<ControlValue> for ColorCorrectionAberrationMode {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Self::try_from(i32::try_from(value.clone())?).map_err(|_| ControlValueError::UnknownVariant(value))
    }
}

impl From<ColorCorrectionAberrationMode> for ControlValue {
    fn from(val: ColorCorrectionAberrationMode) -> Self {
        ControlValue::from(<i32>::from(val))
    }
}
impl ControlEntry for ColorCorrectionAberrationMode {
    const ID: u32 = ControlId::ColorCorrectionAberrationMode as _;
}

impl Control for ColorCorrectionAberrationMode {}

/// Control to report the current AE algorithm state. Currently identical to
/// ANDROID_CONTROL_AE_STATE.
///
///  Current state of the AE algorithm.
#[derive(Debug, Clone, Copy, Eq, PartialEq, TryFromPrimitive, IntoPrimitive)]
#[repr(i32)]
pub enum AeState {
    /// The AE algorithm is inactive.
    Inactive = 0,
    /// The AE algorithm has not converged yet.
    Searching = 1,
    /// The AE algorithm has converged.
    Converged = 2,
    /// The AE algorithm is locked.
    Locked = 3,
    /// The AE algorithm would need a flash for good results
    FlashRequired = 4,
    /// The AE algorithm has started a pre-capture metering session.
    /// \sa AePrecaptureTrigger
    Precapture = 5,
}

impl TryFrom<ControlValue> for AeState {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Self::try_from(i32::try_from(value.clone())?).map_err(|_| ControlValueError::UnknownVariant(value))
    }
}

impl From<AeState> for ControlValue {
    fn from(val: AeState) -> Self {
        ControlValue::from(<i32>::from(val))
    }
}
impl ControlEntry for AeState {
    const ID: u32 = ControlId::AeState as _;
}

impl Control for AeState {}

/// Control to report the current AWB algorithm state. Currently identical
/// to ANDROID_CONTROL_AWB_STATE.
///
///  Current state of the AWB algorithm.
#[derive(Debug, Clone, Copy, Eq, PartialEq, TryFromPrimitive, IntoPrimitive)]
#[repr(i32)]
pub enum AwbState {
    /// The AWB algorithm is inactive.
    Inactive = 0,
    /// The AWB algorithm has not converged yet.
    Searching = 1,
    /// The AWB algorithm has converged.
    AwbConverged = 2,
    /// The AWB algorithm is locked.
    AwbLocked = 3,
}

impl TryFrom<ControlValue> for AwbState {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Self::try_from(i32::try_from(value.clone())?).map_err(|_| ControlValueError::UnknownVariant(value))
    }
}

impl From<AwbState> for ControlValue {
    fn from(val: AwbState) -> Self {
        ControlValue::from(<i32>::from(val))
    }
}
impl ControlEntry for AwbState {
    const ID: u32 = ControlId::AwbState as _;
}

impl Control for AwbState {}

/// Control to report the time between the start of exposure of the first
/// row and the start of exposure of the last row. Currently identical to
/// ANDROID_SENSOR_ROLLING_SHUTTER_SKEW
#[derive(Debug, Clone)]
pub struct SensorRollingShutterSkew(pub i64);

impl Deref for SensorRollingShutterSkew {
    type Target = i64;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for SensorRollingShutterSkew {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl TryFrom<ControlValue> for SensorRollingShutterSkew {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Ok(Self(<i64>::try_from(value)?))
    }
}

impl From<SensorRollingShutterSkew> for ControlValue {
    fn from(val: SensorRollingShutterSkew) -> Self {
        ControlValue::from(val.0)
    }
}

impl ControlEntry for SensorRollingShutterSkew {
    const ID: u32 = ControlId::SensorRollingShutterSkew as _;
}

impl Control for SensorRollingShutterSkew {}

/// Control to report if the lens shading map is available. Currently
/// identical to ANDROID_STATISTICS_LENS_SHADING_MAP_MODE.
#[derive(Debug, Clone, Copy, Eq, PartialEq, TryFromPrimitive, IntoPrimitive)]
#[repr(i32)]
pub enum LensShadingMapMode {
    /// No lens shading map mode is available.
    Off = 0,
    /// The lens shading map mode is available.
    On = 1,
}

impl TryFrom<ControlValue> for LensShadingMapMode {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Self::try_from(i32::try_from(value.clone())?).map_err(|_| ControlValueError::UnknownVariant(value))
    }
}

impl From<LensShadingMapMode> for ControlValue {
    fn from(val: LensShadingMapMode) -> Self {
        ControlValue::from(<i32>::from(val))
    }
}
impl ControlEntry for LensShadingMapMode {
    const ID: u32 = ControlId::LensShadingMapMode as _;
}

impl Control for LensShadingMapMode {}

/// Control to report the detected scene light frequency. Currently
/// identical to ANDROID_STATISTICS_SCENE_FLICKER.
#[derive(Debug, Clone, Copy, Eq, PartialEq, TryFromPrimitive, IntoPrimitive)]
#[repr(i32)]
pub enum SceneFlicker {
    /// No flickering detected.
    SceneFickerOff = 0,
    /// 50Hz flickering detected.
    SceneFicker50Hz = 1,
    /// 60Hz flickering detected.
    SceneFicker60Hz = 2,
}

impl TryFrom<ControlValue> for SceneFlicker {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Self::try_from(i32::try_from(value.clone())?).map_err(|_| ControlValueError::UnknownVariant(value))
    }
}

impl From<SceneFlicker> for ControlValue {
    fn from(val: SceneFlicker) -> Self {
        ControlValue::from(<i32>::from(val))
    }
}
impl ControlEntry for SceneFlicker {
    const ID: u32 = ControlId::SceneFlicker as _;
}

impl Control for SceneFlicker {}

/// Specifies the number of pipeline stages the frame went through from when
/// it was exposed to when the final completed result was available to the
/// framework. Always less than or equal to PipelineMaxDepth. Currently
/// identical to ANDROID_REQUEST_PIPELINE_DEPTH.
///
/// The typical value for this control is 3 as a frame is first exposed,
/// captured and then processed in a single pass through the ISP. Any
/// additional processing step performed after the ISP pass (in example face
/// detection, additional format conversions etc) count as an additional
/// pipeline stage.
#[derive(Debug, Clone)]
pub struct PipelineDepth(pub i32);

impl Deref for PipelineDepth {
    type Target = i32;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for PipelineDepth {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl TryFrom<ControlValue> for PipelineDepth {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Ok(Self(<i32>::try_from(value)?))
    }
}

impl From<PipelineDepth> for ControlValue {
    fn from(val: PipelineDepth) -> Self {
        ControlValue::from(val.0)
    }
}

impl ControlEntry for PipelineDepth {
    const ID: u32 = ControlId::PipelineDepth as _;
}

impl Control for PipelineDepth {}

/// The maximum number of frames that can occur after a request (different
/// than the previous) has been submitted, and before the result's state
/// becomes synchronized. A value of -1 indicates unknown latency, and 0
/// indicates per-frame control. Currently identical to
/// ANDROID_SYNC_MAX_LATENCY.
#[derive(Debug, Clone)]
pub struct MaxLatency(pub i32);

impl Deref for MaxLatency {
    type Target = i32;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for MaxLatency {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl TryFrom<ControlValue> for MaxLatency {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Ok(Self(<i32>::try_from(value)?))
    }
}

impl From<MaxLatency> for ControlValue {
    fn from(val: MaxLatency) -> Self {
        ControlValue::from(val.0)
    }
}

impl ControlEntry for MaxLatency {
    const ID: u32 = ControlId::MaxLatency as _;
}

impl Control for MaxLatency {}

/// Control to select the test pattern mode. Currently identical to
/// ANDROID_SENSOR_TEST_PATTERN_MODE.
#[derive(Debug, Clone, Copy, Eq, PartialEq, TryFromPrimitive, IntoPrimitive)]
#[repr(i32)]
pub enum TestPatternMode {
    /// No test pattern mode is used. The camera device returns frames from
    /// the image sensor.
    Off = 0,
    /// Each pixel in [R, G_even, G_odd, B] is replaced by its respective
    /// color channel provided in test pattern data.
    /// \todo Add control for test pattern data.
    SolidColor = 1,
    /// All pixel data is replaced with an 8-bar color pattern. The vertical
    /// bars (left-to-right) are as follows; white, yellow, cyan, green,
    /// magenta, red, blue and black. Each bar should take up 1/8 of the
    /// sensor pixel array width. When this is not possible, the bar size
    /// should be rounded down to the nearest integer and the pattern can
    /// repeat on the right side. Each bar's height must always take up the
    /// full sensor pixel array height.
    ColorBars = 2,
    /// The test pattern is similar to TestPatternModeColorBars,
    /// except that each bar should start at its specified color at the top
    /// and fade to gray at the bottom. Furthermore each bar is further
    /// subdevided into a left and right half. The left half should have a
    /// smooth gradient, and the right half should have a quantized
    /// gradient. In particular, the right half's should consist of blocks
    /// of the same color for 1/16th active sensor pixel array width. The
    /// least significant bits in the quantized gradient should be copied
    /// from the most significant bits of the smooth gradient. The height of
    /// each bar should always be a multiple of 128. When this is not the
    /// case, the pattern should repeat at the bottom of the image.
    ColorBarsFadeToGray = 3,
    /// All pixel data is replaced by a pseudo-random sequence generated
    /// from a PN9 512-bit sequence (typically implemented in hardware with
    /// a linear feedback shift register). The generator should be reset at
    /// the beginning of each frame, and thus each subsequent raw frame with
    /// this test pattern should be exactly the same as the last.
    Pn9 = 4,
    /// The first custom test pattern. All custom patterns that are
    /// available only on this camera device are at least this numeric
    /// value. All of the custom test patterns will be static (that is the
    /// raw image must not vary from frame to frame).
    Custom1 = 256,
}

impl TryFrom<ControlValue> for TestPatternMode {
    type Error = ControlValueError;

    fn try_from(value: ControlValue) -> Result<Self, Self::Error> {
        Self::try_from(i32::try_from(value.clone())?).map_err(|_| ControlValueError::UnknownVariant(value))
    }
}

impl From<TestPatternMode> for ControlValue {
    fn from(val: TestPatternMode) -> Self {
        ControlValue::from(<i32>::from(val))
    }
}
impl ControlEntry for TestPatternMode {
    const ID: u32 = ControlId::TestPatternMode as _;
}

impl Control for TestPatternMode {}

pub fn make_dyn(id: ControlId, val: ControlValue) -> Result<Box<dyn DynControlEntry>, ControlValueError> {
    match id {
        ControlId::AeEnable => Ok(Box::new(AeEnable::try_from(val)?)),
        ControlId::AeLocked => Ok(Box::new(AeLocked::try_from(val)?)),
        ControlId::AeMeteringMode => Ok(Box::new(AeMeteringMode::try_from(val)?)),
        ControlId::AeConstraintMode => Ok(Box::new(AeConstraintMode::try_from(val)?)),
        ControlId::AeExposureMode => Ok(Box::new(AeExposureMode::try_from(val)?)),
        ControlId::ExposureValue => Ok(Box::new(ExposureValue::try_from(val)?)),
        ControlId::ExposureTime => Ok(Box::new(ExposureTime::try_from(val)?)),
        ControlId::AnalogueGain => Ok(Box::new(AnalogueGain::try_from(val)?)),
        ControlId::Brightness => Ok(Box::new(Brightness::try_from(val)?)),
        ControlId::Contrast => Ok(Box::new(Contrast::try_from(val)?)),
        ControlId::Lux => Ok(Box::new(Lux::try_from(val)?)),
        ControlId::AwbEnable => Ok(Box::new(AwbEnable::try_from(val)?)),
        ControlId::AwbMode => Ok(Box::new(AwbMode::try_from(val)?)),
        ControlId::AwbLocked => Ok(Box::new(AwbLocked::try_from(val)?)),
        ControlId::ColourGains => Ok(Box::new(ColourGains::try_from(val)?)),
        ControlId::ColourTemperature => Ok(Box::new(ColourTemperature::try_from(val)?)),
        ControlId::Saturation => Ok(Box::new(Saturation::try_from(val)?)),
        ControlId::SensorBlackLevels => Ok(Box::new(SensorBlackLevels::try_from(val)?)),
        ControlId::Sharpness => Ok(Box::new(Sharpness::try_from(val)?)),
        ControlId::FocusFoM => Ok(Box::new(FocusFoM::try_from(val)?)),
        ControlId::ColourCorrectionMatrix => Ok(Box::new(ColourCorrectionMatrix::try_from(val)?)),
        ControlId::ScalerCrop => Ok(Box::new(ScalerCrop::try_from(val)?)),
        ControlId::DigitalGain => Ok(Box::new(DigitalGain::try_from(val)?)),
        ControlId::FrameDuration => Ok(Box::new(FrameDuration::try_from(val)?)),
        ControlId::FrameDurationLimits => Ok(Box::new(FrameDurationLimits::try_from(val)?)),
        ControlId::SensorTemperature => Ok(Box::new(SensorTemperature::try_from(val)?)),
        ControlId::SensorTimestamp => Ok(Box::new(SensorTimestamp::try_from(val)?)),
        ControlId::AfMode => Ok(Box::new(AfMode::try_from(val)?)),
        ControlId::AfRange => Ok(Box::new(AfRange::try_from(val)?)),
        ControlId::AfSpeed => Ok(Box::new(AfSpeed::try_from(val)?)),
        ControlId::AfMetering => Ok(Box::new(AfMetering::try_from(val)?)),
        ControlId::AfWindows => Ok(Box::new(AfWindows::try_from(val)?)),
        ControlId::AfTrigger => Ok(Box::new(AfTrigger::try_from(val)?)),
        ControlId::AfPause => Ok(Box::new(AfPause::try_from(val)?)),
        ControlId::LensPosition => Ok(Box::new(LensPosition::try_from(val)?)),
        ControlId::AfState => Ok(Box::new(AfState::try_from(val)?)),
        ControlId::AfPauseState => Ok(Box::new(AfPauseState::try_from(val)?)),
        ControlId::AePrecaptureTrigger => Ok(Box::new(AePrecaptureTrigger::try_from(val)?)),
        ControlId::NoiseReductionMode => Ok(Box::new(NoiseReductionMode::try_from(val)?)),
        ControlId::ColorCorrectionAberrationMode => Ok(Box::new(ColorCorrectionAberrationMode::try_from(val)?)),
        ControlId::AeState => Ok(Box::new(AeState::try_from(val)?)),
        ControlId::AwbState => Ok(Box::new(AwbState::try_from(val)?)),
        ControlId::SensorRollingShutterSkew => Ok(Box::new(SensorRollingShutterSkew::try_from(val)?)),
        ControlId::LensShadingMapMode => Ok(Box::new(LensShadingMapMode::try_from(val)?)),
        ControlId::SceneFlicker => Ok(Box::new(SceneFlicker::try_from(val)?)),
        ControlId::PipelineDepth => Ok(Box::new(PipelineDepth::try_from(val)?)),
        ControlId::MaxLatency => Ok(Box::new(MaxLatency::try_from(val)?)),
        ControlId::TestPatternMode => Ok(Box::new(TestPatternMode::try_from(val)?)),
    }
}