Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp345316rwb; Thu, 12 Jan 2023 21:11:08 -0800 (PST) X-Google-Smtp-Source: AMrXdXsUzhotqyHEWyAjBotw+sUCPRlViiC3Ky0oJZJMc6AIopCRT0tPWwWS/mCaHgDv8WFgn4i+ X-Received: by 2002:a62:38d8:0:b0:582:ca4d:f6a7 with SMTP id f207-20020a6238d8000000b00582ca4df6a7mr9638708pfa.4.1673586668510; Thu, 12 Jan 2023 21:11:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673586668; cv=none; d=google.com; s=arc-20160816; b=miGDPOQYJhfDJBGSx0gwmAWoCkBpcbGNsNkCIV5O6mglln/IYonG/fGCqTQ+j3CsCC c2WYt1T14//cR3bKVFAzj4ghHzbno1Xg9MllKeOb5fvMUNuxDtNedNyvKGiKY/ae41+b mJ70uEmvywaypQHLKpZ3t+4C7yYwGQkjOC79FPOv2g8zJCADUFvZsMA02+2Na59AL6g6 ETe21OwQZ/+r4aEzFYg/sGfjAYF1fp/Ahx10SVaIsSqN3+WuaW7n0oe4+ezzH8orse/4 /xyM6dCvhrPgtuBZ7Wq2/KjWdrCEEPHmXzmD58g6jwKEe5iEr56WmVPXX7G/V3jKdciE QQzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=EIzlJ6x2ZWSoPr/sJ3kWretiXeMnx094rO9r/rA5emI=; b=mCAUfaobnHXKy9cMnbP8cs52h9qdPAmM/htc/A+btYpQux1o+6GO51qCh0j29hE/pW 3fAk9zZ+uMjczi0dPFaMYm5dCRLTjbX36y+cbG7RWnV+MIoGPEtCMo0oY9xLjQN9yF6R xr7V/RMP5/r6RZXJLp/216rWmCifEd9APOfRdTNDQtgrxrDiEBrw4TGs/fB5yIlpwEde TZs5lFkBNusuZjYDxiM1nKetARziWWX91fQhYDm07iHF8E+KFPu0vQBNaS13pFjOmNaM 7pFqUbgtl5R5JwXSc9UeZzYvW6kWVpvJFUcQY4NSFy94oYxFb62C8PTu5EgS8yhzzHdC rAJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gd9FtTTq; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y22-20020a626416000000b0058bb8f860bcsi727675pfb.124.2023.01.12.21.10.42; Thu, 12 Jan 2023 21:11:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gd9FtTTq; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230336AbjAMFGS (ORCPT + 99 others); Fri, 13 Jan 2023 00:06:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230172AbjAMFGP (ORCPT ); Fri, 13 Jan 2023 00:06:15 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59F4F13CC0 for ; Thu, 12 Jan 2023 21:06:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673586373; x=1705122373; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=xibHF4Rx49aQDlgxbf/eboSogVxmbrDDbEEj2z5HdmA=; b=gd9FtTTqfy+Sq2yTARIk5P9pioNWDz8gmXBSwCj3u8d+W7cFR8LyFFb5 aVlS8cQLPUev14vv5F5RkkA7UjDqoKPPF/RjX/GJUNFyuo8snA5MPNLgi iZRp7OIwBE6wIRSKkGxp7vJnJt9U7OtyrbMnQHEjJ0GQzulY7qPa8yC16 O8HYVd8BUQoute0DA4hKWAW6hlJgj5LKVywll0U1PbVJuAnIP2tDe0Nv8 lGQAsa711o2gUMLG5GjHwREJsiGJ/oUoPqBhY6q9ixLu7DnndFH5WO7a9 zFdQaZHZPvKaOIr/zIE6ngtZLbDdOzyaOGuEIBdka7Yupl+Z+4+5qT41y g==; X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="325973927" X-IronPort-AV: E=Sophos;i="5.97,213,1669104000"; d="scan'208";a="325973927" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 21:06:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="690386027" X-IronPort-AV: E=Sophos;i="5.97,213,1669104000"; d="scan'208";a="690386027" Received: from tester-latitude-7480.iind.intel.com ([10.224.186.122]) by orsmga001.jf.intel.com with ESMTP; 12 Jan 2023 21:06:11 -0800 From: Abhay Maheta To: linux-bluetooth@vger.kernel.org Cc: Abhay Maheta , Abhay Maheta Subject: [PATCH BlueZ v3] shared/bap: Fixing Company ID, Vendor ID and Metadata handling Date: Fri, 13 Jan 2023 10:36:05 +0530 Message-Id: <20230113050604.71398-1-abhay.maheshbhai.maheta@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This fixes Company ID, Vendor Codec ID and metadata storing PAC record. --- src/shared/bap.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/shared/bap.c b/src/shared/bap.c index 0cafb75e6..463cdb7a6 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -344,8 +344,10 @@ static void pac_foreach(void *data, void *user_data) p = util_iov_push(iov, sizeof(*p)); p->codec.id = pac->codec.id; - p->codec.cid = pac->codec.cid; - p->codec.vid = pac->codec.vid; + if (p->codec.id == 0xff) { + p->codec.cid = cpu_to_le16(pac->codec.cid); + p->codec.vid = cpu_to_le16(pac->codec.vid); + } if (pac->data) { p->cc_len = pac->data->iov_len; @@ -2773,7 +2775,7 @@ static void bap_parse_pacs(struct bt_bap *bap, uint8_t type, struct bt_pac *p; struct bt_ltv *cc; struct bt_pac_metadata *meta; - struct iovec data, metadata; + struct iovec data, *metadata = NULL; p = util_iov_pull_mem(&iov, sizeof(*p)); if (!p) { @@ -2802,8 +2804,11 @@ static void bap_parse_pacs(struct bt_bap *bap, uint8_t type, data.iov_len = p->cc_len; data.iov_base = cc; - metadata.iov_len = meta->len; - metadata.iov_base = meta->data; + if (meta->len) { + metadata = new0(struct iovec, 1); + metadata->iov_len = meta->len; + metadata->iov_base = meta->data; + } util_iov_pull_mem(&iov, meta->len); @@ -2813,12 +2818,14 @@ static void bap_parse_pacs(struct bt_bap *bap, uint8_t type, /* Check if there is already a PAC record for the codec */ pac = bap_pac_find(bap->rdb, type, &p->codec); if (pac) { - bap_pac_merge(pac, &data, &metadata); + bap_pac_merge(pac, &data, metadata); + free(metadata); continue; } pac = bap_pac_new(bap->rdb, NULL, type, &p->codec, NULL, &data, - &metadata); + metadata); + free(metadata); if (!pac) continue; -- 2.25.1