2014-09-10 14:16:10 +08:00
|
|
|
/*
|
|
|
|
* Copyright © 2014 Intel Corporation
|
|
|
|
* Daniel Vetter <daniel.vetter@ffwll.ch>
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2018-09-05 21:57:06 +08:00
|
|
|
#include <drm/drm_ioctl.h>
|
|
|
|
|
drm: drop obsolete drm_core.h
The drm_core.h header contains a set of constants meant to be used
throughout DRM. However, as it turns out, they're each used just once and
don't bring any benefit. They're also grossly mis-named and lack
name-spacing. This patch inlines them, or moves them into drm_internal.h
as appropriate:
- CORE_AUTHOR and CORE_DESC are inlined into corresponding MODULE_*()
macros. It's just confusing having to follow 2 pointers when trying to
find the definition of these fields. Grep'ping for MODULE_AUTHOR()
should reveal the full information, if there's no strong reason not to.
- CORE_NAME, CORE_DATE, CORE_MAJOR, CORE_MINOR, and CORE_PATCHLEVEL are
inlined into the sysfs 'version' attribute. They're stripped
everywhere else (which is just some printk() statements). CORE_NAME
just doesn't make *any* sense, as we hard-code it in many places,
anyway. The other constants are outdated and just serve
binary-compatibility purposes. Hence, inline them in 'version' sysfs
attribute (we might even try dropping it..).
- DRM_IF_MAJOR and DRM_IF_MINOR are moved into drm_internal.h as they're
only used by the global ioctl handlers. Furthermore, versioning
interfaces breaks backports and as such is deprecated, anyway. We just
keep them for historic reasons. I doubt anyone will ever modify them
again.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20160901124837.680-6-dh.herrmann@gmail.com
2016-09-01 20:48:36 +08:00
|
|
|
#define DRM_IF_MAJOR 1
|
|
|
|
#define DRM_IF_MINOR 4
|
|
|
|
|
2018-12-27 05:03:47 +08:00
|
|
|
#define DRM_IF_VERSION(maj, min) (maj << 16 | min)
|
|
|
|
|
2019-05-27 01:35:32 +08:00
|
|
|
struct dentry;
|
2018-09-05 21:57:06 +08:00
|
|
|
struct dma_buf;
|
2019-05-27 01:35:32 +08:00
|
|
|
struct drm_connector;
|
|
|
|
struct drm_crtc;
|
|
|
|
struct drm_framebuffer;
|
|
|
|
struct drm_gem_object;
|
|
|
|
struct drm_master;
|
|
|
|
struct drm_minor;
|
|
|
|
struct drm_prime_file_private;
|
|
|
|
struct drm_printer;
|
2018-09-05 21:57:06 +08:00
|
|
|
|
2017-03-08 22:12:40 +08:00
|
|
|
/* drm_file.c */
|
2014-09-10 18:43:54 +08:00
|
|
|
extern struct mutex drm_global_mutex;
|
2020-02-04 23:01:46 +08:00
|
|
|
bool drm_dev_needs_global_mutex(struct drm_device *dev);
|
2018-06-18 22:17:28 +08:00
|
|
|
struct drm_file *drm_file_alloc(struct drm_minor *minor);
|
|
|
|
void drm_file_free(struct drm_file *file);
|
2016-04-27 01:29:35 +08:00
|
|
|
void drm_lastclose(struct drm_device *dev);
|
2014-09-10 18:43:53 +08:00
|
|
|
|
2019-12-03 18:03:55 +08:00
|
|
|
#ifdef CONFIG_PCI
|
|
|
|
|
2014-09-10 18:43:53 +08:00
|
|
|
/* drm_pci.c */
|
|
|
|
int drm_irq_by_busid(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
2017-01-25 14:26:52 +08:00
|
|
|
void drm_pci_agp_destroy(struct drm_device *dev);
|
2017-05-24 22:51:39 +08:00
|
|
|
int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master);
|
2014-09-10 18:43:53 +08:00
|
|
|
|
2019-12-03 18:03:55 +08:00
|
|
|
#else
|
|
|
|
|
|
|
|
static inline int drm_irq_by_busid(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv)
|
|
|
|
{
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void drm_pci_agp_destroy(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int drm_pci_set_busid(struct drm_device *dev,
|
|
|
|
struct drm_master *master)
|
|
|
|
{
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2014-09-10 18:43:53 +08:00
|
|
|
/* drm_prime.c */
|
|
|
|
int drm_prime_handle_to_fd_ioctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
int drm_prime_fd_to_handle_ioctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
|
|
|
|
void drm_prime_init_file_private(struct drm_prime_file_private *prime_fpriv);
|
|
|
|
void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv);
|
|
|
|
void drm_prime_remove_buf_handle_locked(struct drm_prime_file_private *prime_fpriv,
|
|
|
|
struct dma_buf *dma_buf);
|
|
|
|
|
2016-11-14 19:58:19 +08:00
|
|
|
/* drm_drv.c */
|
|
|
|
struct drm_minor *drm_minor_acquire(unsigned int minor_id);
|
|
|
|
void drm_minor_release(struct drm_minor *minor);
|
|
|
|
|
drm: add managed resources tied to drm_device
We have lots of these. And the cleanup code tends to be of dubious
quality. The biggest wrong pattern is that developers use devm_, which
ties the release action to the underlying struct device, whereas
all the userspace visible stuff attached to a drm_device can long
outlive that one (e.g. after a hotunplug while userspace has open
files and mmap'ed buffers). Give people what they want, but with more
correctness.
Mostly copied from devres.c, with types adjusted to fit drm_device and
a few simplifications - I didn't (yet) copy over everything. Since
the types don't match code sharing looked like a hopeless endeavour.
For now it's only super simplified, no groups, you can't remove
actions (but kfree exists, we'll need that soon). Plus all specific to
drm_device ofc, including the logging. Which I didn't bother to make
compile-time optional, since none of the other drm logging is compile
time optional either.
One tricky bit here is the chicken&egg between allocating your
drm_device structure and initiliazing it with drm_dev_init. For
perfect onion unwinding we'd need to have the action to kfree the
allocation registered before drm_dev_init registers any of its own
release handlers. But drm_dev_init doesn't know where exactly the
drm_device is emebedded into the overall structure, and by the time it
returns it'll all be too late. And forcing drivers to be able clean up
everything except the one kzalloc is silly.
Work around this by having a very special final_kfree pointer. This
also avoids troubles with the list head possibly disappearing from
underneath us when we release all resources attached to the
drm_device.
v2: Do all the kerneldoc at the end, to avoid lots of fairly pointless
shuffling while getting everything into shape.
v3: Add static to add/del_dr (Neil)
Move typo fix to the right patch (Neil)
v4: Enforce contract for drmm_add_final_kfree:
Use ksize() to check that the drm_device is indeed contained somewhere
in the final kfree(). Because we need that or the entire managed
release logic blows up in a pile of use-after-frees. Motivated by a
discussion with Laurent.
v5: Review from Laurent:
- %zu instead of casting size_t
- header guards
- sorting of includes
- guarding of data assignment if we didn't allocate it for a NULL
pointer
- delete spurious newline
- cast void* data parameter correctly in ->release call, no idea how
this even worked before
v6: Review from Sam
- Add the kerneldoc for the managed sub-struct back in, even if it
doesn't show up in the generated html somehow.
- Explain why __always_inline.
- Fix bisectability around the final kfree() in drm_dev_relase(). This
is just interim code which will disappear again.
- Some whitespace polish.
- Add debug output when drmm_add_action or drmm_kmalloc fail.
v7: My bisectability fix wasn't up to par as noticed by smatch.
v8: Remove unecessary {} around if else
v9: Use kstrdup_const, which requires kfree_const and introducing a free_dr()
helper (Thomas).
v10: kfree_const goes boom on the plain "kmalloc" assignment, somehow
we need to wrap that in kstrdup_const() too!! Also renumber revision
log, I somehow reset it midway thruh.
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Neil Armstrong <narmstrong@baylibre.com
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200324124540.3227396-1-daniel.vetter@ffwll.ch
2020-03-24 20:45:40 +08:00
|
|
|
/* drm_managed.c */
|
|
|
|
void drm_managed_release(struct drm_device *dev);
|
|
|
|
|
2017-05-31 17:21:46 +08:00
|
|
|
/* drm_vblank.c */
|
|
|
|
void drm_vblank_disable_and_save(struct drm_device *dev, unsigned int pipe);
|
2016-11-14 17:02:55 +08:00
|
|
|
|
|
|
|
/* IOCTLS */
|
2017-05-24 22:51:46 +08:00
|
|
|
int drm_wait_vblank_ioctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *filp);
|
|
|
|
int drm_legacy_modeset_ctl_ioctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
|
|
|
|
/* drm_irq.c */
|
|
|
|
|
|
|
|
/* IOCTLS */
|
2019-04-18 15:10:40 +08:00
|
|
|
#if IS_ENABLED(CONFIG_DRM_LEGACY)
|
2016-12-14 07:08:02 +08:00
|
|
|
int drm_legacy_irq_control(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
2019-04-18 15:10:40 +08:00
|
|
|
#endif
|
2014-09-10 18:43:53 +08:00
|
|
|
|
2017-06-30 13:49:31 +08:00
|
|
|
int drm_crtc_get_sequence_ioctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *filp);
|
|
|
|
|
|
|
|
int drm_crtc_queue_sequence_ioctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *filp);
|
|
|
|
|
2014-09-10 18:43:53 +08:00
|
|
|
/* drm_auth.c */
|
|
|
|
int drm_getmagic(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
int drm_authmagic(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
2016-06-15 02:50:59 +08:00
|
|
|
int drm_setmaster_ioctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
2016-06-15 02:51:00 +08:00
|
|
|
int drm_master_open(struct drm_file *file_priv);
|
2016-06-15 02:51:01 +08:00
|
|
|
void drm_master_release(struct drm_file *file_priv);
|
2019-05-07 02:01:30 +08:00
|
|
|
bool drm_master_internal_acquire(struct drm_device *dev);
|
|
|
|
void drm_master_internal_release(struct drm_device *dev);
|
2014-09-10 18:43:53 +08:00
|
|
|
|
|
|
|
/* drm_sysfs.c */
|
2014-09-10 18:43:59 +08:00
|
|
|
extern struct class *drm_class;
|
|
|
|
|
2015-09-09 20:21:30 +08:00
|
|
|
int drm_sysfs_init(void);
|
2014-09-10 18:43:53 +08:00
|
|
|
void drm_sysfs_destroy(void);
|
|
|
|
struct device *drm_sysfs_minor_alloc(struct drm_minor *minor);
|
|
|
|
int drm_sysfs_connector_add(struct drm_connector *connector);
|
|
|
|
void drm_sysfs_connector_remove(struct drm_connector *connector);
|
|
|
|
|
2018-11-29 17:42:26 +08:00
|
|
|
void drm_sysfs_lease_event(struct drm_device *dev);
|
|
|
|
|
2014-09-10 18:43:53 +08:00
|
|
|
/* drm_gem.c */
|
2019-05-13 21:35:04 +08:00
|
|
|
struct drm_gem_object;
|
2014-09-10 18:43:53 +08:00
|
|
|
int drm_gem_init(struct drm_device *dev);
|
|
|
|
int drm_gem_handle_create_tail(struct drm_file *file_priv,
|
|
|
|
struct drm_gem_object *obj,
|
|
|
|
u32 *handlep);
|
|
|
|
int drm_gem_close_ioctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
int drm_gem_flink_ioctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
int drm_gem_open_ioctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
void drm_gem_open(struct drm_device *dev, struct drm_file *file_private);
|
|
|
|
void drm_gem_release(struct drm_device *dev, struct drm_file *file_private);
|
2017-11-08 03:13:40 +08:00
|
|
|
void drm_gem_print_info(struct drm_printer *p, unsigned int indent,
|
|
|
|
const struct drm_gem_object *obj);
|
2014-09-23 21:46:51 +08:00
|
|
|
|
2019-06-15 04:35:18 +08:00
|
|
|
int drm_gem_pin(struct drm_gem_object *obj);
|
|
|
|
void drm_gem_unpin(struct drm_gem_object *obj);
|
|
|
|
void *drm_gem_vmap(struct drm_gem_object *obj);
|
|
|
|
void drm_gem_vunmap(struct drm_gem_object *obj, void *vaddr);
|
|
|
|
|
2017-03-23 04:54:01 +08:00
|
|
|
/* drm_debugfs.c drm_debugfs_crc.c */
|
2014-09-23 21:46:52 +08:00
|
|
|
#if defined(CONFIG_DEBUG_FS)
|
|
|
|
int drm_debugfs_init(struct drm_minor *minor, int minor_id,
|
|
|
|
struct dentry *root);
|
2019-06-13 21:34:39 +08:00
|
|
|
void drm_debugfs_cleanup(struct drm_minor *minor);
|
|
|
|
void drm_debugfs_connector_add(struct drm_connector *connector);
|
2014-09-23 21:46:52 +08:00
|
|
|
void drm_debugfs_connector_remove(struct drm_connector *connector);
|
2019-06-13 21:34:39 +08:00
|
|
|
void drm_debugfs_crtc_add(struct drm_crtc *crtc);
|
2016-10-06 23:21:06 +08:00
|
|
|
void drm_debugfs_crtc_remove(struct drm_crtc *crtc);
|
2019-06-13 21:34:39 +08:00
|
|
|
void drm_debugfs_crtc_crc_add(struct drm_crtc *crtc);
|
2014-09-23 21:46:52 +08:00
|
|
|
#else
|
|
|
|
static inline int drm_debugfs_init(struct drm_minor *minor, int minor_id,
|
|
|
|
struct dentry *root)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-06-13 21:34:39 +08:00
|
|
|
static inline void drm_debugfs_cleanup(struct drm_minor *minor)
|
2014-09-23 21:46:52 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-06-13 21:34:39 +08:00
|
|
|
static inline void drm_debugfs_connector_add(struct drm_connector *connector)
|
2014-09-23 21:46:52 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
static inline void drm_debugfs_connector_remove(struct drm_connector *connector)
|
|
|
|
{
|
|
|
|
}
|
2016-10-06 23:21:06 +08:00
|
|
|
|
2019-06-13 21:34:39 +08:00
|
|
|
static inline void drm_debugfs_crtc_add(struct drm_crtc *crtc)
|
2016-10-06 23:21:06 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
static inline void drm_debugfs_crtc_remove(struct drm_crtc *crtc)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-06-13 21:34:39 +08:00
|
|
|
static inline void drm_debugfs_crtc_crc_add(struct drm_crtc *crtc)
|
2016-10-06 23:21:06 +08:00
|
|
|
{
|
|
|
|
}
|
2017-04-04 11:26:24 +08:00
|
|
|
|
2014-09-23 21:46:52 +08:00
|
|
|
#endif
|
2017-04-04 11:26:24 +08:00
|
|
|
|
2017-05-25 02:11:03 +08:00
|
|
|
drm_ioctl_t drm_version;
|
2017-05-25 02:15:20 +08:00
|
|
|
drm_ioctl_t drm_getunique;
|
2017-05-25 07:10:32 +08:00
|
|
|
drm_ioctl_t drm_getclient;
|
2017-07-10 09:48:37 +08:00
|
|
|
|
2017-04-04 11:26:24 +08:00
|
|
|
/* drm_syncobj.c */
|
|
|
|
void drm_syncobj_open(struct drm_file *file_private);
|
|
|
|
void drm_syncobj_release(struct drm_file *file_private);
|
|
|
|
int drm_syncobj_create_ioctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_private);
|
|
|
|
int drm_syncobj_destroy_ioctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_private);
|
|
|
|
int drm_syncobj_handle_to_fd_ioctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_private);
|
|
|
|
int drm_syncobj_fd_to_handle_ioctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_private);
|
2019-04-01 17:51:01 +08:00
|
|
|
int drm_syncobj_transfer_ioctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_private);
|
2017-08-26 01:52:22 +08:00
|
|
|
int drm_syncobj_wait_ioctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_private);
|
2019-04-01 17:50:57 +08:00
|
|
|
int drm_syncobj_timeline_wait_ioctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_private);
|
2017-08-29 05:10:27 +08:00
|
|
|
int drm_syncobj_reset_ioctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_private);
|
2017-08-29 05:10:28 +08:00
|
|
|
int drm_syncobj_signal_ioctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_private);
|
2019-04-01 17:51:02 +08:00
|
|
|
int drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_private);
|
2019-04-01 17:50:58 +08:00
|
|
|
int drm_syncobj_query_ioctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_private);
|
2017-11-08 03:13:40 +08:00
|
|
|
|
|
|
|
/* drm_framebuffer.c */
|
|
|
|
void drm_framebuffer_print_info(struct drm_printer *p, unsigned int indent,
|
|
|
|
const struct drm_framebuffer *fb);
|
2020-03-10 21:31:21 +08:00
|
|
|
void drm_framebuffer_debugfs_init(struct drm_minor *minor);
|