| 1 |
/* |
| 2 |
* Copyright (c) 2018, 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 |
/* CRF 'type' field values. */ |
| 38 |
#define AVTP_CRF_TYPE_USER 0x00 |
| 39 |
#define AVTP_CRF_TYPE_AUDIO_SAMPLE 0x01 |
| 40 |
#define AVTP_CRF_TYPE_VIDEO_FRAME 0x02 |
| 41 |
#define AVTP_CRF_TYPE_VIDEO_LINE 0x03 |
| 42 |
#define AVTP_CRF_TYPE_MACHINE_CYCLE 0x04 |
| 43 |
|
| 44 |
/* CRF 'pull' field values. */ |
| 45 |
#define AVTP_CRF_PULL_MULT_BY_1 0x00 |
| 46 |
#define AVTP_CRF_PULL_MULT_BY_1_OVER_1_001 0x01 |
| 47 |
#define AVTP_CRF_PULL_MULT_BY_1_001 0x02 |
| 48 |
#define AVTP_CRF_PULL_MULT_BY_24_OVER_25 0x03 |
| 49 |
#define AVTP_CRF_PULL_MULT_BY_25_OVER_24 0x04 |
| 50 |
#define AVTP_CRF_PULL_MULT_BY_1_OVER_8 0x05 |
| 51 |
|
| 52 |
struct avtp_crf_pdu { |
| 53 |
uint32_t subtype_data; |
| 54 |
uint64_t stream_id; |
| 55 |
uint64_t packet_info; |
| 56 |
uint64_t crf_data[0]; |
| 57 |
} __attribute__ ((__packed__)); |
| 58 |
|
| 59 |
enum avtp_crf_field { |
| 60 |
AVTP_CRF_FIELD_SV, |
| 61 |
AVTP_CRF_FIELD_MR, |
| 62 |
AVTP_CRF_FIELD_FS, |
| 63 |
AVTP_CRF_FIELD_TU, |
| 64 |
AVTP_CRF_FIELD_SEQ_NUM, |
| 65 |
AVTP_CRF_FIELD_TYPE, |
| 66 |
AVTP_CRF_FIELD_STREAM_ID, |
| 67 |
AVTP_CRF_FIELD_PULL, |
| 68 |
AVTP_CRF_FIELD_BASE_FREQ, |
| 69 |
AVTP_CRF_FIELD_CRF_DATA_LEN, |
| 70 |
AVTP_CRF_FIELD_TIMESTAMP_INTERVAL, |
| 71 |
AVTP_CRF_FIELD_MAX, |
| 72 |
}; |
| 73 |
|
| 74 |
/* Get value from CRF AVTPDU field. |
| 75 |
* @pdu: Pointer to PDU struct. |
| 76 |
* @field: PDU field to be retrieved. |
| 77 |
* @val: Pointer to variable which the retrieved value should be saved. |
| 78 |
* |
| 79 |
* Returns: |
| 80 |
* 0: Success. |
| 81 |
* -EINVAL: If any argument is invalid. |
| 82 |
*/ |
| 83 |
int avtp_crf_pdu_get(const struct avtp_crf_pdu *pdu, |
| 84 |
enum avtp_crf_field field, uint64_t *val); |
| 85 |
|
| 86 |
/* Set value from CRF AVTPDU field. |
| 87 |
* @pdu: Pointer to PDU struct. |
| 88 |
* @field: PDU field to be set. |
| 89 |
* @val: Value to be set. |
| 90 |
* |
| 91 |
* Returns: |
| 92 |
* 0: Success. |
| 93 |
* -EINVAL: If any argument is invalid. |
| 94 |
*/ |
| 95 |
int avtp_crf_pdu_set(struct avtp_crf_pdu *pdu, enum avtp_crf_field field, |
| 96 |
uint64_t val); |
| 97 |
|
| 98 |
/* Initialize CRF AVTPDU. All AVTPDU fields are initialized with zero except |
| 99 |
* 'subtype' (which is set to AVTP_SUBTYPE_CRF) and 'sv' (which is set to 1). |
| 100 |
* @pdu: Pointer to PDU struct. |
| 101 |
* |
| 102 |
* Return values: |
| 103 |
* 0: Success. |
| 104 |
* -EINVAL: If any argument is invalid. |
| 105 |
*/ |
| 106 |
int avtp_crf_pdu_init(struct avtp_crf_pdu *pdu); |
| 107 |
|
| 108 |
#ifdef __cplusplus |
| 109 |
} |
| 110 |
#endif |