Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3978978ybl; Tue, 21 Jan 2020 10:30:50 -0800 (PST) X-Google-Smtp-Source: APXvYqyYEpx2sZQjEeCMtp3nKpJbMYPF+tTm2ZtLHA0catiVIAZhna2PwqYuynSuthxtEQhhgylH X-Received: by 2002:a9d:62c2:: with SMTP id z2mr4736403otk.309.1579631450358; Tue, 21 Jan 2020 10:30:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579631450; cv=none; d=google.com; s=arc-20160816; b=YzXUar9ydtnHg3ggfMY0Xh0jZp/jSbRu1yxOSjWr6f4cVbI/642v/LIecvP/ZJWZht udUqAqnt7dngrqyujWstpbLIGS6YbGf2oh8q3tcX8fk6Kb8NDc/k/DOENd6nFpx+llpp lW5Tb7lT+MtsQV1axiapO1qao23QE54xAxt/KU/DLX9ckkBWacdTAMiUqT0MGsPpAdTG oa2SbvtJUJCLmf0l+D1ubhN54qS9uHDZ9ZZy+SMGQm2Zh7fNEFiGEaueoYDGBG0+R0sU OUnvmZZQzRkRMRiOxWCG4AbLYKqAiswn2wz4Fw07I/abOVWyD7n+KcOmpWeWS6YyfWvo JieA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Vyh2ukw7HTBkZFo/Ct0XT+fP3oFiX9//5MAyhlIAqxo=; b=qbwhaRFPy3McPPVZ9AGUfuIsSWygx0wb/rkFV4XcTSlfAwOIAvgPzqeZy0KWZc6vNU zik4ZUcK5bmArygrDie/GgsUPuD6KE74PcUOPyoY1kNM9AED6pFGD/UY0ta+ejn3rgS8 e1pus8vkc6XEIRTZrYd/QxgiZqU5p0PjBWYaIatSEZTt+AwAnccFOPB5mJHxMcOAbA7c sl5NEdrFbP6VRtPYJHWy1a07jsLtBQ668MbfvPvSxiSFfyXZXlFmBDWn6AIJnrjMi0hk d+dXqyrKf6HZOyCpTfYOUk+l9i+MsHGMHlyJqYkT4kCWztyWOtiyz2Ook0wH4+Af2Xgj ftqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eW95Fo3d; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l11si20746287oie.231.2020.01.21.10.30.38; Tue, 21 Jan 2020 10:30:50 -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=@kernel.org header.s=default header.b=eW95Fo3d; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729262AbgAUS3l (ORCPT + 99 others); Tue, 21 Jan 2020 13:29:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:60726 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728186AbgAUS3l (ORCPT ); Tue, 21 Jan 2020 13:29:41 -0500 Received: from localhost (lfbn-tou-1-1502-76.w90-89.abo.wanadoo.fr [90.89.68.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5F99A2087E; Tue, 21 Jan 2020 18:29:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579631379; bh=51yKrmQlPgmeyaypex2fjkBrhPuOWZH0iB5oi4tqThI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=eW95Fo3d5uqoxtpENcsNkgmzU63zFhMaZKv/F5WPZkVNdlGolI/KGuuQD6Yy4aJQq V8kY9bvRwA+dJ8hUm4SrupskWqblO+Yd29STduEam1HvbJsehbxMNt2TpTkSSfPK56 Vh4YONOIomQ6fZ9oTBMv4+iaqWFAJqUARF9h1rsE= Date: Tue, 21 Jan 2020 19:29:37 +0100 From: Maxime Ripard To: Stefan Mavrodiev , Mark Brown Cc: Dan Williams , Vinod Koul , Chen-Yu Tsai , David Airlie , Daniel Vetter , open list , "open list:DMA GENERIC OFFLOAD ENGINE SUBSYSTEM" , "moderated list:ARM/Allwinner sunXi SoC support" , "open list:DRM DRIVERS FOR ALLWINNER A10" , linux-sunxi@googlegroups.com Subject: Re: [PATCH v2 2/2] drm: sun4i: hdmi: Add support for sun4i HDMI encoder audio Message-ID: <20200121182937.2ak72e4eklk4za2u@gilmour.lan> References: <20200120123326.30743-1-stefan@olimex.com> <20200120123326.30743-3-stefan@olimex.com> <20200121182905.pxs72ojqx5fz2gi3@gilmour.lan> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="cag4omdmo5ru62iz" Content-Disposition: inline In-Reply-To: <20200121182905.pxs72ojqx5fz2gi3@gilmour.lan> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --cag4omdmo5ru62iz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Actually Cc'ing this time.. On Tue, Jan 21, 2020 at 07:29:05PM +0100, Maxime Ripard wrote: > +Mark > > On Mon, Jan 20, 2020 at 02:33:26PM +0200, Stefan Mavrodiev wrote: > > Add HDMI audio support for the sun4i-hdmi encoder, used on > > the older Allwinner chips - A10, A20, A31. > > > > Most of the code is based on the BSP implementation. In it > > dditional formats are supported (S20_3LE and S24_LE), however > > there where some problems with them and only S16_LE is left. > > What are those problems? > > > Signed-off-by: Stefan Mavrodiev > > --- > > > +static int sun4i_hdmi_audio_probe(struct platform_device *pdev) > > +{ > > + struct snd_soc_card *card = &sun4i_hdmi_audio_card; > > + struct snd_soc_dai_link_component *comp; > > + struct snd_soc_dai_link *link; > > + struct device *dev = &pdev->dev; > > + struct sun4i_hdmi_audio *priv; > > + int ret; > > + > > + ret = devm_snd_dmaengine_pcm_register(dev, > > + &sun4i_hdmi_audio_pcm_config, 0); > > + if (ret) { > > + dev_err(dev, "Failed registering PCM DMA component\n"); > > + return ret; > > + } > > + > > + ret = devm_snd_soc_register_component(dev, > > + &sun4i_hdmi_audio_component, > > + &sun4i_hdmi_audio_dai, 1); > > + if (ret) { > > + dev_err(dev, "Failed registering DAI component\n"); > > + return ret; > > + } > > + > > + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); > > + if (!priv) > > + return -ENOMEM; > > + > > + priv->hdmi = dev->parent; > > + dev->of_node = dev->parent->of_node; > > + > > + link = devm_kzalloc(dev, sizeof(*link), GFP_KERNEL); > > + if (!link) > > + return -ENOMEM; > > + > > + comp = devm_kzalloc(dev, sizeof(*comp) * 3, GFP_KERNEL); > > + if (!comp) > > + return -ENOMEM; > > + > > + link->cpus = &comp[0]; > > + link->codecs = &comp[1]; > > + link->platforms = &comp[2]; > > + > > + link->num_cpus = 1; > > + link->num_codecs = 1; > > + link->num_platforms = 1; > > + > > + link->playback_only = 1; > > + > > + link->name = "SUN4I-HDMI"; > > + link->stream_name = "SUN4I-HDMI PCM"; > > + > > + link->codecs->name = dev_name(dev); > > + link->codecs->dai_name = sun4i_hdmi_audio_dai.name; > > + > > + link->cpus->dai_name = dev_name(dev); > > + > > + link->platforms->name = dev_name(dev); > > + > > + link->dai_fmt = SND_SOC_DAIFMT_I2S; > > + > > + card->dai_link = link; > > + card->num_links = 1; > > + card->dev = dev; > > + > > + snd_soc_card_set_drvdata(card, priv); > > + return devm_snd_soc_register_card(dev, card); > > +} > > + > > +static int sun4i_hdmi_audio_remove(struct platform_device *pdev) > > +{ > > + return 0; > > +} > > + > > +static struct platform_driver sun4i_hdmi_audio_driver = { > > + .probe = sun4i_hdmi_audio_probe, > > + .remove = sun4i_hdmi_audio_remove, > > + .driver = { > > + .name = DRIVER_NAME, > > + }, > > +}; > > +module_platform_driver(sun4i_hdmi_audio_driver); > > + > > +MODULE_AUTHOR("Stefan Mavrodiev > +MODULE_DESCRIPTION("Allwinner A10 HDMI Audio driver"); > > +MODULE_LICENSE("GPL v2"); > > +MODULE_ALIAS("platform:" DRIVER_NAME); > > Sorry if I wasn't clear enough in the previous mail, I didn't suggest > to do a driver, this will open another can of worm (as kbuild already > pointed out), but to create a new device, and pass that new device to > ASoC's functions. > > I tried that, and failed, so I guess it's not an option either. > > Mark, our issue here is that we have a driver tied to a device that is > an HDMI encoder. Obviously, we'll want to register into DRM, which is > what we were doing so far, with the usual case where at remove / > unbind time, in order to free the resources, we just retrieve our > pointer to our private structure using the device's drvdata. > > Now, snd_soc_register_card also sets that pointer to the card we try > to register, which is problematic. It seems that it's used to handle > suspend / resume automatically, which in this case would be also not > really fit for us (or rather, we would need to do more that just > suspend the audio part). > > Is there anyway we can have that kind of setup? I believe vc4 is in a > similar situation, but they worked around it by storing the data they > want to access in a global pointer, but that only works for one device > which doesn't really suit us either. > > Any suggestions? > Thanks! > Maxime --cag4omdmo5ru62iz Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCXidDEQAKCRDj7w1vZxhR xcfQAP9h+bAMOK6CttQGExCiUhHsu7AAwXShhNOzsQ0EX4W+5wD9HoQMFxRS3p4X /GofiUq7GHDK4SgSeA3DOZKvj2lQdwk= =ZXb2 -----END PGP SIGNATURE----- --cag4omdmo5ru62iz--