From 6f3c4bf4250ab1d30a7d60dd1620d7ff4ac03e62 Mon Sep 17 00:00:00 2001 From: Arun Jagadish Date: Wed, 9 Nov 2016 16:34:04 +0530 Subject: [PATCH] Bluetooth: AVDTP: SEP Definition Added SEP structure SEP Registration function Change-Id: Ib8c4a1753c85390009c154a50a1a1a2f2794e8a2 Signed-off-by: Arun Jagadish --- include/bluetooth/avdtp.h | 55 ++++++++++++++++++++++++++ subsys/bluetooth/host/avdtp.c | 30 ++++++++++++++ subsys/bluetooth/host/avdtp_internal.h | 9 +++++ 3 files changed, 94 insertions(+) create mode 100644 include/bluetooth/avdtp.h diff --git a/include/bluetooth/avdtp.h b/include/bluetooth/avdtp.h new file mode 100644 index 00000000000..b750fb26899 --- /dev/null +++ b/include/bluetooth/avdtp.h @@ -0,0 +1,55 @@ +/** @file + * @brief Audio/Video Distribution Transport Protocol header. + */ + +/* + * Copyright (c) 2015-2016 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef __BT_AVDTP_H +#define __BT_AVDTP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** @brief AVDTP SEID Information */ +struct bt_avdtp_seid_info { + /** Stream End Point ID */ + uint8_t id:6; + /** End Point usage status */ + uint8_t inuse:1; + /** Reserved */ + uint8_t rfa0:1; + /** Media-type of the End Point */ + uint8_t media_type:4; + /** TSEP of the End Point */ + uint8_t tsep:1; + /** Reserved */ + uint8_t rfa1:3; +} __packed; + +/** @brief AVDTP Local SEP*/ +struct bt_avdtp_seid_lsep { + /** Stream End Point information */ + struct bt_avdtp_seid_info sep; + /** Pointer to next local Stream End Point structure */ + struct bt_avdtp_seid_lsep *next; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* __BT_AVDTP_H */ diff --git a/subsys/bluetooth/host/avdtp.c b/subsys/bluetooth/host/avdtp.c index 29a28286869..3d477e2b9a5 100644 --- a/subsys/bluetooth/host/avdtp.c +++ b/subsys/bluetooth/host/avdtp.c @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -26,6 +27,7 @@ #include #include #include +#include #include "l2cap_internal.h" #include "avdtp_internal.h" @@ -48,6 +50,8 @@ static struct bt_avdtp bt_avdtp_pool[CONFIG_BLUETOOTH_AVDTP_CONN]; static struct bt_avdtp_event_cb *event_cb; +static struct bt_avdtp_seid_lsep *lseps; + #define AVDTP_CHAN(_ch) CONTAINER_OF(_ch, struct bt_avdtp, br_chan.chan) /* L2CAP Interface callbacks */ @@ -154,6 +158,32 @@ int bt_avdtp_register(struct bt_avdtp_event_cb *cb) return 0; } +int bt_avdtp_register_sep(uint8_t media_type, uint8_t role, + struct bt_avdtp_seid_lsep *lsep) +{ + BT_DBG(""); + + static uint8_t bt_avdtp_seid = BT_AVDTP_MIN_SEID; + + if (!lsep) { + return -EIO; + } + + if (bt_avdtp_seid == BT_AVDTP_MAX_SEID) { + return -EIO; + } + + lsep->sep.id = bt_avdtp_seid++; + lsep->sep.inuse = 0; + lsep->sep.media_type = media_type; + lsep->sep.tsep = role; + + lsep->next = lseps; + lseps = lsep; + + return 0; +} + /* init function */ int bt_avdtp_init(void) { diff --git a/subsys/bluetooth/host/avdtp_internal.h b/subsys/bluetooth/host/avdtp_internal.h index 0f1aa0f7a7c..573a447f5e9 100644 --- a/subsys/bluetooth/host/avdtp_internal.h +++ b/subsys/bluetooth/host/avdtp_internal.h @@ -16,6 +16,8 @@ * limitations under the License. */ +#include + /* @brief A2DP ROLE's */ #define A2DP_SRC_ROLE 0x00 #define A2DP_SNK_ROLE 0x01 @@ -97,6 +99,9 @@ #define BT_AVDTP_MIN_MTU 48 #define BT_AVDTP_MAX_MTU CONFIG_BLUETOOTH_L2CAP_IN_MTU +#define BT_AVDTP_MIN_SEID 0x01 +#define BT_AVDTP_MAX_SEID 0x3E + /* Helper to calculate needed outgoing buffer size. */ #define BT_AVDTP_BUF_SIZE(mtu) (CONFIG_BLUETOOTH_HCI_SEND_RESERVE + \ sizeof(struct bt_hci_acl_hdr) + \ @@ -156,3 +161,7 @@ int bt_avdtp_connect(struct bt_conn *conn, struct bt_avdtp *session); /* AVDTP disconnect */ int bt_avdtp_disconnect(struct bt_avdtp *session); + +/* AVDTP SEP register function */ +int bt_avdtp_register_sep(uint8_t media_type, uint8_t role, + struct bt_avdtp_seid_lsep *sep);