Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2390441pxb; Fri, 8 Oct 2021 06:55:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSS6lCxch2329JYMLHbPOciI846FinZ15O8sCOfAt9ikKe6MJG98nVmmOf4Kyzs5Ss3Knl X-Received: by 2002:a17:90b:4f46:: with SMTP id pj6mr12034287pjb.63.1633701314132; Fri, 08 Oct 2021 06:55:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633701314; cv=none; d=google.com; s=arc-20160816; b=MUAjX2Q0YbxFFCZBTyPvkbIAxIzsVrIrLt4S1FZQ5OkoEldjqjgCtdV2Nja8zFqsTl CTB99m1k3UWGreS/6pqtU25jdvzjz2JyK7QQvKB1lctzdKSd+U+8zrEYQY3PUmzMmnC+ NePXKqRKHPeForWQGTivYr/Qp1Qpwr1N0yQkXiw5jSmxVQOtk9Fbv3KrHMfd1kPjMoZd 04jZuLA/GjOz9jE+InlNulq4cOQmhHiPUzwIINTVLfDrIFGLtXI2xxnEt+UT8UOEb3b7 mdeA3ABGZdngzAlF9EWiqm8r3UvBkEI6/d9chtwfwxdvYIAzuq1H+08ZbrkkDlDaE0NH icLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=Z8zfh2cafdTBkOvf0HZNW74YHKyeMfzmoxnhIC7wVHY=; b=tQAu0q3iJf2lokniL4ZXwBIZnciM7ESyDrgkUTrekcaE3BMzWsLbOJtA9Pr/I85lA1 FDkdG10RFVE7g4iiJ3mixv/Xl7MpTAvEpvsG6kozjKZmd2b8aazn2vZVPlZCatelzYdl fxbxvGfYbwyBgrMVR4dFH8BPN0KVsOCUyZSr8Xq1YiXXIVvP9Y51uZEg+KNgr7mDZBjV rXPFkxTTVu0nq85l/bieGoJr+8ovdTw7WINAFYvt0WDw2r1XKInb9rV5LeN1rYobTE0f xQieBJWkLJY+bkXZaEiZxWlj1TIX+X2h0zcO0d3p5YmZw0GIcyZ12DPQelzdKmq8N5B3 bsfw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u1si3369745pgi.245.2021.10.08.06.54.35; Fri, 08 Oct 2021 06:55:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234083AbhJHNzV (ORCPT + 99 others); Fri, 8 Oct 2021 09:55:21 -0400 Received: from mga18.intel.com ([134.134.136.126]:60420 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233283AbhJHNzU (ORCPT ); Fri, 8 Oct 2021 09:55:20 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10130"; a="213457760" X-IronPort-AV: E=Sophos;i="5.85,357,1624345200"; d="scan'208";a="213457760" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Oct 2021 06:53:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,357,1624345200"; d="scan'208";a="624744956" Received: from intel-lenovo-legion-y540-15irh-pg0.iind.intel.com ([10.224.186.95]) by fmsmga001.fm.intel.com with ESMTP; 08 Oct 2021 06:53:23 -0700 From: Kiran K To: linux-bluetooth@vger.kernel.org Cc: ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, luiz.von.dentz@intel.com, Kiran K Subject: [PATCH v1 2/7] Bluetooth: Support reading of codecs supported over l2cap socket Date: Fri, 8 Oct 2021 19:28:48 +0530 Message-Id: <20211008135853.8604-2-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211008135853.8604-1-kiran.k@intel.com> References: <20211008135853.8604-1-kiran.k@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Codecs supported for A2DP offload use case are returned over l2cap socket. Add BT_CODEC option to getsockopt to return the codecs. Signed-off-by: Kiran K Change-Id: I1592f3bb1167771bfb2cb9114438e473ea372c90 --- include/net/bluetooth/hci.h | 1 + net/bluetooth/l2cap_sock.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 63065bc01b76..451d491f7f68 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -2666,6 +2666,7 @@ static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb) #define hci_iso_data_flags(h) ((h) >> 14) /* codec transport types */ +#define HCI_TRANSPORT_ACL 0x00 #define HCI_TRANSPORT_SCO_ESCO 0x01 /* le24 support */ diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 160c016a5dfb..06f8ea681972 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -36,6 +36,7 @@ #include #include "smp.h" +#include "hci_codec.h" static struct bt_sock_list l2cap_sk_list = { .lock = __RW_LOCK_UNLOCKED(l2cap_sk_list.lock) @@ -549,6 +550,7 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, struct bt_power pwr; u32 phys; int len, mode, err = 0; + struct hci_dev *hdev; BT_DBG("sk %p", sk); @@ -685,6 +687,18 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, err = -EFAULT; break; + case BT_CODEC: + hdev = hci_get_route(BDADDR_ANY, &chan->src, BDADDR_BREDR); + if (!hdev) { + err = -EBADFD; + break; + } + + err = hci_get_supported_codecs(hdev, HCI_TRANSPORT_ACL, optval, + optlen, len); + hci_dev_put(hdev); + break; + default: err = -ENOPROTOOPT; break; -- 2.17.1