#ifndef  _U_RSF_H_
#define  _U_RSF_H_

/*-----------------------------------------------------------------------------
 include files
 -----------------------------------------------------------------------------*/
#include "u_common.h"
#include "x_common.h"
/*-----------------------------------------------------------------------------
 macros, defines, typedefs, enums
 -----------------------------------------------------------------------------*/

/*the return values*/
#define RSF_OK                                  ((INT32) 0) /*ok*/
#define RSF_NOT_INIT                            ((INT32) -1) /*raw section filter not init*/
#define RSF_NOT_RESOURCE                        ((INT32) -2) /*memory alloc failed*/
#define RSF_SEMA_ERR                            ((INT32) -3) /*create sema failed*/
#define RSF_INIT_FAIL                           ((INT32) -4) /*fail to init*/
#define RSF_INV_ARG                             ((INT32) -5) /*arguments or filter id invalid */
#define RSF_OPERATION_NOT_AVAILABLE             ((INT32) -6) /*system error or operation invalid*/
#define RSF_NO_AVAILABLE_CLEINT                 ((INT32) -7)
#define RSF_HANDLE_ERROR                        ((INT32) -8)
#define RSF_SECM_ERROR                          ((INT32) -9)
#define RSF_LOCK_ERROR                          ((INT32) -10) /*fail to get lock*/
#define RSF_UNLOCK_ERROR                        ((INT32) -11) /*fail to release lock*/
#define RSF_ALLOC_SOURCE_ERROR                  ((INT32) -12) /*tuner connection error, can not load section*/
#define RSF_FILTER_STOP_FAIL                    ((INT32) -13) /*fail to allocate filter*/
#define RSF_FILTER_FREE_FAIL                    ((INT32) -14) /*fail to free filter*/

/*ui1_pattern_len+ui1_pattern_offset should not over this value*/
#define RSF_FILTER_PATTERN_MAX_LEN       16

/*not set any flag, use default value*/
#define RSF_REQ_FLAG_NULL              ((UINT16)(0x00))  
/*if set the flag , hardware will not check section CRC, else do hardware CRC check in default, */
#define RSF_REQ_FLAG_NO_CRC_CHECK      ((UINT16)(0x01))  
/* notify all sections if set this flag, else only notify the updated section in default*/
#define RSF_REQ_FLAG_NO_VER_CHECK      ((UINT16)(0x02))

typedef struct _RSF_FILTER_REQ_T
{
    UINT16 ui2_pid;
    UINT8 ui1_pos_pattern[RSF_FILTER_PATTERN_MAX_LEN]; /* positive pattern */
    UINT8 ui1_pos_pattern_mask[RSF_FILTER_PATTERN_MAX_LEN]; /* positive pattern mask */
    UINT8 ui1_neg_pattern[RSF_FILTER_PATTERN_MAX_LEN]; /* negative pattern */
    UINT8 ui1_neg_pattern_mask[RSF_FILTER_PATTERN_MAX_LEN]; /* negative pattern mask */
    UINT8 ui1_pattern_len; /* pos/net patten length,zero means no patten, load table only by pid*/
    UINT8 ui1_pattern_offset; /* patten offset: value[0,RSF_FILTER_PATTERN_OFFSET_MAX_LEN] */
    UINT16 ui2_flag; /*the filter request flag*/
} RSF_FILTER_REQ_T;

/* raw section filter source type, only support one source at a time*/
typedef enum
{
    RSF_SOURCE_TYPE_UNKOWN = 0,
    RSF_SOURCE_TYPE_CAB_DIG, /*cable---digital*/
    RSF_SOURCE_TYPE_SAT_DIG, /*satellite---digital*/
    RSF_SOURCE_TYPE_TER_DIG, /*terrestrial---digital*/
    RSF_SOURCE_TYPE_AGENT /*other source like MMP file*/
} RSF_SOURCE_TYPE_T;

/*-----------------------------------------------------------------------------
 * Name: x_rsf_nfy_fct
 *
 * Description: This is a callback function for loading section ,once the section arrived.
 *              The client must copy the data into the client buffer in the callback function.
 *              Because the pui1_section data will be released after the callback ends.
 *
 * Inputs:  pv_nfy_tag          Contains a notify data from API caller.
 *          pui1_section        The the section data pointer.
 *          ui2_sect_data_size  The total size of section data.
 *
 * Outputs: -
 *
 * Returns: TRUE        success to get section
 *          FALSE       fail to get section
 ----------------------------------------------------------------------------*/
typedef VOID (*x_rsf_nfy_fct)(VOID* pv_nfy_tag, UINT8* pui1_section,
        UINT16 ui2_sect_data_size);

#endif /* _U_RSF_H_ */

