1*9cab9fdeSChristos Margiolis /* $NetBSD$ */ 2*9cab9fdeSChristos Margiolis 3*9cab9fdeSChristos Margiolis /*- 4*9cab9fdeSChristos Margiolis * Copyright (c) 2015 Nathanial Sloss <nathanialsloss@yahoo.com.au> 5*9cab9fdeSChristos Margiolis * 6*9cab9fdeSChristos Margiolis * This software is dedicated to the memory of - 7*9cab9fdeSChristos Margiolis * Baron James Anlezark (Barry) - 1 Jan 1949 - 13 May 2012. 8*9cab9fdeSChristos Margiolis * 9*9cab9fdeSChristos Margiolis * Barry was a man who loved his music. 10*9cab9fdeSChristos Margiolis * 11*9cab9fdeSChristos Margiolis * Redistribution and use in source and binary forms, with or without 12*9cab9fdeSChristos Margiolis * modification, are permitted provided that the following conditions 13*9cab9fdeSChristos Margiolis * are met: 14*9cab9fdeSChristos Margiolis * 1. Redistributions of source code must retain the above copyright 15*9cab9fdeSChristos Margiolis * notice, this list of conditions and the following disclaimer. 16*9cab9fdeSChristos Margiolis * 2. Redistributions in binary form must reproduce the above copyright 17*9cab9fdeSChristos Margiolis * notice, this list of conditions and the following disclaimer in the 18*9cab9fdeSChristos Margiolis * documentation and/or other materials provided with the distribution. 19*9cab9fdeSChristos Margiolis * 20*9cab9fdeSChristos Margiolis * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21*9cab9fdeSChristos Margiolis * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22*9cab9fdeSChristos Margiolis * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23*9cab9fdeSChristos Margiolis * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24*9cab9fdeSChristos Margiolis * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25*9cab9fdeSChristos Margiolis * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26*9cab9fdeSChristos Margiolis * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27*9cab9fdeSChristos Margiolis * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28*9cab9fdeSChristos Margiolis * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29*9cab9fdeSChristos Margiolis * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30*9cab9fdeSChristos Margiolis * POSSIBILITY OF SUCH DAMAGE. 31*9cab9fdeSChristos Margiolis */ 32*9cab9fdeSChristos Margiolis 33*9cab9fdeSChristos Margiolis #ifndef _AVDTP_SIGNAL_H_ 34*9cab9fdeSChristos Margiolis #define _AVDTP_SIGNAL_H_ 35*9cab9fdeSChristos Margiolis 36*9cab9fdeSChristos Margiolis #include <stdint.h> 37*9cab9fdeSChristos Margiolis #include <stdbool.h> 38*9cab9fdeSChristos Margiolis 39*9cab9fdeSChristos Margiolis /* Our endpoint. */ 40*9cab9fdeSChristos Margiolis #define INTSEP 8 41*9cab9fdeSChristos Margiolis #define ACPSEP 8 42*9cab9fdeSChristos Margiolis 43*9cab9fdeSChristos Margiolis /* AVDTP signals. */ 44*9cab9fdeSChristos Margiolis 45*9cab9fdeSChristos Margiolis #define AVDTP_DISCOVER 0x01 46*9cab9fdeSChristos Margiolis #define AVDTP_GET_CAPABILITIES 0x02 47*9cab9fdeSChristos Margiolis #define AVDTP_SET_CONFIGURATION 0x03 48*9cab9fdeSChristos Margiolis #define AVDTP_GET_CONFIGURATION 0x04 49*9cab9fdeSChristos Margiolis #define AVDTP_RECONFIGURE 0x05 50*9cab9fdeSChristos Margiolis #define AVDTP_OPEN 0x06 51*9cab9fdeSChristos Margiolis #define AVDTP_START 0x07 52*9cab9fdeSChristos Margiolis #define AVDTP_CLOSE 0x08 53*9cab9fdeSChristos Margiolis #define AVDTP_SUSPEND 0x09 54*9cab9fdeSChristos Margiolis #define AVDTP_ABORT 0x0a 55*9cab9fdeSChristos Margiolis #define AVDTP_SECUURITY_CONTROL 0x0b 56*9cab9fdeSChristos Margiolis 57*9cab9fdeSChristos Margiolis /* Signal Command & Response Header Masks. */ 58*9cab9fdeSChristos Margiolis 59*9cab9fdeSChristos Margiolis #define TRANSACTIONLABEL 0xf0 60*9cab9fdeSChristos Margiolis #define TRANSACTIONLABEL_S 4 61*9cab9fdeSChristos Margiolis #define SIGNALID_MASK 0x3f 62*9cab9fdeSChristos Margiolis #define PACKETTYPE 0x0c 63*9cab9fdeSChristos Margiolis #define PACKETTYPE_S 0x02 64*9cab9fdeSChristos Margiolis #define MESSAGETYPE 0x03 65*9cab9fdeSChristos Margiolis #define SIGNALIDENTIFIER 0x3f 66*9cab9fdeSChristos Margiolis #define DISCOVER_SEP_IN_USE 0x02 67*9cab9fdeSChristos Margiolis #define DISCOVER_IS_SINK 0x08 68*9cab9fdeSChristos Margiolis 69*9cab9fdeSChristos Margiolis /* Packet Types */ 70*9cab9fdeSChristos Margiolis #define singlePacket 0x0 71*9cab9fdeSChristos Margiolis #define startPacket 0x1 72*9cab9fdeSChristos Margiolis #define continuePacket 0x2 73*9cab9fdeSChristos Margiolis #define endPacket 0x3 74*9cab9fdeSChristos Margiolis 75*9cab9fdeSChristos Margiolis /* Message Types */ 76*9cab9fdeSChristos Margiolis #define COMMAND 0x0 77*9cab9fdeSChristos Margiolis #define RESPONSEACCEPT 0x2 78*9cab9fdeSChristos Margiolis #define RESPONSEREJECT 0x3 79*9cab9fdeSChristos Margiolis 80*9cab9fdeSChristos Margiolis /* Response general error/success lengths */ 81*9cab9fdeSChristos Margiolis #define AVDTP_LEN_SUCCESS 2 82*9cab9fdeSChristos Margiolis #define AVDTP_LEN_ERROR 3 83*9cab9fdeSChristos Margiolis 84*9cab9fdeSChristos Margiolis /* Error codes */ 85*9cab9fdeSChristos Margiolis #define BAD_HEADER_FORMAT 0x01 86*9cab9fdeSChristos Margiolis #define BAD_LENGTH 0x11 87*9cab9fdeSChristos Margiolis #define BAD_ACP_SEID 0x12 88*9cab9fdeSChristos Margiolis #define SEP_IN_USE 0x13 89*9cab9fdeSChristos Margiolis #define SEP_NOT_IN_USE 0x14 90*9cab9fdeSChristos Margiolis #define BAD_SERV_CATAGORY 0x17 91*9cab9fdeSChristos Margiolis #define BAD_PAYLOAD_FORMAT 0x18 92*9cab9fdeSChristos Margiolis #define NOT_SUPPORTED_COMMAND 0x19 93*9cab9fdeSChristos Margiolis #define INVALID_CAPABILITIES 0x1a 94*9cab9fdeSChristos Margiolis 95*9cab9fdeSChristos Margiolis #define BAD_RECOVERY_TYPE 0x22 96*9cab9fdeSChristos Margiolis #define BAD_MEDIA_TRANSPORT_FORMAT 0x23 97*9cab9fdeSChristos Margiolis #define BAD_RECOVERY_FORMAT 0x25 98*9cab9fdeSChristos Margiolis #define BAD_ROHC_FORMAT 0x26 99*9cab9fdeSChristos Margiolis #define BAD_CP_FORMAT 0x27 100*9cab9fdeSChristos Margiolis #define BAD_MULTIPLEXING_FORMAT 0x28 101*9cab9fdeSChristos Margiolis #define UNSUPPORTED_CONFIGURATION 0x29 102*9cab9fdeSChristos Margiolis #define BAD_STATE 0x31 103*9cab9fdeSChristos Margiolis 104*9cab9fdeSChristos Margiolis /* Service Capabilities Field. */ 105*9cab9fdeSChristos Margiolis #define mediaTransport 0x1 106*9cab9fdeSChristos Margiolis #define reporting 0x2 107*9cab9fdeSChristos Margiolis #define recovery 0x3 108*9cab9fdeSChristos Margiolis #define contentProtection 0x4 109*9cab9fdeSChristos Margiolis #define headerCompression 0x5 110*9cab9fdeSChristos Margiolis #define multiplexing 0x6 111*9cab9fdeSChristos Margiolis #define mediaCodec 0x7 112*9cab9fdeSChristos Margiolis 113*9cab9fdeSChristos Margiolis /* Media Codec Capabilities */ 114*9cab9fdeSChristos Margiolis #define mediaCodecSbc 0x00 115*9cab9fdeSChristos Margiolis #define mediaCodecMpeg1 0x01 116*9cab9fdeSChristos Margiolis #define mediaCodecMpeg2 0x02 117*9cab9fdeSChristos Margiolis 118*9cab9fdeSChristos Margiolis #define SBC_CODEC_ID 0x0 119*9cab9fdeSChristos Margiolis #define mediaTypeAudio 0x0 120*9cab9fdeSChristos Margiolis 121*9cab9fdeSChristos Margiolis struct bt_config; 122*9cab9fdeSChristos Margiolis 123*9cab9fdeSChristos Margiolis int avdtpSendAccept(int, uint8_t, uint8_t); 124*9cab9fdeSChristos Margiolis int avdtpSendReject(int, uint8_t, uint8_t); 125*9cab9fdeSChristos Margiolis int avdtpSendDiscResponseAudio(int, uint8_t, uint8_t, uint8_t); 126*9cab9fdeSChristos Margiolis int avdtpDiscoverAndConfig(struct bt_config *, bool); 127*9cab9fdeSChristos Margiolis int avdtpSetConfiguration(int, uint8_t, uint8_t *, int); 128*9cab9fdeSChristos Margiolis int avdtpOpen(int, uint8_t); 129*9cab9fdeSChristos Margiolis int avdtpStart(int, uint8_t); 130*9cab9fdeSChristos Margiolis int avdtpClose(int, uint8_t); 131*9cab9fdeSChristos Margiolis int avdtpSuspend(int, uint8_t); 132*9cab9fdeSChristos Margiolis int avdtpAbort(int, uint8_t); 133*9cab9fdeSChristos Margiolis 134*9cab9fdeSChristos Margiolis /* Return < 0 if error, processed signal otherwise. */ 135*9cab9fdeSChristos Margiolis int avdtpACPHandlePacket(struct bt_config *cfg); 136*9cab9fdeSChristos Margiolis /* Free state allocated in avdtpACPHandlePacket(), if any. */ 137*9cab9fdeSChristos Margiolis void avdtpACPFree(struct bt_config *cfg); 138*9cab9fdeSChristos Margiolis 139*9cab9fdeSChristos Margiolis #endif /* _AVDTP_SIGNAL_H_ */ 140