Skip to content

Commit

Permalink
maybe
Browse files Browse the repository at this point in the history
  • Loading branch information
fishrockz committed Jan 26, 2025
1 parent f1f4637 commit 97c9099
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libcamera/src/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ impl<'d> Camera<'d> {
.unwrap()
}

pub fn controls_basic(&self) -> ControlInfoMap {
unsafe { ControlInfoMap::from_ptr_basic(*libcamera_camera_controls(self.ptr.as_ptr())) }
}
/// Returns a list of available camera controls and their limit.
pub fn controls(&self) -> &ControlInfoMap {
unsafe {
Expand Down
5 changes: 5 additions & 0 deletions libcamera/src/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ impl ControlInfo {
pub struct ControlInfoMap(libcamera_control_info_map_t);

impl ControlInfoMap {
pub(crate) unsafe fn from_ptr_basic<'a>(ptr: libcamera_control_info_map_t) -> Self {
// Safety: we can cast it because of `#[repr(transparent)]`
Self(ptr)
}

pub(crate) unsafe fn from_ptr<'a>(ptr: NonNull<libcamera_control_info_map_t>) -> &'a mut Self {
// Safety: we can cast it because of `#[repr(transparent)]`
&mut *(ptr.as_ptr() as *mut Self)
Expand Down

0 comments on commit 97c9099

Please sign in to comment.