Home | History | Annotate | Line # | Download | only in drm
      1  1.8  riastrad /*	$NetBSD: drm_drv.h,v 1.8 2021/12/19 11:09:47 riastradh Exp $	*/
      2  1.1  riastrad 
      3  1.1  riastrad /*
      4  1.1  riastrad  * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
      5  1.1  riastrad  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
      6  1.1  riastrad  * Copyright (c) 2009-2010, Code Aurora Forum.
      7  1.1  riastrad  * Copyright 2016 Intel Corp.
      8  1.1  riastrad  *
      9  1.1  riastrad  * Permission is hereby granted, free of charge, to any person obtaining a
     10  1.1  riastrad  * copy of this software and associated documentation files (the "Software"),
     11  1.1  riastrad  * to deal in the Software without restriction, including without limitation
     12  1.1  riastrad  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     13  1.1  riastrad  * and/or sell copies of the Software, and to permit persons to whom the
     14  1.1  riastrad  * Software is furnished to do so, subject to the following conditions:
     15  1.1  riastrad  *
     16  1.1  riastrad  * The above copyright notice and this permission notice (including the next
     17  1.1  riastrad  * paragraph) shall be included in all copies or substantial portions of the
     18  1.1  riastrad  * Software.
     19  1.1  riastrad  *
     20  1.1  riastrad  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     21  1.1  riastrad  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     22  1.1  riastrad  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     23  1.1  riastrad  * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
     24  1.1  riastrad  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     25  1.1  riastrad  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     26  1.1  riastrad  * OTHER DEALINGS IN THE SOFTWARE.
     27  1.1  riastrad  */
     28  1.1  riastrad 
     29  1.1  riastrad #ifndef _DRM_DRV_H_
     30  1.1  riastrad #define _DRM_DRV_H_
     31  1.1  riastrad 
     32  1.1  riastrad #include <linux/list.h>
     33  1.1  riastrad #include <linux/irqreturn.h>
     34  1.3  riastrad #include <linux/ktime.h>
     35  1.1  riastrad 
     36  1.1  riastrad #include <drm/drm_device.h>
     37  1.1  riastrad 
     38  1.1  riastrad struct drm_file;
     39  1.1  riastrad struct drm_gem_object;
     40  1.1  riastrad struct drm_master;
     41  1.1  riastrad struct drm_minor;
     42  1.1  riastrad struct dma_buf_attachment;
     43  1.1  riastrad struct drm_display_mode;
     44  1.1  riastrad struct drm_mode_create_dumb;
     45  1.1  riastrad struct drm_printer;
     46  1.1  riastrad 
     47  1.1  riastrad /**
     48  1.1  riastrad  * enum drm_driver_feature - feature flags
     49  1.1  riastrad  *
     50  1.1  riastrad  * See &drm_driver.driver_features, drm_device.driver_features and
     51  1.1  riastrad  * drm_core_check_feature().
     52  1.1  riastrad  */
     53  1.1  riastrad enum drm_driver_feature {
     54  1.1  riastrad 	/**
     55  1.1  riastrad 	 * @DRIVER_GEM:
     56  1.1  riastrad 	 *
     57  1.1  riastrad 	 * Driver use the GEM memory manager. This should be set for all modern
     58  1.1  riastrad 	 * drivers.
     59  1.1  riastrad 	 */
     60  1.1  riastrad 	DRIVER_GEM			= BIT(0),
     61  1.1  riastrad 	/**
     62  1.1  riastrad 	 * @DRIVER_MODESET:
     63  1.1  riastrad 	 *
     64  1.1  riastrad 	 * Driver supports mode setting interfaces (KMS).
     65  1.1  riastrad 	 */
     66  1.1  riastrad 	DRIVER_MODESET			= BIT(1),
     67  1.1  riastrad 	/**
     68  1.1  riastrad 	 * @DRIVER_RENDER:
     69  1.1  riastrad 	 *
     70  1.1  riastrad 	 * Driver supports dedicated render nodes. See also the :ref:`section on
     71  1.1  riastrad 	 * render nodes <drm_render_node>` for details.
     72  1.1  riastrad 	 */
     73  1.1  riastrad 	DRIVER_RENDER			= BIT(3),
     74  1.1  riastrad 	/**
     75  1.1  riastrad 	 * @DRIVER_ATOMIC:
     76  1.1  riastrad 	 *
     77  1.1  riastrad 	 * Driver supports the full atomic modesetting userspace API. Drivers
     78  1.1  riastrad 	 * which only use atomic internally, but do not the support the full
     79  1.1  riastrad 	 * userspace API (e.g. not all properties converted to atomic, or
     80  1.1  riastrad 	 * multi-plane updates are not guaranteed to be tear-free) should not
     81  1.1  riastrad 	 * set this flag.
     82  1.1  riastrad 	 */
     83  1.1  riastrad 	DRIVER_ATOMIC			= BIT(4),
     84  1.1  riastrad 	/**
     85  1.1  riastrad 	 * @DRIVER_SYNCOBJ:
     86  1.1  riastrad 	 *
     87  1.1  riastrad 	 * Driver supports &drm_syncobj for explicit synchronization of command
     88  1.1  riastrad 	 * submission.
     89  1.1  riastrad 	 */
     90  1.1  riastrad 	DRIVER_SYNCOBJ                  = BIT(5),
     91  1.1  riastrad 	/**
     92  1.1  riastrad 	 * @DRIVER_SYNCOBJ_TIMELINE:
     93  1.1  riastrad 	 *
     94  1.1  riastrad 	 * Driver supports the timeline flavor of &drm_syncobj for explicit
     95  1.1  riastrad 	 * synchronization of command submission.
     96  1.1  riastrad 	 */
     97  1.1  riastrad 	DRIVER_SYNCOBJ_TIMELINE         = BIT(6),
     98  1.1  riastrad 
     99  1.1  riastrad 	/* IMPORTANT: Below are all the legacy flags, add new ones above. */
    100  1.1  riastrad 
    101  1.1  riastrad 	/**
    102  1.1  riastrad 	 * @DRIVER_USE_AGP:
    103  1.1  riastrad 	 *
    104  1.1  riastrad 	 * Set up DRM AGP support, see drm_agp_init(), the DRM core will manage
    105  1.1  riastrad 	 * AGP resources. New drivers don't need this.
    106  1.1  riastrad 	 */
    107  1.1  riastrad 	DRIVER_USE_AGP			= BIT(25),
    108  1.1  riastrad 	/**
    109  1.1  riastrad 	 * @DRIVER_LEGACY:
    110  1.1  riastrad 	 *
    111  1.1  riastrad 	 * Denote a legacy driver using shadow attach. Do not use.
    112  1.1  riastrad 	 */
    113  1.1  riastrad 	DRIVER_LEGACY			= BIT(26),
    114  1.1  riastrad 	/**
    115  1.1  riastrad 	 * @DRIVER_PCI_DMA:
    116  1.1  riastrad 	 *
    117  1.1  riastrad 	 * Driver is capable of PCI DMA, mapping of PCI DMA buffers to userspace
    118  1.1  riastrad 	 * will be enabled. Only for legacy drivers. Do not use.
    119  1.1  riastrad 	 */
    120  1.1  riastrad 	DRIVER_PCI_DMA			= BIT(27),
    121  1.1  riastrad 	/**
    122  1.1  riastrad 	 * @DRIVER_SG:
    123  1.1  riastrad 	 *
    124  1.1  riastrad 	 * Driver can perform scatter/gather DMA, allocation and mapping of
    125  1.1  riastrad 	 * scatter/gather buffers will be enabled. Only for legacy drivers. Do
    126  1.1  riastrad 	 * not use.
    127  1.1  riastrad 	 */
    128  1.1  riastrad 	DRIVER_SG			= BIT(28),
    129  1.1  riastrad 
    130  1.1  riastrad 	/**
    131  1.1  riastrad 	 * @DRIVER_HAVE_DMA:
    132  1.1  riastrad 	 *
    133  1.1  riastrad 	 * Driver supports DMA, the userspace DMA API will be supported. Only
    134  1.1  riastrad 	 * for legacy drivers. Do not use.
    135  1.1  riastrad 	 */
    136  1.1  riastrad 	DRIVER_HAVE_DMA			= BIT(29),
    137  1.1  riastrad 	/**
    138  1.1  riastrad 	 * @DRIVER_HAVE_IRQ:
    139  1.1  riastrad 	 *
    140  1.1  riastrad 	 * Legacy irq support. Only for legacy drivers. Do not use.
    141  1.1  riastrad 	 *
    142  1.1  riastrad 	 * New drivers can either use the drm_irq_install() and
    143  1.1  riastrad 	 * drm_irq_uninstall() helper functions, or roll their own irq support
    144  1.1  riastrad 	 * code by calling request_irq() directly.
    145  1.1  riastrad 	 */
    146  1.1  riastrad 	DRIVER_HAVE_IRQ			= BIT(30),
    147  1.1  riastrad 	/**
    148  1.1  riastrad 	 * @DRIVER_KMS_LEGACY_CONTEXT:
    149  1.1  riastrad 	 *
    150  1.1  riastrad 	 * Used only by nouveau for backwards compatibility with existing
    151  1.1  riastrad 	 * userspace.  Do not use.
    152  1.1  riastrad 	 */
    153  1.1  riastrad 	DRIVER_KMS_LEGACY_CONTEXT	= BIT(31),
    154  1.1  riastrad };
    155  1.1  riastrad 
    156  1.1  riastrad /**
    157  1.1  riastrad  * struct drm_driver - DRM driver structure
    158  1.1  riastrad  *
    159  1.1  riastrad  * This structure represent the common code for a family of cards. There will be
    160  1.1  riastrad  * one &struct drm_device for each card present in this family. It contains lots
    161  1.1  riastrad  * of vfunc entries, and a pile of those probably should be moved to more
    162  1.1  riastrad  * appropriate places like &drm_mode_config_funcs or into a new operations
    163  1.1  riastrad  * structure for GEM drivers.
    164  1.1  riastrad  */
    165  1.1  riastrad struct drm_driver {
    166  1.1  riastrad 	/**
    167  1.1  riastrad 	 * @load:
    168  1.1  riastrad 	 *
    169  1.1  riastrad 	 * Backward-compatible driver callback to complete
    170  1.1  riastrad 	 * initialization steps after the driver is registered.  For
    171  1.1  riastrad 	 * this reason, may suffer from race conditions and its use is
    172  1.1  riastrad 	 * deprecated for new drivers.  It is therefore only supported
    173  1.1  riastrad 	 * for existing drivers not yet converted to the new scheme.
    174  1.1  riastrad 	 * See drm_dev_init() and drm_dev_register() for proper and
    175  1.1  riastrad 	 * race-free way to set up a &struct drm_device.
    176  1.1  riastrad 	 *
    177  1.1  riastrad 	 * This is deprecated, do not use!
    178  1.1  riastrad 	 *
    179  1.1  riastrad 	 * Returns:
    180  1.1  riastrad 	 *
    181  1.1  riastrad 	 * Zero on success, non-zero value on failure.
    182  1.1  riastrad 	 */
    183  1.1  riastrad 	int (*load) (struct drm_device *, unsigned long flags);
    184  1.1  riastrad 
    185  1.1  riastrad 	/**
    186  1.1  riastrad 	 * @open:
    187  1.1  riastrad 	 *
    188  1.1  riastrad 	 * Driver callback when a new &struct drm_file is opened. Useful for
    189  1.1  riastrad 	 * setting up driver-private data structures like buffer allocators,
    190  1.1  riastrad 	 * execution contexts or similar things. Such driver-private resources
    191  1.1  riastrad 	 * must be released again in @postclose.
    192  1.1  riastrad 	 *
    193  1.1  riastrad 	 * Since the display/modeset side of DRM can only be owned by exactly
    194  1.1  riastrad 	 * one &struct drm_file (see &drm_file.is_master and &drm_device.master)
    195  1.1  riastrad 	 * there should never be a need to set up any modeset related resources
    196  1.1  riastrad 	 * in this callback. Doing so would be a driver design bug.
    197  1.1  riastrad 	 *
    198  1.1  riastrad 	 * Returns:
    199  1.1  riastrad 	 *
    200  1.1  riastrad 	 * 0 on success, a negative error code on failure, which will be
    201  1.1  riastrad 	 * promoted to userspace as the result of the open() system call.
    202  1.1  riastrad 	 */
    203  1.1  riastrad 	int (*open) (struct drm_device *, struct drm_file *);
    204  1.1  riastrad 
    205  1.1  riastrad 	/**
    206  1.1  riastrad 	 * @postclose:
    207  1.1  riastrad 	 *
    208  1.1  riastrad 	 * One of the driver callbacks when a new &struct drm_file is closed.
    209  1.1  riastrad 	 * Useful for tearing down driver-private data structures allocated in
    210  1.1  riastrad 	 * @open like buffer allocators, execution contexts or similar things.
    211  1.1  riastrad 	 *
    212  1.1  riastrad 	 * Since the display/modeset side of DRM can only be owned by exactly
    213  1.1  riastrad 	 * one &struct drm_file (see &drm_file.is_master and &drm_device.master)
    214  1.1  riastrad 	 * there should never be a need to tear down any modeset related
    215  1.1  riastrad 	 * resources in this callback. Doing so would be a driver design bug.
    216  1.1  riastrad 	 */
    217  1.1  riastrad 	void (*postclose) (struct drm_device *, struct drm_file *);
    218  1.1  riastrad 
    219  1.1  riastrad 	/**
    220  1.1  riastrad 	 * @lastclose:
    221  1.1  riastrad 	 *
    222  1.1  riastrad 	 * Called when the last &struct drm_file has been closed and there's
    223  1.1  riastrad 	 * currently no userspace client for the &struct drm_device.
    224  1.1  riastrad 	 *
    225  1.1  riastrad 	 * Modern drivers should only use this to force-restore the fbdev
    226  1.1  riastrad 	 * framebuffer using drm_fb_helper_restore_fbdev_mode_unlocked().
    227  1.1  riastrad 	 * Anything else would indicate there's something seriously wrong.
    228  1.1  riastrad 	 * Modern drivers can also use this to execute delayed power switching
    229  1.1  riastrad 	 * state changes, e.g. in conjunction with the :ref:`vga_switcheroo`
    230  1.1  riastrad 	 * infrastructure.
    231  1.1  riastrad 	 *
    232  1.1  riastrad 	 * This is called after @postclose hook has been called.
    233  1.1  riastrad 	 *
    234  1.1  riastrad 	 * NOTE:
    235  1.1  riastrad 	 *
    236  1.1  riastrad 	 * All legacy drivers use this callback to de-initialize the hardware.
    237  1.1  riastrad 	 * This is purely because of the shadow-attach model, where the DRM
    238  1.1  riastrad 	 * kernel driver does not really own the hardware. Instead ownershipe is
    239  1.1  riastrad 	 * handled with the help of userspace through an inheritedly racy dance
    240  1.1  riastrad 	 * to set/unset the VT into raw mode.
    241  1.1  riastrad 	 *
    242  1.1  riastrad 	 * Legacy drivers initialize the hardware in the @firstopen callback,
    243  1.1  riastrad 	 * which isn't even called for modern drivers.
    244  1.1  riastrad 	 */
    245  1.1  riastrad 	void (*lastclose) (struct drm_device *);
    246  1.1  riastrad 
    247  1.1  riastrad 	/**
    248  1.1  riastrad 	 * @unload:
    249  1.1  riastrad 	 *
    250  1.1  riastrad 	 * Reverse the effects of the driver load callback.  Ideally,
    251  1.1  riastrad 	 * the clean up performed by the driver should happen in the
    252  1.1  riastrad 	 * reverse order of the initialization.  Similarly to the load
    253  1.1  riastrad 	 * hook, this handler is deprecated and its usage should be
    254  1.1  riastrad 	 * dropped in favor of an open-coded teardown function at the
    255  1.1  riastrad 	 * driver layer.  See drm_dev_unregister() and drm_dev_put()
    256  1.1  riastrad 	 * for the proper way to remove a &struct drm_device.
    257  1.1  riastrad 	 *
    258  1.1  riastrad 	 * The unload() hook is called right after unregistering
    259  1.1  riastrad 	 * the device.
    260  1.1  riastrad 	 *
    261  1.1  riastrad 	 */
    262  1.1  riastrad 	void (*unload) (struct drm_device *);
    263  1.1  riastrad 
    264  1.1  riastrad 	/**
    265  1.1  riastrad 	 * @release:
    266  1.1  riastrad 	 *
    267  1.1  riastrad 	 * Optional callback for destroying device data after the final
    268  1.1  riastrad 	 * reference is released, i.e. the device is being destroyed. Drivers
    269  1.1  riastrad 	 * using this callback are responsible for calling drm_dev_fini()
    270  1.1  riastrad 	 * to finalize the device and then freeing the struct themselves.
    271  1.1  riastrad 	 */
    272  1.1  riastrad 	void (*release) (struct drm_device *);
    273  1.1  riastrad 
    274  1.1  riastrad 	/**
    275  1.1  riastrad 	 * @get_vblank_counter:
    276  1.1  riastrad 	 *
    277  1.1  riastrad 	 * Driver callback for fetching a raw hardware vblank counter for the
    278  1.1  riastrad 	 * CRTC specified with the pipe argument.  If a device doesn't have a
    279  1.1  riastrad 	 * hardware counter, the driver can simply leave the hook as NULL.
    280  1.1  riastrad 	 * The DRM core will account for missed vblank events while interrupts
    281  1.1  riastrad 	 * where disabled based on system timestamps.
    282  1.1  riastrad 	 *
    283  1.1  riastrad 	 * Wraparound handling and loss of events due to modesetting is dealt
    284  1.1  riastrad 	 * with in the DRM core code, as long as drivers call
    285  1.1  riastrad 	 * drm_crtc_vblank_off() and drm_crtc_vblank_on() when disabling or
    286  1.1  riastrad 	 * enabling a CRTC.
    287  1.1  riastrad 	 *
    288  1.1  riastrad 	 * This is deprecated and should not be used by new drivers.
    289  1.1  riastrad 	 * Use &drm_crtc_funcs.get_vblank_counter instead.
    290  1.1  riastrad 	 *
    291  1.1  riastrad 	 * Returns:
    292  1.1  riastrad 	 *
    293  1.1  riastrad 	 * Raw vblank counter value.
    294  1.1  riastrad 	 */
    295  1.1  riastrad 	u32 (*get_vblank_counter) (struct drm_device *dev, unsigned int pipe);
    296  1.1  riastrad 
    297  1.1  riastrad 	/**
    298  1.1  riastrad 	 * @enable_vblank:
    299  1.1  riastrad 	 *
    300  1.1  riastrad 	 * Enable vblank interrupts for the CRTC specified with the pipe
    301  1.1  riastrad 	 * argument.
    302  1.1  riastrad 	 *
    303  1.1  riastrad 	 * This is deprecated and should not be used by new drivers.
    304  1.1  riastrad 	 * Use &drm_crtc_funcs.enable_vblank instead.
    305  1.1  riastrad 	 *
    306  1.1  riastrad 	 * Returns:
    307  1.1  riastrad 	 *
    308  1.1  riastrad 	 * Zero on success, appropriate errno if the given @crtc's vblank
    309  1.1  riastrad 	 * interrupt cannot be enabled.
    310  1.1  riastrad 	 */
    311  1.1  riastrad 	int (*enable_vblank) (struct drm_device *dev, unsigned int pipe);
    312  1.1  riastrad 
    313  1.1  riastrad 	/**
    314  1.1  riastrad 	 * @disable_vblank:
    315  1.1  riastrad 	 *
    316  1.1  riastrad 	 * Disable vblank interrupts for the CRTC specified with the pipe
    317  1.1  riastrad 	 * argument.
    318  1.1  riastrad 	 *
    319  1.1  riastrad 	 * This is deprecated and should not be used by new drivers.
    320  1.1  riastrad 	 * Use &drm_crtc_funcs.disable_vblank instead.
    321  1.1  riastrad 	 */
    322  1.1  riastrad 	void (*disable_vblank) (struct drm_device *dev, unsigned int pipe);
    323  1.1  riastrad 
    324  1.1  riastrad 	/**
    325  1.1  riastrad 	 * @get_scanout_position:
    326  1.1  riastrad 	 *
    327  1.1  riastrad 	 * Called by vblank timestamping code.
    328  1.1  riastrad 	 *
    329  1.1  riastrad 	 * Returns the current display scanout position from a crtc, and an
    330  1.1  riastrad 	 * optional accurate ktime_get() timestamp of when position was
    331  1.1  riastrad 	 * measured. Note that this is a helper callback which is only used if a
    332  1.1  riastrad 	 * driver uses drm_calc_vbltimestamp_from_scanoutpos() for the
    333  1.1  riastrad 	 * @get_vblank_timestamp callback.
    334  1.1  riastrad 	 *
    335  1.1  riastrad 	 * Parameters:
    336  1.1  riastrad 	 *
    337  1.1  riastrad 	 * dev:
    338  1.1  riastrad 	 *     DRM device.
    339  1.1  riastrad 	 * pipe:
    340  1.1  riastrad 	 *     Id of the crtc to query.
    341  1.1  riastrad 	 * in_vblank_irq:
    342  1.1  riastrad 	 *     True when called from drm_crtc_handle_vblank().  Some drivers
    343  1.1  riastrad 	 *     need to apply some workarounds for gpu-specific vblank irq quirks
    344  1.1  riastrad 	 *     if flag is set.
    345  1.1  riastrad 	 * vpos:
    346  1.1  riastrad 	 *     Target location for current vertical scanout position.
    347  1.1  riastrad 	 * hpos:
    348  1.1  riastrad 	 *     Target location for current horizontal scanout position.
    349  1.1  riastrad 	 * stime:
    350  1.1  riastrad 	 *     Target location for timestamp taken immediately before
    351  1.1  riastrad 	 *     scanout position query. Can be NULL to skip timestamp.
    352  1.1  riastrad 	 * etime:
    353  1.1  riastrad 	 *     Target location for timestamp taken immediately after
    354  1.1  riastrad 	 *     scanout position query. Can be NULL to skip timestamp.
    355  1.1  riastrad 	 * mode:
    356  1.1  riastrad 	 *     Current display timings.
    357  1.1  riastrad 	 *
    358  1.1  riastrad 	 * Returns vpos as a positive number while in active scanout area.
    359  1.1  riastrad 	 * Returns vpos as a negative number inside vblank, counting the number
    360  1.1  riastrad 	 * of scanlines to go until end of vblank, e.g., -1 means "one scanline
    361  1.1  riastrad 	 * until start of active scanout / end of vblank."
    362  1.1  riastrad 	 *
    363  1.1  riastrad 	 * Returns:
    364  1.1  riastrad 	 *
    365  1.1  riastrad 	 * True on success, false if a reliable scanout position counter could
    366  1.1  riastrad 	 * not be read out.
    367  1.1  riastrad 	 *
    368  1.1  riastrad 	 * FIXME:
    369  1.1  riastrad 	 *
    370  1.1  riastrad 	 * Since this is a helper to implement @get_vblank_timestamp, we should
    371  1.1  riastrad 	 * move it to &struct drm_crtc_helper_funcs, like all the other
    372  1.1  riastrad 	 * helper-internal hooks.
    373  1.1  riastrad 	 */
    374  1.1  riastrad 	bool (*get_scanout_position) (struct drm_device *dev, unsigned int pipe,
    375  1.1  riastrad 				      bool in_vblank_irq, int *vpos, int *hpos,
    376  1.1  riastrad 				      ktime_t *stime, ktime_t *etime,
    377  1.1  riastrad 				      const struct drm_display_mode *mode);
    378  1.1  riastrad 
    379  1.1  riastrad 	/**
    380  1.1  riastrad 	 * @get_vblank_timestamp:
    381  1.1  riastrad 	 *
    382  1.1  riastrad 	 * Called by drm_get_last_vbltimestamp(). Should return a precise
    383  1.1  riastrad 	 * timestamp when the most recent VBLANK interval ended or will end.
    384  1.1  riastrad 	 *
    385  1.1  riastrad 	 * Specifically, the timestamp in @vblank_time should correspond as
    386  1.1  riastrad 	 * closely as possible to the time when the first video scanline of
    387  1.1  riastrad 	 * the video frame after the end of VBLANK will start scanning out,
    388  1.1  riastrad 	 * the time immediately after end of the VBLANK interval. If the
    389  1.1  riastrad 	 * @crtc is currently inside VBLANK, this will be a time in the future.
    390  1.1  riastrad 	 * If the @crtc is currently scanning out a frame, this will be the
    391  1.1  riastrad 	 * past start time of the current scanout. This is meant to adhere
    392  1.1  riastrad 	 * to the OpenML OML_sync_control extension specification.
    393  1.1  riastrad 	 *
    394  1.1  riastrad 	 * Paramters:
    395  1.1  riastrad 	 *
    396  1.1  riastrad 	 * dev:
    397  1.1  riastrad 	 *     dev DRM device handle.
    398  1.1  riastrad 	 * pipe:
    399  1.1  riastrad 	 *     crtc for which timestamp should be returned.
    400  1.1  riastrad 	 * max_error:
    401  1.1  riastrad 	 *     Maximum allowable timestamp error in nanoseconds.
    402  1.1  riastrad 	 *     Implementation should strive to provide timestamp
    403  1.1  riastrad 	 *     with an error of at most max_error nanoseconds.
    404  1.1  riastrad 	 *     Returns true upper bound on error for timestamp.
    405  1.1  riastrad 	 * vblank_time:
    406  1.1  riastrad 	 *     Target location for returned vblank timestamp.
    407  1.1  riastrad 	 * in_vblank_irq:
    408  1.1  riastrad 	 *     True when called from drm_crtc_handle_vblank().  Some drivers
    409  1.1  riastrad 	 *     need to apply some workarounds for gpu-specific vblank irq quirks
    410  1.1  riastrad 	 *     if flag is set.
    411  1.1  riastrad 	 *
    412  1.1  riastrad 	 * Returns:
    413  1.1  riastrad 	 *
    414  1.1  riastrad 	 * True on success, false on failure, which means the core should
    415  1.1  riastrad 	 * fallback to a simple timestamp taken in drm_crtc_handle_vblank().
    416  1.1  riastrad 	 *
    417  1.1  riastrad 	 * FIXME:
    418  1.1  riastrad 	 *
    419  1.1  riastrad 	 * We should move this hook to &struct drm_crtc_funcs like all the other
    420  1.1  riastrad 	 * vblank hooks.
    421  1.1  riastrad 	 */
    422  1.1  riastrad 	bool (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
    423  1.1  riastrad 				     int *max_error,
    424  1.1  riastrad 				     ktime_t *vblank_time,
    425  1.1  riastrad 				     bool in_vblank_irq);
    426  1.1  riastrad 
    427  1.1  riastrad 	/**
    428  1.1  riastrad 	 * @irq_handler:
    429  1.1  riastrad 	 *
    430  1.1  riastrad 	 * Interrupt handler called when using drm_irq_install(). Not used by
    431  1.1  riastrad 	 * drivers which implement their own interrupt handling.
    432  1.1  riastrad 	 */
    433  1.5  riastrad 	irqreturn_t(*irq_handler) (DRM_IRQ_ARGS);
    434  1.1  riastrad 
    435  1.1  riastrad 	/**
    436  1.1  riastrad 	 * @irq_preinstall:
    437  1.1  riastrad 	 *
    438  1.1  riastrad 	 * Optional callback used by drm_irq_install() which is called before
    439  1.1  riastrad 	 * the interrupt handler is registered. This should be used to clear out
    440  1.1  riastrad 	 * any pending interrupts (from e.g. firmware based drives) and reset
    441  1.1  riastrad 	 * the interrupt handling registers.
    442  1.1  riastrad 	 */
    443  1.1  riastrad 	void (*irq_preinstall) (struct drm_device *dev);
    444  1.1  riastrad 
    445  1.1  riastrad 	/**
    446  1.1  riastrad 	 * @irq_postinstall:
    447  1.1  riastrad 	 *
    448  1.1  riastrad 	 * Optional callback used by drm_irq_install() which is called after
    449  1.1  riastrad 	 * the interrupt handler is registered. This should be used to enable
    450  1.1  riastrad 	 * interrupt generation in the hardware.
    451  1.1  riastrad 	 */
    452  1.1  riastrad 	int (*irq_postinstall) (struct drm_device *dev);
    453  1.1  riastrad 
    454  1.1  riastrad 	/**
    455  1.1  riastrad 	 * @irq_uninstall:
    456  1.1  riastrad 	 *
    457  1.1  riastrad 	 * Optional callback used by drm_irq_uninstall() which is called before
    458  1.1  riastrad 	 * the interrupt handler is unregistered. This should be used to disable
    459  1.1  riastrad 	 * interrupt generation in the hardware.
    460  1.1  riastrad 	 */
    461  1.1  riastrad 	void (*irq_uninstall) (struct drm_device *dev);
    462  1.1  riastrad 
    463  1.4  riastrad #ifdef __NetBSD__
    464  1.4  riastrad 	int (*request_irq)(struct drm_device *, int);
    465  1.4  riastrad 	void (*free_irq)(struct drm_device *);
    466  1.4  riastrad #endif
    467  1.4  riastrad 
    468  1.1  riastrad 	/**
    469  1.1  riastrad 	 * @master_create:
    470  1.1  riastrad 	 *
    471  1.1  riastrad 	 * Called whenever a new master is created. Only used by vmwgfx.
    472  1.1  riastrad 	 */
    473  1.1  riastrad 	int (*master_create)(struct drm_device *dev, struct drm_master *master);
    474  1.1  riastrad 
    475  1.1  riastrad 	/**
    476  1.1  riastrad 	 * @master_destroy:
    477  1.1  riastrad 	 *
    478  1.1  riastrad 	 * Called whenever a master is destroyed. Only used by vmwgfx.
    479  1.1  riastrad 	 */
    480  1.1  riastrad 	void (*master_destroy)(struct drm_device *dev, struct drm_master *master);
    481  1.1  riastrad 
    482  1.1  riastrad 	/**
    483  1.1  riastrad 	 * @master_set:
    484  1.1  riastrad 	 *
    485  1.1  riastrad 	 * Called whenever the minor master is set. Only used by vmwgfx.
    486  1.1  riastrad 	 */
    487  1.1  riastrad 	int (*master_set)(struct drm_device *dev, struct drm_file *file_priv,
    488  1.1  riastrad 			  bool from_open);
    489  1.1  riastrad 	/**
    490  1.1  riastrad 	 * @master_drop:
    491  1.1  riastrad 	 *
    492  1.1  riastrad 	 * Called whenever the minor master is dropped. Only used by vmwgfx.
    493  1.1  riastrad 	 */
    494  1.1  riastrad 	void (*master_drop)(struct drm_device *dev, struct drm_file *file_priv);
    495  1.1  riastrad 
    496  1.1  riastrad 	/**
    497  1.1  riastrad 	 * @debugfs_init:
    498  1.1  riastrad 	 *
    499  1.1  riastrad 	 * Allows drivers to create driver-specific debugfs files.
    500  1.1  riastrad 	 */
    501  1.1  riastrad 	int (*debugfs_init)(struct drm_minor *minor);
    502  1.1  riastrad 
    503  1.1  riastrad 	/**
    504  1.1  riastrad 	 * @gem_free_object: deconstructor for drm_gem_objects
    505  1.1  riastrad 	 *
    506  1.1  riastrad 	 * This is deprecated and should not be used by new drivers. Use
    507  1.1  riastrad 	 * &drm_gem_object_funcs.free instead.
    508  1.1  riastrad 	 */
    509  1.1  riastrad 	void (*gem_free_object) (struct drm_gem_object *obj);
    510  1.1  riastrad 
    511  1.1  riastrad 	/**
    512  1.1  riastrad 	 * @gem_free_object_unlocked: deconstructor for drm_gem_objects
    513  1.1  riastrad 	 *
    514  1.1  riastrad 	 * This is deprecated and should not be used by new drivers. Use
    515  1.1  riastrad 	 * &drm_gem_object_funcs.free instead.
    516  1.1  riastrad 	 * Compared to @gem_free_object this is not encumbered with
    517  1.1  riastrad 	 * &drm_device.struct_mutex legacy locking schemes.
    518  1.1  riastrad 	 */
    519  1.1  riastrad 	void (*gem_free_object_unlocked) (struct drm_gem_object *obj);
    520  1.1  riastrad 
    521  1.1  riastrad 	/**
    522  1.1  riastrad 	 * @gem_open_object:
    523  1.1  riastrad 	 *
    524  1.1  riastrad 	 * This callback is deprecated in favour of &drm_gem_object_funcs.open.
    525  1.1  riastrad 	 *
    526  1.1  riastrad 	 * Driver hook called upon gem handle creation
    527  1.1  riastrad 	 */
    528  1.1  riastrad 	int (*gem_open_object) (struct drm_gem_object *, struct drm_file *);
    529  1.1  riastrad 
    530  1.1  riastrad 	/**
    531  1.1  riastrad 	 * @gem_close_object:
    532  1.1  riastrad 	 *
    533  1.1  riastrad 	 * This callback is deprecated in favour of &drm_gem_object_funcs.close.
    534  1.1  riastrad 	 *
    535  1.1  riastrad 	 * Driver hook called upon gem handle release
    536  1.1  riastrad 	 */
    537  1.1  riastrad 	void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
    538  1.1  riastrad 
    539  1.1  riastrad 	/**
    540  1.1  riastrad 	 * @gem_print_info:
    541  1.1  riastrad 	 *
    542  1.1  riastrad 	 * This callback is deprecated in favour of
    543  1.1  riastrad 	 * &drm_gem_object_funcs.print_info.
    544  1.1  riastrad 	 *
    545  1.1  riastrad 	 * If driver subclasses struct &drm_gem_object, it can implement this
    546  1.1  riastrad 	 * optional hook for printing additional driver specific info.
    547  1.1  riastrad 	 *
    548  1.1  riastrad 	 * drm_printf_indent() should be used in the callback passing it the
    549  1.1  riastrad 	 * indent argument.
    550  1.1  riastrad 	 *
    551  1.1  riastrad 	 * This callback is called from drm_gem_print_info().
    552  1.1  riastrad 	 */
    553  1.1  riastrad 	void (*gem_print_info)(struct drm_printer *p, unsigned int indent,
    554  1.1  riastrad 			       const struct drm_gem_object *obj);
    555  1.1  riastrad 
    556  1.1  riastrad 	/**
    557  1.1  riastrad 	 * @gem_create_object: constructor for gem objects
    558  1.1  riastrad 	 *
    559  1.1  riastrad 	 * Hook for allocating the GEM object struct, for use by the CMA and
    560  1.1  riastrad 	 * SHMEM GEM helpers.
    561  1.1  riastrad 	 */
    562  1.1  riastrad 	struct drm_gem_object *(*gem_create_object)(struct drm_device *dev,
    563  1.1  riastrad 						    size_t size);
    564  1.1  riastrad 	/**
    565  1.1  riastrad 	 * @prime_handle_to_fd:
    566  1.1  riastrad 	 *
    567  1.1  riastrad 	 * Main PRIME export function. Should be implemented with
    568  1.1  riastrad 	 * drm_gem_prime_handle_to_fd() for GEM based drivers.
    569  1.1  riastrad 	 *
    570  1.1  riastrad 	 * For an in-depth discussion see :ref:`PRIME buffer sharing
    571  1.1  riastrad 	 * documentation <prime_buffer_sharing>`.
    572  1.1  riastrad 	 */
    573  1.1  riastrad 	int (*prime_handle_to_fd)(struct drm_device *dev, struct drm_file *file_priv,
    574  1.1  riastrad 				uint32_t handle, uint32_t flags, int *prime_fd);
    575  1.1  riastrad 	/**
    576  1.1  riastrad 	 * @prime_fd_to_handle:
    577  1.1  riastrad 	 *
    578  1.1  riastrad 	 * Main PRIME import function. Should be implemented with
    579  1.1  riastrad 	 * drm_gem_prime_fd_to_handle() for GEM based drivers.
    580  1.1  riastrad 	 *
    581  1.1  riastrad 	 * For an in-depth discussion see :ref:`PRIME buffer sharing
    582  1.1  riastrad 	 * documentation <prime_buffer_sharing>`.
    583  1.1  riastrad 	 */
    584  1.1  riastrad 	int (*prime_fd_to_handle)(struct drm_device *dev, struct drm_file *file_priv,
    585  1.1  riastrad 				int prime_fd, uint32_t *handle);
    586  1.1  riastrad 	/**
    587  1.1  riastrad 	 * @gem_prime_export:
    588  1.1  riastrad 	 *
    589  1.1  riastrad 	 * Export hook for GEM drivers. Deprecated in favour of
    590  1.1  riastrad 	 * &drm_gem_object_funcs.export.
    591  1.1  riastrad 	 */
    592  1.1  riastrad 	struct dma_buf * (*gem_prime_export)(struct drm_gem_object *obj,
    593  1.1  riastrad 					     int flags);
    594  1.1  riastrad 	/**
    595  1.1  riastrad 	 * @gem_prime_import:
    596  1.1  riastrad 	 *
    597  1.1  riastrad 	 * Import hook for GEM drivers.
    598  1.1  riastrad 	 *
    599  1.1  riastrad 	 * This defaults to drm_gem_prime_import() if not set.
    600  1.1  riastrad 	 */
    601  1.1  riastrad 	struct drm_gem_object * (*gem_prime_import)(struct drm_device *dev,
    602  1.1  riastrad 				struct dma_buf *dma_buf);
    603  1.1  riastrad 
    604  1.1  riastrad 	/**
    605  1.1  riastrad 	 * @gem_prime_pin:
    606  1.1  riastrad 	 *
    607  1.1  riastrad 	 * Deprecated hook in favour of &drm_gem_object_funcs.pin.
    608  1.1  riastrad 	 */
    609  1.1  riastrad 	int (*gem_prime_pin)(struct drm_gem_object *obj);
    610  1.1  riastrad 
    611  1.1  riastrad 	/**
    612  1.1  riastrad 	 * @gem_prime_unpin:
    613  1.1  riastrad 	 *
    614  1.1  riastrad 	 * Deprecated hook in favour of &drm_gem_object_funcs.unpin.
    615  1.1  riastrad 	 */
    616  1.1  riastrad 	void (*gem_prime_unpin)(struct drm_gem_object *obj);
    617  1.1  riastrad 
    618  1.1  riastrad 
    619  1.1  riastrad 	/**
    620  1.1  riastrad 	 * @gem_prime_get_sg_table:
    621  1.1  riastrad 	 *
    622  1.1  riastrad 	 * Deprecated hook in favour of &drm_gem_object_funcs.get_sg_table.
    623  1.1  riastrad 	 */
    624  1.1  riastrad 	struct sg_table *(*gem_prime_get_sg_table)(struct drm_gem_object *obj);
    625  1.1  riastrad 
    626  1.1  riastrad 	/**
    627  1.1  riastrad 	 * @gem_prime_import_sg_table:
    628  1.1  riastrad 	 *
    629  1.1  riastrad 	 * Optional hook used by the PRIME helper functions
    630  1.1  riastrad 	 * drm_gem_prime_import() respectively drm_gem_prime_import_dev().
    631  1.1  riastrad 	 */
    632  1.1  riastrad 	struct drm_gem_object *(*gem_prime_import_sg_table)(
    633  1.1  riastrad 				struct drm_device *dev,
    634  1.1  riastrad 				struct dma_buf_attachment *attach,
    635  1.1  riastrad 				struct sg_table *sgt);
    636  1.1  riastrad 	/**
    637  1.1  riastrad 	 * @gem_prime_vmap:
    638  1.1  riastrad 	 *
    639  1.1  riastrad 	 * Deprecated vmap hook for GEM drivers. Please use
    640  1.1  riastrad 	 * &drm_gem_object_funcs.vmap instead.
    641  1.1  riastrad 	 */
    642  1.1  riastrad 	void *(*gem_prime_vmap)(struct drm_gem_object *obj);
    643  1.1  riastrad 
    644  1.1  riastrad 	/**
    645  1.1  riastrad 	 * @gem_prime_vunmap:
    646  1.1  riastrad 	 *
    647  1.1  riastrad 	 * Deprecated vunmap hook for GEM drivers. Please use
    648  1.1  riastrad 	 * &drm_gem_object_funcs.vunmap instead.
    649  1.1  riastrad 	 */
    650  1.1  riastrad 	void (*gem_prime_vunmap)(struct drm_gem_object *obj, void *vaddr);
    651  1.1  riastrad 
    652  1.1  riastrad 	/**
    653  1.1  riastrad 	 * @gem_prime_mmap:
    654  1.1  riastrad 	 *
    655  1.1  riastrad 	 * mmap hook for GEM drivers, used to implement dma-buf mmap in the
    656  1.1  riastrad 	 * PRIME helpers.
    657  1.1  riastrad 	 *
    658  1.1  riastrad 	 * FIXME: There's way too much duplication going on here, and also moved
    659  1.1  riastrad 	 * to &drm_gem_object_funcs.
    660  1.1  riastrad 	 */
    661  1.4  riastrad #ifdef __NetBSD__
    662  1.4  riastrad 	int (*gem_prime_mmap)(struct drm_gem_object *obj, off_t *offp,
    663  1.4  riastrad 	    size_t len, int prot, int *flagsp, int *advicep,
    664  1.4  riastrad 	    struct uvm_object **uobjp, int *maxprotp);
    665  1.4  riastrad #else
    666  1.1  riastrad 	int (*gem_prime_mmap)(struct drm_gem_object *obj,
    667  1.1  riastrad 				struct vm_area_struct *vma);
    668  1.4  riastrad #endif
    669  1.1  riastrad 
    670  1.1  riastrad 	/**
    671  1.1  riastrad 	 * @dumb_create:
    672  1.1  riastrad 	 *
    673  1.1  riastrad 	 * This creates a new dumb buffer in the driver's backing storage manager (GEM,
    674  1.1  riastrad 	 * TTM or something else entirely) and returns the resulting buffer handle. This
    675  1.1  riastrad 	 * handle can then be wrapped up into a framebuffer modeset object.
    676  1.1  riastrad 	 *
    677  1.1  riastrad 	 * Note that userspace is not allowed to use such objects for render
    678  1.1  riastrad 	 * acceleration - drivers must create their own private ioctls for such a use
    679  1.1  riastrad 	 * case.
    680  1.1  riastrad 	 *
    681  1.1  riastrad 	 * Width, height and depth are specified in the &drm_mode_create_dumb
    682  1.1  riastrad 	 * argument. The callback needs to fill the handle, pitch and size for
    683  1.1  riastrad 	 * the created buffer.
    684  1.1  riastrad 	 *
    685  1.1  riastrad 	 * Called by the user via ioctl.
    686  1.1  riastrad 	 *
    687  1.1  riastrad 	 * Returns:
    688  1.1  riastrad 	 *
    689  1.1  riastrad 	 * Zero on success, negative errno on failure.
    690  1.1  riastrad 	 */
    691  1.1  riastrad 	int (*dumb_create)(struct drm_file *file_priv,
    692  1.1  riastrad 			   struct drm_device *dev,
    693  1.1  riastrad 			   struct drm_mode_create_dumb *args);
    694  1.1  riastrad 	/**
    695  1.1  riastrad 	 * @dumb_map_offset:
    696  1.1  riastrad 	 *
    697  1.1  riastrad 	 * Allocate an offset in the drm device node's address space to be able to
    698  1.1  riastrad 	 * memory map a dumb buffer.
    699  1.1  riastrad 	 *
    700  1.1  riastrad 	 * The default implementation is drm_gem_create_mmap_offset(). GEM based
    701  1.1  riastrad 	 * drivers must not overwrite this.
    702  1.1  riastrad 	 *
    703  1.1  riastrad 	 * Called by the user via ioctl.
    704  1.1  riastrad 	 *
    705  1.1  riastrad 	 * Returns:
    706  1.1  riastrad 	 *
    707  1.1  riastrad 	 * Zero on success, negative errno on failure.
    708  1.1  riastrad 	 */
    709  1.1  riastrad 	int (*dumb_map_offset)(struct drm_file *file_priv,
    710  1.1  riastrad 			       struct drm_device *dev, uint32_t handle,
    711  1.1  riastrad 			       uint64_t *offset);
    712  1.1  riastrad 	/**
    713  1.1  riastrad 	 * @dumb_destroy:
    714  1.1  riastrad 	 *
    715  1.1  riastrad 	 * This destroys the userspace handle for the given dumb backing storage buffer.
    716  1.1  riastrad 	 * Since buffer objects must be reference counted in the kernel a buffer object
    717  1.1  riastrad 	 * won't be immediately freed if a framebuffer modeset object still uses it.
    718  1.1  riastrad 	 *
    719  1.1  riastrad 	 * Called by the user via ioctl.
    720  1.1  riastrad 	 *
    721  1.1  riastrad 	 * The default implementation is drm_gem_dumb_destroy(). GEM based drivers
    722  1.1  riastrad 	 * must not overwrite this.
    723  1.1  riastrad 	 *
    724  1.1  riastrad 	 * Returns:
    725  1.1  riastrad 	 *
    726  1.1  riastrad 	 * Zero on success, negative errno on failure.
    727  1.1  riastrad 	 */
    728  1.1  riastrad 	int (*dumb_destroy)(struct drm_file *file_priv,
    729  1.1  riastrad 			    struct drm_device *dev,
    730  1.1  riastrad 			    uint32_t handle);
    731  1.1  riastrad 
    732  1.1  riastrad 	/**
    733  1.1  riastrad 	 * @gem_vm_ops: Driver private ops for this object
    734  1.1  riastrad 	 *
    735  1.1  riastrad 	 * For GEM drivers this is deprecated in favour of
    736  1.1  riastrad 	 * &drm_gem_object_funcs.vm_ops.
    737  1.1  riastrad 	 */
    738  1.4  riastrad #ifdef __NetBSD__
    739  1.4  riastrad 	int (*mmap_object)(struct drm_device *, off_t, size_t, int,
    740  1.4  riastrad 	    struct uvm_object **, voff_t *, struct file *);
    741  1.4  riastrad 	const struct uvm_pagerops *gem_uvm_ops;
    742  1.4  riastrad #else
    743  1.1  riastrad 	const struct vm_operations_struct *gem_vm_ops;
    744  1.4  riastrad #endif
    745  1.1  riastrad 
    746  1.1  riastrad 	/** @major: driver major number */
    747  1.1  riastrad 	int major;
    748  1.1  riastrad 	/** @minor: driver minor number */
    749  1.1  riastrad 	int minor;
    750  1.1  riastrad 	/** @patchlevel: driver patch level */
    751  1.1  riastrad 	int patchlevel;
    752  1.1  riastrad 	/** @name: driver name */
    753  1.6  riastrad 	const char *name;
    754  1.1  riastrad 	/** @desc: driver description */
    755  1.6  riastrad 	const char *desc;
    756  1.1  riastrad 	/** @date: driver date */
    757  1.6  riastrad 	const char *date;
    758  1.1  riastrad 
    759  1.1  riastrad 	/**
    760  1.1  riastrad 	 * @driver_features:
    761  1.1  riastrad 	 * Driver features, see &enum drm_driver_feature. Drivers can disable
    762  1.1  riastrad 	 * some features on a per-instance basis using
    763  1.1  riastrad 	 * &drm_device.driver_features.
    764  1.1  riastrad 	 */
    765  1.1  riastrad 	u32 driver_features;
    766  1.1  riastrad 
    767  1.1  riastrad 	/**
    768  1.1  riastrad 	 * @ioctls:
    769  1.1  riastrad 	 *
    770  1.1  riastrad 	 * Array of driver-private IOCTL description entries. See the chapter on
    771  1.1  riastrad 	 * :ref:`IOCTL support in the userland interfaces
    772  1.1  riastrad 	 * chapter<drm_driver_ioctl>` for the full details.
    773  1.1  riastrad 	 */
    774  1.1  riastrad 
    775  1.1  riastrad 	const struct drm_ioctl_desc *ioctls;
    776  1.1  riastrad 	/** @num_ioctls: Number of entries in @ioctls. */
    777  1.1  riastrad 	int num_ioctls;
    778  1.1  riastrad 
    779  1.1  riastrad 	/**
    780  1.1  riastrad 	 * @fops:
    781  1.1  riastrad 	 *
    782  1.1  riastrad 	 * File operations for the DRM device node. See the discussion in
    783  1.1  riastrad 	 * :ref:`file operations<drm_driver_fops>` for in-depth coverage and
    784  1.1  riastrad 	 * some examples.
    785  1.1  riastrad 	 */
    786  1.1  riastrad 	const struct file_operations *fops;
    787  1.1  riastrad 
    788  1.4  riastrad #ifdef __NetBSD__
    789  1.4  riastrad 	int (*ioctl_override)(struct file *, unsigned long, void *);
    790  1.4  riastrad #endif
    791  1.4  riastrad 
    792  1.1  riastrad 	/* Everything below here is for legacy driver, never use! */
    793  1.1  riastrad 	/* private: */
    794  1.1  riastrad 
    795  1.1  riastrad 	/* List of devices hanging off this driver with stealth attach. */
    796  1.1  riastrad 	struct list_head legacy_dev_list;
    797  1.1  riastrad 	int (*firstopen) (struct drm_device *);
    798  1.1  riastrad 	void (*preclose) (struct drm_device *, struct drm_file *file_priv);
    799  1.1  riastrad 	int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);
    800  1.1  riastrad 	int (*dma_quiescent) (struct drm_device *);
    801  1.1  riastrad 	int (*context_dtor) (struct drm_device *dev, int context);
    802  1.1  riastrad 	int dev_priv_size;
    803  1.1  riastrad };
    804  1.1  riastrad 
    805  1.1  riastrad int drm_dev_init(struct drm_device *dev,
    806  1.1  riastrad 		 struct drm_driver *driver,
    807  1.1  riastrad 		 struct device *parent);
    808  1.1  riastrad int devm_drm_dev_init(struct device *parent,
    809  1.1  riastrad 		      struct drm_device *dev,
    810  1.1  riastrad 		      struct drm_driver *driver);
    811  1.1  riastrad void drm_dev_fini(struct drm_device *dev);
    812  1.1  riastrad 
    813  1.1  riastrad struct drm_device *drm_dev_alloc(struct drm_driver *driver,
    814  1.1  riastrad 				 struct device *parent);
    815  1.1  riastrad int drm_dev_register(struct drm_device *dev, unsigned long flags);
    816  1.1  riastrad void drm_dev_unregister(struct drm_device *dev);
    817  1.1  riastrad 
    818  1.1  riastrad void drm_dev_get(struct drm_device *dev);
    819  1.1  riastrad void drm_dev_put(struct drm_device *dev);
    820  1.1  riastrad void drm_put_dev(struct drm_device *dev);
    821  1.1  riastrad bool drm_dev_enter(struct drm_device *dev, int *idx);
    822  1.1  riastrad void drm_dev_exit(int idx);
    823  1.1  riastrad void drm_dev_unplug(struct drm_device *dev);
    824  1.1  riastrad 
    825  1.1  riastrad /**
    826  1.1  riastrad  * drm_dev_is_unplugged - is a DRM device unplugged
    827  1.1  riastrad  * @dev: DRM device
    828  1.1  riastrad  *
    829  1.1  riastrad  * This function can be called to check whether a hotpluggable is unplugged.
    830  1.1  riastrad  * Unplugging itself is singalled through drm_dev_unplug(). If a device is
    831  1.1  riastrad  * unplugged, these two functions guarantee that any store before calling
    832  1.1  riastrad  * drm_dev_unplug() is visible to callers of this function after it completes
    833  1.1  riastrad  *
    834  1.1  riastrad  * WARNING: This function fundamentally races against drm_dev_unplug(). It is
    835  1.1  riastrad  * recommended that drivers instead use the underlying drm_dev_enter() and
    836  1.1  riastrad  * drm_dev_exit() function pairs.
    837  1.1  riastrad  */
    838  1.1  riastrad static inline bool drm_dev_is_unplugged(struct drm_device *dev)
    839  1.1  riastrad {
    840  1.1  riastrad 	int idx;
    841  1.1  riastrad 
    842  1.1  riastrad 	if (drm_dev_enter(dev, &idx)) {
    843  1.1  riastrad 		drm_dev_exit(idx);
    844  1.1  riastrad 		return false;
    845  1.1  riastrad 	}
    846  1.1  riastrad 
    847  1.1  riastrad 	return true;
    848  1.1  riastrad }
    849  1.1  riastrad 
    850  1.1  riastrad /**
    851  1.1  riastrad  * drm_core_check_feature - check driver feature flags
    852  1.1  riastrad  * @dev: DRM device to check
    853  1.1  riastrad  * @feature: feature flag
    854  1.1  riastrad  *
    855  1.1  riastrad  * This checks @dev for driver features, see &drm_driver.driver_features,
    856  1.1  riastrad  * &drm_device.driver_features, and the various &enum drm_driver_feature flags.
    857  1.1  riastrad  *
    858  1.1  riastrad  * Returns true if the @feature is supported, false otherwise.
    859  1.1  riastrad  */
    860  1.1  riastrad static inline bool drm_core_check_feature(const struct drm_device *dev, u32 feature)
    861  1.1  riastrad {
    862  1.1  riastrad 	return dev->driver->driver_features & dev->driver_features & feature;
    863  1.1  riastrad }
    864  1.1  riastrad 
    865  1.1  riastrad /**
    866  1.1  riastrad  * drm_drv_uses_atomic_modeset - check if the driver implements
    867  1.1  riastrad  * atomic_commit()
    868  1.1  riastrad  * @dev: DRM device
    869  1.1  riastrad  *
    870  1.1  riastrad  * This check is useful if drivers do not have DRIVER_ATOMIC set but
    871  1.1  riastrad  * have atomic modesetting internally implemented.
    872  1.1  riastrad  */
    873  1.1  riastrad static inline bool drm_drv_uses_atomic_modeset(struct drm_device *dev)
    874  1.1  riastrad {
    875  1.1  riastrad 	return drm_core_check_feature(dev, DRIVER_ATOMIC) ||
    876  1.1  riastrad 		(dev->mode_config.funcs && dev->mode_config.funcs->atomic_commit != NULL);
    877  1.1  riastrad }
    878  1.1  riastrad 
    879  1.1  riastrad 
    880  1.1  riastrad int drm_dev_set_unique(struct drm_device *dev, const char *name);
    881  1.1  riastrad 
    882  1.1  riastrad 
    883  1.1  riastrad #endif
    884