Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp174332lqo; Tue, 7 May 2024 16:40:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWF8fsEXFxhrs5dDSb168swcCnJ6ki1Zmuwg23LQaD78xXYlv9YgI98MjFIxrnt7JSLBw6vVIcoME3AEamnAQJ8xFuHpAr5s3NrPC64gQ== X-Google-Smtp-Source: AGHT+IEdDs01QD/9exko9CaEuTBBWMqvcZe8ACBLg+f4jdEKNSJEYhhbFztcsLgUGLIspfgKrAVk X-Received: by 2002:a17:902:c94f:b0:1e4:9ad5:7537 with SMTP id d9443c01a7336-1eeb01a607cmr13530495ad.34.1715125246433; Tue, 07 May 2024 16:40:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715125246; cv=pass; d=google.com; s=arc-20160816; b=I3/Kkfwo3cFPoc72rLuOgkjZdPIAODP0Kyy+dZQ8bBV0lc72pwX7V+ovMYMQ4HayfS jiDdR4/ekNC5Xi1kp2cy4Fjoilp613q3kAlTPqBBg9mNAVSs+1sM1EQM6M7rwG8oPby4 c0XImX47AuqWppD7gk+ppvm3QV+STbbjzNuodcfaNenvrraTxJAY57Z6RgfBtkn90RLl GS75u3QpsWQQKdw1VZVHdExn+E39ddFPTTuRgsgW9xkv+K+pqhIe5k3dgN3owoGcH8sJ xp4mOAy0hN3b5Og86mxZSQ6iSfWkmanaOv3CCZmGScbmJltIPTVc87V6pEyL8Mun5Uni Jndw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=RZIC4WVE2IKOTusEoxmmu05MBWYP2uO1rdu7LjOB08g=; fh=xRRcpb6h8yMZMudBJxDGr3DNGuczvQ78km/oXOMkS+c=; b=t3PnLFj1qOMDcTYhqCGKFi6bIglvVqVFh7a6vdD+31BXfavSbUVoGpr/hTgJo7XVxz XOmM47ptbI/h2bi4fHvNBuZ0l6hpvIzy2QZem6w9AEGzmw34N4avGCwAhcaJZ80PNn38 bsE/kdokpptH9z4UG3VE42PIP0escX0iOJ9rBkE2DNSI/F8c7hU+Ta2e5v08h3DcEe44 EMWn6wk0SiywgmUsQoibmffgzMvgoXJczOgtEJHsDmzwUz/zGmDzK5DqIjTMeHA5FwCR N9LtJ9EH/lreHJzknWqciGTb0qAVFdAoggXXZrmeyRNd0HnxRHft/CEx1PUwFMa7Zexz Lm8g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VQnOdft7; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-172414-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172414-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id ju14-20020a170903428e00b001e2c1740267si8737957plb.456.2024.05.07.16.40.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 16:40:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-172414-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VQnOdft7; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-172414-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172414-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A86A7284621 for ; Tue, 7 May 2024 23:39:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8FBFA14BF89; Tue, 7 May 2024 23:11:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VQnOdft7" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1C7214B946; Tue, 7 May 2024 23:11:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715123470; cv=none; b=IRjtqzPdgqPxcseEdyLFZmpEqBu8yFMNFmoxrnZ45GeN+BmlEQtbJrdCK7+AP/9jVSfOY4gM1t/i/I6zdOtuSpSAWhyq6j+zaopev8x8/4OtfYvtVP1BtEBrq//nOUcEgppWqi7PNjPP0tZflZRWBm8MluDu1T+pZdDzgPKc7vE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715123470; c=relaxed/simple; bh=Hh/1C4AKF94JLe48CVZQ/4GOW6QNUCJrBJ9s/sd1IQE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ldO1tG3zp6qUPM9xtUrcLi9LlDpqvgLXZT04uiU9OnBbReb6+MnXIc+F+Df1J736a0U3sKDYjXTJVs4UKXc2zYUiJrNX1vXK8/p0cjqoA3NveZ/IB8sfgqAnrIW4/bgnGSGwFF+3c8TNS06nb33fkbeHK7TrdkoQMjAyBAQxVu4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VQnOdft7; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B5A9C2BBFC; Tue, 7 May 2024 23:11:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715123470; bh=Hh/1C4AKF94JLe48CVZQ/4GOW6QNUCJrBJ9s/sd1IQE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VQnOdft7vqg6gY+xGXTmNSSeMx5Bxok9ctpBQuA1GFqZcpCXe5WWVmbti0M6ahMCL UQOsQbJe5flB0imLhufjiHMtlsiyWq19s7s8MtB19VE1l4iGBn/1IWbS7yKyAmqvk+ QLA9sPC02AWPNOPnKe6nuF7Qntoo1wTCuFN770ZqV/c0XoSIcsKtx76SnlNUvA2xtX W+nu0TxlUiUtWH3UM7iNKwqNED3DaAFZUmZX4X4T24My3yCcaC7Fmx7kcHe6+jKWj3 9Jf7neATvOpNHlWqurKcX1H9NQXpwBh+2TxRv9WhX5SPPsRv5IlatTsRJo7d1jsGMo jS3x98jpU918g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Oswald Buddenhagen , Takashi Iwai , Sasha Levin , perex@perex.cz, tiwai@suse.com, linux-sound@vger.kernel.org Subject: [PATCH AUTOSEL 6.6 19/43] ALSA: emu10k1: factor out snd_emu1010_load_dock_firmware() Date: Tue, 7 May 2024 19:09:40 -0400 Message-ID: <20240507231033.393285-19-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240507231033.393285-1-sashal@kernel.org> References: <20240507231033.393285-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.6.30 Content-Transfer-Encoding: 8bit From: Oswald Buddenhagen [ Upstream commit 28deafd0fbdc45cc9c63bd7dd4efc35137958862 ] Pulled out of the next patch to improve its legibility. As the function is now available, call it directly from snd_emu10k1_emu1010_init(), thus making the MicroDock firmware loading synchronous - there isn't really a reason not to. Note that this does not affect the AudioDocks of rev1 cards, as these have no independent power supplies, and thus come up only a while after the main card is initialized. As a drive-by, adjust the priorities of two messages to better reflect their impact. Signed-off-by: Oswald Buddenhagen Signed-off-by: Takashi Iwai Message-ID: <20240428093716.3198666-3-oswald.buddenhagen@gmx.de> Signed-off-by: Sasha Levin --- sound/pci/emu10k1/emu10k1_main.c | 66 +++++++++++++++++--------------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index de5c41e578e1f..a6b91597ea544 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -732,11 +732,43 @@ static int snd_emu1010_load_firmware(struct snd_emu10k1 *emu, int dock, return snd_emu1010_load_firmware_entry(emu, *fw); } +static void snd_emu1010_load_dock_firmware(struct snd_emu10k1 *emu) +{ + u32 tmp, tmp2; + int err; + + dev_info(emu->card->dev, "emu1010: Loading Audio Dock Firmware\n"); + /* Return to Audio Dock programming mode */ + snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, + EMU_HANA_FPGA_CONFIG_AUDIODOCK); + err = snd_emu1010_load_firmware(emu, 1, &emu->dock_fw); + if (err < 0) + return; + snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0); + + snd_emu1010_fpga_read(emu, EMU_HANA_ID, &tmp); + dev_dbg(emu->card->dev, "emu1010: EMU_HANA+DOCK_ID = 0x%x\n", tmp); + if ((tmp & 0x1f) != 0x15) { + /* FPGA failed to be programmed */ + dev_err(emu->card->dev, + "emu1010: Loading Audio Dock Firmware failed, reg = 0x%x\n", + tmp); + return; + } + dev_info(emu->card->dev, "emu1010: Audio Dock Firmware loaded\n"); + + snd_emu1010_fpga_read(emu, EMU_DOCK_MAJOR_REV, &tmp); + snd_emu1010_fpga_read(emu, EMU_DOCK_MINOR_REV, &tmp2); + dev_info(emu->card->dev, "Audio Dock ver: %u.%u\n", tmp, tmp2); + + /* Allow DLL to settle, to sync clocking between 1010 and Dock */ + msleep(10); +} + static void emu1010_firmware_work(struct work_struct *work) { struct snd_emu10k1 *emu; - u32 tmp, tmp2, reg; - int err; + u32 reg; emu = container_of(work, struct snd_emu10k1, emu1010.firmware_work); @@ -749,33 +781,7 @@ static void emu1010_firmware_work(struct work_struct *work) snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ®); /* OPTIONS: Which cards are attached to the EMU */ if (reg & EMU_HANA_OPTION_DOCK_OFFLINE) { /* Audio Dock attached */ - /* Return to Audio Dock programming mode */ - dev_info(emu->card->dev, - "emu1010: Loading Audio Dock Firmware\n"); - snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, - EMU_HANA_FPGA_CONFIG_AUDIODOCK); - err = snd_emu1010_load_firmware(emu, 1, &emu->dock_fw); - if (err < 0) - return; - snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0); - snd_emu1010_fpga_read(emu, EMU_HANA_ID, &tmp); - dev_info(emu->card->dev, - "emu1010: EMU_HANA+DOCK_ID = 0x%x\n", tmp); - if ((tmp & 0x1f) != 0x15) { - /* FPGA failed to be programmed */ - dev_info(emu->card->dev, - "emu1010: Loading Audio Dock Firmware file failed, reg = 0x%x\n", - tmp); - return; - } - dev_info(emu->card->dev, - "emu1010: Audio Dock Firmware loaded\n"); - snd_emu1010_fpga_read(emu, EMU_DOCK_MAJOR_REV, &tmp); - snd_emu1010_fpga_read(emu, EMU_DOCK_MINOR_REV, &tmp2); - dev_info(emu->card->dev, "Audio Dock ver: %u.%u\n", tmp, tmp2); - /* Sync clocking between 1010 and Dock */ - /* Allow DLL to settle */ - msleep(10); + snd_emu1010_load_dock_firmware(emu); /* Unmute all. Default is muted after a firmware load */ snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_UNMUTE); } @@ -889,7 +895,7 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu) snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ®); dev_info(emu->card->dev, "emu1010: Card options = 0x%x\n", reg); if (reg & EMU_HANA_OPTION_DOCK_OFFLINE) - schedule_work(&emu->emu1010.firmware_work); + snd_emu1010_load_dock_firmware(emu); if (emu->card_capabilities->no_adat) { emu->emu1010.optical_in = 0; /* IN_SPDIF */ emu->emu1010.optical_out = 0; /* OUT_SPDIF */ -- 2.43.0