xref: /linux/drivers/gpu/drm/gma500/gtt.h (revision 26fbb4c8c7c3ee9a4c3b4de555a8587b5a19154e)
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/drm_gem.h>
12 
13 /* This wants cleaning up with respect to the psb_dev and un-needed stuff */
14 struct psb_gtt {
15 	uint32_t gatt_start;
16 	uint32_t mmu_gatt_start;
17 	uint32_t gtt_start;
18 	uint32_t gtt_phys_start;
19 	unsigned gtt_pages;
20 	unsigned gatt_pages;
21 	unsigned long stolen_size;
22 	unsigned long vram_stolen_size;
23 	struct rw_semaphore sem;
24 };
25 
26 /* Exported functions */
27 extern int psb_gtt_init(struct drm_device *dev, int resume);
28 extern void psb_gtt_takedown(struct drm_device *dev);
29 
30 /* Each gtt_range describes an allocation in the GTT area */
31 struct gtt_range {
32 	struct resource resource;	/* Resource for our allocation */
33 	u32 offset;			/* GTT offset of our object */
34 	struct drm_gem_object gem;	/* GEM high level stuff */
35 	int in_gart;			/* Currently in the GART (ref ct) */
36 	bool stolen;			/* Backed from stolen RAM */
37 	bool mmapping;			/* Is mmappable */
38 	struct page **pages;		/* Backing pages if present */
39 	int npage;			/* Number of backing pages */
40 };
41 
42 #define to_gtt_range(x) container_of(x, struct gtt_range, gem)
43 
44 extern struct gtt_range *psb_gtt_alloc_range(struct drm_device *dev, int len,
45 					     const char *name, int backed,
46 					     u32 align);
47 extern void psb_gtt_kref_put(struct gtt_range *gt);
48 extern void psb_gtt_free_range(struct drm_device *dev, struct gtt_range *gt);
49 extern int psb_gtt_pin(struct gtt_range *gt);
50 extern void psb_gtt_unpin(struct gtt_range *gt);
51 extern int psb_gtt_restore(struct drm_device *dev);
52 #endif
53