Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp734241img; Thu, 28 Feb 2019 07:05:04 -0800 (PST) X-Google-Smtp-Source: AHgI3IYeNSyPMadtam9BpCAi3iJtB8j8Q+uJgaYRiOwSaaHx/mKENsZStRQNCzbE052aOxtnRbQW X-Received: by 2002:a63:5459:: with SMTP id e25mr9012864pgm.131.1551366304481; Thu, 28 Feb 2019 07:05:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551366304; cv=none; d=google.com; s=arc-20160816; b=RKIh0BNxqk+R7jQiTghTOczBpWCihEL9noUsO27uKZzC0jpIMCUE59S+eSFIonsWFX JvaS3t5k/SY6YVpQxcvhlOYZAxsADrjq4JOCO+5aS+o/wUi9Fc8TDah45YRAG0JQaOkH fZCYrG30yDncvz5nCn/UmYIhCcCNNPEfsQ9s6FxUoTDAu5WQC90VkNX1ilMx8sCJbvv0 JRD3G1vcvAuSVOajxMZgRjov+6m+vffzRy0fTbjkOom6LdxrpXCWBwfgtyIS9jJO5tOU GDped5l0fXdW1Ky7wuDt503uMsSv/U3J8A0J38Lem0lufVGUT3wFPFcFdXXoXd1U+AVL Z6IQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject :dkim-signature; bh=6Nyf+ff0HglNrT/E5oQmwk+05/6p8sCzidlDz8JDJZc=; b=yTS/Oazg44czg5JwZR6XbMnUv9BAvEsXJOLIA1D6sIVtKSwrCECYysScalzKbESWox 6TjGwx3IfmmCVNy/6rmDNdhZnBYvyZXR8ROcmBJdgI71GT6tY4jY+QKdjYsgF8vv+6db fplvqCEH+jKIXixasOSHP4+TQMYQ7y6J11oYwG8FPSUXubCsdt/rzp4d+dS6sOwWfowN wNZFwPClNlSv9UDfFhizTCws2sw7nx1y/QjagKZjgNjVnbCYYBQLhjVrrvaPEufK6e/T l9XU361nHmT0+b9gOGN4PxLpMjkoUmCdD+NcEARLJKs/SvllE/CKlf0RmNjskZNaPQOw ACrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=q9KZ5ySq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 5si6785995pgb.585.2019.02.28.07.04.48; Thu, 28 Feb 2019 07:05:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=q9KZ5ySq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732979AbfB1Ofw (ORCPT + 99 others); Thu, 28 Feb 2019 09:35:52 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:37766 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732268AbfB1Ofw (ORCPT ); Thu, 28 Feb 2019 09:35:52 -0500 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id x1SEZWFP093942; Thu, 28 Feb 2019 08:35:32 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1551364532; bh=6Nyf+ff0HglNrT/E5oQmwk+05/6p8sCzidlDz8JDJZc=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=q9KZ5ySq9EQzWyY14XshFc/HlJAp7CniOQnuIDHeg56YrosANW6UPKosA2DNBkONX QoUK7mdWNtNTZadV7xMJ8aTLdov5MzRNPZdE6731HHa1lMnTGF0ZEIpOQBazww1ynA sFn77qqSR3RO8PgAOdp+l5wxg7MqN74MD79J7NsA= Received: from DLEE107.ent.ti.com (dlee107.ent.ti.com [157.170.170.37]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x1SEZW61008165 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 28 Feb 2019 08:35:32 -0600 Received: from DLEE109.ent.ti.com (157.170.170.41) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Thu, 28 Feb 2019 08:35:31 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Thu, 28 Feb 2019 08:35:31 -0600 Received: from [10.1.3.6] (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id x1SEZTE4017104; Thu, 28 Feb 2019 08:35:30 -0600 Subject: Re: hdmi-codec: modifying params in hw_params() callback To: Russell King - ARM Linux admin CC: Liam Girdwood , Mark Brown , , , References: <20190228121516.swd3vweisgcxlvld@shell.armlinux.org.uk> <421c1217-6ff6-6ca2-8169-db026284fb29@ti.com> <20190228131059.i4nffuylja5p6tjv@shell.armlinux.org.uk> From: Jyri Sarha Openpgp: preference=signencrypt Autocrypt: addr=jsarha@ti.com; prefer-encrypt=mutual; keydata= mQINBFbdWt8BEADnCIkQrHIvAmuDcDzp1h2pO9s22nacEffl0ZyzIS//ruiwjMfSnuz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AGJAh8EGAECAAkFAlbdWt8CGwwA CgkQkDazUNfWGUFOfRAA5K/z9DXVEl2kkuMuIWkgtuuLQ7ZwqgxGP3dMA5z3Iv/N+VNRGbaw oxf+ZkTbJHEE/dWclj1TDtpET/t6BJNLaldLtJ1PborQH+0jTmGbsquemKPgaHeSU8vYLCdc GV/Rz+3FN0/fRdmoq2+bIHght4T6KZJ6jsrnBhm7y6gzjMOiftH6M5GXPjU0/FsU09qsk/af jbwLETaea0mlWMrLd9FC2KfVITA/f/YG2gqtUUF9WlizidyctWJqSTZn08MdzaoPItIkRUTv 6Bv6rmFn0daWkHt23BLd0ZP7e7pON1rqNVljWjWQ/b/E/SzeETrehgiyDr8pP+CLlC+vSQxi XtjhWjt1ItFLXxb4/HLZbb/L4gYX7zbZ3NwkON6Ifn3VU7UwqxGLmKfUwu/mFV+DXif1cKSS v6vWkVQ6Go9jPsSMFxMXPA5317sZZk/v18TAkIiwFqda3/SSjwc3e8Y76/DwPvUQd36lEbva uBrUXDDhCoiZnjQaNz/J+o9iYjuMTpY1Wp+igjIretYr9+kLvGsoPo/kTPWyiuh/WiFU2d6J PMCGFGhodTS5qmQA6IOuazek1qSZIl475u3E2uG98AEX/kRhSzgpsbvADPEUPaz75uvlmOCX tv+Sye9QT4Z1QCh3lV/Zh4GlY5lt4MwYnqFCxroK/1LpkLgdyQ4rRVw= Message-ID: Date: Thu, 28 Feb 2019 16:35:29 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190228131059.i4nffuylja5p6tjv@shell.armlinux.org.uk> Content-Type: text/plain; charset="utf-8" Content-Language: en-GB Content-Transfer-Encoding: 8bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28/02/2019 15:10, Russell King - ARM Linux admin wrote: > On Thu, Feb 28, 2019 at 02:54:29PM +0200, Jyri Sarha wrote: >> On 28/02/2019 14:15, Russell King - ARM Linux admin wrote: >>> Hi all, >>> >>> While looking at hdmi-codec issues, I spotted this code: >>> >>> static int hdmi_codec_hw_params(struct snd_pcm_substream *substream, >>> struct snd_pcm_hw_params *params, >>> struct snd_soc_dai *dai) >>> { >>> ... >>> if (params_width(params) > 24) >>> params->msbits = 24; >>> >>> params->msbits is a parameter that is negotiated and refined by >>> libasound, and is part of the ALSA constraint system. The "Writing an >>> ALSA driver" documentation says about the hw_params callback: >>> >>> "This is called when the hardware parameter (``hw_params``) is set up >>> by the application, that is, once when the buffer size, the period >>> size, the format, etc. are defined for the pcm substream." >>> >>> which suggests we should only be reading the parameters, not writing >>> to them. >>> >>> What's more is that the msbits is a parameter that is refined with >>> userspace, so surely the above should be a declared constraint? >>> >> >> Certainly not a constraint. While HDMI can only pass up to 24-bit per >> sample audio the most (or at least the two I have worked with) encoders >> can take 32-bit wide (and probably wider) samples trough i2s. So the >> system can play 32-bit samples, just the 4 LSB is ignored. > > You have not explained why "not a constraint". From the explanation > that Mark gave me on IRC, msbits is the number of bits that the codec > respects, whereas the sample bits is the number of bits in the sample. > If sample bits - msbits != 0, then that is the number of bits ignored. > Mark basically described it as "feel free to send me more than 24 bits > but I'm ignoring the LSBs". > > If the msbits is limited to 24, then userspace gets to know about that > limitation when negotiating with ALSA if it is a constraint. If it > isn't a constraint, userspace has no way to know. > >> Actually there is very little difference between the case of playing >> 32-bit stereo audio with matching i2s bclk ratio, and playing 24-bit >> stereo audio with 64-bit bclk ratio. Especially when the 4 LSB is anyway >> ignored like in HDMI audio case. > > You mean 8 LSB throughout the above two paragraphs. > >>> Digging a bit deeper, ASoC passes a private copy of the params to each >>> codec - a copy is made, then fixups for TDM slots are applied, followed >>> by any topology fixups by the DAI link (be_hw_params_fixup) before the >>> codec driver's hw_params() callback is made. Afterwards, ASoC reads >>> back the rate, channels and physical (memory) width and stores them >>> in the codec's DAI structure. The msbits are not read. >>> >>> hdmi-codec also seems to do nothing with the msbits parameter other >>> than the above code. >>> >>> So, all in all, it seems that the above code limiting msbits is >>> redundant - nothing will read this modified value. Can we kill it? >>> >> >> It certainly looks that way, so yes. In any case struct >> snd_soc_dai_driver .playback.sig_bits = 24 should be all that is needed. > > This sets a constraint to limit msbits to 24 for any sample width > in core ASoC code, doing exactly what you said "certainly not" to > above. > > It also means that the quoted code in hdmi-codec's hw_params() is > redundant for another reason. > > See the description of: > snd_pcm_hw_constraint_msbits() in sound/core/pcm_lib.c, > soc_pcm_set_msb() and soc_pcm_apply_msb() in sound/soc/soc-pcm.c. > > Can you please clarify, because there seems to be some confusion. > If I understand right, the only confusion here is around the term "constraint". I did not follow that you meant in strictly alsa-term. Yes we should set msbits pcm_lib constraint to 24 (as hdmi-codec aready does), because HDMI interface can not deliver more than 24 bits per sample, and any extra LSB bit will be ignored. -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki