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>
33 #include <asm/ioctls.h>
34 #include <mach/msm_adsp.h>
35 #include <linux/msm_audio.h>
36 #include <mach/qdsp5/qdsp5audppcmdi.h>
37 #include <mach/qdsp5/qdsp5audppmsg.h>
38 #include <mach/qdsp5/qdsp5audplaycmdi.h>
39 #include <mach/qdsp5/qdsp5audplaymsg.h>
42 /* for queue ids - should be relative to module number*/
46 #define dprintk(format, arg...) \
47 printk(KERN_DEBUG format, ## arg)
49 #define dprintk(format, arg...) do {} while (0)
52 #define BUFSZ 1080 /* QCELP 13K Hold 600ms packet data = 36 * 30 */
54 #define DMASZ (BUFSZ * BUF_COUNT)
56 #define PCM_BUFSZ_MIN 1600 /* 100ms worth of data */
57 #define PCM_BUF_MAX_COUNT 5
59 #define AUDDEC_DEC_QCELP 9
61 #define ROUTING_MODE_FTRT 1
62 #define ROUTING_MODE_RT 2
63 /* Decoder status received from AUDPPTASK */
64 #define AUDPP_DEC_STATUS_SLEEP 0
65 #define AUDPP_DEC_STATUS_INIT 1
66 #define AUDPP_DEC_STATUS_CFG 2
67 #define AUDPP_DEC_STATUS_PLAY 3
72 unsigned used
; /* Input usage actual DSP produced PCM size */
77 struct buffer out
[BUF_COUNT
];
83 uint8_t out_needed
; /* number of buffers the dsp is waiting for */
86 struct mutex write_lock
;
87 wait_queue_head_t write_wait
;
89 /* Host PCM section - START */
90 struct buffer in
[PCM_BUF_MAX_COUNT
];
91 struct mutex read_lock
;
92 wait_queue_head_t read_wait
; /* Wait queue for read */
93 char *read_data
; /* pointer to reader buffer */
94 dma_addr_t read_phys
; /* physical address of reader buffer */
95 uint8_t read_next
; /* index to input buffers to be read next */
96 uint8_t fill_next
; /* index to buffer that DSP should be filling */
97 uint8_t pcm_buf_count
; /* number of pcm buffer allocated */
98 /* Host PCM section - END */
100 struct msm_adsp_module
*audplay
;
102 struct audmgr audmgr
;
104 /* data allocated for various buffers */
111 uint8_t stopped
:1; /* set when stopped, cleared on flush */
112 uint8_t pcm_feedback
:1; /* set when non-tunnel mode */
113 uint8_t buf_refresh
:1;
120 static struct audio the_qcelp_audio
;
122 static int auddec_dsp_config(struct audio
*audio
, int enable
);
123 static void audpp_cmd_cfg_adec_params(struct audio
*audio
);
124 static void audpp_cmd_cfg_routing_mode(struct audio
*audio
);
125 static void audqcelp_send_data(struct audio
*audio
, unsigned needed
);
126 static void audqcelp_config_hostpcm(struct audio
*audio
);
127 static void audqcelp_buffer_refresh(struct audio
*audio
);
128 static void audqcelp_dsp_event(void *private, unsigned id
, uint16_t *msg
);
130 /* must be called with audio->lock held */
131 static int audqcelp_enable(struct audio
*audio
)
133 struct audmgr_config cfg
;
136 dprintk("audqcelp_enable()\n");
142 audio
->out_needed
= 0;
144 cfg
.tx_rate
= RPC_AUD_DEF_SAMPLE_RATE_NONE
;
145 cfg
.rx_rate
= RPC_AUD_DEF_SAMPLE_RATE_48000
;
146 cfg
.def_method
= RPC_AUD_DEF_METHOD_PLAYBACK
;
147 cfg
.codec
= RPC_AUD_DEF_CODEC_13K
;
148 cfg
.snd_method
= RPC_SND_METHOD_MIDI
;
150 rc
= audmgr_enable(&audio
->audmgr
, &cfg
);
154 if (msm_adsp_enable(audio
->audplay
)) {
155 pr_err("audio: msm_adsp_enable(audplay) failed\n");
156 audmgr_disable(&audio
->audmgr
);
160 if (audpp_enable(audio
->dec_id
, audqcelp_dsp_event
, audio
)) {
161 pr_err("audio: audpp_enable() failed\n");
162 msm_adsp_disable(audio
->audplay
);
163 audmgr_disable(&audio
->audmgr
);
170 /* must be called with audio->lock held */
171 static int audqcelp_disable(struct audio
*audio
)
173 dprintk("audqcelp_disable()\n");
174 if (audio
->enabled
) {
176 auddec_dsp_config(audio
, 0);
177 wake_up(&audio
->write_wait
);
178 wake_up(&audio
->read_wait
);
179 msm_adsp_disable(audio
->audplay
);
180 audpp_disable(audio
->dec_id
, audio
);
181 audmgr_disable(&audio
->audmgr
);
182 audio
->out_needed
= 0;
187 /* ------------------- dsp --------------------- */
188 static void audqcelp_update_pcm_buf_entry(struct audio
*audio
,
194 spin_lock_irqsave(&audio
->dsp_lock
, flags
);
195 for (index
= 0; index
< payload
[1]; index
++) {
196 if (audio
->in
[audio
->fill_next
].addr
==
197 payload
[2 + index
* 2]) {
198 dprintk("audqcelp_update_pcm_buf_entry: in[%d] ready\n",
200 audio
->in
[audio
->fill_next
].used
=
201 payload
[3 + index
* 2];
202 if ((++audio
->fill_next
) == audio
->pcm_buf_count
)
203 audio
->fill_next
= 0;
206 "audqcelp_update_pcm_buf_entry: expected=%x ret=%x\n",
207 audio
->in
[audio
->fill_next
].addr
,
208 payload
[1 + index
* 2]);
212 if (audio
->in
[audio
->fill_next
].used
== 0) {
213 audqcelp_buffer_refresh(audio
);
215 dprintk("audqcelp_update_pcm_buf_entry: read cannot keep up\n");
216 audio
->buf_refresh
= 1;
219 spin_unlock_irqrestore(&audio
->dsp_lock
, flags
);
220 wake_up(&audio
->read_wait
);
223 static void audplay_dsp_event(void *data
, unsigned id
, size_t len
,
224 void (*getevent
) (void *ptr
, size_t len
))
226 struct audio
*audio
= data
;
228 getevent(msg
, sizeof(msg
));
230 dprintk("audplay_dsp_event: msg_id=%x\n", id
);
233 case AUDPLAY_MSG_DEC_NEEDS_DATA
:
234 audqcelp_send_data(audio
, 1);
237 case AUDPLAY_MSG_BUFFER_UPDATE
:
238 audqcelp_update_pcm_buf_entry(audio
, msg
);
242 pr_err("unexpected message from decoder \n");
246 static void audqcelp_dsp_event(void *private, unsigned id
, uint16_t *msg
)
248 struct audio
*audio
= private;
251 case AUDPP_MSG_STATUS_MSG
:{
252 unsigned status
= msg
[1];
255 case AUDPP_DEC_STATUS_SLEEP
:
256 dprintk("decoder status: sleep \n");
259 case AUDPP_DEC_STATUS_INIT
:
260 dprintk("decoder status: init \n");
261 audpp_cmd_cfg_routing_mode(audio
);
264 case AUDPP_DEC_STATUS_CFG
:
265 dprintk("decoder status: cfg \n");
267 case AUDPP_DEC_STATUS_PLAY
:
268 dprintk("decoder status: play \n");
269 if (audio
->pcm_feedback
) {
270 audqcelp_config_hostpcm(audio
);
271 audqcelp_buffer_refresh(audio
);
275 pr_err("unknown decoder status \n");
279 case AUDPP_MSG_CFG_MSG
:
280 if (msg
[0] == AUDPP_MSG_ENA_ENA
) {
281 dprintk("audqcelp_dsp_event: CFG_MSG ENABLE\n");
282 auddec_dsp_config(audio
, 1);
283 audio
->out_needed
= 0;
285 audpp_set_volume_and_pan(audio
->dec_id
, audio
->volume
,
287 audpp_avsync(audio
->dec_id
, 22050);
288 } else if (msg
[0] == AUDPP_MSG_ENA_DIS
) {
289 dprintk("audqcelp_dsp_event: CFG_MSG DISABLE\n");
290 audpp_avsync(audio
->dec_id
, 0);
293 pr_err("audqcelp_dsp_event: CFG_MSG %d?\n", msg
[0]);
296 case AUDPP_MSG_ROUTING_ACK
:
297 dprintk("audqcelp_dsp_event: ROUTING_ACK mode=%d\n", msg
[1]);
298 audpp_cmd_cfg_adec_params(audio
);
301 pr_err("audqcelp_dsp_event: UNKNOWN (%d)\n", id
);
306 struct msm_adsp_ops audplay_adsp_ops_qcelp
= {
307 .event
= audplay_dsp_event
,
310 #define audplay_send_queue0(audio, cmd, len) \
311 msm_adsp_write(audio->audplay, QDSP_uPAudPlay0BitStreamCtrlQueue, \
314 static int auddec_dsp_config(struct audio
*audio
, int enable
)
316 audpp_cmd_cfg_dec_type cmd
;
318 memset(&cmd
, 0, sizeof(cmd
));
319 cmd
.cmd_id
= AUDPP_CMD_CFG_DEC_TYPE
;
321 cmd
.dec0_cfg
= AUDPP_CMD_UPDATDE_CFG_DEC
|
322 AUDPP_CMD_ENA_DEC_V
| AUDDEC_DEC_QCELP
;
324 cmd
.dec0_cfg
= AUDPP_CMD_UPDATDE_CFG_DEC
| AUDPP_CMD_DIS_DEC_V
;
326 return audpp_send_queue1(&cmd
, sizeof(cmd
));
329 static void audpp_cmd_cfg_adec_params(struct audio
*audio
)
331 struct audpp_cmd_cfg_adec_params_v13k cmd
;
333 memset(&cmd
, 0, sizeof(cmd
));
334 cmd
.common
.cmd_id
= AUDPP_CMD_CFG_ADEC_PARAMS
;
335 cmd
.common
.length
= AUDPP_CMD_CFG_ADEC_PARAMS_V13K_LEN
;
336 cmd
.common
.dec_id
= audio
->dec_id
;
337 cmd
.common
.input_sampling_frequency
= 8000;
338 cmd
.stereo_cfg
= AUDPP_CMD_PCM_INTF_MONO_V
;
340 audpp_send_queue2(&cmd
, sizeof(cmd
));
343 static void audpp_cmd_cfg_routing_mode(struct audio
*audio
)
345 struct audpp_cmd_routing_mode cmd
;
346 dprintk("audpp_cmd_cfg_routing_mode()\n");
347 memset(&cmd
, 0, sizeof(cmd
));
348 cmd
.cmd_id
= AUDPP_CMD_ROUTING_MODE
;
349 cmd
.object_number
= audio
->dec_id
;
350 if (audio
->pcm_feedback
)
351 cmd
.routing_mode
= ROUTING_MODE_FTRT
;
353 cmd
.routing_mode
= ROUTING_MODE_RT
;
354 audpp_send_queue1(&cmd
, sizeof(cmd
));
357 static int audplay_dsp_send_data_avail(struct audio
*audio
,
358 unsigned idx
, unsigned len
)
360 audplay_cmd_bitstream_data_avail cmd
;
362 cmd
.cmd_id
= AUDPLAY_CMD_BITSTREAM_DATA_AVAIL
;
363 cmd
.decoder_id
= audio
->dec_id
;
364 cmd
.buf_ptr
= audio
->out
[idx
].addr
;
365 cmd
.buf_size
= len
/ 2;
366 cmd
.partition_number
= 0;
367 return audplay_send_queue0(audio
, &cmd
, sizeof(cmd
));
370 static void audqcelp_buffer_refresh(struct audio
*audio
)
372 struct audplay_cmd_buffer_refresh refresh_cmd
;
374 refresh_cmd
.cmd_id
= AUDPLAY_CMD_BUFFER_REFRESH
;
375 refresh_cmd
.num_buffers
= 1;
376 refresh_cmd
.buf0_address
= audio
->in
[audio
->fill_next
].addr
;
377 refresh_cmd
.buf0_length
= audio
->in
[audio
->fill_next
].size
;
378 refresh_cmd
.buf_read_count
= 0;
379 dprintk("audplay_buffer_fresh: buf0_addr=%x buf0_len=%d\n",
380 refresh_cmd
.buf0_address
, refresh_cmd
.buf0_length
);
382 (void)audplay_send_queue0(audio
, &refresh_cmd
, sizeof(refresh_cmd
));
385 static void audqcelp_config_hostpcm(struct audio
*audio
)
387 struct audplay_cmd_hpcm_buf_cfg cfg_cmd
;
389 dprintk("audqcelp_config_hostpcm()\n");
390 cfg_cmd
.cmd_id
= AUDPLAY_CMD_HPCM_BUF_CFG
;
391 cfg_cmd
.max_buffers
= audio
->pcm_buf_count
;
392 cfg_cmd
.byte_swap
= 0;
393 cfg_cmd
.hostpcm_config
= (0x8000) | (0x4000);
394 cfg_cmd
.feedback_frequency
= 1;
395 cfg_cmd
.partition_number
= 0;
397 (void)audplay_send_queue0(audio
, &cfg_cmd
, sizeof(cfg_cmd
));
400 static void audqcelp_send_data(struct audio
*audio
, unsigned needed
)
402 struct buffer
*frame
;
405 spin_lock_irqsave(&audio
->dsp_lock
, flags
);
410 /* We were called from the callback because the DSP
411 * requested more data. Note that the DSP does want
412 * more data, and if a buffer was in-flight, mark it
413 * as available (since the DSP must now be done with
416 audio
->out_needed
= 1;
417 frame
= audio
->out
+ audio
->out_tail
;
418 if (frame
->used
== 0xffffffff) {
419 dprintk("frame %d free\n", audio
->out_tail
);
421 audio
->out_tail
^= 1;
422 wake_up(&audio
->write_wait
);
426 if (audio
->out_needed
) {
427 /* If the DSP currently wants data and we have a
428 * buffer available, we will send it and reset
429 * the needed flag. We'll mark the buffer as in-flight
430 * so that it won't be recycled until the next buffer
434 frame
= audio
->out
+ audio
->out_tail
;
436 BUG_ON(frame
->used
== 0xffffffff);
437 dprintk("frame %d busy\n", audio
->out_tail
);
438 audplay_dsp_send_data_avail(audio
, audio
->out_tail
,
440 frame
->used
= 0xffffffff;
441 audio
->out_needed
= 0;
445 spin_unlock_irqrestore(&audio
->dsp_lock
, flags
);
448 /* ------------------- device --------------------- */
450 static void audqcelp_flush(struct audio
*audio
)
452 audio
->out
[0].used
= 0;
453 audio
->out
[1].used
= 0;
459 static void audqcelp_flush_pcm_buf(struct audio
*audio
)
463 for (index
= 0; index
< PCM_BUF_MAX_COUNT
; index
++)
464 audio
->in
[index
].used
= 0;
466 audio
->read_next
= 0;
467 audio
->fill_next
= 0;
470 static long audqcelp_ioctl(struct file
*file
, unsigned int cmd
,
473 struct audio
*audio
= file
->private_data
;
476 dprintk("audqcelp_ioctl() cmd = %d\n", cmd
);
478 if (cmd
== AUDIO_GET_STATS
) {
479 struct msm_audio_stats stats
;
480 stats
.byte_count
= audpp_avsync_byte_count(audio
->dec_id
);
481 stats
.sample_count
= audpp_avsync_sample_count(audio
->dec_id
);
482 if (copy_to_user((void *)arg
, &stats
, sizeof(stats
)))
486 if (cmd
== AUDIO_SET_VOLUME
) {
488 spin_lock_irqsave(&audio
->dsp_lock
, flags
);
491 audpp_set_volume_and_pan(audio
->dec_id
, arg
, 0);
492 spin_unlock_irqrestore(&audio
->dsp_lock
, flags
);
495 mutex_lock(&audio
->lock
);
498 rc
= audqcelp_enable(audio
);
501 rc
= audqcelp_disable(audio
);
505 if (audio
->stopped
) {
506 /* Make sure we're stopped and we wake any threads
507 * that might be blocked holding the write_lock.
508 * While audio->stopped write threads will always
511 wake_up(&audio
->write_wait
);
512 mutex_lock(&audio
->write_lock
);
513 audqcelp_flush(audio
);
514 mutex_unlock(&audio
->write_lock
);
515 wake_up(&audio
->read_wait
);
516 mutex_lock(&audio
->read_lock
);
517 audqcelp_flush_pcm_buf(audio
);
518 mutex_unlock(&audio
->read_lock
);
522 case AUDIO_SET_CONFIG
:
523 dprintk("AUDIO_SET_CONFIG not applicable \n");
525 case AUDIO_GET_CONFIG
:{
526 struct msm_audio_config config
;
527 config
.buffer_size
= BUFSZ
;
528 config
.buffer_count
= BUF_COUNT
;
529 config
.sample_rate
= 8000;
530 config
.channel_count
= 1;
531 config
.unused
[0] = 0;
532 config
.unused
[1] = 0;
533 config
.unused
[2] = 0;
534 config
.unused
[3] = 0;
535 if (copy_to_user((void *)arg
, &config
,
543 case AUDIO_GET_PCM_CONFIG
:{
544 struct msm_audio_pcm_config config
;
546 config
.pcm_feedback
= 0;
547 config
.buffer_count
= PCM_BUF_MAX_COUNT
;
548 config
.buffer_size
= PCM_BUFSZ_MIN
;
549 if (copy_to_user((void *)arg
, &config
,
556 case AUDIO_SET_PCM_CONFIG
:{
557 struct msm_audio_pcm_config config
;
559 if (copy_from_user(&config
, (void *)arg
,
564 if ((config
.buffer_count
> PCM_BUF_MAX_COUNT
) ||
565 (config
.buffer_count
== 1))
566 config
.buffer_count
= PCM_BUF_MAX_COUNT
;
568 if (config
.buffer_size
< PCM_BUFSZ_MIN
)
569 config
.buffer_size
= PCM_BUFSZ_MIN
;
571 /* Check if pcm feedback is required */
572 if ((config
.pcm_feedback
) && (!audio
->read_data
)) {
574 "audqcelp_ioctl: allocate PCM buf %d\n",
575 config
.buffer_count
* config
.buffer_size
);
576 audio
->read_data
= dma_alloc_coherent(NULL
,
577 config
.buffer_size
* config
.buffer_count
,
578 &audio
->read_phys
, GFP_KERNEL
);
579 if (!audio
->read_data
) {
581 "audqcelp_ioctl: no mem for pcm buf\n"
588 audio
->pcm_feedback
= 1;
589 audio
->buf_refresh
= 0;
590 audio
->pcm_buf_count
=
592 audio
->read_next
= 0;
593 audio
->fill_next
= 0;
596 index
< config
.buffer_count
; index
++) {
597 audio
->in
[index
].data
=
598 audio
->read_data
+ offset
;
599 audio
->in
[index
].addr
=
600 audio
->read_phys
+ offset
;
601 audio
->in
[index
].size
=
603 audio
->in
[index
].used
= 0;
604 offset
+= config
.buffer_size
;
614 dprintk("%s: AUDIO_PAUSE %ld\n", __func__
, arg
);
615 rc
= audpp_pause(audio
->dec_id
, (int) arg
);
620 mutex_unlock(&audio
->lock
);
624 static ssize_t
audqcelp_read(struct file
*file
, char __user
*buf
, size_t count
,
627 struct audio
*audio
= file
->private_data
;
628 const char __user
*start
= buf
;
631 if (!audio
->pcm_feedback
)
632 return 0; /* PCM feedback is not enabled. Nothing to read */
634 mutex_lock(&audio
->read_lock
);
635 dprintk("audqcelp_read() %d \n", count
);
637 rc
= wait_event_interruptible(audio
->read_wait
,
638 (audio
->in
[audio
->read_next
].used
> 0) ||
643 if (audio
->stopped
) {
648 if (count
< audio
->in
[audio
->read_next
].used
) {
649 /* Read must happen in frame boundary. Since driver does
650 not know frame size, read count must be greater or equal
651 to size of PCM samples */
652 dprintk("audqcelp_read:read stop - partial frame\n");
655 dprintk("audqcelp_read: read from in[%d]\n",
657 if (copy_to_user(buf
,
658 audio
->in
[audio
->read_next
].data
,
659 audio
->in
[audio
->read_next
].used
)) {
660 pr_err("audqcelp_read: invalid addr %x \n",
665 count
-= audio
->in
[audio
->read_next
].used
;
666 buf
+= audio
->in
[audio
->read_next
].used
;
667 audio
->in
[audio
->read_next
].used
= 0;
668 if ((++audio
->read_next
) == audio
->pcm_buf_count
)
669 audio
->read_next
= 0;
673 if (audio
->buf_refresh
) {
674 audio
->buf_refresh
= 0;
675 dprintk("audqcelp_read: kick start pcm feedback again\n");
676 audqcelp_buffer_refresh(audio
);
679 mutex_unlock(&audio
->read_lock
);
684 dprintk("audqcelp_read: read %d bytes\n", rc
);
688 static ssize_t
audqcelp_write(struct file
*file
, const char __user
*buf
,
689 size_t count
, loff_t
*pos
)
691 struct audio
*audio
= file
->private_data
;
692 const char __user
*start
= buf
;
693 struct buffer
*frame
;
699 dprintk("audqcelp_write() \n");
700 mutex_lock(&audio
->write_lock
);
702 frame
= audio
->out
+ audio
->out_head
;
703 rc
= wait_event_interruptible(audio
->write_wait
,
705 || (audio
->stopped
));
706 dprintk("audqcelp_write() buffer available\n");
709 if (audio
->stopped
) {
713 xfer
= (count
> frame
->size
) ? frame
->size
: count
;
714 if (copy_from_user(frame
->data
, buf
, xfer
)) {
720 audio
->out_head
^= 1;
724 audqcelp_send_data(audio
, 0);
727 mutex_unlock(&audio
->write_lock
);
733 static int audqcelp_release(struct inode
*inode
, struct file
*file
)
735 struct audio
*audio
= file
->private_data
;
737 dprintk("audqcelp_release()\n");
739 mutex_lock(&audio
->lock
);
740 audqcelp_disable(audio
);
741 audqcelp_flush(audio
);
742 audqcelp_flush_pcm_buf(audio
);
743 msm_adsp_put(audio
->audplay
);
744 audio
->audplay
= NULL
;
747 dma_free_coherent(NULL
, DMASZ
, audio
->data
, audio
->phys
);
749 if (audio
->read_data
) {
750 dma_free_coherent(NULL
,
751 audio
->in
[0].size
* audio
->pcm_buf_count
,
752 audio
->read_data
, audio
->read_phys
);
753 audio
->read_data
= NULL
;
755 audio
->pcm_feedback
= 0;
756 mutex_unlock(&audio
->lock
);
760 static int audqcelp_open(struct inode
*inode
, struct file
*file
)
762 struct audio
*audio
= &the_qcelp_audio
;
765 mutex_lock(&audio
->lock
);
768 pr_err("audio: busy\n");
773 audio
->data
= dma_alloc_coherent(NULL
, DMASZ
,
774 &audio
->phys
, GFP_KERNEL
);
776 pr_err("audio: could not allocate DMA buffers\n");
781 rc
= audmgr_open(&audio
->audmgr
);
785 rc
= msm_adsp_get("AUDPLAY0TASK", &audio
->audplay
,
786 &audplay_adsp_ops_qcelp
, audio
);
788 pr_err("audio: failed to get audplay0 dsp module\n");
789 audmgr_close(&audio
->audmgr
);
795 audio
->out
[0].data
= audio
->data
+ 0;
796 audio
->out
[0].addr
= audio
->phys
+ 0;
797 audio
->out
[0].size
= BUFSZ
;
799 audio
->out
[1].data
= audio
->data
+ BUFSZ
;
800 audio
->out
[1].addr
= audio
->phys
+ BUFSZ
;
801 audio
->out
[1].size
= BUFSZ
;
803 audio
->volume
= 0x2000; /* Q13 1.0 */
805 audqcelp_flush(audio
);
807 file
->private_data
= audio
;
811 mutex_unlock(&audio
->lock
);
814 dma_free_coherent(NULL
, DMASZ
, audio
->data
, audio
->phys
);
815 mutex_unlock(&audio
->lock
);
819 static struct file_operations audio_qcelp_fops
= {
820 .owner
= THIS_MODULE
,
821 .open
= audqcelp_open
,
822 .release
= audqcelp_release
,
823 .read
= audqcelp_read
,
824 .write
= audqcelp_write
,
825 .unlocked_ioctl
= audqcelp_ioctl
,
828 struct miscdevice audio_qcelp_misc
= {
829 .minor
= MISC_DYNAMIC_MINOR
,
831 .fops
= &audio_qcelp_fops
,
834 static int __init
audqcelp_init(void)
836 mutex_init(&the_qcelp_audio
.lock
);
837 mutex_init(&the_qcelp_audio
.write_lock
);
838 mutex_init(&the_qcelp_audio
.read_lock
);
839 spin_lock_init(&the_qcelp_audio
.dsp_lock
);
840 init_waitqueue_head(&the_qcelp_audio
.write_wait
);
841 init_waitqueue_head(&the_qcelp_audio
.read_wait
);
842 the_qcelp_audio
.read_data
= NULL
;
843 return misc_register(&audio_qcelp_misc
);
846 static void __exit
audqcelp_exit(void)
848 misc_deregister(&audio_qcelp_misc
);
851 module_init(audqcelp_init
);
852 module_exit(audqcelp_exit
);
854 MODULE_DESCRIPTION("MSM QCELP 13K driver");
855 MODULE_LICENSE("GPL v2");
856 MODULE_AUTHOR("QUALCOMM");