Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp640301rdb; Mon, 29 Jan 2024 13:20:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IHUG7BWausgMeQxsxS1B8ThSyn+1wR7RtbGreMIIfpyXmaXnUPhj225axsmZAfih5C2AYVQ X-Received: by 2002:a17:903:32d0:b0:1d7:6fb1:f993 with SMTP id i16-20020a17090332d000b001d76fb1f993mr3912790plr.32.1706563249265; Mon, 29 Jan 2024 13:20:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706563249; cv=pass; d=google.com; s=arc-20160816; b=f0jglIYTfIYce/6LINMHMiTHHZ8pI3i+BDTmCpjJyJ+yiBzjsX9jTAKgXSDmduURDC fPyqqcuumnLffsFynNCNzuq2kzdHHSFBVUWHC3cTi03GyW6klxRlZKFm66BhHk8Xhbwe rM8rhe6dWg/nvKEdIUzNL4RsJQLcSmcdL9NclLzGectjUozkiGKNusAtsiAscFyNHZlR n/3ysFgXbUk8VBR5+S6MqvMVX8atrdanfhhjJa6a8QwI8d55jdEaCbDlX/FpaxGUbprR umUCAchocHsGHLCaWbC5l7EoiyNUqfZ9OTv1DmdQSUo/TbRvUB6OPCjnHln9Em0ztR0G A+jQ== 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:to:from:dkim-signature; bh=JkqRF+mC8DuzEovf7kGj9+XXGT1P8SVx4xHS/zSUU2U=; fh=4lGQI6056MBa4/oovMyIYaKLn+Wz/24RGvUivMmQP8E=; b=DNhtZGq8pe6QfzGb8FHODkIqQ1aiLdtBAoFxuRfroVi7HkBCBiZhLR87rgTC05Ukuc +piG6FgF2aevcq2oKHTVp5/+vPAz8MXE7NRVNXDzoqx6qdn0dVLWUGdCZF4Oz/Qk/cfa CRYu3YuKWY6kJECEB8Gdu5jVseVGk0guMyBAMVhJHR2+lfFyqaQX7BnWsOxkajVrnT9q i3xjGV+RuNfgKxRtBPxQUXevRC+dMIyK1IAmt5pCZXeGzPMrns+47SZJ61pXaOc81VeP 6T0fDmZNpvoH8VxElIQUJwNEOEVy44yRzCV1DOOMi2/MCYgPCqeYYDxwNV3ePQFrCXYU qKWQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=TSxRqP5V; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-bluetooth+bounces-1472-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-1472-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id u8-20020a17090341c800b001d8e4a82e74si2170754ple.543.2024.01.29.13.20.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 13:20:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-1472-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=@gmail.com header.s=20230601 header.b=TSxRqP5V; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-bluetooth+bounces-1472-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-1472-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 5D97F284A94 for ; Mon, 29 Jan 2024 21:20:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D6AF1586DA; Mon, 29 Jan 2024 21:20:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TSxRqP5V" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8F62157E87 for ; Mon, 29 Jan 2024 21:20:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706563243; cv=none; b=dZsawOEPDcvHuDfQ8NSS5F+p8z/HiJfgDwZBma21P4PZO352aJWpWgLbr+N1aZf74x8ycBcaBdi2/2pcH/2Dc+9ejF2DVsddc3E0ejUNxfHc0sowfeRDUN4aaBTtWCyxJRIIkvA9xx3aVCdavqEY3dq2hlrZVSVp+/gqSrXlbHE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706563243; c=relaxed/simple; bh=HScspj2KBEM4z2LFd52QvW2BWvmC2lfzDO8Pg9gmxXQ=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rw/PUlkX8RNEWW7YA2UnMX2ThaSDcBUulzm8MtO7Mm+hdA6fyQh6ePMou5Ju4h4kEm91o07Ur3YBsQia6S6cuWYvKAYepcyWca/NcmvfZrZsBO/LlQjpXGEfkwKCXRv7dq83Coq0rZE2HDpyK/I3xSsYh4N7W5QtTdGLeL05otk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TSxRqP5V; arc=none smtp.client-ip=209.85.128.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-603e7d19725so10015387b3.0 for ; Mon, 29 Jan 2024 13:20:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706563240; x=1707168040; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=JkqRF+mC8DuzEovf7kGj9+XXGT1P8SVx4xHS/zSUU2U=; b=TSxRqP5VL38eSYrxaneql9qXU6Zxe318IGnbxj5xp5GBfEqso0JN+Bba5vzOlpjPWp ziXqCGr8Rn5y7KgkXpepJ46V5jkqAPmUv0dq3mQBCzcfJHeT0zaN14xi3jmsmRyEL4Ni w/t/8i4L6O24W8Ga0/zFGeeYKhClTU5w/j4bFhstrHSKpXvJhHg/bc5UgECmfZA2YKHe zdq7ksNZ2EWBtObgeBw318U64CpLANZ7KTTUl1c3jvcD5qpR1fMzslP9ByTvrup4MeEv XS6K3DS/Q6ytrfMOEkWPQa9WzUcEhzJFSZ4cmiYwym9EFCaY+YfqRiStcfVMfwn9Epmj SdHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706563240; x=1707168040; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JkqRF+mC8DuzEovf7kGj9+XXGT1P8SVx4xHS/zSUU2U=; b=dIpfeLJWHEWlqULM6e5YnFZEU8Nvi/a6iXndpV8XJujtAYJ4QA7WAqJZ9KLnW2BfYI IIN2G5fXFD5SauD/0xJ6ojcQyu44n5kCutBxJbOzJfTjT215QJL37Qz619/bgRbm9SFf O+JO7kNIrUkvKcGFRKZSmSlthRXbJvAigWJESxdn6iFXtfB2yL+2iG6ud5oVOld2+IDr Vq0tHhkWzvxFtGfp8DGtAbDKioj9e+TF6nZkGjRqYSCx+mAKT+smQmBsRIXbgViXMkL1 CLxttSyd1osRZ9xsWJDgEVeO7S28tb7Pk8CuCYMZPakKIlZU0dLfvKM410H9jNb+8H67 +V8g== X-Gm-Message-State: AOJu0YyRLRTe0ZeI5l/nlCTtX5+5iKlAfPCkk0EcfjQm3J2QHAYlRSw8 NsLgWWoIXfHGgq5R7IP8LGTQpokOIHY00buzWKMBcciy1b0Nbgxf5EKLwyR3 X-Received: by 2002:a05:690c:3508:b0:5ff:cbab:2625 with SMTP id fq8-20020a05690c350800b005ffcbab2625mr7690499ywb.36.1706563239913; Mon, 29 Jan 2024 13:20:39 -0800 (PST) Received: from lvondent-mobl4.. (071-047-239-151.res.spectrum.com. [71.47.239.151]) by smtp.gmail.com with ESMTPSA id l198-20020a0de2cf000000b005fff75780f3sm2704904ywe.66.2024.01.29.13.20.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 13:20:38 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v1 2/4] client/player: Add metadata support to struct capabilities Date: Mon, 29 Jan 2024 16:20:34 -0500 Message-ID: <20240129212036.163298-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240129212036.163298-1-luiz.dentz@gmail.com> References: <20240129212036.163298-1-luiz.dentz@gmail.com> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Luiz Augusto von Dentz This enables defining metadata as part of the struct capabilities. --- client/player.c | 92 ++++++++++++++++++++++++------------------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/client/player.c b/client/player.c index 623519209001..f6b2278d5a8f 100644 --- a/client/player.c +++ b/client/player.c @@ -1130,21 +1130,7 @@ static DBusMessage *endpoint_set_configuration(DBusConnection *conn, return NULL; } -struct codec_capabilities { - uint8_t len; - uint8_t type; - uint8_t data[UINT8_MAX]; -}; - -#define data(args...) ((const unsigned char[]) { args }) - -#define CODEC_DATA(args...) \ - { \ - .iov_base = (void *)data(args), \ - .iov_len = sizeof(data(args)), \ - } - -#define CODEC_CAPABILITIES(_uuid, _codec_id, _data) \ +#define CODEC_CAPABILITIES(_uuid, _codec_id, _data, _meta) \ { \ .uuid = _uuid, \ .codec_id = _codec_id, \ @@ -1152,16 +1138,17 @@ struct codec_capabilities { } #define LC3_DATA(_freq, _duration, _chan_count, _len_min, _len_max) \ - CODEC_DATA(0x03, LC3_FREQ, _freq, _freq >> 8, \ - 0x02, LC3_DURATION, _duration, \ - 0x02, LC3_CHAN_COUNT, _chan_count, \ - 0x05, LC3_FRAME_LEN, _len_min, _len_min >> 8, _len_max, \ - _len_max >> 8) + UTIL_IOV_INIT(0x03, LC3_FREQ, _freq, _freq >> 8, \ + 0x02, LC3_DURATION, _duration, \ + 0x02, LC3_CHAN_COUNT, _chan_count, \ + 0x05, LC3_FRAME_LEN, _len_min, _len_min >> 8, \ + _len_max, _len_max >> 8) static const struct capabilities { const char *uuid; uint8_t codec_id; struct iovec data; + struct iovec meta; } caps[] = { /* A2DP SBC Source: * @@ -1172,7 +1159,8 @@ static const struct capabilities { * Bitpool Range: 2-64 */ CODEC_CAPABILITIES(A2DP_SOURCE_UUID, A2DP_CODEC_SBC, - CODEC_DATA(0xff, 0xff, 2, 64)), + UTIL_IOV_INIT(0xff, 0xff, 2, 64), + UTIL_IOV_INIT()), /* A2DP SBC Sink: * * Channel Modes: Mono DualChannel Stereo JointStereo @@ -1182,7 +1170,9 @@ static const struct capabilities { * Bitpool Range: 2-64 */ CODEC_CAPABILITIES(A2DP_SINK_UUID, A2DP_CODEC_SBC, - CODEC_DATA(0xff, 0xff, 2, 64)), + UTIL_IOV_INIT(0xff, 0xff, 2, 64), + UTIL_IOV_INIT()), + /* PAC LC3 Sink: * * Frequencies: 8Khz 11Khz 16Khz 22Khz 24Khz 32Khz 44.1Khz 48Khz @@ -1192,7 +1182,9 @@ static const struct capabilities { */ CODEC_CAPABILITIES(PAC_SINK_UUID, LC3_ID, LC3_DATA(LC3_FREQ_ANY, LC3_DURATION_ANY, - 3u, 30, 240)), + 3u, 30, 240), + UTIL_IOV_INIT()), + /* PAC LC3 Source: * * Frequencies: 8Khz 11Khz 16Khz 22Khz 24Khz 32Khz 44.1Khz 48Khz @@ -1202,7 +1194,9 @@ static const struct capabilities { */ CODEC_CAPABILITIES(PAC_SOURCE_UUID, LC3_ID, LC3_DATA(LC3_FREQ_ANY, LC3_DURATION_ANY, - 3u, 30, 240)), + 3u, 30, 240), + UTIL_IOV_INIT()), + /* Broadcast LC3 Source: * * Frequencies: 8Khz 11Khz 16Khz 22Khz 24Khz 32Khz 44.1Khz 48Khz @@ -1212,7 +1206,8 @@ static const struct capabilities { */ CODEC_CAPABILITIES(BCAA_SERVICE_UUID, LC3_ID, LC3_DATA(LC3_FREQ_ANY, LC3_DURATION_ANY, - 3u, 30, 240)), + 3u, 30, 240), + UTIL_IOV_INIT()), /* Broadcast LC3 Sink: * @@ -1223,7 +1218,8 @@ static const struct capabilities { */ CODEC_CAPABILITIES(BAA_SERVICE_UUID, LC3_ID, LC3_DATA(LC3_FREQ_ANY, LC3_DURATION_ANY, - 3u, 30, 240)), + 3u, 30, 240), + UTIL_IOV_INIT()), }; struct codec_qos { @@ -1258,32 +1254,36 @@ static struct codec_preset sbc_presets[] = { * mono, and 512kb/s for two-channel modes. */ SBC_PRESET("MQ_MONO_44_1", - CODEC_DATA(0x28, 0x15, 2, SBC_BITPOOL_MQ_MONO_44100)), + UTIL_IOV_INIT(0x28, 0x15, 2, SBC_BITPOOL_MQ_MONO_44100)), SBC_PRESET("MQ_MONO_48", - CODEC_DATA(0x18, 0x15, 2, SBC_BITPOOL_MQ_MONO_48000)), + UTIL_IOV_INIT(0x18, 0x15, 2, SBC_BITPOOL_MQ_MONO_48000)), SBC_PRESET("MQ_STEREO_44_1", - CODEC_DATA(0x21, 0x15, 2, SBC_BITPOOL_MQ_JOINT_STEREO_44100)), + UTIL_IOV_INIT(0x21, 0x15, 2, + SBC_BITPOOL_MQ_JOINT_STEREO_44100)), SBC_PRESET("MQ_STEREO_48", - CODEC_DATA(0x11, 0x15, 2, SBC_BITPOOL_MQ_JOINT_STEREO_48000)), + UTIL_IOV_INIT(0x11, 0x15, 2, + SBC_BITPOOL_MQ_JOINT_STEREO_48000)), SBC_PRESET("HQ_MONO_44_1", - CODEC_DATA(0x28, 0x15, 2, SBC_BITPOOL_HQ_MONO_44100)), + UTIL_IOV_INIT(0x28, 0x15, 2, SBC_BITPOOL_HQ_MONO_44100)), SBC_PRESET("HQ_MONO_48", - CODEC_DATA(0x18, 0x15, 2, SBC_BITPOOL_HQ_MONO_48000)), + UTIL_IOV_INIT(0x18, 0x15, 2, SBC_BITPOOL_HQ_MONO_48000)), SBC_PRESET("HQ_STEREO_44_1", - CODEC_DATA(0x21, 0x15, 2, SBC_BITPOOL_HQ_JOINT_STEREO_44100)), + UTIL_IOV_INIT(0x21, 0x15, 2, + SBC_BITPOOL_HQ_JOINT_STEREO_44100)), SBC_PRESET("HQ_STEREO_48", - CODEC_DATA(0x11, 0x15, 2, SBC_BITPOOL_HQ_JOINT_STEREO_48000)), + UTIL_IOV_INIT(0x11, 0x15, 2, + SBC_BITPOOL_HQ_JOINT_STEREO_48000)), /* Higher bitrates not recommended by A2DP spec, it dual channel to * avoid going above 53 bitpool: * * https://habr.com/en/post/456476/ * https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/1092 */ - SBC_PRESET("XQ_DUAL_44_1", CODEC_DATA(0x24, 0x15, 2, 43)), - SBC_PRESET("XQ_DUAL_48", CODEC_DATA(0x14, 0x15, 2, 39)), + SBC_PRESET("XQ_DUAL_44_1", UTIL_IOV_INIT(0x24, 0x15, 2, 43)), + SBC_PRESET("XQ_DUAL_48", UTIL_IOV_INIT(0x14, 0x15, 2, 39)), /* Ultra high bitpool that fits in 512 kbps mandatory bitrate */ - SBC_PRESET("UQ_STEREO_44_1", CODEC_DATA(0x21, 0x15, 2, 64)), - SBC_PRESET("UQ_STEREO_48", CODEC_DATA(0x11, 0x15, 2, 58)), + SBC_PRESET("UQ_STEREO_44_1", UTIL_IOV_INIT(0x21, 0x15, 2, 64)), + SBC_PRESET("UQ_STEREO_48", UTIL_IOV_INIT(0x11, 0x15, 2, 58)), }; #define QOS_CONFIG(_interval, _framing, _phy, _sdu, _rtn, _latency, _delay) \ @@ -1328,16 +1328,16 @@ static struct codec_preset sbc_presets[] = { QOS_FRAMED_2M(10000u, _sdu, _rtn, _latency, _delay) #define LC3_PRESET_DATA(_freq, _duration, _len) \ - CODEC_DATA(0x02, LC3_CONFIG_FREQ, _freq, \ - 0x02, LC3_CONFIG_DURATION, _duration, \ - 0x03, LC3_CONFIG_FRAME_LEN, _len, _len >> 8) + UTIL_IOV_INIT(0x02, LC3_CONFIG_FREQ, _freq, \ + 0x02, LC3_CONFIG_DURATION, _duration, \ + 0x03, LC3_CONFIG_FRAME_LEN, _len, _len >> 8) #define LC3_PRESET_DATA_ALL(_freq, _duration, _alloc, _len) \ - CODEC_DATA(0x02, LC3_CONFIG_FREQ, _freq, \ - 0x02, LC3_CONFIG_DURATION, _duration, \ - 0x05, LC3_CONFIG_CHAN_ALLOC, _alloc, _alloc >> 8, \ - _alloc >> 16, _alloc >> 24, \ - 0x03, LC3_CONFIG_FRAME_LEN, _len, _len >> 8) + UTIL_IOV_INIT(0x02, LC3_CONFIG_FREQ, _freq, \ + 0x02, LC3_CONFIG_DURATION, _duration, \ + 0x05, LC3_CONFIG_CHAN_ALLOC, _alloc, _alloc >> 8, \ + _alloc >> 16, _alloc >> 24, \ + 0x03, LC3_CONFIG_FRAME_LEN, _len, _len >> 8) #define LC3_PRESET_8KHZ(_duration, _len) \ LC3_PRESET_DATA(LC3_CONFIG_FREQ_8KHZ, _duration, _len) -- 2.43.0