From patchwork Mon Mar 26 14:16:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Machek X-Patchwork-Id: 10307953 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CDC6B60212 for ; Mon, 26 Mar 2018 14:16:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE769285E3 for ; Mon, 26 Mar 2018 14:16:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2F6C295F4; Mon, 26 Mar 2018 14:16:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 81534285E3 for ; Mon, 26 Mar 2018 14:16:50 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 75B7226708E; Mon, 26 Mar 2018 16:16:48 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id E7C332670F9; Mon, 26 Mar 2018 16:16:45 +0200 (CEST) Received: from atrey.karlin.mff.cuni.cz (atrey.karlin.mff.cuni.cz [195.113.26.193]) by alsa0.perex.cz (Postfix) with ESMTP id ADE9C266E07 for ; Mon, 26 Mar 2018 16:16:39 +0200 (CEST) Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id 33C188038A; Mon, 26 Mar 2018 16:16:39 +0200 (CEST) Date: Mon, 26 Mar 2018 16:16:38 +0200 From: Pavel Machek To: Sebastian Reichel Message-ID: <20180326141638.GB1450@amd> References: <20180223200254.25685-6-sebastian.reichel@collabora.co.uk> <20180322204804.GA26871@amd> <20180322234832.o24ut5ahon46mdu4@earth.universe> <20180323100930.GA21644@amd> <20180323103006.alymgb3ywftb4gek@earth.universe> MIME-Version: 1.0 In-Reply-To: <20180323103006.alymgb3ywftb4gek@earth.universe> User-Agent: Mutt/1.5.23 (2014-03-12) Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, kernel@collabora.com, Tony Lindgren , linux-kernel@vger.kernel.org, Takashi Iwai , Liam Girdwood , Rob Herring , Mark Brown , linux-omap@vger.kernel.org, Lee Jones Subject: [alsa-devel] omap4-droid4: voice call support was Re: [PATCHv5, 5/5] ARM: dts: omap4-droid4: add soundcard X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Hi! Do you have any ideas what needs to be done for voice calls support? I can talk to the modem and start a call. Then something like this (untested!) is certainly needed. Probably more... Thanks, Pavel diff --git a/sound/soc/codecs/cpcap.c b/sound/soc/codecs/cpcap.c index aedb267..7646f68 100644 --- a/sound/soc/codecs/cpcap.c +++ b/sound/soc/codecs/cpcap.c @@ -1280,6 +1280,60 @@ static int cpcap_voice_hw_params(struct snd_pcm_substream *substream, return 0; } +static int cpcap_incall_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct snd_soc_codec *codec = dai->codec; + struct device *dev = codec->dev; + struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + static const u16 reg_cdi = CPCAP_REG_CDI; + int rate = params_rate(params); + int channels = params_channels(params); + int direction = substream->stream; + u16 val, mask; + int err; + + dev_dbg(dev, "Incall setup HW params: rate=%d, direction=%d, chan=%d", + rate, direction, channels); + + /* codec, 1 in original code is CPCAP_REG_CC + codec, 2 is CPCAP_REG_CDI + codec, 5 is CPCAP_REG_TXI */ + + if (/* cpcap->codec_strm_cnt == */ 1) { + /* + if (pdata->voice_type != VOICE_TYPE_QC) + printk("FIXME: Only MDM6600 support is implemented here.\n"); + */ + + err = regmap_update_bits(cpcap->regmap, CPCAP_REG_CDI, 0xffff, 0xAE02); + if (err) printk("cpcap error %d\n", __LINE__); + + err = regmap_update_bits(cpcap->regmap, CPCAP_REG_CC, 0xffff, 0x6120); + if (err) printk("cpcap error %d\n", __LINE__); + + err = cpcap_set_samprate(cpcap, CPCAP_DAI_VOICE, rate); + printk("Configured stream\n"); + } + + /* (direction == SNDRV_PCM_STREAM_CAPTURE) ?? */ + if (substream->stream) { /* up link */ + unsigned int set = CPCAP_BIT_AUDIHPF_1 | CPCAP_BIT_AUDIHPF_0; + err = regmap_update_bits(cpcap->regmap, CPCAP_REG_CC, set, set); + if (err) printk("cpcap error %d\n", __LINE__); + + set = CPCAP_BIT_MB_ON1L | CPCAP_BIT_MB_ON1R; + err = regmap_update_bits(cpcap->regmap, CPCAP_REG_TXI, set, set); + } else { /* down link */ + unsigned int set = CPCAP_BIT_AUDOHPF_1 | CPCAP_BIT_AUDOHPF_0; + err = regmap_update_bits(cpcap->regmap, CPCAP_REG_CC, set, set); + if (err) printk("cpcap error %d\n", __LINE__); + } + + return err; +} + static int cpcap_voice_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { @@ -1394,6 +1448,14 @@ static const struct snd_soc_dai_ops cpcap_dai_voice_ops = { .digital_mute = cpcap_voice_set_mute, }; +static const struct snd_soc_dai_ops cpcap_dai_incall_ops = { + /* FIXME */ + .hw_params = cpcap_incall_hw_params, + .set_sysclk = cpcap_voice_set_dai_sysclk, + .set_fmt = cpcap_voice_set_dai_fmt, + .digital_mute = cpcap_voice_set_mute, +}; + static struct snd_soc_dai_driver cpcap_dai[] = { { .id = 0, @@ -1426,6 +1488,26 @@ static struct snd_soc_dai_driver cpcap_dai[] = { }, .ops = &cpcap_dai_voice_ops, }, +{ + .id = 2, + .name = "cpcap in-call", + .playback = { + .stream_name = "InCall DL", + .channels_min = 1, + .channels_max = 2, + .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + }, + .capture = { + .stream_name = "Capture", + .channels_min = 1, + .channels_max = 2, + .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + }, + .ops = &cpcap_dai_incall_ops, +}, +/* FIXME: this misses bt-call, cpcap bt, BPvoice, FM */ }; static int cpcap_dai_mux(struct cpcap_audio *cpcap, bool swap_dai_configuration)