summaryrefstree
path: root/kernel/drivers/vision/vpu/vpu-graphmgr.h
blob: db79e51f5741a8a21c2c1d571bfd51ec5b3b93f5 (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
/*
 * 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_GRAPHMGR_H_
#define VPU_GRAPHMGR_H_

#include <linux/kthread.h>
#include <linux/types.h>

#include "vpu-framemgr.h"
#include "vpu-graph.h"
#include "vpu-interface.h"
#include "vpu-resource.h"

#define VPU_MAX_GFRAME			(VPU_MAX_GRAPH * 2)

enum vpu_gframe_state {
	VPU_GFRAME_STATE_INVALID,
	VPU_GFRAME_STATE_FREE,
	VPU_GFRAME_STATE_READY,
	VPU_GFRAME_STATE_REQUEST,
	VPU_GFRAME_STATE_ALLOC,
	VPU_GFRAME_STATE_PROCESS,
	VPU_GFRAME_STATE_COMPLETE
};

struct vpu_gframe {
	struct list_head		list;
	u32				index;
	u32				priority;
	struct vpu_graph		*graph;
	struct vpu_frame		*frame;
	u32				ticks;
	u32				state;
};

enum vpu_graphmgr_state {
	VPU_GRAPHMGR_OPEN,
	VPU_GRAPHMGR_ENUM
};

enum vpu_graphmgr_client {
	VPU_GRAPHMGR_CLIENT_GRAPH = 1,
	VPU_GRAPHMGR_CLIENT_INTERFACE
};

struct vpu_graphmgr {
	struct vpu_graph		*graph[VPU_MAX_GRAPH];
	atomic_t			periodics;
	unsigned long			state;
	struct mutex			mlock;

	u32				tick_cnt;
	u32				tick_pos;
	u32				sched_cnt;
	u32				sched_pos;
	struct kthread_worker		worker;
	struct task_struct		*task_graph;
	struct task_struct		*task_timer;

	struct vpu_resource		*resource;
	struct vpu_interface		*interface;

	struct mutex			glock;
	struct vpu_gframe		gframe[VPU_MAX_GFRAME];
	struct list_head		gfre_list;
	struct list_head		grdy_list;
	struct list_head		greq_list;
	struct list_head		galc_list;
	struct list_head		gpro_list;
	struct list_head		gcom_list;
	u32				gfre_cnt;
	u32				grdy_cnt;
	u32				greq_cnt;
	u32				galc_cnt;
	u32				gpro_cnt;
	u32				gcom_cnt;
};

void vpu_gframe_print(struct vpu_graphmgr *graphmgr);
int vpu_graphmgr_probe(struct vpu_graphmgr *graphmgr, struct vpu_resource *resource);
int vpu_graphmgr_open(struct vpu_graphmgr *graphmgr);
int vpu_graphmgr_close(struct vpu_graphmgr *graphmgr);
int vpu_graphmgr_grp_register(struct vpu_graphmgr *graphmgr, struct vpu_graph *graph);
int vpu_graphmgr_grp_unregister(struct vpu_graphmgr *graphmgr, struct vpu_graph *graph);
int vpu_graphmgr_grp_start(struct vpu_graphmgr *graphmgr, struct vpu_graph *graph);
int vpu_graphmgr_grp_stop(struct vpu_graphmgr *graphmgr, struct vpu_graph *graph);
int vpu_graphmgr_itf_register(struct vpu_graphmgr *graphmgr, struct vpu_interface *interface);
int vpu_graphmgr_itf_unregister(struct vpu_graphmgr *graphmgr, struct vpu_interface *interface);
void vpu_graphmgr_queue(struct vpu_graphmgr *graphmgr, struct vpu_frame *frame);
#endif