Skip to content

Put Device and Master methods into traits. #2

@trissylegs

Description

@trissylegs

Rationale

1. Cards have been split.

There are now three kinds of Drm devices. card, render and control nodes. A typical setup might look like this:

$ ls /dev/dri
card0
controlD64
renderD128

(From memory, not running Linux right now. Mine also has another for my discrete card)

We can split some things into control, some things into render (and leave somethings on both).

2. There are multiple ways of getting and interacting with devices that have different semantics.

If you are root, you can open the device and call DRM_SET_MASTER to get full mode-setting capabilities, or you might open it, use x11 or wayland to computicate auth_magic and convert a card to a auth'd card,
or open render directly.

Design:

pub trait Card {
    unsafe fn ioctl<T:DrmIoctl>(&self, arg: &mut T) -> io::Result<()>;

    fn version(&self) -> io::Result<Version> {
        // Done for you
    }
    // more
}

pub trait Render: Card {
    fn create_dumbbuf(&self) -> Result<DumbBuf>;
    // etc.
}

pub trait Control: Card {
    fn set_crtc(&self, 
        crtc: Id<Crtc>, 
        fb: Option<Id<Fb>>, 
        x: u32, y: u32, 
        connectors: &[Id<Connector>],
}

This does expose ioctl and DrmIoctl, but I did plan on doing that anyway.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions