1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-12-15 19:23:01 +03:00
mobile-nixos/boot/init/tasks/graphics.rb
2021-01-25 18:40:50 -05:00

66 lines
1.3 KiB
Ruby

# Ensures graphics have been initialized and are ready to be used.
class Tasks::Graphics < SingletonTask
def initialize()
add_dependency(
:Any,
Dependencies::Task.new(FBDev.instance),
Dependencies::Task.new(DRM.instance),
)
# Make the Graphics target depend on this task.
Targets[:Graphics].add_dependency(:Task, self)
end
def run()
# no-op
end
def ux_priority()
-100
end
end
# Handles the "legacy fbdev" style of framebuffers.
class Tasks::Graphics::FBDev < SingletonTask
def initialize()
add_dependency(
:Files,
"/sys/class/graphics/fb0/mode",
"/sys/class/graphics/fb0/modes",
)
# This is only incidental to the fact that /dev/fb0 wouldn't exist for
# users of the "Graphics" dependency.
add_dependency(:Mount, "/dev")
end
def run()
mode = File.read("/sys/class/graphics/fb0/modes")
log("Setting framebuffer mode to: #{mode}")
System.write("/sys/class/graphics/fb0/mode", mode)
end
def ux_priority()
-100
end
end
# Handles DRM
# (Does nothing, only handles dependencies)
class Tasks::Graphics::DRM < SingletonTask
def initialize()
add_dependency(
:Files,
"/dev/dri/card0",
)
add_dependency(:Mount, "/dev")
end
def run()
# no-op
end
def ux_priority()
-100
end
end