Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ioctl: use the type field to determine FrmIvalTypes and FrmSizeTypes #39

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/src/ioctl/frameintervals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ pub enum FrmIvalTypes<'a> {

impl v4l2_frmivalenum {
/// Safely access the intervals member of the struct based on the
/// returned index.
/// returned type.
pub fn intervals(&self) -> Option<FrmIvalTypes> {
match self.index {
match self.type_ {
// SAFETY: the member of the union that gets used by the driver
// is determined by the index
// is determined by the type
bindings::v4l2_frmivaltypes_V4L2_FRMIVAL_TYPE_DISCRETE => {
Some(FrmIvalTypes::Discrete(unsafe {
&self.__bindgen_anon_1.discrete
}))
}

// SAFETY: the member of the union that gets used by the driver
// is determined by the index
// is determined by the type
bindings::v4l2_frmivaltypes_V4L2_FRMIVAL_TYPE_CONTINUOUS
| bindings::v4l2_frmivaltypes_V4L2_FRMIVAL_TYPE_STEPWISE => {
Some(FrmIvalTypes::StepWise(unsafe {
Expand Down
8 changes: 4 additions & 4 deletions lib/src/ioctl/framesizes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ pub enum FrmSizeTypes<'a> {

impl v4l2_frmsizeenum {
/// Safely access the size member of the struct based on the
/// returned index.
/// returned type.
pub fn size(&self) -> Option<FrmSizeTypes> {
match self.index {
match self.type_ {
// SAFETY: the member of the union that gets used by the driver
// is determined by the index
// is determined by the type
bindings::v4l2_frmsizetypes_V4L2_FRMSIZE_TYPE_DISCRETE => {
Some(FrmSizeTypes::Discrete(unsafe {
&self.__bindgen_anon_1.discrete
}))
}

// SAFETY: the member of the union that gets used by the driver
// is determined by the index
// is determined by the type
bindings::v4l2_frmsizetypes_V4L2_FRMSIZE_TYPE_CONTINUOUS
| bindings::v4l2_frmsizetypes_V4L2_FRMSIZE_TYPE_STEPWISE => {
Some(FrmSizeTypes::StepWise(unsafe {
Expand Down
Loading