#ifndef _DRM_DEVICE_H_
#define _DRM_DEVICE_H_

#include <linux/list.h>
#include <linux/kref.h>
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
#include <linux/mount.h>
#endif
#include <linux/mutex.h>
#include <linux/idr.h>
#include <linux/sched.h>

#include <drm/drm_mode_config.h>

struct drm_driver;
struct drm_minor;
struct drm_master;
struct drm_vblank_crtc;
struct drm_vma_offset_manager;
struct drm_vram_mm;
struct drm_fb_helper;

struct inode;

struct pci_dev;
struct pci_controller;


#define DRM_WEDGE_RECOVERY_NONE		BIT(0)	
#define DRM_WEDGE_RECOVERY_REBIND	BIT(1)	
#define DRM_WEDGE_RECOVERY_BUS_RESET	BIT(2)	
#define DRM_WEDGE_RECOVERY_VENDOR	BIT(3)	


struct drm_wedge_task_info {
	
	pid_t pid;
	
	char comm[TASK_COMM_LEN];
};



enum switch_power_state {
	
	DRM_SWITCH_POWER_ON = 0,

	
	DRM_SWITCH_POWER_OFF = 1,

	
	DRM_SWITCH_POWER_CHANGING = 2,

	
	DRM_SWITCH_POWER_DYNAMIC_OFF = 3,
};


struct drm_device {
	
	int if_version;

	
	struct kref ref;

	
	struct device *dev;

	
	struct device *dma_dev;

	
	struct {
		
		struct list_head resources;
		
		void *final_kfree;
		
		spinlock_t lock;
	} managed;

	
	const struct drm_driver *driver;

	
	void *dev_private;

	
	struct drm_minor *primary;

	
	struct drm_minor *render;

	
	struct drm_minor *accel;

	
	bool registered;

	
	struct drm_master *master;

#ifdef CONFIG_TRANSPARENT_HUGEPAGE
	
	struct vfsmount *huge_mnt;
#endif

	
	u32 driver_features;

	
	bool unplugged;

	
	struct inode *anon_inode;

	
	char *unique;

	
	struct mutex master_mutex;

	
	atomic_t open_count;

	
	struct mutex filelist_mutex;
	
	struct list_head filelist;

	
	struct list_head filelist_internal;

	
	struct mutex clientlist_mutex;

	
	struct list_head clientlist;

	
	struct list_head client_sysrq_list;

	
	bool vblank_disable_immediate;

	
	struct drm_vblank_crtc *vblank;

	
	spinlock_t vblank_time_lock;
	
	spinlock_t vbl_lock;

	
	u32 max_vblank_count;

	
	struct list_head vblank_event_list;

	
	spinlock_t event_lock;

	
	unsigned int num_crtcs;

	
	struct drm_mode_config mode_config;

	
	struct mutex object_name_lock;

	
	struct idr object_name_idr;

	
	struct drm_vma_offset_manager *vma_offset_manager;

	
	struct drm_vram_mm *vram_mm;

	
	enum switch_power_state switch_power_state;

	
	struct drm_fb_helper *fb_helper;

	
	struct dentry *debugfs_root;

	
	struct mutex gem_lru_mutex;
};

void drm_dev_set_dma_dev(struct drm_device *dev, struct device *dma_dev);


static inline struct device *drm_dev_dma_dev(struct drm_device *dev)
{
	if (dev->dma_dev)
		return dev->dma_dev;
	return dev->dev;
}

#endif
