{"id":18657029,"url":"https://github.com/smithay/drm-rs","last_synced_at":"2025-04-13T23:55:46.031Z","repository":{"id":38360416,"uuid":"91932227","full_name":"Smithay/drm-rs","owner":"Smithay","description":"A low-level abstraction of the Direct Rendering Manager API","archived":false,"fork":false,"pushed_at":"2024-11-04T23:20:00.000Z","size":697,"stargazers_count":88,"open_issues_count":16,"forks_count":54,"subscribers_count":12,"default_branch":"develop","last_synced_at":"2025-04-06T21:09:14.916Z","etag":null,"topics":["drm","gpu","rust"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Smithay.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-21T04:05:40.000Z","updated_at":"2025-03-12T08:02:55.000Z","dependencies_parsed_at":"2023-12-04T19:58:27.312Z","dependency_job_id":"ddd3e9a7-5cd5-4c65-9fcd-596739e7b9f5","html_url":"https://github.com/Smithay/drm-rs","commit_stats":{"total_commits":342,"total_committers":26,"mean_commits":"13.153846153846153","dds":0.6081871345029239,"last_synced_commit":"768cf2d640a4e387ad0ebc155aa6d2c110462b2b"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Smithay%2Fdrm-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Smithay%2Fdrm-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Smithay%2Fdrm-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Smithay%2Fdrm-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Smithay","download_url":"https://codeload.github.com/Smithay/drm-rs/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248799922,"owners_count":21163403,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["drm","gpu","rust"],"created_at":"2024-11-07T07:26:17.132Z","updated_at":"2025-04-13T23:55:46.000Z","avatar_url":"https://github.com/Smithay.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# drm-rs\n\n[![Crates.io](https://img.shields.io/crates/v/drm.svg)](https://crates.io/crates/drm)\n[![docs.rs](https://docs.rs/drm/badge.svg)](https://docs.rs/drm)\n[![Build Status](https://github.com/Smithay/drm-rs/actions/workflows/ci.yml/badge.svg)](https://github.com/Smithay/drm-rs/actions/workflows/ci.yml)\n\nA safe interface to the Direct Rendering Manager.\n\n## Direct Rendering Manager\n\nThe Direct Rendering Manager is a subsystem found on multiple Unix-based\noperating systems that provides a userspace API to graphics hardware.\nSee the [Wikipedia article](https://en.wikipedia.org/wiki/Direct_Rendering_Manager)\nfor more details.\n\n## Usage\n\n### Basic\n\nThe DRM is accessed using [ioctls](https://en.wikipedia.org/wiki/Ioctl)\non a file representing a graphics card. These can normally be\nfound in `/dev/dri`, but can also be opened in other ways (ex. udev).\n\nThis crate does not provide a method of opening these files. Instead, the\nuser program must provide a way to access the file descriptor representing the\ndevice through the [AsFd](https://doc.rust-lang.org/std/os/fd/trait.AsFd.html)\ntrait. Here is a basic example using `File` as a backend:\n\n```rust\n/// A simple wrapper for a device node.\npub struct Card(std::fs::File);\n\n/// Implementing [`AsFd`] is a prerequisite to implementing the traits found\n/// in this crate. Here, we are just calling [`File::as_fd()`] on the inner\n/// [`File`].\nimpl AsFd for Card {\n    fn as_fd(\u0026self) -\u003e BorrowedFd\u003c'_\u003e {\n        self.0.as_fd()\n    }\n}\n\n/// Simple helper methods for opening a `Card`.\nimpl Card {\n    pub fn open(path: \u0026str) -\u003e Self {\n        let mut options = std::fs::OpenOptions::new();\n        options.read(true);\n        options.write(true);\n        Card(options.open(path).unwrap())\n    }\n}\n```\n\nFinally, you can implement `drm::Device` to gain access to the basic DRM\nfunctionality:\n\n```rust\nimpl drm::Device for Card {}\n\nfn main() {\n    let gpu = Card::open(\"/dev/dri/card0\");\n    println!(\"{:#?}\", gpu.get_driver().unwrap());\n}\n```\n\n### Control (modesetting)\n\nSee [`drm::control::Device`](https://docs.rs/drm/*/drm/control/trait.Device.html)\nas well as our mode-setting examples: [`atomic_modeset`](https://github.com/Smithay/drm-rs/blob/develop/examples/atomic_modeset.rs)\nand [`legacy_modeset`](https://github.com/Smithay/drm-rs/blob/develop/examples/legacy_modeset.rs)\n\n### Rendering\n\nRendering is done by [creating](https://docs.rs/drm/*/drm/control/trait.Device.html#method.add_framebuffer) and\n[attaching](https://docs.rs/drm/*/drm/control/trait.Device.html#method.page_flip) [framebuffers](https://docs.rs/drm/*/drm/control/framebuffer/index.html)\nto [crtcs](https://docs.rs/drm/*/drm/control/crtc/index.html).\n\nA framebuffer is created from anything implementing [`Buffer`](https://docs.rs/drm/*/drm/buffer/trait.Buffer.html) like the always\navailable, but very limited, [`DumbBuffer`](https://docs.rs/drm/*/drm/control/dumbbuffer/struct.DumbBuffer.html).\n\nFor faster hardware-backed buffers, checkout [gbm.rs](https://github.com/Smithay/gbm.rs).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmithay%2Fdrm-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmithay%2Fdrm-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmithay%2Fdrm-rs/lists"}