/* 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.
 *
 *****************************************************************************/

#ifndef _X_MHEG5_H_
#define _X_MHEG5_H_
/*-----------------------------------------------------------------------------
                    include files
-----------------------------------------------------------------------------*/
#include "u_common.h"
#include "u_mheg5.h"
#include "x_scc.h"
#include "u_scc.h"
#include "u_wgl.h"

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

/*-----------------------------------------------------------------------------
                    functions declarations
-----------------------------------------------------------------------------*/
extern INT32 x_mheg5_adjust_freeze_mode(UINT32 ui4_eng_code);

extern INT32 x_mheg5_adjust_order(
    UINT32                      ui4_eng_code,
    HANDLE_T                    h_ref_widget,
    WGL_INSERT_MODE_T           e_insert);

extern INT32 x_mheg5_evaluate_stream(UINT32 ui4_eng_code);

extern INT32 x_mheg5_get_display_adjustment(
    UINT32                      ui4_eng_code,
    UINT8                       ui1_afd,
    MHEG5_ASPECT_RATIO_T        e_src_aspect_ratio,
    SCC_VID_SCREEN_MODE_T       e_screen_mode,
    MHEG5_VIDEO_MODE_T          e_vid_mode,
    VSH_REGION_INFO_T*          pt_src_region, 
    VSH_REGION_INFO_T*          pt_dst_region);

extern INT32 x_mheg5_get_eng_code(
    const CHAR* ps_eng_name,
    UINT32*     pui4_eng_code);

extern SCC_VID_SCREEN_MODE_T x_mheg5_get_screen_auto_mode_enum(VOID);

extern INT32 x_mheg5_init_osd(
    UINT32                      ui4_eng_code,
    HANDLE_T                    h_mheg5_canvas,
    HANDLE_T                    h_sbtl_canvas,
    GL_HPALETTE_T               h_palette,
    const GL_COLOR_T*           pt_color_key);

extern INT32 x_mheg5_reg_eng_state_nfy(
    UINT32                      ui4_eng_code,
    x_mheg5_eng_state_nfy_fct   pf_state_nfy,
    VOID*                       pv_tag);


extern INT32 x_mheg5_load_si(
    UINT32                      ui4_eng_code,
    HANDLE_T                    h_svctx,
    UINT16                      ui2_svl_id,
    UINT16                      ui2_svl_rec_id,
    x_mheg5_eng_load_nfy_fct    pf_load_nfy,
    VOID*                       pv_tag);

extern INT32 x_mheg5_pause_service(UINT32 ui4_eng_code);

extern INT32 x_mheg5_query_display_adjustment(
    UINT32                          ui4_eng_code,
    const MHEG5_DISPLAY_PARAM_T*    pt_dspy_param,
    VSH_REGION_INFO_T*              pt_src_region, 
    VSH_REGION_INFO_T*              pt_dst_region);

extern INT32 x_mheg5_query_display_adjustment_ex(
    UINT32                          ui4_eng_code,
    MHEG5_DISPLAY_PARAM_T*          pt_dspy_param,
    VSH_REGION_INFO_T*              pt_src_region, 
    VSH_REGION_INFO_T*              pt_dst_region);

extern BOOL x_mheg5_query_display_b_auto_mode(
    UINT32                          ui4_eng_code);


extern INT32 x_mheg5_register_eng(
    const CHAR*         ps_eng_name,
    MHEG5_FUNC_TBL_T*   pt_ftbl,
    UINT32*             pui4_eng_code);

extern INT32 x_mheg5_resolve(
    UINT32                  ui4_eng_code,
    MHEG5_STREAM_DESC_T*    pt_strm_desc,
    x_mheg5_resolve_nfy     pf_resolve_nfy,
    VOID*                   pv_tag,
    STREAM_PID_INFO_T*      pt_pid_info);

extern INT32 x_mheg5_resume_service(UINT32 ui4_eng_code);

extern INT32 x_mheg5_send_msg(
    UINT32          ui4_eng_code,
    MHEG5_MSG_T*    pt_msg,
    UINT16          ui2_retry);

extern INT32 x_mheg5_adjust_osd(
    UINT32                  ui4_eng_code,
    const MHEG5_CNV_CFG_T*  pt_cnv_cfg);

extern INT32 x_mheg5_adjust_osd_ex(
    UINT32                        ui4_eng_code,
    const MHEG5_CNV_CFG_T*        pt_cnv_cfg,
    const VSH_REGION_INFO_T*      pt_orig_src_reg,
    const VSH_REGION_INFO_T*      pt_full_src_reg,
    const VSH_REGION_INFO_T*      pt_full_dst_reg,
    const VSH_REGION_INFO_T*      pt_xlat_src_reg,
    const VSH_REGION_INFO_T*      pt_xlat_dst_reg);



extern INT32 x_mheg5_set_gui_lang(
    UINT32          ui4_eng_code,
    ISO_639_LANG_T  s639_lang);

extern INT32 x_mheg5_set_default_lang(
    UINT32          ui4_eng_code,
    ISO_639_LANG_T  s639_lang);

extern VOID x_mheg5_set_screen_auto_mode_enum(SCC_VID_SCREEN_MODE_T e_auto_mode);

extern INT32 x_mheg5_show(
    UINT32                      ui4_eng_code,
    MHEG5_COEXIST_DISPLAY_T     e_display,
    BOOL                        b_get_focus);

extern INT32 x_mheg5_start_service(
    UINT32                      ui4_eng_code,
    HANDLE_T                    h_svctx,
    UINT16                      ui2_svl_id,
    UINT16                      ui2_svl_rec_id);

extern INT32 x_mheg5_stop_service(UINT32 ui4_eng_code, MHEG5_STOP_SVC_PARAM_T *pt_param);

extern INT32 x_mheg5_strm_force_no_act(BOOL b_force);

extern INT32 x_mheg5_unload_si(UINT32 ui4_eng_code);

extern INT32 x_mheg5_unregister_eng(const CHAR* ps_eng_name);

extern INT32 x_mheg5_update_screen_mode(
    UINT32                  ui4_eng_code,
    SCC_VID_SCREEN_MODE_T   e_screen_mode);

extern BOOL x_mheg5_with_internal_screen_mode(VOID);

extern INT32 x_mheg5_set_dvb_locator(UINT16 ui2_on_id, UINT16 ui2_ts_id, UINT16 ui2_svc_id);

extern INT32 x_mheg5_set_vdp_mode(
    UINT32          ui4_eng_code,
    SCC_VID_MODE_T  e_mode,
    BOOL            b_resume);

extern INT32 x_mheg5_set_video_info(
    UINT32          ui4_eng_code);

extern INT32 x_mheg5_reg_video_update_nfy(
    UINT32                   ui4_eng_code,
    x_mheg5_video_update_nfy pf_nfy,
    VOID*                    pv_tag);

extern INT32 x_mheg5_reg_sbtl_visibility_nfy(
    UINT32                      ui4_eng_code,
    x_mheg5_sbtl_visibility_nfy pf_nfy,
    VOID*                       pv_tag);

extern INT32 x_mheg5_set_subtitle_info(
    UINT32                 ui4_eng_code,
    MHEG5_SUBTITLE_CFG_T*  pt_cfg);

extern INT32 x_mheg5_set_visibility(
    UINT32          ui4_eng_code,
    WGL_SW_CMD_T    e_sw_cmd);

extern INT32 x_mheg5_set_default_overscan(SCC_VID_OVER_SCAN_CLIPPER_T *pt_clipper);

extern INT32 x_mheg5_reg_tune_method_update_nfy(
    UINT32                         ui4_eng_code,
    x_mheg5_tune_method_update_nfy pf_tune_method_update_nfy,
    VOID*                          pv_tag);


extern INT32 x_mheg5_reg_tune_svc_cb_fct(
    UINT32               ui4_eng_code,
    x_mheg5_tune_svc_fct pf_tune_svc_fct,
    VOID*                pv_tag);

extern INT32 x_mheg5_open(
    UINT32            ui4_eng_code,
    MHEG5_SETUP_T*    pt_setup);


extern INT32 x_mheg5_close(
    UINT32 ui4_eng_code);

extern INT32 x_mheg5_key_press(
    UINT32 ui4_eng_code,
    UINT32 ui4_key_code,
    BOOL*  pb_in_func_grp,
    BOOL   b_process);
    
extern INT32 x_mheg5_start_execution(
    UINT32 ui4_eng_code,
    MHEG5_START_EXEC_T* pt_start_exec);

extern INT32 x_mheg5_stop_execution(
    UINT32 ui4_eng_code,
    MHEG5_STOP_EXEC_T* pt_stop_exec);
    
extern INT32 x_mheg5_pause_execution(
    UINT32 ui4_eng_code,
    MHEG5_PAUSE_EXEC_T* pt_pause_exec);

extern INT32 x_mheg5_query_current_mode(
    UINT32        ui4_eng_code,
    MHEG5_MODE_T* pt_mode);

extern INT32 x_mheg5_reg_select_stream_cb_fct(
    UINT32                          ui4_eng_code,
    x_mheg5_select_stream_fct       pf_select_stream_fct,
    VOID*                           pv_tag);

extern INT32 x_mheg5_reg_ci_nfy(
    UINT32            ui4_eng_code,
    x_mheg5_ci_nfy    pf_func,
    VOID*             pv_tag);

extern INT32 x_mheg5_start_ci_application(
    UINT32            ui4_eng_code,
    MHEG5_CI_START_APP_T* pt_start_ci_app);

extern INT32 x_mheg5_stop_ci_applications(
    UINT32            ui4_eng_code,
    MHEG5_CI_STOP_APPS_T*  pt_stop_ci_apps);

extern INT32 x_mheg5_apply_supported_profile(
    UINT32              ui4_eng_code,
    ISO_3166_COUNT_T    s3166_country,
    MHEG5_PROFILE_ID_T* pe_profile_id,
    BOOL                b_apply);


extern INT32 x_mheg5_open_ics(
    UINT32            ui4_eng_code,
    MHEG5_SETUP_T*    pt_setup,
    BOOL              b_ics_enable);

extern INT32 x_mheg5_set_ic_status(
    UINT32            ui4_eng_code,
    MHEG5_IC_STATE_T  e_new_ic_status);

extern INT32 x_mheg5_reg_ics_guid_visibility_nfy(
    UINT32                          ui4_eng_code,
    x_mheg5_ics_guid_visibility_nfy pf_nfy,
    VOID*                           pv_tag);

extern INT32 x_mheg5_get_ics_guid_info_len(
    UINT32            ui4_eng_code,
    UINT32*           pui4_len);

extern INT32 x_mheg5_get_ics_guid_info(
    UINT32            ui4_eng_code,
    CHAR*             ps_str,
    UINT32*           pui4_len);

extern INT32 x_mheg5_set_ics_guid_result(
    UINT32          ui4_eng_code,
    BOOL            b_result);

extern INT32 x_mheg5_ics_get_proper_lang_info(
                    UINT32                       ui4_eng_code,
                    STREAM_TYPE_T                e_strm_type,
                    x_mheg5_ics_lang_filter      pf_filter,
                    VOID*                        pv_tag );

extern INT32 x_mheg5_reg_pin_support_cb_fct(
    UINT32                  ui4_eng_code,
    x_mheg5_pin_support_fct pf_pin_support_fct,
    VOID*                   pv_tag);

extern INT32 x_mheg5_notify_audio_desc_pref_changed(UINT32 ui4_eng_code);

extern INT32 x_mheg5_reg_audio_desc_cb_fct(
    UINT32               ui4_eng_code,
    x_mheg5_ad_fct       pf_ad_fct,
    VOID*                pv_tag);

extern INT32 x_mheg5_reg_ics_audio_lang_nfy(
    UINT32                          ui4_eng_code,
    x_mheg5_ics_audio_lang_nfy      pf_ics_aud_lang_nfy,
    VOID*                           pv_tag);



extern INT32 x_mheg5_init_tps(
		const CHAR* ps_tps_dev
);

extern INT32 x_mheg5_clear_tps(VOID);

extern INT32 x_mheg5_reg_vid_info_update_nfy(
        UINT32                         ui4_eng_code,
        x_mheg5_vid_info_update_nfy    pf_func,
        VOID*                          pv_tag);

extern INT32 x_mheg5_get_vid_info(
        UINT32                  ui4_eng_code,
        MHEG5_VID_INFO_T*       pt_vid_info);


extern INT32 x_mheg5_reg_graphics_suppressed_nfy(
    UINT32                          ui4_eng_code,
    x_mheg5_graphics_suppressed_nfy pf_func,
    VOID*                           pv_tag);

extern INT32 x_mheg5_reg_audio_switch_fun(
    UINT32                          ui4_eng_code,
    x_mheg5_audio_switch_fun        pf_func,
    VOID*                           pv_tag);


extern INT32 x_mheg5_reg_set_key_input_mask_fun(
    UINT32                          ui4_eng_code,
    x_mheg5_set_key_input_mask      pf_func,
    VOID*                           pv_tag);

extern INT32 x_mheg5_reg_can_launch_hbbtv_nfy (
	UINT32                              ui4_eng_code,
    x_mheg5_can_lanuch_hbbtv_nfy_fct    pf_can_launch_hbbtv_nfy_fct,
    VOID*                               pv_tag );

#endif /* _U_MHEG5_H_ */


