2016-11-14 19:58:19 +08:00
|
|
|
/*
|
|
|
|
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
|
|
|
|
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
|
|
|
* Copyright (c) 2009-2010, Code Aurora Forum.
|
|
|
|
* Copyright 2016 Intel Corp.
|
|
|
|
*
|
|
|
|
* 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 (including the next
|
|
|
|
* paragraph) 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
|
|
|
|
* VA LINUX SYSTEMS AND/OR ITS SUPPLIERS 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _DRM_DRV_H_
|
|
|
|
#define _DRM_DRV_H_
|
|
|
|
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/irqreturn.h>
|
|
|
|
|
2017-08-02 19:56:02 +08:00
|
|
|
#include <drm/drm_device.h>
|
|
|
|
|
2016-11-14 19:58:19 +08:00
|
|
|
struct drm_file;
|
|
|
|
struct drm_gem_object;
|
|
|
|
struct drm_master;
|
|
|
|
struct drm_minor;
|
2020-09-23 18:21:59 +08:00
|
|
|
struct dma_buf;
|
2016-11-14 19:58:19 +08:00
|
|
|
struct dma_buf_attachment;
|
|
|
|
struct drm_display_mode;
|
|
|
|
struct drm_mode_create_dumb;
|
2017-11-08 03:13:40 +08:00
|
|
|
struct drm_printer;
|
2020-09-23 18:21:59 +08:00
|
|
|
struct sg_table;
|
2016-11-14 19:58:19 +08:00
|
|
|
|
2019-01-29 18:42:47 +08:00
|
|
|
/**
|
|
|
|
* enum drm_driver_feature - feature flags
|
|
|
|
*
|
|
|
|
* See &drm_driver.driver_features, drm_device.driver_features and
|
|
|
|
* drm_core_check_feature().
|
|
|
|
*/
|
|
|
|
enum drm_driver_feature {
|
|
|
|
/**
|
|
|
|
* @DRIVER_GEM:
|
|
|
|
*
|
|
|
|
* Driver use the GEM memory manager. This should be set for all modern
|
|
|
|
* drivers.
|
|
|
|
*/
|
|
|
|
DRIVER_GEM = BIT(0),
|
|
|
|
/**
|
|
|
|
* @DRIVER_MODESET:
|
|
|
|
*
|
|
|
|
* Driver supports mode setting interfaces (KMS).
|
|
|
|
*/
|
|
|
|
DRIVER_MODESET = BIT(1),
|
|
|
|
/**
|
|
|
|
* @DRIVER_RENDER:
|
|
|
|
*
|
|
|
|
* Driver supports dedicated render nodes. See also the :ref:`section on
|
|
|
|
* render nodes <drm_render_node>` for details.
|
|
|
|
*/
|
|
|
|
DRIVER_RENDER = BIT(3),
|
|
|
|
/**
|
|
|
|
* @DRIVER_ATOMIC:
|
|
|
|
*
|
|
|
|
* Driver supports the full atomic modesetting userspace API. Drivers
|
2021-03-26 18:32:15 +08:00
|
|
|
* which only use atomic internally, but do not support the full
|
2019-01-29 18:42:47 +08:00
|
|
|
* userspace API (e.g. not all properties converted to atomic, or
|
|
|
|
* multi-plane updates are not guaranteed to be tear-free) should not
|
|
|
|
* set this flag.
|
|
|
|
*/
|
|
|
|
DRIVER_ATOMIC = BIT(4),
|
|
|
|
/**
|
|
|
|
* @DRIVER_SYNCOBJ:
|
|
|
|
*
|
|
|
|
* Driver supports &drm_syncobj for explicit synchronization of command
|
|
|
|
* submission.
|
|
|
|
*/
|
|
|
|
DRIVER_SYNCOBJ = BIT(5),
|
2019-04-16 20:57:50 +08:00
|
|
|
/**
|
|
|
|
* @DRIVER_SYNCOBJ_TIMELINE:
|
|
|
|
*
|
|
|
|
* Driver supports the timeline flavor of &drm_syncobj for explicit
|
|
|
|
* synchronization of command submission.
|
|
|
|
*/
|
|
|
|
DRIVER_SYNCOBJ_TIMELINE = BIT(6),
|
2019-01-29 18:42:47 +08:00
|
|
|
|
|
|
|
/* IMPORTANT: Below are all the legacy flags, add new ones above. */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @DRIVER_USE_AGP:
|
|
|
|
*
|
|
|
|
* Set up DRM AGP support, see drm_agp_init(), the DRM core will manage
|
|
|
|
* AGP resources. New drivers don't need this.
|
|
|
|
*/
|
2019-01-29 18:42:48 +08:00
|
|
|
DRIVER_USE_AGP = BIT(25),
|
2019-01-29 18:42:47 +08:00
|
|
|
/**
|
|
|
|
* @DRIVER_LEGACY:
|
|
|
|
*
|
|
|
|
* Denote a legacy driver using shadow attach. Do not use.
|
|
|
|
*/
|
2019-01-29 18:42:48 +08:00
|
|
|
DRIVER_LEGACY = BIT(26),
|
2019-01-29 18:42:47 +08:00
|
|
|
/**
|
|
|
|
* @DRIVER_PCI_DMA:
|
|
|
|
*
|
|
|
|
* Driver is capable of PCI DMA, mapping of PCI DMA buffers to userspace
|
|
|
|
* will be enabled. Only for legacy drivers. Do not use.
|
|
|
|
*/
|
2019-01-29 18:42:48 +08:00
|
|
|
DRIVER_PCI_DMA = BIT(27),
|
2019-01-29 18:42:47 +08:00
|
|
|
/**
|
|
|
|
* @DRIVER_SG:
|
|
|
|
*
|
|
|
|
* Driver can perform scatter/gather DMA, allocation and mapping of
|
|
|
|
* scatter/gather buffers will be enabled. Only for legacy drivers. Do
|
|
|
|
* not use.
|
|
|
|
*/
|
2019-01-29 18:42:48 +08:00
|
|
|
DRIVER_SG = BIT(28),
|
2019-01-29 18:42:47 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @DRIVER_HAVE_DMA:
|
|
|
|
*
|
|
|
|
* Driver supports DMA, the userspace DMA API will be supported. Only
|
|
|
|
* for legacy drivers. Do not use.
|
|
|
|
*/
|
2019-01-29 18:42:48 +08:00
|
|
|
DRIVER_HAVE_DMA = BIT(29),
|
2019-01-29 18:42:47 +08:00
|
|
|
/**
|
|
|
|
* @DRIVER_HAVE_IRQ:
|
|
|
|
*
|
|
|
|
* Legacy irq support. Only for legacy drivers. Do not use.
|
|
|
|
*/
|
2019-01-29 18:42:48 +08:00
|
|
|
DRIVER_HAVE_IRQ = BIT(30),
|
2019-01-29 18:42:47 +08:00
|
|
|
/**
|
|
|
|
* @DRIVER_KMS_LEGACY_CONTEXT:
|
|
|
|
*
|
|
|
|
* Used only by nouveau for backwards compatibility with existing
|
|
|
|
* userspace. Do not use.
|
|
|
|
*/
|
|
|
|
DRIVER_KMS_LEGACY_CONTEXT = BIT(31),
|
|
|
|
};
|
2016-11-14 19:58:19 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* struct drm_driver - DRM driver structure
|
|
|
|
*
|
2019-03-13 23:35:37 +08:00
|
|
|
* This structure represent the common code for a family of cards. There will be
|
|
|
|
* one &struct drm_device for each card present in this family. It contains lots
|
|
|
|
* of vfunc entries, and a pile of those probably should be moved to more
|
2016-11-14 19:58:19 +08:00
|
|
|
* appropriate places like &drm_mode_config_funcs or into a new operations
|
|
|
|
* structure for GEM drivers.
|
|
|
|
*/
|
|
|
|
struct drm_driver {
|
2017-01-02 22:20:08 +08:00
|
|
|
/**
|
|
|
|
* @load:
|
|
|
|
*
|
2020-09-02 15:26:27 +08:00
|
|
|
* Backward-compatible driver callback to complete initialization steps
|
|
|
|
* after the driver is registered. For this reason, may suffer from
|
|
|
|
* race conditions and its use is deprecated for new drivers. It is
|
|
|
|
* therefore only supported for existing drivers not yet converted to
|
|
|
|
* the new scheme. See devm_drm_dev_alloc() and drm_dev_register() for
|
|
|
|
* proper and race-free way to set up a &struct drm_device.
|
2017-01-02 22:20:08 +08:00
|
|
|
*
|
2017-03-08 22:12:44 +08:00
|
|
|
* This is deprecated, do not use!
|
|
|
|
*
|
2017-01-02 22:20:08 +08:00
|
|
|
* Returns:
|
|
|
|
*
|
|
|
|
* Zero on success, non-zero value on failure.
|
|
|
|
*/
|
2016-11-14 19:58:19 +08:00
|
|
|
int (*load) (struct drm_device *, unsigned long flags);
|
2017-03-08 22:12:44 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @open:
|
|
|
|
*
|
|
|
|
* Driver callback when a new &struct drm_file is opened. Useful for
|
|
|
|
* setting up driver-private data structures like buffer allocators,
|
|
|
|
* execution contexts or similar things. Such driver-private resources
|
|
|
|
* must be released again in @postclose.
|
|
|
|
*
|
|
|
|
* Since the display/modeset side of DRM can only be owned by exactly
|
|
|
|
* one &struct drm_file (see &drm_file.is_master and &drm_device.master)
|
|
|
|
* there should never be a need to set up any modeset related resources
|
|
|
|
* in this callback. Doing so would be a driver design bug.
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
*
|
|
|
|
* 0 on success, a negative error code on failure, which will be
|
|
|
|
* promoted to userspace as the result of the open() system call.
|
|
|
|
*/
|
2016-11-14 19:58:19 +08:00
|
|
|
int (*open) (struct drm_device *, struct drm_file *);
|
2017-03-08 22:12:44 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @postclose:
|
|
|
|
*
|
|
|
|
* One of the driver callbacks when a new &struct drm_file is closed.
|
|
|
|
* Useful for tearing down driver-private data structures allocated in
|
|
|
|
* @open like buffer allocators, execution contexts or similar things.
|
|
|
|
*
|
|
|
|
* Since the display/modeset side of DRM can only be owned by exactly
|
|
|
|
* one &struct drm_file (see &drm_file.is_master and &drm_device.master)
|
|
|
|
* there should never be a need to tear down any modeset related
|
|
|
|
* resources in this callback. Doing so would be a driver design bug.
|
|
|
|
*/
|
2016-11-14 19:58:19 +08:00
|
|
|
void (*postclose) (struct drm_device *, struct drm_file *);
|
2017-03-08 22:12:44 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @lastclose:
|
|
|
|
*
|
|
|
|
* Called when the last &struct drm_file has been closed and there's
|
|
|
|
* currently no userspace client for the &struct drm_device.
|
|
|
|
*
|
|
|
|
* Modern drivers should only use this to force-restore the fbdev
|
|
|
|
* framebuffer using drm_fb_helper_restore_fbdev_mode_unlocked().
|
|
|
|
* Anything else would indicate there's something seriously wrong.
|
|
|
|
* Modern drivers can also use this to execute delayed power switching
|
|
|
|
* state changes, e.g. in conjunction with the :ref:`vga_switcheroo`
|
|
|
|
* infrastructure.
|
|
|
|
*
|
2017-05-08 16:26:33 +08:00
|
|
|
* This is called after @postclose hook has been called.
|
2017-03-08 22:12:44 +08:00
|
|
|
*
|
|
|
|
* NOTE:
|
|
|
|
*
|
|
|
|
* All legacy drivers use this callback to de-initialize the hardware.
|
|
|
|
* This is purely because of the shadow-attach model, where the DRM
|
|
|
|
* kernel driver does not really own the hardware. Instead ownershipe is
|
|
|
|
* handled with the help of userspace through an inheritedly racy dance
|
|
|
|
* to set/unset the VT into raw mode.
|
|
|
|
*
|
|
|
|
* Legacy drivers initialize the hardware in the @firstopen callback,
|
|
|
|
* which isn't even called for modern drivers.
|
|
|
|
*/
|
2016-11-14 19:58:19 +08:00
|
|
|
void (*lastclose) (struct drm_device *);
|
2017-01-02 22:20:08 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @unload:
|
|
|
|
*
|
|
|
|
* Reverse the effects of the driver load callback. Ideally,
|
|
|
|
* the clean up performed by the driver should happen in the
|
|
|
|
* reverse order of the initialization. Similarly to the load
|
|
|
|
* hook, this handler is deprecated and its usage should be
|
|
|
|
* dropped in favor of an open-coded teardown function at the
|
2017-09-26 16:28:49 +08:00
|
|
|
* driver layer. See drm_dev_unregister() and drm_dev_put()
|
2017-01-02 22:20:08 +08:00
|
|
|
* for the proper way to remove a &struct drm_device.
|
|
|
|
*
|
|
|
|
* The unload() hook is called right after unregistering
|
|
|
|
* the device.
|
|
|
|
*
|
|
|
|
*/
|
2017-01-07 01:57:31 +08:00
|
|
|
void (*unload) (struct drm_device *);
|
2017-02-02 17:36:32 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @release:
|
|
|
|
*
|
|
|
|
* Optional callback for destroying device data after the final
|
2020-03-23 22:49:24 +08:00
|
|
|
* reference is released, i.e. the device is being destroyed.
|
drm: Add docs for managed resources
All collected together to provide a consistent story in one patch,
instead of the somewhat bumpy refactor-evolution leading to this.
Also some thoughts on what the next steps could be:
- Create a macro called devm_drm_dev_alloc() which essentially wraps
the kzalloc(); devm_drm_dev_init(); drmm_add_final_kfree() combo.
Needs to be a macro since we'll have to do some typeof trickery and
casting to make this fully generic for all drivers that embed struct
drm_device into their own thing.
- A lot of the simple drivers now have essentially just
drm_dev_unplug(); drm_atomic_helper_shutdown(); as their
$bus_driver->remove hook. We could create a devm_mode_config_reset
which sets drm_atomic_helper_shutdown as it's cleanup action, and a
devm_drm_dev_register with drm_dev_unplug as it's cleanup action,
and simple drivers wouldn't have a need for a ->remove function at
all, and we could delete them.
- For more complicated drivers we need drmm_ versions of a _lot_ more
things. All the userspace visible objects (crtc, plane, encoder,
crtc), anything else hanging of those (maybe a drmm_get_edid, at
least for panels and other built-in stuff).
Also some more thoughts on why we're not reusing devm_ with maybe a
fake struct device embedded into the drm_device (we can't use the
kdev, since that's in each drm_minor).
- Code review gets extremely tricky, since every time you see a devm_
you need to carefully check whether the fake device (with the
drm_device lifetim) or the real device (with the lifetim of the
underlying physical device and driver binding) are used. That's not
going to help at all, and we have enormous amounts of drivers who
use devm_ where they really shouldn't. Having different types makes
sure the compiler type checks this for us and ensures correctness.
- The set of functions are very much non-overlapping. E.g.
devm_ioremap makes total sense, drmm_ioremap has the wrong lifetime,
since hw resources need to be cleaned out at driver unbind and wont
outlive that like a drm_device. Similar, but other way round for
drmm_connector_init (which is the only correct version, devm_ for
drm_connector is just buggy). Simply not having the wrong version
again prevents bugs.
Finally I guess this opens a huge todo for all the drivers. I'm
semi-tempted to do a tree-wide s/devm_kzalloc/drmm_kzalloc/ since most
likely that'll fix an enormous amount of bugs and most likely not
cause any issues at all (aside from maybe holding onto memory slightly
too long).
v2:
- Doc improvements from Laurent.
- Also add kerneldoc for the new drmm_add_action_or_reset.
v3:
- Remove kerneldoc for drmm_remove_action.
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: linux-doc@vger.kernel.org
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
fixup docs
Link: https://patchwork.freedesktop.org/patch/msgid/20200323144950.3018436-52-daniel.vetter@ffwll.ch
2020-03-23 22:49:50 +08:00
|
|
|
*
|
|
|
|
* This is deprecated, clean up all memory allocations associated with a
|
|
|
|
* &drm_device using drmm_add_action(), drmm_kmalloc() and related
|
|
|
|
* managed resources functions.
|
2017-02-02 17:36:32 +08:00
|
|
|
*/
|
|
|
|
void (*release) (struct drm_device *);
|
|
|
|
|
2016-11-14 19:58:20 +08:00
|
|
|
/**
|
|
|
|
* @master_set:
|
|
|
|
*
|
|
|
|
* Called whenever the minor master is set. Only used by vmwgfx.
|
|
|
|
*/
|
2020-05-30 20:46:39 +08:00
|
|
|
void (*master_set)(struct drm_device *dev, struct drm_file *file_priv,
|
|
|
|
bool from_open);
|
2016-11-14 19:58:20 +08:00
|
|
|
/**
|
|
|
|
* @master_drop:
|
|
|
|
*
|
|
|
|
* Called whenever the minor master is dropped. Only used by vmwgfx.
|
|
|
|
*/
|
2016-11-14 19:58:19 +08:00
|
|
|
void (*master_drop)(struct drm_device *dev, struct drm_file *file_priv);
|
|
|
|
|
2017-07-21 01:47:43 +08:00
|
|
|
/**
|
|
|
|
* @debugfs_init:
|
|
|
|
*
|
|
|
|
* Allows drivers to create driver-specific debugfs files.
|
|
|
|
*/
|
2020-03-10 21:31:21 +08:00
|
|
|
void (*debugfs_init)(struct drm_minor *minor);
|
2016-11-14 19:58:19 +08:00
|
|
|
|
|
|
|
/**
|
2016-11-25 20:34:27 +08:00
|
|
|
* @gem_create_object: constructor for gem objects
|
|
|
|
*
|
2021-11-30 17:52:55 +08:00
|
|
|
* Hook for allocating the GEM object struct, for use by the CMA
|
|
|
|
* and SHMEM GEM helpers. Returns a GEM object on success, or an
|
|
|
|
* ERR_PTR()-encoded error code otherwise.
|
2016-11-14 19:58:19 +08:00
|
|
|
*/
|
|
|
|
struct drm_gem_object *(*gem_create_object)(struct drm_device *dev,
|
|
|
|
size_t size);
|
2020-09-23 18:21:59 +08:00
|
|
|
|
2017-07-21 01:47:43 +08:00
|
|
|
/**
|
|
|
|
* @prime_handle_to_fd:
|
|
|
|
*
|
2019-06-20 20:46:15 +08:00
|
|
|
* Main PRIME export function. Should be implemented with
|
|
|
|
* drm_gem_prime_handle_to_fd() for GEM based drivers.
|
|
|
|
*
|
|
|
|
* For an in-depth discussion see :ref:`PRIME buffer sharing
|
|
|
|
* documentation <prime_buffer_sharing>`.
|
2017-07-21 01:47:43 +08:00
|
|
|
*/
|
2016-11-14 19:58:19 +08:00
|
|
|
int (*prime_handle_to_fd)(struct drm_device *dev, struct drm_file *file_priv,
|
|
|
|
uint32_t handle, uint32_t flags, int *prime_fd);
|
2017-07-21 01:47:43 +08:00
|
|
|
/**
|
|
|
|
* @prime_fd_to_handle:
|
|
|
|
*
|
2019-06-20 20:46:15 +08:00
|
|
|
* Main PRIME import function. Should be implemented with
|
|
|
|
* drm_gem_prime_fd_to_handle() for GEM based drivers.
|
|
|
|
*
|
|
|
|
* For an in-depth discussion see :ref:`PRIME buffer sharing
|
|
|
|
* documentation <prime_buffer_sharing>`.
|
2017-07-21 01:47:43 +08:00
|
|
|
*/
|
2016-11-14 19:58:19 +08:00
|
|
|
int (*prime_fd_to_handle)(struct drm_device *dev, struct drm_file *file_priv,
|
|
|
|
int prime_fd, uint32_t *handle);
|
2020-09-23 18:21:59 +08:00
|
|
|
|
2017-07-21 01:47:43 +08:00
|
|
|
/**
|
|
|
|
* @gem_prime_import:
|
|
|
|
*
|
2019-06-20 20:46:15 +08:00
|
|
|
* Import hook for GEM drivers.
|
2018-11-10 22:56:43 +08:00
|
|
|
*
|
|
|
|
* This defaults to drm_gem_prime_import() if not set.
|
2017-07-21 01:47:43 +08:00
|
|
|
*/
|
2016-11-14 19:58:19 +08:00
|
|
|
struct drm_gem_object * (*gem_prime_import)(struct drm_device *dev,
|
|
|
|
struct dma_buf *dma_buf);
|
2019-06-20 20:46:15 +08:00
|
|
|
/**
|
|
|
|
* @gem_prime_import_sg_table:
|
|
|
|
*
|
|
|
|
* Optional hook used by the PRIME helper functions
|
|
|
|
* drm_gem_prime_import() respectively drm_gem_prime_import_dev().
|
|
|
|
*/
|
2016-11-14 19:58:19 +08:00
|
|
|
struct drm_gem_object *(*gem_prime_import_sg_table)(
|
|
|
|
struct drm_device *dev,
|
|
|
|
struct dma_buf_attachment *attach,
|
|
|
|
struct sg_table *sgt);
|
2019-06-20 20:46:15 +08:00
|
|
|
/**
|
|
|
|
* @gem_prime_mmap:
|
|
|
|
*
|
|
|
|
* mmap hook for GEM drivers, used to implement dma-buf mmap in the
|
|
|
|
* PRIME helpers.
|
|
|
|
*
|
2021-11-08 18:28:46 +08:00
|
|
|
* This hook only exists for historical reasons. Drivers must use
|
|
|
|
* drm_gem_prime_mmap() to implement it.
|
|
|
|
*
|
|
|
|
* FIXME: Convert all drivers to implement mmap in struct
|
|
|
|
* &drm_gem_object_funcs and inline drm_gem_prime_mmap() into
|
|
|
|
* its callers. This hook should be removed afterwards.
|
2019-06-20 20:46:15 +08:00
|
|
|
*/
|
2021-11-08 18:28:46 +08:00
|
|
|
int (*gem_prime_mmap)(struct drm_gem_object *obj, struct vm_area_struct *vma);
|
2016-11-14 19:58:19 +08:00
|
|
|
|
2016-11-14 19:58:21 +08:00
|
|
|
/**
|
|
|
|
* @dumb_create:
|
|
|
|
*
|
|
|
|
* This creates a new dumb buffer in the driver's backing storage manager (GEM,
|
|
|
|
* TTM or something else entirely) and returns the resulting buffer handle. This
|
|
|
|
* handle can then be wrapped up into a framebuffer modeset object.
|
|
|
|
*
|
|
|
|
* Note that userspace is not allowed to use such objects for render
|
|
|
|
* acceleration - drivers must create their own private ioctls for such a use
|
|
|
|
* case.
|
|
|
|
*
|
|
|
|
* Width, height and depth are specified in the &drm_mode_create_dumb
|
|
|
|
* argument. The callback needs to fill the handle, pitch and size for
|
|
|
|
* the created buffer.
|
|
|
|
*
|
|
|
|
* Called by the user via ioctl.
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
*
|
|
|
|
* Zero on success, negative errno on failure.
|
|
|
|
*/
|
2016-11-14 19:58:19 +08:00
|
|
|
int (*dumb_create)(struct drm_file *file_priv,
|
|
|
|
struct drm_device *dev,
|
|
|
|
struct drm_mode_create_dumb *args);
|
2016-11-14 19:58:21 +08:00
|
|
|
/**
|
|
|
|
* @dumb_map_offset:
|
|
|
|
*
|
|
|
|
* Allocate an offset in the drm device node's address space to be able to
|
2018-11-27 17:19:21 +08:00
|
|
|
* memory map a dumb buffer.
|
|
|
|
*
|
|
|
|
* The default implementation is drm_gem_create_mmap_offset(). GEM based
|
|
|
|
* drivers must not overwrite this.
|
2016-11-14 19:58:21 +08:00
|
|
|
*
|
|
|
|
* Called by the user via ioctl.
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
*
|
|
|
|
* Zero on success, negative errno on failure.
|
|
|
|
*/
|
2016-11-14 19:58:19 +08:00
|
|
|
int (*dumb_map_offset)(struct drm_file *file_priv,
|
|
|
|
struct drm_device *dev, uint32_t handle,
|
|
|
|
uint64_t *offset);
|
2016-11-14 19:58:21 +08:00
|
|
|
/**
|
|
|
|
* @dumb_destroy:
|
|
|
|
*
|
|
|
|
* This destroys the userspace handle for the given dumb backing storage buffer.
|
|
|
|
* Since buffer objects must be reference counted in the kernel a buffer object
|
|
|
|
* won't be immediately freed if a framebuffer modeset object still uses it.
|
|
|
|
*
|
|
|
|
* Called by the user via ioctl.
|
|
|
|
*
|
2018-11-27 17:19:21 +08:00
|
|
|
* The default implementation is drm_gem_dumb_destroy(). GEM based drivers
|
|
|
|
* must not overwrite this.
|
|
|
|
*
|
2016-11-14 19:58:21 +08:00
|
|
|
* Returns:
|
|
|
|
*
|
|
|
|
* Zero on success, negative errno on failure.
|
|
|
|
*/
|
2016-11-14 19:58:19 +08:00
|
|
|
int (*dumb_destroy)(struct drm_file *file_priv,
|
|
|
|
struct drm_device *dev,
|
|
|
|
uint32_t handle);
|
|
|
|
|
2017-07-21 01:47:43 +08:00
|
|
|
/** @major: driver major number */
|
2016-11-14 19:58:19 +08:00
|
|
|
int major;
|
2017-07-21 01:47:43 +08:00
|
|
|
/** @minor: driver minor number */
|
2016-11-14 19:58:19 +08:00
|
|
|
int minor;
|
2017-07-21 01:47:43 +08:00
|
|
|
/** @patchlevel: driver patch level */
|
2016-11-14 19:58:19 +08:00
|
|
|
int patchlevel;
|
2017-07-21 01:47:43 +08:00
|
|
|
/** @name: driver name */
|
2016-11-14 19:58:19 +08:00
|
|
|
char *name;
|
2017-07-21 01:47:43 +08:00
|
|
|
/** @desc: driver description */
|
2016-11-14 19:58:19 +08:00
|
|
|
char *desc;
|
2017-07-21 01:47:43 +08:00
|
|
|
/** @date: driver date */
|
2016-11-14 19:58:19 +08:00
|
|
|
char *date;
|
|
|
|
|
2019-01-29 18:42:47 +08:00
|
|
|
/**
|
|
|
|
* @driver_features:
|
|
|
|
* Driver features, see &enum drm_driver_feature. Drivers can disable
|
|
|
|
* some features on a per-instance basis using
|
|
|
|
* &drm_device.driver_features.
|
|
|
|
*/
|
2016-11-14 19:58:19 +08:00
|
|
|
u32 driver_features;
|
2017-05-31 17:20:45 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @ioctls:
|
|
|
|
*
|
|
|
|
* Array of driver-private IOCTL description entries. See the chapter on
|
|
|
|
* :ref:`IOCTL support in the userland interfaces
|
|
|
|
* chapter<drm_driver_ioctl>` for the full details.
|
|
|
|
*/
|
|
|
|
|
2016-11-14 19:58:19 +08:00
|
|
|
const struct drm_ioctl_desc *ioctls;
|
2017-05-31 17:20:45 +08:00
|
|
|
/** @num_ioctls: Number of entries in @ioctls. */
|
2016-11-14 19:58:19 +08:00
|
|
|
int num_ioctls;
|
2017-05-31 17:20:45 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @fops:
|
|
|
|
*
|
|
|
|
* File operations for the DRM device node. See the discussion in
|
|
|
|
* :ref:`file operations<drm_driver_fops>` for in-depth coverage and
|
|
|
|
* some examples.
|
|
|
|
*/
|
2016-11-14 19:58:19 +08:00
|
|
|
const struct file_operations *fops;
|
|
|
|
|
2020-11-04 18:04:21 +08:00
|
|
|
#ifdef CONFIG_DRM_LEGACY
|
2017-01-25 14:26:54 +08:00
|
|
|
/* Everything below here is for legacy driver, never use! */
|
|
|
|
/* private: */
|
|
|
|
|
|
|
|
int (*firstopen) (struct drm_device *);
|
2017-05-08 16:26:33 +08:00
|
|
|
void (*preclose) (struct drm_device *, struct drm_file *file_priv);
|
2017-01-25 14:26:54 +08:00
|
|
|
int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);
|
|
|
|
int (*dma_quiescent) (struct drm_device *);
|
|
|
|
int (*context_dtor) (struct drm_device *dev, int context);
|
2021-06-25 21:50:33 +08:00
|
|
|
irqreturn_t (*irq_handler)(int irq, void *arg);
|
|
|
|
void (*irq_preinstall)(struct drm_device *dev);
|
|
|
|
int (*irq_postinstall)(struct drm_device *dev);
|
|
|
|
void (*irq_uninstall)(struct drm_device *dev);
|
2020-01-23 21:59:42 +08:00
|
|
|
u32 (*get_vblank_counter)(struct drm_device *dev, unsigned int pipe);
|
|
|
|
int (*enable_vblank)(struct drm_device *dev, unsigned int pipe);
|
|
|
|
void (*disable_vblank)(struct drm_device *dev, unsigned int pipe);
|
2017-01-25 14:26:54 +08:00
|
|
|
int dev_priv_size;
|
2020-11-04 18:04:21 +08:00
|
|
|
#endif
|
2016-11-14 19:58:19 +08:00
|
|
|
};
|
|
|
|
|
2020-11-04 18:04:23 +08:00
|
|
|
void *__devm_drm_dev_alloc(struct device *parent,
|
|
|
|
const struct drm_driver *driver,
|
2020-04-15 15:39:36 +08:00
|
|
|
size_t size, size_t offset);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* devm_drm_dev_alloc - Resource managed allocation of a &drm_device instance
|
|
|
|
* @parent: Parent device object
|
|
|
|
* @driver: DRM driver
|
|
|
|
* @type: the type of the struct which contains struct &drm_device
|
|
|
|
* @member: the name of the &drm_device within @type.
|
|
|
|
*
|
|
|
|
* This allocates and initialize a new DRM device. No device registration is done.
|
|
|
|
* Call drm_dev_register() to advertice the device to user space and register it
|
|
|
|
* with other core subsystems. This should be done last in the device
|
|
|
|
* initialization sequence to make sure userspace can't access an inconsistent
|
|
|
|
* state.
|
|
|
|
*
|
|
|
|
* The initial ref-count of the object is 1. Use drm_dev_get() and
|
|
|
|
* drm_dev_put() to take and drop further ref-counts.
|
|
|
|
*
|
|
|
|
* It is recommended that drivers embed &struct drm_device into their own device
|
|
|
|
* structure.
|
|
|
|
*
|
|
|
|
* Note that this manages the lifetime of the resulting &drm_device
|
|
|
|
* automatically using devres. The DRM device initialized with this function is
|
|
|
|
* automatically put on driver detach using drm_dev_put().
|
|
|
|
*
|
|
|
|
* RETURNS:
|
|
|
|
* Pointer to new DRM device, or ERR_PTR on failure.
|
|
|
|
*/
|
|
|
|
#define devm_drm_dev_alloc(parent, driver, type, member) \
|
|
|
|
((type *) __devm_drm_dev_alloc(parent, driver, sizeof(type), \
|
|
|
|
offsetof(type, member)))
|
|
|
|
|
2020-11-04 18:04:23 +08:00
|
|
|
struct drm_device *drm_dev_alloc(const struct drm_driver *driver,
|
2016-11-14 19:58:19 +08:00
|
|
|
struct device *parent);
|
|
|
|
int drm_dev_register(struct drm_device *dev, unsigned long flags);
|
|
|
|
void drm_dev_unregister(struct drm_device *dev);
|
|
|
|
|
2017-09-26 16:28:49 +08:00
|
|
|
void drm_dev_get(struct drm_device *dev);
|
|
|
|
void drm_dev_put(struct drm_device *dev);
|
2016-11-14 19:58:19 +08:00
|
|
|
void drm_put_dev(struct drm_device *dev);
|
2018-03-28 15:38:35 +08:00
|
|
|
bool drm_dev_enter(struct drm_device *dev, int *idx);
|
|
|
|
void drm_dev_exit(int idx);
|
2017-08-02 19:56:02 +08:00
|
|
|
void drm_dev_unplug(struct drm_device *dev);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* drm_dev_is_unplugged - is a DRM device unplugged
|
|
|
|
* @dev: DRM device
|
|
|
|
*
|
|
|
|
* This function can be called to check whether a hotpluggable is unplugged.
|
|
|
|
* Unplugging itself is singalled through drm_dev_unplug(). If a device is
|
|
|
|
* unplugged, these two functions guarantee that any store before calling
|
|
|
|
* drm_dev_unplug() is visible to callers of this function after it completes
|
2019-01-29 16:56:43 +08:00
|
|
|
*
|
|
|
|
* WARNING: This function fundamentally races against drm_dev_unplug(). It is
|
|
|
|
* recommended that drivers instead use the underlying drm_dev_enter() and
|
|
|
|
* drm_dev_exit() function pairs.
|
2017-08-02 19:56:02 +08:00
|
|
|
*/
|
2018-03-28 15:38:35 +08:00
|
|
|
static inline bool drm_dev_is_unplugged(struct drm_device *dev)
|
2017-08-02 19:56:02 +08:00
|
|
|
{
|
2018-03-28 15:38:35 +08:00
|
|
|
int idx;
|
|
|
|
|
|
|
|
if (drm_dev_enter(dev, &idx)) {
|
|
|
|
drm_dev_exit(idx);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2017-08-02 19:56:02 +08:00
|
|
|
}
|
|
|
|
|
2020-01-23 20:48:00 +08:00
|
|
|
/**
|
|
|
|
* drm_core_check_all_features - check driver feature flags mask
|
|
|
|
* @dev: DRM device to check
|
|
|
|
* @features: feature flag(s) mask
|
|
|
|
*
|
|
|
|
* This checks @dev for driver features, see &drm_driver.driver_features,
|
|
|
|
* &drm_device.driver_features, and the various &enum drm_driver_feature flags.
|
|
|
|
*
|
|
|
|
* Returns true if all features in the @features mask are supported, false
|
|
|
|
* otherwise.
|
|
|
|
*/
|
|
|
|
static inline bool drm_core_check_all_features(const struct drm_device *dev,
|
|
|
|
u32 features)
|
|
|
|
{
|
|
|
|
u32 supported = dev->driver->driver_features & dev->driver_features;
|
|
|
|
|
|
|
|
return features && (supported & features) == features;
|
|
|
|
}
|
|
|
|
|
2018-07-09 16:40:02 +08:00
|
|
|
/**
|
|
|
|
* drm_core_check_feature - check driver feature flags
|
|
|
|
* @dev: DRM device to check
|
|
|
|
* @feature: feature flag
|
|
|
|
*
|
2018-09-13 21:16:21 +08:00
|
|
|
* This checks @dev for driver features, see &drm_driver.driver_features,
|
2019-01-29 18:42:47 +08:00
|
|
|
* &drm_device.driver_features, and the various &enum drm_driver_feature flags.
|
2018-07-09 16:40:02 +08:00
|
|
|
*
|
|
|
|
* Returns true if the @feature is supported, false otherwise.
|
|
|
|
*/
|
2020-01-23 20:48:00 +08:00
|
|
|
static inline bool drm_core_check_feature(const struct drm_device *dev,
|
|
|
|
enum drm_driver_feature feature)
|
2018-07-09 16:40:02 +08:00
|
|
|
{
|
2020-01-23 20:48:00 +08:00
|
|
|
return drm_core_check_all_features(dev, feature);
|
2018-07-09 16:40:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* drm_drv_uses_atomic_modeset - check if the driver implements
|
|
|
|
* atomic_commit()
|
|
|
|
* @dev: DRM device
|
|
|
|
*
|
|
|
|
* This check is useful if drivers do not have DRIVER_ATOMIC set but
|
|
|
|
* have atomic modesetting internally implemented.
|
|
|
|
*/
|
|
|
|
static inline bool drm_drv_uses_atomic_modeset(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
return drm_core_check_feature(dev, DRIVER_ATOMIC) ||
|
2018-09-18 14:20:18 +08:00
|
|
|
(dev->mode_config.funcs && dev->mode_config.funcs->atomic_commit != NULL);
|
2018-07-09 16:40:02 +08:00
|
|
|
}
|
|
|
|
|
2016-11-14 19:58:19 +08:00
|
|
|
|
2016-11-30 12:18:51 +08:00
|
|
|
int drm_dev_set_unique(struct drm_device *dev, const char *name);
|
|
|
|
|
2021-11-12 21:32:27 +08:00
|
|
|
extern bool drm_firmware_drivers_only(void);
|
2016-11-30 12:18:51 +08:00
|
|
|
|
2016-11-14 19:58:19 +08:00
|
|
|
#endif
|