aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/cdv/drv/psb_gtt.h
blob: 69666762d5f18ef255fe12f6acc28a34c488b229 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/**************************************************************************
 * Copyright (c) 2011, Intel Corporation.
 * All Rights Reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 
 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
 *
 **************************************************************************/

#ifndef _PSB_GTT_H_
#define _PSB_GTT_H_

#include <drm/drmP.h>

#include "img_types.h"

struct psb_gtt {
	struct drm_device *dev;
	int initialized;
	uint32_t gatt_start;
	uint32_t mmu_gatt_start;
	uint32_t ci_start;
	uint32_t rar_start;
	uint32_t gtt_start;
	uint32_t gtt_phys_start;
	unsigned gtt_pages;
	unsigned gatt_pages;
	uint32_t stolen_base;
	void *vram_addr;
	uint32_t pge_ctl;
	u16 gmch_ctrl;
	unsigned long stolen_size;
	unsigned long vram_stolen_size;
	unsigned long ci_stolen_size;
	unsigned long rar_stolen_size;
	uint32_t *gtt_map;
	struct rw_semaphore sem;
};

struct psb_gtt_mm {
	struct drm_mm base;
	struct drm_open_hash hash;
	uint32_t count;
	spinlock_t lock;
};

struct psb_gtt_hash_entry {
	struct drm_open_hash ht;
	uint32_t count;
	struct drm_hash_item item;
};

struct psb_gtt_mem_mapping {
	struct drm_mm_node *node;
	struct drm_hash_item item;
};

#if 0
/*Ioctl args*/
struct psb_gtt_mapping_arg {
	IMG_HANDLE hKernelMemInfo;
};
#endif

/*Exported functions*/
extern int psb_gtt_init(struct psb_gtt *pg, int resume);
extern int psb_gtt_insert_pages(struct psb_gtt *pg, struct page **pages,
				unsigned offset_pages, unsigned num_pages,
				unsigned desired_tile_stride,
				unsigned hw_tile_stride, int type);
extern int psb_gtt_remove_pages(struct psb_gtt *pg, unsigned offset_pages,
				unsigned num_pages,
				unsigned desired_tile_stride,
				unsigned hw_tile_stride,
				int rc_prot);

extern struct psb_gtt *psb_gtt_alloc(struct drm_device *dev);
extern void psb_gtt_takedown(struct psb_gtt *pg, int free);
extern int psb_gtt_map_meminfo(struct drm_device *dev,
				IMG_HANDLE hKernelMemInfo,
				uint32_t *offset);
extern int psb_gtt_unmap_meminfo(struct drm_device *dev,
				 IMG_HANDLE hKernelMemInfo);
extern int psb_gtt_map_meminfo_ioctl(struct drm_device *dev, void *data,
				     struct drm_file *file_priv);
extern int psb_gtt_unmap_meminfo_ioctl(struct drm_device *dev, void *data,
				       struct drm_file *file_priv);
extern int psb_gtt_mm_init(struct psb_gtt *pg);
extern void psb_gtt_mm_takedown(void);

extern int psb_gtt_map_pvr_memory(struct drm_device *dev,
                                                                  unsigned int hHandle,
                                                                  unsigned int ui32TaskId,
                                                                  IMG_CPU_PHYADDR *pPages,
                                                                  unsigned int ui32PagesNum,
                                                                  unsigned int *ui32Offset);

extern int psb_gtt_unmap_pvr_memory(struct drm_device *dev,
                                                                        unsigned int hHandle,
                                                                        unsigned int ui32TaskId);

#endif