summaryrefstree
path: root/kernel/drivers/vision/dsp/dsp-util.h
blob: 706258625b83113c895dc148271badcddb8d94a9 (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
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Samsung Exynos SoC series dsp driver
 *
 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
 *              http://www.samsung.com/
 */

#ifndef __DSP_UTIL_H__
#define __DSP_UTIL_H__

#include <linux/bitmap.h>

#define DSP_BITMAP_NAME_LEN		(16)

struct dsp_util_queue {
	unsigned int			front;
	unsigned int			rear;
	unsigned int			data_size;
	unsigned int			data_count;
	unsigned int			iova;
	unsigned int			size;
	union {
		struct {
			unsigned int	kva_low;
			unsigned int	kva_high;
		};
		void			*kva;
	};
};

struct dsp_util_bitmap {
	char				name[DSP_BITMAP_NAME_LEN];
	unsigned long			*bitmap;
	unsigned int			bitmap_size;
	unsigned int			used_size;
	unsigned int			base_bit;
};

void dsp_util_queue_dump(struct dsp_util_queue *queue);
int dsp_util_queue_read_count(struct dsp_util_queue *queue);
int dsp_util_queue_check_full(struct dsp_util_queue *queue);
int dsp_util_queue_enqueue(struct dsp_util_queue *queue, void *data,
		size_t data_size);
int dsp_util_queue_check_empty(struct dsp_util_queue *queue);
int dsp_util_queue_dequeue(struct dsp_util_queue *queue, void *data,
		size_t data_size);
int dsp_util_queue_init(struct dsp_util_queue *queue, unsigned int data_size,
		unsigned int queue_size, unsigned int iova,
		unsigned long long kva);

void dsp_util_bitmap_dump(struct dsp_util_bitmap *map);
int dsp_util_bitmap_set_region(struct dsp_util_bitmap *map, unsigned int size);
void dsp_util_bitmap_clear_region(struct dsp_util_bitmap *map,
		unsigned int start, unsigned int size);
int dsp_util_bitmap_init(struct dsp_util_bitmap *map, const char *name,
		unsigned int size);
void dsp_util_bitmap_deinit(struct dsp_util_bitmap *map);

#endif