Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1951060iog; Thu, 16 Jun 2022 18:18:31 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uiAM1t5QGWk5gBgs+PpQGyGFp0DUIMyw0AAMr3pZZVr1SzTojGKzPYyznFdoci8KdX6UIZ X-Received: by 2002:a05:6402:4410:b0:434:f35f:132e with SMTP id y16-20020a056402441000b00434f35f132emr9554221eda.215.1655428711438; Thu, 16 Jun 2022 18:18:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655428711; cv=none; d=google.com; s=arc-20160816; b=u3MnJa0RMLwWVaHafHw4TCB5UXfl6xe4126q7Qg5UIxqyNK1/Pbt9VN80YBBQUNrzF 185y7dQ1Y9rUKRff7wiXlJDQtq5tRZFJjqxMuoHUMc0qExJ4gC2euokhA2s1SnVLrx9K CgjgWlOZzVb7y/YMME3YbZBZlf3Q2MMflmuSuA+yNA2Gsk7+coIxl0FvdAuDoCkoQzlS JYrZ2RXbgy3e1h0e6MsspNcbxoL/A3eiQFU9QdwodbK3Aabjb/MWptpEvrCHjxKzTVEk 1cvDBRtBV5Zns9KTHjEeb7A/q361/EhztVqvT8uAdc6GfWI++HEN/8ystRoCQ3ws19bZ dvNA== 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 :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=ngvRkXqu/S3FB6n+X5RMXZi32SU2C1O7n4EzOBlNzLo=; b=q7ECqPNc6GDXiG4MQoPQ7ywRiDHx8vPy56Upv5JgPId6fgQ0zp06j5TMJAB+jC2hBl dgmbygvDlqveDiUP82ypVzm4WESdeTC4FpZGyR3oa+ok/nbhHIGbQftWFmSqK9TsGkMS UQ0/e5kwlteCNOLMvpJltgWKy83Fs+i2bFwk00q7Hb5y6q/MB/oe79PJM4Ye51kvMf4t YniB1/xoPXmqrbwtqdgpWKwnZmZkTo3C1262p5E7kObwQIFgQ/PN11yQICeHi2wQXWQ3 dOiZTOvnS2JWYswB64NBcR0AZxSTyGVFtgo2vjLsM8RK84qLV6MHoiagpxVcfZT2NQT/ fljA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ptALWP4V; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r30-20020a50c01e000000b0042ddac25209si4411204edb.92.2022.06.16.18.17.55; Thu, 16 Jun 2022 18:18:31 -0700 (PDT) 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=@gmail.com header.s=20210112 header.b=ptALWP4V; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232424AbiFQAuE (ORCPT + 99 others); Thu, 16 Jun 2022 20:50:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229734AbiFQAuD (ORCPT ); Thu, 16 Jun 2022 20:50:03 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AD4761636 for ; Thu, 16 Jun 2022 17:50:02 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id b12-20020a17090a6acc00b001ec2b181c98so1644292pjm.4 for ; Thu, 16 Jun 2022 17:50:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ngvRkXqu/S3FB6n+X5RMXZi32SU2C1O7n4EzOBlNzLo=; b=ptALWP4VzR+cziSAJYBLWI2JgXI3DaOjRqxfvIw0+0u/H+BVWRMtsmNE3aDQc2I+3t UWoN3hBFb1RNbIW2Q9oksKAREky8E7ltxoX5upstKFqLgTCgLyysvoQ5SDNTIJVkmUZ8 qGuGSWNlVTl77UPrBPaQTEC0IermFBBvcyycsUg6czNAYwcahVgDsrLfJesNmb4HlhU6 hPU65/n5eDHYs5zWKDC49I1Ha/peVGA5XwypFoJM9zfm3sqTNDr2+M008wk4bxcHQAXv RSrWqfFIQDaHUDSZlZFnMxzpIO41oIZS9TP0beHJpGZLfFsqhvnWpXcV5a83DK86u80M 13Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ngvRkXqu/S3FB6n+X5RMXZi32SU2C1O7n4EzOBlNzLo=; b=fntzP3ODurIZEoJG9MjUV1ku0SjeyMZ2cqhT5r6q2l0VrvMxHA7DzbghKxPo4oR7pU Kdv4YD8XzLBrPs5Nj5i8TsZRhta9rbbXJ/+VpnP/4qGgeZ8dhRknrlkMhjb721+qL6zx FeJMh6aTjDqC13EXQa/f7POnJneU0pH+C5PXCtjrXtYZP4M0hKjYDxZfhQjn8XT4NKrp ZicRW+Ya3uXgkIcV3ylBGsD5oGYDLIVqvCjsY0i0g6TygRU7tyT+7qNXY0XHW3vBxgMI gOPQogVJpNOLhuCxx8OBfAUaiqgd/h+16Jl7J95msE2X+l6WHwHlVNR03TeIFVITCx8E uQog== X-Gm-Message-State: AJIora9DC4XA60hRAbo11MLLddxFTGA0wgvBJamogSs9+AREo3Yd9or5 e5vojEZ9hQ+YHE9lJ2zJl2a5qL5f0dU= X-Received: by 2002:a17:902:b218:b0:168:de55:dfba with SMTP id t24-20020a170902b21800b00168de55dfbamr6995636plr.134.1655427001685; Thu, 16 Jun 2022 17:50:01 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id u23-20020a170902a61700b0015e8d4eb25asm338996plq.164.2022.06.16.17.50.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 17:50:00 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 3/4] monitor/att: Add decoding support for PAC Audio Context Date: Thu, 16 Jun 2022 17:49:56 -0700 Message-Id: <20220617004957.1148939-3-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220617004957.1148939-1-luiz.dentz@gmail.com> References: <20220617004957.1148939-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 From: Luiz Augusto von Dentz This adds decoding support for PAC Audio Context attributes: > ACL Data RX: Handle 42 flags 0x02 dlen 9 Channel: 65 len 5 sdu 3 [PSM 39 mode Enhanced Credit (0x81)] {chan 1} ATT: Read Request (0x0a) len 2 Handle: 0x0026 Type: Supported Audio Contexts (0x2bce) < ACL Data TX: Handle 42 flags 0x00 dlen 11 Channel: 64 len 7 sdu 5 [PSM 39 mode Enhanced Credit (0x81)] {chan 1} ATT: Read Response (0x0b) len 4 Value: ff0f0e00 Handle: 0x0026 Type: Supported Audio Contexts (0x2bce) Sink Context: 0x0fff Unspecified (0x0001) Conversational (0x0002) Media (0x0004) Game (0x0008) Instructional (0x0010) Voice Assistants (0x0020) Live (0x0040) Sound Effects (0x0080) Notifications (0x0100) Ringtone (0x0200) Alerts (0x0400) Emergency alarm (0x0800) Source Context: 0x000e Conversational (0x0002) Media (0x0004) Game (0x0008) --- monitor/att.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/monitor/att.c b/monitor/att.c index 8b47cbd9f..21fa5dde3 100644 --- a/monitor/att.c +++ b/monitor/att.c @@ -1118,6 +1118,69 @@ static void pac_loc_notify(const struct l2cap_frame *frame) print_loc_pac(frame); } +static const struct bitfield_data pac_context_table[] = { + { 0, "Unspecified (0x0001)" }, + { 1, "Conversational (0x0002)" }, + { 2, "Media (0x0004)" }, + { 3, "Game (0x0008)" }, + { 4, "Instructional (0x0010)" }, + { 5, "Voice Assistants (0x0020)" }, + { 6, "Live (0x0040)" }, + { 7, "Sound Effects (0x0080)" }, + { 8, "Notifications (0x0100)" }, + { 9, "Ringtone (0x0200)" }, + { 10, "Alerts (0x0400)" }, + { 11, "Emergency alarm (0x0800)" }, + { 12, "RFU (0x1000)" }, + { 13, "RFU (0x2000)" }, + { 14, "RFU (0x4000)" }, + { 15, "RFU (0x8000)" }, +}; + +static void print_pac_context(const struct l2cap_frame *frame) +{ + uint16_t snk, src; + uint16_t mask; + + if (!l2cap_frame_get_le16((void *)frame, &snk)) { + print_text(COLOR_ERROR, " value: invalid size"); + goto done; + } + + print_field(" Sink Context: 0x%4.4x", snk); + + mask = print_bitfield(4, snk, pac_context_table); + if (mask) + print_text(COLOR_WHITE_BG, " Unknown fields (0x%4.4x)", + mask); + + if (!l2cap_frame_get_le16((void *)frame, &src)) { + print_text(COLOR_ERROR, " sink: invalid size"); + goto done; + } + + print_field(" Source Context: 0x%4.4x", src); + + mask = print_bitfield(4, src, pac_context_table); + if (mask) + print_text(COLOR_WHITE_BG, " Unknown fields (0x%4.4x)", + mask); + +done: + if (frame->size) + print_hex_field(" Data", frame->data, frame->size); +} + +static void pac_context_read(const struct l2cap_frame *frame) +{ + print_pac_context(frame); +} + +static void pac_context_notify(const struct l2cap_frame *frame) +{ + print_pac_context(frame); +} + #define GATT_HANDLER(_uuid, _read, _write, _notify) \ { \ .uuid = { \ @@ -1143,6 +1206,8 @@ struct gatt_handler { GATT_HANDLER(0x2bca, pac_loc_read, NULL, pac_loc_notify), GATT_HANDLER(0x2bcb, pac_read, NULL, pac_notify), GATT_HANDLER(0x2bcc, pac_loc_read, NULL, pac_loc_notify), + GATT_HANDLER(0x2bcd, pac_context_read, NULL, pac_context_notify), + GATT_HANDLER(0x2bce, pac_context_read, NULL, pac_context_notify), }; static struct gatt_handler *get_handler(struct gatt_db_attribute *attr) -- 2.35.3