From patchwork Sun Dec 3 20:41:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasily Khoruzhick X-Patchwork-Id: 10089397 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 825486035E for ; Sun, 3 Dec 2017 20:44:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CF4A28DD1 for ; Sun, 3 Dec 2017 20:44:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81A0C28DE5; Sun, 3 Dec 2017 20:44:07 +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=-4.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0018F28DD1 for ; Sun, 3 Dec 2017 20:44:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=yH1H2WuivxXvd+X3c3f+BzfY+l93jumfaiUJmyaszms=; b=uUvd/3TZgQRSrMCSQGGEzAlWXr IQWZyMsDOxD2qtHRHaDxwZJ0pjQP3g07Fdd3UCTiAJRvLSQ/JOt7i8Y+zGIWTIhUVJrk0tUD1RC5l cVC6Jlm0jvdGQSRWsrGxzDNorUDcz6Zfz/LifxPvy5BkLTu5chC13NVX1RuX73NC7dwiuE2XB98Bm ixvV47P7jOvIxFAfG6g620oCV2/3S4ru9s05Wy1b7IM81nUI1O7f9aDtiNIXLHqvN+DsH+7a4r2dY Y5ADuvL8WXTzgf8XyJvfdWfvrF/XZ0PDBHGCsPqSv83bGChX4nRT1bveRxKqOhleD8a79ntoRXUyQ 3L6Iwhiw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eLb7F-0008So-HB; Sun, 03 Dec 2017 20:43:57 +0000 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eLb5m-00070J-9X for linux-arm-kernel@lists.infradead.org; Sun, 03 Dec 2017 20:42:28 +0000 Received: by mail-pg0-x242.google.com with SMTP id k15so6746187pgr.7 for ; Sun, 03 Dec 2017 12:42:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jO5D3MSjwIElYpm/SNXdQhhEogYhhDApYKbsEyHe0b4=; b=KIC/gTZSXRjWQvpAInIgSPktneUkhknH1UxzADKs3E2Tss9MaPjrT0Ynx6/Cwm7bO4 B5awIPjoOvMlpe3GyHT8p0NounRK4j/rvNEd7F2lTvsYe6zlE1MRxVyfiRKWGGLf0yOC GZUqEg2OlukhPqPM755jEbgl+FjbewBoD4So1zMYao+TVR/dH+73ytTN9krX6WQLzhE8 fD7pPxouiLycG9ZPNYFWphwgwyw5Qxr39ZhJFatjz8Ng+GDcM9LJde725pMeGFpQqjsA 5ockpomlXGf+0+aY/Tzv4SMk0K7f84kWrBAiyKAz8KCFj1PbKn0JlvkgLehzxtPy85JT ofrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jO5D3MSjwIElYpm/SNXdQhhEogYhhDApYKbsEyHe0b4=; b=ZwLzHagTUPLd/mjBj+B9oj4YF6/EJdvjSR7n6KWI1s06JE6OmgLS6cPhcudz3U1BA8 9YOsrOXgq2u+RRnbzMD6azIv20U5HMfAAO0vSlKAWQ1HxN0uOkFX+84kwuVoSTZJBi/Y sZ0gKlujCyUk7ZY9Jkppvzc8esRHZKtjGFY0Idb3etDjAKBiFpIk6RhA9ocnO8xAfCGp xgUVyBMG2pxn3G4jr1YmK5vsAv4+5y81f4NJ6pIzDnOt7lMzrAS7AK1rwrG/eqg8HhpI 6O+o4CCYcFEVTtTpJI5z7jSBJiaJsNGCKpX3SA0djx0dpnTVHMA3ZmH2uUyqCNnk6goc TL8A== X-Gm-Message-State: AJaThX497vEg9+PsGYxQJdnxVhxeZHAyoAU+r4qVvyln6s+wDks2Srnq PxGXjye5zt3Ng56nM9TFd0s= X-Google-Smtp-Source: AGs4zMaimUEs2FUtDHzVKEfZqAi76FwHk/Fr9FwQ+8ZxwiZq742kskajOKJGZv4KYzjFe3gSh0n3NA== X-Received: by 10.84.218.10 with SMTP id q10mr12926949pli.111.1512333727933; Sun, 03 Dec 2017 12:42:07 -0800 (PST) Received: from anarsoul-thinkpad.lan (216-71-193-140.dyn.novuscom.net. [216.71.193.140]) by smtp.gmail.com with ESMTPSA id z25sm19264929pfe.121.2017.12.03.12.42.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Dec 2017 12:42:07 -0800 (PST) From: Vasily Khoruzhick To: Liam Girdwood , Mark Brown , Maxime Ripard , Chen-Yu Tsai , Marcus Cooper , =?UTF-8?q?Myl=C3=A8ne=20Josserand?= , alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 6/9] ASoC: sun8i-codec-analog: Add component driver field to quirks structure Date: Sun, 3 Dec 2017 12:41:54 -0800 Message-Id: <20171203204157.20829-7-anarsoul@gmail.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171203204157.20829-1-anarsoul@gmail.com> References: <20171203204157.20829-1-anarsoul@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171203_124226_361696_37DCA87D X-CRM114-Status: GOOD ( 12.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vasily Khoruzhick MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This is necessary for upcoming addition of A64 support. A64 uses the same DAPM routes, but slightly different widgets. Use approach from sun4i-codec driver and pass appropriate component driver through quirks. Signed-off-by: Vasily Khoruzhick --- sound/soc/sunxi/sun8i-codec-analog.c | 57 +++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/sound/soc/sunxi/sun8i-codec-analog.c b/sound/soc/sunxi/sun8i-codec-analog.c index 384f582b6f69..4e39d2668286 100644 --- a/sound/soc/sunxi/sun8i-codec-analog.c +++ b/sound/soc/sunxi/sun8i-codec-analog.c @@ -759,24 +759,6 @@ struct sun8i_codec_analog_quirks { int (*add_lineout)(struct snd_soc_component *cmpnt); }; -static const struct sun8i_codec_analog_quirks sun8i_a23_quirks = { - .has_headphone = true, - .has_hmic = true, - .has_linein = true, - .has_mbias = true, - .has_mic2 = true, - .add_headphone = sun8i_a23_codec_add_headphone, -}; - -static const struct sun8i_codec_analog_quirks sun8i_h3_quirks = { - .has_linein = true, - .has_lineout = true, - .has_mbias = true, - .has_mic2 = true, - .add_lineout = sun8i_h3_codec_add_lineout, -}; - - static int sun8i_codec_analog_add_mixer(struct snd_soc_component *cmpnt, const struct sun8i_codec_analog_quirks *quirks) { @@ -819,11 +801,6 @@ static int sun8i_codec_analog_add_mixer(struct snd_soc_component *cmpnt, return 0; } -static const struct sun8i_codec_analog_quirks sun8i_v3s_quirks = { - .has_headphone = true, - .has_hmic = true, -}; - static int sun8i_codec_analog_cmpnt_probe(struct snd_soc_component *cmpnt) { struct device *dev = cmpnt->dev; @@ -891,6 +868,31 @@ static const struct snd_soc_component_driver sun8i_codec_analog_cmpnt_drv = { .probe = sun8i_codec_analog_cmpnt_probe, }; +static const struct sun8i_codec_analog_quirks sun8i_a23_quirks = { + .has_headphone = true, + .has_hmic = true, + .has_linein = true, + .has_mbias = true, + .has_mic2 = true, + .add_headphone = sun8i_a23_codec_add_headphone, + .cmpnt_drv = &sun8i_codec_analog_cmpnt_drv, +}; + +static const struct sun8i_codec_analog_quirks sun8i_h3_quirks = { + .has_linein = true, + .has_lineout = true, + .has_mbias = true, + .has_mic2 = true, + .add_lineout = sun8i_h3_codec_add_lineout, + .cmpnt_drv = &sun8i_codec_analog_cmpnt_drv, +}; + +static const struct sun8i_codec_analog_quirks sun8i_v3s_quirks = { + .has_headphone = true, + .has_hmic = true, + .cmpnt_drv = &sun8i_codec_analog_cmpnt_drv, +}; + static const struct of_device_id sun8i_codec_analog_of_match[] = { { .compatible = "allwinner,sun8i-a23-codec-analog", @@ -913,6 +915,13 @@ static int sun8i_codec_analog_probe(struct platform_device *pdev) struct resource *res; struct regmap *regmap; void __iomem *base; + const struct sun8i_codec_analog_quirks *quirks; + + quirks = of_device_get_match_data(&pdev->dev); + if (quirks == NULL) { + dev_err(&pdev->dev, "Failed to determine the quirks to use\n"); + return -ENODEV; + } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); base = devm_ioremap_resource(&pdev->dev, res); @@ -928,7 +937,7 @@ static int sun8i_codec_analog_probe(struct platform_device *pdev) } return devm_snd_soc_register_component(&pdev->dev, - &sun8i_codec_analog_cmpnt_drv, + quirks->cmpnt_drv, NULL, 0); }