#include <string.h>
#include <xf86drm.h>
#include <unistd.h>
+#include <fcntl.h>
#include "loader.h"
#include "target-helpers/drm_helper_public.h"
-#include "state_tracker/drm_driver.h"
+#include "frontend/drm_driver.h"
#include "pipe_loader_priv.h"
#include "util/u_memory.h"
{
.driver_name = "i915",
.create_screen = pipe_i915_create_screen,
- .configuration = pipe_default_configuration_query,
+ },
+ {
+ .driver_name = "iris",
+ .create_screen = pipe_iris_create_screen,
+ .driconf_xml = &iris_driconf_xml,
},
{
.driver_name = "nouveau",
.create_screen = pipe_nouveau_create_screen,
- .configuration = pipe_default_configuration_query,
},
{
.driver_name = "r300",
.create_screen = pipe_r300_create_screen,
- .configuration = pipe_default_configuration_query,
},
{
.driver_name = "r600",
.create_screen = pipe_r600_create_screen,
- .configuration = pipe_default_configuration_query,
},
{
.driver_name = "radeonsi",
.create_screen = pipe_radeonsi_create_screen,
- .configuration = pipe_radeonsi_configuration_query,
+ .driconf_xml = &radeonsi_driconf_xml,
},
{
.driver_name = "vmwgfx",
.create_screen = pipe_vmwgfx_create_screen,
- .configuration = pipe_default_configuration_query,
},
{
.driver_name = "kgsl",
.create_screen = pipe_freedreno_create_screen,
- .configuration = pipe_default_configuration_query,
},
{
.driver_name = "msm",
.create_screen = pipe_freedreno_create_screen,
- .configuration = pipe_default_configuration_query,
- },
- {
- .driver_name = "pl111",
- .create_screen = pipe_pl111_create_screen,
- .configuration = pipe_default_configuration_query,
},
{
.driver_name = "virtio_gpu",
.create_screen = pipe_virgl_create_screen,
- .configuration = pipe_default_configuration_query,
+ .driconf_xml = &virgl_driconf_xml,
},
{
.driver_name = "v3d",
.create_screen = pipe_v3d_create_screen,
- .configuration = pipe_default_configuration_query,
+ .driconf_xml = &v3d_driconf_xml,
},
{
.driver_name = "vc4",
.create_screen = pipe_vc4_create_screen,
- .configuration = pipe_default_configuration_query,
+ .driconf_xml = &v3d_driconf_xml,
},
{
- .driver_name = "etnaviv",
- .create_screen = pipe_etna_create_screen,
- .configuration = pipe_default_configuration_query,
+ .driver_name = "panfrost",
+ .create_screen = pipe_panfrost_create_screen,
},
{
- .driver_name = "imx-drm",
- .create_screen = pipe_imx_drm_create_screen,
- .configuration = pipe_default_configuration_query,
+ .driver_name = "etnaviv",
+ .create_screen = pipe_etna_create_screen,
},
{
.driver_name = "tegra",
.create_screen = pipe_tegra_create_screen,
- .configuration = pipe_default_configuration_query,
},
+ {
+ .driver_name = "lima",
+ .create_screen = pipe_lima_create_screen,
+ },
+ {
+ .driver_name = "zink",
+ .create_screen = pipe_zink_create_screen,
+ },
+};
+
+static const struct drm_driver_descriptor default_driver_descriptor = {
+ .driver_name = "kmsro",
+ .create_screen = pipe_kmsro_create_screen,
+ .driconf_xml = &v3d_driconf_xml,
};
+
#endif
static const struct drm_driver_descriptor *
if (strcmp(driver_descriptors[i].driver_name, driver_name) == 0)
return &driver_descriptors[i];
}
+ return &default_driver_descriptor;
#else
*plib = pipe_loader_find_module(driver_name, PIPE_SEARCH_DIR);
if (!*plib)
return NULL;
}
-bool
-pipe_loader_drm_probe_fd(struct pipe_loader_device **dev, int fd)
+static bool
+pipe_loader_drm_probe_fd_nodup(struct pipe_loader_device **dev, int fd)
{
struct pipe_loader_drm_device *ddev = CALLOC_STRUCT(pipe_loader_drm_device);
int vendor_id, chip_id;
if (!ddev->base.driver_name)
goto fail;
+ /* For the closed source AMD OpenGL driver, we want libgbm to load
+ * "amdgpu_dri.so", but we want Gallium multimedia drivers to load
+ * "radeonsi". So change amdgpu to radeonsi for Gallium.
+ */
+ if (strcmp(ddev->base.driver_name, "amdgpu") == 0) {
+ FREE(ddev->base.driver_name);
+ ddev->base.driver_name = strdup("radeonsi");
+ }
+
struct util_dl_library **plib = NULL;
#ifndef GALLIUM_STATIC_TARGETS
plib = &ddev->lib;
#endif
ddev->dd = get_driver_descriptor(ddev->base.driver_name, plib);
+
+ /* kmsro supports lots of drivers, try as a fallback */
+ if (!ddev->dd)
+ ddev->dd = get_driver_descriptor("kmsro", plib);
+
if (!ddev->dd)
goto fail;
return false;
}
+bool
+pipe_loader_drm_probe_fd(struct pipe_loader_device **dev, int fd)
+{
+ bool ret;
+ int new_fd;
+
+ if (fd < 0 || (new_fd = fcntl(fd, F_DUPFD_CLOEXEC, 3)) < 0)
+ return false;
+
+ ret = pipe_loader_drm_probe_fd_nodup(dev, new_fd);
+ if (!ret)
+ close(new_fd);
+
+ return ret;
+}
+
static int
open_drm_render_node_minor(int minor)
{
if (fd < 0)
continue;
- if (!pipe_loader_drm_probe_fd(&dev, fd)) {
+ if (!pipe_loader_drm_probe_fd_nodup(&dev, fd)) {
close(fd);
continue;
}
pipe_loader_base_release(dev);
}
-static const struct drm_conf_ret *
-pipe_loader_drm_configuration(struct pipe_loader_device *dev,
- enum drm_conf conf)
+static const char *
+pipe_loader_drm_get_driconf_xml(struct pipe_loader_device *dev)
{
struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(dev);
- if (!ddev->dd->configuration)
+ if (!ddev->dd->driconf_xml)
return NULL;
- return ddev->dd->configuration(conf);
+ return *ddev->dd->driconf_xml;
}
static struct pipe_screen *
struct util_dl_library *lib = NULL;
const struct drm_driver_descriptor *dd =
get_driver_descriptor(driver_name, &lib);
- if (!dd)
- goto out;
-
- const struct drm_conf_ret *conf = dd->configuration(DRM_CONF_XML_OPTIONS);
- if (!conf)
- goto out;
- xml = strdup((const char *)conf->val.val_pointer);
+ if (dd && dd->driconf_xml && *dd->driconf_xml)
+ xml = strdup(*dd->driconf_xml);
-out:
if (lib)
util_dl_close(lib);
return xml;
static const struct pipe_loader_ops pipe_loader_drm_ops = {
.create_screen = pipe_loader_drm_create_screen,
- .configuration = pipe_loader_drm_configuration,
+ .get_driconf_xml = pipe_loader_drm_get_driconf_xml,
.release = pipe_loader_drm_release
};