/* 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_cm.h,v $
 * $Revision: #1 $
 * $Date: 2015/05/29 $
 * $Author: brianpc.huang $
 *
 * Description:
 *         This header file contains the connection manager specific
 *         definitions that are exported.
 *---------------------------------------------------------------------------*/

#ifndef _X_CM_H_
#define _X_CM_H_


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

#include "u_cm.h"
#include "u_common.h"
#include "u_handle.h"

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

typedef struct
{
    UINT16    ui2_ca_system_id;
    UINT16    ui2_ca_pid;
    UINT8*    pui1_private_data;
    UINT32    ui4_private_len;
    BOOL      b_valid;
}CM_CA_INFO_T;


/*-----------------------------------------------------------------------------
                    functions declarations
 ----------------------------------------------------------------------------*/

extern INT32 x_cm_close_pipe (HANDLE_T    h_pipe,
                              CM_COND_T*  pe_cond);

extern INT32 x_cm_connect (HANDLE_T             h_obj,
                           const CM_COMMAND_T*  pt_connect_cmd,
                           VOID*                pv_nfy_tag,
                           x_cm_nfy_fct         pf_nfy,
                           HANDLE_T*            ph_conn,
                           CM_COND_T*           pe_cond);

extern INT32 x_cm_disconnect (HANDLE_T    h_conn,
                              CM_COND_T*  pe_cond);

extern INT32 x_cm_get (HANDLE_T        h_conn,
                       CM_CTRL_TYPE_T  e_ctrl,
                       VOID*           pv_get_data);

extern INT32 x_cm_set (HANDLE_T        h_conn,
                       CM_CTRL_TYPE_T  e_ctrl,
                       VOID*           pv_set_data);

extern INT32 x_cm_get_cond (HANDLE_T    h_conn,
                            CM_COND_T*  pe_cond);

extern INT32 x_cm_open_pipe (const CM_COMMAND_T*  pt_pipe_cmd,
                             UINT8                ui1_priority,
                             UINT32               ui4_flags,
                             VOID*                pv_nfy_tag,
                             x_cm_nfy_fct         pf_nfy,
                             HANDLE_T*            ph_pipe,
                             CM_COND_T*           pe_cond);
/*-----------------------------------------------------------------------
* for 32/64 rpc
------------------------------------------------------------------------*/
extern INT32 x_cm_open_pipe_64 (const CM_COMMAND_EX_T*  pt_pipe_cmd_ex,
                             UINT8                ui1_priority,
                             UINT32               ui4_flags,
                             VOID*                pv_nfy_tag,
                             x_cm_nfy_fct         pf_nfy,
                             HANDLE_T*            ph_pipe,
                             CM_COND_T*           pe_cond);

extern INT32 x_cm_connect_64 (HANDLE_T             h_obj,
                           const CM_COMMAND_EX_T*  pt_connect_cmd_ex,
                           VOID*                pv_nfy_tag,
                           x_cm_nfy_fct         pf_nfy,
                           HANDLE_T*            ph_conn,
                           CM_COND_T*           pe_cond);
/*------------------------------------------------------------------------*/

extern INT32 x_cm_store_pre_conn_info(BOOL   b_tv_src,
                                  UINT8  ui1_svl_lst,
                                  UINT32 ui4_channel_id);

extern HANDLE_T x_cm_pipe_get_rm_pipe (HANDLE_T h_cm_pipe);


extern HANDLE_T x_cm_connection_get_pipe (HANDLE_T  h_conn);

extern HANDLE_T x_cm_connection_get_rm_pipe (HANDLE_T  h_conn);

#endif /* _X_CM_H_ */
