5f5eec1c49
Per local/AGENTS.md Rule 2 (NO OVERLAY-STYLE PATCHES — AMENDED 2026), big external projects must NOT have source forks in local/sources/. libdrm's Red Bear edits now live as external patches in local/patches/libdrm/, matching the established pipewire and wireplumber migration pattern (commits8ff9da2ff,722f0c452). The 5 patches were recovered from git history (commit 89d1306c8^ — the migration that deleted them) and renamed to the modern Rule 2 NN-prefix naming for lexical-order application: 01-drm-ioctl-bridge.patch (P1 from old series, 278 lines) 02-ioctl-response-sizes.patch (P1 from old series, 30 lines) 03-drm-get-pci-info.patch (P2 from old series, 153 lines) 04-drm-get-version-driver-name.patch (P3 from old series, 34 lines) 05-drmGetDeviceFromDevId-redox.patch (P4 from old series, 68 lines) These patches add the Redox-side ioctl/ioctl-com and scheme: dispatch path needed by redox-drm and Mesa radeonsi/iris. The recipe now points at upstream libdrm 2.4.125 (https://gitlab.freedesktop.org/mesa/libdrm, tag libdrm-2.4.125) and applies the patches via a [source].script hook (the cookbook's "Optional script to run to prepare the source" field) with a REDBEAR_PATCHES_DIR computed from COOKBOOK_RECIPE. Fixes the broken state where the recipe referenced the now-deleted local/sources/libdrm/ fork.
69 lines
2.8 KiB
Diff
69 lines
2.8 KiB
Diff
diff --git a/xf86drm.c b/xf86drm.c
|
|
index c3904caa3..306026e8b 100644
|
|
--- a/xf86drm.c
|
|
+++ b/xf86drm.c
|
|
@@ -4096 +4096 @@ static int drmParseSubsystemType(int maj, int min)
|
|
-#elif defined(__OpenBSD__) || defined(__DragonFly__) || defined(__FreeBSD__)
|
|
+#elif defined(__OpenBSD__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__redox__)
|
|
@@ -5122,0 +5123,60 @@ drm_public int drmGetDeviceFromDevId(dev_t find_rdev, uint32_t flags, drmDeviceP
|
|
+ return 0;
|
|
+#elif defined(__redox__)
|
|
+ /* On Redox there is no /dev/dri/ directory to enumerate.
|
|
+ * Instead, open /scheme/drm/card0 and query PCI info to
|
|
+ * construct a single drmDevice that serves as both primary
|
|
+ * and render node. */
|
|
+ drmDevicePtr devp;
|
|
+ char *pptr;
|
|
+ int max_node_length = 64, i;
|
|
+ size_t extra, psize;
|
|
+ uint8_t pbuf[22];
|
|
+ size_t prsize = 0;
|
|
+ int pret, fd;
|
|
+
|
|
+ if (device == NULL)
|
|
+ return -EINVAL;
|
|
+ if (drm_device_validate_flags(flags))
|
|
+ return -EINVAL;
|
|
+
|
|
+ fd = open("/scheme/drm/card0", O_RDWR | O_CLOEXEC);
|
|
+ if (fd < 0)
|
|
+ return -errno;
|
|
+
|
|
+ pret = redox_drm_exchange(fd, REDOX_DRM_IOCTL_GET_PCI_INFO, NULL, 0,
|
|
+ pbuf, sizeof(pbuf), &prsize);
|
|
+ close(fd);
|
|
+ if (pret != 0 || prsize < 17)
|
|
+ return -EIO;
|
|
+
|
|
+ extra = DRM_NODE_MAX * (sizeof(void *) + max_node_length);
|
|
+ psize = sizeof(drmDevice) + extra + sizeof(drmPciBusInfo) + sizeof(drmPciDeviceInfo);
|
|
+ devp = calloc(1, psize);
|
|
+ if (!devp)
|
|
+ return -ENOMEM;
|
|
+
|
|
+ devp->bustype = DRM_BUS_PCI;
|
|
+ /* Advertise both PRIMARY and RENDER — same path on Redox */
|
|
+ devp->available_nodes = (1 << DRM_NODE_PRIMARY) | (1 << DRM_NODE_RENDER);
|
|
+ pptr = (char *)devp + sizeof(drmDevice);
|
|
+ devp->nodes = (char **)pptr;
|
|
+ pptr += DRM_NODE_MAX * sizeof(void *);
|
|
+ for (i = 0; i < DRM_NODE_MAX; i++) { devp->nodes[i] = pptr; pptr += max_node_length; }
|
|
+ snprintf(devp->nodes[DRM_NODE_PRIMARY], max_node_length, "/scheme/drm/card0");
|
|
+ snprintf(devp->nodes[DRM_NODE_RENDER], max_node_length, "/scheme/drm/card0");
|
|
+
|
|
+ devp->businfo.pci = (drmPciBusInfoPtr)pptr;
|
|
+ pptr += sizeof(drmPciBusInfo);
|
|
+ devp->businfo.pci->domain = pbuf[10] | (pbuf[11] << 8) | (pbuf[12] << 16) | (pbuf[13] << 24);
|
|
+ devp->businfo.pci->bus = pbuf[14];
|
|
+ devp->businfo.pci->dev = pbuf[15];
|
|
+ devp->businfo.pci->func = pbuf[16];
|
|
+
|
|
+ devp->deviceinfo.pci = (drmPciDeviceInfoPtr)pptr;
|
|
+ devp->deviceinfo.pci->vendor_id = pbuf[0] | (pbuf[1] << 8);
|
|
+ devp->deviceinfo.pci->device_id = pbuf[2] | (pbuf[3] << 8);
|
|
+ devp->deviceinfo.pci->subvendor_id = pbuf[4] | (pbuf[5] << 8);
|
|
+ devp->deviceinfo.pci->subdevice_id = pbuf[6] | (pbuf[7] << 8);
|
|
+ devp->deviceinfo.pci->revision_id = pbuf[8];
|
|
+
|
|
+ *device = devp;
|