2017-08-02 19:56:01 +08:00
|
|
|
#ifndef _DRM_DEVICE_H_
|
|
|
|
#define _DRM_DEVICE_H_
|
|
|
|
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/kref.h>
|
|
|
|
#include <linux/mutex.h>
|
|
|
|
#include <linux/idr.h>
|
|
|
|
|
|
|
|
#include <drm/drm_hashtab.h>
|
|
|
|
#include <drm/drm_mode_config.h>
|
|
|
|
|
|
|
|
struct drm_driver;
|
|
|
|
struct drm_minor;
|
|
|
|
struct drm_master;
|
|
|
|
struct drm_device_dma;
|
|
|
|
struct drm_vblank_crtc;
|
|
|
|
struct drm_sg_mem;
|
|
|
|
struct drm_local_map;
|
|
|
|
struct drm_vma_offset_manager;
|
2017-10-30 23:39:38 +08:00
|
|
|
struct drm_fb_helper;
|
2017-08-02 19:56:01 +08:00
|
|
|
|
|
|
|
struct inode;
|
|
|
|
|
|
|
|
struct pci_dev;
|
|
|
|
struct pci_controller;
|
|
|
|
|
|
|
|
/**
|
2019-01-09 03:29:28 +08:00
|
|
|
* struct drm_device - DRM device structure
|
|
|
|
*
|
|
|
|
* This structure represent a complete card that
|
2017-08-02 19:56:01 +08:00
|
|
|
* may contain multiple heads.
|
|
|
|
*/
|
|
|
|
struct drm_device {
|
2019-01-09 03:29:28 +08:00
|
|
|
/**
|
|
|
|
* @legacy_dev_list:
|
|
|
|
*
|
|
|
|
* List of devices per driver for stealth attach cleanup
|
|
|
|
*/
|
|
|
|
struct list_head legacy_dev_list;
|
|
|
|
|
|
|
|
/** @if_version: Highest interface version set */
|
|
|
|
int if_version;
|
|
|
|
|
|
|
|
/** @ref: Object ref-count */
|
|
|
|
struct kref ref;
|
|
|
|
|
|
|
|
/** @dev: Device structure of bus-device */
|
|
|
|
struct device *dev;
|
|
|
|
|
|
|
|
/** @driver: DRM driver managing the device */
|
|
|
|
struct drm_driver *driver;
|
|
|
|
|
|
|
|
/** @dev_private: DRM driver private data */
|
|
|
|
void *dev_private;
|
|
|
|
|
|
|
|
/** @primary: Primary node */
|
|
|
|
struct drm_minor *primary;
|
|
|
|
|
|
|
|
/** @render: Render node */
|
|
|
|
struct drm_minor *render;
|
|
|
|
|
2017-08-02 19:56:01 +08:00
|
|
|
bool registered;
|
|
|
|
|
2019-01-09 03:29:28 +08:00
|
|
|
/**
|
|
|
|
* @master:
|
|
|
|
*
|
|
|
|
* Currently active master for this device.
|
|
|
|
* Protected by &master_mutex
|
|
|
|
*/
|
2017-08-02 19:56:01 +08:00
|
|
|
struct drm_master *master;
|
|
|
|
|
2018-09-13 21:16:21 +08:00
|
|
|
/**
|
|
|
|
* @driver_features: per-device driver features
|
|
|
|
*
|
|
|
|
* Drivers can clear specific flags here to disallow
|
|
|
|
* certain features on a per-device basis while still
|
|
|
|
* sharing a single &struct drm_driver instance across
|
|
|
|
* all devices.
|
|
|
|
*/
|
|
|
|
u32 driver_features;
|
|
|
|
|
2018-03-28 15:38:35 +08:00
|
|
|
/**
|
|
|
|
* @unplugged:
|
|
|
|
*
|
|
|
|
* Flag to tell if the device has been unplugged.
|
|
|
|
* See drm_dev_enter() and drm_dev_is_unplugged().
|
|
|
|
*/
|
|
|
|
bool unplugged;
|
|
|
|
|
2019-01-09 03:29:28 +08:00
|
|
|
/** @anon_inode: inode for private address-space */
|
|
|
|
struct inode *anon_inode;
|
|
|
|
|
|
|
|
/** @unique: Unique name of the device */
|
|
|
|
char *unique;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @struct_mutex:
|
|
|
|
*
|
|
|
|
* Lock for others (not &drm_minor.master and &drm_file.is_master)
|
|
|
|
*/
|
|
|
|
struct mutex struct_mutex;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @master_mutex:
|
|
|
|
*
|
|
|
|
* Lock for &drm_minor.master and &drm_file.is_master
|
|
|
|
*/
|
|
|
|
struct mutex master_mutex;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @open_count:
|
|
|
|
*
|
|
|
|
* Usage counter for outstanding files open,
|
|
|
|
* protected by drm_global_mutex
|
|
|
|
*/
|
|
|
|
int open_count;
|
|
|
|
|
|
|
|
/** @buf_lock: Lock for &buf_use and a few other things. */
|
|
|
|
spinlock_t buf_lock;
|
2017-08-02 19:56:01 +08:00
|
|
|
|
2019-01-09 03:29:28 +08:00
|
|
|
/** @buf_use: Usage counter for buffers in use -- cannot alloc */
|
|
|
|
int buf_use;
|
2017-08-02 19:56:01 +08:00
|
|
|
|
2019-01-09 03:29:28 +08:00
|
|
|
/** @buf_alloc: Buffer allocation in progress */
|
|
|
|
atomic_t buf_alloc;
|
2017-08-02 19:56:01 +08:00
|
|
|
|
|
|
|
struct mutex filelist_mutex;
|
|
|
|
struct list_head filelist;
|
|
|
|
|
2018-07-04 00:03:47 +08:00
|
|
|
/**
|
|
|
|
* @filelist_internal:
|
|
|
|
*
|
2019-01-09 03:29:28 +08:00
|
|
|
* List of open DRM files for in-kernel clients.
|
|
|
|
* Protected by &filelist_mutex.
|
2018-07-04 00:03:47 +08:00
|
|
|
*/
|
|
|
|
struct list_head filelist_internal;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @clientlist_mutex:
|
|
|
|
*
|
2019-01-09 03:29:28 +08:00
|
|
|
* Protects &clientlist access.
|
2018-07-04 00:03:47 +08:00
|
|
|
*/
|
|
|
|
struct mutex clientlist_mutex;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @clientlist:
|
|
|
|
*
|
2019-01-09 03:29:28 +08:00
|
|
|
* List of in-kernel clients. Protected by &clientlist_mutex.
|
2018-07-04 00:03:47 +08:00
|
|
|
*/
|
|
|
|
struct list_head clientlist;
|
|
|
|
|
2019-01-09 03:29:28 +08:00
|
|
|
/** @maplist: Memory management - linked list of regions */
|
|
|
|
struct list_head maplist;
|
2017-08-02 19:56:01 +08:00
|
|
|
|
2019-01-09 03:29:28 +08:00
|
|
|
/** @map_hash: Memory management - user token hash table for maps */
|
|
|
|
struct drm_open_hash map_hash;
|
2017-08-02 19:56:01 +08:00
|
|
|
|
2019-01-09 03:29:28 +08:00
|
|
|
/**
|
|
|
|
* @ctxlist:
|
|
|
|
* Context handle management - linked list of context handles
|
|
|
|
*/
|
|
|
|
struct list_head ctxlist;
|
2017-08-02 19:56:01 +08:00
|
|
|
|
2019-01-09 03:29:28 +08:00
|
|
|
/**
|
|
|
|
* @ctxlist_mutex:
|
|
|
|
*
|
|
|
|
* Context handle management - mutex for &ctxlist
|
|
|
|
*/
|
|
|
|
struct mutex ctxlist_mutex;
|
2017-08-02 19:56:01 +08:00
|
|
|
|
2019-01-09 03:29:28 +08:00
|
|
|
/**
|
|
|
|
* @ctx_idr:
|
|
|
|
* Context handle management
|
|
|
|
*/
|
|
|
|
struct idr ctx_idr;
|
2017-08-02 19:56:01 +08:00
|
|
|
|
2019-01-09 03:29:28 +08:00
|
|
|
/**
|
|
|
|
* @vmalist:
|
|
|
|
* Context handle management - list of vmas (for debugging)
|
|
|
|
*/
|
|
|
|
struct list_head vmalist;
|
|
|
|
|
|
|
|
/** @dma: Optional pointer for DMA support */
|
|
|
|
struct drm_device_dma *dma;
|
2017-08-02 19:56:01 +08:00
|
|
|
|
2019-01-09 03:29:28 +08:00
|
|
|
/** @context_flag: Context swapping flag */
|
|
|
|
__volatile__ long context_flag;
|
2017-08-02 19:56:01 +08:00
|
|
|
|
2019-01-09 03:29:28 +08:00
|
|
|
/** @last_context: Last current context */
|
|
|
|
int last_context;
|
2017-08-02 19:56:01 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @irq_enabled:
|
|
|
|
*
|
|
|
|
* Indicates that interrupt handling is enabled, specifically vblank
|
|
|
|
* handling. Drivers which don't use drm_irq_install() need to set this
|
|
|
|
* to true manually.
|
|
|
|
*/
|
|
|
|
bool irq_enabled;
|
|
|
|
int irq;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @vblank_disable_immediate:
|
|
|
|
*
|
|
|
|
* If true, vblank interrupt will be disabled immediately when the
|
|
|
|
* refcount drops to zero, as opposed to via the vblank disable
|
|
|
|
* timer.
|
|
|
|
*
|
|
|
|
* This can be set to true it the hardware has a working vblank counter
|
|
|
|
* with high-precision timestamping (otherwise there are races) and the
|
|
|
|
* driver uses drm_crtc_vblank_on() and drm_crtc_vblank_off()
|
|
|
|
* appropriately. See also @max_vblank_count and
|
|
|
|
* &drm_crtc_funcs.get_vblank_counter.
|
|
|
|
*/
|
|
|
|
bool vblank_disable_immediate;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @vblank:
|
|
|
|
*
|
|
|
|
* Array of vblank tracking structures, one per &struct drm_crtc. For
|
|
|
|
* historical reasons (vblank support predates kernel modesetting) this
|
|
|
|
* is free-standing and not part of &struct drm_crtc itself. It must be
|
|
|
|
* initialized explicitly by calling drm_vblank_init().
|
|
|
|
*/
|
|
|
|
struct drm_vblank_crtc *vblank;
|
|
|
|
|
2019-01-09 03:29:28 +08:00
|
|
|
/**
|
|
|
|
* @vblank_time_lock:
|
|
|
|
*
|
|
|
|
* Protects vblank count and time updates during vblank enable/disable
|
|
|
|
*/
|
|
|
|
spinlock_t vblank_time_lock;
|
2017-08-02 19:56:01 +08:00
|
|
|
spinlock_t vbl_lock;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @max_vblank_count:
|
|
|
|
*
|
|
|
|
* Maximum value of the vblank registers. This value +1 will result in a
|
|
|
|
* wrap-around of the vblank register. It is used by the vblank core to
|
|
|
|
* handle wrap-arounds.
|
|
|
|
*
|
|
|
|
* If set to zero the vblank core will try to guess the elapsed vblanks
|
|
|
|
* between times when the vblank interrupt is disabled through
|
|
|
|
* high-precision timestamps. That approach is suffering from small
|
|
|
|
* races and imprecision over longer time periods, hence exposing a
|
|
|
|
* hardware vblank counter is always recommended.
|
|
|
|
*
|
|
|
|
* If non-zeor, &drm_crtc_funcs.get_vblank_counter must be set.
|
|
|
|
*/
|
|
|
|
|
2019-01-09 03:29:28 +08:00
|
|
|
/** @max_vblank_count: Size of vblank counter register */
|
|
|
|
u32 max_vblank_count;
|
|
|
|
|
|
|
|
/** @vblank_event_list: List of vblank events */
|
2017-08-02 19:56:01 +08:00
|
|
|
struct list_head vblank_event_list;
|
|
|
|
spinlock_t event_lock;
|
|
|
|
|
2019-01-09 03:29:28 +08:00
|
|
|
/** @agp: AGP data */
|
|
|
|
struct drm_agp_head *agp;
|
2017-08-02 19:56:01 +08:00
|
|
|
|
2019-01-09 03:29:28 +08:00
|
|
|
/** @pdev: PCI device structure */
|
|
|
|
struct pci_dev *pdev;
|
2017-08-02 19:56:01 +08:00
|
|
|
|
|
|
|
#ifdef __alpha__
|
|
|
|
struct pci_controller *hose;
|
|
|
|
#endif
|
|
|
|
|
2019-01-09 03:29:28 +08:00
|
|
|
/** @sg: Scatter gather memory */
|
|
|
|
struct drm_sg_mem *sg;
|
|
|
|
|
|
|
|
/** @num_crtcs: Number of CRTCs on this device */
|
|
|
|
unsigned int num_crtcs;
|
2017-08-02 19:56:01 +08:00
|
|
|
|
|
|
|
struct {
|
|
|
|
int context;
|
|
|
|
struct drm_hw_lock *lock;
|
|
|
|
} sigdata;
|
|
|
|
|
|
|
|
struct drm_local_map *agp_buffer_map;
|
|
|
|
unsigned int agp_buffer_token;
|
|
|
|
|
2019-01-09 03:29:28 +08:00
|
|
|
/** @mode_config: Current mode config */
|
|
|
|
struct drm_mode_config mode_config;
|
2017-08-02 19:56:01 +08:00
|
|
|
|
2019-01-09 03:29:28 +08:00
|
|
|
/** @object_name_lock: GEM information */
|
2017-08-02 19:56:01 +08:00
|
|
|
struct mutex object_name_lock;
|
2019-01-09 03:29:28 +08:00
|
|
|
|
|
|
|
/** @object_name_idr: GEM information */
|
2017-08-02 19:56:01 +08:00
|
|
|
struct idr object_name_idr;
|
2019-01-09 03:29:28 +08:00
|
|
|
|
|
|
|
/** @vma_offset_manager: GEM information */
|
2017-08-02 19:56:01 +08:00
|
|
|
struct drm_vma_offset_manager *vma_offset_manager;
|
2019-01-09 03:29:28 +08:00
|
|
|
|
2017-08-02 19:56:01 +08:00
|
|
|
int switch_power_state;
|
2017-10-30 23:39:38 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @fb_helper:
|
|
|
|
*
|
|
|
|
* Pointer to the fbdev emulation structure.
|
|
|
|
* Set by drm_fb_helper_init() and cleared by drm_fb_helper_fini().
|
|
|
|
*/
|
|
|
|
struct drm_fb_helper *fb_helper;
|
2017-08-02 19:56:01 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|