diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2007-04-27 11:31:25 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-04-27 14:43:50 -0400 |
commit | 1a0adaf37c30e89e44d1470ef604a930999a5826 (patch) | |
tree | 6e6d6e823f44abdb2ed3847e00406a75bc968cef /drivers/media/video/ivtv/ivtv-mailbox.c | |
parent | ac52ea3c3c04403d10acf0253180ec6f51977142 (diff) |
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/ivtv/ivtv-mailbox.c')
-rw-r--r-- | drivers/media/video/ivtv/ivtv-mailbox.c | 360 |
1 files changed, 360 insertions, 0 deletions
diff --git a/drivers/media/video/ivtv/ivtv-mailbox.c b/drivers/media/video/ivtv/ivtv-mailbox.c new file mode 100644 index 000000000000..6ae42a3b03cc --- /dev/null +++ b/drivers/media/video/ivtv/ivtv-mailbox.c | |||
@@ -0,0 +1,360 @@ | |||
1 | /* | ||
2 | mailbox functions | ||
3 | Copyright (C) 2003-2004 Kevin Thayer <nufan_wfk at yahoo.com> | ||
4 | Copyright (C) 2004 Chris Kennedy <c@groovy.org> | ||
5 | Copyright (C) 2005-2007 Hans Verkuil <hverkuil@xs4all.nl> | ||
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 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program; if not, write to the Free Software | ||
19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | */ | ||
21 | |||
22 | #include <stdarg.h> | ||
23 | |||
24 | #include "ivtv-driver.h" | ||
25 | #include "ivtv-mailbox.h" | ||
26 | |||
27 | /* Firmware mailbox flags*/ | ||
28 | #define IVTV_MBOX_FIRMWARE_DONE 0x00000004 | ||
29 | #define IVTV_MBOX_DRIVER_DONE 0x00000002 | ||
30 | #define IVTV_MBOX_DRIVER_BUSY 0x00000001 | ||
31 | #define IVTV_MBOX_FREE 0x00000000 | ||
32 | |||
33 | /* Firmware mailbox standard timeout */ | ||
34 | #define IVTV_API_STD_TIMEOUT 0x02000000 | ||
35 | |||
36 | #define API_CACHE (1 << 0) /* Allow the command to be stored in the cache */ | ||
37 | #define API_RESULT (1 << 1) /* Allow 1 second for this cmd to end */ | ||
38 | #define API_FAST_RESULT (3 << 1) /* Allow 0.1 second for this cmd to end */ | ||
39 | #define API_DMA (1 << 3) /* DMA mailbox, has special handling */ | ||
40 | #define API_NO_WAIT_MB (1 << 4) /* Command may not wait for a free mailbox */ | ||
41 | #define API_NO_WAIT_RES (1 << 5) /* Command may not wait for the result */ | ||
42 | |||
43 | struct ivtv_api_info { | ||
44 | int flags; /* Flags, see above */ | ||
45 | const char *name; /* The name of the command */ | ||
46 | }; | ||
47 | |||
48 | #define API_ENTRY(x, f) [x] = { (f), #x } | ||
49 | |||
50 | static const struct ivtv_api_info api_info[256] = { | ||
51 | /* MPEG encoder API */ | ||
52 | API_ENTRY(CX2341X_ENC_PING_FW, API_FAST_RESULT), | ||
53 | API_ENTRY(CX2341X_ENC_START_CAPTURE, API_RESULT), | ||
54 | API_ENTRY(CX2341X_ENC_STOP_CAPTURE, API_RESULT), | ||
55 | API_ENTRY(CX2341X_ENC_SET_AUDIO_ID, API_CACHE), | ||
56 | API_ENTRY(CX2341X_ENC_SET_VIDEO_ID, API_CACHE), | ||
57 | API_ENTRY(CX2341X_ENC_SET_PCR_ID, API_CACHE), | ||
58 | API_ENTRY(CX2341X_ENC_SET_FRAME_RATE, API_CACHE), | ||
59 | API_ENTRY(CX2341X_ENC_SET_FRAME_SIZE, API_CACHE), | ||
60 | API_ENTRY(CX2341X_ENC_SET_BIT_RATE, API_CACHE), | ||
61 | API_ENTRY(CX2341X_ENC_SET_GOP_PROPERTIES, API_CACHE), | ||
62 | API_ENTRY(CX2341X_ENC_SET_ASPECT_RATIO, API_CACHE), | ||
63 | API_ENTRY(CX2341X_ENC_SET_DNR_FILTER_MODE, API_CACHE), | ||
64 | API_ENTRY(CX2341X_ENC_SET_DNR_FILTER_PROPS, API_CACHE), | ||
65 | API_ENTRY(CX2341X_ENC_SET_CORING_LEVELS, API_CACHE), | ||
66 | API_ENTRY(CX2341X_ENC_SET_SPATIAL_FILTER_TYPE, API_CACHE), | ||
67 | API_ENTRY(CX2341X_ENC_SET_VBI_LINE, API_RESULT), | ||
68 | API_ENTRY(CX2341X_ENC_SET_STREAM_TYPE, API_CACHE), | ||
69 | API_ENTRY(CX2341X_ENC_SET_OUTPUT_PORT, API_CACHE), | ||
70 | API_ENTRY(CX2341X_ENC_SET_AUDIO_PROPERTIES, API_CACHE), | ||
71 | API_ENTRY(CX2341X_ENC_HALT_FW, API_FAST_RESULT), | ||
72 | API_ENTRY(CX2341X_ENC_GET_VERSION, API_FAST_RESULT), | ||
73 | API_ENTRY(CX2341X_ENC_SET_GOP_CLOSURE, API_CACHE), | ||
74 | API_ENTRY(CX2341X_ENC_GET_SEQ_END, API_RESULT), | ||
75 | API_ENTRY(CX2341X_ENC_SET_PGM_INDEX_INFO, API_FAST_RESULT), | ||
76 | API_ENTRY(CX2341X_ENC_SET_VBI_CONFIG, API_RESULT), | ||
77 | API_ENTRY(CX2341X_ENC_SET_DMA_BLOCK_SIZE, API_CACHE), | ||
78 | API_ENTRY(CX2341X_ENC_GET_PREV_DMA_INFO_MB_10, API_FAST_RESULT), | ||
79 | API_ENTRY(CX2341X_ENC_GET_PREV_DMA_INFO_MB_9, API_FAST_RESULT), | ||
80 | API_ENTRY(CX2341X_ENC_SCHED_DMA_TO_HOST, API_DMA), | ||
81 | API_ENTRY(CX2341X_ENC_INITIALIZE_INPUT, API_RESULT), | ||
82 | API_ENTRY(CX2341X_ENC_SET_FRAME_DROP_RATE, API_CACHE), | ||
83 | API_ENTRY(CX2341X_ENC_PAUSE_ENCODER, API_RESULT), | ||
84 | API_ENTRY(CX2341X_ENC_REFRESH_INPUT, API_NO_WAIT_MB), | ||
85 | API_ENTRY(CX2341X_ENC_SET_COPYRIGHT, API_CACHE), | ||
86 | API_ENTRY(CX2341X_ENC_SET_EVENT_NOTIFICATION, API_RESULT), | ||
87 | API_ENTRY(CX2341X_ENC_SET_NUM_VSYNC_LINES, API_CACHE), | ||
88 | API_ENTRY(CX2341X_ENC_SET_PLACEHOLDER, API_CACHE), | ||
89 | API_ENTRY(CX2341X_ENC_MUTE_VIDEO, API_RESULT), | ||
90 | API_ENTRY(CX2341X_ENC_MUTE_AUDIO, API_RESULT), | ||
91 | API_ENTRY(CX2341X_ENC_SET_VERT_CROP_LINE, API_FAST_RESULT), | ||
92 | API_ENTRY(CX2341X_ENC_MISC, API_FAST_RESULT), | ||
93 | /* Obsolete PULLDOWN API command */ | ||
94 | API_ENTRY(0xb1, API_CACHE), | ||
95 | |||
96 | /* MPEG decoder API */ | ||
97 | API_ENTRY(CX2341X_DEC_PING_FW, API_FAST_RESULT), | ||
98 | API_ENTRY(CX2341X_DEC_START_PLAYBACK, API_RESULT), | ||
99 | API_ENTRY(CX2341X_DEC_STOP_PLAYBACK, API_RESULT), | ||
100 | API_ENTRY(CX2341X_DEC_SET_PLAYBACK_SPEED, API_RESULT), | ||
101 | API_ENTRY(CX2341X_DEC_STEP_VIDEO, API_RESULT), | ||
102 | API_ENTRY(CX2341X_DEC_SET_DMA_BLOCK_SIZE, API_CACHE), | ||
103 | API_ENTRY(CX2341X_DEC_GET_XFER_INFO, API_FAST_RESULT), | ||
104 | API_ENTRY(CX2341X_DEC_GET_DMA_STATUS, API_FAST_RESULT), | ||
105 | API_ENTRY(CX2341X_DEC_SCHED_DMA_FROM_HOST, API_DMA), | ||
106 | API_ENTRY(CX2341X_DEC_PAUSE_PLAYBACK, API_RESULT), | ||
107 | API_ENTRY(CX2341X_DEC_HALT_FW, API_FAST_RESULT), | ||
108 | API_ENTRY(CX2341X_DEC_SET_STANDARD, API_CACHE), | ||
109 | API_ENTRY(CX2341X_DEC_GET_VERSION, API_FAST_RESULT), | ||
110 | API_ENTRY(CX2341X_DEC_SET_STREAM_INPUT, API_CACHE), | ||
111 | API_ENTRY(CX2341X_DEC_GET_TIMING_INFO, API_RESULT /*| API_NO_WAIT_RES*/), | ||
112 | API_ENTRY(CX2341X_DEC_SET_AUDIO_MODE, API_CACHE), | ||
113 | API_ENTRY(CX2341X_DEC_SET_EVENT_NOTIFICATION, API_RESULT), | ||
114 | API_ENTRY(CX2341X_DEC_SET_DISPLAY_BUFFERS, API_CACHE), | ||
115 | API_ENTRY(CX2341X_DEC_EXTRACT_VBI, API_RESULT), | ||
116 | API_ENTRY(CX2341X_DEC_SET_DECODER_SOURCE, API_FAST_RESULT), | ||
117 | API_ENTRY(CX2341X_DEC_SET_PREBUFFERING, API_CACHE), | ||
118 | |||
119 | /* OSD API */ | ||
120 | API_ENTRY(CX2341X_OSD_GET_FRAMEBUFFER, API_FAST_RESULT), | ||
121 | API_ENTRY(CX2341X_OSD_GET_PIXEL_FORMAT, API_FAST_RESULT), | ||
122 | API_ENTRY(CX2341X_OSD_SET_PIXEL_FORMAT, API_CACHE), | ||
123 | API_ENTRY(CX2341X_OSD_GET_STATE, API_FAST_RESULT), | ||
124 | API_ENTRY(CX2341X_OSD_SET_STATE, API_CACHE), | ||
125 | API_ENTRY(CX2341X_OSD_GET_OSD_COORDS, API_FAST_RESULT), | ||
126 | API_ENTRY(CX2341X_OSD_SET_OSD_COORDS, API_CACHE), | ||
127 | API_ENTRY(CX2341X_OSD_GET_SCREEN_COORDS, API_FAST_RESULT), | ||
128 | API_ENTRY(CX2341X_OSD_SET_SCREEN_COORDS, API_CACHE), | ||
129 | API_ENTRY(CX2341X_OSD_GET_GLOBAL_ALPHA, API_FAST_RESULT), | ||
130 | API_ENTRY(CX2341X_OSD_SET_GLOBAL_ALPHA, API_CACHE), | ||
131 | API_ENTRY(CX2341X_OSD_SET_BLEND_COORDS, API_CACHE), | ||
132 | API_ENTRY(CX2341X_OSD_GET_FLICKER_STATE, API_FAST_RESULT), | ||
133 | API_ENTRY(CX2341X_OSD_SET_FLICKER_STATE, API_CACHE), | ||
134 | API_ENTRY(CX2341X_OSD_BLT_COPY, API_RESULT), | ||
135 | API_ENTRY(CX2341X_OSD_BLT_FILL, API_RESULT), | ||
136 | API_ENTRY(CX2341X_OSD_BLT_TEXT, API_RESULT), | ||
137 | API_ENTRY(CX2341X_OSD_SET_FRAMEBUFFER_WINDOW, API_CACHE), | ||
138 | API_ENTRY(CX2341X_OSD_SET_CHROMA_KEY, API_CACHE), | ||
139 | API_ENTRY(CX2341X_OSD_GET_ALPHA_CONTENT_INDEX, API_FAST_RESULT), | ||
140 | API_ENTRY(CX2341X_OSD_SET_ALPHA_CONTENT_INDEX, API_CACHE) | ||
141 | }; | ||
142 | |||
143 | static int try_mailbox(struct ivtv *itv, struct ivtv_mailbox_data *mbdata, int mb) | ||
144 | { | ||
145 | u32 flags = readl(&mbdata->mbox[mb].flags); | ||
146 | int is_free = flags == IVTV_MBOX_FREE || (flags & IVTV_MBOX_FIRMWARE_DONE); | ||
147 | |||
148 | /* if the mailbox is free, then try to claim it */ | ||
149 | if (is_free && !test_and_set_bit(mb, &mbdata->busy)) { | ||
150 | write_sync(IVTV_MBOX_DRIVER_BUSY, &mbdata->mbox[mb].flags); | ||
151 | return 1; | ||
152 | } | ||
153 | return 0; | ||
154 | } | ||
155 | |||
156 | /* Try to find a free mailbox. Note mailbox 0 is reserved for DMA and so is not | ||
157 | attempted here. */ | ||
158 | static int get_mailbox(struct ivtv *itv, struct ivtv_mailbox_data *mbdata, int flags) | ||
159 | { | ||
160 | unsigned long then = jiffies; | ||
161 | int i, mb; | ||
162 | int max_mbox = mbdata->max_mbox; | ||
163 | int retries = 100; | ||
164 | |||
165 | /* All slow commands use the same mailbox, serializing them and also | ||
166 | leaving the other mailbox free for simple fast commands. */ | ||
167 | if ((flags & API_FAST_RESULT) == API_RESULT) | ||
168 | max_mbox = 1; | ||
169 | |||
170 | /* find free non-DMA mailbox */ | ||
171 | for (i = 0; i < retries; i++) { | ||
172 | for (mb = 1; mb <= max_mbox; mb++) | ||
173 | if (try_mailbox(itv, mbdata, mb)) | ||
174 | return mb; | ||
175 | |||
176 | /* Sleep before a retry, if not atomic */ | ||
177 | if (!(flags & API_NO_WAIT_MB)) { | ||
178 | if (jiffies - then > retries * HZ / 100) | ||
179 | break; | ||
180 | ivtv_sleep_timeout(HZ / 100, 0); | ||
181 | } | ||
182 | } | ||
183 | return -ENODEV; | ||
184 | } | ||
185 | |||
186 | static void write_mailbox(volatile struct ivtv_mailbox __iomem *mbox, int cmd, int args, u32 data[]) | ||
187 | { | ||
188 | int i; | ||
189 | |||
190 | write_sync(cmd, &mbox->cmd); | ||
191 | write_sync(IVTV_API_STD_TIMEOUT, &mbox->timeout); | ||
192 | |||
193 | for (i = 0; i < CX2341X_MBOX_MAX_DATA; i++) | ||
194 | write_sync(data[i], &mbox->data[i]); | ||
195 | |||
196 | write_sync(IVTV_MBOX_DRIVER_DONE | IVTV_MBOX_DRIVER_BUSY, &mbox->flags); | ||
197 | } | ||
198 | |||
199 | static void clear_all_mailboxes(struct ivtv *itv, struct ivtv_mailbox_data *mbdata) | ||
200 | { | ||
201 | int i; | ||
202 | |||
203 | for (i = 0; i <= mbdata->max_mbox; i++) { | ||
204 | IVTV_DEBUG_WARN("Clearing mailbox %d: cmd 0x%08x flags 0x%08x\n", | ||
205 | i, readl(&mbdata->mbox[i].cmd), readl(&mbdata->mbox[i].flags)); | ||
206 | write_sync(0, &mbdata->mbox[i].flags); | ||
207 | clear_bit(i, &mbdata->busy); | ||
208 | } | ||
209 | } | ||
210 | |||
211 | static int ivtv_api_call(struct ivtv *itv, int cmd, int args, u32 data[]) | ||
212 | { | ||
213 | struct ivtv_mailbox_data *mbdata = (cmd >= 128) ? &itv->enc_mbox : &itv->dec_mbox; | ||
214 | volatile struct ivtv_mailbox __iomem *mbox; | ||
215 | int api_timeout = HZ; | ||
216 | int flags, mb, i; | ||
217 | unsigned long then; | ||
218 | |||
219 | /* sanity checks */ | ||
220 | if (NULL == mbdata) { | ||
221 | IVTV_ERR("No mailbox allocated\n"); | ||
222 | return -ENODEV; | ||
223 | } | ||
224 | if (args < 0 || args > CX2341X_MBOX_MAX_DATA || | ||
225 | cmd < 0 || cmd > 255 || api_info[cmd].name == NULL) { | ||
226 | IVTV_ERR("Invalid API call: cmd = 0x%02x, args = %d\n", cmd, args); | ||
227 | return -EINVAL; | ||
228 | } | ||
229 | |||
230 | IVTV_DEBUG_API("API Call: %s\n", api_info[cmd].name); | ||
231 | |||
232 | /* clear possibly uninitialized part of data array */ | ||
233 | for (i = args; i < CX2341X_MBOX_MAX_DATA; i++) | ||
234 | data[i] = 0; | ||
235 | |||
236 | /* If this command was issued within the last 30 minutes and with identical | ||
237 | data, then just return 0 as there is no need to issue this command again. | ||
238 | Just an optimization to prevent unnecessary use of mailboxes. */ | ||
239 | if (itv->api_cache[cmd].last_jiffies && | ||
240 | jiffies - itv->api_cache[cmd].last_jiffies < HZ * 1800 && | ||
241 | !memcmp(data, itv->api_cache[cmd].data, sizeof(itv->api_cache[cmd].data))) { | ||
242 | itv->api_cache[cmd].last_jiffies = jiffies; | ||
243 | return 0; | ||
244 | } | ||
245 | |||
246 | flags = api_info[cmd].flags; | ||
247 | |||
248 | if (flags & API_DMA) { | ||
249 | for (i = 0; i < 100; i++) { | ||
250 | mb = i % (mbdata->max_mbox + 1); | ||
251 | if (try_mailbox(itv, mbdata, mb)) { | ||
252 | write_mailbox(&mbdata->mbox[mb], cmd, args, data); | ||
253 | clear_bit(mb, &mbdata->busy); | ||
254 | return 0; | ||
255 | } | ||
256 | IVTV_DEBUG_WARN("%s: mailbox %d not free %08x\n", | ||
257 | api_info[cmd].name, mb, readl(&mbdata->mbox[mb].flags)); | ||
258 | } | ||
259 | IVTV_WARN("Could not find free DMA mailbox for %s\n", api_info[cmd].name); | ||
260 | clear_all_mailboxes(itv, mbdata); | ||
261 | return -EBUSY; | ||
262 | } | ||
263 | |||
264 | if ((flags & API_FAST_RESULT) == API_FAST_RESULT) | ||
265 | api_timeout = HZ / 10; | ||
266 | |||
267 | mb = get_mailbox(itv, mbdata, flags); | ||
268 | if (mb < 0) { | ||
269 | IVTV_DEBUG_WARN("No free mailbox found (%s)\n", api_info[cmd].name); | ||
270 | clear_all_mailboxes(itv, mbdata); | ||
271 | return -EBUSY; | ||
272 | } | ||
273 | mbox = &mbdata->mbox[mb]; | ||
274 | write_mailbox(mbox, cmd, args, data); | ||
275 | if (flags & API_CACHE) { | ||
276 | memcpy(itv->api_cache[cmd].data, data, sizeof(itv->api_cache[cmd].data)); | ||
277 | itv->api_cache[cmd].last_jiffies = jiffies; | ||
278 | } | ||
279 | if ((flags & API_RESULT) == 0) { | ||
280 | clear_bit(mb, &mbdata->busy); | ||
281 | return 0; | ||
282 | } | ||
283 | |||
284 | /* Get results */ | ||
285 | then = jiffies; | ||
286 | |||
287 | while (!(readl(&mbox->flags) & IVTV_MBOX_FIRMWARE_DONE)) { | ||
288 | if (jiffies - then > api_timeout) { | ||
289 | IVTV_DEBUG_WARN("Could not get result (%s)\n", api_info[cmd].name); | ||
290 | /* reset the mailbox, but it is likely too late already */ | ||
291 | write_sync(0, &mbox->flags); | ||
292 | clear_bit(mb, &mbdata->busy); | ||
293 | return -EIO; | ||
294 | } | ||
295 | if (flags & API_NO_WAIT_RES) | ||
296 | mdelay(1); | ||
297 | else | ||
298 | ivtv_sleep_timeout(HZ / 100, 0); | ||
299 | } | ||
300 | if (jiffies - then > HZ / 10) | ||
301 | IVTV_DEBUG_WARN("%s took %lu jiffies (%d per HZ)\n", | ||
302 | api_info[cmd].name, jiffies - then, HZ); | ||
303 | |||
304 | for (i = 0; i < CX2341X_MBOX_MAX_DATA; i++) | ||
305 | data[i] = readl(&mbox->data[i]); | ||
306 | write_sync(0, &mbox->flags); | ||
307 | clear_bit(mb, &mbdata->busy); | ||
308 | return 0; | ||
309 | } | ||
310 | |||
311 | int ivtv_api(struct ivtv *itv, int cmd, int args, u32 data[]) | ||
312 | { | ||
313 | int res = ivtv_api_call(itv, cmd, args, data); | ||
314 | |||
315 | /* Allow a single retry, probably already too late though. | ||
316 | If there is no free mailbox then that is usually an indication | ||
317 | of a more serious problem. */ | ||
318 | return (res == -EBUSY) ? ivtv_api_call(itv, cmd, args, data) : res; | ||
319 | } | ||
320 | |||
321 | int ivtv_api_func(void *priv, int cmd, int in, int out, u32 data[CX2341X_MBOX_MAX_DATA]) | ||
322 | { | ||
323 | return ivtv_api(priv, cmd, in, data); | ||
324 | } | ||
325 | |||
326 | int ivtv_vapi_result(struct ivtv *itv, u32 data[CX2341X_MBOX_MAX_DATA], int cmd, int args, ...) | ||
327 | { | ||
328 | va_list ap; | ||
329 | int i; | ||
330 | |||
331 | va_start(ap, args); | ||
332 | for (i = 0; i < args; i++) { | ||
333 | data[i] = va_arg(ap, u32); | ||
334 | } | ||
335 | va_end(ap); | ||
336 | return ivtv_api(itv, cmd, args, data); | ||
337 | } | ||
338 | |||
339 | int ivtv_vapi(struct ivtv *itv, int cmd, int args, ...) | ||
340 | { | ||
341 | u32 data[CX2341X_MBOX_MAX_DATA]; | ||
342 | va_list ap; | ||
343 | int i; | ||
344 | |||
345 | va_start(ap, args); | ||
346 | for (i = 0; i < args; i++) { | ||
347 | data[i] = va_arg(ap, u32); | ||
348 | } | ||
349 | va_end(ap); | ||
350 | return ivtv_api(itv, cmd, args, data); | ||
351 | } | ||
352 | |||
353 | /* This one is for stuff that can't sleep.. irq handlers, etc.. */ | ||
354 | void ivtv_api_get_data(struct ivtv_mailbox_data *mbdata, int mb, u32 data[]) | ||
355 | { | ||
356 | int i; | ||
357 | |||
358 | for (i = 0; i < CX2341X_MBOX_MAX_DATA; i++) | ||
359 | data[i] = readl(&mbdata->mbox[mb].data[i]); | ||
360 | } | ||