mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
drm/gud: Set struct drm_device.dma_dev
Set the dma_dev field provided by the DRM device. Required for PRIME dma-buf import. Remove the driver's implementation. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Jani Nikula <jani.nikula@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20250307080836.42848-5-tzimmermann@suse.de
This commit is contained in:
@@ -309,21 +309,6 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* FIXME: Dma-buf sharing requires DMA support by the importing device.
|
||||
* This function is a workaround to make USB devices work as well.
|
||||
* See todo.rst for how to fix the issue in the dma-buf framework.
|
||||
*/
|
||||
static struct drm_gem_object *gud_gem_prime_import(struct drm_device *drm, struct dma_buf *dma_buf)
|
||||
{
|
||||
struct gud_device *gdrm = to_gud_device(drm);
|
||||
|
||||
if (!gdrm->dmadev)
|
||||
return ERR_PTR(-ENODEV);
|
||||
|
||||
return drm_gem_prime_import_dev(drm, dma_buf, gdrm->dmadev);
|
||||
}
|
||||
|
||||
static int gud_stats_debugfs(struct seq_file *m, void *data)
|
||||
{
|
||||
struct drm_debugfs_entry *entry = m->private;
|
||||
@@ -376,7 +361,6 @@ static const struct drm_driver gud_drm_driver = {
|
||||
.driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_ATOMIC,
|
||||
.fops = &gud_fops,
|
||||
DRM_GEM_SHMEM_DRIVER_OPS,
|
||||
.gem_prime_import = gud_gem_prime_import,
|
||||
DRM_FBDEV_SHMEM_DRIVER_OPS,
|
||||
|
||||
.name = "gud",
|
||||
@@ -434,6 +418,7 @@ static int gud_probe(struct usb_interface *intf, const struct usb_device_id *id)
|
||||
size_t max_buffer_size = 0;
|
||||
struct gud_device *gdrm;
|
||||
struct drm_device *drm;
|
||||
struct device *dma_dev;
|
||||
u8 *formats_dev;
|
||||
u32 *formats;
|
||||
int ret, i;
|
||||
@@ -609,17 +594,19 @@ static int gud_probe(struct usb_interface *intf, const struct usb_device_id *id)
|
||||
|
||||
usb_set_intfdata(intf, gdrm);
|
||||
|
||||
gdrm->dmadev = usb_intf_get_dma_device(intf);
|
||||
if (!gdrm->dmadev)
|
||||
dev_warn(dev, "buffer sharing not supported");
|
||||
dma_dev = usb_intf_get_dma_device(intf);
|
||||
if (dma_dev) {
|
||||
drm_dev_set_dma_dev(drm, dma_dev);
|
||||
put_device(dma_dev);
|
||||
} else {
|
||||
dev_warn(dev, "buffer sharing not supported"); /* not an error */
|
||||
}
|
||||
|
||||
drm_debugfs_add_file(drm, "stats", gud_stats_debugfs, NULL);
|
||||
|
||||
ret = drm_dev_register(drm, 0);
|
||||
if (ret) {
|
||||
put_device(gdrm->dmadev);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
drm_kms_helper_poll_init(drm);
|
||||
|
||||
@@ -638,8 +625,6 @@ static void gud_disconnect(struct usb_interface *interface)
|
||||
drm_kms_helper_poll_fini(drm);
|
||||
drm_dev_unplug(drm);
|
||||
drm_atomic_helper_shutdown(drm);
|
||||
put_device(gdrm->dmadev);
|
||||
gdrm->dmadev = NULL;
|
||||
}
|
||||
|
||||
static int gud_suspend(struct usb_interface *intf, pm_message_t message)
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
struct gud_device {
|
||||
struct drm_device drm;
|
||||
struct drm_simple_display_pipe pipe;
|
||||
struct device *dmadev;
|
||||
struct work_struct work;
|
||||
u32 flags;
|
||||
const struct drm_format_info *xrgb8888_emulation_format;
|
||||
|
||||
Reference in New Issue
Block a user