27449d20328af543dd4cce6702c3d655d1da3b57
[firefly-linux-kernel-4.4.55.git] / drivers / staging / most / aim-sound / sound.c
1 /*
2  * sound.c - Audio Application Interface Module for Mostcore
3  *
4  * Copyright (C) 2015 Microchip Technology Germany II GmbH & Co. KG
5  *
6  * This program is distributed in the hope that it will be useful,
7  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9  * GNU General Public License for more details.
10  *
11  * This file is licensed under GPLv2.
12  */
13
14 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
15
16 #include <linux/module.h>
17 #include <linux/printk.h>
18 #include <linux/kernel.h>
19 #include <linux/init.h>
20 #include <sound/core.h>
21 #include <sound/pcm.h>
22 #include <linux/sched.h>
23 #include <linux/kthread.h>
24 #include <mostcore.h>
25
26 #define DRIVER_NAME "sound"
27
28 static struct list_head dev_list;
29
30 /**
31  * struct channel - private structure to keep channel specific data
32  * @substream: stores the substream structure
33  * @iface: interface for which the channel belongs to
34  * @cfg: channel configuration
35  * @card: registered sound card
36  * @list: list for private use
37  * @id: channel index
38  * @period_pos: current period position (ring buffer)
39  * @buffer_pos: current buffer position (ring buffer)
40  * @is_stream_running: identifies whether a stream is running or not
41  * @opened: set when the stream is opened
42  * @playback_task: playback thread
43  * @playback_waitq: waitq used by playback thread
44  */
45 struct channel {
46         struct snd_pcm_substream *substream;
47         struct most_interface *iface;
48         struct most_channel_config *cfg;
49         struct snd_card *card;
50         struct list_head list;
51         int id;
52         unsigned int period_pos;
53         unsigned int buffer_pos;
54         bool is_stream_running;
55
56         struct task_struct *playback_task;
57         wait_queue_head_t playback_waitq;
58
59         void (*copy_fn)(void *alsa, void *most, unsigned int bytes);
60 };
61
62 #define MOST_PCM_INFO (SNDRV_PCM_INFO_MMAP | \
63                        SNDRV_PCM_INFO_MMAP_VALID | \
64                        SNDRV_PCM_INFO_BATCH | \
65                        SNDRV_PCM_INFO_INTERLEAVED | \
66                        SNDRV_PCM_INFO_BLOCK_TRANSFER)
67
68 /**
69  * Initialization of struct snd_pcm_hardware
70  */
71 static struct snd_pcm_hardware pcm_hardware_template = {
72         .info               = MOST_PCM_INFO,
73         .rates              = SNDRV_PCM_RATE_48000,
74         .rate_min           = 48000,
75         .rate_max           = 48000,
76         .channels_min       = 1,
77         .channels_max       = 8,
78 };
79
80 #define swap16(val) ( \
81         (((u16)(val) << 8) & (u16)0xFF00) | \
82         (((u16)(val) >> 8) & (u16)0x00FF))
83
84 #define swap32(val) ( \
85         (((u32)(val) << 24) & (u32)0xFF000000) | \
86         (((u32)(val) <<  8) & (u32)0x00FF0000) | \
87         (((u32)(val) >>  8) & (u32)0x0000FF00) | \
88         (((u32)(val) >> 24) & (u32)0x000000FF))
89
90 static void swap_copy16(u16 *dest, const u16 *source, unsigned int bytes)
91 {
92         unsigned int i = 0;
93
94         while (i < (bytes / 2)) {
95                 dest[i] = swap16(source[i]);
96                 i++;
97         }
98 }
99
100 static void swap_copy24(u8 *dest, const u8 *source, unsigned int bytes)
101 {
102         unsigned int i = 0;
103
104         while (i < bytes - 2) {
105                 dest[i] = source[i + 2];
106                 dest[i + 1] = source[i + 1];
107                 dest[i + 2] = source[i];
108                 i += 3;
109         }
110 }
111
112 static void swap_copy32(u32 *dest, const u32 *source, unsigned int bytes)
113 {
114         unsigned int i = 0;
115
116         while (i < bytes / 4) {
117                 dest[i] = swap32(source[i]);
118                 i++;
119         }
120 }
121
122 static void alsa_to_most_memcpy(void *alsa, void *most, unsigned int bytes)
123 {
124         memcpy(most, alsa, bytes);
125 }
126
127 static void alsa_to_most_copy16(void *alsa, void *most, unsigned int bytes)
128 {
129         swap_copy16(most, alsa, bytes);
130 }
131
132 static void alsa_to_most_copy24(void *alsa, void *most, unsigned int bytes)
133 {
134         swap_copy24(most, alsa, bytes);
135 }
136
137 static void alsa_to_most_copy32(void *alsa, void *most, unsigned int bytes)
138 {
139         swap_copy32(most, alsa, bytes);
140 }
141
142 static void most_to_alsa_memcpy(void *alsa, void *most, unsigned int bytes)
143 {
144         memcpy(alsa, most, bytes);
145 }
146
147 static void most_to_alsa_copy16(void *alsa, void *most, unsigned int bytes)
148 {
149         swap_copy16(alsa, most, bytes);
150 }
151
152 static void most_to_alsa_copy24(void *alsa, void *most, unsigned int bytes)
153 {
154         swap_copy24(alsa, most, bytes);
155 }
156
157 static void most_to_alsa_copy32(void *alsa, void *most, unsigned int bytes)
158 {
159         swap_copy32(alsa, most, bytes);
160 }
161
162 /**
163  * get_channel - get pointer to channel
164  * @iface: interface structure
165  * @channel_id: channel ID
166  *
167  * This traverses the channel list and returns the channel matching the
168  * ID and interface.
169  *
170  * Returns pointer to channel on success or NULL otherwise.
171  */
172 static struct channel *get_channel(struct most_interface *iface,
173                                    int channel_id)
174 {
175         struct channel *channel, *tmp;
176
177         list_for_each_entry_safe(channel, tmp, &dev_list, list) {
178                 if ((channel->iface == iface) && (channel->id == channel_id))
179                         return channel;
180         }
181
182         return NULL;
183 }
184
185 /**
186  * copy_data - implements data copying function
187  * @channel: channel
188  * @mbo: MBO from core
189  *
190  * Copy data from/to ring buffer to/from MBO and update the buffer position
191  */
192 static bool copy_data(struct channel *channel, struct mbo *mbo)
193 {
194         struct snd_pcm_runtime *const runtime = channel->substream->runtime;
195         unsigned int const frame_bytes = channel->cfg->subbuffer_size;
196         unsigned int const buffer_size = runtime->buffer_size;
197         unsigned int frames;
198         unsigned int fr0;
199
200         if (channel->cfg->direction & MOST_CH_RX)
201                 frames = mbo->processed_length / frame_bytes;
202         else
203                 frames = mbo->buffer_length / frame_bytes;
204         fr0 = min(buffer_size - channel->buffer_pos, frames);
205
206         channel->copy_fn(runtime->dma_area + channel->buffer_pos * frame_bytes,
207                          mbo->virt_address,
208                          fr0 * frame_bytes);
209
210         if (frames > fr0) {
211                 /* wrap around at end of ring buffer */
212                 channel->copy_fn(runtime->dma_area,
213                                  mbo->virt_address + fr0 * frame_bytes,
214                                  (frames - fr0) * frame_bytes);
215         }
216
217         channel->buffer_pos += frames;
218         if (channel->buffer_pos >= buffer_size)
219                 channel->buffer_pos -= buffer_size;
220         channel->period_pos += frames;
221         if (channel->period_pos >= runtime->period_size) {
222                 channel->period_pos -= runtime->period_size;
223                 return true;
224         }
225
226         return false;
227 }
228
229 /**
230  * playback_thread - function implements the playback thread
231  * @data: private data
232  *
233  * Thread which does the playback functionality in a loop. It waits for a free
234  * MBO from mostcore for a particular channel and copy the data from ring buffer
235  * to MBO. Submit the MBO back to mostcore, after copying the data.
236  *
237  * Returns 0 on success or error code otherwise.
238  */
239 static int playback_thread(void *data)
240 {
241         struct channel *const channel = data;
242
243         pr_info("playback thread started\n");
244
245         while (!kthread_should_stop()) {
246                 struct mbo *mbo = NULL;
247                 bool period_elapsed = false;
248                 int ret;
249
250                 wait_event_interruptible(
251                         channel->playback_waitq,
252                         kthread_should_stop() ||
253                         (mbo = most_get_mbo(channel->iface, channel->id)));
254
255                 if (!mbo)
256                         continue;
257
258                 if (channel->is_stream_running)
259                         period_elapsed = copy_data(channel, mbo);
260                 else
261                         memset(mbo->virt_address, 0, mbo->buffer_length);
262
263                 ret = most_submit_mbo(mbo);
264                 if (ret)
265                         channel->is_stream_running = false;
266
267                 if (period_elapsed)
268                         snd_pcm_period_elapsed(channel->substream);
269         }
270
271         return 0;
272 }
273
274 /**
275  * pcm_open - implements open callback function for PCM middle layer
276  * @substream: pointer to ALSA PCM substream
277  *
278  * This is called when a PCM substream is opened. At least, the function should
279  * initialize the runtime->hw record.
280  *
281  * Returns 0 on success or error code otherwise.
282  */
283 static int pcm_open(struct snd_pcm_substream *substream)
284 {
285         struct channel *channel = substream->private_data;
286         struct snd_pcm_runtime *runtime = substream->runtime;
287         struct most_channel_config *cfg = channel->cfg;
288
289         pr_info("pcm_open(), %s\n", substream->name);
290
291         channel->substream = substream;
292
293         if (cfg->direction == MOST_CH_TX) {
294                 init_waitqueue_head(&channel->playback_waitq);
295                 channel->playback_task = kthread_run(&playback_thread, channel,
296                                                      "most_audio_playback");
297                 if (IS_ERR(channel->playback_task))
298                         return PTR_ERR(channel->playback_task);
299         }
300
301         if (most_start_channel(channel->iface, channel->id)) {
302                 pr_err("most_start_channel() failed!\n");
303                 if (cfg->direction == MOST_CH_TX)
304                         kthread_stop(channel->playback_task);
305                 return -EBUSY;
306         }
307
308         runtime->hw = pcm_hardware_template;
309         runtime->hw.buffer_bytes_max = cfg->num_buffers * cfg->buffer_size;
310         runtime->hw.period_bytes_min = cfg->buffer_size;
311         runtime->hw.period_bytes_max = cfg->buffer_size;
312         runtime->hw.periods_min = 1;
313         runtime->hw.periods_max = cfg->num_buffers;
314
315         return 0;
316 }
317
318 /**
319  * pcm_close - implements close callback function for PCM middle layer
320  * @substream: sub-stream pointer
321  *
322  * Obviously, this is called when a PCM substream is closed. Any private
323  * instance for a PCM substream allocated in the open callback will be
324  * released here.
325  *
326  * Returns 0 on success or error code otherwise.
327  */
328 static int pcm_close(struct snd_pcm_substream *substream)
329 {
330         struct channel *channel = substream->private_data;
331
332         pr_info("pcm_close(), %s\n", substream->name);
333
334         if (channel->cfg->direction == MOST_CH_TX)
335                 kthread_stop(channel->playback_task);
336         most_stop_channel(channel->iface, channel->id);
337
338         return 0;
339 }
340
341 /**
342  * pcm_hw_params - implements hw_params callback function for PCM middle layer
343  * @substream: sub-stream pointer
344  * @hw_params: contains the hardware parameters set by the application
345  *
346  * This is called when the hardware parameters is set by the application, that
347  * is, once when the buffer size, the period size, the format, etc. are defined
348  * for the PCM substream. Many hardware setups should be done is this callback,
349  * including the allocation of buffers.
350  *
351  * Returns 0 on success or error code otherwise.
352  */
353 static int pcm_hw_params(struct snd_pcm_substream *substream,
354                          struct snd_pcm_hw_params *hw_params)
355 {
356         pr_info("pcm_hw_params()\n");
357
358         return snd_pcm_lib_alloc_vmalloc_buffer(substream,
359                                                 params_buffer_bytes(hw_params));
360 }
361
362 /**
363  * pcm_hw_free - implements hw_free callback function for PCM middle layer
364  * @substream: substream pointer
365  *
366  * This is called to release the resources allocated via hw_params.
367  * This function will be always called before the close callback is called.
368  *
369  * Returns 0 on success or error code otherwise.
370  */
371 static int pcm_hw_free(struct snd_pcm_substream *substream)
372 {
373         pr_info("pcm_hw_free()\n");
374
375         return snd_pcm_lib_free_vmalloc_buffer(substream);
376 }
377
378 /**
379  * pcm_prepare - implements prepare callback function for PCM middle layer
380  * @substream: substream pointer
381  *
382  * This callback is called when the PCM is "prepared". Format rate, sample rate,
383  * etc., can be set here. This callback can be called many times at each setup.
384  *
385  * Returns 0 on success or error code otherwise.
386  */
387 static int pcm_prepare(struct snd_pcm_substream *substream)
388 {
389         struct channel *channel = substream->private_data;
390         struct snd_pcm_runtime *runtime = substream->runtime;
391         struct most_channel_config *cfg = channel->cfg;
392         int width = snd_pcm_format_physical_width(runtime->format);
393
394         channel->copy_fn = NULL;
395
396         if (cfg->direction == MOST_CH_TX) {
397                 if (snd_pcm_format_big_endian(runtime->format) || width == 8)
398                         channel->copy_fn = alsa_to_most_memcpy;
399                 else if (width == 16)
400                         channel->copy_fn = alsa_to_most_copy16;
401                 else if (width == 24)
402                         channel->copy_fn = alsa_to_most_copy24;
403                 else if (width == 32)
404                         channel->copy_fn = alsa_to_most_copy32;
405         } else {
406                 if (snd_pcm_format_big_endian(runtime->format) || width == 8)
407                         channel->copy_fn = most_to_alsa_memcpy;
408                 else if (width == 16)
409                         channel->copy_fn = most_to_alsa_copy16;
410                 else if (width == 24)
411                         channel->copy_fn = most_to_alsa_copy24;
412                 else if (width == 32)
413                         channel->copy_fn = most_to_alsa_copy32;
414         }
415
416         if (!channel->copy_fn) {
417                 pr_err("unsupported format\n");
418                 return -EINVAL;
419         }
420
421         channel->period_pos = 0;
422         channel->buffer_pos = 0;
423
424         return 0;
425 }
426
427 /**
428  * pcm_trigger - implements trigger callback function for PCM middle layer
429  * @substream: substream pointer
430  * @cmd: action to perform
431  *
432  * This is called when the PCM is started, stopped or paused. The action will be
433  * specified in the second argument, SNDRV_PCM_TRIGGER_XXX
434  *
435  * Returns 0 on success or error code otherwise.
436  */
437 static int pcm_trigger(struct snd_pcm_substream *substream, int cmd)
438 {
439         struct channel *channel = substream->private_data;
440
441         switch (cmd) {
442         case SNDRV_PCM_TRIGGER_START:
443                 channel->is_stream_running = true;
444                 return 0;
445
446         case SNDRV_PCM_TRIGGER_STOP:
447                 channel->is_stream_running = false;
448                 return 0;
449
450         default:
451                 pr_info("pcm_trigger(), invalid\n");
452                 return -EINVAL;
453         }
454         return 0;
455 }
456
457 /**
458  * pcm_pointer - implements pointer callback function for PCM middle layer
459  * @substream: substream pointer
460  *
461  * This callback is called when the PCM middle layer inquires the current
462  * hardware position on the buffer. The position must be returned in frames,
463  * ranging from 0 to buffer_size-1.
464  */
465 static snd_pcm_uframes_t pcm_pointer(struct snd_pcm_substream *substream)
466 {
467         struct channel *channel = substream->private_data;
468
469         return channel->buffer_pos;
470 }
471
472 /**
473  * Initialization of struct snd_pcm_ops
474  */
475 static struct snd_pcm_ops pcm_ops = {
476         .open       = pcm_open,
477         .close      = pcm_close,
478         .ioctl      = snd_pcm_lib_ioctl,
479         .hw_params  = pcm_hw_params,
480         .hw_free    = pcm_hw_free,
481         .prepare    = pcm_prepare,
482         .trigger    = pcm_trigger,
483         .pointer    = pcm_pointer,
484         .page       = snd_pcm_lib_get_vmalloc_page,
485         .mmap       = snd_pcm_lib_mmap_vmalloc,
486 };
487
488
489 static int split_arg_list(char *buf, char **card_name, char **pcm_format)
490 {
491         *card_name = strsep(&buf, ".");
492         if (!*card_name)
493                 return -EIO;
494         *pcm_format = strsep(&buf, ".\n");
495         if (!*pcm_format)
496                 return -EIO;
497         return 0;
498 }
499
500 static int audio_set_pcm_format(char *pcm_format,
501                                 struct most_channel_config *cfg)
502 {
503         if (!strcmp(pcm_format, "1x8")) {
504                 if (cfg->subbuffer_size != 1)
505                         goto error;
506                 pr_info("PCM format is 8-bit mono\n");
507                 pcm_hardware_template.formats = SNDRV_PCM_FMTBIT_S8;
508         } else if (!strcmp(pcm_format, "2x16")) {
509                 if (cfg->subbuffer_size != 4)
510                         goto error;
511                 pr_info("PCM format is 16-bit stereo\n");
512                 pcm_hardware_template.formats = SNDRV_PCM_FMTBIT_S16_LE |
513                                                 SNDRV_PCM_FMTBIT_S16_BE;
514         } else if (!strcmp(pcm_format, "2x24")) {
515                 if (cfg->subbuffer_size != 6)
516                         goto error;
517                 pr_info("PCM format is 24-bit stereo\n");
518                 pcm_hardware_template.formats = SNDRV_PCM_FMTBIT_S24_3LE |
519                                                 SNDRV_PCM_FMTBIT_S24_3BE;
520         } else if (!strcmp(pcm_format, "2x32")) {
521                 if (cfg->subbuffer_size != 8)
522                         goto error;
523                 pr_info("PCM format is 32-bit stereo\n");
524                 pcm_hardware_template.formats = SNDRV_PCM_FMTBIT_S32_LE |
525                                                 SNDRV_PCM_FMTBIT_S32_BE;
526         } else {
527                 pr_err("PCM format %s not supported\n", pcm_format);
528                 return -EIO;
529         }
530         return 0;
531 error:
532         pr_err("Audio resolution doesn't fit subbuffer size\n");
533         return -EINVAL;
534 }
535
536 /**
537  * audio_probe_channel - probe function of the driver module
538  * @iface: pointer to interface instance
539  * @channel_id: channel index/ID
540  * @cfg: pointer to actual channel configuration
541  * @parent: pointer to kobject (needed for sysfs hook-up)
542  * @arg_list: string that provides the name of the device to be created in /dev
543  *            plus the desired audio resolution
544  *
545  * Creates sound card, pcm device, sets pcm ops and registers sound card.
546  *
547  * Returns 0 on success or error code otherwise.
548  */
549 static int audio_probe_channel(struct most_interface *iface, int channel_id,
550                                struct most_channel_config *cfg,
551                                struct kobject *parent, char *arg_list)
552 {
553         struct channel *channel;
554         struct snd_card *card;
555         struct snd_pcm *pcm;
556         int playback_count = 0;
557         int capture_count = 0;
558         int ret;
559         int direction;
560         char *card_name;
561         char *pcm_format;
562
563         pr_info("sound_probe_channel()\n");
564
565         if (!iface)
566                 return -EINVAL;
567
568         if (cfg->data_type != MOST_CH_SYNC) {
569                 pr_err("Incompatible channel type\n");
570                 return -EINVAL;
571         }
572
573         if (get_channel(iface, channel_id)) {
574                 pr_err("channel (%s:%d) is already linked\n",
575                        iface->description, channel_id);
576                 return -EINVAL;
577         }
578
579         if (cfg->direction == MOST_CH_TX) {
580                 playback_count = 1;
581                 direction = SNDRV_PCM_STREAM_PLAYBACK;
582         } else {
583                 capture_count = 1;
584                 direction = SNDRV_PCM_STREAM_CAPTURE;
585         }
586
587         ret = split_arg_list(arg_list, &card_name, &pcm_format);
588         if (ret < 0) {
589                 pr_info("PCM format missing\n");
590                 return ret;
591         }
592         if (audio_set_pcm_format(pcm_format, cfg))
593                 return ret;
594
595         ret = snd_card_new(NULL, -1, card_name, THIS_MODULE,
596                            sizeof(*channel), &card);
597         if (ret < 0)
598                 return ret;
599
600         channel = card->private_data;
601         channel->card = card;
602         channel->cfg = cfg;
603         channel->iface = iface;
604         channel->id = channel_id;
605
606         snprintf(card->driver, sizeof(card->driver), "%s", DRIVER_NAME);
607         snprintf(card->shortname, sizeof(card->shortname), "MOST:%d",
608                  card->number);
609         snprintf(card->longname, sizeof(card->longname), "%s at %s, ch %d",
610                  card->shortname, iface->description, channel_id);
611
612         ret = snd_pcm_new(card, card_name, 0, playback_count,
613                           capture_count, &pcm);
614         if (ret < 0)
615                 goto err_free_card;
616
617         pcm->private_data = channel;
618
619         snd_pcm_set_ops(pcm, direction, &pcm_ops);
620
621         ret = snd_card_register(card);
622         if (ret < 0)
623                 goto err_free_card;
624
625         list_add_tail(&channel->list, &dev_list);
626
627         return 0;
628
629 err_free_card:
630         snd_card_free(card);
631         return ret;
632 }
633
634 /**
635  * audio_disconnect_channel - function to disconnect a channel
636  * @iface: pointer to interface instance
637  * @channel_id: channel index
638  *
639  * This frees allocated memory and removes the sound card from ALSA
640  *
641  * Returns 0 on success or error code otherwise.
642  */
643 static int audio_disconnect_channel(struct most_interface *iface,
644                                     int channel_id)
645 {
646         struct channel *channel;
647
648         pr_info("sound_disconnect_channel()\n");
649
650         channel = get_channel(iface, channel_id);
651         if (!channel) {
652                 pr_err("sound_disconnect_channel(), invalid channel %d\n",
653                        channel_id);
654                 return -EINVAL;
655         }
656
657         list_del(&channel->list);
658         snd_card_free(channel->card);
659
660         return 0;
661 }
662
663 /**
664  * audio_rx_completion - completion handler for rx channels
665  * @mbo: pointer to buffer object that has completed
666  *
667  * This searches for the channel this MBO belongs to and copy the data from MBO
668  * to ring buffer
669  *
670  * Returns 0 on success or error code otherwise.
671  */
672 static int audio_rx_completion(struct mbo *mbo)
673 {
674         struct channel *channel = get_channel(mbo->ifp, mbo->hdm_channel_id);
675         bool period_elapsed = false;
676
677         if (!channel) {
678                 pr_err("sound_rx_completion(), invalid channel %d\n",
679                        mbo->hdm_channel_id);
680                 return -EINVAL;
681         }
682
683         if (channel->is_stream_running)
684                 period_elapsed = copy_data(channel, mbo);
685
686         most_put_mbo(mbo);
687
688         if (period_elapsed)
689                 snd_pcm_period_elapsed(channel->substream);
690
691         return 0;
692 }
693
694 /**
695  * audio_tx_completion - completion handler for tx channels
696  * @iface: pointer to interface instance
697  * @channel_id: channel index/ID
698  *
699  * This searches the channel that belongs to this combination of interface
700  * pointer and channel ID and wakes a process sitting in the wait queue of
701  * this channel.
702  *
703  * Returns 0 on success or error code otherwise.
704  */
705 static int audio_tx_completion(struct most_interface *iface, int channel_id)
706 {
707         struct channel *channel = get_channel(iface, channel_id);
708
709         if (!channel) {
710                 pr_err("sound_tx_completion(), invalid channel %d\n",
711                        channel_id);
712                 return -EINVAL;
713         }
714
715         wake_up_interruptible(&channel->playback_waitq);
716
717         return 0;
718 }
719
720 /**
721  * Initialization of the struct most_aim
722  */
723 static struct most_aim audio_aim = {
724         .name = DRIVER_NAME,
725         .probe_channel = audio_probe_channel,
726         .disconnect_channel = audio_disconnect_channel,
727         .rx_completion = audio_rx_completion,
728         .tx_completion = audio_tx_completion,
729 };
730
731 static int __init audio_init(void)
732 {
733         pr_info("init()\n");
734
735         INIT_LIST_HEAD(&dev_list);
736
737         return most_register_aim(&audio_aim);
738 }
739
740 static void __exit audio_exit(void)
741 {
742         struct channel *channel, *tmp;
743
744         pr_info("exit()\n");
745
746         list_for_each_entry_safe(channel, tmp, &dev_list, list) {
747                 list_del(&channel->list);
748                 snd_card_free(channel->card);
749         }
750
751         most_deregister_aim(&audio_aim);
752 }
753
754 module_init(audio_init);
755 module_exit(audio_exit);
756
757 MODULE_LICENSE("GPL");
758 MODULE_AUTHOR("Christian Gromm <christian.gromm@microchip.com>");
759 MODULE_DESCRIPTION("Audio Application Interface Module for MostCore");