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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
/*
* 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 VISION_BUFFER_H_
#define VISION_BUFFER_H_
#include <linux/mm_types.h>
#include <linux/mutex.h>
#include <linux/poll.h>
#include <linux/dma-buf.h>
#include <linux/time.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
#include "vision-config.h"
#include "vs4l.h"
#define VB_MAX_BUFFER VISION_MAX_BUFFER
#define VB_MAX_PLANES VISION_MAX_PLANE
struct vb_queue;
struct vb_fmt {
char *name;
u32 colorspace;
u32 planes;
u32 bitsperpixel[VB_MAX_PLANES];
};
struct vb_format {
u32 target;
struct vb_fmt *fmt;
u32 colorspace;
u32 plane;
u32 width;
u32 height;
u32 size[VB_MAX_PLANES];
};
struct vb_format_list {
u32 count;
struct vb_format *formats;
};
struct vb_buffer {
struct vs4l_roi roi;
union {
unsigned long userptr;
__s32 fd;
} m;
struct dma_buf *dbuf;
void *mem_priv;
void *cookie;
void *kvaddr;
dma_addr_t dvaddr;
ulong reserved;
};
struct vb_container {
u32 type;
u32 target;
u32 memory;
u32 reserved[4];
u32 count;
struct vb_buffer *buffers;
struct vb_format *format;
};
struct vb_container_list {
u32 direction;
u32 id;
u32 index;
unsigned long flags;
struct timeval timestamp[6];
u32 count;
struct vb_container *containers;
};
enum vb_bundle_state {
VB_BUF_STATE_DEQUEUED,
VB_BUF_STATE_QUEUED,
VB_BUF_STATE_PROCESS,
VB_BUF_STATE_DONE,
};
struct vb_bundle {
/* this flag is for internal state */
unsigned long flags;
enum vb_bundle_state state;
struct list_head queued_entry;
struct list_head process_entry;
struct list_head done_entry;
struct vb_container_list clist;
};
struct vb_ops {
int (*buf_prepare)(struct vb_queue *q, struct vb_container_list *clist);
int (*buf_unprepare)(struct vb_queue *q, struct vb_container_list *clist);
};
enum vb_queue_state {
VB_QUEUE_STATE_FORMAT,
VB_QUEUE_STATE_START
};
struct vb_queue {
u32 direction;
const char *name;
unsigned long state;
unsigned int streaming:1;
struct mutex *lock;
struct list_head queued_list;
atomic_t queued_count;
struct list_head process_list;
atomic_t process_count;
struct list_head done_list;
atomic_t done_count;
spinlock_t done_lock;
wait_queue_head_t done_wq;
struct vb_format_list format;
struct vb_bundle *bufs[VB_MAX_BUFFER];
unsigned int num_buffers;
void *alloc_ctx;
const struct vb2_mem_ops *mem_ops;
const struct vb_ops *ops;
void *private_data;
};
int vb_queue_init(struct vb_queue *q, void *alloc_ctx, const struct vb2_mem_ops *mem_ops, const struct vb_ops *ops, struct mutex *lock, u32 direction);
int vb_queue_s_format(struct vb_queue *q, struct vs4l_format_list *f);
int vb_queue_start(struct vb_queue *q);
int vb_queue_stop(struct vb_queue *q);
int vb_queue_qbuf(struct vb_queue *q, struct vs4l_container_list *c);
int vb_queue_dqbuf(struct vb_queue *q, struct vs4l_container_list *c, bool nonblocking);
void vb_queue_process(struct vb_queue *q, struct vb_bundle *vb);
void vb_queue_done(struct vb_queue *q, struct vb_bundle *vb);
#define call_memop(q, op, args...) (((q)->mem_ops->op) ? ((q)->mem_ops->op(args)) : 0)
#define call_op(q, op, args...) (((q)->ops->op) ? ((q)->ops->op(args)) : 0)
#endif
|