From patchwork Fri Jun 10 12:36:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 12877571 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7F0A5C433EF for ; Fri, 10 Jun 2022 12:31:37 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id BDF711F80; Fri, 10 Jun 2022 14:30:45 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BDF711F80 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1654864295; bh=HvheQlqo9Qk1XDkvr95LUajm9gwLG5cr+phlYzI9mdc=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Z+cPgyz9AC368V3i2H8qSsU3xDJiE44xlNXzBqt15iFJLxigyoCCVyhBjdyfH63BY BBcsZA3NUU1m22Zb+BB0zm5eys7Ic+Q7wl9JWc3Q4Mo00UHiEAGmCcqHco0HkPFDV7 0NxuDQlVfCZZgOKntrdsFVU+xviCTiRfCfmtuS3M= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 90DA9F805C1; Fri, 10 Jun 2022 14:26:49 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A6218F805C2; Fri, 10 Jun 2022 14:26:48 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 32C9AF805A9 for ; Fri, 10 Jun 2022 14:26:42 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 32C9AF805A9 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="KquV9ol1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654864003; x=1686400003; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HvheQlqo9Qk1XDkvr95LUajm9gwLG5cr+phlYzI9mdc=; b=KquV9ol1K9j5MxyQAlnB6ZkWFkiEFX7MEwEWyQqkGIdokw6bK+4pysi3 j40WZD21POpVFRs1a8r3ajRcjCbg/J20AP6elZTnGCKZL50lesPlcZnw5 DIDr57+1azm1uVgTjtv32HNYb35b8qn4yBmEHGk38yxwhUocuVUomq6jg 6IA6djpMbpCj9X+RHFvwhMcSwgBKSgwtJDxo7MwwT5noVfK12JQgZQG0n I0UGPAWsSqqqTEhcRjLCm0GN5g0b79C3hWDWzGj8GpUH6QQCyHHpVEN5I UyQQQ3WEN0JYhpyKOPWC9uZRKKPDfxIM6kYYpX0qZ2wXzDx1yZco5hgGW w==; X-IronPort-AV: E=McAfee;i="6400,9594,10373"; a="278414495" X-IronPort-AV: E=Sophos;i="5.91,290,1647327600"; d="scan'208";a="278414495" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2022 05:26:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,290,1647327600"; d="scan'208";a="684517949" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by fmsmga002.fm.intel.com with ESMTP; 10 Jun 2022 05:26:38 -0700 From: Cezary Rojewski To: alsa-devel@alsa-project.org, broonie@kernel.org Subject: [PATCH 16/17] ASoC: Intel: bdw_rt286: Refactor suspend/resume Date: Fri, 10 Jun 2022 14:36:26 +0200 Message-Id: <20220610123627.1339985-17-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220610123627.1339985-1-cezary.rojewski@intel.com> References: <20220610123627.1339985-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Cc: Cezary Rojewski , pierre-louis.bossart@linux.intel.com, tiwai@suse.com, hdegoede@redhat.com, amadeuszx.slawinski@linux.intel.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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" Make use of card->remove() rather than pdev->remove() to unassign jack during card unbind procedure. To reduce code size, define unified jack setter in form of bdw_rt286_set_jack() and invoke it during remove(), suspend_pre() and resume_port(). Signed-off-by: Cezary Rojewski Reviewed-by: Amadeusz Sławiński --- sound/soc/intel/boards/bdw_rt286.c | 50 +++++++++--------------------- 1 file changed, 14 insertions(+), 36 deletions(-) diff --git a/sound/soc/intel/boards/bdw_rt286.c b/sound/soc/intel/boards/bdw_rt286.c index 81da9781c3ba..a2ff4da0bb93 100644 --- a/sound/soc/intel/boards/bdw_rt286.c +++ b/sound/soc/intel/boards/bdw_rt286.c @@ -199,43 +199,33 @@ static struct snd_soc_dai_link card_dai_links[] = { }, }; -static void broadwell_disable_jack(struct snd_soc_card *card) +static int card_set_jack(struct snd_soc_card *card, struct snd_soc_jack *jack) { - struct snd_soc_component *component; - - for_each_card_components(card, component) { - if (!strcmp(component->name, "i2c-INT343A:00")) { - dev_dbg(component->dev, "disabling jack detect before going to suspend.\n"); - rt286_mic_detect(component, NULL); - break; - } - } + struct snd_soc_dai *codec_dai = snd_soc_card_get_codec_dai(card, "rt286-aif1"); + + return rt286_mic_detect(codec_dai->component, jack); } -static int card_suspend_pre(struct snd_soc_card *card) +static int card_remove(struct snd_soc_card *card) { - broadwell_disable_jack(card); + return card_set_jack(card, NULL); +} - return 0; +static int card_suspend_pre(struct snd_soc_card *card) +{ + return card_set_jack(card, NULL); } static int card_resume_post(struct snd_soc_card *card) { - struct snd_soc_component *component; - - for_each_card_components(card, component) { - if (!strcmp(component->name, "i2c-INT343A:00")) { - dev_dbg(component->dev, "enabling jack detect for resume.\n"); - rt286_mic_detect(component, &card_headset); - break; - } - } - - return 0; + return card_set_jack(card, &card_headset); } static struct snd_soc_card bdw_rt286_card = { .owner = THIS_MODULE, + .remove = card_remove, + .suspend_pre = card_suspend_pre, + .resume_post = card_resume_post, .dai_link = card_dai_links, .num_links = ARRAY_SIZE(card_dai_links), .controls = card_controls, @@ -245,8 +235,6 @@ static struct snd_soc_card bdw_rt286_card = { .dapm_routes = card_routes, .num_dapm_routes = ARRAY_SIZE(card_routes), .fully_routed = true, - .suspend_pre = card_suspend_pre, - .resume_post = card_resume_post, }; /* Use space before codec name to simplify card ID, and simplify driver name. */ @@ -278,18 +266,8 @@ static int bdw_rt286_probe(struct platform_device *pdev) return devm_snd_soc_register_card(dev, &bdw_rt286_card); } -static int bdw_rt286_remove(struct platform_device *pdev) -{ - struct snd_soc_card *card = platform_get_drvdata(pdev); - - broadwell_disable_jack(card); - - return 0; -} - static struct platform_driver bdw_rt286_driver = { .probe = bdw_rt286_probe, - .remove = bdw_rt286_remove, .driver = { .name = "bdw_rt286", .pm = &snd_soc_pm_ops