1 #ifndef _MEDIA_VIDEOBUF2_INTERNAL_H
2 #define _MEDIA_VIDEOBUF2_INTERNAL_H
5 #include <linux/kernel.h>
6 #include <linux/module.h>
7 #include <media/videobuf2-core.h>
11 #define dprintk(level, fmt, arg...) \
13 if (vb2_debug >= level) \
14 pr_info("vb2: %s: " fmt, __func__, ## arg); \
17 #ifdef CONFIG_VIDEO_ADV_DEBUG
20 * If advanced debugging is on, then count how often each op is called
21 * successfully, which can either be per-buffer or per-queue.
23 * This makes it easy to check that the 'init' and 'cleanup'
24 * (and variations thereof) stay balanced.
27 #define log_memop(vb, op) \
28 dprintk(2, "call_memop(%p, %d, %s)%s\n", \
29 (vb)->vb2_queue, (vb)->index, #op, \
30 (vb)->vb2_queue->mem_ops->op ? "" : " (nop)")
32 #define call_memop(vb, op, args...) \
34 struct vb2_queue *_q = (vb)->vb2_queue; \
38 err = _q->mem_ops->op ? _q->mem_ops->op(args) : 0; \
40 (vb)->cnt_mem_ ## op++; \
44 #define call_ptr_memop(vb, op, args...) \
46 struct vb2_queue *_q = (vb)->vb2_queue; \
50 ptr = _q->mem_ops->op ? _q->mem_ops->op(args) : NULL; \
51 if (!IS_ERR_OR_NULL(ptr)) \
52 (vb)->cnt_mem_ ## op++; \
56 #define call_void_memop(vb, op, args...) \
58 struct vb2_queue *_q = (vb)->vb2_queue; \
61 if (_q->mem_ops->op) \
62 _q->mem_ops->op(args); \
63 (vb)->cnt_mem_ ## op++; \
66 #define log_qop(q, op) \
67 dprintk(2, "call_qop(%p, %s)%s\n", q, #op, \
68 (q)->ops->op ? "" : " (nop)")
70 #define call_qop(q, op, args...) \
75 err = (q)->ops->op ? (q)->ops->op(args) : 0; \
81 #define call_void_qop(q, op, args...) \
89 #define log_vb_qop(vb, op, args...) \
90 dprintk(2, "call_vb_qop(%p, %d, %s)%s\n", \
91 (vb)->vb2_queue, (vb)->index, #op, \
92 (vb)->vb2_queue->ops->op ? "" : " (nop)")
94 #define call_vb_qop(vb, op, args...) \
99 err = (vb)->vb2_queue->ops->op ? \
100 (vb)->vb2_queue->ops->op(args) : 0; \
102 (vb)->cnt_ ## op++; \
106 #define call_void_vb_qop(vb, op, args...) \
108 log_vb_qop(vb, op); \
109 if ((vb)->vb2_queue->ops->op) \
110 (vb)->vb2_queue->ops->op(args); \
111 (vb)->cnt_ ## op++; \
116 #define call_memop(vb, op, args...) \
117 ((vb)->vb2_queue->mem_ops->op ? \
118 (vb)->vb2_queue->mem_ops->op(args) : 0)
120 #define call_ptr_memop(vb, op, args...) \
121 ((vb)->vb2_queue->mem_ops->op ? \
122 (vb)->vb2_queue->mem_ops->op(args) : NULL)
124 #define call_void_memop(vb, op, args...) \
126 if ((vb)->vb2_queue->mem_ops->op) \
127 (vb)->vb2_queue->mem_ops->op(args); \
130 #define call_qop(q, op, args...) \
131 ((q)->ops->op ? (q)->ops->op(args) : 0)
133 #define call_void_qop(q, op, args...) \
136 (q)->ops->op(args); \
139 #define call_vb_qop(vb, op, args...) \
140 ((vb)->vb2_queue->ops->op ? (vb)->vb2_queue->ops->op(args) : 0)
142 #define call_void_vb_qop(vb, op, args...) \
144 if ((vb)->vb2_queue->ops->op) \
145 (vb)->vb2_queue->ops->op(args); \
150 #define call_bufop(q, op, args...) \
153 if (q && q->buf_ops && q->buf_ops->op) \
154 ret = q->buf_ops->op(args); \
158 bool vb2_buffer_in_use(struct vb2_queue
*q
, struct vb2_buffer
*vb
);
159 int vb2_verify_memory_type(struct vb2_queue
*q
,
160 enum vb2_memory memory
, unsigned int type
);
161 #endif /* _MEDIA_VIDEOBUF2_INTERNAL_H */