From patchwork Fri Apr 8 15:03:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrien Thierry X-Patchwork-Id: 12806871 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 228E1C433EF for ; Fri, 8 Apr 2022 15:06:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=CsEI8vWtjQnyfeedXf+cz/HZ6uovJHURFOQEOEon7Zs=; b=WRj3BtzVSuR8qI DMkT1xAoBLLeLMUEtbmSwoeNNipdh8IUK7wuvnRb6mfS0K53Y6Kgxf8Zdjuk7JbGXuDNGxvhjRORe iHeNV3e7TzfF8TuoOMd5vaU6S/uHJ1SkljoJq2lpvJnAu7EZk34jFoImZGOk3fZWugSMjTnRNlOBZ pv6qjB5csZwiyLxFUXKIQKXEXzDPuvx7TSx4BC71ch6GPxqd+pGPP3vBCmWykOVSSpbIjf//417kV tmHU8Y/hIfX9EnWo45rsSaNKdYZfEWwK6qitLuayLsHSvSjSaMfSnku7+ir0J/3BMziPy6MM9kaUu MKjD3OayqZOU3+KHR1DQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncqAa-0009Qs-L4; Fri, 08 Apr 2022 15:05:04 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncqAV-0009O0-Is for linux-arm-kernel@lists.infradead.org; Fri, 08 Apr 2022 15:05:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649430297; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Nf3doDTjAQOJeXMo+td/oIn+T9zeQzKA6cjU7aYrP9I=; b=E+WsOw0GkX2lRcPAFB+0HkYfK/ozjJbsRU87F0lKT/xV45v4JLh1n2tV3+t+ibnKhVL/yy RqqVAc9UguKHGLrlEUj38i8y+VnJphfEt/UTH14DKJxzDHbEGRAP8O9gq4Mzqp4nqcFpOh ZKEAYySZXJMroK0Pbr9ews1ezjF/lSU= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-371-LtmMqq00OfWFf8UedRYEtw-1; Fri, 08 Apr 2022 11:04:56 -0400 X-MC-Unique: LtmMqq00OfWFf8UedRYEtw-1 Received: by mail-qk1-f199.google.com with SMTP id m23-20020a05620a221700b006809e1fa4fdso3773633qkh.6 for ; Fri, 08 Apr 2022 08:04:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Nf3doDTjAQOJeXMo+td/oIn+T9zeQzKA6cjU7aYrP9I=; b=xfLM5vcgNJt0aS5PTH4mTM6XR8sej5EpekI+qlrx2PkG22d7c6UtwoHG/eMuMy8HRw GCavIU8xhgoNdQPLdJg/8ll1nE4hY4Y67pcUrSItIAacnqiYOjajkURCkC1MHvpoTjEk T9nD6CnRUI73MIbbYNcNaoo2QJzWA5wPGQdZvPaUzDpxe+nVmK1wdXrfAAby2u9otu3/ Dh04yvg6ks/f0xMhYCfFarNL4/RjuwAWorMfpJ8J/+qJf32PSZ+DCKT/Jfqqa6MEMjfa v+ZInac6WZ8ynEcUtKJdDx3+O0+9BGDxmDMWQAZYgzslKjJISsgXHgdfXil5vsaU0WVo fZ0g== X-Gm-Message-State: AOAM532VU364X0L1VaJ3jQhY2kj71kCtBiusKR7L4BkLmJc9X3xItf1v FUah4C3uTH7qUfg/2KlN1cmazptdCsb+X8mC6U5kXPR4UOPjYcETFzN/vBPEwx1f4LjByF/BEXV LAfv0RMdX0x7u+GDqEAzMH3Tus4DKB6VR2lQ= X-Received: by 2002:ad4:5d48:0:b0:440:ef43:3667 with SMTP id jk8-20020ad45d48000000b00440ef433667mr16347230qvb.110.1649430295311; Fri, 08 Apr 2022 08:04:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCVc7ORoGlnJj5uukafi+K7qBY9LttNX9++JT3/dAotS3gtzJ8mGW4F4g7a6PbpA5LgjzL4g== X-Received: by 2002:ad4:5d48:0:b0:440:ef43:3667 with SMTP id jk8-20020ad45d48000000b00440ef433667mr16347198qvb.110.1649430295084; Fri, 08 Apr 2022 08:04:55 -0700 (PDT) Received: from fedora.hitronhub.home (modemcable200.11-22-96.mc.videotron.ca. [96.22.11.200]) by smtp.gmail.com with ESMTPSA id g9-20020a05620a108900b0067b13036bd5sm13700748qkk.52.2022.04.08.08.04.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Apr 2022 08:04:54 -0700 (PDT) From: Adrien Thierry To: Greg Kroah-Hartman , Florian Fainelli , Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com, Nicolas Saenz Julienne Cc: Adrien Thierry , linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] staging: bcm2835-audio: remove compat ALSA card Date: Fri, 8 Apr 2022 11:03:58 -0400 Message-Id: <20220408150359.26661-1-athierry@redhat.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=athierry@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220408_080459_717842_72ECBC8B X-CRM114-Status: GOOD ( 16.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Remove compat ALSA card, which has overlapping functionality with the two other cards described by the driver (HDMI and headphones) This handles TODO item "Revisit multi-cards options and PCM route mixer control". Move the S/PDIF device that was part of the compat ALSA card to the HDMI card. Only enable headphones card by default, because HDMI breaks when using both vc4 and bcm2835-audio with HDMI card enabled. Signed-off-by: Adrien Thierry --- I was able to test PCM output on 3.5mm and HDMI on a Raspberry Pi 4. However, I couldn't test the HDMI S/PDIF device since I don't own a S/PDIF capable speaker. .../vc04_services/bcm2835-audio/bcm2835-ctl.c | 86 ++----------------- .../vc04_services/bcm2835-audio/bcm2835.c | 33 ++----- 2 files changed, 15 insertions(+), 104 deletions(-) base-commit: 1831fed559732b132aef0ea8261ac77e73f7eadf diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c index 3703409715da..1c1f040122d7 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c @@ -117,15 +117,6 @@ static const struct snd_kcontrol_new snd_bcm2835_ctl[] = { .get = snd_bcm2835_ctl_get, .put = snd_bcm2835_ctl_put, }, - { - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "PCM Playback Route", - .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, - .private_value = PCM_PLAYBACK_DEVICE, - .info = snd_bcm2835_ctl_info, - .get = snd_bcm2835_ctl_get, - .put = snd_bcm2835_ctl_put, - }, }; static int snd_bcm2835_spdif_default_info(struct snd_kcontrol *kcontrol, @@ -220,7 +211,14 @@ static int create_ctls(struct bcm2835_chip *chip, size_t size, return 0; } -int snd_bcm2835_new_ctl(struct bcm2835_chip *chip) +int snd_bcm2835_new_headphones_ctl(struct bcm2835_chip *chip) +{ + strscpy(chip->card->mixername, "Broadcom Mixer", sizeof(chip->card->mixername)); + return create_ctls(chip, ARRAY_SIZE(snd_bcm2835_ctl), + snd_bcm2835_ctl); +} + +int snd_bcm2835_new_hdmi_ctl(struct bcm2835_chip *chip) { int err; @@ -232,71 +230,3 @@ int snd_bcm2835_new_ctl(struct bcm2835_chip *chip) snd_bcm2835_spdif); } -static const struct snd_kcontrol_new snd_bcm2835_headphones_ctl[] = { - { - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "Headphone Playback Volume", - .index = 0, - .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | - SNDRV_CTL_ELEM_ACCESS_TLV_READ, - .private_value = PCM_PLAYBACK_VOLUME, - .info = snd_bcm2835_ctl_info, - .get = snd_bcm2835_ctl_get, - .put = snd_bcm2835_ctl_put, - .count = 1, - .tlv = {.p = snd_bcm2835_db_scale} - }, - { - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "Headphone Playback Switch", - .index = 0, - .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, - .private_value = PCM_PLAYBACK_MUTE, - .info = snd_bcm2835_ctl_info, - .get = snd_bcm2835_ctl_get, - .put = snd_bcm2835_ctl_put, - .count = 1, - } -}; - -int snd_bcm2835_new_headphones_ctl(struct bcm2835_chip *chip) -{ - strscpy(chip->card->mixername, "Broadcom Mixer", sizeof(chip->card->mixername)); - return create_ctls(chip, ARRAY_SIZE(snd_bcm2835_headphones_ctl), - snd_bcm2835_headphones_ctl); -} - -static const struct snd_kcontrol_new snd_bcm2835_hdmi[] = { - { - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "HDMI Playback Volume", - .index = 0, - .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | - SNDRV_CTL_ELEM_ACCESS_TLV_READ, - .private_value = PCM_PLAYBACK_VOLUME, - .info = snd_bcm2835_ctl_info, - .get = snd_bcm2835_ctl_get, - .put = snd_bcm2835_ctl_put, - .count = 1, - .tlv = {.p = snd_bcm2835_db_scale} - }, - { - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "HDMI Playback Switch", - .index = 0, - .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, - .private_value = PCM_PLAYBACK_MUTE, - .info = snd_bcm2835_ctl_info, - .get = snd_bcm2835_ctl_get, - .put = snd_bcm2835_ctl_put, - .count = 1, - } -}; - -int snd_bcm2835_new_hdmi_ctl(struct bcm2835_chip *chip) -{ - strscpy(chip->card->mixername, "Broadcom Mixer", sizeof(chip->card->mixername)); - return create_ctls(chip, ARRAY_SIZE(snd_bcm2835_hdmi), - snd_bcm2835_hdmi); -} - diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c index 628732d7bf6a..00bc898b0189 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c @@ -10,17 +10,13 @@ #include "bcm2835.h" static bool enable_hdmi; -static bool enable_headphones; -static bool enable_compat_alsa = true; +static bool enable_headphones = true; static int num_channels = MAX_SUBSTREAMS; module_param(enable_hdmi, bool, 0444); MODULE_PARM_DESC(enable_hdmi, "Enables HDMI virtual audio device"); module_param(enable_headphones, bool, 0444); MODULE_PARM_DESC(enable_headphones, "Enables Headphones virtual audio device"); -module_param(enable_compat_alsa, bool, 0444); -MODULE_PARM_DESC(enable_compat_alsa, - "Enables ALSA compatibility virtual audio device"); module_param(num_channels, int, 0644); MODULE_PARM_DESC(num_channels, "Number of audio channels (default: 8)"); @@ -63,19 +59,20 @@ struct bcm2835_audio_driver { enum snd_bcm2835_route route; }; -static int bcm2835_audio_alsa_newpcm(struct bcm2835_chip *chip, +static int bcm2835_audio_dual_newpcm(struct bcm2835_chip *chip, const char *name, enum snd_bcm2835_route route, u32 numchannels) { int err; - err = snd_bcm2835_new_pcm(chip, "bcm2835 ALSA", 0, AUDIO_DEST_AUTO, - numchannels - 1, false); + err = snd_bcm2835_new_pcm(chip, name, 0, route, + numchannels, false); + if (err) return err; - err = snd_bcm2835_new_pcm(chip, "bcm2835 IEC958/HDMI", 1, 0, 1, true); + err = snd_bcm2835_new_pcm(chip, "IEC958", 1, route, 1, true); if (err) return err; @@ -90,18 +87,6 @@ static int bcm2835_audio_simple_newpcm(struct bcm2835_chip *chip, return snd_bcm2835_new_pcm(chip, name, 0, route, numchannels, false); } -static struct bcm2835_audio_driver bcm2835_audio_alsa = { - .driver = { - .name = "bcm2835_alsa", - .owner = THIS_MODULE, - }, - .shortname = "bcm2835 ALSA", - .longname = "bcm2835 ALSA", - .minchannels = 2, - .newpcm = bcm2835_audio_alsa_newpcm, - .newctl = snd_bcm2835_new_ctl, -}; - static struct bcm2835_audio_driver bcm2835_audio_hdmi = { .driver = { .name = "bcm2835_hdmi", @@ -110,7 +95,7 @@ static struct bcm2835_audio_driver bcm2835_audio_hdmi = { .shortname = "bcm2835 HDMI", .longname = "bcm2835 HDMI", .minchannels = 1, - .newpcm = bcm2835_audio_simple_newpcm, + .newpcm = bcm2835_audio_dual_newpcm, .newctl = snd_bcm2835_new_hdmi_ctl, .route = AUDIO_DEST_HDMI }; @@ -134,10 +119,6 @@ struct bcm2835_audio_drivers { }; static struct bcm2835_audio_drivers children_devices[] = { - { - .audio_driver = &bcm2835_audio_alsa, - .is_enabled = &enable_compat_alsa, - }, { .audio_driver = &bcm2835_audio_hdmi, .is_enabled = &enable_hdmi,