# \[ANN\] libdrm - OCaml bindings for Linux mode setting, etc

**URL:** <https://discuss.ocaml.org/t/ann-libdrm-ocaml-bindings-for-linux-mode-setting-etc/17497>\
**Category:** Community\
**Tags:** announce\
**Created:** [November 16, 2025, 5:23pm UTC](https://discuss.ocaml.org/t/ann-libdrm-ocaml-bindings-for-linux-mode-setting-etc/17497 "2025-11-16T17:23:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![talex5](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/talex5/32/353_2.png) [@talex5](https://discuss.ocaml.org/u/talex5)\
**Post date:** [November 16, 2025, 5:23pm UTC](https://discuss.ocaml.org/t/ann-libdrm-ocaml-bindings-for-linux-mode-setting-etc/17497/1 "2025-11-16T17:23:53Z")

</div>

I’m pleased to announce the first release of [libdrm-ocaml](https://github.com/talex5/libdrm-ocaml) (OCaml bindings for the libdrm C library).

libdrm is used by applications such as Wayland compositors to control the physical graphics hardware.

For example, you can use the library to enumerate graphics devices:

```ocaml
utop # Drm.Device.list ();;
- : Drm.Device.Info.t list =
[{primary_node = Some "/dev/dri/card0";
  render_node = Some "/dev/dri/renderD128";
  info = PCI {bus = {domain = 0; bus = 1; dev = 0; func = 0};
              dev = {vendor_id = 0x1002;
                     device_id = 0x67ff;
                     subvendor_id = 0x1458;
                     subdevice_id = 0x230b;
                     revision_id = 0xff}}}]

utop # let dev = Unix.openfile "/dev/dri/card0" [O_CLOEXEC; O_RDWR] 0;;

utop # Drm.Device.Version.get dev;;
- : Drm.Device.Version.t =
{version = 3.61.0; name = "amdgpu"; date = "0"; desc = "AMD GPU"}

```

Here’s an excerpt configuring a hardware plane to present a framebuffer on a CRT controller:

```ocaml
plane.%{ K.Plane.fb_id } <- Some fb;
(* Source region on frame-buffer: *)
plane.%{ K.Plane.src_x } <- Drm.Ufixed.of_int 0;
plane.%{ K.Plane.src_y } <- Drm.Ufixed.of_int 0;
plane.%{ K.Plane.src_w } <- Drm.Ufixed.of_int (fst size);
plane.%{ K.Plane.src_h } <- Drm.Ufixed.of_int (snd size);
(* Destination region on CRTC: *)
plane.%{ K.Plane.crtc_x } <- 0;
plane.%{ K.Plane.crtc_y } <- 0;
plane.%{ K.Plane.crtc_w } <- fst size;
plane.%{ K.Plane.crtc_h } <- snd size;

```

For a proper tutorial, see [Linux mode setting, from the comfort of OCaml](https://roscidus.com/blog/blog/2025/11/16/libdrm-ocaml/).
