summaryrefslogtreecommitdiff
path: root/drivers/media/video/tiler/tmm.h
blob: fbdc1e23d0e84b49bb7d1234f41f8a9af3d88c51 (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
/*
 * tmm.h
 *
 * TMM interface definition for TI TILER driver.
 *
 * Author: Lajos Molnar <molnar@ti.com>
 *
 * Copyright (C) 2009-2010 Texas Instruments, Inc.
 *
 * This package is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 */
#ifndef TMM_H
#define TMM_H

#include <mach/dmm.h>
/**
 * TMM interface
 */
struct tmm {
	void *pvt;

	/* function table */
	u32 *(*get)	(struct tmm *tmm, u32 num_pages);
	void (*free)	(struct tmm *tmm, u32 *pages);
	s32  (*map)	(struct tmm *tmm, struct pat_area area, u32 page_pa);
	void (*clear)	(struct tmm *tmm, struct pat_area area);
	void (*deinit)	(struct tmm *tmm);
};

/**
 * Request a set of pages from the DMM free page stack.
 * @return a pointer to a list of physical page addresses.
 */
static inline
u32 *tmm_get(struct tmm *tmm, u32 num_pages)
{
	if (tmm && tmm->pvt)
		return tmm->get(tmm, num_pages);
	return NULL;
}

/**
 * Return a set of used pages to the DMM free page stack.
 * @param list a pointer to a list of physical page addresses.
 */
static inline
void tmm_free(struct tmm *tmm, u32 *pages)
{
	if (tmm && tmm->pvt)
		tmm->free(tmm, pages);
}

/**
 * Program the physical address translator.
 * @param area PAT area
 * @param list of pages
 */
static inline
s32 tmm_map(struct tmm *tmm, struct pat_area area, u32 page_pa)
{
	if (tmm && tmm->map && tmm->pvt)
		return tmm->map(tmm, area, page_pa);
	return -ENODEV;
}

/**
 * Clears the physical address translator.
 * @param area PAT area
 */
static inline
void tmm_clear(struct tmm *tmm, struct pat_area area)
{
	if (tmm && tmm->clear && tmm->pvt)
		tmm->clear(tmm, area);
}

/**
 * Checks whether tiler memory manager supports mapping
 */
static inline
bool tmm_can_map(struct tmm *tmm)
{
	return tmm && tmm->map;
}

/**
 * Deinitialize tiler memory manager
 */
static inline
void tmm_deinit(struct tmm *tmm)
{
	if (tmm && tmm->pvt)
		tmm->deinit(tmm);
}

/**
 * TMM implementation for PAT support.
 *
 * Initialize TMM for PAT with given id.
 */
struct tmm *tmm_pat_init(u32 pat_id);

#endif