diff options
author | Devin Heitmueller <dheitmueller@kernellabs.com> | 2009-12-20 21:53:46 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-02-26 13:10:44 -0500 |
commit | 60433e2ab8391d1884ddef2269bd19ecdaaa2d72 (patch) | |
tree | 7ad27b824182dced10d64f8ffa6b4aa05f5eaabf /drivers/media/video/cx18 | |
parent | 71036ef26b0026742c8ab79a54937aac1439350d (diff) |
V4L/DVB: cx18-alsa: codingstyle cleanup
Move the cx18_alsa_announce_pcm_data() function further up in the file, since
apparently "make checkpatch" has never heard of a forward declaration. Note
that despite the hg diff showing everything else as having been deleted/added,
in reality it was only that one function that got moved (and the forward
declaration was removed from the top of the file).
This work was sponsored by ONELAN Limited.
Signed-off-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/cx18')
-rw-r--r-- | drivers/media/video/cx18/cx18-alsa-pcm.c | 156 |
1 files changed, 76 insertions, 80 deletions
diff --git a/drivers/media/video/cx18/cx18-alsa-pcm.c b/drivers/media/video/cx18/cx18-alsa-pcm.c index 2d25c6f92d5d..e613826d5a47 100644 --- a/drivers/media/video/cx18/cx18-alsa-pcm.c +++ b/drivers/media/video/cx18/cx18-alsa-pcm.c | |||
@@ -47,10 +47,6 @@ MODULE_PARM_DESC(pcm_debug, "enable debug messages for pcm"); | |||
47 | __func__, ##arg); \ | 47 | __func__, ##arg); \ |
48 | } while (0) | 48 | } while (0) |
49 | 49 | ||
50 | /* Forward Declaration */ | ||
51 | void cx18_alsa_announce_pcm_data(struct snd_cx18_card *cxsc, u8 *pcm_data, | ||
52 | size_t num_bytes); | ||
53 | |||
54 | static struct snd_pcm_hardware snd_cx18_hw_capture = { | 50 | static struct snd_pcm_hardware snd_cx18_hw_capture = { |
55 | .info = SNDRV_PCM_INFO_BLOCK_TRANSFER | | 51 | .info = SNDRV_PCM_INFO_BLOCK_TRANSFER | |
56 | SNDRV_PCM_INFO_MMAP | | 52 | SNDRV_PCM_INFO_MMAP | |
@@ -72,6 +68,82 @@ static struct snd_pcm_hardware snd_cx18_hw_capture = { | |||
72 | .periods_max = 98, /* 12544, */ | 68 | .periods_max = 98, /* 12544, */ |
73 | }; | 69 | }; |
74 | 70 | ||
71 | void cx18_alsa_announce_pcm_data(struct snd_cx18_card *cxsc, u8 *pcm_data, | ||
72 | size_t num_bytes) | ||
73 | { | ||
74 | struct snd_pcm_substream *substream; | ||
75 | struct snd_pcm_runtime *runtime; | ||
76 | unsigned int oldptr; | ||
77 | unsigned int stride; | ||
78 | int period_elapsed = 0; | ||
79 | int length; | ||
80 | |||
81 | dprintk("cx18 alsa announce ptr=%p data=%p num_bytes=%d\n", cxsc, | ||
82 | pcm_data, num_bytes); | ||
83 | |||
84 | substream = cxsc->capture_pcm_substream; | ||
85 | if (substream == NULL) { | ||
86 | dprintk("substream was NULL\n"); | ||
87 | return; | ||
88 | } | ||
89 | |||
90 | runtime = substream->runtime; | ||
91 | if (runtime == NULL) { | ||
92 | dprintk("runtime was NULL\n"); | ||
93 | return; | ||
94 | } | ||
95 | |||
96 | stride = runtime->frame_bits >> 3; | ||
97 | if (stride == 0) { | ||
98 | dprintk("stride is zero\n"); | ||
99 | return; | ||
100 | } | ||
101 | |||
102 | length = num_bytes / stride; | ||
103 | if (length == 0) { | ||
104 | dprintk("%s: length was zero\n", __func__); | ||
105 | return; | ||
106 | } | ||
107 | |||
108 | if (runtime->dma_area == NULL) { | ||
109 | dprintk("dma area was NULL - ignoring\n"); | ||
110 | return; | ||
111 | } | ||
112 | |||
113 | oldptr = cxsc->hwptr_done_capture; | ||
114 | if (oldptr + length >= runtime->buffer_size) { | ||
115 | unsigned int cnt = | ||
116 | runtime->buffer_size - oldptr; | ||
117 | memcpy(runtime->dma_area + oldptr * stride, pcm_data, | ||
118 | cnt * stride); | ||
119 | memcpy(runtime->dma_area, pcm_data + cnt * stride, | ||
120 | length * stride - cnt * stride); | ||
121 | } else { | ||
122 | memcpy(runtime->dma_area + oldptr * stride, pcm_data, | ||
123 | length * stride); | ||
124 | } | ||
125 | snd_pcm_stream_lock(substream); | ||
126 | |||
127 | cxsc->hwptr_done_capture += length; | ||
128 | if (cxsc->hwptr_done_capture >= | ||
129 | runtime->buffer_size) | ||
130 | cxsc->hwptr_done_capture -= | ||
131 | runtime->buffer_size; | ||
132 | |||
133 | cxsc->capture_transfer_done += length; | ||
134 | if (cxsc->capture_transfer_done >= | ||
135 | runtime->period_size) { | ||
136 | cxsc->capture_transfer_done -= | ||
137 | runtime->period_size; | ||
138 | period_elapsed = 1; | ||
139 | } | ||
140 | |||
141 | snd_pcm_stream_unlock(substream); | ||
142 | |||
143 | if (period_elapsed) | ||
144 | snd_pcm_period_elapsed(substream); | ||
145 | } | ||
146 | |||
75 | static int snd_cx18_pcm_capture_open(struct snd_pcm_substream *substream) | 147 | static int snd_cx18_pcm_capture_open(struct snd_pcm_substream *substream) |
76 | { | 148 | { |
77 | struct snd_cx18_card *cxsc = snd_pcm_substream_chip(substream); | 149 | struct snd_cx18_card *cxsc = snd_pcm_substream_chip(substream); |
@@ -245,82 +317,6 @@ static struct snd_pcm_ops snd_cx18_pcm_capture_ops = { | |||
245 | .page = snd_pcm_get_vmalloc_page, | 317 | .page = snd_pcm_get_vmalloc_page, |
246 | }; | 318 | }; |
247 | 319 | ||
248 | void cx18_alsa_announce_pcm_data(struct snd_cx18_card *cxsc, u8 *pcm_data, | ||
249 | size_t num_bytes) | ||
250 | { | ||
251 | struct snd_pcm_substream *substream; | ||
252 | struct snd_pcm_runtime *runtime; | ||
253 | unsigned int oldptr; | ||
254 | unsigned int stride; | ||
255 | int period_elapsed = 0; | ||
256 | int length; | ||
257 | |||
258 | dprintk("cx18 alsa announce ptr=%p data=%p num_bytes=%d\n", cxsc, | ||
259 | pcm_data, num_bytes); | ||
260 | |||
261 | substream = cxsc->capture_pcm_substream; | ||
262 | if (substream == NULL) { | ||
263 | dprintk("substream was NULL\n"); | ||
264 | return; | ||
265 | } | ||
266 | |||
267 | runtime = substream->runtime; | ||
268 | if (runtime == NULL) { | ||
269 | dprintk("runtime was NULL\n"); | ||
270 | return; | ||
271 | } | ||
272 | |||
273 | stride = runtime->frame_bits >> 3; | ||
274 | if (stride == 0) { | ||
275 | dprintk("stride is zero\n"); | ||
276 | return; | ||
277 | } | ||
278 | |||
279 | length = num_bytes / stride; | ||
280 | if (length == 0) { | ||
281 | dprintk("%s: length was zero\n", __func__); | ||
282 | return; | ||
283 | } | ||
284 | |||
285 | if (runtime->dma_area == NULL) { | ||
286 | dprintk("dma area was NULL - ignoring\n"); | ||
287 | return; | ||
288 | } | ||
289 | |||
290 | oldptr = cxsc->hwptr_done_capture; | ||
291 | if (oldptr + length >= runtime->buffer_size) { | ||
292 | unsigned int cnt = | ||
293 | runtime->buffer_size - oldptr; | ||
294 | memcpy(runtime->dma_area + oldptr * stride, pcm_data, | ||
295 | cnt * stride); | ||
296 | memcpy(runtime->dma_area, pcm_data + cnt * stride, | ||
297 | length * stride - cnt * stride); | ||
298 | } else { | ||
299 | memcpy(runtime->dma_area + oldptr * stride, pcm_data, | ||
300 | length * stride); | ||
301 | } | ||
302 | snd_pcm_stream_lock(substream); | ||
303 | |||
304 | cxsc->hwptr_done_capture += length; | ||
305 | if (cxsc->hwptr_done_capture >= | ||
306 | runtime->buffer_size) | ||
307 | cxsc->hwptr_done_capture -= | ||
308 | runtime->buffer_size; | ||
309 | |||
310 | cxsc->capture_transfer_done += length; | ||
311 | if (cxsc->capture_transfer_done >= | ||
312 | runtime->period_size) { | ||
313 | cxsc->capture_transfer_done -= | ||
314 | runtime->period_size; | ||
315 | period_elapsed = 1; | ||
316 | } | ||
317 | |||
318 | snd_pcm_stream_unlock(substream); | ||
319 | |||
320 | if (period_elapsed) | ||
321 | snd_pcm_period_elapsed(substream); | ||
322 | } | ||
323 | |||
324 | int snd_cx18_pcm_create(struct snd_cx18_card *cxsc) | 320 | int snd_cx18_pcm_create(struct snd_cx18_card *cxsc) |
325 | { | 321 | { |
326 | struct snd_pcm *sp; | 322 | struct snd_pcm *sp; |