libdisplay-info 0.3.0

EDID and DisplayID library.
Documentation
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
//! Low-level API for Consumer Technology Association standards.
//!
//! The library implements CTA-861-H, available at:
//! <https://shop.cta.tech/collections/standards/products/a-dtv-profile-for-uncompressed-high-speed-digital-interfaces-cta-861-h>
use std::marker::PhantomData;

use libdisplay_info_derive::FFIFrom;

use crate::{edid::ExtensionRef, ffi, FFIIter};

/// EDID CTA-861 extension block.
#[derive(Debug)]
pub struct CTA<'ext> {
    cta: *const ffi::cta::di_edid_cta,
    phantom: PhantomData<&'ext ()>,
}

impl<'ext> CTA<'ext> {
    /// Get a CTA-861 extension block.
    ///
    /// Returns `None` if the extension block tag is not [CEA](crate::edid::ExtensionTag::CEA).
    pub fn from_extension(extensions: &'ext ExtensionRef) -> Option<CTA<'ext>> {
        let cta = unsafe { ffi::edid::di_edid_ext_get_cta(extensions.as_ptr()) };

        if cta.is_null() {
            None
        } else {
            Some(Self {
                cta: cta as *const ffi::cta::di_edid_cta,
                phantom: PhantomData,
            })
        }
    }

    /// Get the CTA extension revision (also referred to as `version`` by the
    /// specification).
    pub fn revision(&self) -> i32 {
        unsafe { ffi::cta::di_edid_cta_get_revision(self.cta) }
    }

    /// Get miscellaneous CTA flags.
    pub fn flags(&self) -> Flags {
        let flags = unsafe { ffi::cta::di_edid_cta_get_flags(self.cta) };
        Flags::from(unsafe { *flags })
    }

    /// Get CTA data blocks.
    pub fn data_blocks(&self) -> &[DataBlockRef] {
        let data_blocks = unsafe { ffi::cta::di_edid_cta_get_data_blocks(self.cta) };

        let mut len = 0;
        while !unsafe { *data_blocks.offset(len) }.is_null() {
            len += 1;
        }

        unsafe { std::slice::from_raw_parts(data_blocks as *const DataBlockRef, len as usize) }
    }

    /// Get a list of EDID detailed timing definitions.
    pub fn detailed_timing_defs(&self) -> impl Iterator<Item = crate::edid::DetailedTimingDef> {
        FFIIter::new(unsafe {
            ffi::cta::di_edid_cta_get_detailed_timing_defs(self.cta)
                as *const *const ffi::edid::di_edid_detailed_timing_def
        })
    }
}

/// CTA video format picture aspect ratio.
#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_video_format_picture_aspect_ratio)]
#[repr(u32)]
pub enum VideoFormatPictureAspectRatio {
    _4_3 = ffi::cta::di_cta_video_format_picture_aspect_ratio_DI_CTA_VIDEO_FORMAT_PICTURE_ASPECT_RATIO_4_3,
    _16_9 = ffi::cta::di_cta_video_format_picture_aspect_ratio_DI_CTA_VIDEO_FORMAT_PICTURE_ASPECT_RATIO_16_9,
    _64_27 = ffi::cta::di_cta_video_format_picture_aspect_ratio_DI_CTA_VIDEO_FORMAT_PICTURE_ASPECT_RATIO_64_27,
    _256_135 = ffi::cta::di_cta_video_format_picture_aspect_ratio_DI_CTA_VIDEO_FORMAT_PICTURE_ASPECT_RATIO_256_135,
}

/// CTA video format sync pulse polarity.
#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_video_format_sync_polarity)]
#[repr(u32)]
pub enum VideoFormatSyncPolarity {
    Negative = ffi::cta::di_cta_video_format_sync_polarity_DI_CTA_VIDEO_FORMAT_SYNC_NEGATIVE,
    Positive = ffi::cta::di_cta_video_format_sync_polarity_DI_CTA_VIDEO_FORMAT_SYNC_POSITIVE,
}

/// A CTA-861 video format, defined in section 4.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_video_format)]
pub struct VideoFormat {
    pub vic: u8,
    pub h_active: i32,
    pub v_active: i32,
    pub h_front: i32,
    pub v_front: i32,
    pub h_sync: i32,
    pub v_sync: i32,
    pub h_back: i32,
    pub v_back: i32,
    pub h_sync_polarity: VideoFormatSyncPolarity,
    pub v_sync_polarity: VideoFormatSyncPolarity,
    pub pixel_clock_hz: i64,
    pub interlaced: bool,
    pub picture_aspect_ratio: VideoFormatPictureAspectRatio,
}

impl VideoFormat {
    /// Get a CTA-861 video format from a VIC.
    ///
    /// Returns `None` if the VIC is unknown.
    pub fn from_vic(vic: u8) -> Option<VideoFormat> {
        let video_format = unsafe { ffi::cta::di_cta_video_format_from_vic(vic) };

        if video_format.is_null() {
            None
        } else {
            Some(VideoFormat::from(unsafe { *video_format }))
        }
    }
}

/// Miscellaneous EDID CTA flags, defined in section 7.3.3.
///
/// For CTA revision 1, all of the fields are zero.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_edid_cta_flags)]
pub struct Flags {
    pub it_underscan: bool,
    pub basic_audio: bool,
    pub ycc444: bool,
    pub ycc422: bool,
    pub native_dtds: i32,
}

#[cfg_attr(docsrs, cfg(feature = "v0_2"))]
#[cfg_attr(not(docsrs), cfg(all(feature = "v0_2", not(feature = "v0_3"))))]
#[cfg_attr(
    feature = "v0_3",
    deprecated(since = "0.3.0", note = "use `VIITimingBlock` instead")
)]
pub type TypeIIIVIITiming = crate::displayid::TypeIIIVIITiming;

/// CTA data block, defined in section 7.4.
#[repr(transparent)]
pub struct DataBlockRef(*const ffi::cta::di_cta_data_block);

impl DataBlockRef {
    /// Get the tag of the CTA data block.
    pub fn tag(&self) -> DataBlockTag {
        DataBlockTag::from(unsafe { ffi::cta::di_cta_data_block_get_tag(self.0) })
    }

    /// Get an array of short audio descriptors from a CTA data block.
    ///
    /// Returns `None` if the data block tag is not DI_CTA_DATA_BLOCK_AUDIO.
    #[cfg_attr(
        feature = "v0_3",
        deprecated(since = "0.3.0", note = "use `DataBlockRef::audio()` instead")
    )]
    pub fn sads(&self) -> impl Iterator<Item = Sad> {
        FFIIter::new(unsafe { ffi::cta::di_cta_data_block_get_sads(self.0) })
    }

    /// Get the audio from a CTA data block.
    ///
    /// Returns `None` if the data block tag is not DI_CTA_DATA_BLOCK_AUDIO.
    #[cfg(feature = "v0_3")]
    pub fn audio(&self) -> Option<AudioBlockRef> {
        AudioBlockRef::from_ptr(unsafe { ffi::cta::di_cta_data_block_get_audio(self.0) })
    }

    /// Get the speaker allocation from a CTA data block.
    ///
    /// Returns `None` if the data block tag is not DI_CTA_DATA_BLOCK_SPEAKER_ALLOC.
    pub fn speaker_alloc(&self) -> Option<SpeakerAllocBlock> {
        SpeakerAllocBlock::from_ptr(unsafe {
            ffi::cta::di_cta_data_block_get_speaker_alloc(self.0)
        })
    }

    /// Get the video capabilities from a CTA data block.
    ///
    /// Returns `None` if the data block tag is not DI_CTA_DATA_BLOCK_VIDEO_CAP.
    pub fn video_cap(&self) -> Option<VideoCapBlock> {
        VideoCapBlock::from_ptr(unsafe { ffi::cta::di_cta_data_block_get_video_cap(self.0) })
    }

    /// Get the VESA Display Device Data Block (DDDB) from a CTA data block.
    ///
    /// Returns `None` if the data block tag is not
    /// DI_CTA_DATA_BLOCK_VESA_DISPLAY_DEVICE.
    #[cfg_attr(
        feature = "v0_3",
        deprecated(
            since = "0.3.0",
            note = "use `DataBlockRef::vesa_display_device()` instead"
        )
    )]
    #[cfg_attr(not(docsrs), cfg(not(feature = "v0_3")))]
    pub fn vesa_dddb(&self) -> Option<VesaDddb> {
        VesaDddb::from_ptr(unsafe { ffi::cta::di_cta_data_block_get_vesa_dddb(self.0) })
    }

    /// Get the VESA Display Device Data Block (DDDB) from a CTA data block.
    ///
    /// Returns `None` if the data block tag is not DI_CTA_DATA_BLOCK_VESA_DISPLAY_DEVICE.
    #[cfg(feature = "v0_3")]
    pub fn vesa_display_device(&self) -> Option<VesaDisplayDeviceBlock> {
        VesaDisplayDeviceBlock::from_ptr(unsafe {
            ffi::cta::di_cta_data_block_get_vesa_display_device(self.0)
        })
    }

    /// Get the colorimetry data from a CTA data block.
    ///
    /// Returns `None` if the data block tag is not DI_CTA_DATA_BLOCK_COLORIMETRY.
    pub fn colorimetry(&self) -> Option<ColorimetryBlock> {
        ColorimetryBlock::from_ptr(unsafe { ffi::cta::di_cta_data_block_get_colorimetry(self.0) })
    }

    /// Get the HDR static metadata from a CTA data block.
    ///
    /// Returns `None` if the data block tag is not DI_CTA_DATA_BLOCK_HDR_STATIC_METADATA.
    pub fn hdr_static_metadata(&self) -> Option<HdrStaticMetadataBlock> {
        HdrStaticMetadataBlock::from_ptr(unsafe {
            ffi::cta::di_cta_data_block_get_hdr_static_metadata(self.0)
        })
    }

    /// Get the HDR dynamic metadata from a CTA data block.
    ///
    /// Returns `None` if the data block tag is not DI_CTA_DATA_BLOCK_HDR_DYNAMIC_METADATA.
    pub fn hdr_dynamic_metadata(&self) -> Option<HdrDynamicMetadataBlock> {
        HdrDynamicMetadataBlock::from_ptr(unsafe {
            ffi::cta::di_cta_data_block_get_hdr_dynamic_metadata(self.0)
        })
    }

    /// Get an array of short video descriptors from a CTA data block.
    ///
    /// Returns `None` if the data block tag is not DI_CTA_DATA_BLOCK_VIDEO.
    #[cfg_attr(
        feature = "v0_3",
        deprecated(since = "0.3.0", note = "use `DataBlockRef::video()` instead")
    )]
    pub fn svds(&self) -> impl Iterator<Item = Svd> {
        FFIIter::new(unsafe { ffi::cta::di_cta_data_block_get_svds(self.0) })
    }

    /// Get the video from a CTA data block.
    ///
    /// Returns `None` if the data block tag is not DI_CTA_DATA_BLOCK_VIDEO.
    #[cfg(feature = "v0_3")]
    pub fn video(&self) -> Option<VideoBlockRef> {
        VideoBlockRef::from_ptr(unsafe { ffi::cta::di_cta_data_block_get_video(self.0) })
    }

    /// Get an array of short video descriptors which only allow YCbCr 4:2:0 sampling
    /// mode from a CTA data block.
    ///
    /// Returns `None` if the data block tag is not DI_CTA_DATA_BLOCK_YCBCR420.
    #[cfg_attr(
        feature = "v0_3",
        deprecated(since = "0.3.0", note = "use `DataBlockRef::ycbcr420_video()` instead")
    )]
    pub fn ycbcr420_svds(&self) -> impl Iterator<Item = Svd> {
        FFIIter::new(unsafe { ffi::cta::di_cta_data_block_get_ycbcr420_svds(self.0) })
    }

    /// Get the YCbCr video from a CTA data block.
    ///
    /// Returns `None` if the data block tag is not DI_CTA_DATA_BLOCK_YCBCR420.
    #[cfg(feature = "v0_3")]
    pub fn ycbcr420_video(&self) -> Option<Ycbcr420VideoBlockRef> {
        Ycbcr420VideoBlockRef::from_ptr(unsafe {
            ffi::cta::di_cta_data_block_get_ycbcr420_video(self.0)
        })
    }

    /// Get the Display Transfer Characteristic from a CTA data block.
    ///
    /// Returns `None` if the data block tag is not
    /// DI_CTA_DATA_BLOCK_VESA_DISPLAY_TRANSFER_CHARACTERISTIC.
    ///
    /// Upstream is not aware of any EDID blob containing a Display Transfer
    /// Characteristic data block.
    /// If such a blob is found, please share it with upstream!
    #[cfg_attr(not(docsrs), cfg(not(feature = "v0_3")))]
    pub fn vesa_transfer_characteristics(&self) -> Option<VesaTransferCharacteristics> {
        VesaTransferCharacteristics::from_ptr(unsafe {
            ffi::cta::di_cta_data_block_get_vesa_transfer_characteristics(self.0)
        })
    }

    /// Get the Display Transfer Characteristic from a CTA data block.
    ///
    /// Returns `None` if the data block tag is not
    /// DI_CTA_DATA_BLOCK_VESA_DISPLAY_TRANSFER_CHARACTERISTIC.
    ///
    /// Upstream is not aware of any EDID blob containing a Display Transfer
    /// Characteristic data block.
    /// If such a blob is found, please share it with upstream!
    #[cfg_attr(not(docsrs), cfg(feature = "v0_3"))]
    #[cfg_attr(docsrs, cfg(not(feature = "v0_2")))]
    pub fn vesa_transfer_characteristics(&self) -> Option<VesaTransferCharacteristicsBlock> {
        VesaTransferCharacteristicsBlock::from_ptr(unsafe {
            ffi::cta::di_cta_data_block_get_vesa_transfer_characteristics(self.0)
        })
    }

    /// Get the YCbCr 4:2:0 Capability Map from a CTA data block.
    ///
    /// Returns `None` if the data block tag is not DI_CTA_DATA_BLOCK_YCBCR420_CAP_MAP.
    #[cfg_attr(not(docsrs), cfg(not(feature = "v0_3")))]
    pub fn ycbcr420_cap_map(&self) -> Option<Ycbcr420CapMapRef> {
        Ycbcr420CapMapRef::from_ptr(unsafe {
            ffi::cta::di_cta_data_block_get_ycbcr420_cap_map(self.0)
        })
    }

    /// Get the YCbCr 4:2:0 Capability Map from a CTA data block.
    ///
    /// Returns `None` if the data block tag is not DI_CTA_DATA_BLOCK_YCBCR420_CAP_MAP.
    #[cfg_attr(not(docsrs), cfg(feature = "v0_3"))]
    #[cfg_attr(docsrs, cfg(not(feature = "v0_2")))]
    pub fn ycbcr420_cap_map(&self) -> Option<Ycbcr420CapMapBlockRef> {
        Ycbcr420CapMapBlockRef::from_ptr(unsafe {
            ffi::cta::di_cta_data_block_get_ycbcr420_cap_map(self.0)
        })
    }

    /// Get the InfoFrame information from a CTA data block.
    ///
    /// Returns `None` if the data block tag is not DI_CTA_DATA_BLOCK_INFOFRAME.
    pub fn infoframe(&self) -> Option<InfoframeBlockRef> {
        InfoframeBlockRef::from_ptr(unsafe { ffi::cta::di_cta_data_block_get_infoframe(self.0) })
    }

    /// Get the HDMI Audio information from a CTA data block.
    ///
    /// Returns `None` if the data block tag is not DI_CTA_DATA_BLOCK_HDMI_AUDIO.
    #[cfg(any(feature = "v0_2", feature = "v0_3"))]
    pub fn hdmi_audio(&self) -> Option<HdmiAudioBlockRef> {
        HdmiAudioBlockRef::from_ptr(unsafe { ffi::cta::di_cta_data_block_get_hdmi_audio(self.0) })
    }

    /// Get the Room Configuration from a CTA data block.
    ///
    /// Returns `None` if the data block tag is not DI_CTA_DATA_BLOCK_ROOM_CONFIG.
    #[cfg_attr(not(docsrs), cfg(all(feature = "v0_2", not(feature = "v0_3"))))]
    #[cfg_attr(docsrs, cfg(any(feature = "v0_2", feature = "v0_3")))]
    pub fn room_configuration(&self) -> Option<RoomConfiguration> {
        RoomConfiguration::from_ptr(unsafe {
            ffi::cta::di_cta_data_block_get_room_configuration(self.0)
        })
    }

    /// Get the Room Configuration from a CTA data block.
    ///
    /// Returns `None` if the data block tag is not DI_CTA_DATA_BLOCK_ROOM_CONFIG.
    #[cfg_attr(not(docsrs), cfg(feature = "v0_3"))]
    #[cfg_attr(docsrs, cfg(not(feature = "v0_2")))]
    pub fn room_configuration(&self) -> Option<RoomConfigurationBlock> {
        RoomConfigurationBlock::from_ptr(unsafe {
            ffi::cta::di_cta_data_block_get_room_configuration(self.0)
        })
    }

    /// Get an array of Speaker Locations.
    ///
    /// Returns `None` if the data block tag is not DI_CTA_DATA_BLOCK_SPEAKER_LOCATION.
    #[cfg_attr(not(docsrs), cfg(all(feature = "v0_2", not(feature = "v0_3"))))]
    #[cfg_attr(docsrs, cfg(any(feature = "v0_2", feature = "v0_3")))]
    pub fn speaker_locations(&self) -> impl Iterator<Item = SpeakerLocations> {
        // SAFETY: This is somewhat unfortunate, both v0.2 and v0.3 have this function,
        // but v0.3 changed the return type.
        // For now the polyfills in the -sys crate use a type alias to point to the new
        // ffi type, which from C ABI point is safe to cast. Iteration should also be
        // fine like this.
        FFIIter::new(unsafe {
            ffi::cta::di_cta_data_block_get_speaker_locations(self.0)
                as *const *const ffi::cta::di_cta_speaker_locations
        })
    }

    /// Get the Speaker Locations from a CTA data block.
    ///
    /// Returns `None` if the data block tag is not DI_CTA_DATA_BLOCK_SPEAKER_LOCATION.
    #[cfg_attr(not(docsrs), cfg(feature = "v0_3"))]
    #[cfg_attr(docsrs, cfg(not(feature = "v0_2")))]
    pub fn speaker_locations(&self) -> Option<SpeakerLocationBlockRef> {
        SpeakerLocationBlockRef::from_ptr(unsafe {
            ffi::cta::di_cta_data_block_get_speaker_locations(self.0)
        })
    }

    /// Get the DisplayID Type VII Video Timing from a CTA data block.
    ///
    /// Returns `None` if the data block tag is not
    /// DI_CTA_DATA_BLOCK_DISPLAYID_VIDEO_TIMING_VII.
    #[cfg_attr(docsrs, cfg(any(feature = "v0_2", feature = "v0_3")))]
    #[cfg_attr(not(docsrs), cfg(all(feature = "v0_2", not(feature = "v0_3"))))]
    pub fn did_type_vii_timing(&self) -> Option<TypeIIIVIITiming> {
        TypeIIIVIITiming::from_ptr(unsafe {
            ffi::cta::di_cta_data_block_get_did_type_vii_timing(self.0)
                as *const ffi::displayid::di_displayid_type_i_ii_vii_timing
        })
    }

    /// Get the DisplayID Type VII Video Timing from a CTA data block.
    ///
    /// Returns `None` if the data block tag is not
    /// DI_CTA_DATA_BLOCK_DISPLAYID_VIDEO_TIMING_VII.
    #[cfg_attr(not(docsrs), cfg(feature = "v0_3"))]
    #[cfg_attr(docsrs, cfg(not(feature = "v0_2")))]
    pub fn did_type_vii_timing(&self) -> Option<VIITimingBlock> {
        VIITimingBlock::from_ptr(unsafe {
            ffi::cta::di_cta_data_block_get_did_type_vii_timing(self.0)
                as *const ffi::cta::di_cta_type_vii_timing_block
        })
    }

    /// Get an array of Short Video References (SVRs) from a CTA data block. The
    /// first SVR refers to the most-preferred Video Format, while the next SVRs
    /// are listed in order of decreasing preference.
    ///
    /// Returns `None` if the data block tag is not
    /// DI_CTA_DATA_BLOCK_VIDEO_FORMAT_PREF.
    #[cfg(any(feature = "v0_2", feature = "v0_3"))]
    #[cfg_attr(
        feature = "v0_3",
        deprecated(
            since = "0.3.0",
            note = "use `DataBlockRef::video_format_pref()` instead"
        )
    )]
    pub fn svrs(&self) -> impl Iterator<Item = Svr> {
        FFIIter::new(unsafe { ffi::cta::di_cta_data_block_get_svrs(self.0) })
    }

    /// Get the Video Format Preference information from a CTA data block.
    ///
    /// Returns `None` if the data block tag is not
    /// DI_CTA_DATA_BLOCK_VIDEO_FORMAT_PREF.
    #[cfg(feature = "v0_3")]
    pub fn video_format_pref(&self) -> Option<VideoFormatPrefBlockRef> {
        VideoFormatPrefBlockRef::from_ptr(unsafe {
            ffi::cta::di_cta_data_block_get_video_format_pref(self.0)
        })
    }

    /// Get the HDR10+ information from a CTA data block.
    ///
    /// Returns `None` if the data block tag is not DI_CTA_DATA_BLOCK_HDR10PLUS.
    #[cfg(feature = "v0_3")]
    pub fn hdr10plus(&self) -> Option<HDR10PlusBlock> {
        HDR10PlusBlock::from_ptr(unsafe { ffi::cta::di_cta_data_block_get_hdr10plus(self.0) })
    }

    /// Get the Dolby Vision information from a CTA data block.
    ///
    /// Returns `None` if the data block tag is not DI_CTA_DATA_BLOCK_DOLBY_VIDEO.
    #[cfg(feature = "v0_3")]
    pub fn dolby_video(&self) -> Option<DolbyVideoBlock> {
        DolbyVideoBlock::from_ptr(unsafe { ffi::cta::di_cta_data_block_get_dolby_video(self.0) })
    }

    /// Get the vendor-specific HDMI information from a CTA data block.
    ///
    /// Note, the HDMI and HDMI Forum vendor-specific data blocks are different.
    ///
    /// Returns `None` if the data block tag is not\n DI_CTA_DATA_BLOCK_VENDOR_HDMI.
    #[cfg(feature = "v0_3")]
    pub fn vendor_hdmi(&self) -> Option<VendorHdmiBlockRef> {
        VendorHdmiBlockRef::from_ptr(unsafe { ffi::cta::di_cta_data_block_get_vendor_hdmi(self.0) })
    }

    /// Get the vendor-specific HDMI Forum information from a CTA data block.
    ///
    /// Note, the HDMI and HDMI Forum vendor-specific data blocks are different.
    ///
    /// Returns `None` if the data block tag is not\n DI_CTA_DATA_BLOCK_VENDOR_HDMI_FORUM.
    #[cfg(feature = "v0_3")]
    pub fn vendor_hdmi_forum(&self) -> Option<VendorHdmiForumBlock> {
        VendorHdmiForumBlock::from_ptr(unsafe {
            ffi::cta::di_cta_data_block_get_vendor_hdmi_forum(self.0)
        })
    }

    /// Get the HDMI Forum Sink Capability (HF-SCDB) from a CTA data block.
    ///
    /// Returns `None` if the data block tag is not
    /// DI_CTA_DATA_BLOCK_HDMI_SINK_CAP.
    #[cfg(feature = "v0_3")]
    pub fn hdmi_sink_cap(&self) -> Option<HdmiForumSinkCap> {
        HdmiForumSinkCap::from_ptr(unsafe { ffi::cta::di_cta_data_block_get_hdmi_sink_cap(self.0) })
    }
}

/// CTA data block tag.
///
/// Note, the enum values don't match the specification.
#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_data_block_tag)]
#[repr(u32)]
pub enum DataBlockTag {
    Audio = ffi::cta::di_cta_data_block_tag_DI_CTA_DATA_BLOCK_AUDIO,
    Video = ffi::cta::di_cta_data_block_tag_DI_CTA_DATA_BLOCK_VIDEO,
    SpeakerAlloc = ffi::cta::di_cta_data_block_tag_DI_CTA_DATA_BLOCK_SPEAKER_ALLOC,
    VesaDisplayTransferCharacteristic =
        ffi::cta::di_cta_data_block_tag_DI_CTA_DATA_BLOCK_VESA_DISPLAY_TRANSFER_CHARACTERISTIC,
    VideoFormat = ffi::cta::di_cta_data_block_tag_DI_CTA_DATA_BLOCK_VIDEO_FORMAT,
    VideoCap = ffi::cta::di_cta_data_block_tag_DI_CTA_DATA_BLOCK_VIDEO_CAP,
    VesaDisplayDevice = ffi::cta::di_cta_data_block_tag_DI_CTA_DATA_BLOCK_VESA_DISPLAY_DEVICE,
    Colorimetry = ffi::cta::di_cta_data_block_tag_DI_CTA_DATA_BLOCK_COLORIMETRY,
    HdrStaticMetadata = ffi::cta::di_cta_data_block_tag_DI_CTA_DATA_BLOCK_HDR_STATIC_METADATA,
    HdrDynamicMetadata = ffi::cta::di_cta_data_block_tag_DI_CTA_DATA_BLOCK_HDR_DYNAMIC_METADATA,
    NativeVideoResolution =
        ffi::cta::di_cta_data_block_tag_DI_CTA_DATA_BLOCK_NATIVE_VIDEO_RESOLUTION,
    VideoFormatPref = ffi::cta::di_cta_data_block_tag_DI_CTA_DATA_BLOCK_VIDEO_FORMAT_PREF,
    Ycbcr420 = ffi::cta::di_cta_data_block_tag_DI_CTA_DATA_BLOCK_YCBCR420,
    Ycbcr420CapMap = ffi::cta::di_cta_data_block_tag_DI_CTA_DATA_BLOCK_YCBCR420_CAP_MAP,
    HdmiAudio = ffi::cta::di_cta_data_block_tag_DI_CTA_DATA_BLOCK_HDMI_AUDIO,
    RoomConfig = ffi::cta::di_cta_data_block_tag_DI_CTA_DATA_BLOCK_ROOM_CONFIG,
    SpeakerLocation = ffi::cta::di_cta_data_block_tag_DI_CTA_DATA_BLOCK_SPEAKER_LOCATION,
    Infoframe = ffi::cta::di_cta_data_block_tag_DI_CTA_DATA_BLOCK_INFOFRAME,
    DisplayidVideoTimingVii =
        ffi::cta::di_cta_data_block_tag_DI_CTA_DATA_BLOCK_DISPLAYID_VIDEO_TIMING_VII,
    DisplayidVideoTimingViii =
        ffi::cta::di_cta_data_block_tag_DI_CTA_DATA_BLOCK_DISPLAYID_VIDEO_TIMING_VIII,
    DisplayidVideoTimingX =
        ffi::cta::di_cta_data_block_tag_DI_CTA_DATA_BLOCK_DISPLAYID_VIDEO_TIMING_X,
    HdmiEdidExtOverride = ffi::cta::di_cta_data_block_tag_DI_CTA_DATA_BLOCK_HDMI_EDID_EXT_OVERRIDE,
    HdmiSinkCap = ffi::cta::di_cta_data_block_tag_DI_CTA_DATA_BLOCK_HDMI_SINK_CAP,
    #[cfg(feature = "v0_3")]
    VendorHdmi = ffi::cta::di_cta_data_block_tag_DI_CTA_DATA_BLOCK_VENDOR_HDMI,
    #[cfg(feature = "v0_3")]
    DolbyVideo = ffi::cta::di_cta_data_block_tag_DI_CTA_DATA_BLOCK_DOLBY_VIDEO,
    #[cfg(feature = "v0_3")]
    HDR10Plus = ffi::cta::di_cta_data_block_tag_DI_CTA_DATA_BLOCK_HDR10PLUS,
    #[cfg(feature = "v0_3")]
    VendorHdmiForum = ffi::cta::di_cta_data_block_tag_DI_CTA_DATA_BLOCK_VENDOR_HDMI_FORUM,
}

/// Audio formats, defined in tables 37 and 39.
///
/// Note, the enum values don't match the specification.
#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_audio_format)]
#[repr(u32)]
#[allow(non_camel_case_types)]
pub enum AudioFormat {
    LPCM = ffi::cta::di_cta_audio_format_DI_CTA_AUDIO_FORMAT_LPCM,
    AC3 = ffi::cta::di_cta_audio_format_DI_CTA_AUDIO_FORMAT_AC3,
    MPEG1 = ffi::cta::di_cta_audio_format_DI_CTA_AUDIO_FORMAT_MPEG1,
    MP3 = ffi::cta::di_cta_audio_format_DI_CTA_AUDIO_FORMAT_MP3,
    MPEG2 = ffi::cta::di_cta_audio_format_DI_CTA_AUDIO_FORMAT_MPEG2,
    AAC_LC = ffi::cta::di_cta_audio_format_DI_CTA_AUDIO_FORMAT_AAC_LC,
    DTS = ffi::cta::di_cta_audio_format_DI_CTA_AUDIO_FORMAT_DTS,
    ATRAC = ffi::cta::di_cta_audio_format_DI_CTA_AUDIO_FORMAT_ATRAC,
    ONE_BIT_AUDIO = ffi::cta::di_cta_audio_format_DI_CTA_AUDIO_FORMAT_ONE_BIT_AUDIO,
    ENHANCED_AC3 = ffi::cta::di_cta_audio_format_DI_CTA_AUDIO_FORMAT_ENHANCED_AC3,
    DTS_HD = ffi::cta::di_cta_audio_format_DI_CTA_AUDIO_FORMAT_DTS_HD,
    MAT = ffi::cta::di_cta_audio_format_DI_CTA_AUDIO_FORMAT_MAT,
    DST = ffi::cta::di_cta_audio_format_DI_CTA_AUDIO_FORMAT_DST,
    WMA_PRO = ffi::cta::di_cta_audio_format_DI_CTA_AUDIO_FORMAT_WMA_PRO,
    MPEG4_HE_AAC = ffi::cta::di_cta_audio_format_DI_CTA_AUDIO_FORMAT_MPEG4_HE_AAC,
    MPEG4_HE_AAC_V2 = ffi::cta::di_cta_audio_format_DI_CTA_AUDIO_FORMAT_MPEG4_HE_AAC_V2,
    MPEG4_AAC_LC = ffi::cta::di_cta_audio_format_DI_CTA_AUDIO_FORMAT_MPEG4_AAC_LC,
    DRA = ffi::cta::di_cta_audio_format_DI_CTA_AUDIO_FORMAT_DRA,
    MPEG4_HE_AAC_MPEG_SURROUND =
        ffi::cta::di_cta_audio_format_DI_CTA_AUDIO_FORMAT_MPEG4_HE_AAC_MPEG_SURROUND,
    MPEG4_AAC_LC_MPEG_SURROUND =
        ffi::cta::di_cta_audio_format_DI_CTA_AUDIO_FORMAT_MPEG4_AAC_LC_MPEG_SURROUND,
    MPEGH_3D = ffi::cta::di_cta_audio_format_DI_CTA_AUDIO_FORMAT_MPEGH_3D,
    AC4 = ffi::cta::di_cta_audio_format_DI_CTA_AUDIO_FORMAT_AC4,
    LPCM_3D = ffi::cta::di_cta_audio_format_DI_CTA_AUDIO_FORMAT_LPCM_3D,
}

#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_sad_sample_rates)]
pub struct SadSampleRates {
    pub has_192_khz: bool,
    pub has_176_4_khz: bool,
    pub has_96_khz: bool,
    pub has_88_2_khz: bool,
    pub has_48_khz: bool,
    pub has_44_1_khz: bool,
    pub has_32_khz: bool,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_sad_mpegh_3d_level)]
#[repr(u32)]
pub enum SadMpegh3dLevel {
    Unspecified = ffi::cta::di_cta_sad_mpegh_3d_level_DI_CTA_SAD_MPEGH_3D_LEVEL_UNSPECIFIED,
    _1 = ffi::cta::di_cta_sad_mpegh_3d_level_DI_CTA_SAD_MPEGH_3D_LEVEL_1,
    _2 = ffi::cta::di_cta_sad_mpegh_3d_level_DI_CTA_SAD_MPEGH_3D_LEVEL_2,
    _3 = ffi::cta::di_cta_sad_mpegh_3d_level_DI_CTA_SAD_MPEGH_3D_LEVEL_3,
    _4 = ffi::cta::di_cta_sad_mpegh_3d_level_DI_CTA_SAD_MPEGH_3D_LEVEL_4,
    _5 = ffi::cta::di_cta_sad_mpegh_3d_level_DI_CTA_SAD_MPEGH_3D_LEVEL_5,
}

#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_sad_mpegh_3d)]
pub struct SadMpegh3d {
    pub level: SadMpegh3dLevel,
    pub low_complexity_profile: bool,
    pub baseline_profile: bool,
}

#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_sad_mpeg_aac)]
pub struct SadMpegAac {
    pub has_frame_length_960: bool,
    pub has_frame_length_1024: bool,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_sad_mpeg_surround_signaling)]
#[repr(u32)]
pub enum SadMpegSurroundSignaling {
    Implicit =
        ffi::cta::di_cta_sad_mpeg_surround_signaling_DI_CTA_SAD_MPEG_SURROUND_SIGNALING_IMPLICIT,
    ImplicitAndExplicit = ffi::cta::di_cta_sad_mpeg_surround_signaling_DI_CTA_SAD_MPEG_SURROUND_SIGNALING_IMPLICIT_AND_EXPLICIT,
}

#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_sad_mpeg_surround)]
pub struct SadMpegSurround {
    pub signaling: SadMpegSurroundSignaling,
}

#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_sad_mpeg_aac_le)]
pub struct SadMpegAacLe {
    pub supports_multichannel_sound: bool,
}

#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_sad_lpcm)]
pub struct SadLpcm {
    pub has_sample_size_24_bits: bool,
    pub has_sample_size_20_bits: bool,
    pub has_sample_size_16_bits: bool,
}

#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_sad_enhanced_ac3)]
#[allow(non_snake_case)]
pub struct SadEnhancedAc3 {
    pub supports_joint_object_coding: bool,
    pub supports_joint_object_coding_ACMOD28: bool,
}

#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_sad_mat)]
pub struct SadMat {
    pub supports_object_audio_and_channel_based: bool,
    pub requires_hash_calculation: bool,
}

#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_sad_wma_pro)]
pub struct SadWmaPro {
    pub profile: ::std::os::raw::c_int,
}

/// A CTA short audio descriptor (SAD), defined in section 7.5.2.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_sad)]
pub struct Sad {
    pub format: AudioFormat,
    #[optional(0i32)]
    pub max_channels: Option<i32>,
    #[ptr_deref]
    pub supported_sample_rates: Option<SadSampleRates>,
    #[optional(0i32)]
    pub max_bitrate_kbs: Option<i32>,
    #[ptr_deref]
    pub lpcm: Option<SadLpcm>,
    #[ptr_deref]
    pub mpegh_3d: Option<SadMpegh3d>,
    #[ptr_deref]
    pub mpeg_aac: Option<SadMpegAac>,
    #[ptr_deref]
    pub mpeg_surround: Option<SadMpegSurround>,
    #[ptr_deref]
    pub mpeg_aac_le: Option<SadMpegAacLe>,
    #[ptr_deref]
    pub enhanced_ac3: Option<SadEnhancedAc3>,
    #[ptr_deref]
    pub mat: Option<SadMat>,
    #[ptr_deref]
    pub wma_pro: Option<SadWmaPro>,
}

#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_audio_block)]
#[wrap]
#[cfg(feature = "v0_3")]
pub struct AudioBlock {}

#[cfg(feature = "v0_3")]
impl AudioBlockRef {
    /// Get an array of short audio descriptors.
    pub fn sads(&self) -> impl Iterator<Item = Sad> {
        FFIIter::new(unsafe { (*self.0).sads })
    }
}

/// Indicates which speakers are present.
///
/// See figure 6 for the meaning of the fields.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_speaker_allocation)]
pub struct SpeakerAllocation {
    pub flw_frw: bool,
    pub flc_frc: bool,
    pub bc: bool,
    pub bl_br: bool,
    pub fc: bool,
    pub lfe1: bool,
    pub fl_fr: bool,
    pub tpsil_tpsir: bool,
    pub sil_sir: bool,
    pub tpbc: bool,
    pub lfe2: bool,
    pub ls_rs: bool,
    pub tpfc: bool,
    pub tpc: bool,
    pub tpfl_tpfr: bool,
    pub btfl_btfr: bool,
    pub btfc: bool,
    pub tpbl_tpbr: bool,
}

/// Speaker allocation data block (SADB), defined in section 7.5.3.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_speaker_alloc_block)]
pub struct SpeakerAllocBlock {
    pub speakers: SpeakerAllocation,
}

/// Over- and underscan capability.
#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_video_cap_over_underscan)]
#[repr(u32)]
pub enum VideoCapOverUnderscan {
    UnknownOverUnderscan =
        ffi::cta::di_cta_video_cap_over_underscan_DI_CTA_VIDEO_CAP_UNKNOWN_OVER_UNDERSCAN,
    AlwaysOverscan = ffi::cta::di_cta_video_cap_over_underscan_DI_CTA_VIDEO_CAP_ALWAYS_OVERSCAN,
    AlwaysUnderscan = ffi::cta::di_cta_video_cap_over_underscan_DI_CTA_VIDEO_CAP_ALWAYS_UNDERSCAN,
    BothOverUnderscan =
        ffi::cta::di_cta_video_cap_over_underscan_DI_CTA_VIDEO_CAP_BOTH_OVER_UNDERSCAN,
}

/// Video capability data block (VCDB), defined in section 7.5.6.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_video_cap_block)]
pub struct VideoCapBlock {
    pub selectable_ycc_quantization_range: bool,
    pub selectable_rgb_quantization_range: bool,
    pub pt_over_underscan: VideoCapOverUnderscan,
    pub it_over_underscan: VideoCapOverUnderscan,
    pub ce_over_underscan: VideoCapOverUnderscan,
}

/// Interface types, defined in VESA DDDB section 2.3.1 and 2.3.2.
///
/// Note, the enum values don't match the specification.
#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_vesa_dddb_interface_type)]
#[repr(u32)]
#[allow(non_camel_case_types)]
#[cfg_attr(
    feature = "v0_3",
    deprecated(since = "0.3.0", note = "use `VesaDisplayDeviceInterfaceType` instead")
)]
#[cfg_attr(not(docsrs), cfg(not(feature = "v0_3")))]
pub enum VesaDddbInterfaceType {
    VGA = ffi::cta::di_cta_vesa_dddb_interface_type_DI_CTA_VESA_DDDB_INTERFACE_VGA,
    NAVI_V = ffi::cta::di_cta_vesa_dddb_interface_type_DI_CTA_VESA_DDDB_INTERFACE_NAVI_V,
    NAVI_D = ffi::cta::di_cta_vesa_dddb_interface_type_DI_CTA_VESA_DDDB_INTERFACE_NAVI_D,
    LVDS = ffi::cta::di_cta_vesa_dddb_interface_type_DI_CTA_VESA_DDDB_INTERFACE_LVDS,
    RSDS = ffi::cta::di_cta_vesa_dddb_interface_type_DI_CTA_VESA_DDDB_INTERFACE_RSDS,
    DVI_D = ffi::cta::di_cta_vesa_dddb_interface_type_DI_CTA_VESA_DDDB_INTERFACE_DVI_D,
    DVI_I_ANALOG =
        ffi::cta::di_cta_vesa_dddb_interface_type_DI_CTA_VESA_DDDB_INTERFACE_DVI_I_ANALOG,
    DVI_I_DIGITAL =
        ffi::cta::di_cta_vesa_dddb_interface_type_DI_CTA_VESA_DDDB_INTERFACE_DVI_I_DIGITAL,
    HDMI_A = ffi::cta::di_cta_vesa_dddb_interface_type_DI_CTA_VESA_DDDB_INTERFACE_HDMI_A,
    HDMI_B = ffi::cta::di_cta_vesa_dddb_interface_type_DI_CTA_VESA_DDDB_INTERFACE_HDMI_B,
    MDDI = ffi::cta::di_cta_vesa_dddb_interface_type_DI_CTA_VESA_DDDB_INTERFACE_MDDI,
    DISPLAYPORT = ffi::cta::di_cta_vesa_dddb_interface_type_DI_CTA_VESA_DDDB_INTERFACE_DISPLAYPORT,
    IEEE_1394 = ffi::cta::di_cta_vesa_dddb_interface_type_DI_CTA_VESA_DDDB_INTERFACE_IEEE_1394,
    M1_ANALOG = ffi::cta::di_cta_vesa_dddb_interface_type_DI_CTA_VESA_DDDB_INTERFACE_M1_ANALOG,
    M1_DIGITAL = ffi::cta::di_cta_vesa_dddb_interface_type_DI_CTA_VESA_DDDB_INTERFACE_M1_DIGITAL,
}

/// Interface types, defined in VESA DDDB section 2.3.1 and 2.3.2.
///
/// Note, the enum values don't match the specification.
#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_vesa_display_device_interface_type)]
#[repr(u32)]
#[allow(non_camel_case_types)]
#[cfg(feature = "v0_3")]
pub enum VesaDisplayDeviceInterfaceType {
    VGA = ffi::cta::di_cta_vesa_display_device_interface_type_DI_CTA_VESA_DISPLAY_DEVICE_INTERFACE_VGA,
    NAVI_V = ffi::cta::di_cta_vesa_display_device_interface_type_DI_CTA_VESA_DISPLAY_DEVICE_INTERFACE_NAVI_V,
    NAVI_D = ffi::cta::di_cta_vesa_display_device_interface_type_DI_CTA_VESA_DISPLAY_DEVICE_INTERFACE_NAVI_D,
    LVDS = ffi::cta::di_cta_vesa_display_device_interface_type_DI_CTA_VESA_DISPLAY_DEVICE_INTERFACE_LVDS,
    RSDS = ffi::cta::di_cta_vesa_display_device_interface_type_DI_CTA_VESA_DISPLAY_DEVICE_INTERFACE_RSDS,
    DVI_D = ffi::cta::di_cta_vesa_display_device_interface_type_DI_CTA_VESA_DISPLAY_DEVICE_INTERFACE_DVI_D,
    DVI_I_ANALOG = ffi::cta::di_cta_vesa_display_device_interface_type_DI_CTA_VESA_DISPLAY_DEVICE_INTERFACE_DVI_I_ANALOG,
    DVI_I_DIGITAL = ffi::cta::di_cta_vesa_display_device_interface_type_DI_CTA_VESA_DISPLAY_DEVICE_INTERFACE_DVI_I_DIGITAL,
    HDMI_A = ffi::cta::di_cta_vesa_display_device_interface_type_DI_CTA_VESA_DISPLAY_DEVICE_INTERFACE_HDMI_A,
    HDMI_B = ffi::cta::di_cta_vesa_display_device_interface_type_DI_CTA_VESA_DISPLAY_DEVICE_INTERFACE_HDMI_B,
    MDDI = ffi::cta::di_cta_vesa_display_device_interface_type_DI_CTA_VESA_DISPLAY_DEVICE_INTERFACE_MDDI,
    DISPLAYPORT = ffi::cta::di_cta_vesa_display_device_interface_type_DI_CTA_VESA_DISPLAY_DEVICE_INTERFACE_DISPLAYPORT,
    IEEE_1394 = ffi::cta::di_cta_vesa_display_device_interface_type_DI_CTA_VESA_DISPLAY_DEVICE_INTERFACE_IEEE_1394,
    M1_ANALOG = ffi::cta::di_cta_vesa_display_device_interface_type_DI_CTA_VESA_DISPLAY_DEVICE_INTERFACE_M1_ANALOG,
    M1_DIGITAL = ffi::cta::di_cta_vesa_display_device_interface_type_DI_CTA_VESA_DISPLAY_DEVICE_INTERFACE_M1_DIGITAL,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_vesa_dddb_content_protection)]
#[repr(u32)]
#[cfg_attr(
    feature = "v0_3",
    deprecated(
        since = "0.3.0",
        note = "use `VesaDisplayDeviceContentProtection` instead"
    )
)]
#[cfg_attr(not(docsrs), cfg(not(feature = "v0_3")))]
pub enum VesaDddbContentProtection {
    None = ffi::cta::di_cta_vesa_dddb_content_protection_DI_CTA_VESA_DDDB_CONTENT_PROTECTION_NONE,
    HDCP = ffi::cta::di_cta_vesa_dddb_content_protection_DI_CTA_VESA_DDDB_CONTENT_PROTECTION_HDCP,
    DTCP = ffi::cta::di_cta_vesa_dddb_content_protection_DI_CTA_VESA_DDDB_CONTENT_PROTECTION_DTCP,
    DPCP = ffi::cta::di_cta_vesa_dddb_content_protection_DI_CTA_VESA_DDDB_CONTENT_PROTECTION_DPCP,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_vesa_display_device_content_protection)]
#[repr(u32)]
#[cfg(feature = "v0_3")]
pub enum VesaDisplayDeviceContentProtection {
    None = ffi::cta::di_cta_vesa_display_device_content_protection_DI_CTA_VESA_DISPLAY_DEVICE_CONTENT_PROTECTION_NONE,
    HDCP = ffi::cta::di_cta_vesa_display_device_content_protection_DI_CTA_VESA_DISPLAY_DEVICE_CONTENT_PROTECTION_HDCP,
    DTCP = ffi::cta::di_cta_vesa_display_device_content_protection_DI_CTA_VESA_DISPLAY_DEVICE_CONTENT_PROTECTION_DTCP,
    DPCP = ffi::cta::di_cta_vesa_display_device_content_protection_DI_CTA_VESA_DISPLAY_DEVICE_CONTENT_PROTECTION_DPCP,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_vesa_dddb_default_orientation)]
#[repr(u32)]
#[cfg_attr(
    feature = "v0_3",
    deprecated(
        since = "0.3.0",
        note = "use `VesaDisplayDeviceDefaultOrientation` instead"
    )
)]
#[cfg_attr(not(docsrs), cfg(not(feature = "v0_3")))]
pub enum VesaDddbDefaultOrientation {
    Landscape = ffi::cta::di_cta_vesa_dddb_default_orientation_DI_CTA_VESA_DDDB_DEFAULT_ORIENTATION_LANDSCAPE,
    Portrait =
        ffi::cta::di_cta_vesa_dddb_default_orientation_DI_CTA_VESA_DDDB_DEFAULT_ORIENTATION_PORTAIT,
    Unfixed =
        ffi::cta::di_cta_vesa_dddb_default_orientation_DI_CTA_VESA_DDDB_DEFAULT_ORIENTATION_UNFIXED,
    Undefined = ffi::cta::di_cta_vesa_dddb_default_orientation_DI_CTA_VESA_DDDB_DEFAULT_ORIENTATION_UNDEFINED,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_vesa_display_device_default_orientation)]
#[repr(u32)]
#[cfg(feature = "v0_3")]
pub enum VesaDisplayDeviceDefaultOrientation {
    Landscape = ffi::cta::di_cta_vesa_display_device_default_orientation_DI_CTA_VESA_DISPLAY_DEVICE_DEFAULT_ORIENTATION_LANDSCAPE,
    Portrait = ffi::cta::di_cta_vesa_display_device_default_orientation_DI_CTA_VESA_DISPLAY_DEVICE_DEFAULT_ORIENTATION_PORTAIT,
    Unfixed = ffi::cta::di_cta_vesa_display_device_default_orientation_DI_CTA_VESA_DISPLAY_DEVICE_DEFAULT_ORIENTATION_UNFIXED,
    Undefined = ffi::cta::di_cta_vesa_display_device_default_orientation_DI_CTA_VESA_DISPLAY_DEVICE_DEFAULT_ORIENTATION_UNDEFINED,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_vesa_dddb_rotation_cap)]
#[repr(u32)]
#[allow(non_camel_case_types)]
#[cfg_attr(
    feature = "v0_3",
    deprecated(since = "0.3.0", note = "use `VesaDisplayDeviceRotationCap` instead")
)]
#[cfg_attr(not(docsrs), cfg(not(feature = "v0_3")))]
pub enum VesaDddbRotationCap {
    None = ffi::cta::di_cta_vesa_dddb_rotation_cap_DI_CTA_VESA_DDDB_ROTATION_CAP_NONE,
    _90DEG_CLOCKWISE =
        ffi::cta::di_cta_vesa_dddb_rotation_cap_DI_CTA_VESA_DDDB_ROTATION_CAP_90DEG_CLOCKWISE,
    _90DEG_COUNTERCLOCKWISE = ffi::cta::di_cta_vesa_dddb_rotation_cap_DI_CTA_VESA_DDDB_ROTATION_CAP_90DEG_COUNTERCLOCKWISE,
    _90DEG_EITHER =
        ffi::cta::di_cta_vesa_dddb_rotation_cap_DI_CTA_VESA_DDDB_ROTATION_CAP_90DEG_EITHER,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_vesa_display_device_rotation_cap)]
#[repr(u32)]
#[allow(non_camel_case_types)]
#[cfg(feature = "v0_3")]
pub enum VesaDisplayDeviceRotationCap {
    None = ffi::cta::di_cta_vesa_display_device_rotation_cap_DI_CTA_VESA_DISPLAY_DEVICE_ROTATION_CAP_NONE,
    _90DEG_CLOCKWISE = ffi::cta::di_cta_vesa_display_device_rotation_cap_DI_CTA_VESA_DISPLAY_DEVICE_ROTATION_CAP_90DEG_CLOCKWISE,
    _90DEG_COUNTERCLOCKWISE = ffi::cta::di_cta_vesa_display_device_rotation_cap_DI_CTA_VESA_DISPLAY_DEVICE_ROTATION_CAP_90DEG_COUNTERCLOCKWISE,
    _90DEG_EITHER = ffi::cta::di_cta_vesa_display_device_rotation_cap_DI_CTA_VESA_DISPLAY_DEVICE_ROTATION_CAP_90DEG_EITHER,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_vesa_dddb_zero_pixel_location)]
#[repr(u32)]
#[cfg_attr(
    feature = "v0_3",
    deprecated(since = "0.3.0", note = "use `VesaDddbZeroPixelLocation` instead")
)]
#[cfg_attr(not(docsrs), cfg(not(feature = "v0_3")))]
pub enum VesaDddbZeroPixelLocation {
    UpperLeft =
        ffi::cta::di_cta_vesa_dddb_zero_pixel_location_DI_CTA_VESA_DDDB_ZERO_PIXEL_UPPER_LEFT,
    UpperRight =
        ffi::cta::di_cta_vesa_dddb_zero_pixel_location_DI_CTA_VESA_DDDB_ZERO_PIXEL_UPPER_RIGHT,
    LowerLeft =
        ffi::cta::di_cta_vesa_dddb_zero_pixel_location_DI_CTA_VESA_DDDB_ZERO_PIXEL_LOWER_LEFT,
    LowerRight =
        ffi::cta::di_cta_vesa_dddb_zero_pixel_location_DI_CTA_VESA_DDDB_ZERO_PIXEL_LOWER_RIGHT,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_vesa_display_device_zero_pixel_location)]
#[repr(u32)]
#[cfg(feature = "v0_3")]
pub enum VesaDisplayDeviceZeroPixelLocation {
    UpperLeft = ffi::cta::di_cta_vesa_display_device_zero_pixel_location_DI_CTA_VESA_DISPLAY_DEVICE_ZERO_PIXEL_UPPER_LEFT,
    UpperRight = ffi::cta::di_cta_vesa_display_device_zero_pixel_location_DI_CTA_VESA_DISPLAY_DEVICE_ZERO_PIXEL_UPPER_RIGHT,
    LowerLeft = ffi::cta::di_cta_vesa_display_device_zero_pixel_location_DI_CTA_VESA_DISPLAY_DEVICE_ZERO_PIXEL_LOWER_LEFT,
    LowerRight = ffi::cta::di_cta_vesa_display_device_zero_pixel_location_DI_CTA_VESA_DISPLAY_DEVICE_ZERO_PIXEL_LOWER_RIGHT,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_vesa_dddb_scan_direction)]
#[repr(u32)]
#[cfg_attr(
    feature = "v0_3",
    deprecated(since = "0.3.0", note = "use `VesaDddbScanDirection` instead")
)]
#[cfg_attr(not(docsrs), cfg(not(feature = "v0_3")))]
pub enum VesaDddbScanDirection {
    Undefined = ffi::cta::di_cta_vesa_dddb_scan_direction_DI_CTA_VESA_DDDB_SCAN_DIRECTION_UNDEFINED,
    FastLongSlowShort = ffi::cta::di_cta_vesa_dddb_scan_direction_DI_CTA_VESA_DDDB_SCAN_DIRECTION_FAST_LONG_SLOW_SHORT,
    FastShortSlowLong = ffi::cta::di_cta_vesa_dddb_scan_direction_DI_CTA_VESA_DDDB_SCAN_DIRECTION_FAST_SHORT_SLOW_LONG,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_vesa_display_device_scan_direction)]
#[repr(u32)]
#[cfg(feature = "v0_3")]
pub enum VesaDisplayDeviceScanDirection {
    Undefined = ffi::cta::di_cta_vesa_display_device_scan_direction_DI_CTA_VESA_DISPLAY_DEVICE_SCAN_DIRECTION_UNDEFINED,
    FastLongSlowShort = ffi::cta::di_cta_vesa_display_device_scan_direction_DI_CTA_VESA_DISPLAY_DEVICE_SCAN_DIRECTION_FAST_LONG_SLOW_SHORT,
    FastShortSlowLong = ffi::cta::di_cta_vesa_display_device_scan_direction_DI_CTA_VESA_DISPLAY_DEVICE_SCAN_DIRECTION_FAST_SHORT_SLOW_LONG,
}

/// Subpixel layout, defined in VESA DDDB section 2.9.
///
/// For layouts with more than 3 subpixels, the color coordinates of the
/// additional subpixels are defined in the additional primary chromaticities.
#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_vesa_dddb_subpixel_layout)]
#[repr(u32)]
#[allow(non_camel_case_types)]
#[cfg_attr(
    feature = "v0_3",
    deprecated(
        since = "0.3.0",
        note = "use `VesaDisplayDeviceSubpixelLayout` instead"
    )
)]
#[cfg_attr(not(docsrs), cfg(not(feature = "v0_3")))]
pub enum VesaDddbSubpixelLayout {
    Undefined = ffi::cta::di_cta_vesa_dddb_subpixel_layout_DI_CTA_VESA_DDDB_SUBPIXEL_UNDEFINED,
    RGB_VERT = ffi::cta::di_cta_vesa_dddb_subpixel_layout_DI_CTA_VESA_DDDB_SUBPIXEL_RGB_VERT,
    RGB_HORIZ = ffi::cta::di_cta_vesa_dddb_subpixel_layout_DI_CTA_VESA_DDDB_SUBPIXEL_RGB_HORIZ,
    EDID_CHROM_VERT =
        ffi::cta::di_cta_vesa_dddb_subpixel_layout_DI_CTA_VESA_DDDB_SUBPIXEL_EDID_CHROM_VERT,
    EDID_CHROM_HORIZ =
        ffi::cta::di_cta_vesa_dddb_subpixel_layout_DI_CTA_VESA_DDDB_SUBPIXEL_EDID_CHROM_HORIZ,
    QUAD_RGGB = ffi::cta::di_cta_vesa_dddb_subpixel_layout_DI_CTA_VESA_DDDB_SUBPIXEL_QUAD_RGGB,
    QUAD_GBRG = ffi::cta::di_cta_vesa_dddb_subpixel_layout_DI_CTA_VESA_DDDB_SUBPIXEL_QUAD_GBRG,
    DELTA_RGB = ffi::cta::di_cta_vesa_dddb_subpixel_layout_DI_CTA_VESA_DDDB_SUBPIXEL_DELTA_RGB,
    MOSAIC = ffi::cta::di_cta_vesa_dddb_subpixel_layout_DI_CTA_VESA_DDDB_SUBPIXEL_MOSAIC,
    QUAD_ANY = ffi::cta::di_cta_vesa_dddb_subpixel_layout_DI_CTA_VESA_DDDB_SUBPIXEL_QUAD_ANY,
    FIVE = ffi::cta::di_cta_vesa_dddb_subpixel_layout_DI_CTA_VESA_DDDB_SUBPIXEL_FIVE,
    SIX = ffi::cta::di_cta_vesa_dddb_subpixel_layout_DI_CTA_VESA_DDDB_SUBPIXEL_SIX,
    CLAIRVOYANTE_PENTILE =
        ffi::cta::di_cta_vesa_dddb_subpixel_layout_DI_CTA_VESA_DDDB_SUBPIXEL_CLAIRVOYANTE_PENTILE,
}

/// Subpixel layout, defined in VESA DDDB section 2.9.
///
/// For layouts with more than 3 subpixels, the color coordinates of the
/// additional subpixels are defined in the additional primary chromaticities.
#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_vesa_display_device_subpixel_layout)]
#[repr(u32)]
#[allow(non_camel_case_types)]
#[cfg(feature = "v0_3")]
pub enum VesaDisplayDeviceSubpixelLayout {
    Undefined = ffi::cta::di_cta_vesa_display_device_subpixel_layout_DI_CTA_VESA_DISPLAY_DEVICE_SUBPIXEL_UNDEFINED,
    RGB_VERT = ffi::cta::di_cta_vesa_display_device_subpixel_layout_DI_CTA_VESA_DISPLAY_DEVICE_SUBPIXEL_RGB_VERT,
    RGB_HORIZ = ffi::cta::di_cta_vesa_display_device_subpixel_layout_DI_CTA_VESA_DISPLAY_DEVICE_SUBPIXEL_RGB_HORIZ,
    EDID_CHROM_VERT = ffi::cta::di_cta_vesa_display_device_subpixel_layout_DI_CTA_VESA_DISPLAY_DEVICE_SUBPIXEL_EDID_CHROM_VERT,
    EDID_CHROM_HORIZ = ffi::cta::di_cta_vesa_display_device_subpixel_layout_DI_CTA_VESA_DISPLAY_DEVICE_SUBPIXEL_EDID_CHROM_HORIZ,
    QUAD_RGGB = ffi::cta::di_cta_vesa_display_device_subpixel_layout_DI_CTA_VESA_DISPLAY_DEVICE_SUBPIXEL_QUAD_RGGB,
    QUAD_GBRG = ffi::cta::di_cta_vesa_display_device_subpixel_layout_DI_CTA_VESA_DISPLAY_DEVICE_SUBPIXEL_QUAD_GBRG,
    DELTA_RGB = ffi::cta::di_cta_vesa_display_device_subpixel_layout_DI_CTA_VESA_DISPLAY_DEVICE_SUBPIXEL_DELTA_RGB,
    MOSAIC = ffi::cta::di_cta_vesa_display_device_subpixel_layout_DI_CTA_VESA_DISPLAY_DEVICE_SUBPIXEL_MOSAIC,
    QUAD_ANY = ffi::cta::di_cta_vesa_display_device_subpixel_layout_DI_CTA_VESA_DISPLAY_DEVICE_SUBPIXEL_QUAD_ANY,
    FIVE = ffi::cta::di_cta_vesa_display_device_subpixel_layout_DI_CTA_VESA_DISPLAY_DEVICE_SUBPIXEL_FIVE,
    SIX = ffi::cta::di_cta_vesa_display_device_subpixel_layout_DI_CTA_VESA_DISPLAY_DEVICE_SUBPIXEL_SIX,
    CLAIRVOYANTE_PENTILE = ffi::cta::di_cta_vesa_display_device_subpixel_layout_DI_CTA_VESA_DISPLAY_DEVICE_SUBPIXEL_CLAIRVOYANTE_PENTILE,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_vesa_dddb_dithering_type)]
#[repr(u32)]
#[cfg_attr(
    feature = "v0_3",
    deprecated(since = "0.3.0", note = "use `VesaDisplayDeviceDitheringType` instead")
)]
#[cfg_attr(not(docsrs), cfg(not(feature = "v0_3")))]
pub enum VesaDddbDitheringType {
    None = ffi::cta::di_cta_vesa_dddb_dithering_type_DI_CTA_VESA_DDDB_DITHERING_NONE,
    Spacial = ffi::cta::di_cta_vesa_dddb_dithering_type_DI_CTA_VESA_DDDB_DITHERING_SPACIAL,
    Temporal = ffi::cta::di_cta_vesa_dddb_dithering_type_DI_CTA_VESA_DDDB_DITHERING_TEMPORAL,
    SpatialAndTemporal =
        ffi::cta::di_cta_vesa_dddb_dithering_type_DI_CTA_VESA_DDDB_DITHERING_SPATIAL_AND_TEMPORAL,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_vesa_display_device_dithering_type)]
#[repr(u32)]
#[cfg(feature = "v0_3")]
pub enum VesaDisplayDeviceDitheringType {
    None = ffi::cta::di_cta_vesa_display_device_dithering_type_DI_CTA_VESA_DISPLAY_DEVICE_DITHERING_NONE,
    Spacial = ffi::cta::di_cta_vesa_display_device_dithering_type_DI_CTA_VESA_DISPLAY_DEVICE_DITHERING_SPACIAL,
    Temporal = ffi::cta::di_cta_vesa_display_device_dithering_type_DI_CTA_VESA_DISPLAY_DEVICE_DITHERING_TEMPORAL,
    SpatialAndTemporal = ffi::cta::di_cta_vesa_display_device_dithering_type_DI_CTA_VESA_DISPLAY_DEVICE_DITHERING_SPATIAL_AND_TEMPORAL,
}

#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_vesa_dddb_additional_primary_chromaticity)]
#[cfg_attr(
    feature = "v0_3",
    deprecated(
        since = "0.3.0",
        note = "use `VesaDisplayDeviceAdditionalPrimaryChromaticity` instead"
    )
)]
#[cfg_attr(not(docsrs), cfg(not(feature = "v0_3")))]
pub struct VesaDddbAdditionalPrimaryChromaticity {
    pub x: f32,
    pub y: f32,
}

#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_vesa_display_device_additional_primary_chromaticity)]
#[cfg(feature = "v0_3")]
pub struct VesaDisplayDeviceAdditionalPrimaryChromaticity {
    pub x: f32,
    pub y: f32,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_vesa_dddb_frame_rate_conversion)]
#[repr(u32)]
#[cfg_attr(
    feature = "v0_3",
    deprecated(
        since = "0.3.0",
        note = "use `VesaDisplayDeviceFrameRateConversion` instead"
    )
)]
#[cfg_attr(not(docsrs), cfg(not(feature = "v0_3")))]
pub enum VesaDddbFrameRateConversion {
    None = ffi::cta::di_cta_vesa_dddb_frame_rate_conversion_DI_CTA_VESA_DDDB_FRAME_RATE_CONVERSION_NONE,
    SingleBuffering = ffi::cta::di_cta_vesa_dddb_frame_rate_conversion_DI_CTA_VESA_DDDB_FRAME_RATE_CONVERSION_SINGLE_BUFFERING,
    DoubleBuffering = ffi::cta::di_cta_vesa_dddb_frame_rate_conversion_DI_CTA_VESA_DDDB_FRAME_RATE_CONVERSION_DOUBLE_BUFFERING,
    Advanced = ffi::cta::di_cta_vesa_dddb_frame_rate_conversion_DI_CTA_VESA_DDDB_FRAME_RATE_CONVERSION_ADVANCED,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_vesa_display_device_frame_rate_conversion)]
#[repr(u32)]
#[cfg(feature = "v0_3")]
pub enum VesaDisplayDeviceFrameRateConversion {
    None = ffi::cta::di_cta_vesa_display_device_frame_rate_conversion_DI_CTA_VESA_DISPLAY_DEVICE_FRAME_RATE_CONVERSION_NONE,
    SingleBuffering = ffi::cta::di_cta_vesa_display_device_frame_rate_conversion_DI_CTA_VESA_DISPLAY_DEVICE_FRAME_RATE_CONVERSION_SINGLE_BUFFERING,
    DoubleBuffering = ffi::cta::di_cta_vesa_display_device_frame_rate_conversion_DI_CTA_VESA_DISPLAY_DEVICE_FRAME_RATE_CONVERSION_DOUBLE_BUFFERING,
    Advanced = ffi::cta::di_cta_vesa_display_device_frame_rate_conversion_DI_CTA_VESA_DISPLAY_DEVICE_FRAME_RATE_CONVERSION_ADVANCED,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_vesa_dddb_resp_time_transition)]
#[repr(u32)]
#[cfg_attr(
    feature = "v0_3",
    deprecated(
        since = "0.3.0",
        note = "use `VesaDisplayDeviceRespTimeTransition` instead"
    )
)]
#[cfg_attr(not(docsrs), cfg(not(feature = "v0_3")))]
pub enum VesaDddbRespTimeTransition {
    BlackToWhite =
        ffi::cta::di_cta_vesa_dddb_resp_time_transition_DI_CTA_VESA_DDDB_RESP_TIME_BLACK_TO_WHITE,
    WhiteToBlack =
        ffi::cta::di_cta_vesa_dddb_resp_time_transition_DI_CTA_VESA_DDDB_RESP_TIME_WHITE_TO_BLACK,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_vesa_display_device_resp_time_transition)]
#[repr(u32)]
#[cfg(feature = "v0_3")]
pub enum VesaDisplayDeviceRespTimeTransition {
    BlackToWhite = ffi::cta::di_cta_vesa_display_device_resp_time_transition_DI_CTA_VESA_DISPLAY_DEVICE_RESP_TIME_BLACK_TO_WHITE,
    WhiteToBlack = ffi::cta::di_cta_vesa_display_device_resp_time_transition_DI_CTA_VESA_DISPLAY_DEVICE_RESP_TIME_WHITE_TO_BLACK,
}

/// VESA Display Device Data Block (DDDB), defined in VESA Display Device Data
/// Block (DDDB) Standard version 1.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_vesa_dddb)]
#[cfg_attr(
    feature = "v0_3",
    deprecated(since = "0.3.0", note = "use `VesaDisplayDeviceBlock` instead")
)]
#[cfg_attr(not(docsrs), cfg(not(feature = "v0_3")))]
pub struct VesaDddb {
    pub interface_type: VesaDddbInterfaceType,
    #[optional(0i32)]
    pub num_channels: Option<i32>,
    pub interface_version: i32,
    pub interface_release: i32,
    pub content_protection: VesaDddbContentProtection,
    pub min_clock_freq_mhz: i32,
    pub max_clock_freq_mhz: i32,
    pub native_horiz_pixels: i32,
    pub native_vert_pixels: i32,
    pub aspect_ratio: f32,
    pub default_orientation: VesaDddbDefaultOrientation,
    pub rotation_cap: VesaDddbRotationCap,
    pub zero_pixel_location: VesaDddbZeroPixelLocation,
    pub scan_direction: VesaDddbScanDirection,
    pub subpixel_layout: VesaDddbSubpixelLayout,
    pub horiz_pitch_mm: f32,
    pub vert_pitch_mm: f32,
    pub dithering_type: VesaDddbDitheringType,
    pub direct_drive: bool,
    pub overdrive_not_recommended: bool,
    pub deinterlacing: bool,
    pub audio_support: bool,
    pub separate_audio_inputs: bool,
    pub audio_input_override: bool,
    pub audio_delay_provided: bool,
    pub audio_delay_ms: i32,
    pub frame_rate_conversion: VesaDddbFrameRateConversion,
    #[optional(0i32)]
    pub frame_rate_range_hz: Option<i32>,
    pub frame_rate_native_hz: i32,
    pub bit_depth_interface: i32,
    pub bit_depth_display: i32,
    pub additional_primary_chromaticities_len: usize,
    pub additional_primary_chromaticities: [VesaDddbAdditionalPrimaryChromaticity; 3usize],
    pub resp_time_transition: VesaDddbRespTimeTransition,
    pub resp_time_ms: i32,
    pub overscan_horiz_pct: i32,
    pub overscan_vert_pct: i32,
}

/// VESA Display Device Data Block (DDDB), defined in VESA Display Device Data
/// Block (DDDB) Standard version 1.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_vesa_display_device_block)]
#[cfg(feature = "v0_3")]
pub struct VesaDisplayDeviceBlock {
    pub interface_type: VesaDisplayDeviceInterfaceType,
    #[optional(0i32)]
    pub num_channels: Option<i32>,
    pub interface_version: i32,
    pub interface_release: i32,
    pub content_protection: VesaDisplayDeviceContentProtection,
    pub min_clock_freq_mhz: i32,
    pub max_clock_freq_mhz: i32,
    pub native_horiz_pixels: i32,
    pub native_vert_pixels: i32,
    pub aspect_ratio: f32,
    pub default_orientation: VesaDisplayDeviceDefaultOrientation,
    pub rotation_cap: VesaDisplayDeviceRotationCap,
    pub zero_pixel_location: VesaDisplayDeviceZeroPixelLocation,
    pub scan_direction: VesaDisplayDeviceScanDirection,
    pub subpixel_layout: VesaDisplayDeviceSubpixelLayout,
    pub horiz_pitch_mm: f32,
    pub vert_pitch_mm: f32,
    pub dithering_type: VesaDisplayDeviceDitheringType,
    pub direct_drive: bool,
    pub overdrive_not_recommended: bool,
    pub deinterlacing: bool,
    pub audio_support: bool,
    pub separate_audio_inputs: bool,
    pub audio_input_override: bool,
    pub audio_delay_provided: bool,
    pub audio_delay_ms: i32,
    pub frame_rate_conversion: VesaDisplayDeviceFrameRateConversion,
    #[optional(0i32)]
    pub frame_rate_range_hz: Option<i32>,
    pub frame_rate_native_hz: i32,
    pub bit_depth_interface: i32,
    pub bit_depth_display: i32,
    pub additional_primary_chromaticities_len: usize,
    pub additional_primary_chromaticities: [VesaDisplayDeviceAdditionalPrimaryChromaticity; 3usize],
    pub resp_time_transition: VesaDisplayDeviceRespTimeTransition,
    pub resp_time_ms: i32,
    pub overscan_horiz_pct: i32,
    pub overscan_vert_pct: i32,
}

/// CTA colorimetry data block, defined in section 7.5.5.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_colorimetry_block)]
pub struct ColorimetryBlock {
    pub xvycc_601: bool,
    pub xvycc_709: bool,
    pub sycc_601: bool,
    pub opycc_601: bool,
    pub oprgb: bool,
    pub bt2020_cycc: bool,
    pub bt2020_ycc: bool,
    pub bt2020_rgb: bool,
    pub st2113_rgb: bool,
    pub ictcp: bool,
}

/// Supported Electro-Optical Transfer Functions for a CTA HDR static metadata
/// block.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_hdr_static_metadata_block_eotfs)]
#[cfg_attr(
    feature = "v0_3",
    deprecated(since = "0.3.0", note = "use `HdrStaticMetadataEotfs` instead")
)]
#[cfg_attr(not(docsrs), cfg(not(feature = "v0_3")))]
pub struct HdrStaticMetadataBlockEotfs {
    pub traditional_sdr: bool,
    pub traditional_hdr: bool,
    pub pq: bool,
    pub hlg: bool,
}

/// Supported Electro-Optical Transfer Functions for a CTA HDR static metadata
/// block.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_hdr_static_metadata_eotfs)]
#[cfg(feature = "v0_3")]
pub struct HdrStaticMetadataEotfs {
    pub traditional_sdr: bool,
    pub traditional_hdr: bool,
    pub pq: bool,
    pub hlg: bool,
}

/// Supported static metadata descriptors for a CTA HDR static metadata block.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_hdr_static_metadata_block_descriptors)]
#[cfg_attr(
    feature = "v0_3",
    deprecated(since = "0.3.0", note = "use `HdrStaticMetadataDescriptors` instead")
)]
#[cfg_attr(not(docsrs), cfg(not(feature = "v0_3")))]
pub struct HdrStaticMetadataBlockDescriptors {
    pub type1: bool,
}

/// Supported static metadata descriptors for a CTA HDR static metadata block.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_hdr_static_metadata_descriptors)]
#[cfg(feature = "v0_3")]
pub struct HdrStaticMetadataDescriptors {
    pub type1: bool,
}

#[cfg(not(feature = "v0_3"))]
pub type HdrStaticMetadataBlockFieldEotfs = HdrStaticMetadataBlockEotfs;
#[cfg(feature = "v0_3")]
pub type HdrStaticMetadataBlockFieldEotfs = HdrStaticMetadataEotfs;

#[cfg(not(feature = "v0_3"))]
pub type HdrStaticMetadataBlockFieldDescriptors = HdrStaticMetadataBlockDescriptors;
#[cfg(feature = "v0_3")]
pub type HdrStaticMetadataBlockFieldDescriptors = HdrStaticMetadataDescriptors;

/// CTA HDR static metadata block, defined in section 7.5.13.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_hdr_static_metadata_block)]
pub struct HdrStaticMetadataBlock {
    #[optional(0f32)]
    pub desired_content_max_luminance: Option<f32>,
    #[optional(0f32)]
    pub desired_content_max_frame_avg_luminance: Option<f32>,
    #[optional(0f32)]
    pub desired_content_min_luminance: Option<f32>,
    #[ptr_deref]
    pub eotfs: Option<HdrStaticMetadataBlockFieldEotfs>,
    #[ptr_deref]
    pub descriptors: Option<HdrStaticMetadataBlockFieldDescriptors>,
}

#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_hdr_dynamic_metadata_block_type1)]
#[cfg_attr(
    feature = "v0_3",
    deprecated(since = "0.3.0", note = "use `HdrDynamicMetadataType1` instead")
)]
#[cfg_attr(not(docsrs), cfg(not(feature = "v0_3")))]
pub struct HdrDynamicMetadataBlockType1 {
    pub type_1_hdr_metadata_version: u8,
}

#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_hdr_dynamic_metadata_type1)]
#[cfg(feature = "v0_3")]
pub struct HdrDynamicMetadataType1 {
    pub type_1_hdr_metadata_version: u8,
}

#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_hdr_dynamic_metadata_block_type2)]
#[cfg_attr(
    feature = "v0_3",
    deprecated(since = "0.3.0", note = "use `HdrDynamicMetadataBlockType2` instead")
)]
#[cfg_attr(not(docsrs), cfg(not(feature = "v0_3")))]
pub struct HdrDynamicMetadataBlockType2 {
    pub ts_103_433_spec_version: u8,
    pub ts_103_433_1_capable: bool,
    pub ts_103_433_2_capable: bool,
    pub ts_103_433_3_capable: bool,
}

#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_hdr_dynamic_metadata_type2)]
#[cfg(feature = "v0_3")]
pub struct HdrDynamicMetadataType2 {
    pub ts_103_433_spec_version: u8,
    pub ts_103_433_1_capable: bool,
    pub ts_103_433_2_capable: bool,
    pub ts_103_433_3_capable: bool,
}

#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_hdr_dynamic_metadata_block_type3)]
#[cfg_attr(
    feature = "v0_3",
    deprecated(since = "0.3.0", note = "use `HdrDynamicMetadataType3` instead")
)]
#[cfg_attr(not(docsrs), cfg(not(feature = "v0_3")))]
pub struct HdrDynamicMetadataBlockType3 {}

#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_hdr_dynamic_metadata_type3)]
#[cfg(feature = "v0_3")]
pub struct HdrDynamicMetadataType3 {}

#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_hdr_dynamic_metadata_block_type4)]
#[cfg_attr(
    feature = "v0_3",
    deprecated(since = "0.3.0", note = "use `HdrDynamicMetadataType4` instead")
)]
#[cfg_attr(not(docsrs), cfg(not(feature = "v0_3")))]
pub struct HdrDynamicMetadataBlockType4 {
    pub type_4_hdr_metadata_version: u8,
}

#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_hdr_dynamic_metadata_type4)]
#[cfg(feature = "v0_3")]
pub struct HdrDynamicMetadataType4 {
    pub type_4_hdr_metadata_version: u8,
}

#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_hdr_dynamic_metadata_block_type256)]
#[cfg_attr(
    feature = "v0_3",
    deprecated(since = "0.3.0", note = "use `HdrDynamicMetadataType256` instead")
)]
#[cfg_attr(not(docsrs), cfg(not(feature = "v0_3")))]
pub struct HdrDynamicMetadataBlockType256 {
    pub graphics_overlay_flag_version: u8,
}

#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_hdr_dynamic_metadata_type256)]
#[cfg(feature = "v0_3")]
pub struct HdrDynamicMetadataType256 {
    pub graphics_overlay_flag_version: u8,
}

#[cfg(not(feature = "v0_3"))]
pub type HdrDynamicMetadataBlockFieldType1 = HdrDynamicMetadataBlockType1;
#[cfg(feature = "v0_3")]
pub type HdrDynamicMetadataBlockFieldType1 = HdrDynamicMetadataType1;
#[cfg(not(feature = "v0_3"))]
pub type HdrDynamicMetadataBlockFieldType2 = HdrDynamicMetadataBlockType2;
#[cfg(feature = "v0_3")]
pub type HdrDynamicMetadataBlockFieldType2 = HdrDynamicMetadataType2;
#[cfg(not(feature = "v0_3"))]
pub type HdrDynamicMetadataBlockFieldType3 = HdrDynamicMetadataBlockType3;
#[cfg(feature = "v0_3")]
pub type HdrDynamicMetadataBlockFieldType3 = HdrDynamicMetadataType3;
#[cfg(not(feature = "v0_3"))]
pub type HdrDynamicMetadataBlockFieldType4 = HdrDynamicMetadataBlockType4;
#[cfg(feature = "v0_3")]
pub type HdrDynamicMetadataBlockFieldType4 = HdrDynamicMetadataType4;
#[cfg(not(feature = "v0_3"))]
pub type HdrDynamicMetadataBlockFieldType256 = HdrDynamicMetadataBlockType256;
#[cfg(feature = "v0_3")]
pub type HdrDynamicMetadataBlockFieldType256 = HdrDynamicMetadataType256;

#[doc = " CTA HDR dynamic metadata block, defined in section 7.5.14."]
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_hdr_dynamic_metadata_block)]
pub struct HdrDynamicMetadataBlock {
    #[ptr_deref]
    pub type1: Option<HdrDynamicMetadataBlockFieldType1>,
    #[ptr_deref]
    pub type2: Option<HdrDynamicMetadataBlockFieldType2>,
    #[ptr_deref]
    pub type3: Option<HdrDynamicMetadataBlockFieldType3>,
    #[ptr_deref]
    pub type4: Option<HdrDynamicMetadataBlockFieldType4>,
    #[ptr_deref]
    pub type256: Option<HdrDynamicMetadataBlockFieldType256>,
}

/// A Short Video Descriptor (SVD).
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_svd)]
pub struct Svd {
    pub vic: u8,
    #[cfg(feature = "v0_3")]
    pub original_index: u8,
    pub native: bool,
}

#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_video_block)]
#[wrap]
#[cfg(feature = "v0_3")]
pub struct VideoBlock {}

#[cfg(feature = "v0_3")]
impl VideoBlockRef {
    /// Get an array of short video descriptors.
    pub fn svds(&self) -> impl Iterator<Item = Svd> {
        FFIIter::new(unsafe { (*self.0).svds })
    }
}

#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_ycbcr420_video_block)]
#[wrap]
#[cfg(feature = "v0_3")]
pub struct Ycbcr420VideoBlock {}

#[cfg(feature = "v0_3")]
impl Ycbcr420VideoBlockRef {
    /// Get an array of short video descriptors.
    pub fn svds(&self) -> impl Iterator<Item = Svd> {
        FFIIter::new(unsafe { (*self.0).svds })
    }
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_vesa_transfer_characteristics_usage)]
#[repr(u32)]
pub enum VesaTransferCharacteristicsUsage {
    White = ffi::cta::di_cta_vesa_transfer_characteristics_usage_DI_CTA_VESA_TRANSFER_CHARACTERISTIC_USAGE_WHITE,
    Red = ffi::cta::di_cta_vesa_transfer_characteristics_usage_DI_CTA_VESA_TRANSFER_CHARACTERISTIC_USAGE_RED,
    Green = ffi::cta::di_cta_vesa_transfer_characteristics_usage_DI_CTA_VESA_TRANSFER_CHARACTERISTIC_USAGE_GREEN,
    Blue = ffi::cta::di_cta_vesa_transfer_characteristics_usage_DI_CTA_VESA_TRANSFER_CHARACTERISTIC_USAGE_BLUE,
}

/// VESA Display Transfer Characteristic Data Block, defined in VESA Display
/// Transfer Characteristics Data Block Standard Version 1.0
///
/// Contains 8, 16 or 32 evenly distributed points on the input axis describing
/// the normalized relative luminance at that input. The first value includes the
/// relative black level luminance.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_vesa_transfer_characteristics)]
#[cfg_attr(
    feature = "v0_3",
    deprecated(
        since = "0.3.0",
        note = "use `VesaTransferCharacteristicsBlock` instead"
    )
)]
#[cfg_attr(not(docsrs), cfg(not(feature = "v0_3")))]
pub struct VesaTransferCharacteristics {
    pub usage: VesaTransferCharacteristicsUsage,
    pub points_len: u8,
    pub points: [f32; 32usize],
}

/// VESA Display Transfer Characteristic Data Block, defined in VESA Display
/// Transfer Characteristics Data Block Standard Version 1.0
///
/// Contains 8, 16 or 32 evenly distributed points on the input axis describing
/// the normalized relative luminance at that input. The first value includes the
/// relative black level luminance.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_vesa_transfer_characteristics_block)]
#[cfg(feature = "v0_3")]
pub struct VesaTransferCharacteristicsBlock {
    pub usage: VesaTransferCharacteristicsUsage,
    pub points_len: u8,
    pub points: [f32; 32usize],
}

/// CTA YCbCr 4:2:0 Capability Map block, defined in section 7.5.11.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_ycbcr420_cap_map)]
#[wrap]
#[cfg_attr(
    feature = "v0_3",
    deprecated(
        since = "0.3.0",
        note = "use `VesaTransferCharacteristicsBlock` instead"
    )
)]
#[cfg_attr(not(docsrs), cfg(not(feature = "v0_3")))]
pub struct Ycbcr420CapMap {}

#[cfg_attr(not(docsrs), cfg(not(feature = "v0_3")))]
impl Ycbcr420CapMapRef {
    /// Returns true if the SVD in regular Video Data Blocks at index `svd_index`
    /// supports YCbCr 4:2:0 subsampling.
    pub fn di_cta_ycbcr420_cap_map_supported(&self, svd_index: usize) -> bool {
        unsafe { ffi::cta::di_cta_ycbcr420_cap_map_supported(self.0, svd_index) }
    }
}

/// CTA YCbCr 4:2:0 Capability Map block, defined in section 7.5.11.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_ycbcr420_cap_map_block)]
#[wrap]
#[cfg(feature = "v0_3")]
pub struct Ycbcr420CapMapBlock {}

#[cfg(feature = "v0_3")]
impl Ycbcr420CapMapBlockRef {
    /// Returns true if the SVD in regular Video Data Blocks at index `svd_index`
    /// supports YCbCr 4:2:0 subsampling.
    pub fn di_cta_ycbcr420_cap_map_supported(&self, svd_index: usize) -> bool {
        unsafe { ffi::cta::di_cta_ycbcr420_cap_map_supported(self.0, svd_index) }
    }
}

/// InfoFrame types, defined in table 7.
///
/// Note, the enum values don't match the specification.
#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_infoframe_type)]
#[repr(u32)]
pub enum InfoframeType {
    AuxiliaryVideoInformation =
        ffi::cta::di_cta_infoframe_type_DI_CTA_INFOFRAME_TYPE_AUXILIARY_VIDEO_INFORMATION,
    SourceProductDescription =
        ffi::cta::di_cta_infoframe_type_DI_CTA_INFOFRAME_TYPE_SOURCE_PRODUCT_DESCRIPTION,
    Audio = ffi::cta::di_cta_infoframe_type_DI_CTA_INFOFRAME_TYPE_AUDIO,
    MpegSource = ffi::cta::di_cta_infoframe_type_DI_CTA_INFOFRAME_TYPE_MPEG_SOURCE,
    NtscVbi = ffi::cta::di_cta_infoframe_type_DI_CTA_INFOFRAME_TYPE_NTSC_VBI,
    DynamicRangeAndMastering =
        ffi::cta::di_cta_infoframe_type_DI_CTA_INFOFRAME_TYPE_DYNAMIC_RANGE_AND_MASTERING,
}

/// CTA InfoFrame descriptor, defined in section 7.5.9.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_infoframe_descriptor)]
pub struct InfoframeDescriptor {
    pub type_: InfoframeType,
}

/// CTA InfoFrame processing, defined in section 7.5.9.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_infoframe_block)]
#[wrap]
pub struct InfoframeBlock {
    pub num_simultaneous_vsifs: i32,
}

impl InfoframeBlockRef {
    pub fn infoframes(&self) -> impl Iterator<Item = InfoframeDescriptor> {
        FFIIter::new(unsafe { (*self.0).infoframes })
    }
}

/// InfoFrame types, defined in table 7.
///
/// Note, the enum values don't match the specification.
#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_hdmi_audio_3d_channels)]
#[repr(u32)]
#[cfg(any(feature = "v0_2", feature = "v0_3"))]
pub enum HdmiAudio3DChannels {
    Unknown = ffi::cta::di_cta_hdmi_audio_3d_channels_DI_CTA_HDMI_AUDIO_3D_CHANNELS_UNKNOWN,
    _10_2 = ffi::cta::di_cta_hdmi_audio_3d_channels_DI_CTA_HDMI_AUDIO_3D_CHANNELS_10_2,
    _22_2 = ffi::cta::di_cta_hdmi_audio_3d_channels_DI_CTA_HDMI_AUDIO_3D_CHANNELS_22_2,
    _30_2 = ffi::cta::di_cta_hdmi_audio_3d_channels_DI_CTA_HDMI_AUDIO_3D_CHANNELS_30_2,
}

/// HDMI 3D Audio
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_hdmi_audio_3d)]
#[wrap]
#[cfg(any(feature = "v0_2", feature = "v0_3"))]
pub struct HdmiAudio3d {
    pub channels: HdmiAudio3DChannels,
    pub speakers: SpeakerAllocation,
}

#[cfg(any(feature = "v0_2", feature = "v0_3"))]
impl HdmiAudio3dRef {
    pub fn sads(&self) -> impl Iterator<Item = Sad> {
        FFIIter::new(unsafe { (*self.0).sads })
    }
}

/// HDMI Multi-Stream Audio
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_hdmi_audio_multi_stream)]
#[cfg(any(feature = "v0_2", feature = "v0_3"))]
pub struct HdmiAudioMultiStream {
    pub max_streams: ::std::os::raw::c_int,
    pub supports_non_mixed: bool,
}

/// HDMI Audio
#[derive(Debug, FFIFrom)]
#[ffi(ffi::cta::di_cta_hdmi_audio_block)]
#[wrap]
#[cfg(any(feature = "v0_2", feature = "v0_3"))]
pub struct HdmiAudioBlock {
    #[ptr_deref]
    pub multi_stream: Option<HdmiAudioMultiStream>,
}

#[cfg(any(feature = "v0_2", feature = "v0_3"))]
impl HdmiAudioBlockRef {
    pub fn audio_3d(&self) -> Option<HdmiAudio3dRef> {
        HdmiAudio3dRef::from_ptr(unsafe { (*self.0).audio_3d })
    }
}

/// Room Configuration Data Block, defined in section 7.5.15.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_room_configuration)]
#[cfg(feature = "v0_2")]
#[cfg_attr(
    feature = "v0_3",
    deprecated(since = "0.3.0", note = "use `RoomConfigurationBlock` instead")
)]
pub struct RoomConfiguration {
    pub speakers: SpeakerAllocation,
    pub speaker_count: ::std::os::raw::c_int,
    pub has_speaker_location_descriptors: bool,
    pub max_x: ::std::os::raw::c_int,
    pub max_y: ::std::os::raw::c_int,
    pub max_z: ::std::os::raw::c_int,
    pub display_x: f64,
    pub display_y: f64,
    pub display_z: f64,
}

/// Room Configuration Data Block, defined in section 7.5.15.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_room_configuration_block)]
#[cfg(feature = "v0_3")]
pub struct RoomConfigurationBlock {
    pub speakers: SpeakerAllocation,
    pub speaker_count: ::std::os::raw::c_int,
    pub has_speaker_location_descriptors: bool,
    pub max_x: ::std::os::raw::c_int,
    pub max_y: ::std::os::raw::c_int,
    pub max_z: ::std::os::raw::c_int,
    pub display_x: f64,
    pub display_y: f64,
    pub display_z: f64,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_speaker_placement)]
#[repr(u32)]
#[cfg(any(feature = "v0_2", feature = "v0_3"))]
pub enum SpeakerPlacement {
    FL = ffi::cta::di_cta_speaker_placement_DI_CTA_SPEAKER_PLACEMENT_FL,
    FR = ffi::cta::di_cta_speaker_placement_DI_CTA_SPEAKER_PLACEMENT_FR,
    FC = ffi::cta::di_cta_speaker_placement_DI_CTA_SPEAKER_PLACEMENT_FC,
    LFE1 = ffi::cta::di_cta_speaker_placement_DI_CTA_SPEAKER_PLACEMENT_LFE1,
    BL = ffi::cta::di_cta_speaker_placement_DI_CTA_SPEAKER_PLACEMENT_BL,
    BR = ffi::cta::di_cta_speaker_placement_DI_CTA_SPEAKER_PLACEMENT_BR,
    FLC = ffi::cta::di_cta_speaker_placement_DI_CTA_SPEAKER_PLACEMENT_FLC,
    FRC = ffi::cta::di_cta_speaker_placement_DI_CTA_SPEAKER_PLACEMENT_FRC,
    BC = ffi::cta::di_cta_speaker_placement_DI_CTA_SPEAKER_PLACEMENT_BC,
    LFE2 = ffi::cta::di_cta_speaker_placement_DI_CTA_SPEAKER_PLACEMENT_LFE2,
    SIL = ffi::cta::di_cta_speaker_placement_DI_CTA_SPEAKER_PLACEMENT_SIL,
    SIR = ffi::cta::di_cta_speaker_placement_DI_CTA_SPEAKER_PLACEMENT_SIR,
    TPFL = ffi::cta::di_cta_speaker_placement_DI_CTA_SPEAKER_PLACEMENT_TPFL,
    TPFR = ffi::cta::di_cta_speaker_placement_DI_CTA_SPEAKER_PLACEMENT_TPFR,
    TPFC = ffi::cta::di_cta_speaker_placement_DI_CTA_SPEAKER_PLACEMENT_TPFC,
    TPC = ffi::cta::di_cta_speaker_placement_DI_CTA_SPEAKER_PLACEMENT_TPC,
    TPBL = ffi::cta::di_cta_speaker_placement_DI_CTA_SPEAKER_PLACEMENT_TPBL,
    TPBR = ffi::cta::di_cta_speaker_placement_DI_CTA_SPEAKER_PLACEMENT_TPBR,
    TPSIL = ffi::cta::di_cta_speaker_placement_DI_CTA_SPEAKER_PLACEMENT_TPSIL,
    TPSIR = ffi::cta::di_cta_speaker_placement_DI_CTA_SPEAKER_PLACEMENT_TPSIR,
    TPBC = ffi::cta::di_cta_speaker_placement_DI_CTA_SPEAKER_PLACEMENT_TPBC,
    BTFC = ffi::cta::di_cta_speaker_placement_DI_CTA_SPEAKER_PLACEMENT_BTFC,
    BTFL = ffi::cta::di_cta_speaker_placement_DI_CTA_SPEAKER_PLACEMENT_BTFL,
    BRFR = ffi::cta::di_cta_speaker_placement_DI_CTA_SPEAKER_PLACEMENT_BRFR,
    FLW = ffi::cta::di_cta_speaker_placement_DI_CTA_SPEAKER_PLACEMENT_FLW,
    FRW = ffi::cta::di_cta_speaker_placement_DI_CTA_SPEAKER_PLACEMENT_FRW,
    LS = ffi::cta::di_cta_speaker_placement_DI_CTA_SPEAKER_PLACEMENT_LS,
    RS = ffi::cta::di_cta_speaker_placement_DI_CTA_SPEAKER_PLACEMENT_RS,
}

/// Speaker Location Data Block, defined in section 7.5.16.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_speaker_locations)]
#[cfg(feature = "v0_2")]
#[cfg_attr(
    feature = "v0_3",
    deprecated(since = "0.3.0", note = "use `SpeakerLocationBlock` instead")
)]
pub struct SpeakerLocations {
    pub channel_index: ::std::os::raw::c_int,
    pub is_active: bool,
    pub has_coords: bool,
    pub x: f64,
    pub y: f64,
    pub z: f64,
    pub speaker_id: SpeakerPlacement,
}

/// Speaker Location Descriptor, defined in section 7.5.16.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_speaker_location_descriptor)]
#[cfg(feature = "v0_3")]
pub struct SpeakerLocationDescriptor {
    pub channel_index: ::std::os::raw::c_int,
    pub is_active: bool,
    pub has_coords: bool,
    pub x: f64,
    pub y: f64,
    pub z: f64,
    pub speaker_id: SpeakerPlacement,
}

/// Speaker Location Data Block, defined in section 7.5.16.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_speaker_location_block)]
#[wrap]
#[cfg(feature = "v0_3")]
pub struct SpeakerLocationBlock {}

#[cfg(feature = "v0_3")]
impl SpeakerLocationBlockRef {
    /// Get an array of speaker location descriptors.
    pub fn locations(&self) -> impl Iterator<Item = SpeakerLocationDescriptor> {
        FFIIter::new(unsafe { (*self.0).locations })
    }
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_svr_type)]
#[repr(u32)]
#[cfg(any(feature = "v0_2", feature = "v0_3"))]
pub enum SvrType {
    VIC = ffi::cta::di_cta_svr_type_DI_CTA_SVR_TYPE_VIC,
    DtdIndex = ffi::cta::di_cta_svr_type_DI_CTA_SVR_TYPE_DTD_INDEX,
    T7T10VTDB = ffi::cta::di_cta_svr_type_DI_CTA_SVR_TYPE_T7T10VTDB,
    FirstT8vtdb = ffi::cta::di_cta_svr_type_DI_CTA_SVR_TYPE_FIRST_T8VTDB,
}

/// Short Video Reference, defined in section 7.5.12.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_svr)]
#[cfg(any(feature = "v0_2", feature = "v0_3"))]
pub struct Svr {
    pub type_: SvrType,
    pub vic: u8,
    pub dtd_index: u8,
    pub t7_t10_vtdb_index: u8,
}
/// A HDMI video format, not to be confused with a CTA-861 video format.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_hdmi_video_format)]
#[cfg(feature = "v0_3")]
pub struct HdmiVideoFormat {
    pub vic: u8,
    pub h_active: i32,
    pub v_active: i32,
    pub h_front: i32,
    pub v_front: i32,
    pub h_sync: i32,
    pub v_sync: i32,
    pub h_back: i32,
    pub v_back: i32,
    pub pixel_clock_hz: i64,
}

#[cfg(feature = "v0_3")]
impl HdmiVideoFormat {
    /// Get a HDMI video format from a HDMI VIC.
    ///
    /// Returns `None` if the HDMI VIC is unknown.
    pub fn from_vic(hdmi_vic: u8) -> Option<Self> {
        HdmiVideoFormat::from_ptr(unsafe {
            ffi::cta::di_cta_hdmi_video_format_from_hdmi_vic(hdmi_vic)
        })
    }
}

/// HDR10+ Vendor-Specific Video Data Block
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_hdr10plus_block)]
#[cfg(feature = "v0_3")]
pub struct HDR10PlusBlock {
    pub version: ::std::os::raw::c_int,
    pub peak_lum: ::std::os::raw::c_int,
    pub ff_peak_lum: ::std::os::raw::c_int,
}

/// Dolby Video Colorimetry
#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_dolby_video_colorimetry)]
#[repr(u32)]
#[cfg(feature = "v0_3")]
pub enum DolbyVideoColorimetry {
    BT709 = ffi::cta::di_cta_dolby_video_colorimetry_DI_CTA_DOLBY_VIDEO_COLORIMETRY_BT_709,
    P3D65 = ffi::cta::di_cta_dolby_video_colorimetry_DI_CTA_DOLBY_VIDEO_COLORIMETRY_P3_D65,
}

/// Dolby Video YUV 4:4:4 support
#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_dolby_video_yuv444)]
#[repr(u32)]
#[cfg(feature = "v0_3")]
pub enum DolbyVideoYuv444 {
    None = ffi::cta::di_cta_dolby_video_yuv444_DI_CTA_DOLBY_VIDEO_YUV444_NONE,
    _10Bits = ffi::cta::di_cta_dolby_video_yuv444_DI_CTA_DOLBY_VIDEO_YUV444_10_BITS,
    _12Bits = ffi::cta::di_cta_dolby_video_yuv444_DI_CTA_DOLBY_VIDEO_YUV444_12_BITS,
}

/// Dolby Video Version 0 Data
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_dolby_video_block_v0)]
#[cfg(feature = "v0_3")]
pub struct DolbyVideoBlockV0 {
    pub yuv422_12bit: bool,
    pub global_dimming: bool,
    pub supports_2160p60: bool,
    pub dynamic_metadata_version_major: i32,
    pub dynamic_metadata_version_minor: i32,
    pub target_pq_12b_level_min: i32,
    pub target_pq_12b_level_max: i32,
    pub red_x: f64,
    pub red_y: f64,
    pub green_x: f64,
    pub green_y: f64,
    pub blue_x: f64,
    pub blue_y: f64,
    pub white_x: f64,
    pub white_y: f64,
}

/// Dolby Video Version 1 Data
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_dolby_video_block_v1)]
#[cfg(feature = "v0_3")]
pub struct DolbyVideoBlockV1 {
    pub yuv422_12bit: bool,
    pub global_dimming: bool,
    pub supports_2160p60: bool,
    pub dynamic_metadata_version: i32,
    pub colorimetry: DolbyVideoColorimetry,
    pub target_luminance_min: f64,
    pub target_luminance_max: f64,
    pub mode_low_latency: bool,
    pub unique_primaries: bool,
    pub red_x: f64,
    pub red_y: f64,
    pub green_x: f64,
    pub green_y: f64,
    pub blue_x: f64,
    pub blue_y: f64,
}

/// Dolby Video Version 2 Data
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_dolby_video_block_v2)]
#[cfg(feature = "v0_3")]
pub struct DolbyVideoBlockV2 {
    pub yuv422_12bit: bool,
    pub global_dimming: bool,
    pub dynamic_metadata_version: i32,
    pub backlight_control: bool,
    pub backlight_luminance_min: f64,
    pub mode_standard: bool,
    pub mode_low_latency_hdmi: bool,
    pub yuv444: DolbyVideoYuv444,
    pub target_pq_12b_level_min: i32,
    pub target_pq_12b_level_max: i32,
    pub red_x: f64,
    pub red_y: f64,
    pub green_x: f64,
    pub green_y: f64,
    pub blue_x: f64,
    pub blue_y: f64,
}

/// Dolby Video Data Block version
#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_dolby_video_version)]
#[repr(u32)]
#[cfg(feature = "v0_3")]
pub enum DolbyVideoVersion {
    Version0 = ffi::cta::di_cta_dolby_video_version_DI_CTA_DOLBY_VIDEO_VERSION0,
    Version1 = ffi::cta::di_cta_dolby_video_version_DI_CTA_DOLBY_VIDEO_VERSION1,
    Version2 = ffi::cta::di_cta_dolby_video_version_DI_CTA_DOLBY_VIDEO_VERSION2,
}

/// Dolby Video Data Block
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_dolby_video_block)]
#[cfg(feature = "v0_3")]
pub struct DolbyVideoBlock {
    pub version: DolbyVideoVersion,
    #[ptr_deref]
    pub v0: Option<DolbyVideoBlockV0>,
    #[ptr_deref]
    pub v1: Option<DolbyVideoBlockV1>,
    #[ptr_deref]
    pub v2: Option<DolbyVideoBlockV2>,
}

/// Type VII Video Timing Data Block, defined in section 7.5.17.1
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_type_vii_timing_block)]
#[cfg(feature = "v0_3")]
pub struct VIITimingBlock {
    #[cast_as(*const ffi::displayid::di_displayid_type_i_ii_vii_timing)]
    #[ptr_deref]
    pub timing: Option<crate::displayid::TypeIIIVIITiming>,
}

/// HDMI vendor-specific data block.
///
/// This block is defined in HDMI 1.4b section 8.3.2.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_vendor_hdmi_block)]
#[cfg(feature = "v0_3")]
#[wrap]
pub struct VendorHdmiBlock {
    pub source_phys_addr: u16,
    pub supports_ai: bool,
    pub supports_dc_48bit: bool,
    pub supports_dc_36bit: bool,
    pub supports_dc_30bit: bool,
    pub supports_dc_y444: bool,
    pub supports_dvi_dual: bool,
    pub max_tmds_clock: ::std::os::raw::c_int,
    pub supports_content_graphics: bool,
    pub supports_content_photo: bool,
    pub supports_content_cinema: bool,
    pub supports_content_game: bool,
    /// If !has_latency and !has_interlaced_latency, we have no latency
    /// information at all.
    ///
    /// If only has_latency, video/audio latency fields are valid and
    /// should be used for both progressive and interlaced video/audio
    /// formats.
    ///
    /// If both are valid, it means that video_latency and audio_latency
    /// should be used for progressive video/audio formats, and their
    /// interlaced counterpart for interlaced formats.
    pub has_latency: bool,
    pub has_interlaced_latency: bool,
    pub supports_progressive_video: bool,
    pub supports_progressive_audio: bool,
    pub supports_interlaced_video: bool,
    pub supports_interlaced_audio: bool,
    pub progressive_video_latency: ::std::os::raw::c_int,
    pub progressive_audio_latency: ::std::os::raw::c_int,
    pub interlaced_video_latency: ::std::os::raw::c_int,
    pub interlaced_audio_latency: ::std::os::raw::c_int,
}

#[cfg(feature = "v0_3")]
impl VendorHdmiBlockRef {
    /// Get the vics from the hdmi block.
    pub fn vics(&self) -> &[u8] {
        unsafe { std::slice::from_raw_parts((*self.0).vics, (*self.0).vics_len) }
    }
}

/// Fixed Rate Link (FRL) support.
#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_hdmi_frl)]
#[repr(u32)]
#[cfg(feature = "v0_3")]
pub enum HdmiFrl {
    Unsupported = ffi::cta::di_cta_hdmi_frl_DI_CTA_HDMI_FRL_UNSUPPORTED,
    _3GBps3Lanes = ffi::cta::di_cta_hdmi_frl_DI_CTA_HDMI_FRL_3GBPS_3LANES,
    _6GBps3Lanes = ffi::cta::di_cta_hdmi_frl_DI_CTA_HDMI_FRL_6GBPS_3LANES,
    _6GBps4Lanes = ffi::cta::di_cta_hdmi_frl_DI_CTA_HDMI_FRL_6GBPS_4LANES,
    _8GBps4Lanes = ffi::cta::di_cta_hdmi_frl_DI_CTA_HDMI_FRL_8GBPS_4LANES,
    _10GBps4Lanes = ffi::cta::di_cta_hdmi_frl_DI_CTA_HDMI_FRL_10GBPS_4LANES,
    _12GBps4Lanes = ffi::cta::di_cta_hdmi_frl_DI_CTA_HDMI_FRL_12GBPS_4LANES,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, FFIFrom)]
#[ffi(ffi::cta::di_cta_hdmi_dsc_max_slices)]
#[repr(u32)]
#[cfg(feature = "v0_3")]
pub enum HdmiDscMaxSlices {
    Unsupported = ffi::cta::di_cta_hdmi_dsc_max_slices_DI_CTA_HDMI_DSC_MAX_SLICES_UNSUPPORTED,
    _1_340MHZ = ffi::cta::di_cta_hdmi_dsc_max_slices_DI_CTA_HDMI_DSC_MAX_SLICES_1_340MHZ,
    _2_340MHZ = ffi::cta::di_cta_hdmi_dsc_max_slices_DI_CTA_HDMI_DSC_MAX_SLICES_2_340MHZ,
    _4_340MHZ = ffi::cta::di_cta_hdmi_dsc_max_slices_DI_CTA_HDMI_DSC_MAX_SLICES_4_340MHZ,
    _8_340MHZ = ffi::cta::di_cta_hdmi_dsc_max_slices_DI_CTA_HDMI_DSC_MAX_SLICES_8_340MHZ,
    _8_400MHZ = ffi::cta::di_cta_hdmi_dsc_max_slices_DI_CTA_HDMI_DSC_MAX_SLICES_8_400MHZ,
    _12_400MHZ = ffi::cta::di_cta_hdmi_dsc_max_slices_DI_CTA_HDMI_DSC_MAX_SLICES_12_400MHZ,
    _16_400MHZ = ffi::cta::di_cta_hdmi_dsc_max_slices_DI_CTA_HDMI_DSC_MAX_SLICES_16_400MHZ,
}

/// Display Stream Compression (DSC) support.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_hdmi_dsc)]
#[cfg(feature = "v0_3")]
pub struct HdmiDsc {
    pub supports_10bpc: bool,
    pub supports_12bpc: bool,
    pub supports_all_bpc: bool,
    pub supports_native_420: bool,
    pub max_slices: HdmiDscMaxSlices,
    pub max_frl_rate: HdmiFrl,
    pub max_total_chunk_bytes: i32,
}

/// HDMI Sink Capability Data Structure (SCDS).
///
/// This data is exposed via HDMI Forum Vendor-Specific Data Block (HF-VSDB) or
/// the HDMI Forum Sink Capability Data Block (HF-SCDB).
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_hdmi_scds)]
#[cfg(feature = "v0_3")]
pub struct HdmiScds {
    pub version: ::std::os::raw::c_int,
    pub max_tmds_char_rate_mhz: ::std::os::raw::c_int,
    pub supports_3d_osd_disparity: bool,
    pub supports_3d_dual_view: bool,
    pub supports_3d_independent_view: bool,
    pub supports_lte_340mcsc_scramble: bool,
    pub supports_ccbpci: bool,
    pub supports_cable_status: bool,
    pub supports_scdc_read_request: bool,
    pub supports_scdc: bool,
    pub supports_dc_30bit_420: bool,
    pub supports_dc_36bit_420: bool,
    pub supports_dc_48bit_420: bool,
    pub supports_uhd_vic: bool,
    pub max_frl_rate: HdmiFrl,
    pub supports_fapa_start_location: bool,
    pub supports_allm: bool,
    pub supports_fva: bool,
    pub supports_neg_mvrr: bool,
    pub supports_cinema_vrr: bool,
    pub m_delta: bool,
    pub supports_qms: bool,
    pub supports_fapa_end_extended: bool,
    pub vrr_min_hz: ::std::os::raw::c_int,
    pub vrr_max_hz: ::std::os::raw::c_int,
    pub qms_tfr_min: bool,
    pub qms_tfr_max: bool,
    #[ptr_deref]
    pub dsc: Option<HdmiDsc>,
}

/// HDMI Forum vendor-specific data block (HF-VSDB).
///
/// This block is defined in HDMI 2.1 section 10.3.2.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_vendor_hdmi_forum_block)]
#[cfg(feature = "v0_3")]
pub struct VendorHdmiForumBlock {
    pub scds: HdmiScds,
}

/// HDMI Forum Sink Capability Data Block (HF-SCDB).
///
/// This block is defined in HDMI 2.1a
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_hdmi_forum_sink_cap)]
#[cfg(feature = "v0_3")]
pub struct HdmiForumSinkCap {
    pub scds: HdmiScds,
}

/// Video Format Preference Data Block, defined in section 7.5.12.
#[derive(Debug, Copy, Clone, FFIFrom)]
#[ffi(ffi::cta::di_cta_video_format_pref_block)]
#[wrap]
#[cfg(feature = "v0_3")]
pub struct VideoFormatPrefBlock {}

#[cfg(feature = "v0_3")]
impl VideoFormatPrefBlockRef {
    /// Get the svrs of the pref block
    pub fn svrs(&self) -> impl Iterator<Item = Svr> {
        FFIIter::new(unsafe { (*self.0).svrs })
    }
}