1 /* arch/arm/mach-msm/qdsp5/audio_qcelp.c
3 * qcelp 13k audio decoder device
5 * Copyright (c) 2008 QUALCOMM USA, INC.
7 * This code is based in part on audio_mp3.c, which is
8 * Copyright (C) 2008 Google, Inc.
9 * Copyright (C) 2008 HTC Corporation
11 * This software is licensed under the terms of the GNU General Public
12 * License version 2, as published by the Free Software Foundation, and
13 * may be copied, distributed, and modified under those terms.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 * See the GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, you can find it at http://www.fsf.org.
25 #include <linux/module.h>
27 #include <linux/miscdevice.h>
28 #include <linux/uaccess.h>
29 #include <linux/sched.h>
30 #include <linux/wait.h>
31 #include <linux/dma-mapping.h>
32 #include <linux/gfp.h>
34 #include <asm/ioctls.h>
35 #include <mach/msm_adsp.h>
36 #include <linux/msm_audio.h>
37 #include <mach/qdsp5/qdsp5audppcmdi.h>
38 #include <mach/qdsp5/qdsp5audppmsg.h>
39 #include <mach/qdsp5/qdsp5audplaycmdi.h>
40 #include <mach/qdsp5/qdsp5audplaymsg.h>
43 /* for queue ids - should be relative to module number*/
47 #define dprintk(format, arg...) \
48 printk(KERN_DEBUG format, ## arg)
50 #define dprintk(format, arg...) do {} while (0)
53 #define BUFSZ 1080 /* QCELP 13K Hold 600ms packet data = 36 * 30 */
55 #define DMASZ (BUFSZ * BUF_COUNT)
57 #define PCM_BUFSZ_MIN 1600 /* 100ms worth of data */
58 #define PCM_BUF_MAX_COUNT 5
60 #define AUDDEC_DEC_QCELP 9
62 #define ROUTING_MODE_FTRT 1
63 #define ROUTING_MODE_RT 2
64 /* Decoder status received from AUDPPTASK */
65 #define AUDPP_DEC_STATUS_SLEEP 0
66 #define AUDPP_DEC_STATUS_INIT 1
67 #define AUDPP_DEC_STATUS_CFG 2
68 #define AUDPP_DEC_STATUS_PLAY 3
73 unsigned used
; /* Input usage actual DSP produced PCM size */
78 struct buffer out
[BUF_COUNT
];
84 uint8_t out_needed
; /* number of buffers the dsp is waiting for */
87 struct mutex write_lock
;
88 wait_queue_head_t write_wait
;
90 /* Host PCM section - START */
91 struct buffer in
[PCM_BUF_MAX_COUNT
];
92 struct mutex read_lock
;
93 wait_queue_head_t read_wait
; /* Wait queue for read */
94 char *read_data
; /* pointer to reader buffer */
95 dma_addr_t read_phys
; /* physical address of reader buffer */
96 uint8_t read_next
; /* index to input buffers to be read next */
97 uint8_t fill_next
; /* index to buffer that DSP should be filling */
98 uint8_t pcm_buf_count
; /* number of pcm buffer allocated */
99 /* Host PCM section - END */
101 struct msm_adsp_module
*audplay
;
103 struct audmgr audmgr
;
105 /* data allocated for various buffers */
112 uint8_t stopped
:1; /* set when stopped, cleared on flush */
113 uint8_t pcm_feedback
:1; /* set when non-tunnel mode */
114 uint8_t buf_refresh
:1;
121 static struct audio the_qcelp_audio
;
123 static int auddec_dsp_config(struct audio
*audio
, int enable
);
124 static void audpp_cmd_cfg_adec_params(struct audio
*audio
);
125 static void audpp_cmd_cfg_routing_mode(struct audio
*audio
);
126 static void audqcelp_send_data(struct audio
*audio
, unsigned needed
);
127 static void audqcelp_config_hostpcm(struct audio
*audio
);
128 static void audqcelp_buffer_refresh(struct audio
*audio
);
129 static void audqcelp_dsp_event(void *private, unsigned id
, uint16_t *msg
);
131 /* must be called with audio->lock held */
132 static int audqcelp_enable(struct audio
*audio
)
134 struct audmgr_config cfg
;
137 dprintk("audqcelp_enable()\n");
143 audio
->out_needed
= 0;
145 cfg
.tx_rate
= RPC_AUD_DEF_SAMPLE_RATE_NONE
;
146 cfg
.rx_rate
= RPC_AUD_DEF_SAMPLE_RATE_48000
;
147 cfg
.def_method
= RPC_AUD_DEF_METHOD_PLAYBACK
;
148 cfg
.codec
= RPC_AUD_DEF_CODEC_13K
;
149 cfg
.snd_method
= RPC_SND_METHOD_MIDI
;
151 rc
= audmgr_enable(&audio
->audmgr
, &cfg
);
155 if (msm_adsp_enable(audio
->audplay
)) {
156 pr_err("audio: msm_adsp_enable(audplay) failed\n");
157 audmgr_disable(&audio
->audmgr
);
161 if (audpp_enable(audio
->dec_id
, audqcelp_dsp_event
, audio
)) {
162 pr_err("audio: audpp_enable() failed\n");
163 msm_adsp_disable(audio
->audplay
);
164 audmgr_disable(&audio
->audmgr
);
171 /* must be called with audio->lock held */
172 static int audqcelp_disable(struct audio
*audio
)
174 dprintk("audqcelp_disable()\n");
175 if (audio
->enabled
) {
177 auddec_dsp_config(audio
, 0);
178 wake_up(&audio
->write_wait
);
179 wake_up(&audio
->read_wait
);
180 msm_adsp_disable(audio
->audplay
);
181 audpp_disable(audio
->dec_id
, audio
);
182 audmgr_disable(&audio
->audmgr
);
183 audio
->out_needed
= 0;
188 /* ------------------- dsp --------------------- */
189 static void audqcelp_update_pcm_buf_entry(struct audio
*audio
,
195 spin_lock_irqsave(&audio
->dsp_lock
, flags
);
196 for (index
= 0; index
< payload
[1]; index
++) {
197 if (audio
->in
[audio
->fill_next
].addr
==
198 payload
[2 + index
* 2]) {
199 dprintk("audqcelp_update_pcm_buf_entry: in[%d] ready\n",
201 audio
->in
[audio
->fill_next
].used
=
202 payload
[3 + index
* 2];
203 if ((++audio
->fill_next
) == audio
->pcm_buf_count
)
204 audio
->fill_next
= 0;
207 "audqcelp_update_pcm_buf_entry: expected=%x ret=%x\n",
208 audio
->in
[audio
->fill_next
].addr
,
209 payload
[1 + index
* 2]);
213 if (audio
->in
[audio
->fill_next
].used
== 0) {
214 audqcelp_buffer_refresh(audio
);
216 dprintk("audqcelp_update_pcm_buf_entry: read cannot keep up\n");
217 audio
->buf_refresh
= 1;
220 spin_unlock_irqrestore(&audio
->dsp_lock
, flags
);
221 wake_up(&audio
->read_wait
);
224 static void audplay_dsp_event(void *data
, unsigned id
, size_t len
,
225 void (*getevent
) (void *ptr
, size_t len
))
227 struct audio
*audio
= data
;
229 getevent(msg
, sizeof(msg
));
231 dprintk("audplay_dsp_event: msg_id=%x\n", id
);
234 case AUDPLAY_MSG_DEC_NEEDS_DATA
:
235 audqcelp_send_data(audio
, 1);
238 case AUDPLAY_MSG_BUFFER_UPDATE
:
239 audqcelp_update_pcm_buf_entry(audio
, msg
);
243 pr_err("unexpected message from decoder \n");
247 static void audqcelp_dsp_event(void *private, unsigned id
, uint16_t *msg
)
249 struct audio
*audio
= private;
252 case AUDPP_MSG_STATUS_MSG
:{
253 unsigned status
= msg
[1];
256 case AUDPP_DEC_STATUS_SLEEP
:
257 dprintk("decoder status: sleep \n");
260 case AUDPP_DEC_STATUS_INIT
:
261 dprintk("decoder status: init \n");
262 audpp_cmd_cfg_routing_mode(audio
);
265 case AUDPP_DEC_STATUS_CFG
:
266 dprintk("decoder status: cfg \n");
268 case AUDPP_DEC_STATUS_PLAY
:
269 dprintk("decoder status: play \n");
270 if (audio
->pcm_feedback
) {
271 audqcelp_config_hostpcm(audio
);
272 audqcelp_buffer_refresh(audio
);
276 pr_err("unknown decoder status \n");
280 case AUDPP_MSG_CFG_MSG
:
281 if (msg
[0] == AUDPP_MSG_ENA_ENA
) {
282 dprintk("audqcelp_dsp_event: CFG_MSG ENABLE\n");
283 auddec_dsp_config(audio
, 1);
284 audio
->out_needed
= 0;
286 audpp_set_volume_and_pan(audio
->dec_id
, audio
->volume
,
288 audpp_avsync(audio
->dec_id
, 22050);
289 } else if (msg
[0] == AUDPP_MSG_ENA_DIS
) {
290 dprintk("audqcelp_dsp_event: CFG_MSG DISABLE\n");
291 audpp_avsync(audio
->dec_id
, 0);
294 pr_err("audqcelp_dsp_event: CFG_MSG %d?\n", msg
[0]);
297 case AUDPP_MSG_ROUTING_ACK
:
298 dprintk("audqcelp_dsp_event: ROUTING_ACK mode=%d\n", msg
[1]);
299 audpp_cmd_cfg_adec_params(audio
);
302 pr_err("audqcelp_dsp_event: UNKNOWN (%d)\n", id
);
307 struct msm_adsp_ops audplay_adsp_ops_qcelp
= {
308 .event
= audplay_dsp_event
,
311 #define audplay_send_queue0(audio, cmd, len) \
312 msm_adsp_write(audio->audplay, QDSP_uPAudPlay0BitStreamCtrlQueue, \
315 static int auddec_dsp_config(struct audio
*audio
, int enable
)
317 audpp_cmd_cfg_dec_type cmd
;
319 memset(&cmd
, 0, sizeof(cmd
));
320 cmd
.cmd_id
= AUDPP_CMD_CFG_DEC_TYPE
;
322 cmd
.dec0_cfg
= AUDPP_CMD_UPDATDE_CFG_DEC
|
323 AUDPP_CMD_ENA_DEC_V
| AUDDEC_DEC_QCELP
;
325 cmd
.dec0_cfg
= AUDPP_CMD_UPDATDE_CFG_DEC
| AUDPP_CMD_DIS_DEC_V
;
327 return audpp_send_queue1(&cmd
, sizeof(cmd
));
330 static void audpp_cmd_cfg_adec_params(struct audio
*audio
)
332 struct audpp_cmd_cfg_adec_params_v13k cmd
;
334 memset(&cmd
, 0, sizeof(cmd
));
335 cmd
.common
.cmd_id
= AUDPP_CMD_CFG_ADEC_PARAMS
;
336 cmd
.common
.length
= AUDPP_CMD_CFG_ADEC_PARAMS_V13K_LEN
;
337 cmd
.common
.dec_id
= audio
->dec_id
;
338 cmd
.common
.input_sampling_frequency
= 8000;
339 cmd
.stereo_cfg
= AUDPP_CMD_PCM_INTF_MONO_V
;
341 audpp_send_queue2(&cmd
, sizeof(cmd
));
344 static void audpp_cmd_cfg_routing_mode(struct audio
*audio
)
346 struct audpp_cmd_routing_mode cmd
;
347 dprintk("audpp_cmd_cfg_routing_mode()\n");
348 memset(&cmd
, 0, sizeof(cmd
));
349 cmd
.cmd_id
= AUDPP_CMD_ROUTING_MODE
;
350 cmd
.object_number
= audio
->dec_id
;
351 if (audio
->pcm_feedback
)
352 cmd
.routing_mode
= ROUTING_MODE_FTRT
;
354 cmd
.routing_mode
= ROUTING_MODE_RT
;
355 audpp_send_queue1(&cmd
, sizeof(cmd
));
358 static int audplay_dsp_send_data_avail(struct audio
*audio
,
359 unsigned idx
, unsigned len
)
361 audplay_cmd_bitstream_data_avail cmd
;
363 cmd
.cmd_id
= AUDPLAY_CMD_BITSTREAM_DATA_AVAIL
;
364 cmd
.decoder_id
= audio
->dec_id
;
365 cmd
.buf_ptr
= audio
->out
[idx
].addr
;
366 cmd
.buf_size
= len
/ 2;
367 cmd
.partition_number
= 0;
368 return audplay_send_queue0(audio
, &cmd
, sizeof(cmd
));
371 static void audqcelp_buffer_refresh(struct audio
*audio
)
373 struct audplay_cmd_buffer_refresh refresh_cmd
;
375 refresh_cmd
.cmd_id
= AUDPLAY_CMD_BUFFER_REFRESH
;
376 refresh_cmd
.num_buffers
= 1;
377 refresh_cmd
.buf0_address
= audio
->in
[audio
->fill_next
].addr
;
378 refresh_cmd
.buf0_length
= audio
->in
[audio
->fill_next
].size
;
379 refresh_cmd
.buf_read_count
= 0;
380 dprintk("audplay_buffer_fresh: buf0_addr=%x buf0_len=%d\n",
381 refresh_cmd
.buf0_address
, refresh_cmd
.buf0_length
);
383 (void)audplay_send_queue0(audio
, &refresh_cmd
, sizeof(refresh_cmd
));
386 static void audqcelp_config_hostpcm(struct audio
*audio
)
388 struct audplay_cmd_hpcm_buf_cfg cfg_cmd
;
390 dprintk("audqcelp_config_hostpcm()\n");
391 cfg_cmd
.cmd_id
= AUDPLAY_CMD_HPCM_BUF_CFG
;
392 cfg_cmd
.max_buffers
= audio
->pcm_buf_count
;
393 cfg_cmd
.byte_swap
= 0;
394 cfg_cmd
.hostpcm_config
= (0x8000) | (0x4000);
395 cfg_cmd
.feedback_frequency
= 1;
396 cfg_cmd
.partition_number
= 0;
398 (void)audplay_send_queue0(audio
, &cfg_cmd
, sizeof(cfg_cmd
));
401 static void audqcelp_send_data(struct audio
*audio
, unsigned needed
)
403 struct buffer
*frame
;
406 spin_lock_irqsave(&audio
->dsp_lock
, flags
);
411 /* We were called from the callback because the DSP
412 * requested more data. Note that the DSP does want
413 * more data, and if a buffer was in-flight, mark it
414 * as available (since the DSP must now be done with
417 audio
->out_needed
= 1;
418 frame
= audio
->out
+ audio
->out_tail
;
419 if (frame
->used
== 0xffffffff) {
420 dprintk("frame %d free\n", audio
->out_tail
);
422 audio
->out_tail
^= 1;
423 wake_up(&audio
->write_wait
);
427 if (audio
->out_needed
) {
428 /* If the DSP currently wants data and we have a
429 * buffer available, we will send it and reset
430 * the needed flag. We'll mark the buffer as in-flight
431 * so that it won't be recycled until the next buffer
435 frame
= audio
->out
+ audio
->out_tail
;
437 BUG_ON(frame
->used
== 0xffffffff);
438 dprintk("frame %d busy\n", audio
->out_tail
);
439 audplay_dsp_send_data_avail(audio
, audio
->out_tail
,
441 frame
->used
= 0xffffffff;
442 audio
->out_needed
= 0;
446 spin_unlock_irqrestore(&audio
->dsp_lock
, flags
);
449 /* ------------------- device --------------------- */
451 static void audqcelp_flush(struct audio
*audio
)
453 audio
->out
[0].used
= 0;
454 audio
->out
[1].used
= 0;
460 static void audqcelp_flush_pcm_buf(struct audio
*audio
)
464 for (index
= 0; index
< PCM_BUF_MAX_COUNT
; index
++)
465 audio
->in
[index
].used
= 0;
467 audio
->read_next
= 0;
468 audio
->fill_next
= 0;
471 static long audqcelp_ioctl(struct file
*file
, unsigned int cmd
,
474 struct audio
*audio
= file
->private_data
;
477 dprintk("audqcelp_ioctl() cmd = %d\n", cmd
);
479 if (cmd
== AUDIO_GET_STATS
) {
480 struct msm_audio_stats stats
;
481 stats
.byte_count
= audpp_avsync_byte_count(audio
->dec_id
);
482 stats
.sample_count
= audpp_avsync_sample_count(audio
->dec_id
);
483 if (copy_to_user((void *)arg
, &stats
, sizeof(stats
)))
487 if (cmd
== AUDIO_SET_VOLUME
) {
489 spin_lock_irqsave(&audio
->dsp_lock
, flags
);
492 audpp_set_volume_and_pan(audio
->dec_id
, arg
, 0);
493 spin_unlock_irqrestore(&audio
->dsp_lock
, flags
);
496 mutex_lock(&audio
->lock
);
499 rc
= audqcelp_enable(audio
);
502 rc
= audqcelp_disable(audio
);
506 if (audio
->stopped
) {
507 /* Make sure we're stopped and we wake any threads
508 * that might be blocked holding the write_lock.
509 * While audio->stopped write threads will always
512 wake_up(&audio
->write_wait
);
513 mutex_lock(&audio
->write_lock
);
514 audqcelp_flush(audio
);
515 mutex_unlock(&audio
->write_lock
);
516 wake_up(&audio
->read_wait
);
517 mutex_lock(&audio
->read_lock
);
518 audqcelp_flush_pcm_buf(audio
);
519 mutex_unlock(&audio
->read_lock
);
523 case AUDIO_SET_CONFIG
:
524 dprintk("AUDIO_SET_CONFIG not applicable \n");
526 case AUDIO_GET_CONFIG
:{
527 struct msm_audio_config config
;
528 config
.buffer_size
= BUFSZ
;
529 config
.buffer_count
= BUF_COUNT
;
530 config
.sample_rate
= 8000;
531 config
.channel_count
= 1;
532 config
.unused
[0] = 0;
533 config
.unused
[1] = 0;
534 config
.unused
[2] = 0;
535 config
.unused
[3] = 0;
536 if (copy_to_user((void *)arg
, &config
,
544 case AUDIO_GET_PCM_CONFIG
:{
545 struct msm_audio_pcm_config config
;
547 config
.pcm_feedback
= 0;
548 config
.buffer_count
= PCM_BUF_MAX_COUNT
;
549 config
.buffer_size
= PCM_BUFSZ_MIN
;
550 if (copy_to_user((void *)arg
, &config
,
557 case AUDIO_SET_PCM_CONFIG
:{
558 struct msm_audio_pcm_config config
;
560 if (copy_from_user(&config
, (void *)arg
,
565 if ((config
.buffer_count
> PCM_BUF_MAX_COUNT
) ||
566 (config
.buffer_count
== 1))
567 config
.buffer_count
= PCM_BUF_MAX_COUNT
;
569 if (config
.buffer_size
< PCM_BUFSZ_MIN
)
570 config
.buffer_size
= PCM_BUFSZ_MIN
;
572 /* Check if pcm feedback is required */
573 if ((config
.pcm_feedback
) && (!audio
->read_data
)) {
575 "audqcelp_ioctl: allocate PCM buf %d\n",
576 config
.buffer_count
* config
.buffer_size
);
577 audio
->read_data
= dma_alloc_coherent(NULL
,
578 config
.buffer_size
* config
.buffer_count
,
579 &audio
->read_phys
, GFP_KERNEL
);
580 if (!audio
->read_data
) {
582 "audqcelp_ioctl: no mem for pcm buf\n"
589 audio
->pcm_feedback
= 1;
590 audio
->buf_refresh
= 0;
591 audio
->pcm_buf_count
=
593 audio
->read_next
= 0;
594 audio
->fill_next
= 0;
597 index
< config
.buffer_count
; index
++) {
598 audio
->in
[index
].data
=
599 audio
->read_data
+ offset
;
600 audio
->in
[index
].addr
=
601 audio
->read_phys
+ offset
;
602 audio
->in
[index
].size
=
604 audio
->in
[index
].used
= 0;
605 offset
+= config
.buffer_size
;
615 dprintk("%s: AUDIO_PAUSE %ld\n", __func__
, arg
);
616 rc
= audpp_pause(audio
->dec_id
, (int) arg
);
621 mutex_unlock(&audio
->lock
);
625 static ssize_t
audqcelp_read(struct file
*file
, char __user
*buf
, size_t count
,
628 struct audio
*audio
= file
->private_data
;
629 const char __user
*start
= buf
;
632 if (!audio
->pcm_feedback
)
633 return 0; /* PCM feedback is not enabled. Nothing to read */
635 mutex_lock(&audio
->read_lock
);
636 dprintk("audqcelp_read() %d \n", count
);
638 rc
= wait_event_interruptible(audio
->read_wait
,
639 (audio
->in
[audio
->read_next
].used
> 0) ||
644 if (audio
->stopped
) {
649 if (count
< audio
->in
[audio
->read_next
].used
) {
650 /* Read must happen in frame boundary. Since driver does
651 not know frame size, read count must be greater or equal
652 to size of PCM samples */
653 dprintk("audqcelp_read:read stop - partial frame\n");
656 dprintk("audqcelp_read: read from in[%d]\n",
658 if (copy_to_user(buf
,
659 audio
->in
[audio
->read_next
].data
,
660 audio
->in
[audio
->read_next
].used
)) {
661 pr_err("audqcelp_read: invalid addr %x \n",
666 count
-= audio
->in
[audio
->read_next
].used
;
667 buf
+= audio
->in
[audio
->read_next
].used
;
668 audio
->in
[audio
->read_next
].used
= 0;
669 if ((++audio
->read_next
) == audio
->pcm_buf_count
)
670 audio
->read_next
= 0;
674 if (audio
->buf_refresh
) {
675 audio
->buf_refresh
= 0;
676 dprintk("audqcelp_read: kick start pcm feedback again\n");
677 audqcelp_buffer_refresh(audio
);
680 mutex_unlock(&audio
->read_lock
);
685 dprintk("audqcelp_read: read %d bytes\n", rc
);
689 static ssize_t
audqcelp_write(struct file
*file
, const char __user
*buf
,
690 size_t count
, loff_t
*pos
)
692 struct audio
*audio
= file
->private_data
;
693 const char __user
*start
= buf
;
694 struct buffer
*frame
;
700 dprintk("audqcelp_write() \n");
701 mutex_lock(&audio
->write_lock
);
703 frame
= audio
->out
+ audio
->out_head
;
704 rc
= wait_event_interruptible(audio
->write_wait
,
706 || (audio
->stopped
));
707 dprintk("audqcelp_write() buffer available\n");
710 if (audio
->stopped
) {
714 xfer
= (count
> frame
->size
) ? frame
->size
: count
;
715 if (copy_from_user(frame
->data
, buf
, xfer
)) {
721 audio
->out_head
^= 1;
725 audqcelp_send_data(audio
, 0);
728 mutex_unlock(&audio
->write_lock
);
734 static int audqcelp_release(struct inode
*inode
, struct file
*file
)
736 struct audio
*audio
= file
->private_data
;
738 dprintk("audqcelp_release()\n");
740 mutex_lock(&audio
->lock
);
741 audqcelp_disable(audio
);
742 audqcelp_flush(audio
);
743 audqcelp_flush_pcm_buf(audio
);
744 msm_adsp_put(audio
->audplay
);
745 audio
->audplay
= NULL
;
748 dma_free_coherent(NULL
, DMASZ
, audio
->data
, audio
->phys
);
750 if (audio
->read_data
) {
751 dma_free_coherent(NULL
,
752 audio
->in
[0].size
* audio
->pcm_buf_count
,
753 audio
->read_data
, audio
->read_phys
);
754 audio
->read_data
= NULL
;
756 audio
->pcm_feedback
= 0;
757 mutex_unlock(&audio
->lock
);
761 static int audqcelp_open(struct inode
*inode
, struct file
*file
)
763 struct audio
*audio
= &the_qcelp_audio
;
766 mutex_lock(&audio
->lock
);
769 pr_err("audio: busy\n");
774 audio
->data
= dma_alloc_coherent(NULL
, DMASZ
,
775 &audio
->phys
, GFP_KERNEL
);
777 pr_err("audio: could not allocate DMA buffers\n");
782 rc
= audmgr_open(&audio
->audmgr
);
786 rc
= msm_adsp_get("AUDPLAY0TASK", &audio
->audplay
,
787 &audplay_adsp_ops_qcelp
, audio
);
789 pr_err("audio: failed to get audplay0 dsp module\n");
790 audmgr_close(&audio
->audmgr
);
796 audio
->out
[0].data
= audio
->data
+ 0;
797 audio
->out
[0].addr
= audio
->phys
+ 0;
798 audio
->out
[0].size
= BUFSZ
;
800 audio
->out
[1].data
= audio
->data
+ BUFSZ
;
801 audio
->out
[1].addr
= audio
->phys
+ BUFSZ
;
802 audio
->out
[1].size
= BUFSZ
;
804 audio
->volume
= 0x2000; /* Q13 1.0 */
806 audqcelp_flush(audio
);
808 file
->private_data
= audio
;
812 mutex_unlock(&audio
->lock
);
815 dma_free_coherent(NULL
, DMASZ
, audio
->data
, audio
->phys
);
816 mutex_unlock(&audio
->lock
);
820 static struct file_operations audio_qcelp_fops
= {
821 .owner
= THIS_MODULE
,
822 .open
= audqcelp_open
,
823 .release
= audqcelp_release
,
824 .read
= audqcelp_read
,
825 .write
= audqcelp_write
,
826 .unlocked_ioctl
= audqcelp_ioctl
,
829 struct miscdevice audio_qcelp_misc
= {
830 .minor
= MISC_DYNAMIC_MINOR
,
832 .fops
= &audio_qcelp_fops
,
835 static int __init
audqcelp_init(void)
837 mutex_init(&the_qcelp_audio
.lock
);
838 mutex_init(&the_qcelp_audio
.write_lock
);
839 mutex_init(&the_qcelp_audio
.read_lock
);
840 spin_lock_init(&the_qcelp_audio
.dsp_lock
);
841 init_waitqueue_head(&the_qcelp_audio
.write_wait
);
842 init_waitqueue_head(&the_qcelp_audio
.read_wait
);
843 the_qcelp_audio
.read_data
= NULL
;
844 return misc_register(&audio_qcelp_misc
);
847 static void __exit
audqcelp_exit(void)
849 misc_deregister(&audio_qcelp_misc
);
852 module_init(audqcelp_init
);
853 module_exit(audqcelp_exit
);
855 MODULE_DESCRIPTION("MSM QCELP 13K driver");
856 MODULE_LICENSE("GPL v2");
857 MODULE_AUTHOR("QUALCOMM");