hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
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
100
101
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (C) Rockchip Electronics Co., Ltd.
 *
 * Author: Huang Lee <Putin.li@rock-chips.com>
 */
 
#ifndef __LINUX_RGA_FENCE_H_
#define __LINUX_RGA_FENCE_H_
 
struct rga_fence_context {
   unsigned int context;
   unsigned int seqno;
   spinlock_t spinlock;
};
 
struct rga_fence_waiter {
   /* Base sync driver waiter structure */
   struct dma_fence_cb waiter;
 
   void *private;
};
 
#ifdef CONFIG_ROCKCHIP_RGA_ASYNC
int rga_fence_context_init(struct rga_fence_context **ctx);
void rga_fence_context_remove(struct rga_fence_context **ctx);
 
struct dma_fence *rga_dma_fence_alloc(void);
int rga_dma_fence_get_fd(struct dma_fence *fence);
struct dma_fence *rga_get_dma_fence_from_fd(int fence_fd);
int rga_dma_fence_wait(struct dma_fence *fence);
int rga_dma_fence_add_callback(struct dma_fence *fence, dma_fence_func_t func, void *private);
 
 
static inline void rga_dma_fence_put(struct dma_fence *fence)
{
   if (fence)
       dma_fence_put(fence);
}
 
static inline void rga_dma_fence_signal(struct dma_fence *fence, int error)
{
   if (fence) {
       if (error != 0)
           dma_fence_set_error(fence, error);
       dma_fence_signal(fence);
   }
}
 
static inline int rga_dma_fence_get_status(struct dma_fence *fence)
{
   if (fence)
       return dma_fence_get_status(fence);
   else
       return 1;
}
 
#else
static inline struct dma_fence *rga_dma_fence_alloc(void)
{
   return NULL;
}
 
static inline int rga_dma_fence_get_fd(struct dma_fence *fence)
{
   return 0;
}
 
static inline struct dma_fence *rga_get_dma_fence_from_fd(int fence_fd)
{
   return NULL;
}
 
static inline int rga_dma_fence_wait(struct dma_fence *fence)
{
   return 0;
}
 
static inline int rga_dma_fence_add_callback(struct dma_fence *fence,
                        dma_fence_func_t func,
                        void *private)
{
   return 0;
}
 
static inline void rga_dma_fence_put(struct dma_fence *fence)
{
}
 
static inline void rga_dma_fence_signal(struct dma_fence *fence, int error)
{
}
 
static inline int rga_dma_fence_get_status(struct dma_fence *fence)
{
   return 0;
}
 
#endif /* #ifdef CONFIG_SYNC_FILE */
 
#endif /* __LINUX_RGA_FENCE_H_ */