forked from Gnurou/v4l2r
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add utility to work around bindgen bug 753
rust-lang/rust-bindgen#753 As a result all V4L2_FWHT_FL_* macros have no bindings generated for them. The github issue describes a suggested workaround, which is applied in this patch which adds a dedicated "runbindgen" utility, and is centered around using a wrapper C header file for the problematic header and defining a custom parse callback. This works for _BITUL(), but unfortunately not for GENMASK() found in v4l2-controls.h, which is included from videodev2.h. However, there are just 2 invocations of GENMASK, so in the fix753.h wrapper we can #undef the 2 masks and define them manually. To generate bindings - inside runbindgen directory: cargo run -- -o ../videodev2_64.rs -I /path/to/kerneldir/usr/include/ cargo run -- -o ../videodev2_32.rs -I /path/to/kerneldir/usr/include/ -s /usr/i686-linux-gnu/ -t i686-linux-gnu
- Loading branch information
Showing
8 changed files
with
9,653 additions
and
2,539 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
members = [ | ||
"lib", | ||
"ffi", | ||
"lib/src/bindings/runbindgen", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "runbindgen" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
bindgen = "0.63.0" | ||
clap = { version = "4.0", features = ["derive"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#undef V4L2_FWHT_FL_COMPONENTS_NUM_MSK | ||
#undef V4L2_FWHT_FL_PIXENC_MSK | ||
|
||
MARK_FIX_753(V4L2_FWHT_FL_IS_INTERLACED); | ||
MARK_FIX_753(V4L2_FWHT_FL_IS_BOTTOM_FIRST); | ||
MARK_FIX_753(V4L2_FWHT_FL_IS_ALTERNATE); | ||
MARK_FIX_753(V4L2_FWHT_FL_IS_BOTTOM_FIELD); | ||
MARK_FIX_753(V4L2_FWHT_FL_LUMA_IS_UNCOMPRESSED); | ||
MARK_FIX_753(V4L2_FWHT_FL_CB_IS_UNCOMPRESSED); | ||
MARK_FIX_753(V4L2_FWHT_FL_CR_IS_UNCOMPRESSED); | ||
MARK_FIX_753(V4L2_FWHT_FL_CHROMA_FULL_HEIGHT); | ||
MARK_FIX_753(V4L2_FWHT_FL_CHROMA_FULL_WIDTH); | ||
MARK_FIX_753(V4L2_FWHT_FL_ALPHA_IS_UNCOMPRESSED); | ||
MARK_FIX_753(V4L2_FWHT_FL_I_FRAME); | ||
|
||
#define V4L2_FWHT_FL_COMPONENTS_NUM_MSK (7 << V4L2_FWHT_FL_COMPONENTS_NUM_OFFSET) | ||
#define V4L2_FWHT_FL_PIXENC_MSK (3 << V4L2_FWHT_FL_PIXENC_OFFSET) |
Oops, something went wrong.