summaryrefslogtreecommitdiffstats
path: root/src/of_node.rs
diff options
context:
space:
mode:
authorAgathe Porte <microjoe@microjoe.org>2020-02-08 14:28:16 +0100
committerAgathe Porte <microjoe@microjoe.org>2020-02-08 14:28:16 +0100
commit9b1f700dc54cd1eb6dc73e3260b2c284ec91cca4 (patch)
tree9d407e0c951d04578afc442723563d5cc78c7cb3 /src/of_node.rs
parent61a61f3907e802f0be9bc0039a84ebaabba7b372 (diff)
downloadcharlcd-9b1f700dc54cd1eb6dc73e3260b2c284ec91cca4.tar.gz
charlcd-9b1f700dc54cd1eb6dc73e3260b2c284ec91cca4.zip
add width and height support (hack)
Diffstat (limited to 'src/of_node.rs')
-rw-r--r--src/of_node.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/of_node.rs b/src/of_node.rs
new file mode 100644
index 0000000..5dff2a0
--- /dev/null
+++ b/src/of_node.rs
@@ -0,0 +1,24 @@
+// This module is a hack to read additional information in the DT nodes in the
+// kernel to retrieve data that is currently not exposed in the charlcd.c
+// driver.
+
+use std::fs::File;
+use std::io::Result;
+
+use byteorder::{BigEndian, ReadBytesExt};
+
+fn read_u32_node(node_name: &str) -> Result<u32> {
+ let mut f = File::open(format!(
+ "/sys/devices/platform/auxdisplay/of_node/{}",
+ node_name
+ ))?;
+ Ok(f.read_u32::<BigEndian>()?)
+}
+
+pub fn display_height_chars() -> Result<u32> {
+ read_u32_node("display-height-chars")
+}
+
+pub fn display_width_chars() -> Result<u32> {
+ read_u32_node("display-width-chars")
+}