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: 10089395 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 499C86035E for ; Sun, 3 Dec 2017 20:44:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5442628DD1 for ; Sun, 3 Dec 2017 20:44:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48EAD28DE5; Sun, 3 Dec 2017 20:44:06 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no 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 7FB6628DD1 for ; Sun, 3 Dec 2017 20:44:05 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 8C6E6267516; Sun, 3 Dec 2017 21:42:17 +0100 (CET) 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 4BFA22674FC; Sun, 3 Dec 2017 21:42:15 +0100 (CET) Received: from mail-pg0-f65.google.com (mail-pg0-f65.google.com [74.125.83.65]) by alsa0.perex.cz (Postfix) with ESMTP id 505BC267358 for ; Sun, 3 Dec 2017 21:42:11 +0100 (CET) Received: by mail-pg0-f65.google.com with SMTP id e14so6746496pgr.9 for ; Sun, 03 Dec 2017 12:42:10 -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=T08fp9DygCirqxKTkOycXJVyC23n6feT8MQPaEQPhggY0lMm+Nf2+0oE1UPjBxI3zL Se5Zc5fpQb9Gq+zBCDj003LjKHlSGvb1bg5ns1ftSteBXTO8Q6tCmm2SmE2NZDEjEwK/ BFN6oJmfEkGYcQ/KeNHndZktVS9sFmwraF1jizi/QKqTNVZ4Z4COElE4hk+Qin0fAccv UvhiH690FZOysw8fVzT8d5QzUVhUKzhn1RbyyQcMncO9JMXO799ufkQHuIr2r8ZqjFj2 1kr18INJ+ELOLfADmmCys6k0wqwboG83p5/Pv4WeCWe5842qFJ12xaDMR4OQgoPr5z6j mUbQ== X-Gm-Message-State: AJaThX4cr5pVDAGdQTGyQUorHIc31L2KVXuWXgeH2Jbba7h3iuwJzlMY 7pyPWt4mgVVQL35+bae+zQE= 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 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> Cc: Vasily Khoruzhick Subject: [alsa-devel] [PATCH 6/9] ASoC: sun8i-codec-analog: Add component driver field to quirks structure 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.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); }