aboutsummaryrefslogtreecommitdiffstats
path: root/include/media
diff options
context:
space:
mode:
Diffstat (limited to 'include/media')
-rw-r--r--include/media/cx2341x.h2
-rw-r--r--include/media/ir-common.h1
-rw-r--r--include/media/ivtv.h65
-rw-r--r--include/media/saa7146.h1
-rw-r--r--include/media/saa7146_vv.h2
-rw-r--r--include/media/tuner-types.h4
-rw-r--r--include/media/tuner.h1
-rw-r--r--include/media/v4l2-chip-ident.h3
-rw-r--r--include/media/v4l2-dev.h16
-rw-r--r--include/media/v4l2-int-device.h278
-rw-r--r--include/media/videobuf-core.h (renamed from include/media/video-buf.h)181
-rw-r--r--include/media/videobuf-dma-sg.h122
-rw-r--r--include/media/videobuf-dvb.h (renamed from include/media/video-buf-dvb.h)0
-rw-r--r--include/media/videobuf-vmalloc.h41
14 files changed, 524 insertions, 193 deletions
diff --git a/include/media/cx2341x.h b/include/media/cx2341x.h
index 38c12fed7535..af8071d7620d 100644
--- a/include/media/cx2341x.h
+++ b/include/media/cx2341x.h
@@ -91,7 +91,7 @@ int cx2341x_update(void *priv, cx2341x_mbox_func func,
91int cx2341x_ctrl_query(struct cx2341x_mpeg_params *params, 91int cx2341x_ctrl_query(struct cx2341x_mpeg_params *params,
92 struct v4l2_queryctrl *qctrl); 92 struct v4l2_queryctrl *qctrl);
93const char **cx2341x_ctrl_get_menu(u32 id); 93const char **cx2341x_ctrl_get_menu(u32 id);
94int cx2341x_ext_ctrls(struct cx2341x_mpeg_params *params, 94int cx2341x_ext_ctrls(struct cx2341x_mpeg_params *params, int busy,
95 struct v4l2_ext_controls *ctrls, unsigned int cmd); 95 struct v4l2_ext_controls *ctrls, unsigned int cmd);
96void cx2341x_fill_defaults(struct cx2341x_mpeg_params *p); 96void cx2341x_fill_defaults(struct cx2341x_mpeg_params *p);
97void cx2341x_log_status(struct cx2341x_mpeg_params *p, const char *prefix); 97void cx2341x_log_status(struct cx2341x_mpeg_params *p, const char *prefix);
diff --git a/include/media/ir-common.h b/include/media/ir-common.h
index 9807a7c15830..7a785fa77212 100644
--- a/include/media/ir-common.h
+++ b/include/media/ir-common.h
@@ -140,6 +140,7 @@ extern IR_KEYTAB_TYPE ir_codes_budget_ci_old[IR_KEYTAB_SIZE];
140extern IR_KEYTAB_TYPE ir_codes_asus_pc39[IR_KEYTAB_SIZE]; 140extern IR_KEYTAB_TYPE ir_codes_asus_pc39[IR_KEYTAB_SIZE];
141extern IR_KEYTAB_TYPE ir_codes_encore_enltv[IR_KEYTAB_SIZE]; 141extern IR_KEYTAB_TYPE ir_codes_encore_enltv[IR_KEYTAB_SIZE];
142extern IR_KEYTAB_TYPE ir_codes_tt_1500[IR_KEYTAB_SIZE]; 142extern IR_KEYTAB_TYPE ir_codes_tt_1500[IR_KEYTAB_SIZE];
143extern IR_KEYTAB_TYPE ir_codes_fusionhdtv_mce[IR_KEYTAB_SIZE];
143 144
144#endif 145#endif
145 146
diff --git a/include/media/ivtv.h b/include/media/ivtv.h
deleted file mode 100644
index 412b48ea8eda..000000000000
--- a/include/media/ivtv.h
+++ /dev/null
@@ -1,65 +0,0 @@
1/*
2 Public ivtv API header
3 Copyright (C) 2003-2004 Kevin Thayer <nufan_wfk at yahoo.com>
4 Copyright (C) 2004-2007 Hans Verkuil <hverkuil@xs4all.nl>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#ifndef _LINUX_IVTV_H
22#define _LINUX_IVTV_H
23
24/* ivtv knows several distinct output modes: MPEG streaming,
25 YUV streaming, YUV updates through user DMA and the passthrough
26 mode.
27
28 In order to clearly tell the driver that we are in user DMA
29 YUV mode you need to call IVTV_IOC_DMA_FRAME with y_source == NULL
30 first (althrough if you don't then the first time
31 DMA_FRAME is called the mode switch is done automatically).
32
33 When you close the file handle the user DMA mode is exited again.
34
35 While in one mode, you cannot use another mode (EBUSY is returned).
36
37 All this means that if you want to change the YUV interlacing
38 for the user DMA YUV mode you first need to do call IVTV_IOC_DMA_FRAME
39 with y_source == NULL before you can set the correct format using
40 VIDIOC_S_FMT.
41
42 Eventually all this should be replaced with a proper V4L2 API,
43 but for now we have to do it this way. */
44
45struct ivtv_dma_frame {
46 enum v4l2_buf_type type; /* V4L2_BUF_TYPE_VIDEO_OUTPUT */
47 __u32 pixelformat; /* 0 == same as destination */
48 void __user *y_source; /* if NULL and type == V4L2_BUF_TYPE_VIDEO_OUTPUT,
49 then just switch to user DMA YUV output mode */
50 void __user *uv_source; /* Unused for RGB pixelformats */
51 struct v4l2_rect src;
52 struct v4l2_rect dst;
53 __u32 src_width;
54 __u32 src_height;
55};
56
57#define IVTV_IOC_DMA_FRAME _IOW ('V', BASE_VIDIOC_PRIVATE+0, struct ivtv_dma_frame)
58
59/* These are the VBI types as they appear in the embedded VBI private packets. */
60#define IVTV_SLICED_TYPE_TELETEXT_B (1)
61#define IVTV_SLICED_TYPE_CAPTION_525 (4)
62#define IVTV_SLICED_TYPE_WSS_625 (5)
63#define IVTV_SLICED_TYPE_VPS (7)
64
65#endif /* _LINUX_IVTV_H */
diff --git a/include/media/saa7146.h b/include/media/saa7146.h
index 67703249b245..cd3ff2c29d5e 100644
--- a/include/media/saa7146.h
+++ b/include/media/saa7146.h
@@ -146,7 +146,6 @@ struct saa7146_dev
146 146
147/* from saa7146_i2c.c */ 147/* from saa7146_i2c.c */
148int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev, struct i2c_adapter *i2c_adapter, u32 bitrate); 148int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev, struct i2c_adapter *i2c_adapter, u32 bitrate);
149int saa7146_i2c_transfer(struct saa7146_dev *saa, const struct i2c_msg *msgs, int num, int retries);
150 149
151/* from saa7146_core.c */ 150/* from saa7146_core.c */
152extern struct list_head saa7146_devices; 151extern struct list_head saa7146_devices;
diff --git a/include/media/saa7146_vv.h b/include/media/saa7146_vv.h
index cce20ed5cf6c..e49f7e156061 100644
--- a/include/media/saa7146_vv.h
+++ b/include/media/saa7146_vv.h
@@ -4,7 +4,7 @@
4#include <linux/videodev.h> 4#include <linux/videodev.h>
5#include <media/v4l2-common.h> 5#include <media/v4l2-common.h>
6#include <media/saa7146.h> 6#include <media/saa7146.h>
7#include <media/video-buf.h> 7#include <media/videobuf-dma-sg.h>
8 8
9#define MAX_SAA7146_CAPTURE_BUFFERS 32 /* arbitrary */ 9#define MAX_SAA7146_CAPTURE_BUFFERS 32 /* arbitrary */
10#define BUFFER_TIMEOUT (HZ/2) /* 0.5 seconds */ 10#define BUFFER_TIMEOUT (HZ/2) /* 0.5 seconds */
diff --git a/include/media/tuner-types.h b/include/media/tuner-types.h
index e5ad3fcfe984..b201371416a0 100644
--- a/include/media/tuner-types.h
+++ b/include/media/tuner-types.h
@@ -79,6 +79,10 @@ struct tuner_params {
79 /* Select 18% (or according to datasheet 0%) L standard PLL gating, 79 /* Select 18% (or according to datasheet 0%) L standard PLL gating,
80 vs the driver default of 36%. */ 80 vs the driver default of 36%. */
81 unsigned int default_pll_gating_18:1; 81 unsigned int default_pll_gating_18:1;
82 /* IF to use in radio mode. Tuners with a separate radio IF filter
83 seem to use 10.7, while those without use 33.3 for PAL/SECAM tuners
84 and 41.3 for NTSC tuners. 0 = 10.7, 1 = 33.3, 2 = 41.3 */
85 unsigned int radio_if:2;
82 /* Default tda9887 TOP value in dB for the low band. Default is 0. 86 /* Default tda9887 TOP value in dB for the low band. Default is 0.
83 Range: -16:+15 */ 87 Range: -16:+15 */
84 signed int default_top_low:5; 88 signed int default_top_low:5;
diff --git a/include/media/tuner.h b/include/media/tuner.h
index 160381c72e4b..c03dceb92605 100644
--- a/include/media/tuner.h
+++ b/include/media/tuner.h
@@ -146,6 +146,7 @@ extern int tuner_debug;
146#define TDA9887_AUTOMUTE (1<<18) 146#define TDA9887_AUTOMUTE (1<<18)
147#define TDA9887_GATING_18 (1<<19) 147#define TDA9887_GATING_18 (1<<19)
148#define TDA9887_GAIN_NORMAL (1<<20) 148#define TDA9887_GAIN_NORMAL (1<<20)
149#define TDA9887_RIF_41_3 (1<<21) /* radio IF1 41.3 vs 33.3 */
149 150
150#ifdef __KERNEL__ 151#ifdef __KERNEL__
151 152
diff --git a/include/media/v4l2-chip-ident.h b/include/media/v4l2-chip-ident.h
index 09d16c4f00f7..8ae42c41dd08 100644
--- a/include/media/v4l2-chip-ident.h
+++ b/include/media/v4l2-chip-ident.h
@@ -65,6 +65,9 @@ enum {
65 V4L2_IDENT_CX23415 = 415, 65 V4L2_IDENT_CX23415 = 415,
66 V4L2_IDENT_CX23416 = 416, 66 V4L2_IDENT_CX23416 = 416,
67 67
68 /* module vp27smpx: just ident 2700 */
69 V4L2_IDENT_VP27SMPX = 2700,
70
68 /* module wm8739: just ident 8739 */ 71 /* module wm8739: just ident 8739 */
69 V4L2_IDENT_WM8739 = 8739, 72 V4L2_IDENT_WM8739 = 8739,
70 73
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index 17f8f3a2f0a3..e75d5e6c4cea 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -23,8 +23,6 @@
23#include <linux/videodev2.h> 23#include <linux/videodev2.h>
24#endif 24#endif
25 25
26#include <linux/fs.h>
27
28#define VIDEO_MAJOR 81 26#define VIDEO_MAJOR 81
29/* Minor device allocation */ 27/* Minor device allocation */
30#define MINOR_VFL_TYPE_GRABBER_MIN 0 28#define MINOR_VFL_TYPE_GRABBER_MIN 0
@@ -88,8 +86,11 @@ struct video_device
88 /* device ops */ 86 /* device ops */
89 const struct file_operations *fops; 87 const struct file_operations *fops;
90 88
89 /* sysfs */
90 struct device class_dev; /* v4l device */
91 struct device *dev; /* device parent */
92
91 /* device info */ 93 /* device info */
92 struct device *dev;
93 char name[32]; 94 char name[32];
94 int type; /* v4l1 */ 95 int type; /* v4l1 */
95 int type2; /* v4l2 */ 96 int type2; /* v4l2 */
@@ -334,7 +335,6 @@ void *priv;
334 /* for videodev.c intenal usage -- please don't touch */ 335 /* for videodev.c intenal usage -- please don't touch */
335 int users; /* video_exclusive_{open|close} ... */ 336 int users; /* video_exclusive_{open|close} ... */
336 struct mutex lock; /* ... helper function uses these */ 337 struct mutex lock; /* ... helper function uses these */
337 struct class_device class_dev; /* sysfs */
338}; 338};
339 339
340/* Class-dev to video-device */ 340/* Class-dev to video-device */
@@ -362,18 +362,18 @@ extern int video_usercopy(struct inode *inode, struct file *file,
362 362
363static inline int __must_check 363static inline int __must_check
364video_device_create_file(struct video_device *vfd, 364video_device_create_file(struct video_device *vfd,
365 struct class_device_attribute *attr) 365 struct device_attribute *attr)
366{ 366{
367 int ret = class_device_create_file(&vfd->class_dev, attr); 367 int ret = device_create_file(&vfd->class_dev, attr);
368 if (ret < 0) 368 if (ret < 0)
369 printk(KERN_WARNING "%s error: %d\n", __FUNCTION__, ret); 369 printk(KERN_WARNING "%s error: %d\n", __FUNCTION__, ret);
370 return ret; 370 return ret;
371} 371}
372static inline void 372static inline void
373video_device_remove_file(struct video_device *vfd, 373video_device_remove_file(struct video_device *vfd,
374 struct class_device_attribute *attr) 374 struct device_attribute *attr)
375{ 375{
376 class_device_remove_file(&vfd->class_dev, attr); 376 device_remove_file(&vfd->class_dev, attr);
377} 377}
378 378
379#endif /* CONFIG_VIDEO_V4L1_COMPAT */ 379#endif /* CONFIG_VIDEO_V4L1_COMPAT */
diff --git a/include/media/v4l2-int-device.h b/include/media/v4l2-int-device.h
new file mode 100644
index 000000000000..066ebfc4f983
--- /dev/null
+++ b/include/media/v4l2-int-device.h
@@ -0,0 +1,278 @@
1/*
2 * include/media/v4l2-int-device.h
3 *
4 * V4L2 internal ioctl interface.
5 *
6 * Copyright (C) 2007 Nokia Corporation.
7 *
8 * Contact: Sakari Ailus <sakari.ailus@nokia.com>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * version 2 as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 * 02110-1301 USA
23 */
24
25#ifndef V4L2_INT_DEVICE_H
26#define V4L2_INT_DEVICE_H
27
28#include <linux/module.h>
29#include <media/v4l2-common.h>
30
31#define V4L2NAMESIZE 32
32
33/*
34 *
35 * The internal V4L2 device interface core.
36 *
37 */
38
39enum v4l2_int_type {
40 v4l2_int_type_master = 1,
41 v4l2_int_type_slave
42};
43
44struct v4l2_int_device;
45
46struct v4l2_int_master {
47 int (*attach)(struct v4l2_int_device *master,
48 struct v4l2_int_device *slave);
49 void (*detach)(struct v4l2_int_device *master);
50};
51
52typedef int (v4l2_int_ioctl_func)(struct v4l2_int_device *);
53typedef int (v4l2_int_ioctl_func_0)(struct v4l2_int_device *);
54typedef int (v4l2_int_ioctl_func_1)(struct v4l2_int_device *, void *);
55
56struct v4l2_int_ioctl_desc {
57 int num;
58 v4l2_int_ioctl_func *func;
59};
60
61struct v4l2_int_slave {
62 /* Don't touch master. */
63 struct v4l2_int_device *master;
64
65 char attach_to[V4L2NAMESIZE];
66
67 int num_ioctls;
68 struct v4l2_int_ioctl_desc *ioctls;
69};
70
71struct v4l2_int_device {
72 /* Don't touch head. */
73 struct list_head head;
74
75 struct module *module;
76
77 char name[V4L2NAMESIZE];
78
79 enum v4l2_int_type type;
80 union {
81 struct v4l2_int_master *master;
82 struct v4l2_int_slave *slave;
83 } u;
84
85 void *priv;
86};
87
88int v4l2_int_device_register(struct v4l2_int_device *d);
89void v4l2_int_device_unregister(struct v4l2_int_device *d);
90
91int v4l2_int_ioctl_0(struct v4l2_int_device *d, int cmd);
92int v4l2_int_ioctl_1(struct v4l2_int_device *d, int cmd, void *arg);
93
94/*
95 *
96 * Types and definitions for IOCTL commands.
97 *
98 */
99
100/* Slave interface type. */
101enum v4l2_if_type {
102 /*
103 * Parallel 8-, 10- or 12-bit interface, used by for example
104 * on certain image sensors.
105 */
106 V4L2_IF_TYPE_BT656,
107};
108
109enum v4l2_if_type_bt656_mode {
110 /*
111 * Modes without Bt synchronisation codes. Separate
112 * synchronisation signal lines are used.
113 */
114 V4L2_IF_TYPE_BT656_MODE_NOBT_8BIT,
115 V4L2_IF_TYPE_BT656_MODE_NOBT_10BIT,
116 V4L2_IF_TYPE_BT656_MODE_NOBT_12BIT,
117 /*
118 * Use Bt synchronisation codes. The vertical and horizontal
119 * synchronisation is done based on synchronisation codes.
120 */
121 V4L2_IF_TYPE_BT656_MODE_BT_8BIT,
122 V4L2_IF_TYPE_BT656_MODE_BT_10BIT,
123};
124
125struct v4l2_if_type_bt656 {
126 /*
127 * 0: Frame begins when vsync is high.
128 * 1: Frame begins when vsync changes from low to high.
129 */
130 unsigned frame_start_on_rising_vs:1;
131 /* Use Bt synchronisation codes for sync correction. */
132 unsigned bt_sync_correct:1;
133 /* Swap every two adjacent image data elements. */
134 unsigned swap:1;
135 /* Inverted latch clock polarity from slave. */
136 unsigned latch_clk_inv:1;
137 /* Hs polarity. 0 is active high, 1 active low. */
138 unsigned nobt_hs_inv:1;
139 /* Vs polarity. 0 is active high, 1 active low. */
140 unsigned nobt_vs_inv:1;
141 enum v4l2_if_type_bt656_mode mode;
142 /* Minimum accepted bus clock for slave (in Hz). */
143 u32 clock_min;
144 /* Maximum accepted bus clock for slave. */
145 u32 clock_max;
146 /*
147 * Current wish of the slave. May only change in response to
148 * ioctls that affect image capture.
149 */
150 u32 clock_curr;
151};
152
153struct v4l2_ifparm {
154 enum v4l2_if_type if_type;
155 union {
156 struct v4l2_if_type_bt656 bt656;
157 } u;
158};
159
160/* IOCTL command numbers. */
161enum v4l2_int_ioctl_num {
162 /*
163 *
164 * "Proper" V4L ioctls, as in struct video_device.
165 *
166 */
167 vidioc_int_enum_fmt_cap_num = 1,
168 vidioc_int_g_fmt_cap_num,
169 vidioc_int_s_fmt_cap_num,
170 vidioc_int_try_fmt_cap_num,
171 vidioc_int_queryctrl_num,
172 vidioc_int_g_ctrl_num,
173 vidioc_int_s_ctrl_num,
174 vidioc_int_g_parm_num,
175 vidioc_int_s_parm_num,
176
177 /*
178 *
179 * Strictly internal ioctls.
180 *
181 */
182 /* Initialise the device when slave attaches to the master. */
183 vidioc_int_dev_init_num = 1000,
184 /* Delinitialise the device at slave detach. */
185 vidioc_int_dev_exit_num,
186 /* Set device power state: 0 is off, non-zero is on. */
187 vidioc_int_s_power_num,
188 /* Get slave interface parameters. */
189 vidioc_int_g_ifparm_num,
190 /* Does the slave need to be reset after VIDIOC_DQBUF? */
191 vidioc_int_g_needs_reset_num,
192
193 /*
194 *
195 * VIDIOC_INT_* ioctls.
196 *
197 */
198 /* VIDIOC_INT_RESET */
199 vidioc_int_reset_num,
200 /* VIDIOC_INT_INIT */
201 vidioc_int_init_num,
202 /* VIDIOC_INT_G_CHIP_IDENT */
203 vidioc_int_g_chip_ident_num,
204
205 /*
206 *
207 * Start of private ioctls.
208 *
209 */
210 vidioc_int_priv_start_num = 2000,
211};
212
213/*
214 *
215 * IOCTL wrapper functions for better type checking.
216 *
217 */
218
219#define V4L2_INT_WRAPPER_0(name) \
220 static inline int vidioc_int_##name(struct v4l2_int_device *d) \
221 { \
222 return v4l2_int_ioctl_0(d, vidioc_int_##name##_num); \
223 } \
224 \
225 static inline struct v4l2_int_ioctl_desc \
226 vidioc_int_##name##_cb(int (*func) \
227 (struct v4l2_int_device *)) \
228 { \
229 struct v4l2_int_ioctl_desc desc; \
230 \
231 desc.num = vidioc_int_##name##_num; \
232 desc.func = (v4l2_int_ioctl_func *)func; \
233 \
234 return desc; \
235 }
236
237#define V4L2_INT_WRAPPER_1(name, arg_type, asterisk) \
238 static inline int vidioc_int_##name(struct v4l2_int_device *d, \
239 arg_type asterisk arg) \
240 { \
241 return v4l2_int_ioctl_1(d, vidioc_int_##name##_num, \
242 (void *)(unsigned long)arg); \
243 } \
244 \
245 static inline struct v4l2_int_ioctl_desc \
246 vidioc_int_##name##_cb(int (*func) \
247 (struct v4l2_int_device *, \
248 arg_type asterisk)) \
249 { \
250 struct v4l2_int_ioctl_desc desc; \
251 \
252 desc.num = vidioc_int_##name##_num; \
253 desc.func = (v4l2_int_ioctl_func *)func; \
254 \
255 return desc; \
256 }
257
258V4L2_INT_WRAPPER_1(enum_fmt_cap, struct v4l2_fmtdesc, *);
259V4L2_INT_WRAPPER_1(g_fmt_cap, struct v4l2_format, *);
260V4L2_INT_WRAPPER_1(s_fmt_cap, struct v4l2_format, *);
261V4L2_INT_WRAPPER_1(try_fmt_cap, struct v4l2_format, *);
262V4L2_INT_WRAPPER_1(queryctrl, struct v4l2_queryctrl, *);
263V4L2_INT_WRAPPER_1(g_ctrl, struct v4l2_control, *);
264V4L2_INT_WRAPPER_1(s_ctrl, struct v4l2_control, *);
265V4L2_INT_WRAPPER_1(g_parm, struct v4l2_streamparm, *);
266V4L2_INT_WRAPPER_1(s_parm, struct v4l2_streamparm, *);
267
268V4L2_INT_WRAPPER_0(dev_init);
269V4L2_INT_WRAPPER_0(dev_exit);
270V4L2_INT_WRAPPER_1(s_power, int, );
271V4L2_INT_WRAPPER_1(g_ifparm, struct v4l2_ifparm, *);
272V4L2_INT_WRAPPER_1(g_needs_reset, void, *);
273
274V4L2_INT_WRAPPER_0(reset);
275V4L2_INT_WRAPPER_0(init);
276V4L2_INT_WRAPPER_1(g_chip_ident, int, *);
277
278#endif
diff --git a/include/media/video-buf.h b/include/media/videobuf-core.h
index d6f079476db3..9fa09fb800a1 100644
--- a/include/media/video-buf.h
+++ b/include/media/videobuf-core.h
@@ -1,48 +1,26 @@
1/* 1/*
2 * generic helper functions for handling video4linux capture buffers
2 * 3 *
3 * generic helper functions for video4linux capture buffers, to handle 4 * (c) 2007 Mauro Carvalho Chehab, <mchehab@infradead.org>
4 * memory management and PCI DMA.
5 * Right now, bttv, saa7134, saa7146 and cx88 use it.
6 *
7 * The functions expect the hardware being able to scatter gatter
8 * (i.e. the buffers are not linear in physical memory, but fragmented
9 * into PAGE_SIZE chunks). They also assume the driver does not need
10 * to touch the video data.
11 *
12 * device specific map/unmap/sync stuff now are mapped as file operations
13 * to allow its usage by USB and virtual devices.
14 * 5 *
6 * Highly based on video-buf written originally by:
15 * (c) 2001,02 Gerd Knorr <kraxel@bytesex.org> 7 * (c) 2001,02 Gerd Knorr <kraxel@bytesex.org>
16 * (c) 2006 Mauro Carvalho Chehab, <mchehab@infradead.org> 8 * (c) 2006 Mauro Carvalho Chehab, <mchehab@infradead.org>
17 * (c) 2006 Ted Walther and John Sokol 9 * (c) 2006 Ted Walther and John Sokol
18 * 10 *
19 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by 12 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or 13 * the Free Software Foundation; either version 2
22 * (at your option) any later version.
23 */ 14 */
24 15
25#include <linux/videodev2.h>
26#include <linux/poll.h> 16#include <linux/poll.h>
17#ifdef CONFIG_VIDEO_V4L1_COMPAT
18#include <linux/videodev.h>
19#endif
20#include <linux/videodev2.h>
27 21
28#define UNSET (-1U) 22#define UNSET (-1U)
29 23
30/* --------------------------------------------------------------------- */
31
32/*
33 * Return a scatterlist for some page-aligned vmalloc()'ed memory
34 * block (NULL on errors). Memory for the scatterlist is allocated
35 * using kmalloc. The caller must free the memory.
36 */
37struct scatterlist* videobuf_vmalloc_to_sg(unsigned char *virt, int nr_pages);
38
39/*
40 * Return a scatterlist for a an array of userpages (NULL on errors).
41 * Memory for the scatterlist is allocated using kmalloc. The caller
42 * must free the memory.
43 */
44struct scatterlist* videobuf_pages_to_sg(struct page **pages, int nr_pages,
45 int offset);
46 24
47struct videobuf_buffer; 25struct videobuf_buffer;
48struct videobuf_queue; 26struct videobuf_queue;
@@ -50,69 +28,6 @@ struct videobuf_queue;
50/* --------------------------------------------------------------------- */ 28/* --------------------------------------------------------------------- */
51 29
52/* 30/*
53 * A small set of helper functions to manage buffers (both userland
54 * and kernel) for DMA.
55 *
56 * videobuf_dma_init_*()
57 * creates a buffer. The userland version takes a userspace
58 * pointer + length. The kernel version just wants the size and
59 * does memory allocation too using vmalloc_32().
60 *
61 * videobuf_dma_*()
62 * see Documentation/DMA-mapping.txt, these functions to
63 * basically the same. The map function does also build a
64 * scatterlist for the buffer (and unmap frees it ...)
65 *
66 * videobuf_dma_free()
67 * no comment ...
68 *
69 */
70
71struct videobuf_dmabuf {
72 u32 magic;
73
74 /* for userland buffer */
75 int offset;
76 struct page **pages;
77
78 /* for kernel buffers */
79 void *vmalloc;
80
81 /* Stores the userspace pointer to vmalloc area */
82 void *varea;
83
84 /* for overlay buffers (pci-pci dma) */
85 dma_addr_t bus_addr;
86
87 /* common */
88 struct scatterlist *sglist;
89 int sglen;
90 int nr_pages;
91 int direction;
92};
93
94void videobuf_dma_init(struct videobuf_dmabuf *dma);
95int videobuf_dma_init_user(struct videobuf_dmabuf *dma, int direction,
96 unsigned long data, unsigned long size);
97int videobuf_dma_init_kernel(struct videobuf_dmabuf *dma, int direction,
98 int nr_pages);
99int videobuf_dma_init_overlay(struct videobuf_dmabuf *dma, int direction,
100 dma_addr_t addr, int nr_pages);
101int videobuf_dma_free(struct videobuf_dmabuf *dma);
102
103int videobuf_dma_map(struct videobuf_queue* q,struct videobuf_dmabuf *dma);
104int videobuf_dma_sync(struct videobuf_queue* q,struct videobuf_dmabuf *dma);
105int videobuf_dma_unmap(struct videobuf_queue* q,struct videobuf_dmabuf *dma);
106
107 /*FIXME: these variants are used only on *-alsa code, where videobuf is
108 * used without queue
109 */
110int videobuf_pci_dma_map(struct pci_dev *pci,struct videobuf_dmabuf *dma);
111int videobuf_pci_dma_unmap(struct pci_dev *pci,struct videobuf_dmabuf *dma);
112
113/* --------------------------------------------------------------------- */
114
115/*
116 * A small set of helper functions to manage video4linux buffers. 31 * A small set of helper functions to manage video4linux buffers.
117 * 32 *
118 * struct videobuf_buffer holds the data structures used by the helper 33 * struct videobuf_buffer holds the data structures used by the helper
@@ -162,26 +77,33 @@ struct videobuf_buffer {
162 unsigned int input; 77 unsigned int input;
163 enum v4l2_field field; 78 enum v4l2_field field;
164 enum videobuf_state state; 79 enum videobuf_state state;
165 struct videobuf_dmabuf dma;
166 struct list_head stream; /* QBUF/DQBUF list */ 80 struct list_head stream; /* QBUF/DQBUF list */
167 81
168 /* for mmap'ed buffers */
169 enum v4l2_memory memory;
170 size_t boff; /* buffer offset (mmap + overlay) */
171 size_t bsize; /* buffer size */
172 unsigned long baddr; /* buffer addr (userland ptr!) */
173 struct videobuf_mapping *map;
174
175 /* touched by irq handler */ 82 /* touched by irq handler */
176 struct list_head queue; 83 struct list_head queue;
177 wait_queue_head_t done; 84 wait_queue_head_t done;
178 unsigned int field_count; 85 unsigned int field_count;
179 struct timeval ts; 86 struct timeval ts;
180};
181 87
182typedef int (vb_map_sg_t)(void *dev,struct scatterlist *sglist,int nr_pages, 88 /* Memory type */
183 int direction); 89 enum v4l2_memory memory;
90
91 /* buffer size */
92 size_t bsize;
93
94 /* buffer offset (mmap + overlay) */
95 size_t boff;
184 96
97 /* buffer addr (userland ptr!) */
98 unsigned long baddr;
99
100 /* for mmap'ed buffers */
101 struct videobuf_mapping *map;
102
103 /* Private pointer to allow specific methods to store their data */
104 int privsize;
105 void *priv;
106};
185 107
186struct videobuf_queue_ops { 108struct videobuf_queue_ops {
187 int (*buf_setup)(struct videobuf_queue *q, 109 int (*buf_setup)(struct videobuf_queue *q,
@@ -193,14 +115,37 @@ struct videobuf_queue_ops {
193 struct videobuf_buffer *vb); 115 struct videobuf_buffer *vb);
194 void (*buf_release)(struct videobuf_queue *q, 116 void (*buf_release)(struct videobuf_queue *q,
195 struct videobuf_buffer *vb); 117 struct videobuf_buffer *vb);
118};
196 119
197 /* Helper operations - device dependent. 120#define MAGIC_QTYPE_OPS 0x12261003
198 * If null, videobuf_init defaults all to PCI handling 121
199 */ 122/* Helper operations - device type dependent */
123struct videobuf_qtype_ops {
124 u32 magic;
200 125
201 vb_map_sg_t *vb_map_sg; 126 void* (*alloc) (size_t size);
202 vb_map_sg_t *vb_dma_sync_sg; 127 int (*iolock) (struct videobuf_queue* q,
203 vb_map_sg_t *vb_unmap_sg; 128 struct videobuf_buffer *vb,
129 struct v4l2_framebuffer *fbuf);
130 int (*mmap) (struct videobuf_queue *q,
131 unsigned int *count,
132 unsigned int *size,
133 enum v4l2_memory memory);
134 int (*sync) (struct videobuf_queue* q,
135 struct videobuf_buffer *buf);
136 int (*copy_to_user) (struct videobuf_queue *q,
137 char __user *data,
138 size_t count,
139 int nonblocking);
140 int (*copy_stream) (struct videobuf_queue *q,
141 char __user *data,
142 size_t count,
143 size_t pos,
144 int vbihack,
145 int nonblocking);
146 int (*mmap_free) (struct videobuf_queue *q);
147 int (*mmap_mapper) (struct videobuf_queue *q,
148 struct vm_area_struct *vma);
204}; 149};
205 150
206struct videobuf_queue { 151struct videobuf_queue {
@@ -215,6 +160,7 @@ struct videobuf_queue {
215 enum v4l2_field last; /* for field=V4L2_FIELD_ALTERNATE */ 160 enum v4l2_field last; /* for field=V4L2_FIELD_ALTERNATE */
216 struct videobuf_buffer *bufs[VIDEO_MAX_FRAME]; 161 struct videobuf_buffer *bufs[VIDEO_MAX_FRAME];
217 struct videobuf_queue_ops *ops; 162 struct videobuf_queue_ops *ops;
163 struct videobuf_qtype_ops *int_ops;
218 164
219 /* capture via mmap() + ioctl(QBUF/DQBUF) */ 165 /* capture via mmap() + ioctl(QBUF/DQBUF) */
220 unsigned int streaming; 166 unsigned int streaming;
@@ -229,28 +175,25 @@ struct videobuf_queue {
229 void *priv_data; 175 void *priv_data;
230}; 176};
231 177
232void* videobuf_alloc(unsigned int size);
233int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr); 178int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr);
234int videobuf_iolock(struct videobuf_queue* q, struct videobuf_buffer *vb, 179int videobuf_iolock(struct videobuf_queue* q, struct videobuf_buffer *vb,
235 struct v4l2_framebuffer *fbuf); 180 struct v4l2_framebuffer *fbuf);
236 181
237/* Maps fops to PCI stuff */ 182void *videobuf_alloc(struct videobuf_queue* q);
238void videobuf_queue_pci(struct videobuf_queue* q);
239 183
240void videobuf_queue_init(struct videobuf_queue *q, 184void videobuf_queue_core_init(struct videobuf_queue *q,
241 struct videobuf_queue_ops *ops, 185 struct videobuf_queue_ops *ops,
242 void *dev, 186 void *dev,
243 spinlock_t *irqlock, 187 spinlock_t *irqlock,
244 enum v4l2_buf_type type, 188 enum v4l2_buf_type type,
245 enum v4l2_field field, 189 enum v4l2_field field,
246 unsigned int msize, 190 unsigned int msize,
247 void *priv); 191 void *priv,
192 struct videobuf_qtype_ops *int_ops);
248int videobuf_queue_is_busy(struct videobuf_queue *q); 193int videobuf_queue_is_busy(struct videobuf_queue *q);
249void videobuf_queue_cancel(struct videobuf_queue *q); 194void videobuf_queue_cancel(struct videobuf_queue *q);
250 195
251enum v4l2_field videobuf_next_field(struct videobuf_queue *q); 196enum v4l2_field videobuf_next_field(struct videobuf_queue *q);
252void videobuf_status(struct v4l2_buffer *b, struct videobuf_buffer *vb,
253 enum v4l2_buf_type type);
254int videobuf_reqbufs(struct videobuf_queue *q, 197int videobuf_reqbufs(struct videobuf_queue *q,
255 struct v4l2_requestbuffers *req); 198 struct v4l2_requestbuffers *req);
256int videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b); 199int videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b);
@@ -258,6 +201,10 @@ int videobuf_qbuf(struct videobuf_queue *q,
258 struct v4l2_buffer *b); 201 struct v4l2_buffer *b);
259int videobuf_dqbuf(struct videobuf_queue *q, 202int videobuf_dqbuf(struct videobuf_queue *q,
260 struct v4l2_buffer *b, int nonblocking); 203 struct v4l2_buffer *b, int nonblocking);
204#ifdef CONFIG_VIDEO_V4L1_COMPAT
205int videobuf_cgmbuf(struct videobuf_queue *q,
206 struct video_mbuf *mbuf, int count);
207#endif
261int videobuf_streamon(struct videobuf_queue *q); 208int videobuf_streamon(struct videobuf_queue *q);
262int videobuf_streamoff(struct videobuf_queue *q); 209int videobuf_streamoff(struct videobuf_queue *q);
263 210
diff --git a/include/media/videobuf-dma-sg.h b/include/media/videobuf-dma-sg.h
new file mode 100644
index 000000000000..38105031db23
--- /dev/null
+++ b/include/media/videobuf-dma-sg.h
@@ -0,0 +1,122 @@
1/*
2 * helper functions for PCI DMA video4linux capture buffers
3 *
4 * The functions expect the hardware being able to scatter gatter
5 * (i.e. the buffers are not linear in physical memory, but fragmented
6 * into PAGE_SIZE chunks). They also assume the driver does not need
7 * to touch the video data.
8 *
9 * (c) 2007 Mauro Carvalho Chehab, <mchehab@infradead.org>
10 *
11 * Highly based on video-buf written originally by:
12 * (c) 2001,02 Gerd Knorr <kraxel@bytesex.org>
13 * (c) 2006 Mauro Carvalho Chehab, <mchehab@infradead.org>
14 * (c) 2006 Ted Walther and John Sokol
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2
19 */
20
21#include <media/videobuf-core.h>
22
23/* --------------------------------------------------------------------- */
24
25/*
26 * Return a scatterlist for some page-aligned vmalloc()'ed memory
27 * block (NULL on errors). Memory for the scatterlist is allocated
28 * using kmalloc. The caller must free the memory.
29 */
30struct scatterlist* videobuf_vmalloc_to_sg(unsigned char *virt, int nr_pages);
31
32/*
33 * Return a scatterlist for a an array of userpages (NULL on errors).
34 * Memory for the scatterlist is allocated using kmalloc. The caller
35 * must free the memory.
36 */
37struct scatterlist* videobuf_pages_to_sg(struct page **pages, int nr_pages,
38 int offset);
39
40/* --------------------------------------------------------------------- */
41
42/*
43 * A small set of helper functions to manage buffers (both userland
44 * and kernel) for DMA.
45 *
46 * videobuf_dma_init_*()
47 * creates a buffer. The userland version takes a userspace
48 * pointer + length. The kernel version just wants the size and
49 * does memory allocation too using vmalloc_32().
50 *
51 * videobuf_dma_*()
52 * see Documentation/DMA-mapping.txt, these functions to
53 * basically the same. The map function does also build a
54 * scatterlist for the buffer (and unmap frees it ...)
55 *
56 * videobuf_dma_free()
57 * no comment ...
58 *
59 */
60
61struct videobuf_dmabuf {
62 u32 magic;
63
64 /* for userland buffer */
65 int offset;
66 struct page **pages;
67
68 /* for kernel buffers */
69 void *vmalloc;
70
71 /* Stores the userspace pointer to vmalloc area */
72 void *varea;
73
74 /* for overlay buffers (pci-pci dma) */
75 dma_addr_t bus_addr;
76
77 /* common */
78 struct scatterlist *sglist;
79 int sglen;
80 int nr_pages;
81 int direction;
82};
83
84struct videbuf_pci_sg_memory
85{
86 u32 magic;
87
88 /* for mmap'ed buffers */
89 struct videobuf_dmabuf dma;
90};
91
92void videobuf_dma_init(struct videobuf_dmabuf *dma);
93int videobuf_dma_init_user(struct videobuf_dmabuf *dma, int direction,
94 unsigned long data, unsigned long size);
95int videobuf_dma_init_kernel(struct videobuf_dmabuf *dma, int direction,
96 int nr_pages);
97int videobuf_dma_init_overlay(struct videobuf_dmabuf *dma, int direction,
98 dma_addr_t addr, int nr_pages);
99int videobuf_dma_free(struct videobuf_dmabuf *dma);
100
101int videobuf_dma_map(struct videobuf_queue* q,struct videobuf_dmabuf *dma);
102int videobuf_dma_sync(struct videobuf_queue* q,struct videobuf_dmabuf *dma);
103int videobuf_dma_unmap(struct videobuf_queue* q,struct videobuf_dmabuf *dma);
104struct videobuf_dmabuf *videobuf_to_dma (struct videobuf_buffer *buf);
105
106void *videobuf_pci_alloc (size_t size);
107
108void videobuf_queue_pci_init(struct videobuf_queue* q,
109 struct videobuf_queue_ops *ops,
110 void *dev,
111 spinlock_t *irqlock,
112 enum v4l2_buf_type type,
113 enum v4l2_field field,
114 unsigned int msize,
115 void *priv);
116
117 /*FIXME: these variants are used only on *-alsa code, where videobuf is
118 * used without queue
119 */
120int videobuf_pci_dma_map(struct pci_dev *pci,struct videobuf_dmabuf *dma);
121int videobuf_pci_dma_unmap(struct pci_dev *pci,struct videobuf_dmabuf *dma);
122
diff --git a/include/media/video-buf-dvb.h b/include/media/videobuf-dvb.h
index 8233cafdeef6..8233cafdeef6 100644
--- a/include/media/video-buf-dvb.h
+++ b/include/media/videobuf-dvb.h
diff --git a/include/media/videobuf-vmalloc.h b/include/media/videobuf-vmalloc.h
new file mode 100644
index 000000000000..26a8958d23d1
--- /dev/null
+++ b/include/media/videobuf-vmalloc.h
@@ -0,0 +1,41 @@
1/*
2 * helper functions for vmalloc capture buffers
3 *
4 * The functions expect the hardware being able to scatter gatter
5 * (i.e. the buffers are not linear in physical memory, but fragmented
6 * into PAGE_SIZE chunks). They also assume the driver does not need
7 * to touch the video data.
8 *
9 * (c) 2007 Mauro Carvalho Chehab, <mchehab@infradead.org>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2
14 */
15
16#include <media/videobuf-core.h>
17
18/* --------------------------------------------------------------------- */
19
20struct videbuf_vmalloc_memory
21{
22 u32 magic;
23
24 void *vmalloc;
25
26 /* remap_vmalloc_range seems to need to run after mmap() on some cases */
27 struct vm_area_struct *vma;
28};
29
30void videobuf_queue_vmalloc_init(struct videobuf_queue* q,
31 struct videobuf_queue_ops *ops,
32 void *dev,
33 spinlock_t *irqlock,
34 enum v4l2_buf_type type,
35 enum v4l2_field field,
36 unsigned int msize,
37 void *priv);
38
39void *videobuf_to_vmalloc (struct videobuf_buffer *buf);
40
41void videobuf_vmalloc_free (struct videobuf_buffer *buf);