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
|
/*
* Copyright © 2010 Jerome Glisse <glisse@freedesktop.org>
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that 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 RADEON_DEVICE_H
#define RADEON_DEVICE_H
#include "radeon.h"
#include "lwrapper.h"
#include "radeon_atom.h"
struct radeon_device;
struct radeon_ib;
struct radeon_atom;
/* Wrapper to make it looks like kernel *************************************/
#define radeon_bo_size(bo) ((bo)->size)
struct radeon_device {
struct radeon *radeon;
int fd;
struct radeon_bo *bo[32];
u32 nbo;
struct idr idr;
struct mutex mutex;
struct r600_batches batches;
unsigned npipes;
unsigned nbanks;
unsigned group_bytes;
};
struct radeon_ib {
u32 *ptr;
u32 cpkts;
u32 length_dw;
u32 *relocs;
u32 crelocs;
u32 nrelocs;
};
extern u32 radeon_ib_reloc(struct radeon_ib *ib, struct radeon_bo *bo, u32 d);
extern int radeon_ib_get(struct radeon_device *rdev, struct radeon_ib **ib);
extern void radeon_ib_free(struct radeon_ib *ib);
extern int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib);
static inline int radeon_ib_begin(struct radeon_ib *ib, u32 ndw)
{
if ((ib->cpkts + ndw) > ib->length_dw)
return -ENOMEM;
return 0;
}
static inline int radeon_ib_copy(struct radeon_ib *ib, u32 *pkts, u32 ndw)
{
if ((ib->cpkts + ndw) > ib->length_dw) {
fprintf(stderr, "IB FULL !\n");
return -ENOMEM;
}
memcpy(&ib->ptr[ib->cpkts], pkts, ndw * 4);
ib->cpkts += ndw;
return 0;
}
#endif
|