summaryrefslogtreecommitdiff
path: root/include/drm/drm_gem.h
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2017-03-08 17:12:57 +0300
committerDaniel Vetter <daniel.vetter@ffwll.ch>2017-03-14 16:38:34 +0300
commitf42e181935d5e5670c87d31ae48063a495bbacae (patch)
treea84c21a0dc379cf262040c50632aef8331d53200 /include/drm/drm_gem.h
parentd55f7e5d54c31c8ed61fdbfc59835cd6804ba954 (diff)
downloadlinux-f42e181935d5e5670c87d31ae48063a495bbacae.tar.xz
drm/gem: Add DEFINE_DRM_GEM_FOPS
Sadly there's only 1 driver which can use it, everyone else is special for some reason: - gma500 has a horrible runtime PM ioctl wrapper that probably doesn't really work but meh. - i915 needs special compat_ioctl handler because regrets. - arcgpu needs to fixup the pgprot because (no idea why it can't do that in the fault handler like everyone else). - tegra does even worse stuff with pgprot - udl does something with vm_flags too ... - cma helpers, etnaviv, mtk, msm, rockchip, omap all implement some variation on prefaulting. - exynos is exynos, I got lost in the midlayers. - vc4 has to reinvent half of cma helpers because those are too much midlayer, plus vm_flags dances. - vgem also seems unhappy with the default vm_flags. So pretty sad divergence and I'm sure we could do better, but not really an idea. Oh well, maybe this macro here helps to encourage more consistency at least going forward. Reviewed-by: Sean Paul <seanpaul@chromium.org> Reviewed-by: Liviu Dudau <Liviu.Dudau@arm.com> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/20170308141257.12119-25-daniel.vetter@ffwll.ch
Diffstat (limited to 'include/drm/drm_gem.h')
-rw-r--r--include/drm/drm_gem.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
index b9ade75ecd82..663d80358057 100644
--- a/include/drm/drm_gem.h
+++ b/include/drm/drm_gem.h
@@ -178,6 +178,32 @@ struct drm_gem_object {
struct dma_buf_attachment *import_attach;
};
+/**
+ * DEFINE_DRM_GEM_FOPS() - macro to generate file operations for GEM drivers
+ * @name: name for the generated structure
+ *
+ * This macro autogenerates a suitable &struct file_operations for GEM based
+ * drivers, which can be assigned to &drm_driver.fops. Note that this structure
+ * cannot be shared between drivers, because it contains a reference to the
+ * current module using THIS_MODULE.
+ *
+ * Note that the declaration is already marked as static - if you need a
+ * non-static version of this you're probably doing it wrong and will break the
+ * THIS_MODULE reference by accident.
+ */
+#define DEFINE_DRM_GEM_FOPS(name) \
+ static const struct file_operations name = {\
+ .owner = THIS_MODULE,\
+ .open = drm_open,\
+ .release = drm_release,\
+ .unlocked_ioctl = drm_ioctl,\
+ .compat_ioctl = drm_compat_ioctl,\
+ .poll = drm_poll,\
+ .read = drm_read,\
+ .llseek = noop_llseek,\
+ .mmap = drm_gem_mmap,\
+ }
+
void drm_gem_object_release(struct drm_gem_object *obj);
void drm_gem_object_free(struct kref *kref);
int drm_gem_object_init(struct drm_device *dev,