pandev.h 2.32 KB
Newer Older
1
/*
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
2
 * © Copyright 2017-2018 The Panfrost Community
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
 *
 * This program is free software and is provided to you under the terms of the
 * GNU General Public License version 2 as published by the Free Software
 * Foundation, and any use by you of this program is subject to the terms
 * of such GNU licence.
 *
 * A copy of the licence is included with the program, and can also be obtained
 * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301, USA.
 *
 */

#ifndef __PANDEV_H__
#define __PANDEV_H__

18 19
#include <unistd.h>
#include <sys/mman.h>
20
#include <stdbool.h>
21
#include <mali-ioctl.h>
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
22
#include <mali-job.h>
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
23
#include <linux/ioctl.h>
24
#include "slow-framebuffer.h"
25

26
int pandev_open(void);
27 28
int pandev_query_mem(int fd, mali_ptr addr, enum mali_ioctl_mem_query_type attr,
		     u64 *out);
29

Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
30
/* Calls used while replaying */
31
int pandev_raw_open(void);
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
32 33 34
u8* pandev_map_mtp(int fd);
int pandev_ioctl(int fd, unsigned long request, void *args);

35 36 37
int pandev_standard_allocate(int fd, int va_pages, int flags, u64 *out);
int pandev_general_allocate(int fd, int va_pages, int commit_pages, int extent, int flags, u64 *out);

38
void pandev_shader_assemble(uint32_t *dst, const char *src, int type);
39
void* pandev_shader_compile(uint32_t *dst, const char *src, int type);
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
40

41
struct panfrost_context;
42
struct panfrost_shader_state;
43
void
44
panfrost_shader_compile(struct panfrost_context *ctx, struct mali_tripipe *meta, const char *src, int type, struct panfrost_shader_state *state);
45

46 47 48 49
struct panfrost_memory {
	uint8_t* cpu;
	mali_ptr gpu;
	int stack_bottom;
50
	size_t size;
51 52 53
};

/* Functions for replay */
54
mali_ptr pandev_upload(int cheating_offset, int *stack_bottom, mali_ptr base, void *base_map, void *data, size_t sz, bool no_pad);
55
mali_ptr pandev_upload_sequential(mali_ptr base, void *base_map, void *data, size_t sz);
56

57
/* Functions for the actual Galliumish driver */
58
mali_ptr panfrost_upload(struct panfrost_memory *mem, const void *data, size_t sz, bool no_pad);
59 60
mali_ptr panfrost_upload_sequential(struct panfrost_memory *mem, void *data, size_t sz);

61 62 63
void *
panfrost_allocate_transfer(struct panfrost_memory *mem, size_t sz, mali_ptr *gpu);

64 65 66 67 68 69
static inline void
panfrost_reserve(struct panfrost_memory *mem, size_t sz)
{
	mem->stack_bottom += sz;
}

70 71 72
#include <math.h>
#define inff INFINITY

73 74
#define R(...) #__VA_ARGS__

75
#endif /* __PANDEV_H__ */