chuangcheng.peng | 60c4828 | 2024-04-12 10:16:35 +0800 | [diff] [blame^] | 1 | /*************************************************************************** |
| 2 | * Copyright (C) 2017 Amlogic, Inc. All rights reserved. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 12 | * more details. |
| 13 | * |
| 14 | * Description: |
| 15 | */ |
| 16 | /**\file |
| 17 | * \brief Demux module |
| 18 | * |
| 19 | * Basic data structures definition in "linux/dvb/dmx.h" |
| 20 | * |
| 21 | * \author Gong Ke <ke.gong@amlogic.com> |
| 22 | * \date 2010-05-21: create the document |
| 23 | ***************************************************************************/ |
| 24 | |
| 25 | #ifndef _AM_DMX_H |
| 26 | #define _AM_DMX_H |
| 27 | |
| 28 | #include "am_types.h" |
| 29 | /*add for config define for linux dvb *.h*/ |
| 30 | //#include "am_config.h" |
| 31 | #include "dmx.h" |
| 32 | |
| 33 | #ifdef __cplusplus |
| 34 | extern "C" |
| 35 | { |
| 36 | #endif |
| 37 | |
| 38 | /**************************************************************************** |
| 39 | * Macro definitions |
| 40 | ***************************************************************************/ |
| 41 | |
| 42 | /**************************************************************************** |
| 43 | * Error code definitions |
| 44 | ****************************************************************************/ |
| 45 | |
| 46 | /**\brief Error code of the demux module*/ |
| 47 | enum AM_DMX_ErrorCode |
| 48 | { |
| 49 | AM_DMX_ERROR_BASE=AM_ERROR_BASE(AM_MOD_DMX), |
| 50 | AM_DMX_ERR_INVALID_DEV_NO, /**< Invalid device number*/ |
| 51 | AM_DMX_ERR_INVALID_ID, /**< Invalid filer handle*/ |
| 52 | AM_DMX_ERR_BUSY, /**< The device has already been opened*/ |
| 53 | AM_DMX_ERR_NOT_ALLOCATED, /**< The device has not been allocated*/ |
| 54 | AM_DMX_ERR_CANNOT_CREATE_THREAD, /**< Cannot create new thread*/ |
| 55 | AM_DMX_ERR_CANNOT_OPEN_DEV, /**< Cannot open device*/ |
| 56 | AM_DMX_ERR_NOT_SUPPORTED, /**< Not supported*/ |
| 57 | AM_DMX_ERR_NO_FREE_FILTER, /**< No free filter*/ |
| 58 | AM_DMX_ERR_NO_MEM, /**< Not enough memory*/ |
| 59 | AM_DMX_ERR_TIMEOUT, /**< Timeout*/ |
| 60 | AM_DMX_ERR_SYS, /**< System error*/ |
| 61 | AM_DMX_ERR_NO_DATA, /**< No data received*/ |
| 62 | AM_DMX_ERR_END |
| 63 | }; |
| 64 | |
| 65 | /**************************************************************************** |
| 66 | * Type definitions |
| 67 | ***************************************************************************/ |
| 68 | |
| 69 | /**\brief Input source of the demux*/ |
| 70 | typedef enum |
| 71 | { |
| 72 | AM_DMX_SRC_TS0, /**< TS input port 0*/ |
| 73 | AM_DMX_SRC_TS1, /**< TS input port 1*/ |
| 74 | AM_DMX_SRC_TS2, /**< TS input port 2*/ |
| 75 | AM_DMX_SRC_TS3, /**< TS input port 3*/ |
| 76 | AM_DMX_SRC_HIU, /**< HIU input (memory)*/ |
| 77 | AM_DMX_SRC_HIU1 |
| 78 | } AM_DMX_Source_t; |
| 79 | |
| 80 | /**\brief Demux device open parameters*/ |
| 81 | typedef struct |
| 82 | { |
| 83 | AM_Bool_t use_sw_filter; /**< M_TURE to use DVR software filters.*/ |
| 84 | int dvr_fifo_no; /**< Async fifo number if use software filters.*/ |
| 85 | int dvr_buf_size; /**< Async fifo buffer size if use software filters.*/ |
| 86 | } AM_DMX_OpenPara_t; |
| 87 | |
| 88 | /**\brief Filter received data callback function |
| 89 | * \a fandle is the filter's handle. |
| 90 | * \a data is the received data buffer pointer. |
| 91 | * \a len is the data length. |
| 92 | * If \a data == null, means timeout. |
| 93 | */ |
| 94 | typedef void (*AM_DMX_DataCb) (int dev_no, int fhandle, const uint8_t *data, int len, void *user_data); |
| 95 | |
| 96 | |
| 97 | /**************************************************************************** |
| 98 | * Function prototypes |
| 99 | ***************************************************************************/ |
| 100 | |
| 101 | /**\brief Open a demux device |
| 102 | * \param dev_no Demux device number |
| 103 | * \param[in] para Demux device's open parameters |
| 104 | * \retval AM_SUCCESS On success |
| 105 | * \return Error code |
| 106 | */ |
| 107 | extern AM_ErrorCode_t AM_DMX_Open(int dev_no, const AM_DMX_OpenPara_t *para); |
| 108 | |
| 109 | /**\brief Close a demux device |
| 110 | * \param dev_no Demux device number |
| 111 | * \retval AM_SUCCESS On success |
| 112 | * \return Error code |
| 113 | */ |
| 114 | extern AM_ErrorCode_t AM_DMX_Close(int dev_no); |
| 115 | |
| 116 | /**\brief Allocate a filter |
| 117 | * \param dev_no Demux device number |
| 118 | * \param[out] fhandle Return the allocated filter's handle |
| 119 | * \retval AM_SUCCESS On success |
| 120 | * \return Error Code |
| 121 | */ |
| 122 | extern AM_ErrorCode_t AM_DMX_AllocateFilter(int dev_no, int *fhandle); |
| 123 | |
| 124 | /**\brief Set a section filter's parameters |
| 125 | * \param dev_no Demux device number |
| 126 | * \param fhandle Filter handle |
| 127 | * \param[in] params Section filter's parameters |
| 128 | * \retval AM_SUCCESS On success |
| 129 | * \return Error code |
| 130 | */ |
| 131 | extern AM_ErrorCode_t AM_DMX_SetSecFilter(int dev_no, int fhandle, const struct dmx_sct_filter_params *params); |
| 132 | |
| 133 | /**\brief Set a PES filter's parameters |
| 134 | * \param dev_no Demux device number |
| 135 | * \param fhandle Filter handle |
| 136 | * \param[in] params PES filter's parameters |
| 137 | * \retval AM_SUCCESS On success |
| 138 | * \return Error code |
| 139 | */ |
| 140 | extern AM_ErrorCode_t AM_DMX_SetPesFilter(int dev_no, int fhandle, const struct dmx_pes_filter_params *params); |
| 141 | |
| 142 | /**\brief Release an unused filter |
| 143 | * \param dev_no Demux device number |
| 144 | * \param fhandle Filter handle |
| 145 | * \retval AM_SUCCESS On success |
| 146 | * \return Error code |
| 147 | */ |
| 148 | extern AM_ErrorCode_t AM_DMX_FreeFilter(int dev_no, int fhandle); |
| 149 | |
| 150 | /**\brief Start filtering |
| 151 | * \param dev_no Demux device number |
| 152 | * \param fhandle Filter handle |
| 153 | * \retval AM_SUCCESS On success |
| 154 | * \return Error code |
| 155 | */ |
| 156 | extern AM_ErrorCode_t AM_DMX_StartFilter(int dev_no, int fhandle); |
| 157 | |
| 158 | /**\brief Stop filtering |
| 159 | * \param dev_no Demux device number |
| 160 | * \param fhandle Filter handle |
| 161 | * \retval AM_SUCCESS On success |
| 162 | * \return Error code |
| 163 | */ |
| 164 | extern AM_ErrorCode_t AM_DMX_StopFilter(int dev_no, int fhandle); |
| 165 | |
| 166 | /**\brief Set the ring queue buffer size of a filter |
| 167 | * \param dev_no Demux device number |
| 168 | * \param fhandle Filter handle |
| 169 | * \param size Ring queue buffer size in bytes |
| 170 | * \retval AM_SUCCESS On success |
| 171 | * \return Error code |
| 172 | */ |
| 173 | extern AM_ErrorCode_t AM_DMX_SetBufferSize(int dev_no, int fhandle, int size); |
| 174 | |
| 175 | /**\brief Get a filter's data callback function |
| 176 | * \param dev_no Demux device number |
| 177 | * \param fhandle Filter handle |
| 178 | * \param[out] cb Return the data callback function of the filter |
| 179 | * \param[out] data Return the user defined parameter of the callback function |
| 180 | * \retval AM_SUCCESS On success |
| 181 | * \return Error code |
| 182 | */ |
| 183 | extern AM_ErrorCode_t AM_DMX_GetCallback(int dev_no, int fhandle, AM_DMX_DataCb *cb, void **data); |
| 184 | |
| 185 | /**\brief Set a filter's data callback function |
| 186 | * \param dev_no Demux device number |
| 187 | * \param fhandle Filter handle |
| 188 | * \param[in] cb New data callback function |
| 189 | * \param[in] data User defined parameter of the callback function |
| 190 | * \retval AM_SUCCESS On success |
| 191 | * \return Error code |
| 192 | */ |
| 193 | extern AM_ErrorCode_t AM_DMX_SetCallback(int dev_no, int fhandle, AM_DMX_DataCb cb, void *data); |
| 194 | |
| 195 | /**\brief Set the demux's input source |
| 196 | * \param dev_no Demux device number |
| 197 | * \param src Input source |
| 198 | * \retval AM_SUCCESS On success |
| 199 | * \return Error code |
| 200 | */ |
| 201 | extern AM_ErrorCode_t AM_DMX_SetSource(int dev_no, AM_DMX_Source_t src); |
| 202 | |
| 203 | /**\cond */ |
| 204 | /**\brief Sync the demux data |
| 205 | * \param dev_no Demux device number |
| 206 | * \retval AM_SUCCESS On success |
| 207 | * \return Error code |
| 208 | */ |
| 209 | extern AM_ErrorCode_t AM_DMX_Sync(int dev_no); |
| 210 | /**\endcond */ |
| 211 | |
| 212 | /** |
| 213 | * Get the scramble status of the AV channels in the demux |
| 214 | * \param dev_no Demux device number |
| 215 | * \param[out] dev_status Return the AV channels's scramble status. |
| 216 | * dev_status[0] is the video status, dev_status[1] is the audio status. |
| 217 | * AM_TRUE means the channel is scrambled, AM_FALSE means the channel is not scrambled. |
| 218 | * \retval AM_SUCCESS On success |
| 219 | * \return Error code |
| 220 | */ |
| 221 | extern AM_ErrorCode_t AM_DMX_GetScrambleStatus(int dev_no, AM_Bool_t dev_status[2]); |
| 222 | |
| 223 | extern AM_ErrorCode_t AM_DMX_GetSTC(int dev_no, int fhandle); |
| 224 | |
| 225 | #ifdef __cplusplus |
| 226 | } |
| 227 | #endif |
| 228 | |
| 229 | #endif |
| 230 | |