Skip to content

Commit

Permalink
Reimplement gamma functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Drakulix authored and Slabity committed May 16, 2019
1 parent 9929f98 commit 664678f
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/control/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,50 @@ pub trait Device: super::Device {

Ok(prop_val_set)
}

/// Receive the currently set gamma ramp of a crtc
fn get_gamma(&self, crtc: crtc::Handle, red: &mut [u16], green: &mut [u16], blue: &mut [u16]) -> Result<(), SystemError> {
let crtc_info = self.get_crtc(crtc)?;
if crtc_info.gamma_length as usize > red.len() ||
crtc_info.gamma_length as usize > green.len() ||
crtc_info.gamma_length as usize > blue.len()
{
return Err(SystemError::InvalidArgument);
}

ffi::mode::get_gamma(
self.as_raw_fd(),
crtc.as_ref().get(),
crtc_info.gamma_length as usize,
red,
green,
blue
)?;

Ok(())
}

/// Set a gamma ramp for the given crtc
fn set_gamma(&self, crtc: crtc::Handle, red: &[u16], green: &[u16], blue: &[u16]) -> Result<(), SystemError> {
let crtc_info = self.get_crtc(crtc)?;
if crtc_info.gamma_length as usize > red.len() ||
crtc_info.gamma_length as usize > green.len() ||
crtc_info.gamma_length as usize > blue.len()
{
return Err(SystemError::InvalidArgument);
}

ffi::mode::set_gamma(
self.as_raw_fd(),
crtc.as_ref().get(),
crtc_info.gamma_length as usize,
red,
green,
blue
)?;

Ok(())
}
}

/// The set of [ResourceHandles](ResourceHandle.t.html) that a
Expand Down

0 comments on commit 664678f

Please sign in to comment.