s390/ptrace: get rid of long longs in psw_bits
[linux/fpc-iii.git] / drivers / media / v4l2-core / videobuf2-internal.h
blob79018c74928262d46c4bb5de74b2efcca5749162
1 #ifndef _MEDIA_VIDEOBUF2_INTERNAL_H
2 #define _MEDIA_VIDEOBUF2_INTERNAL_H
4 #include <linux/err.h>
5 #include <linux/kernel.h>
6 #include <linux/module.h>
7 #include <media/videobuf2-core.h>
9 extern int vb2_debug;
11 #define dprintk(level, fmt, arg...) \
12 do { \
13 if (vb2_debug >= level) \
14 pr_info("vb2: %s: " fmt, __func__, ## arg); \
15 } while (0)
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...) \
33 ({ \
34 struct vb2_queue *_q = (vb)->vb2_queue; \
35 int err; \
37 log_memop(vb, op); \
38 err = _q->mem_ops->op ? _q->mem_ops->op(args) : 0; \
39 if (!err) \
40 (vb)->cnt_mem_ ## op++; \
41 err; \
44 #define call_ptr_memop(vb, op, args...) \
45 ({ \
46 struct vb2_queue *_q = (vb)->vb2_queue; \
47 void *ptr; \
49 log_memop(vb, op); \
50 ptr = _q->mem_ops->op ? _q->mem_ops->op(args) : NULL; \
51 if (!IS_ERR_OR_NULL(ptr)) \
52 (vb)->cnt_mem_ ## op++; \
53 ptr; \
56 #define call_void_memop(vb, op, args...) \
57 ({ \
58 struct vb2_queue *_q = (vb)->vb2_queue; \
60 log_memop(vb, op); \
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...) \
71 ({ \
72 int err; \
74 log_qop(q, op); \
75 err = (q)->ops->op ? (q)->ops->op(args) : 0; \
76 if (!err) \
77 (q)->cnt_ ## op++; \
78 err; \
81 #define call_void_qop(q, op, args...) \
82 ({ \
83 log_qop(q, op); \
84 if ((q)->ops->op) \
85 (q)->ops->op(args); \
86 (q)->cnt_ ## op++; \
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...) \
95 ({ \
96 int err; \
98 log_vb_qop(vb, op); \
99 err = (vb)->vb2_queue->ops->op ? \
100 (vb)->vb2_queue->ops->op(args) : 0; \
101 if (!err) \
102 (vb)->cnt_ ## op++; \
103 err; \
106 #define call_void_vb_qop(vb, op, args...) \
107 ({ \
108 log_vb_qop(vb, op); \
109 if ((vb)->vb2_queue->ops->op) \
110 (vb)->vb2_queue->ops->op(args); \
111 (vb)->cnt_ ## op++; \
114 #else
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...) \
125 do { \
126 if ((vb)->vb2_queue->mem_ops->op) \
127 (vb)->vb2_queue->mem_ops->op(args); \
128 } while (0)
130 #define call_qop(q, op, args...) \
131 ((q)->ops->op ? (q)->ops->op(args) : 0)
133 #define call_void_qop(q, op, args...) \
134 do { \
135 if ((q)->ops->op) \
136 (q)->ops->op(args); \
137 } while (0)
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...) \
143 do { \
144 if ((vb)->vb2_queue->ops->op) \
145 (vb)->vb2_queue->ops->op(args); \
146 } while (0)
148 #endif
150 #define call_bufop(q, op, args...) \
151 ({ \
152 int ret = 0; \
153 if (q && q->buf_ops && q->buf_ops->op) \
154 ret = q->buf_ops->op(args); \
155 ret; \
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 */