Skip to content

Commit

Permalink
control: Add support for compound types
Browse files Browse the repository at this point in the history
  • Loading branch information
Detlev Casanova authored and raymanfx committed Jul 25, 2021
1 parent 0c5d30d commit 3f158d8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ pub enum Value {
Integer(i64),
Boolean(bool),
String(String),
/* compound (matrix) values */
CompoundU8(Vec<u8>),
CompoundU16(Vec<u16>),
CompoundU32(Vec<u32>),
CompoundPtr(Vec<u8>),
}

impl TryInto<v4l2_control> for Control {
Expand Down
16 changes: 16 additions & 0 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,22 @@ impl Device {
control.__bindgen_anon_1.string = val.as_ptr() as *mut i8;
control.size = val.len() as u32;
}
control::Value::CompoundU8(ref val) => {
control.__bindgen_anon_1.p_u8 = val.as_ptr() as *mut u8;
control.size = (val.len() * std::mem::size_of::<u8>()) as u32;
}
control::Value::CompoundU16(ref val) => {
control.__bindgen_anon_1.p_u16 = val.as_ptr() as *mut u16;
control.size = (val.len() * std::mem::size_of::<u16>()) as u32;
}
control::Value::CompoundU32(ref val) => {
control.__bindgen_anon_1.p_u32 = val.as_ptr() as *mut u32;
control.size = (val.len() * std::mem::size_of::<u32>()) as u32;
}
control::Value::CompoundPtr(ref val) => {
control.__bindgen_anon_1.ptr = val.as_ptr() as *mut std::os::raw::c_void;
control.size = (val.len() * std::mem::size_of::<u8>()) as u32;
}
};

control_list.push(control);
Expand Down

0 comments on commit 3f158d8

Please sign in to comment.