nouveau_drm.h 3.6 KB
Newer Older
1 2 3
#ifndef __NOUVEAU_DRMCLI_H__
#define __NOUVEAU_DRMCLI_H__

4 5 6 7 8 9 10 11 12 13 14
#define DRIVER_AUTHOR		"Nouveau Project"
#define DRIVER_EMAIL		"nouveau@lists.freedesktop.org"

#define DRIVER_NAME		"nouveau"
#define DRIVER_DESC		"nVidia Riva/TNT/GeForce/Quadro/Tesla"
#define DRIVER_DATE		"20120801"

#define DRIVER_MAJOR		1
#define DRIVER_MINOR		1
#define DRIVER_PATCHLEVEL	0

15 16
#include <core/client.h>

17 18
#include <subdev/vm.h>

19 20 21
#include <drmP.h>
#include <drm/nouveau_drm.h>

22 23 24 25 26 27 28 29 30 31 32 33
#include "ttm/ttm_bo_api.h"
#include "ttm/ttm_bo_driver.h"
#include "ttm/ttm_placement.h"
#include "ttm/ttm_memory.h"
#include "ttm/ttm_module.h"
#include "ttm/ttm_page_alloc.h"

struct nouveau_channel;

#define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT)

#include "nouveau_fence.h"
34
#include "nouveau_bios.h"
35 36 37 38 39 40

struct nouveau_drm_tile {
	struct nouveau_fence *fence;
	bool used;
};

41 42 43
enum nouveau_drm_handle {
	NVDRM_CLIENT = 0xffffffff,
	NVDRM_DEVICE = 0xdddddddd,
44 45
	NVDRM_PUSH   = 0xbbbb0000, /* |= client chid */
	NVDRM_CHAN   = 0xcccc0000, /* |= client chid */
46 47 48 49 50 51
};

struct nouveau_cli {
	struct nouveau_client base;
	struct list_head head;
	struct mutex mutex;
52
	void *abi16;
53 54
};

55 56 57 58 59 60
static inline struct nouveau_cli *
nouveau_cli(struct drm_file *fpriv)
{
	return fpriv ? fpriv->driver_priv : NULL;
}

61 62 63 64 65 66
struct nouveau_drm {
	struct nouveau_cli client;
	struct drm_device *dev;

	struct nouveau_object *device;
	struct list_head clients;
67 68 69 70 71 72 73 74 75 76

	struct {
		enum {
			UNKNOWN = 0,
			DISABLE = 1,
			ENABLED = 2
		} stat;
		u32 base;
		u32 size;
	} agp;
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99

	/* TTM interface support */
	struct {
		struct drm_global_reference mem_global_ref;
		struct ttm_bo_global_ref bo_global_ref;
		struct ttm_bo_device bdev;
		atomic_t validate_sequence;
		int (*move)(struct nouveau_channel *,
			    struct ttm_buffer_object *,
			    struct ttm_mem_reg *, struct ttm_mem_reg *);
		int mtrr;
	} ttm;

	/* GEM interface support */
	struct {
		u64 vram_available;
		u64 gart_available;
	} gem;

	/* synchronisation */
	void *fence;

	/* context for accelerated drm-internal operations */
100
	struct nouveau_channel *cechan;
101 102 103 104 105 106 107 108 109
	struct nouveau_channel *channel;
	struct nouveau_gpuobj *notify;
	struct nouveau_fbdev *fbcon;

	/* nv10-nv40 tiling regions */
	struct {
		struct nouveau_drm_tile reg[15];
		spinlock_t lock;
	} tile;
110

111 112 113
	/* modesetting */
	struct nvbios vbios;
	struct nouveau_display *display;
114
	struct backlight_device *backlight;
115 116 117

	/* power management */
	struct nouveau_pm *pm;
118 119
};

120 121 122
static inline struct nouveau_drm *
nouveau_drm(struct drm_device *dev)
{
123 124 125 126 127 128 129
	return dev->dev_private;
}

static inline struct nouveau_device *
nouveau_dev(struct drm_device *dev)
{
	return nv_device(nouveau_drm(dev)->device);
130 131
}

132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
int nouveau_drm_suspend(struct pci_dev *, pm_message_t);
int nouveau_drm_resume(struct pci_dev *);

#define NV_PRINTK(level, code, drm, fmt, args...)                              \
	printk(level "nouveau " code "[     DRM][%s] " fmt,                    \
	       pci_name((drm)->dev->pdev), ##args)
#define NV_FATAL(drm, fmt, args...)                                            \
	NV_PRINTK(KERN_CRIT, "!", (drm), fmt, ##args)
#define NV_ERROR(drm, fmt, args...)                                            \
	NV_PRINTK(KERN_ERR, "E", (drm), fmt, ##args)
#define NV_WARN(drm, fmt, args...)                                             \
	NV_PRINTK(KERN_WARNING, "W", (drm), fmt, ##args)
#define NV_INFO(drm, fmt, args...)                                             \
	NV_PRINTK(KERN_INFO, " ", (drm), fmt, ##args)
#define NV_DEBUG(drm, fmt, args...) do {                                       \
	if (drm_debug & DRM_UT_DRIVER)                                         \
		NV_PRINTK(KERN_DEBUG, "D", drm, fmt, ##args);                  \
} while (0)

#endif