/* SPDX-License-Identifier: LGPL-2.1-only OR BSD-3-Clause */
/******************************************************************************
 *
 * This file is provided under a dual license.  When you use or
 * distribute this software, you may choose to be licensed under
 * version 2.1 of the GNU Lesser General Public License
 * ("LGPLv2.1 License") or BSD License.
 *
 * LGPLv2.1 License
 *
 * Copyright(C) 2019 MediaTek Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2.1 of the GNU Lesser General Public
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html for more
 * details.
 *
 * BSD LICENSE
 *
 * Copyright(C) 2019 MediaTek Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *  * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  * Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *  * Neither the name of the copyright holder nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *****************************************************************************/

/*-----------------------------------------------------------------------------
 * $RCSfile: x_secm_api.h,v $
 * $Revision: #1 $
 * $Date: 2015/05/29 $
 * $Author: brianpc.huang $
 *
 * Description: 
 *         This header file contains handle specific definitions, which are
 *         exported.
 *---------------------------------------------------------------------------*/

#ifndef _X_SECM_API_H_
#define _X_SECM_API_H_

#include "u_secm_api.h"


/*-----------------------------------------------------------------------------
                    include files
-----------------------------------------------------------------------------*/

/*-----------------------------------------------------------------------------
                    macros, defines, typedefs, enums
 ----------------------------------------------------------------------------*/


/*-----------------------------------------------------------------------------
                    functions declarations
 ----------------------------------------------------------------------------*/
/*
 * ph_src : a placeholder of a handle
 * pt_src : contains a reference which specifies the array size and array
 *          of SECM_SRC_INFO_T 
 */
extern INT32 x_secm_alloc_source(HANDLE_T            *ph_src,
                        SRC_COMP_TYPE_T     e_src_type,
                        VOID                *pv_src_comp);

/*
 * h_src : source handle, returned from secm_alloc_source()
 * pf_nfy: source state notification fuction
 * pv_nfy_tag : tag as an argument in pf_nfy.
 */

extern INT32 x_secm_attach_source_nfy(HANDLE_T           h_src,
                             secm_src_nfy_fct   pf_nfy,
                             VOID               *pv_nfy_tag);

/*
 * ph_logical : contains a reference to a handle
 * h_src : handle returned from secm_alloc_src()
 * t_pid: contains PID value
 * pf_nfy: notification fuction
 */ 
extern INT32 x_secm_alloc_raw_filter(HANDLE_T            *ph_logical,
                            HANDLE_T            h_src,
                            MPEG_2_PID_T        t_pid,
                            UINT8               ui1_flag,
                            SIZE_T              z_buf_size,
                            secm_nfy_fct        pf_nfy);

/*
 * h_logical : contains a handle, returned via secm_alloc_acq_filter() or
 *            secm_alloc_mon_filter().
 * b_ctrl: control operation, TRUE to enable the filter, FALSE to disable
 *         the filter
 */
extern INT32 x_secm_ctrl_filter(HANDLE_T h_logical,
                       BOOL     b_ctrl);

/*
 * t_pid: pid value.
 * b_ctrl: control operation, TRUE to enable the filter, FALSE to disable
 *         the filter
 */
extern INT32 x_secm_ctrl_pid_filter(MPEG_2_PID_T t_pid,
                           BOOL         b_ctrl);

/*
 * h_obj : contains a handle of a logical filter or a section filter or
 *         a source object.
 */
extern INT32 x_secm_close_obj(HANDLE_T   h_obj);


/*
 * h_logical : contains a handle, returned via secm_alloc_acq_filter() or
 *            secm_alloc_mon_filter().
 * ph_sec_req : contains a reference to a handle for this section request
 * h_src : handle return from secm_alloc_src()
 * pt_ts_descr: contains a reference to TS_DESCR_T
 * pv_nfy_tag: notification tag to pf_nfy in secm_alloc_acq_filter() or
 *             secm_alloc_mon_filter().
 * pt_sec_req: contains a reference to SECM_MON_REQ_T. this conatins bytes
 *             combination of the first 16 bytes of a section table.
 */ 
extern INT32 x_secm_set_raw_filter(HANDLE_T          h_logical,
                          HANDLE_T          *ph_sec_req,
                          TS_DESCR_T        *pt_ts_descr,
                          VOID              *pv_nfy_tag,
                          MPEG_2_PID_T      t_pid,
                          SECM_RAW_REQ_T    *pt_raw_req);

#endif /* _SECM_API_H_ */

