diff options
Diffstat (limited to 'drivers/media/video/em28xx')
-rw-r--r-- | drivers/media/video/em28xx/em28xx-audio.c | 373 |
1 files changed, 197 insertions, 176 deletions
diff --git a/drivers/media/video/em28xx/em28xx-audio.c b/drivers/media/video/em28xx/em28xx-audio.c index e1e1eda517a7..c631cac4c5d2 100644 --- a/drivers/media/video/em28xx/em28xx-audio.c +++ b/drivers/media/video/em28xx/em28xx-audio.c | |||
@@ -44,37 +44,39 @@ | |||
44 | #include "em28xx.h" | 44 | #include "em28xx.h" |
45 | 45 | ||
46 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; | 46 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; |
47 | static int em28xx_cmd(struct em28xx *dev, int cmd,int arg); | 47 | static int em28xx_cmd(struct em28xx *dev, int cmd, int arg); |
48 | 48 | ||
49 | 49 | static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, | |
50 | static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, size_t size) | 50 | size_t size) |
51 | { | 51 | { |
52 | struct snd_pcm_runtime *runtime = subs->runtime; | 52 | struct snd_pcm_runtime *runtime = subs->runtime; |
53 | if(runtime->dma_area){ | 53 | if (runtime->dma_area) { |
54 | if(runtime->dma_bytes > size) | 54 | if (runtime->dma_bytes > size) |
55 | return 0; | 55 | return 0; |
56 | vfree(runtime->dma_area); | 56 | vfree(runtime->dma_area); |
57 | } | 57 | } |
58 | runtime->dma_area = vmalloc(size); | 58 | runtime->dma_area = vmalloc(size); |
59 | if(!runtime ->dma_area) | 59 | if (!runtime->dma_area) |
60 | return -ENOMEM; | 60 | return -ENOMEM; |
61 | runtime->dma_bytes = size; | 61 | runtime->dma_bytes = size; |
62 | return 0; | 62 | return 0; |
63 | } | 63 | } |
64 | 64 | ||
65 | static struct snd_pcm_hardware snd_em28xx_hw_capture = { | 65 | static struct snd_pcm_hardware snd_em28xx_hw_capture = { |
66 | .info = SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID, | 66 | .info = |
67 | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP | | ||
68 | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID, | ||
67 | .formats = SNDRV_PCM_FMTBIT_S16_LE, | 69 | .formats = SNDRV_PCM_FMTBIT_S16_LE, |
68 | .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_KNOT, | 70 | .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_KNOT, |
69 | .rate_min = 48000, | 71 | .rate_min = 48000, |
70 | .rate_max = 48000, | 72 | .rate_max = 48000, |
71 | .channels_min = 2, | 73 | .channels_min = 2, |
72 | .channels_max = 2, | 74 | .channels_max = 2, |
73 | .buffer_bytes_max = 62720*8, /* just about the value in usbaudio.c */ | 75 | .buffer_bytes_max = 62720 * 8, /* just about the value in usbaudio.c */ |
74 | .period_bytes_min = 64, //12544/2, | 76 | .period_bytes_min = 64, //12544/2, |
75 | .period_bytes_max = 12544, | 77 | .period_bytes_max = 12544, |
76 | .periods_min = 2, | 78 | .periods_min = 2, |
77 | .periods_max = 98, //12544, | 79 | .periods_max = 98, //12544, |
78 | }; | 80 | }; |
79 | 81 | ||
80 | static int snd_em28xx_capture_open(struct snd_pcm_substream *substream) | 82 | static int snd_em28xx_capture_open(struct snd_pcm_substream *substream) |
@@ -84,66 +86,68 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream) | |||
84 | struct em28xx *dev = snd_pcm_substream_chip(substream); | 86 | struct em28xx *dev = snd_pcm_substream_chip(substream); |
85 | struct snd_pcm_runtime *runtime = substream->runtime; | 87 | struct snd_pcm_runtime *runtime = substream->runtime; |
86 | printk("opening radio device and trying to acquire exclusive lock\n"); | 88 | printk("opening radio device and trying to acquire exclusive lock\n"); |
87 | switch(dev->mode){ | 89 | switch (dev->mode) { |
88 | case TUNER_STUB_DVBC_TV: | 90 | case TUNER_STUB_DVBC_TV: |
89 | case TUNER_STUB_DVBT_TV: | 91 | case TUNER_STUB_DVBT_TV: |
90 | case TUNER_STUB_ATSC_TV: | 92 | case TUNER_STUB_ATSC_TV: |
91 | /* digital has no support for analog audio */ | 93 | /* digital has no support for analog audio */ |
92 | if (ret != 0 ) { | 94 | if (ret != 0) { |
93 | printk("device is already in use by DVB-T\n"); | 95 | printk("device is already in use by DVB-T\n"); |
94 | return -EINVAL; | 96 | return -EINVAL; |
95 | } else { | 97 | } else { |
96 | struct v4l2_tuner tuner; | 98 | struct v4l2_tuner tuner; |
97 | printk("switching device to FM mode\n"); | 99 | printk("switching device to FM mode\n"); |
98 | 100 | ||
99 | mode = TUNER_STUB_RADIO; | 101 | mode = TUNER_STUB_RADIO; |
100 | memset(&tuner, 0x0, sizeof(struct v4l2_tuner)); | 102 | memset(&tuner, 0x0, sizeof(struct v4l2_tuner)); |
101 | tuner.type = V4L2_TUNER_RADIO; | 103 | tuner.type = V4L2_TUNER_RADIO; |
102 | 104 | ||
103 | /* enable GPIO for analog TV */ | 105 | /* enable GPIO for analog TV */ |
104 | dev->em28xx_gpio_control(dev, EM28XX_MODE, (void*)mode); | 106 | dev->em28xx_gpio_control(dev, EM28XX_MODE, |
105 | dev->mode = mode; | 107 | (void *)mode); |
106 | /* upload firmware */ | 108 | dev->mode = mode; |
107 | tuner_run_cmd(dev->tobj, TUNER_CMD_INIT, (void*)mode); | 109 | /* upload firmware */ |
108 | 110 | tuner_run_cmd(dev->tobj, TUNER_CMD_INIT, (void *)mode); | |
109 | /* required for devices which have kerneldriver dependencies */ | 111 | |
110 | // em28xx_config(dev); | 112 | /* required for devices which have kerneldriver dependencies */ |
111 | // em28xx_config_i2c(dev); | 113 | // em28xx_config(dev); |
112 | 114 | // em28xx_config_i2c(dev); | |
113 | /* this is moreover to switch the decoder to FM */ | 115 | |
114 | em28xx_i2c_call_clients(dev, VIDIOC_S_TUNER, &tuner); | 116 | /* this is moreover to switch the decoder to FM */ |
115 | 117 | em28xx_i2c_call_clients(dev, VIDIOC_S_TUNER, &tuner); | |
116 | dev->em28xx_write_regs(dev, 0x0f, "\x87", 1); | 118 | |
117 | ret = dev->em28xx_acquire(dev, EM28XX_RADIO, 1); | 119 | dev->em28xx_write_regs(dev, 0x0f, "\x87", 1); |
118 | em28xx_i2c_call_clients(dev, VIDIOC_INT_RESET, 0); | 120 | ret = dev->em28xx_acquire(dev, EM28XX_RADIO, 1); |
119 | /* TODO switch to FM mode */ | 121 | em28xx_i2c_call_clients(dev, VIDIOC_INT_RESET, 0); |
120 | 122 | /* TODO switch to FM mode */ | |
121 | printk("em28xx-audio: %d mode\n", mode); | 123 | |
122 | tuner_run_cmd(dev->tobj, TUNER_CMD_G_MODE, &mode); | 124 | printk("em28xx-audio: %d mode\n", mode); |
123 | printk("retrieved mode from tuner: %d\n",mode); | 125 | tuner_run_cmd(dev->tobj, TUNER_CMD_G_MODE, &mode); |
124 | } | 126 | printk("retrieved mode from tuner: %d\n", mode); |
125 | break; | 127 | } |
126 | 128 | break; | |
127 | case TUNER_STUB_ANALOG_TV: | 129 | |
128 | printk("em28xx-audio: device is currently in analog TV mode\n"); | 130 | case TUNER_STUB_ANALOG_TV: |
129 | /* unmute by default */ | 131 | printk("em28xx-audio: device is currently in analog TV mode\n"); |
130 | dev->em28xx_write_regs(dev, 0x0f, "\x87", 1); | 132 | /* unmute by default */ |
131 | break; | 133 | dev->em28xx_write_regs(dev, 0x0f, "\x87", 1); |
132 | case TUNER_STUB_RADIO: | 134 | break; |
133 | /* check current mode and put a hard lock onto it */ | 135 | case TUNER_STUB_RADIO: |
134 | printk("em28xx-audio: device is currently in analogue FM mode\n"); | 136 | /* check current mode and put a hard lock onto it */ |
135 | /* unmute by default here */ | 137 | printk |
136 | dev->em28xx_write_regs(dev, 0x0f, "\x87", 1); | 138 | ("em28xx-audio: device is currently in analogue FM mode\n"); |
137 | ret = dev->em28xx_acquire(dev, EM28XX_RADIO, 1); | 139 | /* unmute by default here */ |
138 | if ( ret == 0 ) | 140 | dev->em28xx_write_regs(dev, 0x0f, "\x87", 1); |
139 | printk("device is locked in fmradio mode now\n"); | 141 | ret = dev->em28xx_acquire(dev, EM28XX_RADIO, 1); |
140 | break; | 142 | if (ret == 0) |
141 | default: | 143 | printk("device is locked in fmradio mode now\n"); |
142 | printk("em28xx-audio: unhandled mode %d\n", dev->mode); | 144 | break; |
145 | default: | ||
146 | printk("em28xx-audio: unhandled mode %d\n", dev->mode); | ||
143 | } | 147 | } |
144 | 148 | ||
145 | runtime->hw = snd_em28xx_hw_capture; | 149 | runtime->hw = snd_em28xx_hw_capture; |
146 | if(dev->alt == 0 && dev->adev->users == 0 ) { | 150 | if (dev->alt == 0 && dev->adev->users == 0) { |
147 | int errCode; | 151 | int errCode; |
148 | dev->alt = 7; | 152 | dev->alt = 7; |
149 | errCode = usb_set_interface(dev->udev, 0, 7); | 153 | errCode = usb_set_interface(dev->udev, 0, 7); |
@@ -163,48 +167,51 @@ static int snd_em28xx_pcm_close(struct snd_pcm_substream *substream) | |||
163 | dev->adev->users--; | 167 | dev->adev->users--; |
164 | 168 | ||
165 | /* decrease audio reference */ | 169 | /* decrease audio reference */ |
166 | switch(dev->mode) { | 170 | switch (dev->mode) { |
167 | case TUNER_STUB_ANALOG_TV: | 171 | case TUNER_STUB_ANALOG_TV: |
168 | amode = EM28XX_VIDEO; | 172 | amode = EM28XX_VIDEO; |
169 | break; | 173 | break; |
170 | case TUNER_STUB_RADIO: | 174 | case TUNER_STUB_RADIO: |
171 | amode = EM28XX_RADIO; | 175 | amode = EM28XX_RADIO; |
172 | break; | 176 | break; |
173 | default: | 177 | default: |
174 | printk("invalid mode: %d\n",dev->mode); | 178 | printk("invalid mode: %d\n", dev->mode); |
175 | break; | 179 | break; |
176 | } | 180 | } |
177 | 181 | ||
178 | dev->em28xx_acquire(dev, amode, 0); | 182 | dev->em28xx_acquire(dev, amode, 0); |
179 | 183 | ||
180 | if(dev->adev->users == 0 && dev->adev->shutdown == 1) { | 184 | if (dev->adev->users == 0 && dev->adev->shutdown == 1) { |
181 | printk("audio users: %d\n",dev->adev->users); | 185 | printk("audio users: %d\n", dev->adev->users); |
182 | printk("disabling audio stream!\n"); | 186 | printk("disabling audio stream!\n"); |
183 | dev->adev->shutdown = 0; | 187 | dev->adev->shutdown = 0; |
184 | printk("released lock\n"); | 188 | printk("released lock\n"); |
185 | em28xx_cmd(dev,EM28XX_CAPTURE_STREAM_EN,0); | 189 | em28xx_cmd(dev, EM28XX_CAPTURE_STREAM_EN, 0); |
186 | } | 190 | } |
187 | return 0; | 191 | return 0; |
188 | } | 192 | } |
189 | 193 | ||
190 | static int snd_em28xx_hw_capture_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) | 194 | static int snd_em28xx_hw_capture_params(struct snd_pcm_substream *substream, |
195 | struct snd_pcm_hw_params *hw_params) | ||
191 | { | 196 | { |
192 | unsigned int channels, rate, format; | 197 | unsigned int channels, rate, format; |
193 | int ret; | 198 | int ret; |
194 | ret = snd_pcm_alloc_vmalloc_buffer(substream, params_buffer_bytes(hw_params)); | 199 | ret = |
200 | snd_pcm_alloc_vmalloc_buffer(substream, | ||
201 | params_buffer_bytes(hw_params)); | ||
195 | format = params_format(hw_params); | 202 | format = params_format(hw_params); |
196 | rate = params_rate(hw_params); | 203 | rate = params_rate(hw_params); |
197 | channels = params_channels(hw_params); | 204 | channels = params_channels(hw_params); |
198 | /* TODO: set up em28xx audio chip to deliver the correct audio format, current default is 48000hz multiplexed => 96000hz mono | 205 | /* TODO: set up em28xx audio chip to deliver the correct audio format, current default is 48000hz multiplexed => 96000hz mono |
199 | which shouldn't matter since analogue TV only supports mono*/ | 206 | which shouldn't matter since analogue TV only supports mono */ |
200 | return 0; | 207 | return 0; |
201 | } | 208 | } |
202 | 209 | ||
203 | static int snd_em28xx_hw_capture_free(struct snd_pcm_substream *substream) | 210 | static int snd_em28xx_hw_capture_free(struct snd_pcm_substream *substream) |
204 | { | 211 | { |
205 | struct em28xx *dev = snd_pcm_substream_chip(substream); | 212 | struct em28xx *dev = snd_pcm_substream_chip(substream); |
206 | if(dev->adev->capture_stream==STREAM_ON){ | 213 | if (dev->adev->capture_stream == STREAM_ON) { |
207 | em28xx_cmd(dev,EM28XX_CAPTURE_STREAM_EN,0); | 214 | em28xx_cmd(dev, EM28XX_CAPTURE_STREAM_EN, 0); |
208 | } | 215 | } |
209 | return 0; | 216 | return 0; |
210 | } | 217 | } |
@@ -214,24 +221,25 @@ static int snd_em28xx_prepare(struct snd_pcm_substream *substream) | |||
214 | return 0; | 221 | return 0; |
215 | } | 222 | } |
216 | 223 | ||
217 | static int snd_em28xx_capture_trigger(struct snd_pcm_substream *substream, int cmd) | 224 | static int snd_em28xx_capture_trigger(struct snd_pcm_substream *substream, |
225 | int cmd) | ||
218 | { | 226 | { |
219 | struct em28xx *dev = snd_pcm_substream_chip(substream); | 227 | struct em28xx *dev = snd_pcm_substream_chip(substream); |
220 | switch(cmd){ | 228 | switch (cmd) { |
221 | case SNDRV_PCM_TRIGGER_START: | 229 | case SNDRV_PCM_TRIGGER_START: |
222 | em28xx_cmd(dev,EM28XX_CAPTURE_STREAM_EN,1); | 230 | em28xx_cmd(dev, EM28XX_CAPTURE_STREAM_EN, 1); |
223 | return 0; | 231 | return 0; |
224 | case SNDRV_PCM_TRIGGER_STOP: | 232 | case SNDRV_PCM_TRIGGER_STOP: |
225 | dev->adev->shutdown=1; | 233 | dev->adev->shutdown = 1; |
226 | return 0; | 234 | return 0; |
227 | default: | 235 | default: |
228 | return -EINVAL; | 236 | return -EINVAL; |
229 | } | 237 | } |
230 | } | 238 | } |
231 | 239 | ||
232 | static void em28xx_audio_isocirq(struct urb *urb) | 240 | static void em28xx_audio_isocirq(struct urb *urb) |
233 | { | 241 | { |
234 | struct em28xx *dev=urb->context; | 242 | struct em28xx *dev = urb->context; |
235 | int i; | 243 | int i; |
236 | unsigned int oldptr; | 244 | unsigned int oldptr; |
237 | unsigned long flags; | 245 | unsigned long flags; |
@@ -241,50 +249,61 @@ static void em28xx_audio_isocirq(struct urb *urb) | |||
241 | unsigned int stride; | 249 | unsigned int stride; |
242 | struct snd_pcm_substream *substream; | 250 | struct snd_pcm_substream *substream; |
243 | struct snd_pcm_runtime *runtime; | 251 | struct snd_pcm_runtime *runtime; |
244 | if(dev->adev->capture_pcm_substream){ | 252 | if (dev->adev->capture_pcm_substream) { |
245 | substream=dev->adev->capture_pcm_substream; | 253 | substream = dev->adev->capture_pcm_substream; |
246 | runtime=substream->runtime; | 254 | runtime = substream->runtime; |
247 | 255 | ||
248 | stride = runtime->frame_bits >> 3; | 256 | stride = runtime->frame_bits >> 3; |
249 | for(i=0;i<urb->number_of_packets;i++){ | 257 | for (i = 0; i < urb->number_of_packets; i++) { |
250 | int length=urb->iso_frame_desc[i].actual_length/stride; | 258 | int length = |
251 | cp=(unsigned char *) urb->transfer_buffer + urb->iso_frame_desc[i].offset; | 259 | urb->iso_frame_desc[i].actual_length / stride; |
260 | cp = (unsigned char *)urb->transfer_buffer + | ||
261 | urb->iso_frame_desc[i].offset; | ||
252 | 262 | ||
253 | if(!length) | 263 | if (!length) |
254 | continue; | 264 | continue; |
255 | 265 | ||
256 | spin_lock_irqsave(&dev->adev->slock, flags); | 266 | spin_lock_irqsave(&dev->adev->slock, flags); |
257 | oldptr = dev->adev->hwptr_done_capture; | 267 | oldptr = dev->adev->hwptr_done_capture; |
258 | dev->adev->hwptr_done_capture +=length; | 268 | dev->adev->hwptr_done_capture += length; |
259 | if(dev->adev->hwptr_done_capture >= runtime->buffer_size) | 269 | if (dev->adev->hwptr_done_capture >= |
260 | dev->adev->hwptr_done_capture -= runtime->buffer_size; | 270 | runtime->buffer_size) |
271 | dev->adev->hwptr_done_capture -= | ||
272 | runtime->buffer_size; | ||
261 | 273 | ||
262 | dev->adev->capture_transfer_done += length; | 274 | dev->adev->capture_transfer_done += length; |
263 | if(dev->adev->capture_transfer_done >= runtime->period_size){ | 275 | if (dev->adev->capture_transfer_done >= |
264 | dev->adev->capture_transfer_done -= runtime->period_size; | 276 | runtime->period_size) { |
265 | period_elapsed=1; | 277 | dev->adev->capture_transfer_done -= |
278 | runtime->period_size; | ||
279 | period_elapsed = 1; | ||
266 | } | 280 | } |
267 | spin_unlock_irqrestore(&dev->adev->slock, flags); | 281 | spin_unlock_irqrestore(&dev->adev->slock, flags); |
268 | 282 | ||
269 | if(oldptr + length >= runtime->buffer_size){ | 283 | if (oldptr + length >= runtime->buffer_size) { |
270 | unsigned int cnt = runtime->buffer_size-oldptr-1; | 284 | unsigned int cnt = |
271 | memcpy(runtime->dma_area+oldptr*stride, cp , cnt*stride); | 285 | runtime->buffer_size - oldptr - 1; |
272 | memcpy(runtime->dma_area, cp + cnt, length*stride - cnt*stride); | 286 | memcpy(runtime->dma_area + oldptr * stride, cp, |
287 | cnt * stride); | ||
288 | memcpy(runtime->dma_area, cp + cnt, | ||
289 | length * stride - cnt * stride); | ||
273 | } else { | 290 | } else { |
274 | memcpy(runtime->dma_area+oldptr*stride, cp, length*stride); | 291 | memcpy(runtime->dma_area + oldptr * stride, cp, |
292 | length * stride); | ||
275 | } | 293 | } |
276 | } | 294 | } |
277 | if(period_elapsed){ | 295 | if (period_elapsed) { |
278 | snd_pcm_period_elapsed(substream); | 296 | snd_pcm_period_elapsed(substream); |
279 | } | 297 | } |
280 | } | 298 | } |
281 | urb->status = 0; | 299 | urb->status = 0; |
282 | 300 | ||
283 | if(dev->adev->shutdown) | 301 | if (dev->adev->shutdown) |
284 | return; | 302 | return; |
285 | 303 | ||
286 | if((status = usb_submit_urb(urb, GFP_ATOMIC))){ | 304 | if ((status = usb_submit_urb(urb, GFP_ATOMIC))) { |
287 | em28xx_errdev("resubmit of audio urb failed (error=%i)\n", status); | 305 | em28xx_errdev("resubmit of audio urb failed (error=%i)\n", |
306 | status); | ||
288 | } | 307 | } |
289 | return; | 308 | return; |
290 | } | 309 | } |
@@ -292,10 +311,10 @@ static void em28xx_audio_isocirq(struct urb *urb) | |||
292 | static int em28xx_isoc_audio_deinit(struct em28xx *dev) | 311 | static int em28xx_isoc_audio_deinit(struct em28xx *dev) |
293 | { | 312 | { |
294 | int i; | 313 | int i; |
295 | for(i=0;i<EM28XX_AUDIO_BUFS;i++){ | 314 | for (i = 0; i < EM28XX_AUDIO_BUFS; i++) { |
296 | usb_kill_urb(dev->adev->urb[i]); | 315 | usb_kill_urb(dev->adev->urb[i]); |
297 | usb_free_urb(dev->adev->urb[i]); | 316 | usb_free_urb(dev->adev->urb[i]); |
298 | dev->adev->urb[i]=NULL; | 317 | dev->adev->urb[i] = NULL; |
299 | } | 318 | } |
300 | return 0; | 319 | return 0; |
301 | } | 320 | } |
@@ -304,40 +323,42 @@ static int em28xx_init_audio_isoc(struct em28xx *dev) | |||
304 | { | 323 | { |
305 | int i; | 324 | int i; |
306 | int errCode; | 325 | int errCode; |
307 | const int sb_size=EM28XX_NUM_AUDIO_PACKETS * EM28XX_AUDIO_MAX_PACKET_SIZE; | 326 | const int sb_size = |
327 | EM28XX_NUM_AUDIO_PACKETS * EM28XX_AUDIO_MAX_PACKET_SIZE; | ||
308 | 328 | ||
309 | 329 | for (i = 0; i < EM28XX_AUDIO_BUFS; i++) { | |
310 | for(i=0;i<EM28XX_AUDIO_BUFS;i++){ | ||
311 | struct urb *urb; | 330 | struct urb *urb; |
312 | int j,k; | 331 | int j, k; |
313 | dev->adev->transfer_buffer[i]=kmalloc(sb_size,GFP_ATOMIC); | 332 | dev->adev->transfer_buffer[i] = kmalloc(sb_size, GFP_ATOMIC); |
314 | if(!dev->adev->transfer_buffer[i]){ | 333 | if (!dev->adev->transfer_buffer[i]) { |
315 | return -ENOMEM; | 334 | return -ENOMEM; |
316 | } | 335 | } |
317 | memset(dev->adev->transfer_buffer[i],0x80,sb_size); | 336 | memset(dev->adev->transfer_buffer[i], 0x80, sb_size); |
318 | urb = usb_alloc_urb(EM28XX_NUM_AUDIO_PACKETS,GFP_ATOMIC); | 337 | urb = usb_alloc_urb(EM28XX_NUM_AUDIO_PACKETS, GFP_ATOMIC); |
319 | if(urb){ | 338 | if (urb) { |
320 | urb->dev=dev->udev; | 339 | urb->dev = dev->udev; |
321 | urb->context=dev; | 340 | urb->context = dev; |
322 | urb->pipe=usb_rcvisocpipe(dev->udev,0x83); | 341 | urb->pipe = usb_rcvisocpipe(dev->udev, 0x83); |
323 | urb->transfer_flags = URB_ISO_ASAP; | 342 | urb->transfer_flags = URB_ISO_ASAP; |
324 | urb->transfer_buffer = dev->adev->transfer_buffer[i]; | 343 | urb->transfer_buffer = dev->adev->transfer_buffer[i]; |
325 | urb->interval=1; | 344 | urb->interval = 1; |
326 | urb->complete = em28xx_audio_isocirq; | 345 | urb->complete = em28xx_audio_isocirq; |
327 | urb->number_of_packets = EM28XX_NUM_AUDIO_PACKETS; | 346 | urb->number_of_packets = EM28XX_NUM_AUDIO_PACKETS; |
328 | urb->transfer_buffer_length = sb_size; | 347 | urb->transfer_buffer_length = sb_size; |
329 | for(j=k=0; j<EM28XX_NUM_AUDIO_PACKETS;j++,k+=EM28XX_AUDIO_MAX_PACKET_SIZE){ | 348 | for (j = k = 0; j < EM28XX_NUM_AUDIO_PACKETS; |
349 | j++, k += EM28XX_AUDIO_MAX_PACKET_SIZE) { | ||
330 | urb->iso_frame_desc[j].offset = k; | 350 | urb->iso_frame_desc[j].offset = k; |
331 | urb->iso_frame_desc[j].length=EM28XX_AUDIO_MAX_PACKET_SIZE; | 351 | urb->iso_frame_desc[j].length = |
352 | EM28XX_AUDIO_MAX_PACKET_SIZE; | ||
332 | } | 353 | } |
333 | dev->adev->urb[i]=urb; | 354 | dev->adev->urb[i] = urb; |
334 | } else { | 355 | } else { |
335 | return -ENOMEM; | 356 | return -ENOMEM; |
336 | } | 357 | } |
337 | } | 358 | } |
338 | for(i=0;i<EM28XX_AUDIO_BUFS;i++){ | 359 | for (i = 0; i < EM28XX_AUDIO_BUFS; i++) { |
339 | errCode = usb_submit_urb(dev->adev->urb[i], GFP_ATOMIC); | 360 | errCode = usb_submit_urb(dev->adev->urb[i], GFP_ATOMIC); |
340 | if (errCode){ | 361 | if (errCode) { |
341 | em28xx_isoc_audio_deinit(dev); | 362 | em28xx_isoc_audio_deinit(dev); |
342 | return errCode; | 363 | return errCode; |
343 | } | 364 | } |
@@ -345,27 +366,28 @@ static int em28xx_init_audio_isoc(struct em28xx *dev) | |||
345 | return 0; | 366 | return 0; |
346 | } | 367 | } |
347 | 368 | ||
348 | 369 | static int em28xx_cmd(struct em28xx *dev, int cmd, int arg) | |
349 | static int em28xx_cmd(struct em28xx *dev, int cmd,int arg) | ||
350 | { | 370 | { |
351 | switch(cmd){ | 371 | switch (cmd) { |
352 | case EM28XX_CAPTURE_STREAM_EN: | 372 | case EM28XX_CAPTURE_STREAM_EN: |
353 | if(dev->adev->capture_stream == STREAM_OFF && arg==1){ | 373 | if (dev->adev->capture_stream == STREAM_OFF && arg == 1) { |
354 | dev->adev->capture_stream=STREAM_ON; | 374 | dev->adev->capture_stream = STREAM_ON; |
355 | em28xx_init_audio_isoc(dev); | 375 | em28xx_init_audio_isoc(dev); |
356 | } else if (dev->adev->capture_stream==STREAM_ON && arg==0){ | 376 | } else if (dev->adev->capture_stream == STREAM_ON && arg == 0) { |
357 | dev->adev->capture_stream=STREAM_OFF; | 377 | dev->adev->capture_stream = STREAM_OFF; |
358 | em28xx_isoc_audio_deinit(dev); | 378 | em28xx_isoc_audio_deinit(dev); |
359 | } else { | 379 | } else { |
360 | printk("An underrun occured very likely... ignoring it\n"); | 380 | printk |
361 | } | 381 | ("An underrun occured very likely... ignoring it\n"); |
362 | return 0; | 382 | } |
363 | default: | 383 | return 0; |
364 | return -EINVAL; | 384 | default: |
385 | return -EINVAL; | ||
365 | } | 386 | } |
366 | } | 387 | } |
367 | 388 | ||
368 | static snd_pcm_uframes_t snd_em28xx_capture_pointer(struct snd_pcm_substream *substream) | 389 | static snd_pcm_uframes_t snd_em28xx_capture_pointer(struct snd_pcm_substream |
390 | *substream) | ||
369 | { | 391 | { |
370 | struct em28xx *dev; | 392 | struct em28xx *dev; |
371 | snd_pcm_uframes_t hwptr_done; | 393 | snd_pcm_uframes_t hwptr_done; |
@@ -393,7 +415,6 @@ static struct snd_pcm_ops snd_em28xx_pcm_capture = { | |||
393 | .page = snd_pcm_get_vmalloc_page, | 415 | .page = snd_pcm_get_vmalloc_page, |
394 | }; | 416 | }; |
395 | 417 | ||
396 | |||
397 | static int em28xx_audio_init(struct em28xx *dev) | 418 | static int em28xx_audio_init(struct em28xx *dev) |
398 | { | 419 | { |
399 | struct em28xx_audio *adev; | 420 | struct em28xx_audio *adev; |
@@ -404,54 +425,54 @@ static int em28xx_audio_init(struct em28xx *dev) | |||
404 | int err; | 425 | int err; |
405 | printk("em28xx-audio.c: probing for em28x1 non standard usbaudio\n"); | 426 | printk("em28xx-audio.c: probing for em28x1 non standard usbaudio\n"); |
406 | printk("em28xx-audio.c: Copyright (C) 2006 Markus Rechberger\n"); | 427 | printk("em28xx-audio.c: Copyright (C) 2006 Markus Rechberger\n"); |
407 | adev=kzalloc(sizeof(*adev),GFP_KERNEL); | 428 | adev = kzalloc(sizeof(*adev), GFP_KERNEL); |
408 | if(!adev){ | 429 | if (!adev) { |
409 | printk("em28xx-audio.c: out of memory\n"); | 430 | printk("em28xx-audio.c: out of memory\n"); |
410 | return -1; | 431 | return -1; |
411 | } | 432 | } |
412 | card = snd_card_new(index[devnr], "Em28xx Audio", THIS_MODULE,0); | 433 | card = snd_card_new(index[devnr], "Em28xx Audio", THIS_MODULE, 0); |
413 | if(card==NULL){ | 434 | if (card == NULL) { |
414 | kfree(adev); | 435 | kfree(adev); |
415 | return -ENOMEM; | 436 | return -ENOMEM; |
416 | } | 437 | } |
417 | 438 | ||
418 | spin_lock_init(&adev->slock); | 439 | spin_lock_init(&adev->slock); |
419 | ret=snd_pcm_new(card, "Em28xx Audio", 0, 0, 1, &pcm); | 440 | ret = snd_pcm_new(card, "Em28xx Audio", 0, 0, 1, &pcm); |
420 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_em28xx_pcm_capture); | 441 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_em28xx_pcm_capture); |
421 | pcm->info_flags = 0; | 442 | pcm->info_flags = 0; |
422 | pcm->private_data = dev; | 443 | pcm->private_data = dev; |
423 | strcpy(pcm->name,"Empia 28xx Capture"); | 444 | strcpy(pcm->name, "Empia 28xx Capture"); |
424 | strcpy(card->driver, "Empia Em28xx Audio"); | 445 | strcpy(card->driver, "Empia Em28xx Audio"); |
425 | strcpy(card->shortname, "Em28xx Audio"); | 446 | strcpy(card->shortname, "Em28xx Audio"); |
426 | strcpy(card->longname,"Empia Em28xx Audio"); | 447 | strcpy(card->longname, "Empia Em28xx Audio"); |
427 | 448 | ||
428 | if((err = snd_card_register(card))<0){ | 449 | if ((err = snd_card_register(card)) < 0) { |
429 | snd_card_free(card); | 450 | snd_card_free(card); |
430 | return -ENOMEM; | 451 | return -ENOMEM; |
431 | } | 452 | } |
432 | adev->sndcard=card; | 453 | adev->sndcard = card; |
433 | adev->udev=dev->udev; | 454 | adev->udev = dev->udev; |
434 | dev->adev=adev; | 455 | dev->adev = adev; |
435 | return 0; | 456 | return 0; |
436 | } | 457 | } |
437 | 458 | ||
438 | static int em28xx_audio_fini(struct em28xx *dev) | 459 | static int em28xx_audio_fini(struct em28xx *dev) |
439 | { | 460 | { |
440 | if(dev==NULL) | 461 | if (dev == NULL) |
441 | return 0; | 462 | return 0; |
442 | if(dev->adev){ | 463 | if (dev->adev) { |
443 | snd_card_free(dev->adev->sndcard); | 464 | snd_card_free(dev->adev->sndcard); |
444 | kfree(dev->adev); | 465 | kfree(dev->adev); |
445 | dev->adev=NULL; | 466 | dev->adev = NULL; |
446 | } | 467 | } |
447 | return 0; | 468 | return 0; |
448 | } | 469 | } |
449 | 470 | ||
450 | static struct em28xx_ops audio_ops = { | 471 | static struct em28xx_ops audio_ops = { |
451 | .id = EM28XX_AUDIO, | 472 | .id = EM28XX_AUDIO, |
452 | .name = "Em28xx Audio Extension", | 473 | .name = "Em28xx Audio Extension", |
453 | .init = em28xx_audio_init, | 474 | .init = em28xx_audio_init, |
454 | .fini = em28xx_audio_fini, | 475 | .fini = em28xx_audio_fini, |
455 | }; | 476 | }; |
456 | 477 | ||
457 | static int __init em28xx_alsa_register(void) | 478 | static int __init em28xx_alsa_register(void) |