aboutsummaryrefslogtreecommitdiffstats
path: root/include/media
diff options
context:
space:
mode:
Diffstat (limited to 'include/media')
-rw-r--r--include/media/bt819.h5
-rw-r--r--include/media/cx2341x.h2
-rw-r--r--include/media/davinci/dm355_ccdc.h2
-rw-r--r--include/media/davinci/isif.h2
-rw-r--r--include/media/davinci/vpss.h2
-rw-r--r--include/media/ir-common.h107
-rw-r--r--include/media/ir-core.h185
-rw-r--r--include/media/ir-kbd-i2c.h21
-rw-r--r--include/media/lirc.h2
-rw-r--r--include/media/lirc_dev.h14
-rw-r--r--include/media/m5mols.h35
-rw-r--r--include/media/media-device.h95
-rw-r--r--include/media/media-devnode.h97
-rw-r--r--include/media/media-entity.h151
-rw-r--r--include/media/mt9v011.h17
-rw-r--r--include/media/mt9v032.h12
-rw-r--r--include/media/noon010pc30.h28
-rw-r--r--include/media/omap1_camera.h35
-rw-r--r--include/media/ovcamchip.h90
-rw-r--r--include/media/rc-core.h226
-rw-r--r--include/media/rc-map.h68
-rw-r--r--include/media/s5p_fimc.h61
-rw-r--r--include/media/saa6588.h (renamed from include/media/rds.h)18
-rw-r--r--include/media/saa7146.h4
-rw-r--r--include/media/sh_vou.h1
-rw-r--r--include/media/si4713.h3
-rw-r--r--include/media/soc_camera.h53
-rw-r--r--include/media/soc_camera_platform.h50
-rw-r--r--include/media/soc_mediabus.h27
-rw-r--r--include/media/sr030pc30.h21
-rw-r--r--include/media/timb_radio.h1
-rw-r--r--include/media/timb_video.h33
-rw-r--r--include/media/tuner.h16
-rw-r--r--include/media/v4l2-chip-ident.h13
-rw-r--r--include/media/v4l2-common.h54
-rw-r--r--include/media/v4l2-ctrls.h11
-rw-r--r--include/media/v4l2-dev.h48
-rw-r--r--include/media/v4l2-device.h83
-rw-r--r--include/media/v4l2-fh.h29
-rw-r--r--include/media/v4l2-i2c-drv.h80
-rw-r--r--include/media/v4l2-ioctl.h40
-rw-r--r--include/media/v4l2-mediabus.h53
-rw-r--r--include/media/v4l2-mem2mem.h58
-rw-r--r--include/media/v4l2-subdev.h162
-rw-r--r--include/media/videobuf-core.h27
-rw-r--r--include/media/videobuf-dma-contig.h3
-rw-r--r--include/media/videobuf-dma-sg.h3
-rw-r--r--include/media/videobuf-dvb.h4
-rw-r--r--include/media/videobuf-vmalloc.h3
-rw-r--r--include/media/videobuf2-core.h380
-rw-r--r--include/media/videobuf2-dma-contig.h32
-rw-r--r--include/media/videobuf2-dma-sg.h32
-rw-r--r--include/media/videobuf2-memops.h45
-rw-r--r--include/media/videobuf2-vmalloc.h20
-rw-r--r--include/media/wm8775.h9
55 files changed, 1930 insertions, 743 deletions
diff --git a/include/media/bt819.h b/include/media/bt819.h
index 38f666bde77a..8025f4bc2bb6 100644
--- a/include/media/bt819.h
+++ b/include/media/bt819.h
@@ -26,7 +26,10 @@
26/* v4l2_device notifications. */ 26/* v4l2_device notifications. */
27 27
28/* Needed to reset the FIFO buffer when changing the input 28/* Needed to reset the FIFO buffer when changing the input
29 or the video standard. */ 29 or the video standard.
30
31 Note: these ioctls that internal to the kernel and are never called
32 from userspace. */
30#define BT819_FIFO_RESET_LOW _IO('b', 0) 33#define BT819_FIFO_RESET_LOW _IO('b', 0)
31#define BT819_FIFO_RESET_HIGH _IO('b', 1) 34#define BT819_FIFO_RESET_HIGH _IO('b', 1)
32 35
diff --git a/include/media/cx2341x.h b/include/media/cx2341x.h
index 8d08ebfe20b7..9635eebaab09 100644
--- a/include/media/cx2341x.h
+++ b/include/media/cx2341x.h
@@ -95,7 +95,7 @@ int cx2341x_update(void *priv, cx2341x_mbox_func func,
95 const struct cx2341x_mpeg_params *new); 95 const struct cx2341x_mpeg_params *new);
96int cx2341x_ctrl_query(const struct cx2341x_mpeg_params *params, 96int cx2341x_ctrl_query(const struct cx2341x_mpeg_params *params,
97 struct v4l2_queryctrl *qctrl); 97 struct v4l2_queryctrl *qctrl);
98const char **cx2341x_ctrl_get_menu(const struct cx2341x_mpeg_params *p, u32 id); 98const char * const *cx2341x_ctrl_get_menu(const struct cx2341x_mpeg_params *p, u32 id);
99int cx2341x_ext_ctrls(struct cx2341x_mpeg_params *params, int busy, 99int cx2341x_ext_ctrls(struct cx2341x_mpeg_params *params, int busy,
100 struct v4l2_ext_controls *ctrls, unsigned int cmd); 100 struct v4l2_ext_controls *ctrls, unsigned int cmd);
101void cx2341x_fill_defaults(struct cx2341x_mpeg_params *p); 101void cx2341x_fill_defaults(struct cx2341x_mpeg_params *p);
diff --git a/include/media/davinci/dm355_ccdc.h b/include/media/davinci/dm355_ccdc.h
index df8a7b107477..adf2fe4bf0bb 100644
--- a/include/media/davinci/dm355_ccdc.h
+++ b/include/media/davinci/dm355_ccdc.h
@@ -193,7 +193,7 @@ struct ccdc_dft_corr_mem_ctl {
193#define CCDC_DFT_TABLE_SIZE 16 193#define CCDC_DFT_TABLE_SIZE 16
194/* 194/*
195 * Main Structure for vertical defect correction. Vertical defect 195 * Main Structure for vertical defect correction. Vertical defect
196 * correction can correct upto 16 defects if defects less than 16 196 * correction can correct up to 16 defects if defects less than 16
197 * then pad the rest with 0 197 * then pad the rest with 0
198 */ 198 */
199struct ccdc_vertical_dft { 199struct ccdc_vertical_dft {
diff --git a/include/media/davinci/isif.h b/include/media/davinci/isif.h
index b0b74ad618cc..7f3d76a4b9e3 100644
--- a/include/media/davinci/isif.h
+++ b/include/media/davinci/isif.h
@@ -199,7 +199,7 @@ struct isif_black_clamp {
199}; 199};
200 200
201/************************************************************************* 201/*************************************************************************
202** Color Space Convertion (CSC) 202** Color Space Conversion (CSC)
203*************************************************************************/ 203*************************************************************************/
204#define ISIF_CSC_NUM_COEFF 16 204#define ISIF_CSC_NUM_COEFF 16
205struct isif_color_space_conv { 205struct isif_color_space_conv {
diff --git a/include/media/davinci/vpss.h b/include/media/davinci/vpss.h
index c59cc029c74a..b586495bcd53 100644
--- a/include/media/davinci/vpss.h
+++ b/include/media/davinci/vpss.h
@@ -44,7 +44,7 @@ struct vpss_pg_frame_size {
44 short pplen; 44 short pplen;
45}; 45};
46 46
47/* Used for enable/diable VPSS Clock */ 47/* Used for enable/disable VPSS Clock */
48enum vpss_clock_sel { 48enum vpss_clock_sel {
49 /* DM355/DM365 */ 49 /* DM355/DM365 */
50 VPSS_CCDC_CLOCK, 50 VPSS_CCDC_CLOCK,
diff --git a/include/media/ir-common.h b/include/media/ir-common.h
deleted file mode 100644
index 528050e39ad9..000000000000
--- a/include/media/ir-common.h
+++ /dev/null
@@ -1,107 +0,0 @@
1/*
2 *
3 * some common structs and functions to handle infrared remotes via
4 * input layer ...
5 *
6 * (c) 2003 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#ifndef _IR_COMMON
24#define _IR_COMMON
25
26#include <linux/input.h>
27#include <linux/workqueue.h>
28#include <linux/interrupt.h>
29#include <media/ir-core.h>
30
31#define RC5_START(x) (((x)>>12)&3)
32#define RC5_TOGGLE(x) (((x)>>11)&1)
33#define RC5_ADDR(x) (((x)>>6)&31)
34#define RC5_INSTR(x) ((x)&63)
35
36struct ir_input_state {
37 /* configuration */
38 u64 ir_type;
39
40 /* key info */
41 u32 ir_key; /* ir scancode */
42 u32 keycode; /* linux key code */
43 int keypressed; /* current state */
44};
45
46/* this was saa7134_ir and bttv_ir, moved here for
47 * rc5 decoding. */
48struct card_ir {
49 struct input_dev *dev;
50 struct ir_input_state ir;
51 char name[32];
52 char phys[32];
53 int users;
54
55 u32 running:1;
56 struct ir_dev_props props;
57
58 /* Usual gpio signalling */
59
60 u32 mask_keycode;
61 u32 mask_keydown;
62 u32 mask_keyup;
63 u32 polling;
64 u32 last_gpio;
65 int shift_by;
66 int start; // What should RC5_START() be
67 int addr; // What RC5_ADDR() should be.
68 int rc5_key_timeout;
69 int rc5_remote_gap;
70 struct work_struct work;
71 struct timer_list timer;
72
73 /* RC5 gpio */
74 u32 rc5_gpio;
75 struct timer_list timer_end; /* timer_end for code completion */
76 struct timer_list timer_keyup; /* timer_end for key release */
77 u32 last_rc5; /* last good rc5 code */
78 u32 last_bit; /* last raw bit seen */
79 u32 code; /* raw code under construction */
80 struct timeval base_time; /* time of last seen code */
81 int active; /* building raw code */
82
83 /* NEC decoding */
84 u32 nec_gpio;
85 struct tasklet_struct tlet;
86
87 /* IR core raw decoding */
88 u32 raw_decode;
89};
90
91/* Routines from ir-functions.c */
92
93int ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
94 const u64 ir_type);
95void ir_input_nokey(struct input_dev *dev, struct ir_input_state *ir);
96void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir,
97 u32 ir_key);
98u32 ir_extract_bits(u32 data, u32 mask);
99int ir_dump_samples(u32 *samples, int count);
100int ir_decode_biphase(u32 *samples, int count, int low, int high);
101int ir_decode_pulsedistance(u32 *samples, int count, int low, int high);
102u32 ir_rc5_decode(unsigned int code);
103
104void ir_rc5_timer_end(unsigned long data);
105void ir_rc5_timer_keyup(unsigned long data);
106
107#endif
diff --git a/include/media/ir-core.h b/include/media/ir-core.h
deleted file mode 100644
index eb7fddf8f607..000000000000
--- a/include/media/ir-core.h
+++ /dev/null
@@ -1,185 +0,0 @@
1/*
2 * Remote Controller core header
3 *
4 * Copyright (C) 2009-2010 by Mauro Carvalho Chehab <mchehab@redhat.com>
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 version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#ifndef _IR_CORE
17#define _IR_CORE
18
19#include <linux/spinlock.h>
20#include <linux/kfifo.h>
21#include <linux/time.h>
22#include <linux/timer.h>
23#include <media/rc-map.h>
24
25extern int ir_core_debug;
26#define IR_dprintk(level, fmt, arg...) if (ir_core_debug >= level) \
27 printk(KERN_DEBUG "%s: " fmt , __func__, ## arg)
28
29enum rc_driver_type {
30 RC_DRIVER_SCANCODE = 0, /* Driver or hardware generates a scancode */
31 RC_DRIVER_IR_RAW, /* Needs a Infra-Red pulse/space decoder */
32};
33
34/**
35 * struct ir_dev_props - Allow caller drivers to set special properties
36 * @driver_type: specifies if the driver or hardware have already a decoder,
37 * or if it needs to use the IR raw event decoders to produce a scancode
38 * @allowed_protos: bitmask with the supported IR_TYPE_* protocols
39 * @scanmask: some hardware decoders are not capable of providing the full
40 * scancode to the application. As this is a hardware limit, we can't do
41 * anything with it. Yet, as the same keycode table can be used with other
42 * devices, a mask is provided to allow its usage. Drivers should generally
43 * leave this field in blank
44 * @timeout: optional time after which device stops sending data
45 * @min_timeout: minimum timeout supported by device
46 * @max_timeout: maximum timeout supported by device
47 * @rx_resolution : resolution (in ns) of input sampler
48 * @tx_resolution: resolution (in ns) of output sampler
49 * @priv: driver-specific data, to be used on the callbacks
50 * @change_protocol: allow changing the protocol used on hardware decoders
51 * @open: callback to allow drivers to enable polling/irq when IR input device
52 * is opened.
53 * @close: callback to allow drivers to disable polling/irq when IR input device
54 * is opened.
55 * @s_tx_mask: set transmitter mask (for devices with multiple tx outputs)
56 * @s_tx_carrier: set transmit carrier frequency
57 * @s_tx_duty_cycle: set transmit duty cycle (0% - 100%)
58 * @s_rx_carrier: inform driver about carrier it is expected to handle
59 * @tx_ir: transmit IR
60 * @s_idle: optional: enable/disable hardware idle mode, upon which,
61 device doesn't interrupt host until it sees IR pulses
62 * @s_learning_mode: enable wide band receiver used for learning
63 */
64struct ir_dev_props {
65 enum rc_driver_type driver_type;
66 unsigned long allowed_protos;
67 u32 scanmask;
68
69 u32 timeout;
70 u32 min_timeout;
71 u32 max_timeout;
72
73 u32 rx_resolution;
74 u32 tx_resolution;
75
76 void *priv;
77 int (*change_protocol)(void *priv, u64 ir_type);
78 int (*open)(void *priv);
79 void (*close)(void *priv);
80 int (*s_tx_mask)(void *priv, u32 mask);
81 int (*s_tx_carrier)(void *priv, u32 carrier);
82 int (*s_tx_duty_cycle)(void *priv, u32 duty_cycle);
83 int (*s_rx_carrier_range)(void *priv, u32 min, u32 max);
84 int (*tx_ir)(void *priv, int *txbuf, u32 n);
85 void (*s_idle)(void *priv, int enable);
86 int (*s_learning_mode)(void *priv, int enable);
87};
88
89struct ir_input_dev {
90 struct device dev; /* device */
91 char *driver_name; /* Name of the driver module */
92 struct ir_scancode_table rc_tab; /* scan/key table */
93 unsigned long devno; /* device number */
94 struct ir_dev_props *props; /* Device properties */
95 struct ir_raw_event_ctrl *raw; /* for raw pulse/space events */
96 struct input_dev *input_dev; /* the input device associated with this device */
97 bool idle;
98
99 /* key info - needed by IR keycode handlers */
100 spinlock_t keylock; /* protects the below members */
101 bool keypressed; /* current state */
102 unsigned long keyup_jiffies; /* when should the current keypress be released? */
103 struct timer_list timer_keyup; /* timer for releasing a keypress */
104 u32 last_keycode; /* keycode of last command */
105 u32 last_scancode; /* scancode of last command */
106 u8 last_toggle; /* toggle of last command */
107};
108
109enum raw_event_type {
110 IR_SPACE = (1 << 0),
111 IR_PULSE = (1 << 1),
112 IR_START_EVENT = (1 << 2),
113 IR_STOP_EVENT = (1 << 3),
114};
115
116#define to_ir_input_dev(_attr) container_of(_attr, struct ir_input_dev, attr)
117
118/* From ir-keytable.c */
119int __ir_input_register(struct input_dev *dev,
120 const struct ir_scancode_table *ir_codes,
121 struct ir_dev_props *props,
122 const char *driver_name);
123
124static inline int ir_input_register(struct input_dev *dev,
125 const char *map_name,
126 struct ir_dev_props *props,
127 const char *driver_name) {
128 struct ir_scancode_table *ir_codes;
129 struct ir_input_dev *ir_dev;
130 int rc;
131
132 if (!map_name)
133 return -EINVAL;
134
135 ir_codes = get_rc_map(map_name);
136 if (!ir_codes) {
137 ir_codes = get_rc_map(RC_MAP_EMPTY);
138
139 if (!ir_codes)
140 return -EINVAL;
141 }
142
143 rc = __ir_input_register(dev, ir_codes, props, driver_name);
144 if (rc < 0)
145 return -EINVAL;
146
147 ir_dev = input_get_drvdata(dev);
148
149 if (!rc && ir_dev->props && ir_dev->props->change_protocol)
150 rc = ir_dev->props->change_protocol(ir_dev->props->priv,
151 ir_codes->ir_type);
152
153 return rc;
154}
155
156void ir_input_unregister(struct input_dev *input_dev);
157
158void ir_repeat(struct input_dev *dev);
159void ir_keydown(struct input_dev *dev, int scancode, u8 toggle);
160u32 ir_g_keycode_from_table(struct input_dev *input_dev, u32 scancode);
161
162/* From ir-raw-event.c */
163
164struct ir_raw_event {
165 unsigned pulse:1;
166 unsigned duration:31;
167};
168
169#define IR_MAX_DURATION 0x7FFFFFFF /* a bit more than 2 seconds */
170
171void ir_raw_event_handle(struct input_dev *input_dev);
172int ir_raw_event_store(struct input_dev *input_dev, struct ir_raw_event *ev);
173int ir_raw_event_store_edge(struct input_dev *input_dev, enum raw_event_type type);
174int ir_raw_event_store_with_filter(struct input_dev *input_dev,
175 struct ir_raw_event *ev);
176void ir_raw_event_set_idle(struct input_dev *input_dev, int idle);
177
178static inline void ir_raw_event_reset(struct input_dev *input_dev)
179{
180 struct ir_raw_event ev = { .pulse = false, .duration = 0 };
181 ir_raw_event_store(input_dev, &ev);
182 ir_raw_event_handle(input_dev);
183}
184
185#endif /* _IR_CORE */
diff --git a/include/media/ir-kbd-i2c.h b/include/media/ir-kbd-i2c.h
index 5e96d7a430be..768aa77925cd 100644
--- a/include/media/ir-kbd-i2c.h
+++ b/include/media/ir-kbd-i2c.h
@@ -1,20 +1,22 @@
1#ifndef _IR_I2C 1#ifndef _IR_I2C
2#define _IR_I2C 2#define _IR_I2C
3 3
4#include <media/ir-common.h> 4#include <media/rc-core.h>
5
6#define DEFAULT_POLLING_INTERVAL 100 /* ms */
5 7
6struct IR_i2c; 8struct IR_i2c;
7 9
8struct IR_i2c { 10struct IR_i2c {
9 char *ir_codes; 11 char *ir_codes;
10
11 struct i2c_client *c; 12 struct i2c_client *c;
12 struct input_dev *input; 13 struct rc_dev *rc;
13 struct ir_input_state ir; 14
14 u64 ir_type;
15 /* Used to avoid fast repeating */ 15 /* Used to avoid fast repeating */
16 unsigned char old; 16 unsigned char old;
17 17
18 u32 polling_interval; /* in ms */
19
18 struct delayed_work work; 20 struct delayed_work work;
19 char name[32]; 21 char name[32];
20 char phys[32]; 22 char phys[32];
@@ -24,7 +26,6 @@ struct IR_i2c {
24enum ir_kbd_get_key_fn { 26enum ir_kbd_get_key_fn {
25 IR_KBD_GET_KEY_CUSTOM = 0, 27 IR_KBD_GET_KEY_CUSTOM = 0,
26 IR_KBD_GET_KEY_PIXELVIEW, 28 IR_KBD_GET_KEY_PIXELVIEW,
27 IR_KBD_GET_KEY_PV951,
28 IR_KBD_GET_KEY_HAUP, 29 IR_KBD_GET_KEY_HAUP,
29 IR_KBD_GET_KEY_KNC1, 30 IR_KBD_GET_KEY_KNC1,
30 IR_KBD_GET_KEY_FUSIONHDTV, 31 IR_KBD_GET_KEY_FUSIONHDTV,
@@ -35,13 +36,17 @@ enum ir_kbd_get_key_fn {
35/* Can be passed when instantiating an ir_video i2c device */ 36/* Can be passed when instantiating an ir_video i2c device */
36struct IR_i2c_init_data { 37struct IR_i2c_init_data {
37 char *ir_codes; 38 char *ir_codes;
38 const char *name; 39 const char *name;
39 u64 type; /* IR_TYPE_RC5, etc */ 40 u64 type; /* RC_TYPE_RC5, etc */
41 u32 polling_interval; /* 0 means DEFAULT_POLLING_INTERVAL */
42
40 /* 43 /*
41 * Specify either a function pointer or a value indicating one of 44 * Specify either a function pointer or a value indicating one of
42 * ir_kbd_i2c's internal get_key functions 45 * ir_kbd_i2c's internal get_key functions
43 */ 46 */
44 int (*get_key)(struct IR_i2c*, u32*, u32*); 47 int (*get_key)(struct IR_i2c*, u32*, u32*);
45 enum ir_kbd_get_key_fn internal_get_key_func; 48 enum ir_kbd_get_key_fn internal_get_key_func;
49
50 struct rc_dev *rc_dev;
46}; 51};
47#endif 52#endif
diff --git a/include/media/lirc.h b/include/media/lirc.h
index 6678a169fd9e..4b3ab2966b5a 100644
--- a/include/media/lirc.h
+++ b/include/media/lirc.h
@@ -137,7 +137,7 @@
137 */ 137 */
138#define LIRC_SET_REC_FILTER_SPACE _IOW('i', 0x0000001b, __u32) 138#define LIRC_SET_REC_FILTER_SPACE _IOW('i', 0x0000001b, __u32)
139/* 139/*
140 * if filter cannot be set independantly for pulse/space, this should 140 * if filter cannot be set independently for pulse/space, this should
141 * be used 141 * be used
142 */ 142 */
143#define LIRC_SET_REC_FILTER _IOW('i', 0x0000001c, __u32) 143#define LIRC_SET_REC_FILTER _IOW('i', 0x0000001c, __u32)
diff --git a/include/media/lirc_dev.h b/include/media/lirc_dev.h
index b1f60663cb39..168dd0b1bae2 100644
--- a/include/media/lirc_dev.h
+++ b/include/media/lirc_dev.h
@@ -9,7 +9,7 @@
9#ifndef _LINUX_LIRC_DEV_H 9#ifndef _LINUX_LIRC_DEV_H
10#define _LINUX_LIRC_DEV_H 10#define _LINUX_LIRC_DEV_H
11 11
12#define MAX_IRCTL_DEVICES 4 12#define MAX_IRCTL_DEVICES 8
13#define BUFLEN 16 13#define BUFLEN 16
14 14
15#define mod(n, div) ((n) % (div)) 15#define mod(n, div) ((n) % (div))
@@ -125,10 +125,10 @@ static inline unsigned int lirc_buffer_write(struct lirc_buffer *buf,
125struct lirc_driver { 125struct lirc_driver {
126 char name[40]; 126 char name[40];
127 int minor; 127 int minor;
128 unsigned long code_length; 128 __u32 code_length;
129 unsigned int buffer_size; /* in chunks holding one code each */ 129 unsigned int buffer_size; /* in chunks holding one code each */
130 int sample_rate; 130 int sample_rate;
131 unsigned long features; 131 __u32 features;
132 132
133 unsigned int chunk_size; 133 unsigned int chunk_size;
134 134
@@ -139,7 +139,7 @@ struct lirc_driver {
139 struct lirc_buffer *rbuf; 139 struct lirc_buffer *rbuf;
140 int (*set_use_inc) (void *data); 140 int (*set_use_inc) (void *data);
141 void (*set_use_dec) (void *data); 141 void (*set_use_dec) (void *data);
142 struct file_operations *fops; 142 const struct file_operations *fops;
143 struct device *dev; 143 struct device *dev;
144 struct module *owner; 144 struct module *owner;
145}; 145};
@@ -217,9 +217,9 @@ int lirc_dev_fop_open(struct inode *inode, struct file *file);
217int lirc_dev_fop_close(struct inode *inode, struct file *file); 217int lirc_dev_fop_close(struct inode *inode, struct file *file);
218unsigned int lirc_dev_fop_poll(struct file *file, poll_table *wait); 218unsigned int lirc_dev_fop_poll(struct file *file, poll_table *wait);
219long lirc_dev_fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg); 219long lirc_dev_fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
220ssize_t lirc_dev_fop_read(struct file *file, char *buffer, size_t length, 220ssize_t lirc_dev_fop_read(struct file *file, char __user *buffer, size_t length,
221 loff_t *ppos); 221 loff_t *ppos);
222ssize_t lirc_dev_fop_write(struct file *file, const char *buffer, size_t length, 222ssize_t lirc_dev_fop_write(struct file *file, const char __user *buffer,
223 loff_t *ppos); 223 size_t length, loff_t *ppos);
224 224
225#endif 225#endif
diff --git a/include/media/m5mols.h b/include/media/m5mols.h
new file mode 100644
index 000000000000..aac2c0e06d5e
--- /dev/null
+++ b/include/media/m5mols.h
@@ -0,0 +1,35 @@
1/*
2 * Driver header for M-5MOLS 8M Pixel camera sensor with ISP
3 *
4 * Copyright (C) 2011 Samsung Electronics Co., Ltd.
5 * Author: HeungJun Kim <riverful.kim@samsung.com>
6 *
7 * Copyright (C) 2009 Samsung Electronics Co., Ltd.
8 * Author: Dongsoo Nathaniel Kim <dongsoo45.kim@samsung.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 */
15
16#ifndef MEDIA_M5MOLS_H
17#define MEDIA_M5MOLS_H
18
19/**
20 * struct m5mols_platform_data - platform data for M-5MOLS driver
21 * @irq: GPIO getting the irq pin of M-5MOLS
22 * @gpio_reset: GPIO driving the reset pin of M-5MOLS
23 * @reset_polarity: active state for gpio_rst pin, 0 or 1
24 * @set_power: an additional callback to the board setup code
25 * to be called after enabling and before disabling
26 * the sensor's supply regulators
27 */
28struct m5mols_platform_data {
29 int irq;
30 int gpio_reset;
31 u8 reset_polarity;
32 int (*set_power)(struct device *dev, int on);
33};
34
35#endif /* MEDIA_M5MOLS_H */
diff --git a/include/media/media-device.h b/include/media/media-device.h
new file mode 100644
index 000000000000..6a27d916c250
--- /dev/null
+++ b/include/media/media-device.h
@@ -0,0 +1,95 @@
1/*
2 * Media device
3 *
4 * Copyright (C) 2010 Nokia Corporation
5 *
6 * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
7 * Sakari Ailus <sakari.ailus@iki.fi>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#ifndef _MEDIA_DEVICE_H
24#define _MEDIA_DEVICE_H
25
26#include <linux/device.h>
27#include <linux/list.h>
28#include <linux/mutex.h>
29#include <linux/spinlock.h>
30
31#include <media/media-devnode.h>
32#include <media/media-entity.h>
33
34/**
35 * struct media_device - Media device
36 * @dev: Parent device
37 * @devnode: Media device node
38 * @model: Device model name
39 * @serial: Device serial number (optional)
40 * @bus_info: Unique and stable device location identifier
41 * @hw_revision: Hardware device revision
42 * @driver_version: Device driver version
43 * @entity_id: ID of the next entity to be registered
44 * @entities: List of registered entities
45 * @lock: Entities list lock
46 * @graph_mutex: Entities graph operation lock
47 *
48 * This structure represents an abstract high-level media device. It allows easy
49 * access to entities and provides basic media device-level support. The
50 * structure can be allocated directly or embedded in a larger structure.
51 *
52 * The parent @dev is a physical device. It must be set before registering the
53 * media device.
54 *
55 * @model is a descriptive model name exported through sysfs. It doesn't have to
56 * be unique.
57 */
58struct media_device {
59 /* dev->driver_data points to this struct. */
60 struct device *dev;
61 struct media_devnode devnode;
62
63 char model[32];
64 char serial[40];
65 char bus_info[32];
66 u32 hw_revision;
67 u32 driver_version;
68
69 u32 entity_id;
70 struct list_head entities;
71
72 /* Protects the entities list */
73 spinlock_t lock;
74 /* Serializes graph operations. */
75 struct mutex graph_mutex;
76
77 int (*link_notify)(struct media_pad *source,
78 struct media_pad *sink, u32 flags);
79};
80
81/* media_devnode to media_device */
82#define to_media_device(node) container_of(node, struct media_device, devnode)
83
84int __must_check media_device_register(struct media_device *mdev);
85void media_device_unregister(struct media_device *mdev);
86
87int __must_check media_device_register_entity(struct media_device *mdev,
88 struct media_entity *entity);
89void media_device_unregister_entity(struct media_entity *entity);
90
91/* Iterate over all entities. */
92#define media_device_for_each_entity(entity, mdev) \
93 list_for_each_entry(entity, &(mdev)->entities, list)
94
95#endif
diff --git a/include/media/media-devnode.h b/include/media/media-devnode.h
new file mode 100644
index 000000000000..f6caafc874cb
--- /dev/null
+++ b/include/media/media-devnode.h
@@ -0,0 +1,97 @@
1/*
2 * Media device node
3 *
4 * Copyright (C) 2010 Nokia Corporation
5 *
6 * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
7 * Sakari Ailus <sakari.ailus@iki.fi>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 * --
23 *
24 * Common functions for media-related drivers to register and unregister media
25 * device nodes.
26 */
27
28#ifndef _MEDIA_DEVNODE_H
29#define _MEDIA_DEVNODE_H
30
31#include <linux/poll.h>
32#include <linux/fs.h>
33#include <linux/device.h>
34#include <linux/cdev.h>
35
36/*
37 * Flag to mark the media_devnode struct as registered. Drivers must not touch
38 * this flag directly, it will be set and cleared by media_devnode_register and
39 * media_devnode_unregister.
40 */
41#define MEDIA_FLAG_REGISTERED 0
42
43struct media_file_operations {
44 struct module *owner;
45 ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
46 ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
47 unsigned int (*poll) (struct file *, struct poll_table_struct *);
48 long (*ioctl) (struct file *, unsigned int, unsigned long);
49 int (*open) (struct file *);
50 int (*release) (struct file *);
51};
52
53/**
54 * struct media_devnode - Media device node
55 * @parent: parent device
56 * @minor: device node minor number
57 * @flags: flags, combination of the MEDIA_FLAG_* constants
58 *
59 * This structure represents a media-related device node.
60 *
61 * The @parent is a physical device. It must be set by core or device drivers
62 * before registering the node.
63 */
64struct media_devnode {
65 /* device ops */
66 const struct media_file_operations *fops;
67
68 /* sysfs */
69 struct device dev; /* media device */
70 struct cdev cdev; /* character device */
71 struct device *parent; /* device parent */
72
73 /* device info */
74 int minor;
75 unsigned long flags; /* Use bitops to access flags */
76
77 /* callbacks */
78 void (*release)(struct media_devnode *mdev);
79};
80
81/* dev to media_devnode */
82#define to_media_devnode(cd) container_of(cd, struct media_devnode, dev)
83
84int __must_check media_devnode_register(struct media_devnode *mdev);
85void media_devnode_unregister(struct media_devnode *mdev);
86
87static inline struct media_devnode *media_devnode_data(struct file *filp)
88{
89 return filp->private_data;
90}
91
92static inline int media_devnode_is_registered(struct media_devnode *mdev)
93{
94 return test_bit(MEDIA_FLAG_REGISTERED, &mdev->flags);
95}
96
97#endif /* _MEDIA_DEVNODE_H */
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
new file mode 100644
index 000000000000..cd8bca63a502
--- /dev/null
+++ b/include/media/media-entity.h
@@ -0,0 +1,151 @@
1/*
2 * Media entity
3 *
4 * Copyright (C) 2010 Nokia Corporation
5 *
6 * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
7 * Sakari Ailus <sakari.ailus@iki.fi>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#ifndef _MEDIA_ENTITY_H
24#define _MEDIA_ENTITY_H
25
26#include <linux/list.h>
27#include <linux/media.h>
28
29struct media_pipeline {
30};
31
32struct media_link {
33 struct media_pad *source; /* Source pad */
34 struct media_pad *sink; /* Sink pad */
35 struct media_link *reverse; /* Link in the reverse direction */
36 unsigned long flags; /* Link flags (MEDIA_LNK_FL_*) */
37};
38
39struct media_pad {
40 struct media_entity *entity; /* Entity this pad belongs to */
41 u16 index; /* Pad index in the entity pads array */
42 unsigned long flags; /* Pad flags (MEDIA_PAD_FL_*) */
43};
44
45struct media_entity_operations {
46 int (*link_setup)(struct media_entity *entity,
47 const struct media_pad *local,
48 const struct media_pad *remote, u32 flags);
49};
50
51struct media_entity {
52 struct list_head list;
53 struct media_device *parent; /* Media device this entity belongs to*/
54 u32 id; /* Entity ID, unique in the parent media
55 * device context */
56 const char *name; /* Entity name */
57 u32 type; /* Entity type (MEDIA_ENT_T_*) */
58 u32 revision; /* Entity revision, driver specific */
59 unsigned long flags; /* Entity flags (MEDIA_ENT_FL_*) */
60 u32 group_id; /* Entity group ID */
61
62 u16 num_pads; /* Number of sink and source pads */
63 u16 num_links; /* Number of existing links, both
64 * enabled and disabled */
65 u16 num_backlinks; /* Number of backlinks */
66 u16 max_links; /* Maximum number of links */
67
68 struct media_pad *pads; /* Pads array (num_pads elements) */
69 struct media_link *links; /* Links array (max_links elements)*/
70
71 const struct media_entity_operations *ops; /* Entity operations */
72
73 /* Reference counts must never be negative, but are signed integers on
74 * purpose: a simple WARN_ON(<0) check can be used to detect reference
75 * count bugs that would make them negative.
76 */
77 int stream_count; /* Stream count for the entity. */
78 int use_count; /* Use count for the entity. */
79
80 struct media_pipeline *pipe; /* Pipeline this entity belongs to. */
81
82 union {
83 /* Node specifications */
84 struct {
85 u32 major;
86 u32 minor;
87 } v4l;
88 struct {
89 u32 major;
90 u32 minor;
91 } fb;
92 struct {
93 u32 card;
94 u32 device;
95 u32 subdevice;
96 } alsa;
97 int dvb;
98
99 /* Sub-device specifications */
100 /* Nothing needed yet */
101 };
102};
103
104static inline u32 media_entity_type(struct media_entity *entity)
105{
106 return entity->type & MEDIA_ENT_TYPE_MASK;
107}
108
109static inline u32 media_entity_subtype(struct media_entity *entity)
110{
111 return entity->type & MEDIA_ENT_SUBTYPE_MASK;
112}
113
114#define MEDIA_ENTITY_ENUM_MAX_DEPTH 16
115
116struct media_entity_graph {
117 struct {
118 struct media_entity *entity;
119 int link;
120 } stack[MEDIA_ENTITY_ENUM_MAX_DEPTH];
121 int top;
122};
123
124int media_entity_init(struct media_entity *entity, u16 num_pads,
125 struct media_pad *pads, u16 extra_links);
126void media_entity_cleanup(struct media_entity *entity);
127
128int media_entity_create_link(struct media_entity *source, u16 source_pad,
129 struct media_entity *sink, u16 sink_pad, u32 flags);
130int __media_entity_setup_link(struct media_link *link, u32 flags);
131int media_entity_setup_link(struct media_link *link, u32 flags);
132struct media_link *media_entity_find_link(struct media_pad *source,
133 struct media_pad *sink);
134struct media_pad *media_entity_remote_source(struct media_pad *pad);
135
136struct media_entity *media_entity_get(struct media_entity *entity);
137void media_entity_put(struct media_entity *entity);
138
139void media_entity_graph_walk_start(struct media_entity_graph *graph,
140 struct media_entity *entity);
141struct media_entity *
142media_entity_graph_walk_next(struct media_entity_graph *graph);
143void media_entity_pipeline_start(struct media_entity *entity,
144 struct media_pipeline *pipe);
145void media_entity_pipeline_stop(struct media_entity *entity);
146
147#define media_entity_call(entity, operation, args...) \
148 (((entity)->ops && (entity)->ops->operation) ? \
149 (entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD)
150
151#endif
diff --git a/include/media/mt9v011.h b/include/media/mt9v011.h
new file mode 100644
index 000000000000..ea29fc74cd06
--- /dev/null
+++ b/include/media/mt9v011.h
@@ -0,0 +1,17 @@
1/* mt9v011 sensor
2 *
3 * Copyright (C) 2011 Hans Verkuil <hverkuil@xs4all.nl>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9
10#ifndef __MT9V011_H__
11#define __MT9V011_H__
12
13struct mt9v011_platform_data {
14 unsigned xtal; /* Hz */
15};
16
17#endif
diff --git a/include/media/mt9v032.h b/include/media/mt9v032.h
new file mode 100644
index 000000000000..5e27f9be6b95
--- /dev/null
+++ b/include/media/mt9v032.h
@@ -0,0 +1,12 @@
1#ifndef _MEDIA_MT9V032_H
2#define _MEDIA_MT9V032_H
3
4struct v4l2_subdev;
5
6struct mt9v032_platform_data {
7 unsigned int clk_pol:1;
8
9 void (*set_clock)(struct v4l2_subdev *subdev, unsigned int rate);
10};
11
12#endif
diff --git a/include/media/noon010pc30.h b/include/media/noon010pc30.h
new file mode 100644
index 000000000000..58eafee36b30
--- /dev/null
+++ b/include/media/noon010pc30.h
@@ -0,0 +1,28 @@
1/*
2 * Driver header for NOON010PC30L camera sensor chip.
3 *
4 * Copyright (c) 2010 Samsung Electronics, Co. Ltd
5 * Contact: Sylwester Nawrocki <s.nawrocki@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13#ifndef NOON010PC30_H
14#define NOON010PC30_H
15
16/**
17 * @clk_rate: the clock frequency in Hz
18 * @gpio_nreset: GPIO driving nRESET pin
19 * @gpio_nstby: GPIO driving nSTBY pin
20 */
21
22struct noon010pc30_platform_data {
23 unsigned long clk_rate;
24 int gpio_nreset;
25 int gpio_nstby;
26};
27
28#endif /* NOON010PC30_H */
diff --git a/include/media/omap1_camera.h b/include/media/omap1_camera.h
new file mode 100644
index 000000000000..819767cf04d4
--- /dev/null
+++ b/include/media/omap1_camera.h
@@ -0,0 +1,35 @@
1/*
2 * Header for V4L2 SoC Camera driver for OMAP1 Camera Interface
3 *
4 * Copyright (C) 2010, Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
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 version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __MEDIA_OMAP1_CAMERA_H_
12#define __MEDIA_OMAP1_CAMERA_H_
13
14#include <linux/bitops.h>
15
16#define OMAP1_CAMERA_IOSIZE 0x1c
17
18enum omap1_cam_vb_mode {
19 OMAP1_CAM_DMA_CONTIG = 0,
20 OMAP1_CAM_DMA_SG,
21};
22
23#define OMAP1_CAMERA_MIN_BUF_COUNT(x) ((x) == OMAP1_CAM_DMA_CONTIG ? 3 : 2)
24
25struct omap1_cam_platform_data {
26 unsigned long camexclk_khz;
27 unsigned long lclk_khz_max;
28 unsigned long flags;
29};
30
31#define OMAP1_CAMERA_LCLK_RISING BIT(0)
32#define OMAP1_CAMERA_RST_LOW BIT(1)
33#define OMAP1_CAMERA_RST_HIGH BIT(2)
34
35#endif /* __MEDIA_OMAP1_CAMERA_H_ */
diff --git a/include/media/ovcamchip.h b/include/media/ovcamchip.h
deleted file mode 100644
index 05b9569ef1c8..000000000000
--- a/include/media/ovcamchip.h
+++ /dev/null
@@ -1,90 +0,0 @@
1/* OmniVision* camera chip driver API
2 *
3 * Copyright (c) 1999-2004 Mark McClelland
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. NO WARRANTY OF ANY KIND is expressed or implied.
9 *
10 * * OmniVision is a trademark of OmniVision Technologies, Inc. This driver
11 * is not sponsored or developed by them.
12 */
13
14#ifndef __LINUX_OVCAMCHIP_H
15#define __LINUX_OVCAMCHIP_H
16
17#include <linux/videodev.h>
18#include <media/v4l2-common.h>
19
20/* --------------------------------- */
21/* ENUMERATIONS */
22/* --------------------------------- */
23
24/* Controls */
25enum {
26 OVCAMCHIP_CID_CONT, /* Contrast */
27 OVCAMCHIP_CID_BRIGHT, /* Brightness */
28 OVCAMCHIP_CID_SAT, /* Saturation */
29 OVCAMCHIP_CID_HUE, /* Hue */
30 OVCAMCHIP_CID_EXP, /* Exposure */
31 OVCAMCHIP_CID_FREQ, /* Light frequency */
32 OVCAMCHIP_CID_BANDFILT, /* Banding filter */
33 OVCAMCHIP_CID_AUTOBRIGHT, /* Auto brightness */
34 OVCAMCHIP_CID_AUTOEXP, /* Auto exposure */
35 OVCAMCHIP_CID_BACKLIGHT, /* Back light compensation */
36 OVCAMCHIP_CID_MIRROR, /* Mirror horizontally */
37};
38
39/* Chip types */
40#define NUM_CC_TYPES 9
41enum {
42 CC_UNKNOWN,
43 CC_OV76BE,
44 CC_OV7610,
45 CC_OV7620,
46 CC_OV7620AE,
47 CC_OV6620,
48 CC_OV6630,
49 CC_OV6630AE,
50 CC_OV6630AF,
51};
52
53/* --------------------------------- */
54/* I2C ADDRESSES */
55/* --------------------------------- */
56
57#define OV7xx0_SID (0x42 >> 1)
58#define OV6xx0_SID (0xC0 >> 1)
59
60/* --------------------------------- */
61/* API */
62/* --------------------------------- */
63
64struct ovcamchip_control {
65 __u32 id;
66 __s32 value;
67};
68
69struct ovcamchip_window {
70 int x;
71 int y;
72 int width;
73 int height;
74 int format;
75 int quarter; /* Scale width and height down 2x */
76
77 /* This stuff will be removed eventually */
78 int clockdiv; /* Clock divisor setting */
79};
80
81/* Commands */
82#define OVCAMCHIP_CMD_Q_SUBTYPE _IOR (0x88, 0x00, int)
83#define OVCAMCHIP_CMD_INITIALIZE _IOW (0x88, 0x01, int)
84/* You must call OVCAMCHIP_CMD_INITIALIZE before any of commands below! */
85#define OVCAMCHIP_CMD_S_CTRL _IOW (0x88, 0x02, struct ovcamchip_control)
86#define OVCAMCHIP_CMD_G_CTRL _IOWR (0x88, 0x03, struct ovcamchip_control)
87#define OVCAMCHIP_CMD_S_MODE _IOW (0x88, 0x04, struct ovcamchip_window)
88#define OVCAMCHIP_MAX_CMD _IO (0x88, 0x3f)
89
90#endif
diff --git a/include/media/rc-core.h b/include/media/rc-core.h
new file mode 100644
index 000000000000..60536c74c1ea
--- /dev/null
+++ b/include/media/rc-core.h
@@ -0,0 +1,226 @@
1/*
2 * Remote Controller core header
3 *
4 * Copyright (C) 2009-2010 by Mauro Carvalho Chehab <mchehab@redhat.com>
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 version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#ifndef _RC_CORE
17#define _RC_CORE
18
19#include <linux/spinlock.h>
20#include <linux/kfifo.h>
21#include <linux/time.h>
22#include <linux/timer.h>
23#include <media/rc-map.h>
24
25extern int rc_core_debug;
26#define IR_dprintk(level, fmt, arg...) if (rc_core_debug >= level) \
27 printk(KERN_DEBUG "%s: " fmt , __func__, ## arg)
28
29enum rc_driver_type {
30 RC_DRIVER_SCANCODE = 0, /* Driver or hardware generates a scancode */
31 RC_DRIVER_IR_RAW, /* Needs a Infra-Red pulse/space decoder */
32};
33
34/**
35 * struct rc_dev - represents a remote control device
36 * @dev: driver model's view of this device
37 * @input_name: name of the input child device
38 * @input_phys: physical path to the input child device
39 * @input_id: id of the input child device (struct input_id)
40 * @driver_name: name of the hardware driver which registered this device
41 * @map_name: name of the default keymap
42 * @rc_map: current scan/key table
43 * @lock: used to ensure we've filled in all protocol details before
44 * anyone can call show_protocols or store_protocols
45 * @devno: unique remote control device number
46 * @raw: additional data for raw pulse/space devices
47 * @input_dev: the input child device used to communicate events to userspace
48 * @driver_type: specifies if protocol decoding is done in hardware or software
49 * @idle: used to keep track of RX state
50 * @allowed_protos: bitmask with the supported RC_TYPE_* protocols
51 * @scanmask: some hardware decoders are not capable of providing the full
52 * scancode to the application. As this is a hardware limit, we can't do
53 * anything with it. Yet, as the same keycode table can be used with other
54 * devices, a mask is provided to allow its usage. Drivers should generally
55 * leave this field in blank
56 * @priv: driver-specific data
57 * @keylock: protects the remaining members of the struct
58 * @keypressed: whether a key is currently pressed
59 * @keyup_jiffies: time (in jiffies) when the current keypress should be released
60 * @timer_keyup: timer for releasing a keypress
61 * @last_keycode: keycode of last keypress
62 * @last_scancode: scancode of last keypress
63 * @last_toggle: toggle value of last command
64 * @timeout: optional time after which device stops sending data
65 * @min_timeout: minimum timeout supported by device
66 * @max_timeout: maximum timeout supported by device
67 * @rx_resolution : resolution (in ns) of input sampler
68 * @tx_resolution: resolution (in ns) of output sampler
69 * @change_protocol: allow changing the protocol used on hardware decoders
70 * @open: callback to allow drivers to enable polling/irq when IR input device
71 * is opened.
72 * @close: callback to allow drivers to disable polling/irq when IR input device
73 * is opened.
74 * @s_tx_mask: set transmitter mask (for devices with multiple tx outputs)
75 * @s_tx_carrier: set transmit carrier frequency
76 * @s_tx_duty_cycle: set transmit duty cycle (0% - 100%)
77 * @s_rx_carrier: inform driver about carrier it is expected to handle
78 * @tx_ir: transmit IR
79 * @s_idle: enable/disable hardware idle mode, upon which,
80 * device doesn't interrupt host until it sees IR pulses
81 * @s_learning_mode: enable wide band receiver used for learning
82 * @s_carrier_report: enable carrier reports
83 */
84struct rc_dev {
85 struct device dev;
86 const char *input_name;
87 const char *input_phys;
88 struct input_id input_id;
89 char *driver_name;
90 const char *map_name;
91 struct rc_map rc_map;
92 struct mutex lock;
93 unsigned long devno;
94 struct ir_raw_event_ctrl *raw;
95 struct input_dev *input_dev;
96 enum rc_driver_type driver_type;
97 bool idle;
98 u64 allowed_protos;
99 u32 scanmask;
100 void *priv;
101 spinlock_t keylock;
102 bool keypressed;
103 unsigned long keyup_jiffies;
104 struct timer_list timer_keyup;
105 u32 last_keycode;
106 u32 last_scancode;
107 u8 last_toggle;
108 u32 timeout;
109 u32 min_timeout;
110 u32 max_timeout;
111 u32 rx_resolution;
112 u32 tx_resolution;
113 int (*change_protocol)(struct rc_dev *dev, u64 rc_type);
114 int (*open)(struct rc_dev *dev);
115 void (*close)(struct rc_dev *dev);
116 int (*s_tx_mask)(struct rc_dev *dev, u32 mask);
117 int (*s_tx_carrier)(struct rc_dev *dev, u32 carrier);
118 int (*s_tx_duty_cycle)(struct rc_dev *dev, u32 duty_cycle);
119 int (*s_rx_carrier_range)(struct rc_dev *dev, u32 min, u32 max);
120 int (*tx_ir)(struct rc_dev *dev, int *txbuf, u32 n);
121 void (*s_idle)(struct rc_dev *dev, bool enable);
122 int (*s_learning_mode)(struct rc_dev *dev, int enable);
123 int (*s_carrier_report) (struct rc_dev *dev, int enable);
124};
125
126#define to_rc_dev(d) container_of(d, struct rc_dev, dev)
127
128/*
129 * From rc-main.c
130 * Those functions can be used on any type of Remote Controller. They
131 * basically creates an input_dev and properly reports the device as a
132 * Remote Controller, at sys/class/rc.
133 */
134
135struct rc_dev *rc_allocate_device(void);
136void rc_free_device(struct rc_dev *dev);
137int rc_register_device(struct rc_dev *dev);
138void rc_unregister_device(struct rc_dev *dev);
139
140void rc_repeat(struct rc_dev *dev);
141void rc_keydown(struct rc_dev *dev, int scancode, u8 toggle);
142void rc_keydown_notimeout(struct rc_dev *dev, int scancode, u8 toggle);
143void rc_keyup(struct rc_dev *dev);
144u32 rc_g_keycode_from_table(struct rc_dev *dev, u32 scancode);
145
146/*
147 * From rc-raw.c
148 * The Raw interface is specific to InfraRed. It may be a good idea to
149 * split it later into a separate header.
150 */
151
152enum raw_event_type {
153 IR_SPACE = (1 << 0),
154 IR_PULSE = (1 << 1),
155 IR_START_EVENT = (1 << 2),
156 IR_STOP_EVENT = (1 << 3),
157};
158
159struct ir_raw_event {
160 union {
161 u32 duration;
162
163 struct {
164 u32 carrier;
165 u8 duty_cycle;
166 };
167 };
168
169 unsigned pulse:1;
170 unsigned reset:1;
171 unsigned timeout:1;
172 unsigned carrier_report:1;
173};
174
175#define DEFINE_IR_RAW_EVENT(event) \
176 struct ir_raw_event event = { \
177 { .duration = 0 } , \
178 .pulse = 0, \
179 .reset = 0, \
180 .timeout = 0, \
181 .carrier_report = 0 }
182
183static inline void init_ir_raw_event(struct ir_raw_event *ev)
184{
185 memset(ev, 0, sizeof(*ev));
186}
187
188#define IR_MAX_DURATION 0xFFFFFFFF /* a bit more than 4 seconds */
189#define US_TO_NS(usec) ((usec) * 1000)
190#define MS_TO_US(msec) ((msec) * 1000)
191#define MS_TO_NS(msec) ((msec) * 1000 * 1000)
192
193void ir_raw_event_handle(struct rc_dev *dev);
194int ir_raw_event_store(struct rc_dev *dev, struct ir_raw_event *ev);
195int ir_raw_event_store_edge(struct rc_dev *dev, enum raw_event_type type);
196int ir_raw_event_store_with_filter(struct rc_dev *dev,
197 struct ir_raw_event *ev);
198void ir_raw_event_set_idle(struct rc_dev *dev, bool idle);
199
200static inline void ir_raw_event_reset(struct rc_dev *dev)
201{
202 DEFINE_IR_RAW_EVENT(ev);
203 ev.reset = true;
204
205 ir_raw_event_store(dev, &ev);
206 ir_raw_event_handle(dev);
207}
208
209/* extract mask bits out of data and pack them into the result */
210static inline u32 ir_extract_bits(u32 data, u32 mask)
211{
212 u32 vbit = 1, value = 0;
213
214 do {
215 if (mask & 1) {
216 if (data & 1)
217 value |= vbit;
218 vbit <<= 1;
219 }
220 data >>= 1;
221 } while (mask >>= 1);
222
223 return value;
224}
225
226#endif /* _RC_CORE */
diff --git a/include/media/rc-map.h b/include/media/rc-map.h
index a9c041d49662..4e1409ec2613 100644
--- a/include/media/rc-map.h
+++ b/include/media/rc-map.h
@@ -11,49 +11,52 @@
11 11
12#include <linux/input.h> 12#include <linux/input.h>
13 13
14#define IR_TYPE_UNKNOWN 0 14#define RC_TYPE_UNKNOWN 0
15#define IR_TYPE_RC5 (1 << 0) /* Philips RC5 protocol */ 15#define RC_TYPE_RC5 (1 << 0) /* Philips RC5 protocol */
16#define IR_TYPE_NEC (1 << 1) 16#define RC_TYPE_NEC (1 << 1)
17#define IR_TYPE_RC6 (1 << 2) /* Philips RC6 protocol */ 17#define RC_TYPE_RC6 (1 << 2) /* Philips RC6 protocol */
18#define IR_TYPE_JVC (1 << 3) /* JVC protocol */ 18#define RC_TYPE_JVC (1 << 3) /* JVC protocol */
19#define IR_TYPE_SONY (1 << 4) /* Sony12/15/20 protocol */ 19#define RC_TYPE_SONY (1 << 4) /* Sony12/15/20 protocol */
20#define IR_TYPE_LIRC (1 << 30) /* Pass raw IR to lirc userspace */ 20#define RC_TYPE_RC5_SZ (1 << 5) /* RC5 variant used by Streamzap */
21#define IR_TYPE_OTHER (1u << 31) 21#define RC_TYPE_LIRC (1 << 30) /* Pass raw IR to lirc userspace */
22#define RC_TYPE_OTHER (1u << 31)
22 23
23#define IR_TYPE_ALL (IR_TYPE_RC5 | IR_TYPE_NEC | IR_TYPE_RC6 | \ 24#define RC_TYPE_ALL (RC_TYPE_RC5 | RC_TYPE_NEC | RC_TYPE_RC6 | \
24 IR_TYPE_JVC | IR_TYPE_SONY | IR_TYPE_LIRC | \ 25 RC_TYPE_JVC | RC_TYPE_SONY | RC_TYPE_LIRC | \
25 IR_TYPE_OTHER) 26 RC_TYPE_RC5_SZ | RC_TYPE_OTHER)
26 27
27struct ir_scancode { 28struct rc_map_table {
28 u32 scancode; 29 u32 scancode;
29 u32 keycode; 30 u32 keycode;
30}; 31};
31 32
32struct ir_scancode_table { 33struct rc_map {
33 struct ir_scancode *scan; 34 struct rc_map_table *scan;
34 unsigned int size; /* Max number of entries */ 35 unsigned int size; /* Max number of entries */
35 unsigned int len; /* Used number of entries */ 36 unsigned int len; /* Used number of entries */
36 unsigned int alloc; /* Size of *scan in bytes */ 37 unsigned int alloc; /* Size of *scan in bytes */
37 u64 ir_type; 38 u64 rc_type;
38 char *name; 39 const char *name;
39 spinlock_t lock; 40 spinlock_t lock;
40}; 41};
41 42
42struct rc_keymap { 43struct rc_map_list {
43 struct list_head list; 44 struct list_head list;
44 struct ir_scancode_table map; 45 struct rc_map map;
45}; 46};
46 47
47/* Routines from rc-map.c */ 48/* Routines from rc-map.c */
48 49
49int ir_register_map(struct rc_keymap *map); 50int rc_map_register(struct rc_map_list *map);
50void ir_unregister_map(struct rc_keymap *map); 51void rc_map_unregister(struct rc_map_list *map);
51struct ir_scancode_table *get_rc_map(const char *name); 52struct rc_map *rc_map_get(const char *name);
52void rc_map_init(void); 53void rc_map_init(void);
53 54
54/* Names of the several keytables defined in-kernel */ 55/* Names of the several keytables defined in-kernel */
55 56
56#define RC_MAP_ADSTECH_DVB_T_PCI "rc-adstech-dvb-t-pci" 57#define RC_MAP_ADSTECH_DVB_T_PCI "rc-adstech-dvb-t-pci"
58#define RC_MAP_ALINK_DTU_M "rc-alink-dtu-m"
59#define RC_MAP_ANYSEE "rc-anysee"
57#define RC_MAP_APAC_VIEWCOMP "rc-apac-viewcomp" 60#define RC_MAP_APAC_VIEWCOMP "rc-apac-viewcomp"
58#define RC_MAP_ASUS_PC39 "rc-asus-pc39" 61#define RC_MAP_ASUS_PC39 "rc-asus-pc39"
59#define RC_MAP_ATI_TV_WONDER_HD_600 "rc-ati-tv-wonder-hd-600" 62#define RC_MAP_ATI_TV_WONDER_HD_600 "rc-ati-tv-wonder-hd-600"
@@ -62,8 +65,10 @@ void rc_map_init(void);
62#define RC_MAP_AVERMEDIA_DVBT "rc-avermedia-dvbt" 65#define RC_MAP_AVERMEDIA_DVBT "rc-avermedia-dvbt"
63#define RC_MAP_AVERMEDIA_M135A "rc-avermedia-m135a" 66#define RC_MAP_AVERMEDIA_M135A "rc-avermedia-m135a"
64#define RC_MAP_AVERMEDIA_M733A_RM_K6 "rc-avermedia-m733a-rm-k6" 67#define RC_MAP_AVERMEDIA_M733A_RM_K6 "rc-avermedia-m733a-rm-k6"
68#define RC_MAP_AVERMEDIA_RM_KS "rc-avermedia-rm-ks"
65#define RC_MAP_AVERMEDIA "rc-avermedia" 69#define RC_MAP_AVERMEDIA "rc-avermedia"
66#define RC_MAP_AVERTV_303 "rc-avertv-303" 70#define RC_MAP_AVERTV_303 "rc-avertv-303"
71#define RC_MAP_AZUREWAVE_AD_TU700 "rc-azurewave-ad-tu700"
67#define RC_MAP_BEHOLD_COLUMBUS "rc-behold-columbus" 72#define RC_MAP_BEHOLD_COLUMBUS "rc-behold-columbus"
68#define RC_MAP_BEHOLD "rc-behold" 73#define RC_MAP_BEHOLD "rc-behold"
69#define RC_MAP_BUDGET_CI_OLD "rc-budget-ci-old" 74#define RC_MAP_BUDGET_CI_OLD "rc-budget-ci-old"
@@ -71,6 +76,8 @@ void rc_map_init(void);
71#define RC_MAP_CINERGY "rc-cinergy" 76#define RC_MAP_CINERGY "rc-cinergy"
72#define RC_MAP_DIB0700_NEC_TABLE "rc-dib0700-nec" 77#define RC_MAP_DIB0700_NEC_TABLE "rc-dib0700-nec"
73#define RC_MAP_DIB0700_RC5_TABLE "rc-dib0700-rc5" 78#define RC_MAP_DIB0700_RC5_TABLE "rc-dib0700-rc5"
79#define RC_MAP_DIGITALNOW_TINYTWIN "rc-digitalnow-tinytwin"
80#define RC_MAP_DIGITTRADE "rc-digittrade"
74#define RC_MAP_DM1105_NEC "rc-dm1105-nec" 81#define RC_MAP_DM1105_NEC "rc-dm1105-nec"
75#define RC_MAP_DNTV_LIVE_DVBT_PRO "rc-dntv-live-dvbt-pro" 82#define RC_MAP_DNTV_LIVE_DVBT_PRO "rc-dntv-live-dvbt-pro"
76#define RC_MAP_DNTV_LIVE_DVB_T "rc-dntv-live-dvb-t" 83#define RC_MAP_DNTV_LIVE_DVB_T "rc-dntv-live-dvb-t"
@@ -87,15 +94,19 @@ void rc_map_init(void);
87#define RC_MAP_GADMEI_RM008Z "rc-gadmei-rm008z" 94#define RC_MAP_GADMEI_RM008Z "rc-gadmei-rm008z"
88#define RC_MAP_GENIUS_TVGO_A11MCE "rc-genius-tvgo-a11mce" 95#define RC_MAP_GENIUS_TVGO_A11MCE "rc-genius-tvgo-a11mce"
89#define RC_MAP_GOTVIEW7135 "rc-gotview7135" 96#define RC_MAP_GOTVIEW7135 "rc-gotview7135"
90#define RC_MAP_HAUPPAUGE_NEW "rc-hauppauge-new" 97#define RC_MAP_HAUPPAUGE_NEW "rc-hauppauge"
91#define RC_MAP_IMON_MCE "rc-imon-mce" 98#define RC_MAP_IMON_MCE "rc-imon-mce"
92#define RC_MAP_IMON_PAD "rc-imon-pad" 99#define RC_MAP_IMON_PAD "rc-imon-pad"
93#define RC_MAP_IODATA_BCTV7E "rc-iodata-bctv7e" 100#define RC_MAP_IODATA_BCTV7E "rc-iodata-bctv7e"
94#define RC_MAP_KAIOMY "rc-kaiomy" 101#define RC_MAP_KAIOMY "rc-kaiomy"
95#define RC_MAP_KWORLD_315U "rc-kworld-315u" 102#define RC_MAP_KWORLD_315U "rc-kworld-315u"
96#define RC_MAP_KWORLD_PLUS_TV_ANALOG "rc-kworld-plus-tv-analog" 103#define RC_MAP_KWORLD_PLUS_TV_ANALOG "rc-kworld-plus-tv-analog"
104#define RC_MAP_LEADTEK_Y04G0051 "rc-leadtek-y04g0051"
97#define RC_MAP_LIRC "rc-lirc" 105#define RC_MAP_LIRC "rc-lirc"
106#define RC_MAP_LME2510 "rc-lme2510"
98#define RC_MAP_MANLI "rc-manli" 107#define RC_MAP_MANLI "rc-manli"
108#define RC_MAP_MSI_DIGIVOX_II "rc-msi-digivox-ii"
109#define RC_MAP_MSI_DIGIVOX_III "rc-msi-digivox-iii"
99#define RC_MAP_MSI_TVANYWHERE_PLUS "rc-msi-tvanywhere-plus" 110#define RC_MAP_MSI_TVANYWHERE_PLUS "rc-msi-tvanywhere-plus"
100#define RC_MAP_MSI_TVANYWHERE "rc-msi-tvanywhere" 111#define RC_MAP_MSI_TVANYWHERE "rc-msi-tvanywhere"
101#define RC_MAP_NEBULA "rc-nebula" 112#define RC_MAP_NEBULA "rc-nebula"
@@ -108,20 +119,29 @@ void rc_map_init(void);
108#define RC_MAP_PINNACLE_PCTV_HD "rc-pinnacle-pctv-hd" 119#define RC_MAP_PINNACLE_PCTV_HD "rc-pinnacle-pctv-hd"
109#define RC_MAP_PIXELVIEW_NEW "rc-pixelview-new" 120#define RC_MAP_PIXELVIEW_NEW "rc-pixelview-new"
110#define RC_MAP_PIXELVIEW "rc-pixelview" 121#define RC_MAP_PIXELVIEW "rc-pixelview"
122#define RC_MAP_PIXELVIEW_002T "rc-pixelview-002t"
111#define RC_MAP_PIXELVIEW_MK12 "rc-pixelview-mk12" 123#define RC_MAP_PIXELVIEW_MK12 "rc-pixelview-mk12"
112#define RC_MAP_POWERCOLOR_REAL_ANGEL "rc-powercolor-real-angel" 124#define RC_MAP_POWERCOLOR_REAL_ANGEL "rc-powercolor-real-angel"
113#define RC_MAP_PROTEUS_2309 "rc-proteus-2309" 125#define RC_MAP_PROTEUS_2309 "rc-proteus-2309"
114#define RC_MAP_PURPLETV "rc-purpletv" 126#define RC_MAP_PURPLETV "rc-purpletv"
115#define RC_MAP_PV951 "rc-pv951" 127#define RC_MAP_PV951 "rc-pv951"
116#define RC_MAP_RC5_HAUPPAUGE_NEW "rc-rc5-hauppauge-new" 128#define RC_MAP_HAUPPAUGE "rc-hauppauge"
117#define RC_MAP_RC5_STREAMZAP "rc-rc5-streamzap"
118#define RC_MAP_RC5_TV "rc-rc5-tv" 129#define RC_MAP_RC5_TV "rc-rc5-tv"
119#define RC_MAP_RC6_MCE "rc-rc6-mce" 130#define RC_MAP_RC6_MCE "rc-rc6-mce"
120#define RC_MAP_REAL_AUDIO_220_32_KEYS "rc-real-audio-220-32-keys" 131#define RC_MAP_REAL_AUDIO_220_32_KEYS "rc-real-audio-220-32-keys"
132#define RC_MAP_STREAMZAP "rc-streamzap"
121#define RC_MAP_TBS_NEC "rc-tbs-nec" 133#define RC_MAP_TBS_NEC "rc-tbs-nec"
134#define RC_MAP_TECHNISAT_USB2 "rc-technisat-usb2"
122#define RC_MAP_TERRATEC_CINERGY_XS "rc-terratec-cinergy-xs" 135#define RC_MAP_TERRATEC_CINERGY_XS "rc-terratec-cinergy-xs"
136#define RC_MAP_TERRATEC_SLIM "rc-terratec-slim"
137#define RC_MAP_TERRATEC_SLIM_2 "rc-terratec-slim-2"
123#define RC_MAP_TEVII_NEC "rc-tevii-nec" 138#define RC_MAP_TEVII_NEC "rc-tevii-nec"
139#define RC_MAP_TIVO "rc-tivo"
140#define RC_MAP_TOTAL_MEDIA_IN_HAND "rc-total-media-in-hand"
141#define RC_MAP_TREKSTOR "rc-trekstor"
124#define RC_MAP_TT_1500 "rc-tt-1500" 142#define RC_MAP_TT_1500 "rc-tt-1500"
143#define RC_MAP_TWINHAN_VP1027_DVBS "rc-twinhan1027"
144#define RC_MAP_VIDEOMATE_M1F "rc-videomate-m1f"
125#define RC_MAP_VIDEOMATE_S350 "rc-videomate-s350" 145#define RC_MAP_VIDEOMATE_S350 "rc-videomate-s350"
126#define RC_MAP_VIDEOMATE_TV_PVR "rc-videomate-tv-pvr" 146#define RC_MAP_VIDEOMATE_TV_PVR "rc-videomate-tv-pvr"
127#define RC_MAP_WINFAST "rc-winfast" 147#define RC_MAP_WINFAST "rc-winfast"
diff --git a/include/media/s5p_fimc.h b/include/media/s5p_fimc.h
new file mode 100644
index 000000000000..9fdff8a4ed26
--- /dev/null
+++ b/include/media/s5p_fimc.h
@@ -0,0 +1,61 @@
1/*
2 * Samsung S5P SoC camera interface driver header
3 *
4 * Copyright (c) 2010 Samsung Electronics Co., Ltd
5 * Author: Sylwester Nawrocki, <s.nawrocki@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#ifndef S5P_FIMC_H_
13#define S5P_FIMC_H_
14
15enum cam_bus_type {
16 FIMC_ITU_601 = 1,
17 FIMC_ITU_656,
18 FIMC_MIPI_CSI2,
19 FIMC_LCD_WB, /* FIFO link from LCD mixer */
20};
21
22#define FIMC_CLK_INV_PCLK (1 << 0)
23#define FIMC_CLK_INV_VSYNC (1 << 1)
24#define FIMC_CLK_INV_HREF (1 << 2)
25#define FIMC_CLK_INV_HSYNC (1 << 3)
26
27struct i2c_board_info;
28
29/**
30 * struct s5p_fimc_isp_info - image sensor information required for host
31 * interace configuration.
32 *
33 * @board_info: pointer to I2C subdevice's board info
34 * @clk_frequency: frequency of the clock the host interface provides to sensor
35 * @bus_type: determines bus type, MIPI, ITU-R BT.601 etc.
36 * @csi_data_align: MIPI-CSI interface data alignment in bits
37 * @i2c_bus_num: i2c control bus id the sensor is attached to
38 * @mux_id: FIMC camera interface multiplexer index (separate for MIPI and ITU)
39 * @flags: flags defining bus signals polarity inversion (High by default)
40 */
41struct s5p_fimc_isp_info {
42 struct i2c_board_info *board_info;
43 unsigned long clk_frequency;
44 enum cam_bus_type bus_type;
45 u16 csi_data_align;
46 u16 i2c_bus_num;
47 u16 mux_id;
48 u16 flags;
49};
50
51/**
52 * struct s5p_platform_fimc - camera host interface platform data
53 *
54 * @isp_info: properties of camera sensor required for host interface setup
55 * @num_clients: the number of attached image sensors
56 */
57struct s5p_platform_fimc {
58 struct s5p_fimc_isp_info *isp_info;
59 int num_clients;
60};
61#endif /* S5P_FIMC_H_ */
diff --git a/include/media/rds.h b/include/media/saa6588.h
index a89426667618..2c3c4420a4eb 100644
--- a/include/media/rds.h
+++ b/include/media/saa6588.h
@@ -4,9 +4,6 @@
4 saa6588.c and every driver (e.g. bttv-driver.c) that wants 4 saa6588.c and every driver (e.g. bttv-driver.c) that wants
5 to use the saa6588 module. 5 to use the saa6588 module.
6 6
7 Instead of having a separate rds.h, I'd prefer to include
8 this stuff in one of the already existing files like tuner.h
9
10 (c) 2005 by Hans J. Koch 7 (c) 2005 by Hans J. Koch
11 8
12 This program is free software; you can redistribute it and/or modify 9 This program is free software; you can redistribute it and/or modify
@@ -25,10 +22,10 @@
25 22
26*/ 23*/
27 24
28#ifndef _RDS_H 25#ifndef _SAA6588_H
29#define _RDS_H 26#define _SAA6588_H
30 27
31struct rds_command { 28struct saa6588_command {
32 unsigned int block_count; 29 unsigned int block_count;
33 int result; 30 int result;
34 unsigned char __user *buffer; 31 unsigned char __user *buffer;
@@ -36,9 +33,10 @@ struct rds_command {
36 poll_table *event_list; 33 poll_table *event_list;
37}; 34};
38 35
39#define RDS_CMD_OPEN _IOW('R',1,int) 36/* These ioctls are internal to the kernel */
40#define RDS_CMD_CLOSE _IOW('R',2,int) 37#define SAA6588_CMD_OPEN _IOW('R', 1, int)
41#define RDS_CMD_READ _IOR('R',3,int) 38#define SAA6588_CMD_CLOSE _IOW('R', 2, int)
42#define RDS_CMD_POLL _IOR('R',4,int) 39#define SAA6588_CMD_READ _IOR('R', 3, int)
40#define SAA6588_CMD_POLL _IOR('R', 4, int)
43 41
44#endif 42#endif
diff --git a/include/media/saa7146.h b/include/media/saa7146.h
index 7a9f76ecbbbd..79827143d5ac 100644
--- a/include/media/saa7146.h
+++ b/include/media/saa7146.h
@@ -115,7 +115,7 @@ struct saa7146_dev
115 115
116 /* different device locks */ 116 /* different device locks */
117 spinlock_t slock; 117 spinlock_t slock;
118 struct mutex lock; 118 struct mutex v4l2_lock;
119 119
120 unsigned char __iomem *mem; /* pointer to mapped IO memory */ 120 unsigned char __iomem *mem; /* pointer to mapped IO memory */
121 u32 revision; /* chip revision; needed for bug-workarounds*/ 121 u32 revision; /* chip revision; needed for bug-workarounds*/
@@ -161,7 +161,7 @@ extern struct list_head saa7146_devices;
161extern struct mutex saa7146_devices_lock; 161extern struct mutex saa7146_devices_lock;
162int saa7146_register_extension(struct saa7146_extension*); 162int saa7146_register_extension(struct saa7146_extension*);
163int saa7146_unregister_extension(struct saa7146_extension*); 163int saa7146_unregister_extension(struct saa7146_extension*);
164struct saa7146_format* format_by_fourcc(struct saa7146_dev *dev, int fourcc); 164struct saa7146_format* saa7146_format_by_fourcc(struct saa7146_dev *dev, int fourcc);
165int saa7146_pgtable_alloc(struct pci_dev *pci, struct saa7146_pgtable *pt); 165int saa7146_pgtable_alloc(struct pci_dev *pci, struct saa7146_pgtable *pt);
166void saa7146_pgtable_free(struct pci_dev *pci, struct saa7146_pgtable *pt); 166void saa7146_pgtable_free(struct pci_dev *pci, struct saa7146_pgtable *pt);
167int saa7146_pgtable_build_single(struct pci_dev *pci, struct saa7146_pgtable *pt, struct scatterlist *list, int length ); 167int saa7146_pgtable_build_single(struct pci_dev *pci, struct saa7146_pgtable *pt, struct scatterlist *list, int length );
diff --git a/include/media/sh_vou.h b/include/media/sh_vou.h
index a3ef30242b00..ec3ba9a597a2 100644
--- a/include/media/sh_vou.h
+++ b/include/media/sh_vou.h
@@ -28,7 +28,6 @@ struct sh_vou_pdata {
28 int i2c_adap; 28 int i2c_adap;
29 struct i2c_board_info *board_info; 29 struct i2c_board_info *board_info;
30 unsigned long flags; 30 unsigned long flags;
31 char *module_name;
32}; 31};
33 32
34#endif 33#endif
diff --git a/include/media/si4713.h b/include/media/si4713.h
index 99850a54ed09..ed7353e8a982 100644
--- a/include/media/si4713.h
+++ b/include/media/si4713.h
@@ -23,8 +23,7 @@
23 * Platform dependent definition 23 * Platform dependent definition
24 */ 24 */
25struct si4713_platform_data { 25struct si4713_platform_data {
26 /* Set power state, zero is off, non-zero is on. */ 26 int gpio_reset; /* < 0 if not used */
27 int (*set_power)(int power);
28}; 27};
29 28
30/* 29/*
diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h
index 2ce957301f77..238bd334fd83 100644
--- a/include/media/soc_camera.h
+++ b/include/media/soc_camera.h
@@ -17,16 +17,21 @@
17#include <linux/pm.h> 17#include <linux/pm.h>
18#include <linux/videodev2.h> 18#include <linux/videodev2.h>
19#include <media/videobuf-core.h> 19#include <media/videobuf-core.h>
20#include <media/videobuf2-core.h>
20#include <media/v4l2-device.h> 21#include <media/v4l2-device.h>
21 22
22extern struct bus_type soc_camera_bus_type; 23extern struct bus_type soc_camera_bus_type;
23 24
25struct file;
26
24struct soc_camera_device { 27struct soc_camera_device {
25 struct list_head list; 28 struct list_head list;
26 struct device dev; 29 struct device dev;
27 struct device *pdev; /* Platform device */ 30 struct device *pdev; /* Platform device */
28 s32 user_width; 31 s32 user_width;
29 s32 user_height; 32 s32 user_height;
33 u32 bytesperline; /* for padding, zero if unused */
34 u32 sizeimage;
30 enum v4l2_colorspace colorspace; 35 enum v4l2_colorspace colorspace;
31 unsigned char iface; /* Host number */ 36 unsigned char iface; /* Host number */
32 unsigned char devnum; /* Device number per host */ 37 unsigned char devnum; /* Device number per host */
@@ -41,11 +46,11 @@ struct soc_camera_device {
41 /* soc_camera.c private count. Only accessed with .video_lock held */ 46 /* soc_camera.c private count. Only accessed with .video_lock held */
42 int use_count; 47 int use_count;
43 struct mutex video_lock; /* Protects device data */ 48 struct mutex video_lock; /* Protects device data */
44}; 49 struct file *streamer; /* stream owner */
45 50 union {
46struct soc_camera_file { 51 struct videobuf_queue vb_vidq;
47 struct soc_camera_device *icd; 52 struct vb2_queue vb2_vidq;
48 struct videobuf_queue vb_vidq; 53 };
49}; 54};
50 55
51struct soc_camera_host { 56struct soc_camera_host {
@@ -75,17 +80,25 @@ struct soc_camera_host_ops {
75 int (*cropcap)(struct soc_camera_device *, struct v4l2_cropcap *); 80 int (*cropcap)(struct soc_camera_device *, struct v4l2_cropcap *);
76 int (*get_crop)(struct soc_camera_device *, struct v4l2_crop *); 81 int (*get_crop)(struct soc_camera_device *, struct v4l2_crop *);
77 int (*set_crop)(struct soc_camera_device *, struct v4l2_crop *); 82 int (*set_crop)(struct soc_camera_device *, struct v4l2_crop *);
83 /*
84 * The difference to .set_crop() is, that .set_livecrop is not allowed
85 * to change the output sizes
86 */
87 int (*set_livecrop)(struct soc_camera_device *, struct v4l2_crop *);
78 int (*set_fmt)(struct soc_camera_device *, struct v4l2_format *); 88 int (*set_fmt)(struct soc_camera_device *, struct v4l2_format *);
79 int (*try_fmt)(struct soc_camera_device *, struct v4l2_format *); 89 int (*try_fmt)(struct soc_camera_device *, struct v4l2_format *);
80 void (*init_videobuf)(struct videobuf_queue *, 90 void (*init_videobuf)(struct videobuf_queue *,
81 struct soc_camera_device *); 91 struct soc_camera_device *);
82 int (*reqbufs)(struct soc_camera_file *, struct v4l2_requestbuffers *); 92 int (*init_videobuf2)(struct vb2_queue *,
93 struct soc_camera_device *);
94 int (*reqbufs)(struct soc_camera_device *, struct v4l2_requestbuffers *);
83 int (*querycap)(struct soc_camera_host *, struct v4l2_capability *); 95 int (*querycap)(struct soc_camera_host *, struct v4l2_capability *);
84 int (*set_bus_param)(struct soc_camera_device *, __u32); 96 int (*set_bus_param)(struct soc_camera_device *, __u32);
85 int (*get_ctrl)(struct soc_camera_device *, struct v4l2_control *); 97 int (*get_ctrl)(struct soc_camera_device *, struct v4l2_control *);
86 int (*set_ctrl)(struct soc_camera_device *, struct v4l2_control *); 98 int (*set_ctrl)(struct soc_camera_device *, struct v4l2_control *);
87 int (*get_parm)(struct soc_camera_device *, struct v4l2_streamparm *); 99 int (*get_parm)(struct soc_camera_device *, struct v4l2_streamparm *);
88 int (*set_parm)(struct soc_camera_device *, struct v4l2_streamparm *); 100 int (*set_parm)(struct soc_camera_device *, struct v4l2_streamparm *);
101 int (*enum_fsizes)(struct soc_camera_device *, struct v4l2_frmsizeenum *);
89 unsigned int (*poll)(struct file *, poll_table *); 102 unsigned int (*poll)(struct file *, poll_table *);
90 const struct v4l2_queryctrl *controls; 103 const struct v4l2_queryctrl *controls;
91 int num_controls; 104 int num_controls;
@@ -96,8 +109,15 @@ struct soc_camera_host_ops {
96#define SOCAM_SENSOR_INVERT_HSYNC (1 << 2) 109#define SOCAM_SENSOR_INVERT_HSYNC (1 << 2)
97#define SOCAM_SENSOR_INVERT_VSYNC (1 << 3) 110#define SOCAM_SENSOR_INVERT_VSYNC (1 << 3)
98#define SOCAM_SENSOR_INVERT_DATA (1 << 4) 111#define SOCAM_SENSOR_INVERT_DATA (1 << 4)
112#define SOCAM_MIPI_1LANE (1 << 5)
113#define SOCAM_MIPI_2LANE (1 << 6)
114#define SOCAM_MIPI_3LANE (1 << 7)
115#define SOCAM_MIPI_4LANE (1 << 8)
116#define SOCAM_MIPI (SOCAM_MIPI_1LANE | SOCAM_MIPI_2LANE | \
117 SOCAM_MIPI_3LANE | SOCAM_MIPI_4LANE)
99 118
100struct i2c_board_info; 119struct i2c_board_info;
120struct regulator_bulk_data;
101 121
102struct soc_camera_link { 122struct soc_camera_link {
103 /* Camera bus id, used to match a camera and a bus */ 123 /* Camera bus id, used to match a camera and a bus */
@@ -109,6 +129,10 @@ struct soc_camera_link {
109 const char *module_name; 129 const char *module_name;
110 void *priv; 130 void *priv;
111 131
132 /* Optional regulators that have to be managed on power on/off events */
133 struct regulator_bulk_data *regulators;
134 int num_regulators;
135
112 /* 136 /*
113 * For non-I2C devices platform platform has to provide methods to 137 * For non-I2C devices platform platform has to provide methods to
114 * add a device to the system and to remove 138 * add a device to the system and to remove
@@ -255,6 +279,7 @@ static inline unsigned long soc_camera_bus_param_compatible(
255 unsigned long camera_flags, unsigned long bus_flags) 279 unsigned long camera_flags, unsigned long bus_flags)
256{ 280{
257 unsigned long common_flags, hsync, vsync, pclk, data, buswidth, mode; 281 unsigned long common_flags, hsync, vsync, pclk, data, buswidth, mode;
282 unsigned long mipi;
258 283
259 common_flags = camera_flags & bus_flags; 284 common_flags = camera_flags & bus_flags;
260 285
@@ -264,8 +289,9 @@ static inline unsigned long soc_camera_bus_param_compatible(
264 data = common_flags & (SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATA_ACTIVE_LOW); 289 data = common_flags & (SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATA_ACTIVE_LOW);
265 mode = common_flags & (SOCAM_MASTER | SOCAM_SLAVE); 290 mode = common_flags & (SOCAM_MASTER | SOCAM_SLAVE);
266 buswidth = common_flags & SOCAM_DATAWIDTH_MASK; 291 buswidth = common_flags & SOCAM_DATAWIDTH_MASK;
292 mipi = common_flags & SOCAM_MIPI;
267 293
268 return (!hsync || !vsync || !pclk || !data || !mode || !buswidth) ? 0 : 294 return ((!hsync || !vsync || !pclk || !data || !mode || !buswidth) && !mipi) ? 0 :
269 common_flags; 295 common_flags;
270} 296}
271 297
@@ -295,4 +321,17 @@ static inline struct video_device *soc_camera_i2c_to_vdev(struct i2c_client *cli
295 return icd->vdev; 321 return icd->vdev;
296} 322}
297 323
324static inline struct soc_camera_device *soc_camera_from_vb2q(struct vb2_queue *vq)
325{
326 return container_of(vq, struct soc_camera_device, vb2_vidq);
327}
328
329static inline struct soc_camera_device *soc_camera_from_vbq(struct videobuf_queue *vq)
330{
331 return container_of(vq, struct soc_camera_device, vb_vidq);
332}
333
334void soc_camera_lock(struct vb2_queue *vq);
335void soc_camera_unlock(struct vb2_queue *vq);
336
298#endif 337#endif
diff --git a/include/media/soc_camera_platform.h b/include/media/soc_camera_platform.h
index 0ecefe227b76..6d7a4fd00fc0 100644
--- a/include/media/soc_camera_platform.h
+++ b/include/media/soc_camera_platform.h
@@ -25,4 +25,54 @@ struct soc_camera_platform_info {
25 int (*set_capture)(struct soc_camera_platform_info *info, int enable); 25 int (*set_capture)(struct soc_camera_platform_info *info, int enable);
26}; 26};
27 27
28static inline void soc_camera_platform_release(struct platform_device **pdev)
29{
30 *pdev = NULL;
31}
32
33static inline int soc_camera_platform_add(const struct soc_camera_link *icl,
34 struct device *dev,
35 struct platform_device **pdev,
36 struct soc_camera_link *plink,
37 void (*release)(struct device *dev),
38 int id)
39{
40 struct soc_camera_platform_info *info = plink->priv;
41 int ret;
42
43 if (icl != plink)
44 return -ENODEV;
45
46 if (*pdev)
47 return -EBUSY;
48
49 *pdev = platform_device_alloc("soc_camera_platform", id);
50 if (!*pdev)
51 return -ENOMEM;
52
53 info->dev = dev;
54
55 (*pdev)->dev.platform_data = info;
56 (*pdev)->dev.release = release;
57
58 ret = platform_device_add(*pdev);
59 if (ret < 0) {
60 platform_device_put(*pdev);
61 *pdev = NULL;
62 info->dev = NULL;
63 }
64
65 return ret;
66}
67
68static inline void soc_camera_platform_del(const struct soc_camera_link *icl,
69 struct platform_device *pdev,
70 const struct soc_camera_link *plink)
71{
72 if (icl != plink || !pdev)
73 return;
74
75 platform_device_unregister(pdev);
76}
77
28#endif /* __SOC_CAMERA_H__ */ 78#endif /* __SOC_CAMERA_H__ */
diff --git a/include/media/soc_mediabus.h b/include/media/soc_mediabus.h
index 037cd7be001e..fae432544b41 100644
--- a/include/media/soc_mediabus.h
+++ b/include/media/soc_mediabus.h
@@ -12,23 +12,28 @@
12#define SOC_MEDIABUS_H 12#define SOC_MEDIABUS_H
13 13
14#include <linux/videodev2.h> 14#include <linux/videodev2.h>
15 15#include <linux/v4l2-mediabus.h>
16#include <media/v4l2-mediabus.h>
17 16
18/** 17/**
19 * enum soc_mbus_packing - data packing types on the media-bus 18 * enum soc_mbus_packing - data packing types on the media-bus
20 * @SOC_MBUS_PACKING_NONE: no packing, bit-for-bit transfer to RAM 19 * @SOC_MBUS_PACKING_NONE: no packing, bit-for-bit transfer to RAM, one
20 * sample represents one pixel
21 * @SOC_MBUS_PACKING_2X8_PADHI: 16 bits transferred in 2 8-bit samples, in the 21 * @SOC_MBUS_PACKING_2X8_PADHI: 16 bits transferred in 2 8-bit samples, in the
22 * possibly incomplete byte high bits are padding 22 * possibly incomplete byte high bits are padding
23 * @SOC_MBUS_PACKING_2X8_PADLO: as above, but low bits are padding 23 * @SOC_MBUS_PACKING_2X8_PADLO: as above, but low bits are padding
24 * @SOC_MBUS_PACKING_EXTEND16: sample width (e.g., 10 bits) has to be extended 24 * @SOC_MBUS_PACKING_EXTEND16: sample width (e.g., 10 bits) has to be extended
25 * to 16 bits 25 * to 16 bits
26 * @SOC_MBUS_PACKING_VARIABLE: compressed formats with variable packing
27 * @SOC_MBUS_PACKING_1_5X8: used for packed YUV 4:2:0 formats, where 4
28 * pixels occupy 6 bytes in RAM
26 */ 29 */
27enum soc_mbus_packing { 30enum soc_mbus_packing {
28 SOC_MBUS_PACKING_NONE, 31 SOC_MBUS_PACKING_NONE,
29 SOC_MBUS_PACKING_2X8_PADHI, 32 SOC_MBUS_PACKING_2X8_PADHI,
30 SOC_MBUS_PACKING_2X8_PADLO, 33 SOC_MBUS_PACKING_2X8_PADLO,
31 SOC_MBUS_PACKING_EXTEND16, 34 SOC_MBUS_PACKING_EXTEND16,
35 SOC_MBUS_PACKING_VARIABLE,
36 SOC_MBUS_PACKING_1_5X8,
32}; 37};
33 38
34/** 39/**
@@ -58,8 +63,24 @@ struct soc_mbus_pixelfmt {
58 u8 bits_per_sample; 63 u8 bits_per_sample;
59}; 64};
60 65
66/**
67 * struct soc_mbus_lookup - Lookup FOURCC IDs by mediabus codes for pass-through
68 * @code: mediabus pixel-code
69 * @fmt: pixel format description
70 */
71struct soc_mbus_lookup {
72 enum v4l2_mbus_pixelcode code;
73 struct soc_mbus_pixelfmt fmt;
74};
75
76const struct soc_mbus_pixelfmt *soc_mbus_find_fmtdesc(
77 enum v4l2_mbus_pixelcode code,
78 const struct soc_mbus_lookup *lookup,
79 int n);
61const struct soc_mbus_pixelfmt *soc_mbus_get_fmtdesc( 80const struct soc_mbus_pixelfmt *soc_mbus_get_fmtdesc(
62 enum v4l2_mbus_pixelcode code); 81 enum v4l2_mbus_pixelcode code);
63s32 soc_mbus_bytes_per_line(u32 width, const struct soc_mbus_pixelfmt *mf); 82s32 soc_mbus_bytes_per_line(u32 width, const struct soc_mbus_pixelfmt *mf);
83int soc_mbus_samples_per_pixel(const struct soc_mbus_pixelfmt *mf,
84 unsigned int *numerator, unsigned int *denominator);
64 85
65#endif 86#endif
diff --git a/include/media/sr030pc30.h b/include/media/sr030pc30.h
new file mode 100644
index 000000000000..6f901a653ba2
--- /dev/null
+++ b/include/media/sr030pc30.h
@@ -0,0 +1,21 @@
1/*
2 * Driver header for SR030PC30 camera sensor
3 *
4 * Copyright (c) 2010 Samsung Electronics, Co. Ltd
5 * Contact: Sylwester Nawrocki <s.nawrocki@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13#ifndef SR030PC30_H
14#define SR030PC30_H
15
16struct sr030pc30_platform_data {
17 unsigned long clk_rate; /* master clock frequency in Hz */
18 int (*set_power)(struct device *dev, int on);
19};
20
21#endif /* SR030PC30_H */
diff --git a/include/media/timb_radio.h b/include/media/timb_radio.h
index fcd32a3696ba..a59a84854dc1 100644
--- a/include/media/timb_radio.h
+++ b/include/media/timb_radio.h
@@ -24,7 +24,6 @@
24struct timb_radio_platform_data { 24struct timb_radio_platform_data {
25 int i2c_adapter; /* I2C adapter where the tuner and dsp are attached */ 25 int i2c_adapter; /* I2C adapter where the tuner and dsp are attached */
26 struct { 26 struct {
27 const char *module_name;
28 struct i2c_board_info *info; 27 struct i2c_board_info *info;
29 } tuner; 28 } tuner;
30 struct { 29 struct {
diff --git a/include/media/timb_video.h b/include/media/timb_video.h
new file mode 100644
index 000000000000..70ae43970a49
--- /dev/null
+++ b/include/media/timb_video.h
@@ -0,0 +1,33 @@
1/*
2 * timb_video.h Platform struct for the Timberdale video driver
3 * Copyright (c) 2009-2010 Intel Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19#ifndef _TIMB_VIDEO_
20#define _TIMB_VIDEO_ 1
21
22#include <linux/i2c.h>
23
24struct timb_video_platform_data {
25 int dma_channel;
26 int i2c_adapter; /* The I2C adapter where the encoder is attached */
27 struct {
28 const char *module_name;
29 struct i2c_board_info *info;
30 } encoder;
31};
32
33#endif
diff --git a/include/media/tuner.h b/include/media/tuner.h
index 51811eac46f1..963e33471835 100644
--- a/include/media/tuner.h
+++ b/include/media/tuner.h
@@ -21,6 +21,7 @@
21 21
22#ifndef _TUNER_H 22#ifndef _TUNER_H
23#define _TUNER_H 23#define _TUNER_H
24#ifdef __KERNEL__
24 25
25#include <linux/videodev2.h> 26#include <linux/videodev2.h>
26 27
@@ -131,6 +132,7 @@
131#define TUNER_NXP_TDA18271 83 132#define TUNER_NXP_TDA18271 83
132#define TUNER_SONY_BTF_PXN01Z 84 133#define TUNER_SONY_BTF_PXN01Z 84
133#define TUNER_PHILIPS_FQ1236_MK5 85 /* NTSC, TDA9885, no FM radio */ 134#define TUNER_PHILIPS_FQ1236_MK5 85 /* NTSC, TDA9885, no FM radio */
135#define TUNER_TENA_TNF_5337 86
134 136
135/* tv card specific */ 137/* tv card specific */
136#define TDA9887_PRESENT (1<<0) 138#define TDA9887_PRESENT (1<<0)
@@ -156,14 +158,10 @@
156#define TDA9887_GAIN_NORMAL (1<<20) 158#define TDA9887_GAIN_NORMAL (1<<20)
157#define TDA9887_RIF_41_3 (1<<21) /* radio IF1 41.3 vs 33.3 */ 159#define TDA9887_RIF_41_3 (1<<21) /* radio IF1 41.3 vs 33.3 */
158 160
159#ifdef __KERNEL__
160
161enum tuner_mode { 161enum tuner_mode {
162 T_UNINITIALIZED = 0,
163 T_RADIO = 1 << V4L2_TUNER_RADIO, 162 T_RADIO = 1 << V4L2_TUNER_RADIO,
164 T_ANALOG_TV = 1 << V4L2_TUNER_ANALOG_TV, 163 T_ANALOG_TV = 1 << V4L2_TUNER_ANALOG_TV,
165 T_DIGITAL_TV = 1 << V4L2_TUNER_DIGITAL_TV, 164 /* Don't need to map V4L2_TUNER_DIGITAL_TV, as tuner-core won't use it */
166 T_STANDBY = 1 << 31
167}; 165};
168 166
169/* Older boards only had a single tuner device. Nowadays multiple tuner 167/* Older boards only had a single tuner device. Nowadays multiple tuner
@@ -193,11 +191,3 @@ struct tuner_setup {
193#endif /* __KERNEL__ */ 191#endif /* __KERNEL__ */
194 192
195#endif /* _TUNER_H */ 193#endif /* _TUNER_H */
196
197/*
198 * Overrides for Emacs so that we follow Linus's tabbing style.
199 * ---------------------------------------------------------------------------
200 * Local variables:
201 * c-basic-offset: 8
202 * End:
203 */
diff --git a/include/media/v4l2-chip-ident.h b/include/media/v4l2-chip-ident.h
index 21b4428c12ab..b3edb67a8311 100644
--- a/include/media/v4l2-chip-ident.h
+++ b/include/media/v4l2-chip-ident.h
@@ -38,6 +38,9 @@ enum {
38 /* module tvaudio: reserved range 50-99 */ 38 /* module tvaudio: reserved range 50-99 */
39 V4L2_IDENT_TVAUDIO = 50, /* A tvaudio chip, unknown which it is exactly */ 39 V4L2_IDENT_TVAUDIO = 50, /* A tvaudio chip, unknown which it is exactly */
40 40
41 /* Sony IMX074 */
42 V4L2_IDENT_IMX074 = 74,
43
41 /* module saa7110: just ident 100 */ 44 /* module saa7110: just ident 100 */
42 V4L2_IDENT_SAA7110 = 100, 45 V4L2_IDENT_SAA7110 = 100,
43 46
@@ -70,6 +73,9 @@ enum {
70 V4L2_IDENT_OV9655 = 255, 73 V4L2_IDENT_OV9655 = 255,
71 V4L2_IDENT_SOI968 = 256, 74 V4L2_IDENT_SOI968 = 256,
72 V4L2_IDENT_OV9640 = 257, 75 V4L2_IDENT_OV9640 = 257,
76 V4L2_IDENT_OV6650 = 258,
77 V4L2_IDENT_OV2640 = 259,
78 V4L2_IDENT_OV9740 = 260,
73 79
74 /* module saa7146: reserved range 300-309 */ 80 /* module saa7146: reserved range 300-309 */
75 V4L2_IDENT_SAA7146 = 300, 81 V4L2_IDENT_SAA7146 = 300,
@@ -111,6 +117,10 @@ enum {
111 V4L2_IDENT_VPX3216B = 3216, 117 V4L2_IDENT_VPX3216B = 3216,
112 V4L2_IDENT_VPX3220A = 3220, 118 V4L2_IDENT_VPX3220A = 3220,
113 119
120 /* VX855 just ident 3409 */
121 /* Other via devs could use 3314, 3324, 3327, 3336, 3364, 3353 */
122 V4L2_IDENT_VIA_VX855 = 3409,
123
114 /* module tvp5150 */ 124 /* module tvp5150 */
115 V4L2_IDENT_TVP5150 = 5150, 125 V4L2_IDENT_TVP5150 = 5150,
116 126
@@ -200,6 +210,9 @@ enum {
200 /* module sn9c20x: just ident 10000 */ 210 /* module sn9c20x: just ident 10000 */
201 V4L2_IDENT_SN9C20X = 10000, 211 V4L2_IDENT_SN9C20X = 10000,
202 212
213 /* Siliconfile sensors: reserved range 10100 - 10199 */
214 V4L2_IDENT_NOON010PC30 = 10100,
215
203 /* module cx231xx and cx25840 */ 216 /* module cx231xx and cx25840 */
204 V4L2_IDENT_CX2310X_AV = 23099, /* Integrated A/V decoder; not in '100 */ 217 V4L2_IDENT_CX2310X_AV = 23099, /* Integrated A/V decoder; not in '100 */
205 V4L2_IDENT_CX23100 = 23100, 218 V4L2_IDENT_CX23100 = 23100,
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
index 98b32645e5a7..a298ec49ddc4 100644
--- a/include/media/v4l2-common.h
+++ b/include/media/v4l2-common.h
@@ -80,30 +80,15 @@
80 80
81/* ------------------------------------------------------------------------- */ 81/* ------------------------------------------------------------------------- */
82 82
83/* Priority helper functions */
84
85struct v4l2_prio_state {
86 atomic_t prios[4];
87};
88void v4l2_prio_init(struct v4l2_prio_state *global);
89int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local,
90 enum v4l2_priority new);
91void v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local);
92void v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority local);
93enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global);
94int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority local);
95
96/* ------------------------------------------------------------------------- */
97
98/* Control helper functions */ 83/* Control helper functions */
99 84
100int v4l2_ctrl_check(struct v4l2_ext_control *ctrl, struct v4l2_queryctrl *qctrl, 85int v4l2_ctrl_check(struct v4l2_ext_control *ctrl, struct v4l2_queryctrl *qctrl,
101 const char **menu_items); 86 const char * const *menu_items);
102const char *v4l2_ctrl_get_name(u32 id); 87const char *v4l2_ctrl_get_name(u32 id);
103const char **v4l2_ctrl_get_menu(u32 id); 88const char * const *v4l2_ctrl_get_menu(u32 id);
104int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 step, s32 def); 89int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 step, s32 def);
105int v4l2_ctrl_query_menu(struct v4l2_querymenu *qmenu, 90int v4l2_ctrl_query_menu(struct v4l2_querymenu *qmenu,
106 struct v4l2_queryctrl *qctrl, const char **menu_items); 91 struct v4l2_queryctrl *qctrl, const char * const *menu_items);
107#define V4L2_CTRL_MENU_IDS_END (0xffffffff) 92#define V4L2_CTRL_MENU_IDS_END (0xffffffff)
108int v4l2_ctrl_query_menu_valid_items(struct v4l2_querymenu *qmenu, const u32 *ids); 93int v4l2_ctrl_query_menu_valid_items(struct v4l2_querymenu *qmenu, const u32 *ids);
109 94
@@ -137,31 +122,16 @@ struct v4l2_subdev_ops;
137 122
138 123
139/* Load an i2c module and return an initialized v4l2_subdev struct. 124/* Load an i2c module and return an initialized v4l2_subdev struct.
140 Only call request_module if module_name != NULL.
141 The client_type argument is the name of the chip that's on the adapter. */ 125 The client_type argument is the name of the chip that's on the adapter. */
142struct v4l2_subdev *v4l2_i2c_new_subdev_cfg(struct v4l2_device *v4l2_dev, 126struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev,
143 struct i2c_adapter *adapter, 127 struct i2c_adapter *adapter, const char *client_type,
144 const char *module_name, const char *client_type,
145 int irq, void *platform_data,
146 u8 addr, const unsigned short *probe_addrs); 128 u8 addr, const unsigned short *probe_addrs);
147 129
148/* Load an i2c module and return an initialized v4l2_subdev struct.
149 Only call request_module if module_name != NULL.
150 The client_type argument is the name of the chip that's on the adapter. */
151static inline struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev,
152 struct i2c_adapter *adapter,
153 const char *module_name, const char *client_type,
154 u8 addr, const unsigned short *probe_addrs)
155{
156 return v4l2_i2c_new_subdev_cfg(v4l2_dev, adapter, module_name,
157 client_type, 0, NULL, addr, probe_addrs);
158}
159
160struct i2c_board_info; 130struct i2c_board_info;
161 131
162struct v4l2_subdev *v4l2_i2c_new_subdev_board(struct v4l2_device *v4l2_dev, 132struct v4l2_subdev *v4l2_i2c_new_subdev_board(struct v4l2_device *v4l2_dev,
163 struct i2c_adapter *adapter, const char *module_name, 133 struct i2c_adapter *adapter, struct i2c_board_info *info,
164 struct i2c_board_info *info, const unsigned short *probe_addrs); 134 const unsigned short *probe_addrs);
165 135
166/* Initialize an v4l2_subdev with data from an i2c_client struct */ 136/* Initialize an v4l2_subdev with data from an i2c_client struct */
167void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client, 137void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client,
@@ -232,4 +202,14 @@ void v4l_bound_align_image(unsigned int *w, unsigned int wmin,
232 unsigned int hmax, unsigned int halign, 202 unsigned int hmax, unsigned int halign,
233 unsigned int salign); 203 unsigned int salign);
234int v4l_fill_dv_preset_info(u32 preset, struct v4l2_dv_enum_preset *info); 204int v4l_fill_dv_preset_info(u32 preset, struct v4l2_dv_enum_preset *info);
205
206struct v4l2_discrete_probe {
207 const struct v4l2_frmsize_discrete *sizes;
208 int num_sizes;
209};
210
211const struct v4l2_frmsize_discrete *v4l2_find_nearest_format(
212 const struct v4l2_discrete_probe *probe,
213 s32 width, s32 height);
214
235#endif /* V4L2_COMMON_H_ */ 215#endif /* V4L2_COMMON_H_ */
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index 9b7bea928a88..97d063837b61 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -23,6 +23,7 @@
23 23
24#include <linux/list.h> 24#include <linux/list.h>
25#include <linux/device.h> 25#include <linux/device.h>
26#include <linux/videodev2.h>
26 27
27/* forward references */ 28/* forward references */
28struct v4l2_ctrl_handler; 29struct v4l2_ctrl_handler;
@@ -53,8 +54,10 @@ struct v4l2_ctrl_ops {
53 * @handler: The handler that owns the control. 54 * @handler: The handler that owns the control.
54 * @cluster: Point to start of cluster array. 55 * @cluster: Point to start of cluster array.
55 * @ncontrols: Number of controls in cluster array. 56 * @ncontrols: Number of controls in cluster array.
56 * @has_new: Internal flag: set when there is a valid new value.
57 * @done: Internal flag: set for each processed control. 57 * @done: Internal flag: set for each processed control.
58 * @is_new: Set when the user specified a new value for this control. It
59 * is also set when called from v4l2_ctrl_handler_setup. Drivers
60 * should never set this flag.
58 * @is_private: If set, then this control is private to its handler and it 61 * @is_private: If set, then this control is private to its handler and it
59 * will not be added to any other handlers. Drivers can set 62 * will not be added to any other handlers. Drivers can set
60 * this flag. 63 * this flag.
@@ -97,9 +100,9 @@ struct v4l2_ctrl {
97 struct v4l2_ctrl_handler *handler; 100 struct v4l2_ctrl_handler *handler;
98 struct v4l2_ctrl **cluster; 101 struct v4l2_ctrl **cluster;
99 unsigned ncontrols; 102 unsigned ncontrols;
100 unsigned int has_new:1;
101 unsigned int done:1; 103 unsigned int done:1;
102 104
105 unsigned int is_new:1;
103 unsigned int is_private:1; 106 unsigned int is_private:1;
104 unsigned int is_volatile:1; 107 unsigned int is_volatile:1;
105 108
@@ -112,7 +115,7 @@ struct v4l2_ctrl {
112 u32 step; 115 u32 step;
113 u32 menu_skip_mask; 116 u32 menu_skip_mask;
114 }; 117 };
115 const char **qmenu; 118 const char * const *qmenu;
116 unsigned long flags; 119 unsigned long flags;
117 union { 120 union {
118 s32 val; 121 s32 val;
@@ -202,7 +205,7 @@ struct v4l2_ctrl_config {
202 s32 def; 205 s32 def;
203 u32 flags; 206 u32 flags;
204 u32 menu_skip_mask; 207 u32 menu_skip_mask;
205 const char **qmenu; 208 const char * const *qmenu;
206 unsigned int is_private:1; 209 unsigned int is_private:1;
207 unsigned int is_volatile:1; 210 unsigned int is_volatile:1;
208}; 211};
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index 1efcacbed01a..c7c40f1d2624 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -16,12 +16,14 @@
16#include <linux/mutex.h> 16#include <linux/mutex.h>
17#include <linux/videodev2.h> 17#include <linux/videodev2.h>
18 18
19#include <media/media-entity.h>
20
19#define VIDEO_MAJOR 81 21#define VIDEO_MAJOR 81
20 22
21#define VFL_TYPE_GRABBER 0 23#define VFL_TYPE_GRABBER 0
22#define VFL_TYPE_VBI 1 24#define VFL_TYPE_VBI 1
23#define VFL_TYPE_RADIO 2 25#define VFL_TYPE_RADIO 2
24#define VFL_TYPE_VTX 3 26#define VFL_TYPE_SUBDEV 3
25#define VFL_TYPE_MAX 4 27#define VFL_TYPE_MAX 4
26 28
27struct v4l2_ioctl_callbacks; 29struct v4l2_ioctl_callbacks;
@@ -33,7 +35,25 @@ struct v4l2_ctrl_handler;
33 Drivers can clear this flag if they want to block all future 35 Drivers can clear this flag if they want to block all future
34 device access. It is cleared by video_unregister_device. */ 36 device access. It is cleared by video_unregister_device. */
35#define V4L2_FL_REGISTERED (0) 37#define V4L2_FL_REGISTERED (0)
38/* file->private_data points to struct v4l2_fh */
36#define V4L2_FL_USES_V4L2_FH (1) 39#define V4L2_FL_USES_V4L2_FH (1)
40/* Use the prio field of v4l2_fh for core priority checking */
41#define V4L2_FL_USE_FH_PRIO (2)
42
43/* Priority helper functions */
44
45struct v4l2_prio_state {
46 atomic_t prios[4];
47};
48
49void v4l2_prio_init(struct v4l2_prio_state *global);
50int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local,
51 enum v4l2_priority new);
52void v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local);
53void v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority local);
54enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global);
55int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority local);
56
37 57
38struct v4l2_file_operations { 58struct v4l2_file_operations {
39 struct module *owner; 59 struct module *owner;
@@ -57,6 +77,9 @@ struct v4l2_file_operations {
57 77
58struct video_device 78struct video_device
59{ 79{
80#if defined(CONFIG_MEDIA_CONTROLLER)
81 struct media_entity entity;
82#endif
60 /* device ops */ 83 /* device ops */
61 const struct v4l2_file_operations *fops; 84 const struct v4l2_file_operations *fops;
62 85
@@ -71,6 +94,9 @@ struct video_device
71 /* Control handler associated with this device node. May be NULL. */ 94 /* Control handler associated with this device node. May be NULL. */
72 struct v4l2_ctrl_handler *ctrl_handler; 95 struct v4l2_ctrl_handler *ctrl_handler;
73 96
97 /* Priority state. If NULL, then v4l2_dev->prio will be used. */
98 struct v4l2_prio_state *prio;
99
74 /* device info */ 100 /* device info */
75 char name[32]; 101 char name[32];
76 int vfl_type; 102 int vfl_type;
@@ -97,20 +123,36 @@ struct video_device
97 123
98 /* ioctl callbacks */ 124 /* ioctl callbacks */
99 const struct v4l2_ioctl_ops *ioctl_ops; 125 const struct v4l2_ioctl_ops *ioctl_ops;
126
127 /* serialization lock */
128 struct mutex *lock;
100}; 129};
101 130
131#define media_entity_to_video_device(__e) \
132 container_of(__e, struct video_device, entity)
102/* dev to video-device */ 133/* dev to video-device */
103#define to_video_device(cd) container_of(cd, struct video_device, dev) 134#define to_video_device(cd) container_of(cd, struct video_device, dev)
104 135
136int __must_check __video_register_device(struct video_device *vdev, int type,
137 int nr, int warn_if_nr_in_use, struct module *owner);
138
105/* Register video devices. Note that if video_register_device fails, 139/* Register video devices. Note that if video_register_device fails,
106 the release() callback of the video_device structure is *not* called, so 140 the release() callback of the video_device structure is *not* called, so
107 the caller is responsible for freeing any data. Usually that means that 141 the caller is responsible for freeing any data. Usually that means that
108 you call video_device_release() on failure. */ 142 you call video_device_release() on failure. */
109int __must_check video_register_device(struct video_device *vdev, int type, int nr); 143static inline int __must_check video_register_device(struct video_device *vdev,
144 int type, int nr)
145{
146 return __video_register_device(vdev, type, nr, 1, vdev->fops->owner);
147}
110 148
111/* Same as video_register_device, but no warning is issued if the desired 149/* Same as video_register_device, but no warning is issued if the desired
112 device node number was already in use. */ 150 device node number was already in use. */
113int __must_check video_register_device_no_warn(struct video_device *vdev, int type, int nr); 151static inline int __must_check video_register_device_no_warn(
152 struct video_device *vdev, int type, int nr)
153{
154 return __video_register_device(vdev, type, nr, 0, vdev->fops->owner);
155}
114 156
115/* Unregister video devices. Will do nothing if vdev == NULL or 157/* Unregister video devices. Will do nothing if vdev == NULL or
116 video_is_registered() returns false. */ 158 video_is_registered() returns false. */
diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
index 8bcbd7a0271c..d61febfb1668 100644
--- a/include/media/v4l2-device.h
+++ b/include/media/v4l2-device.h
@@ -21,7 +21,9 @@
21#ifndef _V4L2_DEVICE_H 21#ifndef _V4L2_DEVICE_H
22#define _V4L2_DEVICE_H 22#define _V4L2_DEVICE_H
23 23
24#include <media/media-device.h>
24#include <media/v4l2-subdev.h> 25#include <media/v4l2-subdev.h>
26#include <media/v4l2-dev.h>
25 27
26/* Each instance of a V4L2 device should create the v4l2_device struct, 28/* Each instance of a V4L2 device should create the v4l2_device struct,
27 either stand-alone or embedded in a larger struct. 29 either stand-alone or embedded in a larger struct.
@@ -39,6 +41,9 @@ struct v4l2_device {
39 Note: dev might be NULL if there is no parent device 41 Note: dev might be NULL if there is no parent device
40 as is the case with e.g. ISA devices. */ 42 as is the case with e.g. ISA devices. */
41 struct device *dev; 43 struct device *dev;
44#if defined(CONFIG_MEDIA_CONTROLLER)
45 struct media_device *mdev;
46#endif
42 /* used to keep track of the registered subdevs */ 47 /* used to keep track of the registered subdevs */
43 struct list_head subdevs; 48 struct list_head subdevs;
44 /* lock this struct; can be used by the driver as well if this 49 /* lock this struct; can be used by the driver as well if this
@@ -51,8 +56,23 @@ struct v4l2_device {
51 unsigned int notification, void *arg); 56 unsigned int notification, void *arg);
52 /* The control handler. May be NULL. */ 57 /* The control handler. May be NULL. */
53 struct v4l2_ctrl_handler *ctrl_handler; 58 struct v4l2_ctrl_handler *ctrl_handler;
59 /* Device's priority state */
60 struct v4l2_prio_state prio;
61 /* BKL replacement mutex. Temporary solution only. */
62 struct mutex ioctl_lock;
63 /* Keep track of the references to this struct. */
64 struct kref ref;
65 /* Release function that is called when the ref count goes to 0. */
66 void (*release)(struct v4l2_device *v4l2_dev);
54}; 67};
55 68
69static inline void v4l2_device_get(struct v4l2_device *v4l2_dev)
70{
71 kref_get(&v4l2_dev->ref);
72}
73
74int v4l2_device_put(struct v4l2_device *v4l2_dev);
75
56/* Initialize v4l2_dev and make dev->driver_data point to v4l2_dev. 76/* Initialize v4l2_dev and make dev->driver_data point to v4l2_dev.
57 dev may be NULL in rare cases (ISA devices). In that case you 77 dev may be NULL in rare cases (ISA devices). In that case you
58 must fill in the v4l2_dev->name field before calling this function. */ 78 must fill in the v4l2_dev->name field before calling this function. */
@@ -94,6 +114,12 @@ int __must_check v4l2_device_register_subdev(struct v4l2_device *v4l2_dev,
94 wasn't registered. In that case it will do nothing. */ 114 wasn't registered. In that case it will do nothing. */
95void v4l2_device_unregister_subdev(struct v4l2_subdev *sd); 115void v4l2_device_unregister_subdev(struct v4l2_subdev *sd);
96 116
117/* Register device nodes for all subdev of the v4l2 device that are marked with
118 * the V4L2_SUBDEV_FL_HAS_DEVNODE flag.
119 */
120int __must_check
121v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev);
122
97/* Iterate over all subdevs. */ 123/* Iterate over all subdevs. */
98#define v4l2_device_for_each_subdev(sd, v4l2_dev) \ 124#define v4l2_device_for_each_subdev(sd, v4l2_dev) \
99 list_for_each_entry(sd, &(v4l2_dev)->subdevs, list) 125 list_for_each_entry(sd, &(v4l2_dev)->subdevs, list)
@@ -101,46 +127,67 @@ void v4l2_device_unregister_subdev(struct v4l2_subdev *sd);
101/* Call the specified callback for all subdevs matching the condition. 127/* Call the specified callback for all subdevs matching the condition.
102 Ignore any errors. Note that you cannot add or delete a subdev 128 Ignore any errors. Note that you cannot add or delete a subdev
103 while walking the subdevs list. */ 129 while walking the subdevs list. */
104#define __v4l2_device_call_subdevs(v4l2_dev, cond, o, f, args...) \ 130#define __v4l2_device_call_subdevs_p(v4l2_dev, sd, cond, o, f, args...) \
105 do { \ 131 do { \
106 struct v4l2_subdev *sd; \ 132 list_for_each_entry((sd), &(v4l2_dev)->subdevs, list) \
133 if ((cond) && (sd)->ops->o && (sd)->ops->o->f) \
134 (sd)->ops->o->f((sd) , ##args); \
135 } while (0)
136
137#define __v4l2_device_call_subdevs(v4l2_dev, cond, o, f, args...) \
138 do { \
139 struct v4l2_subdev *__sd; \
107 \ 140 \
108 list_for_each_entry(sd, &(v4l2_dev)->subdevs, list) \ 141 __v4l2_device_call_subdevs_p(v4l2_dev, __sd, cond, o, \
109 if ((cond) && sd->ops->o && sd->ops->o->f) \ 142 f , ##args); \
110 sd->ops->o->f(sd , ##args); \
111 } while (0) 143 } while (0)
112 144
113/* Call the specified callback for all subdevs matching the condition. 145/* Call the specified callback for all subdevs matching the condition.
114 If the callback returns an error other than 0 or -ENOIOCTLCMD, then 146 If the callback returns an error other than 0 or -ENOIOCTLCMD, then
115 return with that error code. Note that you cannot add or delete a 147 return with that error code. Note that you cannot add or delete a
116 subdev while walking the subdevs list. */ 148 subdev while walking the subdevs list. */
117#define __v4l2_device_call_subdevs_until_err(v4l2_dev, cond, o, f, args...) \ 149#define __v4l2_device_call_subdevs_until_err_p(v4l2_dev, sd, cond, o, f, args...) \
118({ \ 150({ \
119 struct v4l2_subdev *sd; \ 151 long __err = 0; \
120 long err = 0; \
121 \ 152 \
122 list_for_each_entry(sd, &(v4l2_dev)->subdevs, list) { \ 153 list_for_each_entry((sd), &(v4l2_dev)->subdevs, list) { \
123 if ((cond) && sd->ops->o && sd->ops->o->f) \ 154 if ((cond) && (sd)->ops->o && (sd)->ops->o->f) \
124 err = sd->ops->o->f(sd , ##args); \ 155 __err = (sd)->ops->o->f((sd) , ##args); \
125 if (err && err != -ENOIOCTLCMD) \ 156 if (__err && __err != -ENOIOCTLCMD) \
126 break; \ 157 break; \
127 } \ 158 } \
128 (err == -ENOIOCTLCMD) ? 0 : err; \ 159 (__err == -ENOIOCTLCMD) ? 0 : __err; \
160})
161
162#define __v4l2_device_call_subdevs_until_err(v4l2_dev, cond, o, f, args...) \
163({ \
164 struct v4l2_subdev *__sd; \
165 __v4l2_device_call_subdevs_until_err_p(v4l2_dev, __sd, cond, o, \
166 f , ##args); \
129}) 167})
130 168
131/* Call the specified callback for all subdevs matching grp_id (if 0, then 169/* Call the specified callback for all subdevs matching grp_id (if 0, then
132 match them all). Ignore any errors. Note that you cannot add or delete 170 match them all). Ignore any errors. Note that you cannot add or delete
133 a subdev while walking the subdevs list. */ 171 a subdev while walking the subdevs list. */
134#define v4l2_device_call_all(v4l2_dev, grpid, o, f, args...) \ 172#define v4l2_device_call_all(v4l2_dev, grpid, o, f, args...) \
135 __v4l2_device_call_subdevs(v4l2_dev, \ 173 do { \
136 !(grpid) || sd->grp_id == (grpid), o, f , ##args) 174 struct v4l2_subdev *__sd; \
175 \
176 __v4l2_device_call_subdevs_p(v4l2_dev, __sd, \
177 !(grpid) || __sd->grp_id == (grpid), o, f , \
178 ##args); \
179 } while (0)
137 180
138/* Call the specified callback for all subdevs matching grp_id (if 0, then 181/* Call the specified callback for all subdevs matching grp_id (if 0, then
139 match them all). If the callback returns an error other than 0 or 182 match them all). If the callback returns an error other than 0 or
140 -ENOIOCTLCMD, then return with that error code. Note that you cannot 183 -ENOIOCTLCMD, then return with that error code. Note that you cannot
141 add or delete a subdev while walking the subdevs list. */ 184 add or delete a subdev while walking the subdevs list. */
142#define v4l2_device_call_until_err(v4l2_dev, grpid, o, f, args...) \ 185#define v4l2_device_call_until_err(v4l2_dev, grpid, o, f, args...) \
143 __v4l2_device_call_subdevs_until_err(v4l2_dev, \ 186({ \
144 !(grpid) || sd->grp_id == (grpid), o, f , ##args) 187 struct v4l2_subdev *__sd; \
188 __v4l2_device_call_subdevs_until_err_p(v4l2_dev, __sd, \
189 !(grpid) || __sd->grp_id == (grpid), o, f , \
190 ##args); \
191})
145 192
146#endif 193#endif
diff --git a/include/media/v4l2-fh.h b/include/media/v4l2-fh.h
index 1d72dde320bf..0206aa55be24 100644
--- a/include/media/v4l2-fh.h
+++ b/include/media/v4l2-fh.h
@@ -35,6 +35,7 @@ struct v4l2_fh {
35 struct list_head list; 35 struct list_head list;
36 struct video_device *vdev; 36 struct video_device *vdev;
37 struct v4l2_events *events; /* events, pending and subscribed */ 37 struct v4l2_events *events; /* events, pending and subscribed */
38 enum v4l2_priority prio;
38}; 39};
39 40
40/* 41/*
@@ -50,8 +51,16 @@ int v4l2_fh_init(struct v4l2_fh *fh, struct video_device *vdev);
50 */ 51 */
51void v4l2_fh_add(struct v4l2_fh *fh); 52void v4l2_fh_add(struct v4l2_fh *fh);
52/* 53/*
54 * Can be used as the open() op of v4l2_file_operations.
55 * It allocates a v4l2_fh and inits and adds it to the video_device associated
56 * with the file pointer.
57 */
58int v4l2_fh_open(struct file *filp);
59/*
53 * Remove file handle from the list of file handles. Must be called in 60 * Remove file handle from the list of file handles. Must be called in
54 * v4l2_file_operations->release() handler if the driver uses v4l2_fh. 61 * v4l2_file_operations->release() handler if the driver uses v4l2_fh.
62 * On error filp->private_data will be NULL, otherwise it will point to
63 * the v4l2_fh struct.
55 */ 64 */
56void v4l2_fh_del(struct v4l2_fh *fh); 65void v4l2_fh_del(struct v4l2_fh *fh);
57/* 66/*
@@ -61,5 +70,25 @@ void v4l2_fh_del(struct v4l2_fh *fh);
61 * driver uses v4l2_fh. 70 * driver uses v4l2_fh.
62 */ 71 */
63void v4l2_fh_exit(struct v4l2_fh *fh); 72void v4l2_fh_exit(struct v4l2_fh *fh);
73/*
74 * Can be used as the release() op of v4l2_file_operations.
75 * It deletes and exits the v4l2_fh associated with the file pointer and
76 * frees it. It will do nothing if filp->private_data (the pointer to the
77 * v4l2_fh struct) is NULL. This function always returns 0.
78 */
79int v4l2_fh_release(struct file *filp);
80/*
81 * Returns 1 if this filehandle is the only filehandle opened for the
82 * associated video_device. If fh is NULL, then it returns 0.
83 */
84int v4l2_fh_is_singular(struct v4l2_fh *fh);
85/*
86 * Helper function with struct file as argument. If filp->private_data is
87 * NULL, then it will return 0.
88 */
89static inline int v4l2_fh_is_singular_file(struct file *filp)
90{
91 return v4l2_fh_is_singular(filp->private_data);
92}
64 93
65#endif /* V4L2_EVENT_H */ 94#endif /* V4L2_EVENT_H */
diff --git a/include/media/v4l2-i2c-drv.h b/include/media/v4l2-i2c-drv.h
deleted file mode 100644
index 74bf741d1a9b..000000000000
--- a/include/media/v4l2-i2c-drv.h
+++ /dev/null
@@ -1,80 +0,0 @@
1/*
2 * v4l2-i2c-drv.h - contains I2C handling code that's identical for
3 * all V4L2 I2C drivers. Use this header if the
4 * I2C driver is only used by drivers converted
5 * to the bus-based I2C API.
6 *
7 * Copyright (C) 2007 Hans Verkuil <hverkuil@xs4all.nl>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU 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., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24/* NOTE: the full version of this header is in the v4l-dvb repository
25 * and allows v4l i2c drivers to be compiled on pre-2.6.26 kernels.
26 * The version of this header as it appears in the kernel is a stripped
27 * version (without all the backwards compatibility stuff) and so it
28 * looks a bit odd.
29 *
30 * If you look at the full version then you will understand the reason
31 * for introducing this header since you really don't want to have all
32 * the tricky backwards compatibility code in each and every i2c driver.
33 *
34 * If the i2c driver will never be compiled for pre-2.6.26 kernels, then
35 * DO NOT USE this header! Just write it as a regular i2c driver.
36 */
37
38#ifndef __V4L2_I2C_DRV_H__
39#define __V4L2_I2C_DRV_H__
40
41#include <media/v4l2-common.h>
42
43struct v4l2_i2c_driver_data {
44 const char * const name;
45 int (*command)(struct i2c_client *client, unsigned int cmd, void *arg);
46 int (*probe)(struct i2c_client *client, const struct i2c_device_id *id);
47 int (*remove)(struct i2c_client *client);
48 int (*suspend)(struct i2c_client *client, pm_message_t state);
49 int (*resume)(struct i2c_client *client);
50 const struct i2c_device_id *id_table;
51};
52
53static struct v4l2_i2c_driver_data v4l2_i2c_data;
54static struct i2c_driver v4l2_i2c_driver;
55
56
57/* Bus-based I2C implementation for kernels >= 2.6.26 */
58
59static int __init v4l2_i2c_drv_init(void)
60{
61 v4l2_i2c_driver.driver.name = v4l2_i2c_data.name;
62 v4l2_i2c_driver.command = v4l2_i2c_data.command;
63 v4l2_i2c_driver.probe = v4l2_i2c_data.probe;
64 v4l2_i2c_driver.remove = v4l2_i2c_data.remove;
65 v4l2_i2c_driver.suspend = v4l2_i2c_data.suspend;
66 v4l2_i2c_driver.resume = v4l2_i2c_data.resume;
67 v4l2_i2c_driver.id_table = v4l2_i2c_data.id_table;
68 return i2c_add_driver(&v4l2_i2c_driver);
69}
70
71
72static void __exit v4l2_i2c_drv_cleanup(void)
73{
74 i2c_del_driver(&v4l2_i2c_driver);
75}
76
77module_init(v4l2_i2c_drv_init);
78module_exit(v4l2_i2c_drv_cleanup);
79
80#endif /* __V4L2_I2C_DRV_H__ */
diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
index 06daa6e8e051..dd9f1e7b8ff7 100644
--- a/include/media/v4l2-ioctl.h
+++ b/include/media/v4l2-ioctl.h
@@ -14,12 +14,7 @@
14#include <linux/device.h> 14#include <linux/device.h>
15#include <linux/mutex.h> 15#include <linux/mutex.h>
16#include <linux/compiler.h> /* need __user */ 16#include <linux/compiler.h> /* need __user */
17#ifdef CONFIG_VIDEO_V4L1_COMPAT
18#define __MIN_V4L1
19#include <linux/videodev.h>
20#else
21#include <linux/videodev2.h> 17#include <linux/videodev2.h>
22#endif
23 18
24struct v4l2_fh; 19struct v4l2_fh;
25 20
@@ -42,6 +37,10 @@ struct v4l2_ioctl_ops {
42 struct v4l2_fmtdesc *f); 37 struct v4l2_fmtdesc *f);
43 int (*vidioc_enum_fmt_vid_out) (struct file *file, void *fh, 38 int (*vidioc_enum_fmt_vid_out) (struct file *file, void *fh,
44 struct v4l2_fmtdesc *f); 39 struct v4l2_fmtdesc *f);
40 int (*vidioc_enum_fmt_vid_cap_mplane)(struct file *file, void *fh,
41 struct v4l2_fmtdesc *f);
42 int (*vidioc_enum_fmt_vid_out_mplane)(struct file *file, void *fh,
43 struct v4l2_fmtdesc *f);
45 int (*vidioc_enum_fmt_type_private)(struct file *file, void *fh, 44 int (*vidioc_enum_fmt_type_private)(struct file *file, void *fh,
46 struct v4l2_fmtdesc *f); 45 struct v4l2_fmtdesc *f);
47 46
@@ -62,6 +61,10 @@ struct v4l2_ioctl_ops {
62 struct v4l2_format *f); 61 struct v4l2_format *f);
63 int (*vidioc_g_fmt_sliced_vbi_out)(struct file *file, void *fh, 62 int (*vidioc_g_fmt_sliced_vbi_out)(struct file *file, void *fh,
64 struct v4l2_format *f); 63 struct v4l2_format *f);
64 int (*vidioc_g_fmt_vid_cap_mplane)(struct file *file, void *fh,
65 struct v4l2_format *f);
66 int (*vidioc_g_fmt_vid_out_mplane)(struct file *file, void *fh,
67 struct v4l2_format *f);
65 int (*vidioc_g_fmt_type_private)(struct file *file, void *fh, 68 int (*vidioc_g_fmt_type_private)(struct file *file, void *fh,
66 struct v4l2_format *f); 69 struct v4l2_format *f);
67 70
@@ -82,6 +85,10 @@ struct v4l2_ioctl_ops {
82 struct v4l2_format *f); 85 struct v4l2_format *f);
83 int (*vidioc_s_fmt_sliced_vbi_out)(struct file *file, void *fh, 86 int (*vidioc_s_fmt_sliced_vbi_out)(struct file *file, void *fh,
84 struct v4l2_format *f); 87 struct v4l2_format *f);
88 int (*vidioc_s_fmt_vid_cap_mplane)(struct file *file, void *fh,
89 struct v4l2_format *f);
90 int (*vidioc_s_fmt_vid_out_mplane)(struct file *file, void *fh,
91 struct v4l2_format *f);
85 int (*vidioc_s_fmt_type_private)(struct file *file, void *fh, 92 int (*vidioc_s_fmt_type_private)(struct file *file, void *fh,
86 struct v4l2_format *f); 93 struct v4l2_format *f);
87 94
@@ -102,6 +109,10 @@ struct v4l2_ioctl_ops {
102 struct v4l2_format *f); 109 struct v4l2_format *f);
103 int (*vidioc_try_fmt_sliced_vbi_out)(struct file *file, void *fh, 110 int (*vidioc_try_fmt_sliced_vbi_out)(struct file *file, void *fh,
104 struct v4l2_format *f); 111 struct v4l2_format *f);
112 int (*vidioc_try_fmt_vid_cap_mplane)(struct file *file, void *fh,
113 struct v4l2_format *f);
114 int (*vidioc_try_fmt_vid_out_mplane)(struct file *file, void *fh,
115 struct v4l2_format *f);
105 int (*vidioc_try_fmt_type_private)(struct file *file, void *fh, 116 int (*vidioc_try_fmt_type_private)(struct file *file, void *fh,
106 struct v4l2_format *f); 117 struct v4l2_format *f);
107 118
@@ -113,10 +124,6 @@ struct v4l2_ioctl_ops {
113 124
114 125
115 int (*vidioc_overlay) (struct file *file, void *fh, unsigned int i); 126 int (*vidioc_overlay) (struct file *file, void *fh, unsigned int i);
116#ifdef CONFIG_VIDEO_V4L1_COMPAT
117 /* buffer type is struct vidio_mbuf * */
118 int (*vidiocgmbuf) (struct file *file, void *fh, struct video_mbuf *p);
119#endif
120 int (*vidioc_g_fbuf) (struct file *file, void *fh, 127 int (*vidioc_g_fbuf) (struct file *file, void *fh,
121 struct v4l2_framebuffer *a); 128 struct v4l2_framebuffer *a);
122 int (*vidioc_s_fbuf) (struct file *file, void *fh, 129 int (*vidioc_s_fbuf) (struct file *file, void *fh,
@@ -263,7 +270,7 @@ struct v4l2_ioctl_ops {
263 270
264 /* For other private ioctls */ 271 /* For other private ioctls */
265 long (*vidioc_default) (struct file *file, void *fh, 272 long (*vidioc_default) (struct file *file, void *fh,
266 int cmd, void *arg); 273 bool valid_prio, int cmd, void *arg);
267}; 274};
268 275
269 276
@@ -300,22 +307,15 @@ extern void v4l_printk_ioctl(unsigned int cmd);
300extern const char *v4l2_field_names[]; 307extern const char *v4l2_field_names[];
301extern const char *v4l2_type_names[]; 308extern const char *v4l2_type_names[];
302 309
303/* Compatibility layer interface -- v4l1-compat module */
304typedef long (*v4l2_kioctl)(struct file *file,
305 unsigned int cmd, void *arg);
306#ifdef CONFIG_VIDEO_V4L1_COMPAT
307long v4l_compat_translate_ioctl(struct file *file,
308 int cmd, void *arg, v4l2_kioctl driver_ioctl);
309#else
310#define v4l_compat_translate_ioctl(file, cmd, arg, ioctl) (-EINVAL)
311#endif
312
313#ifdef CONFIG_COMPAT 310#ifdef CONFIG_COMPAT
314/* 32 Bits compatibility layer for 64 bits processors */ 311/* 32 Bits compatibility layer for 64 bits processors */
315extern long v4l2_compat_ioctl32(struct file *file, unsigned int cmd, 312extern long v4l2_compat_ioctl32(struct file *file, unsigned int cmd,
316 unsigned long arg); 313 unsigned long arg);
317#endif 314#endif
318 315
316typedef long (*v4l2_kioctl)(struct file *file,
317 unsigned int cmd, void *arg);
318
319/* Include support for obsoleted stuff */ 319/* Include support for obsoleted stuff */
320extern long video_usercopy(struct file *file, unsigned int cmd, 320extern long video_usercopy(struct file *file, unsigned int cmd,
321 unsigned long arg, v4l2_kioctl func); 321 unsigned long arg, v4l2_kioctl func);
diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
index f0cf2e7def06..971c7fa29614 100644
--- a/include/media/v4l2-mediabus.h
+++ b/include/media/v4l2-mediabus.h
@@ -11,58 +11,7 @@
11#ifndef V4L2_MEDIABUS_H 11#ifndef V4L2_MEDIABUS_H
12#define V4L2_MEDIABUS_H 12#define V4L2_MEDIABUS_H
13 13
14/* 14#include <linux/v4l2-mediabus.h>
15 * These pixel codes uniquely identify data formats on the media bus. Mostly
16 * they correspond to similarly named V4L2_PIX_FMT_* formats, format 0 is
17 * reserved, V4L2_MBUS_FMT_FIXED shall be used by host-client pairs, where the
18 * data format is fixed. Additionally, "2X8" means that one pixel is transferred
19 * in two 8-bit samples, "BE" or "LE" specify in which order those samples are
20 * transferred over the bus: "LE" means that the least significant bits are
21 * transferred first, "BE" means that the most significant bits are transferred
22 * first, and "PADHI" and "PADLO" define which bits - low or high, in the
23 * incomplete high byte, are filled with padding bits.
24 */
25enum v4l2_mbus_pixelcode {
26 V4L2_MBUS_FMT_FIXED = 1,
27 V4L2_MBUS_FMT_YUYV8_2X8,
28 V4L2_MBUS_FMT_YVYU8_2X8,
29 V4L2_MBUS_FMT_UYVY8_2X8,
30 V4L2_MBUS_FMT_VYUY8_2X8,
31 V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE,
32 V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE,
33 V4L2_MBUS_FMT_RGB565_2X8_LE,
34 V4L2_MBUS_FMT_RGB565_2X8_BE,
35 V4L2_MBUS_FMT_SBGGR8_1X8,
36 V4L2_MBUS_FMT_SBGGR10_1X10,
37 V4L2_MBUS_FMT_GREY8_1X8,
38 V4L2_MBUS_FMT_Y10_1X10,
39 V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE,
40 V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_LE,
41 V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_BE,
42 V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_BE,
43 V4L2_MBUS_FMT_SGRBG8_1X8,
44 V4L2_MBUS_FMT_SBGGR12_1X12,
45 V4L2_MBUS_FMT_YUYV8_1_5X8,
46 V4L2_MBUS_FMT_YVYU8_1_5X8,
47 V4L2_MBUS_FMT_UYVY8_1_5X8,
48 V4L2_MBUS_FMT_VYUY8_1_5X8,
49};
50
51/**
52 * struct v4l2_mbus_framefmt - frame format on the media bus
53 * @width: frame width
54 * @height: frame height
55 * @code: data format code
56 * @field: used interlacing type
57 * @colorspace: colorspace of the data
58 */
59struct v4l2_mbus_framefmt {
60 __u32 width;
61 __u32 height;
62 enum v4l2_mbus_pixelcode code;
63 enum v4l2_field field;
64 enum v4l2_colorspace colorspace;
65};
66 15
67static inline void v4l2_fill_pix_format(struct v4l2_pix_format *pix_fmt, 16static inline void v4l2_fill_pix_format(struct v4l2_pix_format *pix_fmt,
68 const struct v4l2_mbus_framefmt *mbus_fmt) 17 const struct v4l2_mbus_framefmt *mbus_fmt)
diff --git a/include/media/v4l2-mem2mem.h b/include/media/v4l2-mem2mem.h
index 8d149f1c58d0..16ac4733e80d 100644
--- a/include/media/v4l2-mem2mem.h
+++ b/include/media/v4l2-mem2mem.h
@@ -5,7 +5,7 @@
5 * and destination. 5 * and destination.
6 * 6 *
7 * Copyright (c) 2009 Samsung Electronics Co., Ltd. 7 * Copyright (c) 2009 Samsung Electronics Co., Ltd.
8 * Pawel Osciak, <p.osciak@samsung.com> 8 * Pawel Osciak, <pawel@osciak.com>
9 * Marek Szyprowski, <m.szyprowski@samsung.com> 9 * Marek Szyprowski, <m.szyprowski@samsung.com>
10 * 10 *
11 * 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
@@ -17,7 +17,7 @@
17#ifndef _MEDIA_V4L2_MEM2MEM_H 17#ifndef _MEDIA_V4L2_MEM2MEM_H
18#define _MEDIA_V4L2_MEM2MEM_H 18#define _MEDIA_V4L2_MEM2MEM_H
19 19
20#include <media/videobuf-core.h> 20#include <media/videobuf2-core.h>
21 21
22/** 22/**
23 * struct v4l2_m2m_ops - mem-to-mem device driver callbacks 23 * struct v4l2_m2m_ops - mem-to-mem device driver callbacks
@@ -45,17 +45,20 @@ struct v4l2_m2m_ops {
45 void (*device_run)(void *priv); 45 void (*device_run)(void *priv);
46 int (*job_ready)(void *priv); 46 int (*job_ready)(void *priv);
47 void (*job_abort)(void *priv); 47 void (*job_abort)(void *priv);
48 void (*lock)(void *priv);
49 void (*unlock)(void *priv);
48}; 50};
49 51
50struct v4l2_m2m_dev; 52struct v4l2_m2m_dev;
51 53
52struct v4l2_m2m_queue_ctx { 54struct v4l2_m2m_queue_ctx {
53/* private: internal use only */ 55/* private: internal use only */
54 struct videobuf_queue q; 56 struct vb2_queue q;
55 57
56 /* Queue for buffers ready to be processed as soon as this 58 /* Queue for buffers ready to be processed as soon as this
57 * instance receives access to the device */ 59 * instance receives access to the device */
58 struct list_head rdy_queue; 60 struct list_head rdy_queue;
61 spinlock_t rdy_spinlock;
59 u8 num_rdy; 62 u8 num_rdy;
60}; 63};
61 64
@@ -72,19 +75,31 @@ struct v4l2_m2m_ctx {
72 /* For device job queue */ 75 /* For device job queue */
73 struct list_head queue; 76 struct list_head queue;
74 unsigned long job_flags; 77 unsigned long job_flags;
78 wait_queue_head_t finished;
75 79
76 /* Instance private data */ 80 /* Instance private data */
77 void *priv; 81 void *priv;
78}; 82};
79 83
84struct v4l2_m2m_buffer {
85 struct vb2_buffer vb;
86 struct list_head list;
87};
88
80void *v4l2_m2m_get_curr_priv(struct v4l2_m2m_dev *m2m_dev); 89void *v4l2_m2m_get_curr_priv(struct v4l2_m2m_dev *m2m_dev);
81 90
82struct videobuf_queue *v4l2_m2m_get_vq(struct v4l2_m2m_ctx *m2m_ctx, 91struct vb2_queue *v4l2_m2m_get_vq(struct v4l2_m2m_ctx *m2m_ctx,
83 enum v4l2_buf_type type); 92 enum v4l2_buf_type type);
84 93
85void v4l2_m2m_job_finish(struct v4l2_m2m_dev *m2m_dev, 94void v4l2_m2m_job_finish(struct v4l2_m2m_dev *m2m_dev,
86 struct v4l2_m2m_ctx *m2m_ctx); 95 struct v4l2_m2m_ctx *m2m_ctx);
87 96
97static inline void
98v4l2_m2m_buf_done(struct vb2_buffer *buf, enum vb2_buffer_state state)
99{
100 vb2_buffer_done(buf, state);
101}
102
88int v4l2_m2m_reqbufs(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, 103int v4l2_m2m_reqbufs(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
89 struct v4l2_requestbuffers *reqbufs); 104 struct v4l2_requestbuffers *reqbufs);
90 105
@@ -110,13 +125,13 @@ int v4l2_m2m_mmap(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
110struct v4l2_m2m_dev *v4l2_m2m_init(struct v4l2_m2m_ops *m2m_ops); 125struct v4l2_m2m_dev *v4l2_m2m_init(struct v4l2_m2m_ops *m2m_ops);
111void v4l2_m2m_release(struct v4l2_m2m_dev *m2m_dev); 126void v4l2_m2m_release(struct v4l2_m2m_dev *m2m_dev);
112 127
113struct v4l2_m2m_ctx *v4l2_m2m_ctx_init(void *priv, struct v4l2_m2m_dev *m2m_dev, 128struct v4l2_m2m_ctx *v4l2_m2m_ctx_init(struct v4l2_m2m_dev *m2m_dev,
114 void (*vq_init)(void *priv, struct videobuf_queue *, 129 void *drv_priv,
115 enum v4l2_buf_type)); 130 int (*queue_init)(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq));
131
116void v4l2_m2m_ctx_release(struct v4l2_m2m_ctx *m2m_ctx); 132void v4l2_m2m_ctx_release(struct v4l2_m2m_ctx *m2m_ctx);
117 133
118void v4l2_m2m_buf_queue(struct v4l2_m2m_ctx *m2m_ctx, struct videobuf_queue *vq, 134void v4l2_m2m_buf_queue(struct v4l2_m2m_ctx *m2m_ctx, struct vb2_buffer *vb);
119 struct videobuf_buffer *vb);
120 135
121/** 136/**
122 * v4l2_m2m_num_src_bufs_ready() - return the number of source buffers ready for 137 * v4l2_m2m_num_src_bufs_ready() - return the number of source buffers ready for
@@ -138,7 +153,7 @@ unsigned int v4l2_m2m_num_dst_bufs_ready(struct v4l2_m2m_ctx *m2m_ctx)
138 return m2m_ctx->out_q_ctx.num_rdy; 153 return m2m_ctx->out_q_ctx.num_rdy;
139} 154}
140 155
141void *v4l2_m2m_next_buf(struct v4l2_m2m_ctx *m2m_ctx, enum v4l2_buf_type type); 156void *v4l2_m2m_next_buf(struct v4l2_m2m_queue_ctx *q_ctx);
142 157
143/** 158/**
144 * v4l2_m2m_next_src_buf() - return next source buffer from the list of ready 159 * v4l2_m2m_next_src_buf() - return next source buffer from the list of ready
@@ -146,7 +161,7 @@ void *v4l2_m2m_next_buf(struct v4l2_m2m_ctx *m2m_ctx, enum v4l2_buf_type type);
146 */ 161 */
147static inline void *v4l2_m2m_next_src_buf(struct v4l2_m2m_ctx *m2m_ctx) 162static inline void *v4l2_m2m_next_src_buf(struct v4l2_m2m_ctx *m2m_ctx)
148{ 163{
149 return v4l2_m2m_next_buf(m2m_ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); 164 return v4l2_m2m_next_buf(&m2m_ctx->out_q_ctx);
150} 165}
151 166
152/** 167/**
@@ -155,29 +170,28 @@ static inline void *v4l2_m2m_next_src_buf(struct v4l2_m2m_ctx *m2m_ctx)
155 */ 170 */
156static inline void *v4l2_m2m_next_dst_buf(struct v4l2_m2m_ctx *m2m_ctx) 171static inline void *v4l2_m2m_next_dst_buf(struct v4l2_m2m_ctx *m2m_ctx)
157{ 172{
158 return v4l2_m2m_next_buf(m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); 173 return v4l2_m2m_next_buf(&m2m_ctx->cap_q_ctx);
159} 174}
160 175
161/** 176/**
162 * v4l2_m2m_get_src_vq() - return videobuf_queue for source buffers 177 * v4l2_m2m_get_src_vq() - return vb2_queue for source buffers
163 */ 178 */
164static inline 179static inline
165struct videobuf_queue *v4l2_m2m_get_src_vq(struct v4l2_m2m_ctx *m2m_ctx) 180struct vb2_queue *v4l2_m2m_get_src_vq(struct v4l2_m2m_ctx *m2m_ctx)
166{ 181{
167 return v4l2_m2m_get_vq(m2m_ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); 182 return &m2m_ctx->out_q_ctx.q;
168} 183}
169 184
170/** 185/**
171 * v4l2_m2m_get_dst_vq() - return videobuf_queue for destination buffers 186 * v4l2_m2m_get_dst_vq() - return vb2_queue for destination buffers
172 */ 187 */
173static inline 188static inline
174struct videobuf_queue *v4l2_m2m_get_dst_vq(struct v4l2_m2m_ctx *m2m_ctx) 189struct vb2_queue *v4l2_m2m_get_dst_vq(struct v4l2_m2m_ctx *m2m_ctx)
175{ 190{
176 return v4l2_m2m_get_vq(m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); 191 return &m2m_ctx->cap_q_ctx.q;
177} 192}
178 193
179void *v4l2_m2m_buf_remove(struct v4l2_m2m_ctx *m2m_ctx, 194void *v4l2_m2m_buf_remove(struct v4l2_m2m_queue_ctx *q_ctx);
180 enum v4l2_buf_type type);
181 195
182/** 196/**
183 * v4l2_m2m_src_buf_remove() - take off a source buffer from the list of ready 197 * v4l2_m2m_src_buf_remove() - take off a source buffer from the list of ready
@@ -185,7 +199,7 @@ void *v4l2_m2m_buf_remove(struct v4l2_m2m_ctx *m2m_ctx,
185 */ 199 */
186static inline void *v4l2_m2m_src_buf_remove(struct v4l2_m2m_ctx *m2m_ctx) 200static inline void *v4l2_m2m_src_buf_remove(struct v4l2_m2m_ctx *m2m_ctx)
187{ 201{
188 return v4l2_m2m_buf_remove(m2m_ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); 202 return v4l2_m2m_buf_remove(&m2m_ctx->out_q_ctx);
189} 203}
190 204
191/** 205/**
@@ -194,7 +208,7 @@ static inline void *v4l2_m2m_src_buf_remove(struct v4l2_m2m_ctx *m2m_ctx)
194 */ 208 */
195static inline void *v4l2_m2m_dst_buf_remove(struct v4l2_m2m_ctx *m2m_ctx) 209static inline void *v4l2_m2m_dst_buf_remove(struct v4l2_m2m_ctx *m2m_ctx)
196{ 210{
197 return v4l2_m2m_buf_remove(m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); 211 return v4l2_m2m_buf_remove(&m2m_ctx->cap_q_ctx);
198} 212}
199 213
200#endif /* _MEDIA_V4L2_MEM2MEM_H */ 214#endif /* _MEDIA_V4L2_MEM2MEM_H */
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 4a97d7341a94..2884e3e69cb1 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -21,7 +21,11 @@
21#ifndef _V4L2_SUBDEV_H 21#ifndef _V4L2_SUBDEV_H
22#define _V4L2_SUBDEV_H 22#define _V4L2_SUBDEV_H
23 23
24#include <linux/v4l2-subdev.h>
25#include <media/media-entity.h>
24#include <media/v4l2-common.h> 26#include <media/v4l2-common.h>
27#include <media/v4l2-dev.h>
28#include <media/v4l2-fh.h>
25#include <media/v4l2-mediabus.h> 29#include <media/v4l2-mediabus.h>
26 30
27/* generic v4l2_device notify callback notification values */ 31/* generic v4l2_device notify callback notification values */
@@ -36,7 +40,10 @@
36 40
37struct v4l2_device; 41struct v4l2_device;
38struct v4l2_ctrl_handler; 42struct v4l2_ctrl_handler;
43struct v4l2_event_subscription;
44struct v4l2_fh;
39struct v4l2_subdev; 45struct v4l2_subdev;
46struct v4l2_subdev_fh;
40struct tuner_setup; 47struct tuner_setup;
41 48
42/* decode_vbi_line */ 49/* decode_vbi_line */
@@ -106,10 +113,7 @@ struct v4l2_subdev_io_pin_config {
106 u8 strength; /* Pin drive strength */ 113 u8 strength; /* Pin drive strength */
107}; 114};
108 115
109/* s_config: if set, then it is always called by the v4l2_i2c_new_subdev* 116/*
110 functions after the v4l2_subdev was registered. It is used to pass
111 platform data to the subdev which can be used during initialization.
112
113 s_io_pin_config: configure one or more chip I/O pins for chips that 117 s_io_pin_config: configure one or more chip I/O pins for chips that
114 multiplex different internal signal pads out to IO pins. This function 118 multiplex different internal signal pads out to IO pins. This function
115 takes a pointer to an array of 'n' pin configuration entries, one for 119 takes a pointer to an array of 'n' pin configuration entries, one for
@@ -141,7 +145,6 @@ struct v4l2_subdev_io_pin_config {
141struct v4l2_subdev_core_ops { 145struct v4l2_subdev_core_ops {
142 int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip); 146 int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip);
143 int (*log_status)(struct v4l2_subdev *sd); 147 int (*log_status)(struct v4l2_subdev *sd);
144 int (*s_config)(struct v4l2_subdev *sd, int irq, void *platform_data);
145 int (*s_io_pin_config)(struct v4l2_subdev *sd, size_t n, 148 int (*s_io_pin_config)(struct v4l2_subdev *sd, size_t n,
146 struct v4l2_subdev_io_pin_config *pincfg); 149 struct v4l2_subdev_io_pin_config *pincfg);
147 int (*init)(struct v4l2_subdev *sd, u32 val); 150 int (*init)(struct v4l2_subdev *sd, u32 val);
@@ -164,18 +167,26 @@ struct v4l2_subdev_core_ops {
164 int (*s_power)(struct v4l2_subdev *sd, int on); 167 int (*s_power)(struct v4l2_subdev *sd, int on);
165 int (*interrupt_service_routine)(struct v4l2_subdev *sd, 168 int (*interrupt_service_routine)(struct v4l2_subdev *sd,
166 u32 status, bool *handled); 169 u32 status, bool *handled);
170 int (*subscribe_event)(struct v4l2_subdev *sd, struct v4l2_fh *fh,
171 struct v4l2_event_subscription *sub);
172 int (*unsubscribe_event)(struct v4l2_subdev *sd, struct v4l2_fh *fh,
173 struct v4l2_event_subscription *sub);
167}; 174};
168 175
169/* s_mode: switch the tuner to a specific tuner mode. Replacement of s_radio. 176/* s_radio: v4l device was opened in radio mode.
170 177
171 s_radio: v4l device was opened in Radio mode, to be replaced by s_mode. 178 g_frequency: freq->type must be filled in. Normally done by video_ioctl2
179 or the bridge driver.
180
181 g_tuner:
182 s_tuner: vt->type must be filled in. Normally done by video_ioctl2 or the
183 bridge driver.
172 184
173 s_type_addr: sets tuner type and its I2C addr. 185 s_type_addr: sets tuner type and its I2C addr.
174 186
175 s_config: sets tda9887 specific stuff, like port1, port2 and qss 187 s_config: sets tda9887 specific stuff, like port1, port2 and qss
176 */ 188 */
177struct v4l2_subdev_tuner_ops { 189struct v4l2_subdev_tuner_ops {
178 int (*s_mode)(struct v4l2_subdev *sd, enum v4l2_tuner_type);
179 int (*s_radio)(struct v4l2_subdev *sd); 190 int (*s_radio)(struct v4l2_subdev *sd);
180 int (*s_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq); 191 int (*s_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq);
181 int (*g_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq); 192 int (*g_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq);
@@ -256,15 +267,15 @@ struct v4l2_subdev_video_ops {
256 int (*querystd)(struct v4l2_subdev *sd, v4l2_std_id *std); 267 int (*querystd)(struct v4l2_subdev *sd, v4l2_std_id *std);
257 int (*g_input_status)(struct v4l2_subdev *sd, u32 *status); 268 int (*g_input_status)(struct v4l2_subdev *sd, u32 *status);
258 int (*s_stream)(struct v4l2_subdev *sd, int enable); 269 int (*s_stream)(struct v4l2_subdev *sd, int enable);
259 int (*enum_fmt)(struct v4l2_subdev *sd, struct v4l2_fmtdesc *fmtdesc);
260 int (*g_fmt)(struct v4l2_subdev *sd, struct v4l2_format *fmt);
261 int (*try_fmt)(struct v4l2_subdev *sd, struct v4l2_format *fmt);
262 int (*s_fmt)(struct v4l2_subdev *sd, struct v4l2_format *fmt);
263 int (*cropcap)(struct v4l2_subdev *sd, struct v4l2_cropcap *cc); 270 int (*cropcap)(struct v4l2_subdev *sd, struct v4l2_cropcap *cc);
264 int (*g_crop)(struct v4l2_subdev *sd, struct v4l2_crop *crop); 271 int (*g_crop)(struct v4l2_subdev *sd, struct v4l2_crop *crop);
265 int (*s_crop)(struct v4l2_subdev *sd, struct v4l2_crop *crop); 272 int (*s_crop)(struct v4l2_subdev *sd, struct v4l2_crop *crop);
266 int (*g_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param); 273 int (*g_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param);
267 int (*s_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param); 274 int (*s_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param);
275 int (*g_frame_interval)(struct v4l2_subdev *sd,
276 struct v4l2_subdev_frame_interval *interval);
277 int (*s_frame_interval)(struct v4l2_subdev *sd,
278 struct v4l2_subdev_frame_interval *interval);
268 int (*enum_framesizes)(struct v4l2_subdev *sd, struct v4l2_frmsizeenum *fsize); 279 int (*enum_framesizes)(struct v4l2_subdev *sd, struct v4l2_frmsizeenum *fsize);
269 int (*enum_frameintervals)(struct v4l2_subdev *sd, struct v4l2_frmivalenum *fival); 280 int (*enum_frameintervals)(struct v4l2_subdev *sd, struct v4l2_frmivalenum *fival);
270 int (*enum_dv_presets) (struct v4l2_subdev *sd, 281 int (*enum_dv_presets) (struct v4l2_subdev *sd,
@@ -279,6 +290,8 @@ struct v4l2_subdev_video_ops {
279 struct v4l2_dv_timings *timings); 290 struct v4l2_dv_timings *timings);
280 int (*enum_mbus_fmt)(struct v4l2_subdev *sd, unsigned int index, 291 int (*enum_mbus_fmt)(struct v4l2_subdev *sd, unsigned int index,
281 enum v4l2_mbus_pixelcode *code); 292 enum v4l2_mbus_pixelcode *code);
293 int (*enum_mbus_fsizes)(struct v4l2_subdev *sd,
294 struct v4l2_frmsizeenum *fsize);
282 int (*g_mbus_fmt)(struct v4l2_subdev *sd, 295 int (*g_mbus_fmt)(struct v4l2_subdev *sd,
283 struct v4l2_mbus_framefmt *fmt); 296 struct v4l2_mbus_framefmt *fmt);
284 int (*try_mbus_fmt)(struct v4l2_subdev *sd, 297 int (*try_mbus_fmt)(struct v4l2_subdev *sd,
@@ -332,9 +345,13 @@ struct v4l2_subdev_vbi_ops {
332 * This is needed for some sensors, which always corrupt 345 * This is needed for some sensors, which always corrupt
333 * several top lines of the output image, or which send their 346 * several top lines of the output image, or which send their
334 * metadata in them. 347 * metadata in them.
348 * @g_skip_frames: number of frames to skip at stream start. This is needed for
349 * buggy sensors that generate faulty frames when they are
350 * turned on.
335 */ 351 */
336struct v4l2_subdev_sensor_ops { 352struct v4l2_subdev_sensor_ops {
337 int (*g_skip_top_lines)(struct v4l2_subdev *sd, u32 *lines); 353 int (*g_skip_top_lines)(struct v4l2_subdev *sd, u32 *lines);
354 int (*g_skip_frames)(struct v4l2_subdev *sd, u32 *frames);
338}; 355};
339 356
340/* 357/*
@@ -409,6 +426,25 @@ struct v4l2_subdev_ir_ops {
409 struct v4l2_subdev_ir_parameters *params); 426 struct v4l2_subdev_ir_parameters *params);
410}; 427};
411 428
429struct v4l2_subdev_pad_ops {
430 int (*enum_mbus_code)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
431 struct v4l2_subdev_mbus_code_enum *code);
432 int (*enum_frame_size)(struct v4l2_subdev *sd,
433 struct v4l2_subdev_fh *fh,
434 struct v4l2_subdev_frame_size_enum *fse);
435 int (*enum_frame_interval)(struct v4l2_subdev *sd,
436 struct v4l2_subdev_fh *fh,
437 struct v4l2_subdev_frame_interval_enum *fie);
438 int (*get_fmt)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
439 struct v4l2_subdev_format *format);
440 int (*set_fmt)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
441 struct v4l2_subdev_format *format);
442 int (*set_crop)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
443 struct v4l2_subdev_crop *crop);
444 int (*get_crop)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
445 struct v4l2_subdev_crop *crop);
446};
447
412struct v4l2_subdev_ops { 448struct v4l2_subdev_ops {
413 const struct v4l2_subdev_core_ops *core; 449 const struct v4l2_subdev_core_ops *core;
414 const struct v4l2_subdev_tuner_ops *tuner; 450 const struct v4l2_subdev_tuner_ops *tuner;
@@ -417,24 +453,55 @@ struct v4l2_subdev_ops {
417 const struct v4l2_subdev_vbi_ops *vbi; 453 const struct v4l2_subdev_vbi_ops *vbi;
418 const struct v4l2_subdev_ir_ops *ir; 454 const struct v4l2_subdev_ir_ops *ir;
419 const struct v4l2_subdev_sensor_ops *sensor; 455 const struct v4l2_subdev_sensor_ops *sensor;
456 const struct v4l2_subdev_pad_ops *pad;
457};
458
459/*
460 * Internal ops. Never call this from drivers, only the v4l2 framework can call
461 * these ops.
462 *
463 * registered: called when this subdev is registered. When called the v4l2_dev
464 * field is set to the correct v4l2_device.
465 *
466 * unregistered: called when this subdev is unregistered. When called the
467 * v4l2_dev field is still set to the correct v4l2_device.
468 *
469 * open: called when the subdev device node is opened by an application.
470 *
471 * close: called when the subdev device node is closed.
472 */
473struct v4l2_subdev_internal_ops {
474 int (*registered)(struct v4l2_subdev *sd);
475 void (*unregistered)(struct v4l2_subdev *sd);
476 int (*open)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh);
477 int (*close)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh);
420}; 478};
421 479
422#define V4L2_SUBDEV_NAME_SIZE 32 480#define V4L2_SUBDEV_NAME_SIZE 32
423 481
424/* Set this flag if this subdev is a i2c device. */ 482/* Set this flag if this subdev is a i2c device. */
425#define V4L2_SUBDEV_FL_IS_I2C (1U << 0) 483#define V4L2_SUBDEV_FL_IS_I2C (1U << 0)
426/* Set this flag if this subdev is a spi device. */ 484/* Set this flag if this subdev is a spi device. */
427#define V4L2_SUBDEV_FL_IS_SPI (1U << 1) 485#define V4L2_SUBDEV_FL_IS_SPI (1U << 1)
486/* Set this flag if this subdev needs a device node. */
487#define V4L2_SUBDEV_FL_HAS_DEVNODE (1U << 2)
488/* Set this flag if this subdev generates events. */
489#define V4L2_SUBDEV_FL_HAS_EVENTS (1U << 3)
428 490
429/* Each instance of a subdev driver should create this struct, either 491/* Each instance of a subdev driver should create this struct, either
430 stand-alone or embedded in a larger struct. 492 stand-alone or embedded in a larger struct.
431 */ 493 */
432struct v4l2_subdev { 494struct v4l2_subdev {
495#if defined(CONFIG_MEDIA_CONTROLLER)
496 struct media_entity entity;
497#endif
433 struct list_head list; 498 struct list_head list;
434 struct module *owner; 499 struct module *owner;
435 u32 flags; 500 u32 flags;
436 struct v4l2_device *v4l2_dev; 501 struct v4l2_device *v4l2_dev;
437 const struct v4l2_subdev_ops *ops; 502 const struct v4l2_subdev_ops *ops;
503 /* Never call these internal ops from within a driver! */
504 const struct v4l2_subdev_internal_ops *internal_ops;
438 /* The control handler of this subdev. May be NULL. */ 505 /* The control handler of this subdev. May be NULL. */
439 struct v4l2_ctrl_handler *ctrl_handler; 506 struct v4l2_ctrl_handler *ctrl_handler;
440 /* name must be unique */ 507 /* name must be unique */
@@ -442,33 +509,72 @@ struct v4l2_subdev {
442 /* can be used to group similar subdevs, value is driver-specific */ 509 /* can be used to group similar subdevs, value is driver-specific */
443 u32 grp_id; 510 u32 grp_id;
444 /* pointer to private data */ 511 /* pointer to private data */
445 void *priv; 512 void *dev_priv;
513 void *host_priv;
514 /* subdev device node */
515 struct video_device devnode;
516 /* number of events to be allocated on open */
517 unsigned int nevents;
446}; 518};
447 519
520#define media_entity_to_v4l2_subdev(ent) \
521 container_of(ent, struct v4l2_subdev, entity)
522#define vdev_to_v4l2_subdev(vdev) \
523 container_of(vdev, struct v4l2_subdev, devnode)
524
525/*
526 * Used for storing subdev information per file handle
527 */
528struct v4l2_subdev_fh {
529 struct v4l2_fh vfh;
530#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
531 struct v4l2_mbus_framefmt *try_fmt;
532 struct v4l2_rect *try_crop;
533#endif
534};
535
536#define to_v4l2_subdev_fh(fh) \
537 container_of(fh, struct v4l2_subdev_fh, vfh)
538
539#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
540static inline struct v4l2_mbus_framefmt *
541v4l2_subdev_get_try_format(struct v4l2_subdev_fh *fh, unsigned int pad)
542{
543 return &fh->try_fmt[pad];
544}
545
546static inline struct v4l2_rect *
547v4l2_subdev_get_try_crop(struct v4l2_subdev_fh *fh, unsigned int pad)
548{
549 return &fh->try_crop[pad];
550}
551#endif
552
553extern const struct v4l2_file_operations v4l2_subdev_fops;
554
448static inline void v4l2_set_subdevdata(struct v4l2_subdev *sd, void *p) 555static inline void v4l2_set_subdevdata(struct v4l2_subdev *sd, void *p)
449{ 556{
450 sd->priv = p; 557 sd->dev_priv = p;
451} 558}
452 559
453static inline void *v4l2_get_subdevdata(const struct v4l2_subdev *sd) 560static inline void *v4l2_get_subdevdata(const struct v4l2_subdev *sd)
454{ 561{
455 return sd->priv; 562 return sd->dev_priv;
456} 563}
457 564
458static inline void v4l2_subdev_init(struct v4l2_subdev *sd, 565static inline void v4l2_set_subdev_hostdata(struct v4l2_subdev *sd, void *p)
459 const struct v4l2_subdev_ops *ops)
460{ 566{
461 INIT_LIST_HEAD(&sd->list); 567 sd->host_priv = p;
462 /* ops->core MUST be set */
463 BUG_ON(!ops || !ops->core);
464 sd->ops = ops;
465 sd->v4l2_dev = NULL;
466 sd->flags = 0;
467 sd->name[0] = '\0';
468 sd->grp_id = 0;
469 sd->priv = NULL;
470} 568}
471 569
570static inline void *v4l2_get_subdev_hostdata(const struct v4l2_subdev *sd)
571{
572 return sd->host_priv;
573}
574
575void v4l2_subdev_init(struct v4l2_subdev *sd,
576 const struct v4l2_subdev_ops *ops);
577
472/* Call an ops of a v4l2_subdev, doing the right checks against 578/* Call an ops of a v4l2_subdev, doing the right checks against
473 NULL pointers. 579 NULL pointers.
474 580
diff --git a/include/media/videobuf-core.h b/include/media/videobuf-core.h
index f2c41cebf453..90ed895e217d 100644
--- a/include/media/videobuf-core.h
+++ b/include/media/videobuf-core.h
@@ -17,10 +17,6 @@
17#define _VIDEOBUF_CORE_H 17#define _VIDEOBUF_CORE_H
18 18
19#include <linux/poll.h> 19#include <linux/poll.h>
20#ifdef CONFIG_VIDEO_V4L1_COMPAT
21#define __MIN_V4L1
22#include <linux/videodev.h>
23#endif
24#include <linux/videodev2.h> 20#include <linux/videodev2.h>
25 21
26#define UNSET (-1U) 22#define UNSET (-1U)
@@ -139,6 +135,7 @@ struct videobuf_qtype_ops {
139 135
140struct videobuf_queue { 136struct videobuf_queue {
141 struct mutex vb_lock; 137 struct mutex vb_lock;
138 struct mutex *ext_lock;
142 spinlock_t *irqlock; 139 spinlock_t *irqlock;
143 struct device *dev; 140 struct device *dev;
144 141
@@ -167,7 +164,20 @@ struct videobuf_queue {
167 void *priv_data; 164 void *priv_data;
168}; 165};
169 166
170int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr); 167static inline void videobuf_queue_lock(struct videobuf_queue *q)
168{
169 if (!q->ext_lock)
170 mutex_lock(&q->vb_lock);
171}
172
173static inline void videobuf_queue_unlock(struct videobuf_queue *q)
174{
175 if (!q->ext_lock)
176 mutex_unlock(&q->vb_lock);
177}
178
179int videobuf_waiton(struct videobuf_queue *q, struct videobuf_buffer *vb,
180 int non_blocking, int intr);
171int videobuf_iolock(struct videobuf_queue *q, struct videobuf_buffer *vb, 181int videobuf_iolock(struct videobuf_queue *q, struct videobuf_buffer *vb,
172 struct v4l2_framebuffer *fbuf); 182 struct v4l2_framebuffer *fbuf);
173 183
@@ -185,7 +195,8 @@ void videobuf_queue_core_init(struct videobuf_queue *q,
185 enum v4l2_field field, 195 enum v4l2_field field,
186 unsigned int msize, 196 unsigned int msize,
187 void *priv, 197 void *priv,
188 struct videobuf_qtype_ops *int_ops); 198 struct videobuf_qtype_ops *int_ops,
199 struct mutex *ext_lock);
189int videobuf_queue_is_busy(struct videobuf_queue *q); 200int videobuf_queue_is_busy(struct videobuf_queue *q);
190void videobuf_queue_cancel(struct videobuf_queue *q); 201void videobuf_queue_cancel(struct videobuf_queue *q);
191 202
@@ -197,10 +208,6 @@ int videobuf_qbuf(struct videobuf_queue *q,
197 struct v4l2_buffer *b); 208 struct v4l2_buffer *b);
198int videobuf_dqbuf(struct videobuf_queue *q, 209int videobuf_dqbuf(struct videobuf_queue *q,
199 struct v4l2_buffer *b, int nonblocking); 210 struct v4l2_buffer *b, int nonblocking);
200#ifdef CONFIG_VIDEO_V4L1_COMPAT
201int videobuf_cgmbuf(struct videobuf_queue *q,
202 struct video_mbuf *mbuf, int count);
203#endif
204int videobuf_streamon(struct videobuf_queue *q); 211int videobuf_streamon(struct videobuf_queue *q);
205int videobuf_streamoff(struct videobuf_queue *q); 212int videobuf_streamoff(struct videobuf_queue *q);
206 213
diff --git a/include/media/videobuf-dma-contig.h b/include/media/videobuf-dma-contig.h
index ebaa9bc1ee8d..f0ed82543d9f 100644
--- a/include/media/videobuf-dma-contig.h
+++ b/include/media/videobuf-dma-contig.h
@@ -23,7 +23,8 @@ void videobuf_queue_dma_contig_init(struct videobuf_queue *q,
23 enum v4l2_buf_type type, 23 enum v4l2_buf_type type,
24 enum v4l2_field field, 24 enum v4l2_field field,
25 unsigned int msize, 25 unsigned int msize,
26 void *priv); 26 void *priv,
27 struct mutex *ext_lock);
27 28
28dma_addr_t videobuf_to_dma_contig(struct videobuf_buffer *buf); 29dma_addr_t videobuf_to_dma_contig(struct videobuf_buffer *buf);
29void videobuf_dma_contig_free(struct videobuf_queue *q, 30void videobuf_dma_contig_free(struct videobuf_queue *q,
diff --git a/include/media/videobuf-dma-sg.h b/include/media/videobuf-dma-sg.h
index aa4ebb42a565..1c647e8148c4 100644
--- a/include/media/videobuf-dma-sg.h
+++ b/include/media/videobuf-dma-sg.h
@@ -103,7 +103,8 @@ void videobuf_queue_sg_init(struct videobuf_queue *q,
103 enum v4l2_buf_type type, 103 enum v4l2_buf_type type,
104 enum v4l2_field field, 104 enum v4l2_field field,
105 unsigned int msize, 105 unsigned int msize,
106 void *priv); 106 void *priv,
107 struct mutex *ext_lock);
107 108
108#endif /* _VIDEOBUF_DMA_SG_H */ 109#endif /* _VIDEOBUF_DMA_SG_H */
109 110
diff --git a/include/media/videobuf-dvb.h b/include/media/videobuf-dvb.h
index 07cf4b9d0a65..bf365721d6b0 100644
--- a/include/media/videobuf-dvb.h
+++ b/include/media/videobuf-dvb.h
@@ -4,6 +4,9 @@
4#include <dvb_net.h> 4#include <dvb_net.h>
5#include <dvb_frontend.h> 5#include <dvb_frontend.h>
6 6
7#ifndef _VIDEOBUF_DVB_H_
8#define _VIDEOBUF_DVB_H_
9
7struct videobuf_dvb { 10struct videobuf_dvb {
8 /* filling that the job of the driver */ 11 /* filling that the job of the driver */
9 char *name; 12 char *name;
@@ -54,6 +57,7 @@ void videobuf_dvb_dealloc_frontends(struct videobuf_dvb_frontends *f);
54struct videobuf_dvb_frontend * videobuf_dvb_get_frontend(struct videobuf_dvb_frontends *f, int id); 57struct videobuf_dvb_frontend * videobuf_dvb_get_frontend(struct videobuf_dvb_frontends *f, int id);
55int videobuf_dvb_find_frontend(struct videobuf_dvb_frontends *f, struct dvb_frontend *p); 58int videobuf_dvb_find_frontend(struct videobuf_dvb_frontends *f, struct dvb_frontend *p);
56 59
60#endif /* _VIDEOBUF_DVB_H_ */
57 61
58/* 62/*
59 * Local variables: 63 * Local variables:
diff --git a/include/media/videobuf-vmalloc.h b/include/media/videobuf-vmalloc.h
index e19403c18dae..486a97efdb56 100644
--- a/include/media/videobuf-vmalloc.h
+++ b/include/media/videobuf-vmalloc.h
@@ -36,7 +36,8 @@ void videobuf_queue_vmalloc_init(struct videobuf_queue *q,
36 enum v4l2_buf_type type, 36 enum v4l2_buf_type type,
37 enum v4l2_field field, 37 enum v4l2_field field,
38 unsigned int msize, 38 unsigned int msize,
39 void *priv); 39 void *priv,
40 struct mutex *ext_lock);
40 41
41void *videobuf_to_vmalloc(struct videobuf_buffer *buf); 42void *videobuf_to_vmalloc(struct videobuf_buffer *buf);
42 43
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
new file mode 100644
index 000000000000..f87472acbc51
--- /dev/null
+++ b/include/media/videobuf2-core.h
@@ -0,0 +1,380 @@
1/*
2 * videobuf2-core.h - V4L2 driver helper framework
3 *
4 * Copyright (C) 2010 Samsung Electronics
5 *
6 * Author: Pawel Osciak <pawel@osciak.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation.
11 */
12#ifndef _MEDIA_VIDEOBUF2_CORE_H
13#define _MEDIA_VIDEOBUF2_CORE_H
14
15#include <linux/mm_types.h>
16#include <linux/mutex.h>
17#include <linux/poll.h>
18#include <linux/videodev2.h>
19
20struct vb2_alloc_ctx;
21struct vb2_fileio_data;
22
23/**
24 * struct vb2_mem_ops - memory handling/memory allocator operations
25 * @alloc: allocate video memory and, optionally, allocator private data,
26 * return NULL on failure or a pointer to allocator private,
27 * per-buffer data on success; the returned private structure
28 * will then be passed as buf_priv argument to other ops in this
29 * structure
30 * @put: inform the allocator that the buffer will no longer be used;
31 * usually will result in the allocator freeing the buffer (if
32 * no other users of this buffer are present); the buf_priv
33 * argument is the allocator private per-buffer structure
34 * previously returned from the alloc callback
35 * @get_userptr: acquire userspace memory for a hardware operation; used for
36 * USERPTR memory types; vaddr is the address passed to the
37 * videobuf layer when queuing a video buffer of USERPTR type;
38 * should return an allocator private per-buffer structure
39 * associated with the buffer on success, NULL on failure;
40 * the returned private structure will then be passed as buf_priv
41 * argument to other ops in this structure
42 * @put_userptr: inform the allocator that a USERPTR buffer will no longer
43 * be used
44 * @vaddr: return a kernel virtual address to a given memory buffer
45 * associated with the passed private structure or NULL if no
46 * such mapping exists
47 * @cookie: return allocator specific cookie for a given memory buffer
48 * associated with the passed private structure or NULL if not
49 * available
50 * @num_users: return the current number of users of a memory buffer;
51 * return 1 if the videobuf layer (or actually the driver using
52 * it) is the only user
53 * @mmap: setup a userspace mapping for a given memory buffer under
54 * the provided virtual memory region
55 *
56 * Required ops for USERPTR types: get_userptr, put_userptr.
57 * Required ops for MMAP types: alloc, put, num_users, mmap.
58 * Required ops for read/write access types: alloc, put, num_users, vaddr
59 */
60struct vb2_mem_ops {
61 void *(*alloc)(void *alloc_ctx, unsigned long size);
62 void (*put)(void *buf_priv);
63
64 void *(*get_userptr)(void *alloc_ctx, unsigned long vaddr,
65 unsigned long size, int write);
66 void (*put_userptr)(void *buf_priv);
67
68 void *(*vaddr)(void *buf_priv);
69 void *(*cookie)(void *buf_priv);
70
71 unsigned int (*num_users)(void *buf_priv);
72
73 int (*mmap)(void *buf_priv, struct vm_area_struct *vma);
74};
75
76struct vb2_plane {
77 void *mem_priv;
78 int mapped:1;
79};
80
81/**
82 * enum vb2_io_modes - queue access methods
83 * @VB2_MMAP: driver supports MMAP with streaming API
84 * @VB2_USERPTR: driver supports USERPTR with streaming API
85 * @VB2_READ: driver supports read() style access
86 * @VB2_WRITE: driver supports write() style access
87 */
88enum vb2_io_modes {
89 VB2_MMAP = (1 << 0),
90 VB2_USERPTR = (1 << 1),
91 VB2_READ = (1 << 2),
92 VB2_WRITE = (1 << 3),
93};
94
95/**
96 * enum vb2_fileio_flags - flags for selecting a mode of the file io emulator,
97 * by default the 'streaming' style is used by the file io emulator
98 * @VB2_FILEIO_READ_ONCE: report EOF after reading the first buffer
99 * @VB2_FILEIO_WRITE_IMMEDIATELY: queue buffer after each write() call
100 */
101enum vb2_fileio_flags {
102 VB2_FILEIO_READ_ONCE = (1 << 0),
103 VB2_FILEIO_WRITE_IMMEDIATELY = (1 << 1),
104};
105
106/**
107 * enum vb2_buffer_state - current video buffer state
108 * @VB2_BUF_STATE_DEQUEUED: buffer under userspace control
109 * @VB2_BUF_STATE_QUEUED: buffer queued in videobuf, but not in driver
110 * @VB2_BUF_STATE_ACTIVE: buffer queued in driver and possibly used
111 * in a hardware operation
112 * @VB2_BUF_STATE_DONE: buffer returned from driver to videobuf, but
113 * not yet dequeued to userspace
114 * @VB2_BUF_STATE_ERROR: same as above, but the operation on the buffer
115 * has ended with an error, which will be reported
116 * to the userspace when it is dequeued
117 */
118enum vb2_buffer_state {
119 VB2_BUF_STATE_DEQUEUED,
120 VB2_BUF_STATE_QUEUED,
121 VB2_BUF_STATE_ACTIVE,
122 VB2_BUF_STATE_DONE,
123 VB2_BUF_STATE_ERROR,
124};
125
126struct vb2_queue;
127
128/**
129 * struct vb2_buffer - represents a video buffer
130 * @v4l2_buf: struct v4l2_buffer associated with this buffer; can
131 * be read by the driver and relevant entries can be
132 * changed by the driver in case of CAPTURE types
133 * (such as timestamp)
134 * @v4l2_planes: struct v4l2_planes associated with this buffer; can
135 * be read by the driver and relevant entries can be
136 * changed by the driver in case of CAPTURE types
137 * (such as bytesused); NOTE that even for single-planar
138 * types, the v4l2_planes[0] struct should be used
139 * instead of v4l2_buf for filling bytesused - drivers
140 * should use the vb2_set_plane_payload() function for that
141 * @vb2_queue: the queue to which this driver belongs
142 * @num_planes: number of planes in the buffer
143 * on an internal driver queue
144 * @state: current buffer state; do not change
145 * @queued_entry: entry on the queued buffers list, which holds all
146 * buffers queued from userspace
147 * @done_entry: entry on the list that stores all buffers ready to
148 * be dequeued to userspace
149 * @planes: private per-plane information; do not change
150 * @num_planes_mapped: number of mapped planes; do not change
151 */
152struct vb2_buffer {
153 struct v4l2_buffer v4l2_buf;
154 struct v4l2_plane v4l2_planes[VIDEO_MAX_PLANES];
155
156 struct vb2_queue *vb2_queue;
157
158 unsigned int num_planes;
159
160/* Private: internal use only */
161 enum vb2_buffer_state state;
162
163 struct list_head queued_entry;
164 struct list_head done_entry;
165
166 struct vb2_plane planes[VIDEO_MAX_PLANES];
167 unsigned int num_planes_mapped;
168};
169
170/**
171 * struct vb2_ops - driver-specific callbacks
172 *
173 * @queue_setup: called from a VIDIOC_REQBUFS handler, before
174 * memory allocation; driver should return the required
175 * number of buffers in num_buffers, the required number
176 * of planes per buffer in num_planes; the size of each
177 * plane should be set in the sizes[] array and optional
178 * per-plane allocator specific context in alloc_ctxs[]
179 * array
180 * @wait_prepare: release any locks taken while calling vb2 functions;
181 * it is called before an ioctl needs to wait for a new
182 * buffer to arrive; required to avoid a deadlock in
183 * blocking access type
184 * @wait_finish: reacquire all locks released in the previous callback;
185 * required to continue operation after sleeping while
186 * waiting for a new buffer to arrive
187 * @buf_init: called once after allocating a buffer (in MMAP case)
188 * or after acquiring a new USERPTR buffer; drivers may
189 * perform additional buffer-related initialization;
190 * initialization failure (return != 0) will prevent
191 * queue setup from completing successfully; optional
192 * @buf_prepare: called every time the buffer is queued from userspace;
193 * drivers may perform any initialization required before
194 * each hardware operation in this callback;
195 * if an error is returned, the buffer will not be queued
196 * in driver; optional
197 * @buf_finish: called before every dequeue of the buffer back to
198 * userspace; drivers may perform any operations required
199 * before userspace accesses the buffer; optional
200 * @buf_cleanup: called once before the buffer is freed; drivers may
201 * perform any additional cleanup; optional
202 * @start_streaming: called once before entering 'streaming' state; enables
203 * driver to receive buffers over buf_queue() callback
204 * @stop_streaming: called when 'streaming' state must be disabled; driver
205 * should stop any DMA transactions or wait until they
206 * finish and give back all buffers it got from buf_queue()
207 * callback; may use vb2_wait_for_all_buffers() function
208 * @buf_queue: passes buffer vb to the driver; driver may start
209 * hardware operation on this buffer; driver should give
210 * the buffer back by calling vb2_buffer_done() function
211 */
212struct vb2_ops {
213 int (*queue_setup)(struct vb2_queue *q, unsigned int *num_buffers,
214 unsigned int *num_planes, unsigned long sizes[],
215 void *alloc_ctxs[]);
216
217 void (*wait_prepare)(struct vb2_queue *q);
218 void (*wait_finish)(struct vb2_queue *q);
219
220 int (*buf_init)(struct vb2_buffer *vb);
221 int (*buf_prepare)(struct vb2_buffer *vb);
222 int (*buf_finish)(struct vb2_buffer *vb);
223 void (*buf_cleanup)(struct vb2_buffer *vb);
224
225 int (*start_streaming)(struct vb2_queue *q);
226 int (*stop_streaming)(struct vb2_queue *q);
227
228 void (*buf_queue)(struct vb2_buffer *vb);
229};
230
231/**
232 * struct vb2_queue - a videobuf queue
233 *
234 * @type: queue type (see V4L2_BUF_TYPE_* in linux/videodev2.h
235 * @io_modes: supported io methods (see vb2_io_modes enum)
236 * @io_flags: additional io flags (see vb2_fileio_flags enum)
237 * @ops: driver-specific callbacks
238 * @mem_ops: memory allocator specific callbacks
239 * @drv_priv: driver private data
240 * @buf_struct_size: size of the driver-specific buffer structure;
241 * "0" indicates the driver doesn't want to use a custom buffer
242 * structure type, so sizeof(struct vb2_buffer) will is used
243 *
244 * @memory: current memory type used
245 * @bufs: videobuf buffer structures
246 * @num_buffers: number of allocated/used buffers
247 * @queued_list: list of buffers currently queued from userspace
248 * @queued_count: number of buffers owned by the driver
249 * @done_list: list of buffers ready to be dequeued to userspace
250 * @done_lock: lock to protect done_list list
251 * @done_wq: waitqueue for processes waiting for buffers ready to be dequeued
252 * @alloc_ctx: memory type/allocator-specific contexts for each plane
253 * @streaming: current streaming state
254 * @fileio: file io emulator internal data, used only if emulator is active
255 */
256struct vb2_queue {
257 enum v4l2_buf_type type;
258 unsigned int io_modes;
259 unsigned int io_flags;
260
261 const struct vb2_ops *ops;
262 const struct vb2_mem_ops *mem_ops;
263 void *drv_priv;
264 unsigned int buf_struct_size;
265
266/* private: internal use only */
267 enum v4l2_memory memory;
268 struct vb2_buffer *bufs[VIDEO_MAX_FRAME];
269 unsigned int num_buffers;
270
271 struct list_head queued_list;
272
273 atomic_t queued_count;
274 struct list_head done_list;
275 spinlock_t done_lock;
276 wait_queue_head_t done_wq;
277
278 void *alloc_ctx[VIDEO_MAX_PLANES];
279
280 unsigned int streaming:1;
281
282 struct vb2_fileio_data *fileio;
283};
284
285void *vb2_plane_vaddr(struct vb2_buffer *vb, unsigned int plane_no);
286void *vb2_plane_cookie(struct vb2_buffer *vb, unsigned int plane_no);
287
288void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state);
289int vb2_wait_for_all_buffers(struct vb2_queue *q);
290
291int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b);
292int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req);
293
294int vb2_queue_init(struct vb2_queue *q);
295
296void vb2_queue_release(struct vb2_queue *q);
297
298int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b);
299int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking);
300
301int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type);
302int vb2_streamoff(struct vb2_queue *q, enum v4l2_buf_type type);
303
304int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma);
305unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait);
306size_t vb2_read(struct vb2_queue *q, char __user *data, size_t count,
307 loff_t *ppos, int nonblock);
308size_t vb2_write(struct vb2_queue *q, char __user *data, size_t count,
309 loff_t *ppos, int nonblock);
310
311/**
312 * vb2_is_streaming() - return streaming status of the queue
313 * @q: videobuf queue
314 */
315static inline bool vb2_is_streaming(struct vb2_queue *q)
316{
317 return q->streaming;
318}
319
320/**
321 * vb2_is_busy() - return busy status of the queue
322 * @q: videobuf queue
323 *
324 * This function checks if queue has any buffers allocated.
325 */
326static inline bool vb2_is_busy(struct vb2_queue *q)
327{
328 return (q->num_buffers > 0);
329}
330
331/**
332 * vb2_get_drv_priv() - return driver private data associated with the queue
333 * @q: videobuf queue
334 */
335static inline void *vb2_get_drv_priv(struct vb2_queue *q)
336{
337 return q->drv_priv;
338}
339
340/**
341 * vb2_set_plane_payload() - set bytesused for the plane plane_no
342 * @vb: buffer for which plane payload should be set
343 * @plane_no: plane number for which payload should be set
344 * @size: payload in bytes
345 */
346static inline void vb2_set_plane_payload(struct vb2_buffer *vb,
347 unsigned int plane_no, unsigned long size)
348{
349 if (plane_no < vb->num_planes)
350 vb->v4l2_planes[plane_no].bytesused = size;
351}
352
353/**
354 * vb2_get_plane_payload() - get bytesused for the plane plane_no
355 * @vb: buffer for which plane payload should be set
356 * @plane_no: plane number for which payload should be set
357 * @size: payload in bytes
358 */
359static inline unsigned long vb2_get_plane_payload(struct vb2_buffer *vb,
360 unsigned int plane_no)
361{
362 if (plane_no < vb->num_planes)
363 return vb->v4l2_planes[plane_no].bytesused;
364 return 0;
365}
366
367/**
368 * vb2_plane_size() - return plane size in bytes
369 * @vb: buffer for which plane size should be returned
370 * @plane_no: plane number for which size should be returned
371 */
372static inline unsigned long
373vb2_plane_size(struct vb2_buffer *vb, unsigned int plane_no)
374{
375 if (plane_no < vb->num_planes)
376 return vb->v4l2_planes[plane_no].length;
377 return 0;
378}
379
380#endif /* _MEDIA_VIDEOBUF2_CORE_H */
diff --git a/include/media/videobuf2-dma-contig.h b/include/media/videobuf2-dma-contig.h
new file mode 100644
index 000000000000..7e6c68b23773
--- /dev/null
+++ b/include/media/videobuf2-dma-contig.h
@@ -0,0 +1,32 @@
1/*
2 * videobuf2-dma-coherent.h - DMA coherent memory allocator for videobuf2
3 *
4 * Copyright (C) 2010 Samsung Electronics
5 *
6 * Author: Pawel Osciak <pawel@osciak.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation.
11 */
12
13#ifndef _MEDIA_VIDEOBUF2_DMA_COHERENT_H
14#define _MEDIA_VIDEOBUF2_DMA_COHERENT_H
15
16#include <media/videobuf2-core.h>
17#include <linux/dma-mapping.h>
18
19static inline dma_addr_t
20vb2_dma_contig_plane_paddr(struct vb2_buffer *vb, unsigned int plane_no)
21{
22 dma_addr_t *paddr = vb2_plane_cookie(vb, plane_no);
23
24 return *paddr;
25}
26
27void *vb2_dma_contig_init_ctx(struct device *dev);
28void vb2_dma_contig_cleanup_ctx(void *alloc_ctx);
29
30extern const struct vb2_mem_ops vb2_dma_contig_memops;
31
32#endif
diff --git a/include/media/videobuf2-dma-sg.h b/include/media/videobuf2-dma-sg.h
new file mode 100644
index 000000000000..0038526b8ef7
--- /dev/null
+++ b/include/media/videobuf2-dma-sg.h
@@ -0,0 +1,32 @@
1/*
2 * videobuf2-dma-sg.h - DMA scatter/gather memory allocator for videobuf2
3 *
4 * Copyright (C) 2010 Samsung Electronics
5 *
6 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation.
11 */
12
13#ifndef _MEDIA_VIDEOBUF2_DMA_SG_H
14#define _MEDIA_VIDEOBUF2_DMA_SG_H
15
16#include <media/videobuf2-core.h>
17
18struct vb2_dma_sg_desc {
19 unsigned long size;
20 unsigned int num_pages;
21 struct scatterlist *sglist;
22};
23
24static inline struct vb2_dma_sg_desc *vb2_dma_sg_plane_desc(
25 struct vb2_buffer *vb, unsigned int plane_no)
26{
27 return (struct vb2_dma_sg_desc *)vb2_plane_cookie(vb, plane_no);
28}
29
30extern const struct vb2_mem_ops vb2_dma_sg_memops;
31
32#endif
diff --git a/include/media/videobuf2-memops.h b/include/media/videobuf2-memops.h
new file mode 100644
index 000000000000..84e1f6c031c5
--- /dev/null
+++ b/include/media/videobuf2-memops.h
@@ -0,0 +1,45 @@
1/*
2 * videobuf2-memops.h - generic memory handling routines for videobuf2
3 *
4 * Copyright (C) 2010 Samsung Electronics
5 *
6 * Author: Pawel Osciak <pawel@osciak.com>
7 * Marek Szyprowski <m.szyprowski@samsung.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation.
12 */
13
14#ifndef _MEDIA_VIDEOBUF2_MEMOPS_H
15#define _MEDIA_VIDEOBUF2_MEMOPS_H
16
17#include <media/videobuf2-core.h>
18
19/**
20 * vb2_vmarea_handler - common vma refcount tracking handler
21 * @refcount: pointer to refcount entry in the buffer
22 * @put: callback to function that decreases buffer refcount
23 * @arg: argument for @put callback
24 */
25struct vb2_vmarea_handler {
26 atomic_t *refcount;
27 void (*put)(void *arg);
28 void *arg;
29};
30
31extern const struct vm_operations_struct vb2_common_vm_ops;
32
33int vb2_get_contig_userptr(unsigned long vaddr, unsigned long size,
34 struct vm_area_struct **res_vma, dma_addr_t *res_pa);
35
36int vb2_mmap_pfn_range(struct vm_area_struct *vma, unsigned long paddr,
37 unsigned long size,
38 const struct vm_operations_struct *vm_ops,
39 void *priv);
40
41struct vm_area_struct *vb2_get_vma(struct vm_area_struct *vma);
42void vb2_put_vma(struct vm_area_struct *vma);
43
44
45#endif
diff --git a/include/media/videobuf2-vmalloc.h b/include/media/videobuf2-vmalloc.h
new file mode 100644
index 000000000000..93a76b43038d
--- /dev/null
+++ b/include/media/videobuf2-vmalloc.h
@@ -0,0 +1,20 @@
1/*
2 * videobuf2-vmalloc.h - vmalloc memory allocator for videobuf2
3 *
4 * Copyright (C) 2010 Samsung Electronics
5 *
6 * Author: Pawel Osciak <pawel@osciak.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation.
11 */
12
13#ifndef _MEDIA_VIDEOBUF2_VMALLOC_H
14#define _MEDIA_VIDEOBUF2_VMALLOC_H
15
16#include <media/videobuf2-core.h>
17
18extern const struct vb2_mem_ops vb2_vmalloc_memops;
19
20#endif
diff --git a/include/media/wm8775.h b/include/media/wm8775.h
index 60739c5a23ae..d0e801a9935c 100644
--- a/include/media/wm8775.h
+++ b/include/media/wm8775.h
@@ -32,4 +32,13 @@
32#define WM8775_AIN3 4 32#define WM8775_AIN3 4
33#define WM8775_AIN4 8 33#define WM8775_AIN4 8
34 34
35
36struct wm8775_platform_data {
37 /*
38 * FIXME: Instead, we should parametrize the params
39 * that need different settings between ivtv, pvrusb2, and Nova-S
40 */
41 bool is_nova_s;
42};
43
35#endif 44#endif