2 * linux/sound/oss/omap-audio.c
4 * Common audio handling for the OMAP processors
6 * Copyright (C) 2004 Texas Instruments, Inc.
8 * Copyright (C) 2000, 2001 Nicolas Pitre <nico@cam.org>
10 * This package is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
14 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
16 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 * 2004/08/12 Nishanth Menon - Modified to integrate Audio requirements on 1610,1710 platforms
22 * 2004-11-01 Nishanth Menon - modified to support 16xx and 17xx
23 * platform multi channel chaining.
25 * 2004-11-04 Nishanth Menon - Added support for power management
27 * 2004-12-17 Nishanth Menon - Provided proper module handling support
30 /***************************** INCLUDES ************************************/
32 #include <linux/config.h>
33 #include <linux/module.h>
34 #include <linux/init.h>
35 #include <linux/types.h>
38 #include <linux/slab.h>
39 #include <linux/sched.h>
40 #include <linux/poll.h>
42 #include <linux/errno.h>
43 #include <linux/sound.h>
44 #include <linux/soundcard.h>
45 #include <linux/sysrq.h>
46 #include <linux/delay.h>
47 #include <linux/platform_device.h>
48 #include <linux/completion.h>
50 #include <asm/uaccess.h>
52 #include <asm/hardware.h>
53 #include <asm/semaphore.h>
55 #include "omap-audio-dma-intfc.h"
56 #include "omap-audio.h"
58 /***************************** MACROS ************************************/
63 #define DPRINTK printk
64 #define FN_IN printk("[omap_audio.c:[%s] start\n", __FUNCTION__)
65 #define FN_OUT(n) printk("[omap_audio.c:[%s] end(%d)\n", __FUNCTION__ , n)
67 #define DPRINTK( x... )
72 #define OMAP_AUDIO_NAME "omap-audio"
73 #define AUDIO_NBFRAGS_DEFAULT 8
74 #define AUDIO_FRAGSIZE_DEFAULT 8192
76 /* HACK ALERT!: These values will bave to be tuned as this is a trade off b/w
77 * Sampling Rate vs buffer size and delay we are prepared to do before giving up
79 #define MAX_QUEUE_FULL_RETRIES 1000000
80 #define QUEUE_WAIT_TIME 10
82 #define AUDIO_ACTIVE(state) ((state)->rd_ref || (state)->wr_ref)
84 #define SPIN_ADDR (dma_addr_t)0
85 #define SPIN_SIZE 2048
87 /***************************** MODULES SPECIFIC FUNCTION PROTOTYPES ********************/
89 static int audio_write(struct file *file, const char __user *buffer,
90 size_t count, loff_t * ppos);
92 static int audio_read(struct file *file, char __user *buffer, size_t count,
95 static int audio_mmap(struct file *file, struct vm_area_struct *vma);
97 static unsigned int audio_poll(struct file *file,
98 struct poll_table_struct *wait);
100 static loff_t audio_llseek(struct file *file, loff_t offset, int origin);
102 static int audio_ioctl(struct inode *inode, struct file *file, uint cmd,
105 static int audio_open(struct inode *inode, struct file *file);
107 static int audio_release(struct inode *inode, struct file *file);
109 static int audio_probe(struct platform_device *pdev);
111 static int audio_remove(struct platform_device *pdev);
113 static void audio_shutdown(struct platform_device *pdev);
115 static int audio_suspend(struct platform_device *pdev, pm_message_t mesg);
117 static int audio_resume(struct platform_device *pdev);
119 static void audio_free(struct device *dev);
121 /***************************** Data Structures **********************************/
124 * The function pointer set to be registered by the codec.
126 static audio_state_t audio_state = { NULL };
128 /* DMA Call back function */
129 static dma_callback_t audio_dma_callback = NULL;
131 /* File Ops structure */
132 static struct file_operations omap_audio_fops = {
134 .release = audio_release,
135 .write = audio_write,
139 .ioctl = audio_ioctl,
140 .llseek = audio_llseek,
144 /* Driver information */
145 static struct platform_driver omap_audio_driver = {
146 .probe = audio_probe,
147 .remove = audio_remove,
148 .suspend = audio_suspend,
149 .shutdown = audio_shutdown,
150 .resume = audio_resume,
152 .name = OMAP_AUDIO_NAME,
156 /* Device Information */
157 static struct platform_device omap_audio_device = {
158 .name = OMAP_AUDIO_NAME,
160 .driver_data = &audio_state,
161 .release = audio_free,
166 /***************************** GLOBAL FUNCTIONs **********************************/
168 /* Power Management Functions for Linux Device Model */
169 /* DEBUG PUPOSES ONLY! */
175 /*********************************************************************************
177 * audio_ldm_suspend(): Suspend operation
179 *********************************************************************************/
180 static int audio_ldm_suspend(void *data)
182 audio_state_t *state = data;
187 * Reject the suspend request if we are already actively transmitting data
188 * Rationale: We dont want to be suspended while in the middle of a call!
190 if (AUDIO_ACTIVE(state) && state->hw_init) {
191 printk(KERN_ERR "Audio device Active, Cannot Suspend");
195 * This Piece of code is commented out in hope
196 * That one day we would need to suspend the device while
197 * audio operations are in progress and resume the operations
198 * once the resume is done.
199 * This is just a sample implementation of how it could be done.
200 * Currently NOT SUPPORTED
202 audio_stream_t *is = state->input_stream;
203 audio_stream_t *os = state->output_stream;
205 if (is && is->buffers) {
206 printk("IS Suspend\n");
207 stopstate = is->stopped;
211 is->stopped = stopstate;
213 if (os && os->buffers) {
214 printk("OS Suspend\n");
215 stopstate = os->stopped;
219 os->stopped = stopstate;
228 /*********************************************************************************
230 * audio_ldm_resume(): Resume Operations
232 *********************************************************************************/
233 static int audio_ldm_resume(void *data)
235 audio_state_t *state = data;
238 if (AUDIO_ACTIVE(state) && state->hw_init) {
239 /* Should never occur - since we never suspend with active state */
244 * This Piece of code is commented out in hope
245 * That one day we would need to suspend the device while
246 * audio operations are in progress and resume the operations
247 * once the resume is done.
248 * This is just a sample implementation of how it could be done.
249 * Currently NOT SUPPORTED
251 audio_stream_t *is = state->input_stream;
252 audio_stream_t *os = state->output_stream;
253 if (os && os->buffers) {
254 printk("OS Resume\n");
256 audio_process_dma(os);
258 if (is && is->buffers) {
259 printk("IS Resume\n");
261 audio_process_dma(is);
268 #endif /* End of #ifdef CONFIG_PM */
270 /*********************************************************************************
272 * audio_free(): The Audio driver release function
273 * This is a dummy function required by the platform driver
275 *********************************************************************************/
276 static void audio_free(struct device *dev)
278 /* Nothing to Release! */
281 /*********************************************************************************
283 * audio_probe(): The Audio driver probe function
284 * WARNING!!!! : It is expected that the codec would have registered with us by now
286 *********************************************************************************/
287 static int audio_probe(struct platform_device *pdev)
291 if (!audio_state.hw_probe) {
292 printk(KERN_ERR "Probe Function Not Registered\n");
295 ret = audio_state.hw_probe();
300 /*********************************************************************************
302 * audio_remove() Function to handle removal operations
304 *********************************************************************************/
305 static int audio_remove(struct platform_device *pdev)
308 if (audio_state.hw_remove) {
309 audio_state.hw_remove();
315 /*********************************************************************************
317 * audio_shutdown(): Function to handle shutdown operations
319 *********************************************************************************/
320 static void audio_shutdown(struct platform_device *pdev)
323 if (audio_state.hw_cleanup) {
324 audio_state.hw_cleanup();
330 /*********************************************************************************
332 * audio_suspend(): Function to handle suspend operations
334 *********************************************************************************/
335 static int audio_suspend(struct platform_device *pdev, pm_message_t mesg)
340 void *data = pdev->dev.driver_data;
342 if (audio_state.hw_suspend) {
343 ret = audio_ldm_suspend(data);
345 ret = audio_state.hw_suspend();
348 printk(KERN_INFO "Audio Suspend Failed \n");
350 printk(KERN_INFO "Audio Suspend Success \n");
352 #endif /* CONFIG_PM */
358 /*********************************************************************************
360 * audio_resume(): Function to handle resume operations
362 *********************************************************************************/
363 static int audio_resume(struct platform_device *pdev)
368 void *data = pdev->dev.driver_data;
370 if (audio_state.hw_resume) {
371 ret = audio_ldm_resume(data);
373 ret = audio_state.hw_resume();
376 printk(KERN_INFO " Audio Resume Failed \n");
378 printk(KERN_INFO " Audio Resume Success \n");
380 #endif /* CONFIG_PM */
386 /*********************************************************************************
388 * audio_get_fops(): Return the fops required to get the function pointers of
391 *********************************************************************************/
392 struct file_operations *audio_get_fops(void)
396 return &omap_audio_fops;
399 /*********************************************************************************
401 * audio_register_codec(): Register a Codec fn points using this function
402 * WARNING!!!!! : Codecs should ensure that they do so! no sanity checks
403 * during runtime is done due to obvious performance
406 *********************************************************************************/
407 int audio_register_codec(audio_state_t * codec_state)
412 /* We dont handle multiple codecs now */
413 if (audio_state.hw_init) {
414 printk(KERN_ERR " Codec Already registered\n");
418 /* Grab the dma Callback */
419 audio_dma_callback = audio_get_dma_callback();
420 if (!audio_dma_callback) {
421 printk(KERN_ERR "Unable to get call back function\n");
427 printk(KERN_ERR "NULL ARGUMENT!\n");
431 if (!codec_state->hw_probe || !codec_state->hw_init
432 || !codec_state->hw_shutdown || !codec_state->client_ioctl) {
434 "Required Fn Entry point Missing probe=%p init=%p,down=%p,ioctl=%p!\n",
435 codec_state->hw_probe, codec_state->hw_init,
436 codec_state->hw_shutdown, codec_state->client_ioctl);
440 memcpy(&audio_state, codec_state, sizeof(audio_state_t));
441 sema_init(&audio_state.sem, 1);
443 ret = platform_device_register(&omap_audio_device);
445 printk(KERN_ERR "Platform dev_register failed =%d\n", ret);
450 ret = platform_driver_register(&omap_audio_driver);
452 printk(KERN_ERR "Device Register failed =%d\n", ret);
454 platform_device_unregister(&omap_audio_device);
464 /*********************************************************************************
466 * audio_unregister_codec(): Un-Register a Codec using this function
468 *********************************************************************************/
469 int audio_unregister_codec(audio_state_t * codec_state)
473 /* We dont handle multiple codecs now */
474 if (!audio_state.hw_init) {
475 printk(KERN_ERR " No Codec registered\n");
479 if (audio_state.hw_init != codec_state->hw_init) {
481 " Attempt to unregister codec which was not registered with us\n");
485 platform_driver_unregister(&omap_audio_driver);
486 platform_device_unregister(&omap_audio_device);
488 memset(&audio_state, 0, sizeof(audio_state_t));
494 /***************************** MODULES SPECIFIC FUNCTION *************************/
496 /*********************************************************************************
498 * audio_write(): Exposed to write() call
500 *********************************************************************************/
502 audio_write(struct file *file, const char __user *buffer,
503 size_t count, loff_t * ppos)
505 const char __user *buffer0 = buffer;
506 audio_state_t *state = file->private_data;
507 audio_stream_t *s = state->output_stream;
508 int chunksize, ret = 0;
510 DPRINTK("audio_write: count=%d\n", count);
511 if (*ppos != file->f_pos) {
512 printk("FPOS not ppos ppos=0x%x fpos =0x%x\n", (u32) * ppos,
517 printk("s already mapped\n");
520 if (!s->buffers && audio_setup_buf(s)) {
521 printk("NO MEMORY\n");
526 audio_buf_t *b = &s->buffers[s->usr_head];
528 /* Wait for a buffer to become free */
529 if (file->f_flags & O_NONBLOCK) {
535 if (wait_for_completion_interruptible(&s->wfc))
538 /* Feed the current buffer */
539 chunksize = s->fragsize - b->offset;
540 if (chunksize > count)
542 DPRINTK("write %d to %d\n", chunksize, s->usr_head);
543 if (copy_from_user(b->data + b->offset, buffer, chunksize)) {
544 printk(KERN_ERR "Audio: CopyFrom User failed \n");
551 b->offset += chunksize;
553 if (b->offset < s->fragsize) {
558 /* Update pointers and send current fragment to DMA */
560 if (++s->usr_head >= s->nbfrags)
562 /* Add the num of frags pending */
566 audio_process_dma(s);
570 if ((buffer - buffer0))
571 ret = buffer - buffer0;
572 DPRINTK("audio_write: return=%d\n", ret);
576 /*********************************************************************************
578 * audio_read(): Exposed as read() function
580 *********************************************************************************/
582 audio_read(struct file *file, char __user *buffer, size_t count, loff_t * ppos)
584 char __user *buffer0 = buffer;
585 audio_state_t *state = file->private_data;
586 audio_stream_t *s = state->input_stream;
587 int chunksize, ret = 0;
590 DPRINTK("audio_read: count=%d\n", count);
592 if (*ppos != file->f_pos) {
593 printk("AudioRead - FPOS not ppos ppos=0x%x fpos =0x%x\n",
594 (u32) * ppos, (u32) file->f_pos);
598 printk("AudioRead - s already mapped\n");
603 if (!s->buffers && audio_setup_buf(s)) {
604 printk("AudioRead - No Memory\n");
607 audio_prime_rx(state);
611 audio_buf_t *b = &s->buffers[s->usr_head];
613 /* Wait for a buffer to become full */
614 if (file->f_flags & O_NONBLOCK) {
620 if (wait_for_completion_interruptible(&s->wfc))
623 /* Grab data from the current buffer */
624 chunksize = s->fragsize - b->offset;
625 if (chunksize > count)
627 DPRINTK("read %d from %d\n", chunksize, s->usr_head);
628 if (copy_to_user(buffer, b->data + b->offset, chunksize)) {
634 b->offset += chunksize;
635 if (b->offset < s->fragsize) {
640 /* Update pointers and return current fragment to DMA */
641 local_irq_save(flags);
643 if (++s->usr_head >= s->nbfrags)
647 local_irq_restore(flags);
648 audio_process_dma(s);
652 if ((buffer - buffer0))
653 ret = buffer - buffer0;
654 DPRINTK("audio_read: return=%d\n", ret);
658 /*********************************************************************************
660 * audio_mmap(): Exposed as mmap Function
661 * !!WARNING: Still under development
663 *********************************************************************************/
664 static int audio_mmap(struct file *file, struct vm_area_struct *vma)
666 audio_state_t *state = file->private_data;
668 unsigned long size, vma_addr;
672 if (vma->vm_pgoff != 0)
675 if (vma->vm_flags & VM_WRITE) {
678 s = state->output_stream;
679 } else if (vma->vm_flags & VM_READ) {
682 s = state->input_stream;
688 size = vma->vm_end - vma->vm_start;
689 if (size != s->fragsize * s->nbfrags)
691 if (!s->buffers && audio_setup_buf(s))
693 vma_addr = vma->vm_start;
694 for (i = 0; i < s->nbfrags; i++) {
695 audio_buf_t *buf = &s->buffers[i];
699 remap_pfn_range(vma, vma_addr, buf->dma_addr >> PAGE_SHIFT,
700 buf->master, vma->vm_page_prot);
703 vma_addr += buf->master;
711 /*********************************************************************************
713 * audio_poll(): Exposed as poll function
715 *********************************************************************************/
717 audio_poll(struct file *file, struct poll_table_struct *wait)
719 audio_state_t *state = file->private_data;
720 audio_stream_t *is = state->input_stream;
721 audio_stream_t *os = state->output_stream;
722 unsigned int mask = 0;
724 DPRINTK("audio_poll(): mode=%s%s\n",
725 (file->f_mode & FMODE_READ) ? "r" : "",
726 (file->f_mode & FMODE_WRITE) ? "w" : "");
728 if (file->f_mode & FMODE_READ) {
729 /* Start audio input if not already active */
731 if (!is->buffers && audio_setup_buf(is))
733 audio_prime_rx(state);
735 poll_wait(file, &is->wq, wait);
738 if (file->f_mode & FMODE_WRITE) {
739 if (!os->buffers && audio_setup_buf(os))
741 poll_wait(file, &os->wq, wait);
744 if (file->f_mode & FMODE_READ)
745 if ((is->mapped && is->bytecount > 0) ||
746 (!is->mapped && is->wfc.done > 0))
747 mask |= POLLIN | POLLRDNORM;
749 if (file->f_mode & FMODE_WRITE)
750 if ((os->mapped && os->bytecount > 0) ||
751 (!os->mapped && os->wfc.done > 0))
752 mask |= POLLOUT | POLLWRNORM;
754 DPRINTK("audio_poll() returned mask of %s%s\n",
755 (mask & POLLIN) ? "r" : "", (mask & POLLOUT) ? "w" : "");
761 /*********************************************************************************
763 * audio_llseek(): Exposed as lseek() function.
765 *********************************************************************************/
766 static loff_t audio_llseek(struct file *file, loff_t offset, int origin)
773 /*********************************************************************************
775 * audio_ioctl(): Handles generic ioctls. If there is a request for something this
776 * fn cannot handle, its then given to client specific ioctl routine, that will take
777 * up platform specific requests
779 *********************************************************************************/
781 audio_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
783 audio_state_t *state = file->private_data;
784 audio_stream_t *os = state->output_stream;
785 audio_stream_t *is = state->input_stream;
788 DPRINTK(__FILE__ " audio_ioctl 0x%08x\n", cmd);
790 /* dispatch based on command */
793 return put_user(SOUND_VERSION, (int __user *)arg);
795 case SNDCTL_DSP_GETBLKSIZE:
796 if (file->f_mode & FMODE_WRITE)
797 return put_user(os->fragsize, (int __user *)arg);
799 return put_user(is->fragsize, (int __user *)arg);
801 case SNDCTL_DSP_GETCAPS:
802 val = DSP_CAP_REALTIME | DSP_CAP_TRIGGER | DSP_CAP_MMAP;
804 val |= DSP_CAP_DUPLEX;
806 return put_user(val, (int __user *)arg);
808 case SNDCTL_DSP_SETFRAGMENT:
809 if (get_user(val, (long __user *)arg)) {
813 if (file->f_mode & FMODE_READ) {
814 int ret = audio_set_fragments(is, val);
819 ret = put_user(ret, (int __user *)arg);
825 if (file->f_mode & FMODE_WRITE) {
826 int ret = audio_set_fragments(os, val);
831 ret = put_user(ret, (int __user *)arg);
840 case SNDCTL_DSP_SYNC:
842 return audio_sync(file);
844 case SNDCTL_DSP_SETDUPLEX:
848 case SNDCTL_DSP_POST:
852 case SNDCTL_DSP_GETTRIGGER:
854 if (file->f_mode & FMODE_READ && is->active && !is->stopped)
855 val |= PCM_ENABLE_INPUT;
856 if (file->f_mode & FMODE_WRITE && os->active && !os->stopped)
857 val |= PCM_ENABLE_OUTPUT;
859 return put_user(val, (int __user *)arg);
861 case SNDCTL_DSP_SETTRIGGER:
862 if (get_user(val, (int __user *)arg)) {
866 if (file->f_mode & FMODE_READ) {
867 if (val & PCM_ENABLE_INPUT) {
870 if (!is->buffers && audio_setup_buf(is)) {
874 audio_prime_rx(state);
876 local_irq_save(flags);
878 local_irq_restore(flags);
879 audio_process_dma(is);
885 if (file->f_mode & FMODE_WRITE) {
886 if (val & PCM_ENABLE_OUTPUT) {
888 if (!os->buffers && audio_setup_buf(os)) {
892 local_irq_save(flags);
893 if (os->mapped && !os->pending_frags) {
894 os->pending_frags = os->nbfrags;
895 init_completion(&os->wfc);
900 local_irq_restore(flags);
901 audio_process_dma(os);
910 case SNDCTL_DSP_GETOPTR:
911 case SNDCTL_DSP_GETIPTR:
913 count_info inf = { 0, };
915 (cmd == SNDCTL_DSP_GETOPTR) ? os : is;
916 int bytecount, offset;
919 if ((s == is && !(file->f_mode & FMODE_READ)) ||
920 (s == os && !(file->f_mode & FMODE_WRITE))) {
925 local_irq_save(flags);
926 offset = audio_get_dma_pos(s);
927 inf.ptr = s->dma_tail * s->fragsize + offset;
928 bytecount = s->bytecount + offset;
929 s->bytecount = -offset;
930 inf.blocks = s->fragcount;
932 local_irq_restore(flags);
935 inf.bytes = bytecount;
938 return copy_to_user((void __user *)arg, &inf, sizeof(inf));
941 case SNDCTL_DSP_GETOSPACE:
942 case SNDCTL_DSP_GETISPACE:
944 audio_buf_info inf = { 0, };
946 (cmd == SNDCTL_DSP_GETOSPACE) ? os : is;
948 if ((s == is && !(file->f_mode & FMODE_READ)) ||
949 (s == os && !(file->f_mode & FMODE_WRITE))) {
953 if (!s->buffers && audio_setup_buf(s)) {
957 inf.bytes = s->wfc.done * s->fragsize;
959 inf.fragments = inf.bytes / s->fragsize;
960 inf.fragsize = s->fragsize;
961 inf.fragstotal = s->nbfrags;
963 return copy_to_user((void __user *)arg, &inf, sizeof(inf));
966 case SNDCTL_DSP_NONBLOCK:
967 file->f_flags |= O_NONBLOCK;
971 case SNDCTL_DSP_RESET:
972 if (file->f_mode & FMODE_READ) {
974 if (state->need_tx_for_rx) {
976 local_irq_save(flags);
978 local_irq_restore(flags);
981 if (file->f_mode & FMODE_WRITE) {
989 * Let the client of this module handle the
993 return state->client_ioctl(inode, file, cmd, arg);
1000 /*********************************************************************************
1002 * audio_open(): Exposed as open() function
1004 *********************************************************************************/
1005 static int audio_open(struct inode *inode, struct file *file)
1007 audio_state_t *state = (&audio_state);
1008 audio_stream_t *os = state->output_stream;
1009 audio_stream_t *is = state->input_stream;
1010 int err, need_tx_dma;
1011 static unsigned char tsc2101_init_flag = 0;
1015 /* Lock the module */
1016 if (!try_module_get(THIS_MODULE)) {
1017 printk(KERN_CRIT "Failed to get module\n");
1020 /* Lock the codec module */
1021 if (!try_module_get(state->owner)) {
1022 printk(KERN_CRIT "Failed to get codec module\n");
1023 module_put(THIS_MODULE);
1029 /* access control */
1031 if ((file->f_mode & FMODE_WRITE) && !os)
1033 if ((file->f_mode & FMODE_READ) && !is)
1036 if ((file->f_mode & FMODE_WRITE) && state->wr_ref)
1038 if ((file->f_mode & FMODE_READ) && state->rd_ref)
1041 if ((file->f_mode & FMODE_READ) && state->need_tx_for_rx && !os)
1044 /* request DMA channels */
1045 need_tx_dma = ((file->f_mode & FMODE_WRITE) ||
1046 ((file->f_mode & FMODE_READ) && state->need_tx_for_rx));
1047 if (state->wr_ref || (state->rd_ref && state->need_tx_for_rx))
1050 DMA_REQUEST(err, os, audio_dma_callback);
1054 if (file->f_mode & FMODE_READ) {
1055 DMA_REQUEST(err, is, audio_dma_callback);
1063 /* now complete initialisation */
1064 if (!AUDIO_ACTIVE(state)) {
1065 if (state->hw_init && !tsc2101_init_flag) {
1066 state->hw_init(state->data);
1067 tsc2101_init_flag = 0;
1073 if ((file->f_mode & FMODE_WRITE)) {
1076 os->fragsize = AUDIO_FRAGSIZE_DEFAULT;
1077 os->nbfrags = AUDIO_NBFRAGS_DEFAULT;
1079 init_waitqueue_head(&os->wq);
1082 if (file->f_mode & FMODE_READ) {
1085 is->fragsize = AUDIO_FRAGSIZE_DEFAULT;
1086 is->nbfrags = AUDIO_NBFRAGS_DEFAULT;
1088 init_waitqueue_head(&is->wq);
1091 file->private_data = state;
1097 module_put(state->owner);
1098 module_put(THIS_MODULE);
1104 /*********************************************************************************
1106 * audio_release(): Exposed as release function()
1108 *********************************************************************************/
1109 static int audio_release(struct inode *inode, struct file *file)
1111 audio_state_t *state = file->private_data;
1112 audio_stream_t *os = state->output_stream;
1113 audio_stream_t *is = state->input_stream;
1119 if (file->f_mode & FMODE_READ) {
1120 audio_discard_buf(is);
1122 is->dma_spinref = 0;
1123 if (state->need_tx_for_rx) {
1125 if (!state->wr_ref) {
1127 os->dma_spinref = 0;
1133 if (file->f_mode & FMODE_WRITE) {
1135 audio_discard_buf(os);
1136 if (!state->need_tx_for_rx || !state->rd_ref) {
1138 os->dma_spinref = 0;
1143 if (!AUDIO_ACTIVE(state)) {
1144 if (state->hw_shutdown)
1145 state->hw_shutdown(state->data);
1150 module_put(state->owner);
1151 module_put(THIS_MODULE);
1157 EXPORT_SYMBOL(audio_register_codec);
1158 EXPORT_SYMBOL(audio_unregister_codec);
1159 EXPORT_SYMBOL(audio_get_fops);
1161 MODULE_AUTHOR("Texas Instruments");
1162 MODULE_DESCRIPTION("Common audio handling for OMAP processors");
1163 MODULE_LICENSE("GPL");