aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFederico Simoncelli <fsimonce@redhat.com>2014-08-11 17:42:22 -0400
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-08-21 16:25:34 -0400
commit63ddf68de52efaac40a9287e44266ac30e71dd36 (patch)
tree660f726bacc3e850925a1c25c5c84103b3a12e16
parentc8fa50549dc6e717e0941ee7092a973388253c7a (diff)
[media] usbtv: add audio support
Add an ALSA handler inside usbtv module, in order to make audio to work with those devices. Signed-off-by: Federico Simoncelli <fsimonce@redhat.com> Tested-by: Lubomir Rintel <lkundrak@v3.sk> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
-rw-r--r--drivers/media/usb/usbtv/Makefile3
-rw-r--r--drivers/media/usb/usbtv/usbtv-audio.c384
-rw-r--r--drivers/media/usb/usbtv/usbtv-core.c16
-rw-r--r--drivers/media/usb/usbtv/usbtv-video.c9
-rw-r--r--drivers/media/usb/usbtv/usbtv.h21
5 files changed, 423 insertions, 10 deletions
diff --git a/drivers/media/usb/usbtv/Makefile b/drivers/media/usb/usbtv/Makefile
index 775316a88ea6..f555cf8a3dd2 100644
--- a/drivers/media/usb/usbtv/Makefile
+++ b/drivers/media/usb/usbtv/Makefile
@@ -1,4 +1,5 @@
1usbtv-y := usbtv-core.o \ 1usbtv-y := usbtv-core.o \
2 usbtv-video.o 2 usbtv-video.o \
3 usbtv-audio.o
3 4
4obj-$(CONFIG_VIDEO_USBTV) += usbtv.o 5obj-$(CONFIG_VIDEO_USBTV) += usbtv.o
diff --git a/drivers/media/usb/usbtv/usbtv-audio.c b/drivers/media/usb/usbtv/usbtv-audio.c
new file mode 100644
index 000000000000..2d8795f683bf
--- /dev/null
+++ b/drivers/media/usb/usbtv/usbtv-audio.c
@@ -0,0 +1,384 @@
1/*
2 * Fushicai USBTV007 Audio-Video Grabber Driver
3 *
4 * Product web site:
5 * http://www.fushicai.com/products_detail/&productId=d05449ee-b690-42f9-a661-aa7353894bed.html
6 *
7 * Copyright (c) 2013 Federico Simoncelli
8 * All rights reserved.
9 * No physical hardware was harmed running Windows during the
10 * reverse-engineering activity
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
20 *
21 * Alternatively, this software may be distributed under the terms of the
22 * GNU General Public License ("GPL").
23 */
24
25#include <sound/core.h>
26#include <sound/initval.h>
27#include <sound/ac97_codec.h>
28#include <sound/pcm_params.h>
29
30#include "usbtv.h"
31
32static struct snd_pcm_hardware snd_usbtv_digital_hw = {
33 .info = SNDRV_PCM_INFO_BATCH |
34 SNDRV_PCM_INFO_MMAP |
35 SNDRV_PCM_INFO_INTERLEAVED |
36 SNDRV_PCM_INFO_BLOCK_TRANSFER |
37 SNDRV_PCM_INFO_MMAP_VALID,
38 .formats = SNDRV_PCM_FMTBIT_S16_LE,
39 .rates = SNDRV_PCM_RATE_48000,
40 .rate_min = 48000,
41 .rate_max = 48000,
42 .channels_min = 2,
43 .channels_max = 2,
44 .period_bytes_min = 11059,
45 .period_bytes_max = 13516,
46 .periods_min = 2,
47 .periods_max = 98,
48 .buffer_bytes_max = 62720 * 8, /* value in usbaudio.c */
49};
50
51static int snd_usbtv_pcm_open(struct snd_pcm_substream *substream)
52{
53 struct usbtv *chip = snd_pcm_substream_chip(substream);
54 struct snd_pcm_runtime *runtime = substream->runtime;
55
56 chip->snd_substream = substream;
57 runtime->hw = snd_usbtv_digital_hw;
58
59 return 0;
60}
61
62static int snd_usbtv_pcm_close(struct snd_pcm_substream *substream)
63{
64 struct usbtv *chip = snd_pcm_substream_chip(substream);
65
66 if (atomic_read(&chip->snd_stream)) {
67 atomic_set(&chip->snd_stream, 0);
68 schedule_work(&chip->snd_trigger);
69 }
70
71 return 0;
72}
73
74static int snd_usbtv_hw_params(struct snd_pcm_substream *substream,
75 struct snd_pcm_hw_params *hw_params)
76{
77 int rv;
78 struct usbtv *chip = snd_pcm_substream_chip(substream);
79
80 rv = snd_pcm_lib_malloc_pages(substream,
81 params_buffer_bytes(hw_params));
82
83 if (rv < 0) {
84 dev_warn(chip->dev, "pcm audio buffer allocation failure %i\n",
85 rv);
86 return rv;
87 }
88
89 return 0;
90}
91
92static int snd_usbtv_hw_free(struct snd_pcm_substream *substream)
93{
94 snd_pcm_lib_free_pages(substream);
95 return 0;
96}
97
98static int snd_usbtv_prepare(struct snd_pcm_substream *substream)
99{
100 struct usbtv *chip = snd_pcm_substream_chip(substream);
101
102 chip->snd_buffer_pos = 0;
103 chip->snd_period_pos = 0;
104
105 return 0;
106}
107
108static void usbtv_audio_urb_received(struct urb *urb)
109{
110 struct usbtv *chip = urb->context;
111 struct snd_pcm_substream *substream = chip->snd_substream;
112 struct snd_pcm_runtime *runtime = substream->runtime;
113 size_t i, frame_bytes, chunk_length, buffer_pos, period_pos;
114 int period_elapsed;
115 void *urb_current;
116
117 switch (urb->status) {
118 case 0:
119 case -ETIMEDOUT:
120 break;
121 case -ENOENT:
122 case -EPROTO:
123 case -ECONNRESET:
124 case -ESHUTDOWN:
125 return;
126 default:
127 dev_warn(chip->dev, "unknown audio urb status %i\n",
128 urb->status);
129 }
130
131 if (!atomic_read(&chip->snd_stream))
132 return;
133
134 frame_bytes = runtime->frame_bits >> 3;
135 chunk_length = USBTV_CHUNK / frame_bytes;
136
137 buffer_pos = chip->snd_buffer_pos;
138 period_pos = chip->snd_period_pos;
139 period_elapsed = 0;
140
141 for (i = 0; i < urb->actual_length; i += USBTV_CHUNK_SIZE) {
142 urb_current = urb->transfer_buffer + i + USBTV_AUDIO_HDRSIZE;
143
144 if (buffer_pos + chunk_length >= runtime->buffer_size) {
145 size_t cnt = (runtime->buffer_size - buffer_pos) *
146 frame_bytes;
147 memcpy(runtime->dma_area + buffer_pos * frame_bytes,
148 urb_current, cnt);
149 memcpy(runtime->dma_area, urb_current + cnt,
150 chunk_length * frame_bytes - cnt);
151 } else {
152 memcpy(runtime->dma_area + buffer_pos * frame_bytes,
153 urb_current, chunk_length * frame_bytes);
154 }
155
156 buffer_pos += chunk_length;
157 period_pos += chunk_length;
158
159 if (buffer_pos >= runtime->buffer_size)
160 buffer_pos -= runtime->buffer_size;
161
162 if (period_pos >= runtime->period_size) {
163 period_pos -= runtime->period_size;
164 period_elapsed = 1;
165 }
166 }
167
168 snd_pcm_stream_lock(substream);
169
170 chip->snd_buffer_pos = buffer_pos;
171 chip->snd_period_pos = period_pos;
172
173 snd_pcm_stream_unlock(substream);
174
175 if (period_elapsed)
176 snd_pcm_period_elapsed(substream);
177
178 usb_submit_urb(urb, GFP_ATOMIC);
179}
180
181static int usbtv_audio_start(struct usbtv *chip)
182{
183 unsigned int pipe;
184 static const u16 setup[][2] = {
185 /* These seem to enable the device. */
186 { USBTV_BASE + 0x0008, 0x0001 },
187 { USBTV_BASE + 0x01d0, 0x00ff },
188 { USBTV_BASE + 0x01d9, 0x0002 },
189
190 { USBTV_BASE + 0x01da, 0x0013 },
191 { USBTV_BASE + 0x01db, 0x0012 },
192 { USBTV_BASE + 0x01e9, 0x0002 },
193 { USBTV_BASE + 0x01ec, 0x006c },
194 { USBTV_BASE + 0x0294, 0x0020 },
195 { USBTV_BASE + 0x0255, 0x00cf },
196 { USBTV_BASE + 0x0256, 0x0020 },
197 { USBTV_BASE + 0x01eb, 0x0030 },
198 { USBTV_BASE + 0x027d, 0x00a6 },
199 { USBTV_BASE + 0x0280, 0x0011 },
200 { USBTV_BASE + 0x0281, 0x0040 },
201 { USBTV_BASE + 0x0282, 0x0011 },
202 { USBTV_BASE + 0x0283, 0x0040 },
203 { 0xf891, 0x0010 },
204
205 /* this sets the input from composite */
206 { USBTV_BASE + 0x0284, 0x00aa },
207 };
208
209 chip->snd_bulk_urb = usb_alloc_urb(0, GFP_KERNEL);
210 if (chip->snd_bulk_urb == NULL)
211 goto err_alloc_urb;
212
213 pipe = usb_rcvbulkpipe(chip->udev, USBTV_AUDIO_ENDP);
214
215 chip->snd_bulk_urb->transfer_buffer = kzalloc(
216 USBTV_AUDIO_URBSIZE, GFP_KERNEL);
217 if (chip->snd_bulk_urb->transfer_buffer == NULL)
218 goto err_transfer_buffer;
219
220 usb_fill_bulk_urb(chip->snd_bulk_urb, chip->udev, pipe,
221 chip->snd_bulk_urb->transfer_buffer, USBTV_AUDIO_URBSIZE,
222 usbtv_audio_urb_received, chip);
223
224 /* starting the stream */
225 usbtv_set_regs(chip, setup, ARRAY_SIZE(setup));
226
227 usb_clear_halt(chip->udev, pipe);
228 usb_submit_urb(chip->snd_bulk_urb, GFP_ATOMIC);
229
230 return 0;
231
232err_transfer_buffer:
233 usb_free_urb(chip->snd_bulk_urb);
234 chip->snd_bulk_urb = NULL;
235
236err_alloc_urb:
237 return -ENOMEM;
238}
239
240static int usbtv_audio_stop(struct usbtv *chip)
241{
242 static const u16 setup[][2] = {
243 /* The original windows driver sometimes sends also:
244 * { USBTV_BASE + 0x00a2, 0x0013 }
245 * but it seems useless and its real effects are untested at
246 * the moment.
247 */
248 { USBTV_BASE + 0x027d, 0x0000 },
249 { USBTV_BASE + 0x0280, 0x0010 },
250 { USBTV_BASE + 0x0282, 0x0010 },
251 };
252
253 if (chip->snd_bulk_urb) {
254 usb_kill_urb(chip->snd_bulk_urb);
255 kfree(chip->snd_bulk_urb->transfer_buffer);
256 usb_free_urb(chip->snd_bulk_urb);
257 chip->snd_bulk_urb = NULL;
258 }
259
260 usbtv_set_regs(chip, setup, ARRAY_SIZE(setup));
261
262 return 0;
263}
264
265void usbtv_audio_suspend(struct usbtv *usbtv)
266{
267 if (atomic_read(&usbtv->snd_stream) && usbtv->snd_bulk_urb)
268 usb_kill_urb(usbtv->snd_bulk_urb);
269}
270
271void usbtv_audio_resume(struct usbtv *usbtv)
272{
273 if (atomic_read(&usbtv->snd_stream) && usbtv->snd_bulk_urb)
274 usb_submit_urb(usbtv->snd_bulk_urb, GFP_ATOMIC);
275}
276
277static void snd_usbtv_trigger(struct work_struct *work)
278{
279 struct usbtv *chip = container_of(work, struct usbtv, snd_trigger);
280
281 if (atomic_read(&chip->snd_stream))
282 usbtv_audio_start(chip);
283 else
284 usbtv_audio_stop(chip);
285}
286
287static int snd_usbtv_card_trigger(struct snd_pcm_substream *substream, int cmd)
288{
289 struct usbtv *chip = snd_pcm_substream_chip(substream);
290
291 switch (cmd) {
292 case SNDRV_PCM_TRIGGER_START:
293 case SNDRV_PCM_TRIGGER_RESUME:
294 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
295 atomic_set(&chip->snd_stream, 1);
296 break;
297 case SNDRV_PCM_TRIGGER_STOP:
298 case SNDRV_PCM_TRIGGER_SUSPEND:
299 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
300 atomic_set(&chip->snd_stream, 0);
301 break;
302 default:
303 return -EINVAL;
304 }
305
306 schedule_work(&chip->snd_trigger);
307
308 return 0;
309}
310
311static snd_pcm_uframes_t snd_usbtv_pointer(struct snd_pcm_substream *substream)
312{
313 struct usbtv *chip = snd_pcm_substream_chip(substream);
314 return chip->snd_buffer_pos;
315}
316
317static struct snd_pcm_ops snd_usbtv_pcm_ops = {
318 .open = snd_usbtv_pcm_open,
319 .close = snd_usbtv_pcm_close,
320 .ioctl = snd_pcm_lib_ioctl,
321 .hw_params = snd_usbtv_hw_params,
322 .hw_free = snd_usbtv_hw_free,
323 .prepare = snd_usbtv_prepare,
324 .trigger = snd_usbtv_card_trigger,
325 .pointer = snd_usbtv_pointer,
326};
327
328int usbtv_audio_init(struct usbtv *usbtv)
329{
330 int rv;
331 struct snd_card *card;
332 struct snd_pcm *pcm;
333
334 INIT_WORK(&usbtv->snd_trigger, snd_usbtv_trigger);
335 atomic_set(&usbtv->snd_stream, 0);
336
337 rv = snd_card_new(&usbtv->udev->dev, SNDRV_DEFAULT_IDX1, "usbtv",
338 THIS_MODULE, 0, &card);
339 if (rv < 0)
340 return rv;
341
342 strlcpy(card->driver, usbtv->dev->driver->name, sizeof(card->driver));
343 strlcpy(card->shortname, "usbtv", sizeof(card->shortname));
344 snprintf(card->longname, sizeof(card->longname),
345 "USBTV Audio at bus %d device %d", usbtv->udev->bus->busnum,
346 usbtv->udev->devnum);
347
348 snd_card_set_dev(card, usbtv->dev);
349
350 usbtv->snd = card;
351
352 rv = snd_pcm_new(card, "USBTV Audio", 0, 0, 1, &pcm);
353 if (rv < 0)
354 goto err;
355
356 strlcpy(pcm->name, "USBTV Audio Input", sizeof(pcm->name));
357 pcm->info_flags = 0;
358 pcm->private_data = usbtv;
359
360 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_usbtv_pcm_ops);
361 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS,
362 snd_dma_continuous_data(GFP_KERNEL), USBTV_AUDIO_BUFFER,
363 USBTV_AUDIO_BUFFER);
364
365 rv = snd_card_register(card);
366 if (rv)
367 goto err;
368
369 return 0;
370
371err:
372 usbtv->snd = NULL;
373 snd_card_free(card);
374
375 return rv;
376}
377
378void usbtv_audio_free(struct usbtv *usbtv)
379{
380 if (usbtv->snd && usbtv->udev) {
381 snd_card_free(usbtv->snd);
382 usbtv->snd = NULL;
383 }
384}
diff --git a/drivers/media/usb/usbtv/usbtv-core.c b/drivers/media/usb/usbtv/usbtv-core.c
index 473fab81b602..bf25ecf143a2 100644
--- a/drivers/media/usb/usbtv/usbtv-core.c
+++ b/drivers/media/usb/usbtv/usbtv-core.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Fushicai USBTV007 Video Grabber Driver 2 * Fushicai USBTV007 Audio-Video Grabber Driver
3 * 3 *
4 * Product web site: 4 * Product web site:
5 * http://www.fushicai.com/products_detail/&productId=d05449ee-b690-42f9-a661-aa7353894bed.html 5 * http://www.fushicai.com/products_detail/&productId=d05449ee-b690-42f9-a661-aa7353894bed.html
@@ -84,12 +84,19 @@ static int usbtv_probe(struct usb_interface *intf,
84 if (ret < 0) 84 if (ret < 0)
85 goto usbtv_video_fail; 85 goto usbtv_video_fail;
86 86
87 ret = usbtv_audio_init(usbtv);
88 if (ret < 0)
89 goto usbtv_audio_fail;
90
87 /* for simplicity we exploit the v4l2_device reference counting */ 91 /* for simplicity we exploit the v4l2_device reference counting */
88 v4l2_device_get(&usbtv->v4l2_dev); 92 v4l2_device_get(&usbtv->v4l2_dev);
89 93
90 dev_info(dev, "Fushicai USBTV007 Video Grabber\n"); 94 dev_info(dev, "Fushicai USBTV007 Audio-Video Grabber\n");
91 return 0; 95 return 0;
92 96
97usbtv_audio_fail:
98 usbtv_video_free(usbtv);
99
93usbtv_video_fail: 100usbtv_video_fail:
94 usb_set_intfdata(intf, NULL); 101 usb_set_intfdata(intf, NULL);
95 usb_put_dev(usbtv->udev); 102 usb_put_dev(usbtv->udev);
@@ -106,6 +113,7 @@ static void usbtv_disconnect(struct usb_interface *intf)
106 if (!usbtv) 113 if (!usbtv)
107 return; 114 return;
108 115
116 usbtv_audio_free(usbtv);
109 usbtv_video_free(usbtv); 117 usbtv_video_free(usbtv);
110 118
111 usb_put_dev(usbtv->udev); 119 usb_put_dev(usbtv->udev);
@@ -122,8 +130,8 @@ static struct usb_device_id usbtv_id_table[] = {
122}; 130};
123MODULE_DEVICE_TABLE(usb, usbtv_id_table); 131MODULE_DEVICE_TABLE(usb, usbtv_id_table);
124 132
125MODULE_AUTHOR("Lubomir Rintel"); 133MODULE_AUTHOR("Lubomir Rintel, Federico Simoncelli");
126MODULE_DESCRIPTION("Fushicai USBTV007 Video Grabber Driver"); 134MODULE_DESCRIPTION("Fushicai USBTV007 Audio-Video Grabber Driver");
127MODULE_LICENSE("Dual BSD/GPL"); 135MODULE_LICENSE("Dual BSD/GPL");
128 136
129static struct usb_driver usbtv_usb_driver = { 137static struct usb_driver usbtv_usb_driver = {
diff --git a/drivers/media/usb/usbtv/usbtv-video.c b/drivers/media/usb/usbtv/usbtv-video.c
index 030c5854b4b3..692c7188a8a6 100644
--- a/drivers/media/usb/usbtv/usbtv-video.c
+++ b/drivers/media/usb/usbtv/usbtv-video.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Fushicai USBTV007 Video Grabber Driver 2 * Fushicai USBTV007 Audio-Video Grabber Driver
3 * 3 *
4 * Product web site: 4 * Product web site:
5 * http://www.fushicai.com/products_detail/&productId=d05449ee-b690-42f9-a661-aa7353894bed.html 5 * http://www.fushicai.com/products_detail/&productId=d05449ee-b690-42f9-a661-aa7353894bed.html
@@ -79,7 +79,6 @@ static int usbtv_select_input(struct usbtv *usbtv, int input)
79 { USBTV_BASE + 0x011f, 0x00f2 }, 79 { USBTV_BASE + 0x011f, 0x00f2 },
80 { USBTV_BASE + 0x0127, 0x0060 }, 80 { USBTV_BASE + 0x0127, 0x0060 },
81 { USBTV_BASE + 0x00ae, 0x0010 }, 81 { USBTV_BASE + 0x00ae, 0x0010 },
82 { USBTV_BASE + 0x0284, 0x00aa },
83 { USBTV_BASE + 0x0239, 0x0060 }, 82 { USBTV_BASE + 0x0239, 0x0060 },
84 }; 83 };
85 84
@@ -88,7 +87,6 @@ static int usbtv_select_input(struct usbtv *usbtv, int input)
88 { USBTV_BASE + 0x011f, 0x00ff }, 87 { USBTV_BASE + 0x011f, 0x00ff },
89 { USBTV_BASE + 0x0127, 0x0060 }, 88 { USBTV_BASE + 0x0127, 0x0060 },
90 { USBTV_BASE + 0x00ae, 0x0030 }, 89 { USBTV_BASE + 0x00ae, 0x0030 },
91 { USBTV_BASE + 0x0284, 0x0088 },
92 { USBTV_BASE + 0x0239, 0x0060 }, 90 { USBTV_BASE + 0x0239, 0x0060 },
93 }; 91 };
94 92
@@ -225,7 +223,6 @@ static int usbtv_setup_capture(struct usbtv *usbtv)
225 { USBTV_BASE + 0x0159, 0x0006 }, 223 { USBTV_BASE + 0x0159, 0x0006 },
226 { USBTV_BASE + 0x015d, 0x0000 }, 224 { USBTV_BASE + 0x015d, 0x0000 },
227 225
228 { USBTV_BASE + 0x0284, 0x0088 },
229 { USBTV_BASE + 0x0003, 0x0004 }, 226 { USBTV_BASE + 0x0003, 0x0004 },
230 { USBTV_BASE + 0x0100, 0x00d3 }, 227 { USBTV_BASE + 0x0100, 0x00d3 },
231 { USBTV_BASE + 0x0115, 0x0015 }, 228 { USBTV_BASE + 0x0115, 0x0015 },
@@ -434,6 +431,8 @@ static int usbtv_start(struct usbtv *usbtv)
434 int i; 431 int i;
435 int ret; 432 int ret;
436 433
434 usbtv_audio_suspend(usbtv);
435
437 ret = usb_set_interface(usbtv->udev, 0, 0); 436 ret = usb_set_interface(usbtv->udev, 0, 0);
438 if (ret < 0) 437 if (ret < 0)
439 return ret; 438 return ret;
@@ -446,6 +445,8 @@ static int usbtv_start(struct usbtv *usbtv)
446 if (ret < 0) 445 if (ret < 0)
447 return ret; 446 return ret;
448 447
448 usbtv_audio_resume(usbtv);
449
449 for (i = 0; i < USBTV_ISOC_TRANSFERS; i++) { 450 for (i = 0; i < USBTV_ISOC_TRANSFERS; i++) {
450 struct urb *ip; 451 struct urb *ip;
451 452
diff --git a/drivers/media/usb/usbtv/usbtv.h b/drivers/media/usb/usbtv/usbtv.h
index cb1d388cc647..968119581fab 100644
--- a/drivers/media/usb/usbtv/usbtv.h
+++ b/drivers/media/usb/usbtv/usbtv.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Fushicai USBTV007 Video Grabber Driver 2 * Fushicai USBTV007 Audio-Video Grabber Driver
3 * 3 *
4 * Copyright (c) 2013 Lubomir Rintel 4 * Copyright (c) 2013 Lubomir Rintel
5 * All rights reserved. 5 * All rights reserved.
@@ -28,6 +28,7 @@
28 28
29/* Hardware. */ 29/* Hardware. */
30#define USBTV_VIDEO_ENDP 0x81 30#define USBTV_VIDEO_ENDP 0x81
31#define USBTV_AUDIO_ENDP 0x83
31#define USBTV_BASE 0xc000 32#define USBTV_BASE 0xc000
32#define USBTV_REQUEST_REG 12 33#define USBTV_REQUEST_REG 12
33 34
@@ -39,6 +40,10 @@
39#define USBTV_CHUNK_SIZE 256 40#define USBTV_CHUNK_SIZE 256
40#define USBTV_CHUNK 240 41#define USBTV_CHUNK 240
41 42
43#define USBTV_AUDIO_URBSIZE 20480
44#define USBTV_AUDIO_HDRSIZE 4
45#define USBTV_AUDIO_BUFFER 65536
46
42/* Chunk header. */ 47/* Chunk header. */
43#define USBTV_MAGIC_OK(chunk) ((be32_to_cpu(chunk[0]) & 0xff000000) \ 48#define USBTV_MAGIC_OK(chunk) ((be32_to_cpu(chunk[0]) & 0xff000000) \
44 == 0x88000000) 49 == 0x88000000)
@@ -91,9 +96,23 @@ struct usbtv {
91 int iso_size; 96 int iso_size;
92 unsigned int sequence; 97 unsigned int sequence;
93 struct urb *isoc_urbs[USBTV_ISOC_TRANSFERS]; 98 struct urb *isoc_urbs[USBTV_ISOC_TRANSFERS];
99
100 /* audio */
101 struct snd_card *snd;
102 struct snd_pcm_substream *snd_substream;
103 atomic_t snd_stream;
104 struct work_struct snd_trigger;
105 struct urb *snd_bulk_urb;
106 size_t snd_buffer_pos;
107 size_t snd_period_pos;
94}; 108};
95 109
96int usbtv_set_regs(struct usbtv *usbtv, const u16 regs[][2], int size); 110int usbtv_set_regs(struct usbtv *usbtv, const u16 regs[][2], int size);
97 111
98int usbtv_video_init(struct usbtv *usbtv); 112int usbtv_video_init(struct usbtv *usbtv);
99void usbtv_video_free(struct usbtv *usbtv); 113void usbtv_video_free(struct usbtv *usbtv);
114
115int usbtv_audio_init(struct usbtv *usbtv);
116void usbtv_audio_free(struct usbtv *usbtv);
117void usbtv_audio_suspend(struct usbtv *usbtv);
118void usbtv_audio_resume(struct usbtv *usbtv);