Skip to content

Commit

Permalink
Implement getting EDID data from MacOS directly.
Browse files Browse the repository at this point in the history
  • Loading branch information
haimgel committed Sep 21, 2020
1 parent d5050cf commit 575894e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::iokit::display::*;
use crate::iokit::io2c_interface::*;
use crate::iokit::wrappers::*;
use core_foundation::base::{kCFAllocatorDefault, CFType, TCFType};
use core_foundation::data::CFData;
use core_foundation::dictionary::CFDictionary;
use core_foundation::number::CFNumber;
use core_foundation::string::{CFString, CFStringRef};
Expand Down Expand Up @@ -121,6 +122,14 @@ impl Monitor {
.map(|name| unsafe { CFString::wrap_under_get_rule(*name as CFStringRef) }.to_string())
}

/// Returns EDID for this display as raw bytes data
pub fn edid(&self) -> Option<Vec<u8>> {
let info = Self::display_info_dict(&self.frame_buffer)?;
let display_product_name_key = CFString::from_static_string("IODisplayEDIDOriginal");
let edid_data = info.find(&display_product_name_key)?.downcast::<CFData>()?;
Some(edid_data.bytes().into())
}

/// CoreGraphics display handle for this monitor
pub fn handle(&self) -> CGDisplay {
self.monitor
Expand Down

0 comments on commit 575894e

Please sign in to comment.