summaryrefstree
path: root/kernel/drivers/vision/vpu/include/vpu-memory.h
blob: 03735c19d1a825214bbfbb434d79cd03ed360669 (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
/*
 * Samsung Exynos SoC series VPU driver
 *
 * Copyright (c) 2015 Samsung Electronics Co., Ltd
 *
 * This program 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.
 */

#ifndef VPU_MEMORY_H_
#define VPU_MEMORY_H_

#include <linux/platform_device.h>
#include <media/videobuf2-core.h>
#if defined(CONFIG_VIDEOBUF2_CMA_PHYS)
#include <media/videobuf2-cma-phys.h>
#elif defined(CONFIG_VIDEOBUF2_ION)
#include <media/videobuf2-ion.h>
#endif

#define VPU_MEMORY_INTERNAL_SIZE	0

struct vpu_memory_buffer {
	struct list_head		list;
	int				fd;
	dma_addr_t			dvaddr;
	void				*kvaddr;
	void				*mem_priv;
	void				*cookie;
	void				*dbuf;
	size_t				size;
};

struct vpu_memory_info {
	void		*cookie;
	void		*kvaddr;
	dma_addr_t	dvaddr;

	u32		dvaddr_debug;
	ulong		kvaddr_debug;
};

struct vpu_mem_ops {
	void (*cleanup)(void *alloc_ctx);
	int (*resume)(void *alloc_ctx);
	void (*suspend)(void *alloc_ctx);
	void (*set_cacheable)(void *alloc_ctx, bool cacheable);
};

struct vpu_memory {
	struct device			*dev;
	struct vb2_alloc_ctx		*alloc_ctx;
	const struct vpu_mem_ops	*vpu_mem_ops;
	const struct vb2_mem_ops	*vb2_mem_ops;

	spinlock_t			im_lock;
	struct list_head		im_list;
	u32				im_count;
	struct vpu_memory_info		info;
};

int vpu_memory_probe(struct vpu_memory *memory, struct device *dev);
int vpu_memory_open(struct vpu_memory *memory);
int vpu_memory_close(struct vpu_memory *memory);
int vpu_memory_map(struct vpu_memory *memory, struct vpu_memory_buffer *buffer);
int vpu_memory_unmap(struct vpu_memory *memory, struct vpu_memory_buffer *buffer);

#endif