xref: /linux/drivers/gpu/drm/gma500/gtt.h (revision 31d166642c7c601c65eccf0ff2e0afe9a0538be2)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /**************************************************************************
3  * Copyright (c) 2007-2008, Intel Corporation.
4  * All Rights Reserved.
5  *
6  **************************************************************************/
7 
8 #ifndef _PSB_GTT_H_
9 #define _PSB_GTT_H_
10 
11 #include <drm/drmP.h>
12 #include <drm/drm_gem.h>
13 
14 /* This wants cleaning up with respect to the psb_dev and un-needed stuff */
15 struct psb_gtt {
16 	uint32_t gatt_start;
17 	uint32_t mmu_gatt_start;
18 	uint32_t gtt_start;
19 	uint32_t gtt_phys_start;
20 	unsigned gtt_pages;
21 	unsigned gatt_pages;
22 	unsigned long stolen_size;
23 	unsigned long vram_stolen_size;
24 	struct rw_semaphore sem;
25 };
26 
27 /* Exported functions */
28 extern int psb_gtt_init(struct drm_device *dev, int resume);
29 extern void psb_gtt_takedown(struct drm_device *dev);
30 
31 /* Each gtt_range describes an allocation in the GTT area */
32 struct gtt_range {
33 	struct resource resource;	/* Resource for our allocation */
34 	u32 offset;			/* GTT offset of our object */
35 	struct drm_gem_object gem;	/* GEM high level stuff */
36 	int in_gart;			/* Currently in the GART (ref ct) */
37 	bool stolen;			/* Backed from stolen RAM */
38 	bool mmapping;			/* Is mmappable */
39 	struct page **pages;		/* Backing pages if present */
40 	int npage;			/* Number of backing pages */
41 	int roll;			/* Roll applied to the GTT entries */
42 };
43 
44 #define to_gtt_range(x) container_of(x, struct gtt_range, gem)
45 
46 extern struct gtt_range *psb_gtt_alloc_range(struct drm_device *dev, int len,
47 					     const char *name, int backed,
48 					     u32 align);
49 extern void psb_gtt_kref_put(struct gtt_range *gt);
50 extern void psb_gtt_free_range(struct drm_device *dev, struct gtt_range *gt);
51 extern int psb_gtt_pin(struct gtt_range *gt);
52 extern void psb_gtt_unpin(struct gtt_range *gt);
53 extern void psb_gtt_roll(struct drm_device *dev,
54 					struct gtt_range *gt, int roll);
55 extern int psb_gtt_restore(struct drm_device *dev);
56 #endif
57