/* 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: u_mhp_eng.h,v $
 * $Revision: #1 $
 * $Date: 2015/11/10 $
 * $Author: dtvbm11 $
 *
 * Description:
 *         This header file contains MHP engine specific definitions, which
 *         are exported.
 *------------------------------------------------------------------------*/

#ifndef _U_MHP_ENG_H_
#define _U_MHP_ENG_H_


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

#include "u_handle_grp.h"
#include "u_common.h"

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

/* Default MHP engine name. */
#define MHP_DEFAULT_NAME  "mhp_engine"

/* MHP engine handle types. */
#define TMT_MHP_AIT      (TMT_MHP + ((HANDLE_TYPE_T)  0))
#define TMT_MHP_XAIT     (TMT_MHP + ((HANDLE_TYPE_T)  1))

/* MHP engine get operations. */
#define MHP_GET_TYPE_APP_ENTRY  (TM_GET_TYPE_LAST_ENTRY + ((TM_GET_TYPE_T) 0))
#define MHP_GET_TYPE_APP_TYPE   (TM_GET_TYPE_LAST_ENTRY + ((TM_GET_TYPE_T) 1))
#define MHP_GET_TYPE_TEST       (TM_GET_TYPE_LAST_ENTRY + ((TM_GET_TYPE_T) 2))

/* MHP engine load types. */
#if 0
#define MHP_LOAD_TYPE_PID_APP_TYPE_VER ((TM_LOAD_TYPE_LAST_ENTRY + ((TM_LOAD_TYPE_T) 0))|TM_LOAD_TYPE_SINGLE_SRC)
#endif
#define MHP_LOAD_TYPE_PID ((TM_LOAD_TYPE_LAST_ENTRY + ((TM_LOAD_TYPE_T) 1))|TM_LOAD_TYPE_SINGLE_SRC)
#define MHP_LOAD_TYPE_PID_EX (TM_LOAD_TYPE_LAST_ENTRY + ((TM_LOAD_TYPE_T) 2))
#define MHP_LOAD_TYPE_PID_APP_TYPE ((TM_LOAD_TYPE_LAST_ENTRY + ((TM_LOAD_TYPE_T) 3))|TM_LOAD_TYPE_SINGLE_SRC)
#define MHP_LOAD_TYPE_PID_APP_TYPE_EX (TM_LOAD_TYPE_LAST_ENTRY + ((TM_LOAD_TYPE_T) 4))

/* ARIB-SI engine get operations. */
#define MHP_GET_TYPE_TXT_DESCR               \
    (TM_GET_TYPE_LAST_ENTRY + ((TM_GET_TYPE_T) 7))    /**<  The operation to get text description type*/

#define MHP_GET_TYPE_TXT                     \
    (TM_GET_TYPE_LAST_ENTRY + ((TM_GET_TYPE_T) 8))    /**<  The operation to get text type */

#define MHP_GET_TYPE_TXT_LEN                 \
    (TM_GET_TYPE_LAST_ENTRY + ((TM_GET_TYPE_T) 9))    /**<   The operation to get the length of text type*/

#define MHP_GET_TYPE_SHORT_TXT               \
    (TM_GET_TYPE_LAST_ENTRY + ((TM_GET_TYPE_T) 10))    /**<  The operation to get short text type */

#define MHP_GET_TYPE_SHORT_TXT_LEN           \
    (TM_GET_TYPE_LAST_ENTRY + ((TM_GET_TYPE_T) 11))    /**<  The operation to get the length of  short text type */

#define MHP_GET_TYPE_TXT_STYLE               \
    (TM_GET_TYPE_LAST_ENTRY + ((TM_GET_TYPE_T) 12))    /**<  The operation to get the style of text type */

#define MHP_GET_TYPE_TXT_STYLE_SIZE          \
    (TM_GET_TYPE_LAST_ENTRY + ((TM_GET_TYPE_T) 13))    /**<  The operation to get the size of text style type*/
    
/* Application Types */
#define MHP_AIT_APP_TYPE_IGNORE     ((UINT16)0xffff)
#define DVB_J_APP                   ((UINT16)1)
#define DVB_HTML_APP                ((UINT16)2)

/* Application Control Codes */
#define APP_CC_AUTOSTART 1
#define APP_CC_PRESENT   2
#define APP_CC_DESTROY   3
#define APP_CC_KILL      4
#define APP_CC_PREFETCH  5
#define APP_CC_REMOTE    6

/* Possible values of requested text mode. */
/*------------------------------------------------------------------*/
/*! @enum MHP_GET_TXT_MODE_T
 *  @brief
 *  @code
 *  typedef enum
 *  {
 *      MHP_GET_TXT_NORMAL,
 *      MHP_GET_TXT_SHORT
 *  }   MHP_GET_TXT_MODE_T;
 *  @endcode
 *  @li@c  MHP_GET_TXT_NORMAL                             -normal text
 *  @li@c  MHP_GET_TXT_SHORT                              -short text
 */
/*------------------------------------------------------------------*/
typedef enum
{
    MHP_GET_TXT_NORMAL,
    MHP_GET_TXT_SHORT
}   MHP_GET_TXT_MODE_T;

/* This structure contains the UTF-8 string as well as the length of 
   the string. */
/*------------------------------------------------------------------*/
/*! @struct ISDB_SI_TXT_INFO_T
 *  @brief This structure contains the UTF-8 string as well as the 
 *         length of the string.
 *  @code
 *  typedef struct _ISDB_SI_TXT_INFO_T
 *  {
 *      CHAR*               ps_txt;
 *      SIZE_T*             pz_txt_len;
 *      ISO_3166_COUNT_T    t_count_code;
 *  }   ISDB_SI_TXT_INFO_T;
 *  @endcode
 *  @li@c  ps_txt                                            - The buffer for text information.
 *  @li@c  pz_txt_len                                        - The length of current text.
 *  @li@c  t_count_code                                      - The country code of current text.
 */
/*------------------------------------------------------------------*/
typedef struct _MHP_TXT_INFO_T
{
    CHAR*               ps_txt;
    SIZE_T*             pz_txt_len;
    ISO_3166_COUNT_T    t_count_code;
}   MHP_TXT_INFO_T;

/* Holds a stream type and PID value. */
typedef struct _MHP_APP_INFO_T
{
    UINT32 ui4_org_id;
    UINT16 ui2_app_id;
    UINT8  ui1_control_code;
}   MHP_APP_INFO_T;

/* for loading AIT */
typedef struct _MHP_PID_APP_TYPE_T
{
    MPEG_2_PID_T t_pid;
    UINT16       ui2_app_type;
} MHP_PID_APP_TYPE_T;

/* MHP engine configuration structure. */
typedef struct _MHP_CONFIG_T
{
    UINT8  ui1_num_ait_filters;

    SIZE_T  z_ait_buff_size;

    UINT16  ui2_num_ait_tbl_objs;
}   MHP_CONFIG_T;

#endif /* _U_MHP_ENG_H_ */
