From patchwork Sun Jul 11 09:53:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Hofman X-Patchwork-Id: 473319 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B82B7C07E96 for ; Sun, 11 Jul 2021 09:54:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A2E861279 for ; Sun, 11 Jul 2021 09:54:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231987AbhGKJ4v (ORCPT ); Sun, 11 Jul 2021 05:56:51 -0400 Received: from cable.insite.cz ([84.242.75.189]:47211 "EHLO cable.insite.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229688AbhGKJ4t (ORCPT ); Sun, 11 Jul 2021 05:56:49 -0400 Received: from localhost (localhost [127.0.0.1]) by cable.insite.cz (Postfix) with ESMTP id AF8DAA1A3D407; Sun, 11 Jul 2021 11:54:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=ivitera.com; s=mail; t=1625997241; bh=vJlus4ofuCFwPzbuWq2f1FcNK+j5C7YAGdAZi7zMfgE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GCmJcJI1ozXfUNdIuF4yRW1+2TU2n7NtzcYl1xxnpaqTzrF1tSLavu2y9QA5WDXaP GnDcEiBKMzkP47FCzIhQqDbpPFuZtdPtc4IDLatZgKuMYE6jiTHSfK784oX5++kq/z WddkKNw0liLnSFa9ikQt3lNuqAC3eZctdHY4U8Fc= Received: from cable.insite.cz ([84.242.75.189]) by localhost (server.insite.cz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FMjKKHqZyw7C; Sun, 11 Jul 2021 11:53:56 +0200 (CEST) Received: from precision.doma (ip28.insite.cz [81.0.237.28]) (Authenticated sender: pavel) by cable.insite.cz (Postfix) with ESMTPSA id 70247A1A3D403; Sun, 11 Jul 2021 11:53:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=ivitera.com; s=mail; t=1625997236; bh=vJlus4ofuCFwPzbuWq2f1FcNK+j5C7YAGdAZi7zMfgE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N1WjCi3V+kpotew//UH8LVyhnTAIi/JHUhDZvPRBaD4XcifBTV5xB26OWrzJEn/c7 h6xQauBSZa9xpL5Mmb+2qX9rp7ZZJJ2mMtg/luejsCjutk56rvfA8eDRLNs46hZiHY 5vw9T1JjDoyA8iS93azi7P1HANPND0aPGjyt64kU= From: Pavel Hofman To: linux-usb@vger.kernel.org Cc: Pavel Hofman , Ruslan Bilovol , Felipe Balbi , Jerome Brunet Subject: [PATCH v2 1/4] usb: audio-v2: add ability to define feature unit descriptor Date: Sun, 11 Jul 2021 11:53:48 +0200 Message-Id: <20210711095351.16877-2-pavel.hofman@ivitera.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210711095351.16877-1-pavel.hofman@ivitera.com> References: <20210711095351.16877-1-pavel.hofman@ivitera.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Ruslan Bilovol Similar to UAC1 spec, UAC2 feature unit descriptor has variable size. Current audio-v2 feature unit descriptor structure is used for parsing descriptors, but can't be used to define your own descriptor. Add a new macro similar to what audio v1 already has. Signed-off-by: Ruslan Bilovol Signed-off-by: Pavel Hofman --- include/linux/usb/audio-v2.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/linux/usb/audio-v2.h b/include/linux/usb/audio-v2.h index ead8c9a47c6a..8fc2abd7aecb 100644 --- a/include/linux/usb/audio-v2.h +++ b/include/linux/usb/audio-v2.h @@ -156,6 +156,20 @@ struct uac2_feature_unit_descriptor { __u8 bmaControls[]; /* variable length */ } __attribute__((packed)); +#define UAC2_DT_FEATURE_UNIT_SIZE(ch) (6 + ((ch) + 1) * 4) + +/* As above, but more useful for defining your own descriptors: */ +#define DECLARE_UAC2_FEATURE_UNIT_DESCRIPTOR(ch) \ +struct uac2_feature_unit_descriptor_##ch { \ + __u8 bLength; \ + __u8 bDescriptorType; \ + __u8 bDescriptorSubtype; \ + __u8 bUnitID; \ + __u8 bSourceID; \ + __le32 bmaControls[ch + 1]; \ + __u8 iFeature; \ +} __packed + /* 4.7.2.10 Effect Unit Descriptor */ struct uac2_effect_unit_descriptor {