| 1 |
/* |
| 2 |
* Copyright (c) 2017, Intel Corporation |
| 3 |
* |
| 4 |
* Redistribution and use in source and binary forms, with or without |
| 5 |
* modification, are permitted provided that the following conditions are met: |
| 6 |
* |
| 7 |
* * Redistributions of source code must retain the above copyright notice, |
| 8 |
* this list of conditions and the following disclaimer. |
| 9 |
* * Redistributions in binary form must reproduce the above copyright |
| 10 |
* notice, this list of conditions and the following disclaimer in the |
| 11 |
* documentation and/or other materials provided with the distribution. |
| 12 |
* * Neither the name of Intel Corporation nor the names of its contributors |
| 13 |
* may be used to endorse or promote products derived from this software |
| 14 |
* without specific prior written permission. |
| 15 |
* |
| 16 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 17 |
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 18 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 19 |
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE |
| 20 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 21 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 22 |
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 23 |
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 24 |
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 25 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 |
*/ |
| 27 |
|
| 28 |
#pragma once |
| 29 |
|
| 30 |
#include <errno.h> |
| 31 |
#include <stdint.h> |
| 32 |
|
| 33 |
#ifdef __cplusplus |
| 34 |
extern "C" { |
| 35 |
#endif |
| 36 |
|
| 37 |
/* AAF PCM 'format' field values. */ |
| 38 |
#define AVTP_AAF_FORMAT_USER 0x00 |
| 39 |
#define AVTP_AAF_FORMAT_FLOAT_32BIT 0x01 |
| 40 |
#define AVTP_AAF_FORMAT_INT_32BIT 0x02 |
| 41 |
#define AVTP_AAF_FORMAT_INT_24BIT 0x03 |
| 42 |
#define AVTP_AAF_FORMAT_INT_16BIT 0x04 |
| 43 |
#define AVTP_AAF_FORMAT_AES3_32BIT 0x05 |
| 44 |
|
| 45 |
/* AAF PCM 'nsr' (nominal sample rate) field values. */ |
| 46 |
#define AVTP_AAF_PCM_NSR_USER 0x00 |
| 47 |
#define AVTP_AAF_PCM_NSR_8KHZ 0x01 |
| 48 |
#define AVTP_AAF_PCM_NSR_16KHZ 0x02 |
| 49 |
#define AVTP_AAF_PCM_NSR_32KHZ 0x03 |
| 50 |
#define AVTP_AAF_PCM_NSR_44_1KHZ 0x04 |
| 51 |
#define AVTP_AAF_PCM_NSR_48KHZ 0x05 |
| 52 |
#define AVTP_AAF_PCM_NSR_88_2KHZ 0x06 |
| 53 |
#define AVTP_AAF_PCM_NSR_96KHZ 0x07 |
| 54 |
#define AVTP_AAF_PCM_NSR_176_4KHZ 0x08 |
| 55 |
#define AVTP_AAF_PCM_NSR_192KHZ 0x09 |
| 56 |
#define AVTP_AAF_PCM_NSR_24KHZ 0x0A |
| 57 |
|
| 58 |
/* AAF PCM 'sp' (sparse timestamp) field values. */ |
| 59 |
#define AVTP_AAF_PCM_SP_NORMAL 0x00 |
| 60 |
#define AVTP_AAF_PCM_SP_SPARSE 0x01 |
| 61 |
|
| 62 |
enum avtp_aaf_field { |
| 63 |
AVTP_AAF_FIELD_SV, |
| 64 |
AVTP_AAF_FIELD_MR, |
| 65 |
AVTP_AAF_FIELD_TV, |
| 66 |
AVTP_AAF_FIELD_SEQ_NUM, |
| 67 |
AVTP_AAF_FIELD_TU, |
| 68 |
AVTP_AAF_FIELD_STREAM_ID, |
| 69 |
AVTP_AAF_FIELD_TIMESTAMP, |
| 70 |
AVTP_AAF_FIELD_STREAM_DATA_LEN, |
| 71 |
AVTP_AAF_FIELD_FORMAT, |
| 72 |
AVTP_AAF_FIELD_NSR, |
| 73 |
AVTP_AAF_FIELD_CHAN_PER_FRAME, |
| 74 |
AVTP_AAF_FIELD_BIT_DEPTH, |
| 75 |
AVTP_AAF_FIELD_SP, |
| 76 |
AVTP_AAF_FIELD_EVT, |
| 77 |
AVTP_AAF_FIELD_MAX, |
| 78 |
}; |
| 79 |
|
| 80 |
/* Get value from AAF AVTPDU field. |
| 81 |
* @pdu: Pointer to PDU struct. |
| 82 |
* @field: PDU field to be retrieved. |
| 83 |
* @val: Pointer to variable which the retrieved value should be saved. |
| 84 |
* |
| 85 |
* Returns: |
| 86 |
* 0: Success. |
| 87 |
* -EINVAL: If any argument is invalid. |
| 88 |
*/ |
| 89 |
int avtp_aaf_pdu_get(const struct avtp_stream_pdu *pdu, |
| 90 |
enum avtp_aaf_field field, uint64_t *val); |
| 91 |
|
| 92 |
/* Set value from AAF AVTPDU field. |
| 93 |
* @pdu: Pointer to PDU struct. |
| 94 |
* @field: PDU field to be set. |
| 95 |
* @val: Value to be set. |
| 96 |
* |
| 97 |
* Returns: |
| 98 |
* 0: Success. |
| 99 |
* -EINVAL: If any argument is invalid. |
| 100 |
*/ |
| 101 |
int avtp_aaf_pdu_set(struct avtp_stream_pdu *pdu, enum avtp_aaf_field field, |
| 102 |
uint64_t val); |
| 103 |
|
| 104 |
/* Initialize AAF AVTPDU. All AVTPDU fields are initialized with zero except |
| 105 |
* 'subtype' (which is set to AVTP_SUBTYPE_AAF) and 'sv' (which is set to 1). |
| 106 |
* @pdu: Pointer to PDU struct. |
| 107 |
* |
| 108 |
* Return values: |
| 109 |
* 0: Success. |
| 110 |
* -EINVAL: If any argument is invalid. |
| 111 |
*/ |
| 112 |
int avtp_aaf_pdu_init(struct avtp_stream_pdu *pdu); |
| 113 |
|
| 114 |
#ifdef __cplusplus |
| 115 |
} |
| 116 |
#endif |