12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346 |
- /* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
- #include <linux/init.h>
- #include <linux/err.h>
- #include <linux/module.h>
- #include <linux/time.h>
- #include <linux/wait.h>
- #include <linux/platform_device.h>
- #include <linux/slab.h>
- #include <linux/dma-mapping.h>
- #include <sound/core.h>
- #include <sound/soc.h>
- #include <sound/soc-dapm.h>
- #include <sound/pcm.h>
- #include <sound/initval.h>
- #include <sound/control.h>
- #include <asm/dma.h>
- #include "msm-pcm-q6.h"
- #include "msm-pcm-routing.h"
- #include "qdsp6/q6voice.h"
- #define VOIP_MAX_Q_LEN 10
- #define VOIP_MAX_VOC_PKT_SIZE 640
- #define VOIP_MIN_VOC_PKT_SIZE 320
- /* Length of the DSP frame info header added to the voc packet. */
- #define DSP_FRAME_HDR_LEN 1
- #define MODE_IS127 0x2
- #define MODE_4GV_NB 0x3
- #define MODE_4GV_WB 0x4
- #define MODE_AMR 0x5
- #define MODE_AMR_WB 0xD
- #define MODE_PCM 0xC
- #define MODE_G711 0xA
- #define MODE_G711A 0xF
- enum msm_audio_g711a_frame_type {
- MVS_G711A_SPEECH_GOOD,
- MVS_G711A_SID,
- MVS_G711A_NO_DATA,
- MVS_G711A_ERASURE
- };
- enum msm_audio_g711a_mode {
- MVS_G711A_MODE_MULAW,
- MVS_G711A_MODE_ALAW
- };
- enum msm_audio_g711_mode {
- MVS_G711_MODE_MULAW,
- MVS_G711_MODE_ALAW
- };
- enum format {
- FORMAT_S16_LE = 2,
- FORMAT_SPECIAL = 31,
- };
- enum amr_rate_type {
- AMR_RATE_4750, /* AMR 4.75 kbps */
- AMR_RATE_5150, /* AMR 5.15 kbps */
- AMR_RATE_5900, /* AMR 5.90 kbps */
- AMR_RATE_6700, /* AMR 6.70 kbps */
- AMR_RATE_7400, /* AMR 7.40 kbps */
- AMR_RATE_7950, /* AMR 7.95 kbps */
- AMR_RATE_10200, /* AMR 10.20 kbps */
- AMR_RATE_12200, /* AMR 12.20 kbps */
- AMR_RATE_6600, /* AMR-WB 6.60 kbps */
- AMR_RATE_8850, /* AMR-WB 8.85 kbps */
- AMR_RATE_12650, /* AMR-WB 12.65 kbps */
- AMR_RATE_14250, /* AMR-WB 14.25 kbps */
- AMR_RATE_15850, /* AMR-WB 15.85 kbps */
- AMR_RATE_18250, /* AMR-WB 18.25 kbps */
- AMR_RATE_19850, /* AMR-WB 19.85 kbps */
- AMR_RATE_23050, /* AMR-WB 23.05 kbps */
- AMR_RATE_23850, /* AMR-WB 23.85 kbps */
- AMR_RATE_UNDEF
- };
- enum voip_state {
- VOIP_STOPPED,
- VOIP_STARTED,
- };
- struct voip_frame {
- union {
- uint32_t frame_type;
- uint32_t packet_rate;
- } header;
- uint32_t len;
- uint8_t voc_pkt[VOIP_MAX_VOC_PKT_SIZE];
- };
- struct voip_buf_node {
- struct list_head list;
- struct voip_frame frame;
- };
- struct voip_drv_info {
- enum voip_state state;
- struct snd_pcm_substream *playback_substream;
- struct snd_pcm_substream *capture_substream;
- struct list_head in_queue;
- struct list_head free_in_queue;
- struct list_head out_queue;
- struct list_head free_out_queue;
- wait_queue_head_t out_wait;
- wait_queue_head_t in_wait;
- struct mutex lock;
- spinlock_t dsp_lock;
- spinlock_t dsp_ul_lock;
- uint32_t mode;
- uint32_t rate_type;
- uint32_t rate;
- uint32_t dtx_mode;
- uint8_t capture_start;
- uint8_t playback_start;
- uint8_t playback_instance;
- uint8_t capture_instance;
- unsigned int play_samp_rate;
- unsigned int cap_samp_rate;
- unsigned int pcm_size;
- unsigned int pcm_count;
- unsigned int pcm_playback_irq_pos; /* IRQ position */
- unsigned int pcm_playback_buf_pos; /* position in buffer */
- unsigned int pcm_capture_size;
- unsigned int pcm_capture_count;
- unsigned int pcm_capture_irq_pos; /* IRQ position */
- unsigned int pcm_capture_buf_pos; /* position in buffer */
- };
- static int voip_get_media_type(uint32_t mode, uint32_t rate_type,
- unsigned int samp_rate,
- uint32_t *media_type);
- static int voip_get_rate_type(uint32_t mode,
- uint32_t rate,
- uint32_t *rate_type);
- static int msm_voip_mode_rate_config_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol);
- static int msm_voip_mode_rate_config_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol);
- static struct voip_drv_info voip_info;
- static struct snd_pcm_hardware msm_pcm_hardware = {
- .info = (SNDRV_PCM_INFO_MMAP |
- SNDRV_PCM_INFO_BLOCK_TRANSFER |
- SNDRV_PCM_INFO_MMAP_VALID |
- SNDRV_PCM_INFO_INTERLEAVED),
- .formats = SNDRV_PCM_FMTBIT_S16_LE |
- SNDRV_PCM_FMTBIT_SPECIAL,
- .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
- .rate_min = 8000,
- .rate_max = 16000,
- .channels_min = 1,
- .channels_max = 1,
- .buffer_bytes_max = sizeof(struct voip_buf_node) * VOIP_MAX_Q_LEN,
- .period_bytes_min = VOIP_MIN_VOC_PKT_SIZE,
- .period_bytes_max = VOIP_MAX_VOC_PKT_SIZE,
- .periods_min = VOIP_MAX_Q_LEN,
- .periods_max = VOIP_MAX_Q_LEN,
- .fifo_size = 0,
- };
- static int msm_voip_mute_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- int mute = ucontrol->value.integer.value[0];
- pr_debug("%s: mute=%d\n", __func__, mute);
- voc_set_tx_mute(voc_get_session_id(VOIP_SESSION_NAME), TX_PATH, mute);
- return 0;
- }
- static int msm_voip_mute_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- ucontrol->value.integer.value[0] = 0;
- return 0;
- }
- static int msm_voip_volume_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- int volume = ucontrol->value.integer.value[0];
- pr_debug("%s: volume: %d\n", __func__, volume);
- voc_set_rx_vol_index(voc_get_session_id(VOIP_SESSION_NAME),
- RX_PATH,
- volume);
- return 0;
- }
- static int msm_voip_volume_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- ucontrol->value.integer.value[0] = 0;
- return 0;
- }
- static int msm_voip_dtx_mode_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- mutex_lock(&voip_info.lock);
- voip_info.dtx_mode = ucontrol->value.integer.value[0];
- pr_debug("%s: dtx: %d\n", __func__, voip_info.dtx_mode);
- mutex_unlock(&voip_info.lock);
- return 0;
- }
- static int msm_voip_dtx_mode_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- mutex_lock(&voip_info.lock);
- ucontrol->value.integer.value[0] = voip_info.dtx_mode;
- mutex_unlock(&voip_info.lock);
- return 0;
- }
- static struct snd_kcontrol_new msm_voip_controls[] = {
- SOC_SINGLE_EXT("Voip Tx Mute", SND_SOC_NOPM, 0, 1, 0,
- msm_voip_mute_get, msm_voip_mute_put),
- SOC_SINGLE_EXT("Voip Rx Volume", SND_SOC_NOPM, 0, 5, 0,
- msm_voip_volume_get, msm_voip_volume_put),
- SOC_SINGLE_MULTI_EXT("Voip Mode Rate Config", SND_SOC_NOPM, 0, 23850,
- 0, 2, msm_voip_mode_rate_config_get,
- msm_voip_mode_rate_config_put),
- SOC_SINGLE_EXT("Voip Dtx Mode", SND_SOC_NOPM, 0, 1, 0,
- msm_voip_dtx_mode_get, msm_voip_dtx_mode_put),
- };
- static int msm_pcm_voip_probe(struct snd_soc_platform *platform)
- {
- snd_soc_add_platform_controls(platform, msm_voip_controls,
- ARRAY_SIZE(msm_voip_controls));
- return 0;
- }
- /* sample rate supported */
- static unsigned int supported_sample_rates[] = {8000, 16000};
- /* capture path */
- static void voip_process_ul_pkt(uint8_t *voc_pkt,
- uint32_t pkt_len,
- void *private_data)
- {
- struct voip_buf_node *buf_node = NULL;
- struct voip_drv_info *prtd = private_data;
- unsigned long dsp_flags;
- if (prtd->capture_substream == NULL)
- return;
- /* Copy up-link packet into out_queue. */
- spin_lock_irqsave(&prtd->dsp_ul_lock, dsp_flags);
- /* discarding UL packets till start is received */
- if (!list_empty(&prtd->free_out_queue) && prtd->capture_start) {
- buf_node = list_first_entry(&prtd->free_out_queue,
- struct voip_buf_node, list);
- list_del(&buf_node->list);
- switch (prtd->mode) {
- case MODE_AMR_WB:
- case MODE_AMR: {
- /* Remove the DSP frame info header. Header format:
- * Bits 0-3: Frame rate
- * Bits 4-7: Frame type
- */
- buf_node->frame.header.frame_type =
- ((*voc_pkt) & 0xF0) >> 4;
- voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN;
- buf_node->frame.len = pkt_len - DSP_FRAME_HDR_LEN;
- memcpy(&buf_node->frame.voc_pkt[0],
- voc_pkt,
- buf_node->frame.len);
- list_add_tail(&buf_node->list, &prtd->out_queue);
- break;
- }
- case MODE_IS127:
- case MODE_4GV_NB:
- case MODE_4GV_WB: {
- /* Remove the DSP frame info header.
- * Header format:
- * Bits 0-3: frame rate
- */
- buf_node->frame.header.packet_rate = (*voc_pkt) & 0x0F;
- voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN;
- buf_node->frame.len = pkt_len - DSP_FRAME_HDR_LEN;
- memcpy(&buf_node->frame.voc_pkt[0],
- voc_pkt,
- buf_node->frame.len);
- list_add_tail(&buf_node->list, &prtd->out_queue);
- break;
- }
- case MODE_G711:
- case MODE_G711A:{
- /* G711 frames are 10ms each, but the DSP works with
- * 20ms frames and sends two 10ms frames per buffer.
- * Extract the two frames and put them in separate
- * buffers.
- */
- /* Remove the first DSP frame info header.
- * Header format: G711A
- * Bits 0-1: Frame type
- * Bits 2-3: Frame rate
- *
- * Header format: G711
- * Bits 2-3: Frame rate
- */
- if (prtd->mode == MODE_G711A)
- buf_node->frame.header.frame_type =
- (*voc_pkt) & 0x03;
- voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN;
- /* There are two frames in the buffer. Length of the
- * first frame:
- */
- buf_node->frame.len = (pkt_len -
- 2 * DSP_FRAME_HDR_LEN) / 2;
- memcpy(&buf_node->frame.voc_pkt[0],
- voc_pkt,
- buf_node->frame.len);
- voc_pkt = voc_pkt + buf_node->frame.len;
- list_add_tail(&buf_node->list, &prtd->out_queue);
- /* Get another buffer from the free Q and fill in the
- * second frame.
- */
- if (!list_empty(&prtd->free_out_queue)) {
- buf_node =
- list_first_entry(&prtd->free_out_queue,
- struct voip_buf_node,
- list);
- list_del(&buf_node->list);
- /* Remove the second DSP frame info header.
- * Header format:
- * Bits 0-1: Frame type
- * Bits 2-3: Frame rate
- */
- if (prtd->mode == MODE_G711A)
- buf_node->frame.header.frame_type =
- (*voc_pkt) & 0x03;
- voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN;
- /* There are two frames in the buffer. Length
- * of the second frame:
- */
- buf_node->frame.len = (pkt_len -
- 2 * DSP_FRAME_HDR_LEN) / 2;
- memcpy(&buf_node->frame.voc_pkt[0],
- voc_pkt,
- buf_node->frame.len);
- list_add_tail(&buf_node->list,
- &prtd->out_queue);
- } else {
- /* Drop the second frame */
- pr_err("%s: UL data dropped, read is slow\n",
- __func__);
- }
- break;
- }
- default: {
- buf_node->frame.len = pkt_len;
- memcpy(&buf_node->frame.voc_pkt[0],
- voc_pkt,
- buf_node->frame.len);
- list_add_tail(&buf_node->list, &prtd->out_queue);
- }
- }
- pr_debug("ul_pkt: pkt_len =%d, frame.len=%d\n", pkt_len,
- buf_node->frame.len);
- prtd->pcm_capture_irq_pos += prtd->pcm_capture_count;
- spin_unlock_irqrestore(&prtd->dsp_ul_lock, dsp_flags);
- snd_pcm_period_elapsed(prtd->capture_substream);
- } else {
- spin_unlock_irqrestore(&prtd->dsp_ul_lock, dsp_flags);
- pr_err("UL data dropped\n");
- }
- wake_up(&prtd->out_wait);
- }
- /* playback path */
- static void voip_process_dl_pkt(uint8_t *voc_pkt,
- uint32_t *pkt_len,
- void *private_data)
- {
- struct voip_buf_node *buf_node = NULL;
- struct voip_drv_info *prtd = private_data;
- unsigned long dsp_flags;
- if (prtd->playback_substream == NULL)
- return;
- spin_lock_irqsave(&prtd->dsp_lock, dsp_flags);
- if (!list_empty(&prtd->in_queue) && prtd->playback_start) {
- buf_node = list_first_entry(&prtd->in_queue,
- struct voip_buf_node, list);
- list_del(&buf_node->list);
- switch (prtd->mode) {
- case MODE_AMR:
- case MODE_AMR_WB: {
- /* Add the DSP frame info header. Header format:
- * Bits 0-3: Frame rate
- * Bits 4-7: Frame type
- */
- *voc_pkt = ((buf_node->frame.header.frame_type &
- 0x0F) << 4) | (prtd->rate_type & 0x0F);
- voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN;
- *pkt_len = buf_node->frame.len + DSP_FRAME_HDR_LEN;
- memcpy(voc_pkt,
- &buf_node->frame.voc_pkt[0],
- buf_node->frame.len);
- list_add_tail(&buf_node->list, &prtd->free_in_queue);
- break;
- }
- case MODE_IS127:
- case MODE_4GV_NB:
- case MODE_4GV_WB: {
- /* Add the DSP frame info header. Header format:
- * Bits 0-3 : Frame rate
- */
- *voc_pkt = buf_node->frame.header.packet_rate & 0x0F;
- voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN;
- *pkt_len = buf_node->frame.len + DSP_FRAME_HDR_LEN;
- memcpy(voc_pkt,
- &buf_node->frame.voc_pkt[0],
- buf_node->frame.len);
- list_add_tail(&buf_node->list, &prtd->free_in_queue);
- break;
- }
- case MODE_G711:
- case MODE_G711A:{
- /* G711 frames are 10ms each but the DSP expects 20ms
- * worth of data, so send two 10ms frames per buffer.
- */
- /* Add the first DSP frame info header. Header format:
- * Bits 0-1: Frame type
- * Bits 2-3: Frame rate
- */
- *voc_pkt = ((prtd->rate_type & 0x0F) << 2) |
- (buf_node->frame.header.frame_type & 0x03);
- voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN;
- *pkt_len = buf_node->frame.len + DSP_FRAME_HDR_LEN;
- memcpy(voc_pkt,
- &buf_node->frame.voc_pkt[0],
- buf_node->frame.len);
- voc_pkt = voc_pkt + buf_node->frame.len;
- list_add_tail(&buf_node->list, &prtd->free_in_queue);
- if (!list_empty(&prtd->in_queue)) {
- /* Get the second buffer. */
- buf_node = list_first_entry(&prtd->in_queue,
- struct voip_buf_node,
- list);
- list_del(&buf_node->list);
- /* Add the second DSP frame info header.
- * Header format:
- * Bits 0-1: Frame type
- * Bits 2-3: Frame rate
- */
- *voc_pkt = ((prtd->rate_type & 0x0F) << 2) |
- (buf_node->frame.header.frame_type & 0x03);
- voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN;
- *pkt_len = *pkt_len +
- buf_node->frame.len + DSP_FRAME_HDR_LEN;
- memcpy(voc_pkt,
- &buf_node->frame.voc_pkt[0],
- buf_node->frame.len);
- list_add_tail(&buf_node->list,
- &prtd->free_in_queue);
- } else {
- /* Only 10ms worth of data is available, signal
- * erasure frame.
- */
- *voc_pkt = ((prtd->rate_type & 0x0F) << 2) |
- (MVS_G711A_ERASURE & 0x03);
- *pkt_len = *pkt_len + DSP_FRAME_HDR_LEN;
- pr_debug("%s, Only 10ms read, erase 2nd frame\n",
- __func__);
- }
- break;
- }
- default: {
- *pkt_len = buf_node->frame.len;
- memcpy(voc_pkt,
- &buf_node->frame.voc_pkt[0],
- buf_node->frame.len);
- list_add_tail(&buf_node->list, &prtd->free_in_queue);
- }
- }
- pr_debug("dl_pkt: pkt_len=%d, frame_len=%d\n", *pkt_len,
- buf_node->frame.len);
- prtd->pcm_playback_irq_pos += prtd->pcm_count;
- spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags);
- snd_pcm_period_elapsed(prtd->playback_substream);
- } else {
- *pkt_len = 0;
- spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags);
- pr_err("DL data not available\n");
- }
- wake_up(&prtd->in_wait);
- }
- static struct snd_pcm_hw_constraint_list constraints_sample_rates = {
- .count = ARRAY_SIZE(supported_sample_rates),
- .list = supported_sample_rates,
- .mask = 0,
- };
- static int msm_pcm_playback_prepare(struct snd_pcm_substream *substream)
- {
- struct snd_pcm_runtime *runtime = substream->runtime;
- struct voip_drv_info *prtd = runtime->private_data;
- prtd->play_samp_rate = runtime->rate;
- prtd->pcm_size = snd_pcm_lib_buffer_bytes(substream);
- prtd->pcm_count = snd_pcm_lib_period_bytes(substream);
- prtd->pcm_playback_irq_pos = 0;
- prtd->pcm_playback_buf_pos = 0;
- return 0;
- }
- static int msm_pcm_capture_prepare(struct snd_pcm_substream *substream)
- {
- struct snd_pcm_runtime *runtime = substream->runtime;
- struct voip_drv_info *prtd = runtime->private_data;
- int ret = 0;
- prtd->cap_samp_rate = runtime->rate;
- prtd->pcm_capture_size = snd_pcm_lib_buffer_bytes(substream);
- prtd->pcm_capture_count = snd_pcm_lib_period_bytes(substream);
- prtd->pcm_capture_irq_pos = 0;
- prtd->pcm_capture_buf_pos = 0;
- return ret;
- }
- static int msm_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
- {
- int ret = 0;
- struct snd_pcm_runtime *runtime = substream->runtime;
- struct voip_drv_info *prtd = runtime->private_data;
- switch (cmd) {
- case SNDRV_PCM_TRIGGER_START:
- case SNDRV_PCM_TRIGGER_RESUME:
- pr_debug("%s: Trigger start\n", __func__);
- if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
- prtd->capture_start = 1;
- else
- prtd->playback_start = 1;
- break;
- case SNDRV_PCM_TRIGGER_STOP:
- pr_debug("SNDRV_PCM_TRIGGER_STOP\n");
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
- prtd->playback_start = 0;
- else
- prtd->capture_start = 0;
- break;
- default:
- ret = -EINVAL;
- break;
- }
- return ret;
- }
- static int msm_pcm_open(struct snd_pcm_substream *substream)
- {
- struct snd_pcm_runtime *runtime = substream->runtime;
- struct voip_drv_info *prtd = &voip_info;
- int ret = 0;
- pr_debug("%s, VoIP\n", __func__);
- mutex_lock(&prtd->lock);
- runtime->hw = msm_pcm_hardware;
- ret = snd_pcm_hw_constraint_list(runtime, 0,
- SNDRV_PCM_HW_PARAM_RATE,
- &constraints_sample_rates);
- if (ret < 0)
- pr_debug("snd_pcm_hw_constraint_list failed\n");
- ret = snd_pcm_hw_constraint_integer(runtime,
- SNDRV_PCM_HW_PARAM_PERIODS);
- if (ret < 0) {
- pr_debug("snd_pcm_hw_constraint_integer failed\n");
- goto err;
- }
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
- prtd->playback_substream = substream;
- prtd->playback_instance++;
- } else {
- prtd->capture_substream = substream;
- prtd->capture_instance++;
- }
- runtime->private_data = prtd;
- err:
- mutex_unlock(&prtd->lock);
- return ret;
- }
- static int msm_pcm_playback_copy(struct snd_pcm_substream *substream, int a,
- snd_pcm_uframes_t hwoff, void __user *buf, snd_pcm_uframes_t frames)
- {
- int ret = 0;
- struct voip_buf_node *buf_node = NULL;
- struct snd_pcm_runtime *runtime = substream->runtime;
- struct voip_drv_info *prtd = runtime->private_data;
- unsigned long dsp_flags;
- int count = frames_to_bytes(runtime, frames);
- pr_debug("%s: count = %d, frames=%d\n", __func__, count, (int)frames);
- ret = wait_event_interruptible_timeout(prtd->in_wait,
- (!list_empty(&prtd->free_in_queue) ||
- prtd->state == VOIP_STOPPED),
- 1 * HZ);
- if (ret > 0) {
- if (count <= VOIP_MAX_VOC_PKT_SIZE) {
- spin_lock_irqsave(&prtd->dsp_lock, dsp_flags);
- buf_node =
- list_first_entry(&prtd->free_in_queue,
- struct voip_buf_node, list);
- list_del(&buf_node->list);
- spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags);
- if (prtd->mode == MODE_PCM) {
- ret = copy_from_user(&buf_node->frame.voc_pkt,
- buf, count);
- buf_node->frame.len = count;
- } else
- ret = copy_from_user(&buf_node->frame,
- buf, count);
- spin_lock_irqsave(&prtd->dsp_lock, dsp_flags);
- list_add_tail(&buf_node->list, &prtd->in_queue);
- spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags);
- } else {
- pr_err("%s: Write cnt %d is > VOIP_MAX_VOC_PKT_SIZE\n",
- __func__, count);
- ret = -ENOMEM;
- }
- } else if (ret == 0) {
- pr_err("%s: No free DL buffs\n", __func__);
- ret = -ETIMEDOUT;
- } else {
- pr_err("%s: playback copy was interrupted\n", __func__);
- }
- return ret;
- }
- static int msm_pcm_capture_copy(struct snd_pcm_substream *substream,
- int channel, snd_pcm_uframes_t hwoff, void __user *buf,
- snd_pcm_uframes_t frames)
- {
- int ret = 0;
- int count = 0;
- struct voip_buf_node *buf_node = NULL;
- struct snd_pcm_runtime *runtime = substream->runtime;
- struct voip_drv_info *prtd = runtime->private_data;
- unsigned long dsp_flags;
- int size;
- count = frames_to_bytes(runtime, frames);
- pr_debug("%s: count = %d\n", __func__, count);
- ret = wait_event_interruptible_timeout(prtd->out_wait,
- (!list_empty(&prtd->out_queue) ||
- prtd->state == VOIP_STOPPED),
- 1 * HZ);
- if (ret > 0) {
- if (count <= VOIP_MAX_VOC_PKT_SIZE) {
- spin_lock_irqsave(&prtd->dsp_ul_lock, dsp_flags);
- buf_node = list_first_entry(&prtd->out_queue,
- struct voip_buf_node, list);
- list_del(&buf_node->list);
- spin_unlock_irqrestore(&prtd->dsp_ul_lock, dsp_flags);
- if (prtd->mode == MODE_PCM) {
- ret = copy_to_user(buf,
- &buf_node->frame.voc_pkt,
- buf_node->frame.len);
- } else {
- size = sizeof(buf_node->frame.header) +
- sizeof(buf_node->frame.len) +
- buf_node->frame.len;
- ret = copy_to_user(buf,
- &buf_node->frame,
- size;
- }
- if (ret) {
- pr_err("%s: Copy to user retuned %d\n",
- __func__, ret);
- ret = -EFAULT;
- }
- spin_lock_irqsave(&prtd->dsp_ul_lock, dsp_flags);
- list_add_tail(&buf_node->list,
- &prtd->free_out_queue);
- spin_unlock_irqrestore(&prtd->dsp_ul_lock, dsp_flags);
- } else {
- pr_err("%s: Read count %d > VOIP_MAX_VOC_PKT_SIZE\n",
- __func__, count);
- ret = -ENOMEM;
- }
- } else if (ret == 0) {
- pr_err("%s: No UL data available\n", __func__);
- ret = -ETIMEDOUT;
- } else {
- pr_err("%s: Read was interrupted\n", __func__);
- ret = -ERESTARTSYS;
- }
- return ret;
- }
- static int msm_pcm_copy(struct snd_pcm_substream *substream, int a,
- snd_pcm_uframes_t hwoff, void __user *buf, snd_pcm_uframes_t frames)
- {
- int ret = 0;
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
- ret = msm_pcm_playback_copy(substream, a, hwoff, buf, frames);
- else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
- ret = msm_pcm_capture_copy(substream, a, hwoff, buf, frames);
- return ret;
- }
- static int msm_pcm_close(struct snd_pcm_substream *substream)
- {
- int ret = 0;
- struct list_head *ptr = NULL;
- struct list_head *next = NULL;
- struct voip_buf_node *buf_node = NULL;
- struct snd_dma_buffer *p_dma_buf, *c_dma_buf;
- struct snd_pcm_substream *p_substream, *c_substream;
- struct snd_pcm_runtime *runtime;
- struct voip_drv_info *prtd;
- unsigned long dsp_flags;
- if (substream == NULL) {
- pr_err("substream is NULL\n");
- return -EINVAL;
- }
- runtime = substream->runtime;
- prtd = runtime->private_data;
- wake_up(&prtd->out_wait);
- mutex_lock(&prtd->lock);
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
- prtd->playback_instance--;
- else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
- prtd->capture_instance--;
- if (!prtd->playback_instance && !prtd->capture_instance) {
- if (prtd->state == VOIP_STARTED) {
- prtd->state = VOIP_STOPPED;
- voc_end_voice_call(
- voc_get_session_id(VOIP_SESSION_NAME));
- voc_register_mvs_cb(NULL, NULL, prtd);
- }
- /* release all buffer */
- /* release in_queue and free_in_queue */
- pr_debug("release all buffer\n");
- p_substream = prtd->playback_substream;
- if (p_substream == NULL) {
- pr_debug("p_substream is NULL\n");
- goto capt;
- }
- p_dma_buf = &p_substream->dma_buffer;
- if (p_dma_buf == NULL) {
- pr_debug("p_dma_buf is NULL\n");
- goto capt;
- }
- if (p_dma_buf->area != NULL) {
- spin_lock_irqsave(&prtd->dsp_lock, dsp_flags);
- list_for_each_safe(ptr, next, &prtd->in_queue) {
- buf_node = list_entry(ptr,
- struct voip_buf_node, list);
- list_del(&buf_node->list);
- }
- list_for_each_safe(ptr, next, &prtd->free_in_queue) {
- buf_node = list_entry(ptr,
- struct voip_buf_node, list);
- list_del(&buf_node->list);
- }
- spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags);
- dma_free_coherent(p_substream->pcm->card->dev,
- runtime->hw.buffer_bytes_max, p_dma_buf->area,
- p_dma_buf->addr);
- p_dma_buf->area = NULL;
- }
- /* release out_queue and free_out_queue */
- capt: c_substream = prtd->capture_substream;
- if (c_substream == NULL) {
- pr_debug("c_substream is NULL\n");
- goto done;
- }
- c_dma_buf = &c_substream->dma_buffer;
- if (c_substream == NULL) {
- pr_debug("c_dma_buf is NULL.\n");
- goto done;
- }
- if (c_dma_buf->area != NULL) {
- spin_lock_irqsave(&prtd->dsp_ul_lock, dsp_flags);
- list_for_each_safe(ptr, next, &prtd->out_queue) {
- buf_node = list_entry(ptr,
- struct voip_buf_node, list);
- list_del(&buf_node->list);
- }
- list_for_each_safe(ptr, next, &prtd->free_out_queue) {
- buf_node = list_entry(ptr,
- struct voip_buf_node, list);
- list_del(&buf_node->list);
- }
- spin_unlock_irqrestore(&prtd->dsp_ul_lock, dsp_flags);
- dma_free_coherent(c_substream->pcm->card->dev,
- runtime->hw.buffer_bytes_max, c_dma_buf->area,
- c_dma_buf->addr);
- c_dma_buf->area = NULL;
- }
- done:
- prtd->capture_substream = NULL;
- prtd->playback_substream = NULL;
- }
- mutex_unlock(&prtd->lock);
- return ret;
- }
- static int msm_pcm_prepare(struct snd_pcm_substream *substream)
- {
- int ret = 0;
- struct snd_pcm_runtime *runtime = substream->runtime;
- struct voip_drv_info *prtd = runtime->private_data;
- uint32_t media_type = 0;
- uint32_t rate_type = 0;
- mutex_lock(&prtd->lock);
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
- ret = msm_pcm_playback_prepare(substream);
- else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
- ret = msm_pcm_capture_prepare(substream);
- if ((runtime->format != FORMAT_SPECIAL) &&
- ((prtd->mode == MODE_AMR) || (prtd->mode == MODE_AMR_WB) ||
- (prtd->mode == MODE_IS127) || (prtd->mode == MODE_4GV_NB) ||
- (prtd->mode == MODE_4GV_WB) || (prtd->mode == MODE_G711) ||
- (prtd->mode == MODE_G711A))) {
- pr_err("mode:%d and format:%u are not mached\n",
- prtd->mode, (uint32_t)runtime->format);
- ret = -EINVAL;
- goto done;
- }
- if ((runtime->format != FORMAT_S16_LE) &&
- (prtd->mode == MODE_PCM)) {
- pr_err("mode:%d and format:%u are not mached\n",
- prtd->mode, (uint32_t)runtime->format);
- ret = -EINVAL;
- goto done;
- }
- if (prtd->playback_instance && prtd->capture_instance
- && (prtd->state != VOIP_STARTED)) {
- ret = voip_get_rate_type(prtd->mode,
- prtd->rate,
- &rate_type);
- if (ret < 0) {
- pr_err("fail at getting rate_type\n");
- ret = -EINVAL;
- goto done;
- }
- prtd->rate_type = rate_type;
- ret = voip_get_media_type(prtd->mode,
- prtd->rate_type,
- prtd->play_samp_rate,
- &media_type);
- if (ret < 0) {
- pr_err("fail at getting media_type\n");
- goto done;
- }
- pr_debug(" media_type=%d, rate_type=%d\n", media_type,
- rate_type);
- if ((prtd->play_samp_rate == 8000) &&
- (prtd->cap_samp_rate == 8000))
- voc_config_vocoder(media_type, rate_type,
- VSS_NETWORK_ID_VOIP_NB,
- voip_info.dtx_mode);
- else if ((prtd->play_samp_rate == 16000) &&
- (prtd->cap_samp_rate == 16000))
- voc_config_vocoder(media_type, rate_type,
- VSS_NETWORK_ID_VOIP_WB,
- voip_info.dtx_mode);
- else {
- pr_debug("%s: Invalid rate playback %d, capture %d\n",
- __func__, prtd->play_samp_rate,
- prtd->cap_samp_rate);
- goto done;
- }
- voc_register_mvs_cb(voip_process_ul_pkt,
- voip_process_dl_pkt, prtd);
- voc_start_voice_call(voc_get_session_id(VOIP_SESSION_NAME));
- prtd->state = VOIP_STARTED;
- }
- done:
- mutex_unlock(&prtd->lock);
- return ret;
- }
- static snd_pcm_uframes_t
- msm_pcm_playback_pointer(struct snd_pcm_substream *substream)
- {
- struct snd_pcm_runtime *runtime = substream->runtime;
- struct voip_drv_info *prtd = runtime->private_data;
- pr_debug("%s\n", __func__);
- if (prtd->pcm_playback_irq_pos >= prtd->pcm_size)
- prtd->pcm_playback_irq_pos = 0;
- return bytes_to_frames(runtime, (prtd->pcm_playback_irq_pos));
- }
- static snd_pcm_uframes_t
- msm_pcm_capture_pointer(struct snd_pcm_substream *substream)
- {
- struct snd_pcm_runtime *runtime = substream->runtime;
- struct voip_drv_info *prtd = runtime->private_data;
- if (prtd->pcm_capture_irq_pos >= prtd->pcm_capture_size)
- prtd->pcm_capture_irq_pos = 0;
- return bytes_to_frames(runtime, (prtd->pcm_capture_irq_pos));
- }
- static snd_pcm_uframes_t msm_pcm_pointer(struct snd_pcm_substream *substream)
- {
- snd_pcm_uframes_t ret = 0;
- pr_debug("%s\n", __func__);
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
- ret = msm_pcm_playback_pointer(substream);
- else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
- ret = msm_pcm_capture_pointer(substream);
- return ret;
- }
- static int msm_pcm_mmap(struct snd_pcm_substream *substream,
- struct vm_area_struct *vma)
- {
- struct snd_pcm_runtime *runtime = substream->runtime;
- pr_debug("%s\n", __func__);
- dma_mmap_coherent(substream->pcm->card->dev, vma,
- runtime->dma_area,
- runtime->dma_addr,
- runtime->dma_bytes);
- return 0;
- }
- static int msm_pcm_hw_params(struct snd_pcm_substream *substream,
- struct snd_pcm_hw_params *params)
- {
- struct snd_pcm_runtime *runtime = substream->runtime;
- struct snd_dma_buffer *dma_buf = &substream->dma_buffer;
- struct voip_buf_node *buf_node = NULL;
- int i = 0, offset = 0;
- pr_debug("%s: voip\n", __func__);
- mutex_lock(&voip_info.lock);
- dma_buf->dev.type = SNDRV_DMA_TYPE_DEV;
- dma_buf->dev.dev = substream->pcm->card->dev;
- dma_buf->private_data = NULL;
- dma_buf->area = dma_alloc_coherent(substream->pcm->card->dev,
- runtime->hw.buffer_bytes_max,
- &dma_buf->addr, GFP_KERNEL);
- if (!dma_buf->area) {
- pr_err("%s:MSM VOIP dma_alloc failed\n", __func__);
- return -ENOMEM;
- }
- dma_buf->bytes = runtime->hw.buffer_bytes_max;
- memset(dma_buf->area, 0, runtime->hw.buffer_bytes_max);
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
- for (i = 0; i < VOIP_MAX_Q_LEN; i++) {
- buf_node = (void *)dma_buf->area + offset;
- list_add_tail(&buf_node->list,
- &voip_info.free_in_queue);
- offset = offset + sizeof(struct voip_buf_node);
- }
- } else {
- for (i = 0; i < VOIP_MAX_Q_LEN; i++) {
- buf_node = (void *) dma_buf->area + offset;
- list_add_tail(&buf_node->list,
- &voip_info.free_out_queue);
- offset = offset + sizeof(struct voip_buf_node);
- }
- }
- mutex_unlock(&voip_info.lock);
- snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
- return 0;
- }
- static int msm_voip_mode_rate_config_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- mutex_lock(&voip_info.lock);
- ucontrol->value.integer.value[0] = voip_info.mode;
- ucontrol->value.integer.value[1] = voip_info.rate;
- mutex_unlock(&voip_info.lock);
- return 0;
- }
- static int msm_voip_mode_rate_config_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- mutex_lock(&voip_info.lock);
- voip_info.mode = ucontrol->value.integer.value[0];
- voip_info.rate = ucontrol->value.integer.value[1];
- pr_debug("%s: mode=%d,rate=%d\n", __func__, voip_info.mode,
- voip_info.rate);
- mutex_unlock(&voip_info.lock);
- return 0;
- }
- static int voip_get_rate_type(uint32_t mode, uint32_t rate,
- uint32_t *rate_type)
- {
- int ret = 0;
- switch (mode) {
- case MODE_AMR: {
- switch (rate) {
- case 4750:
- *rate_type = AMR_RATE_4750;
- break;
- case 5150:
- *rate_type = AMR_RATE_5150;
- break;
- case 5900:
- *rate_type = AMR_RATE_5900;
- break;
- case 6700:
- *rate_type = AMR_RATE_6700;
- break;
- case 7400:
- *rate_type = AMR_RATE_7400;
- break;
- case 7950:
- *rate_type = AMR_RATE_7950;
- break;
- case 10200:
- *rate_type = AMR_RATE_10200;
- break;
- case 12200:
- *rate_type = AMR_RATE_12200;
- break;
- default:
- pr_err("wrong rate for AMR NB.\n");
- ret = -EINVAL;
- break;
- }
- break;
- }
- case MODE_AMR_WB: {
- switch (rate) {
- case 6600:
- *rate_type = AMR_RATE_6600 - AMR_RATE_6600;
- break;
- case 8850:
- *rate_type = AMR_RATE_8850 - AMR_RATE_6600;
- break;
- case 12650:
- *rate_type = AMR_RATE_12650 - AMR_RATE_6600;
- break;
- case 14250:
- *rate_type = AMR_RATE_14250 - AMR_RATE_6600;
- break;
- case 15850:
- *rate_type = AMR_RATE_15850 - AMR_RATE_6600;
- break;
- case 18250:
- *rate_type = AMR_RATE_18250 - AMR_RATE_6600;
- break;
- case 19850:
- *rate_type = AMR_RATE_19850 - AMR_RATE_6600;
- break;
- case 23050:
- *rate_type = AMR_RATE_23050 - AMR_RATE_6600;
- break;
- case 23850:
- *rate_type = AMR_RATE_23850 - AMR_RATE_6600;
- break;
- default:
- pr_err("wrong rate for AMR_WB.\n");
- ret = -EINVAL;
- break;
- }
- break;
- }
- case MODE_PCM: {
- *rate_type = 0;
- break;
- }
- case MODE_IS127:
- case MODE_4GV_NB:
- case MODE_4GV_WB: {
- switch (rate) {
- case VOC_0_RATE:
- case VOC_8_RATE:
- case VOC_4_RATE:
- case VOC_2_RATE:
- case VOC_1_RATE:
- *rate_type = rate;
- break;
- default:
- pr_err("wrong rate for IS127/4GV_NB/WB.\n");
- ret = -EINVAL;
- break;
- }
- break;
- }
- case MODE_G711:
- case MODE_G711A:
- *rate_type = rate;
- break;
- default:
- pr_err("wrong mode type.\n");
- ret = -EINVAL;
- }
- pr_debug("%s, mode=%d, rate=%u, rate_type=%d\n",
- __func__, mode, rate, *rate_type);
- return ret;
- }
- static int voip_get_media_type(uint32_t mode, uint32_t rate_type,
- unsigned int samp_rate,
- uint32_t *media_type)
- {
- int ret = 0;
- pr_debug("%s: mode=%d, samp_rate=%d\n", __func__,
- mode, samp_rate);
- switch (mode) {
- case MODE_AMR:
- *media_type = VSS_MEDIA_ID_AMR_NB_MODEM;
- break;
- case MODE_AMR_WB:
- *media_type = VSS_MEDIA_ID_AMR_WB_MODEM;
- break;
- case MODE_PCM:
- if (samp_rate == 8000)
- *media_type = VSS_MEDIA_ID_PCM_NB;
- else
- *media_type = VSS_MEDIA_ID_PCM_WB;
- break;
- case MODE_IS127: /* EVRC-A */
- *media_type = VSS_MEDIA_ID_EVRC_MODEM;
- break;
- case MODE_4GV_NB: /* EVRC-B */
- *media_type = VSS_MEDIA_ID_4GV_NB_MODEM;
- break;
- case MODE_4GV_WB: /* EVRC-WB */
- *media_type = VSS_MEDIA_ID_4GV_WB_MODEM;
- break;
- case MODE_G711:
- case MODE_G711A:
- if (rate_type == MVS_G711A_MODE_MULAW)
- *media_type = VSS_MEDIA_ID_G711_MULAW;
- else
- *media_type = VSS_MEDIA_ID_G711_ALAW;
- break;
- default:
- pr_debug(" input mode is not supported\n");
- ret = -EINVAL;
- }
- pr_debug("%s: media_type is 0x%x\n", __func__, *media_type);
- return ret;
- }
- static struct snd_pcm_ops msm_pcm_ops = {
- .open = msm_pcm_open,
- .copy = msm_pcm_copy,
- .hw_params = msm_pcm_hw_params,
- .close = msm_pcm_close,
- .prepare = msm_pcm_prepare,
- .trigger = msm_pcm_trigger,
- .pointer = msm_pcm_pointer,
- .mmap = msm_pcm_mmap,
- };
- static int msm_asoc_pcm_new(struct snd_soc_pcm_runtime *rtd)
- {
- struct snd_card *card = rtd->card->snd_card;
- int ret = 0;
- pr_debug("msm_asoc_pcm_new\n");
- if (!card->dev->coherent_dma_mask)
- card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
- return ret;
- }
- static struct snd_soc_platform_driver msm_soc_platform = {
- .ops = &msm_pcm_ops,
- .pcm_new = msm_asoc_pcm_new,
- .probe = msm_pcm_voip_probe,
- };
- static __devinit int msm_pcm_probe(struct platform_device *pdev)
- {
- pr_info("%s: dev name %s\n", __func__, dev_name(&pdev->dev));
- return snd_soc_register_platform(&pdev->dev,
- &msm_soc_platform);
- }
- static int msm_pcm_remove(struct platform_device *pdev)
- {
- snd_soc_unregister_platform(&pdev->dev);
- return 0;
- }
- static struct platform_driver msm_pcm_driver = {
- .driver = {
- .name = "msm-voip-dsp",
- .owner = THIS_MODULE,
- },
- .probe = msm_pcm_probe,
- .remove = __devexit_p(msm_pcm_remove),
- };
- static int __init msm_soc_platform_init(void)
- {
- memset(&voip_info, 0, sizeof(voip_info));
- voip_info.mode = MODE_PCM;
- mutex_init(&voip_info.lock);
- spin_lock_init(&voip_info.dsp_lock);
- spin_lock_init(&voip_info.dsp_ul_lock);
- init_waitqueue_head(&voip_info.out_wait);
- init_waitqueue_head(&voip_info.in_wait);
- INIT_LIST_HEAD(&voip_info.in_queue);
- INIT_LIST_HEAD(&voip_info.free_in_queue);
- INIT_LIST_HEAD(&voip_info.out_queue);
- INIT_LIST_HEAD(&voip_info.free_out_queue);
- return platform_driver_register(&msm_pcm_driver);
- }
- module_init(msm_soc_platform_init);
- static void __exit msm_soc_platform_exit(void)
- {
- platform_driver_unregister(&msm_pcm_driver);
- }
- module_exit(msm_soc_platform_exit);
- MODULE_DESCRIPTION("PCM module platform driver");
- MODULE_LICENSE("GPL v2");
|