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

/*----------------------------------------------------------------------------*/
/*! @file u_sm_ttx_event.h 
 *  $RCSfile: $
 *  $Revision: #1 $
 *  $Date: 2015/05/29 $
 *  $Author: brianpc.huang $
 *  
 *  @par Description:
 *         This header file contains Subtitle Stream handler specific 
 *         events.
 */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/*! @addtogroup groupMW_STRM_MNGR_TTX_HDLR
 *  @{ 
 */
/*----------------------------------------------------------------------------*/

#ifndef _U_SM_TTX_EVENT_H_
#define _U_SM_TTX_EVENT_H_


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

#include "u_common.h"
#include "u_sm_event.h"
#include "u_sm_ttx_common.h"
#include "u_wgl_ttx.h"

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

#define SM_EVN_TTX_APP_OPEN_REQ             ((SM_EVN_TYPE_T) SM_EVN_GRP_TTX + 0)    /**<APP open require event */
#define SM_EVN_TTX_APP_PLAY_REQ             ((SM_EVN_TYPE_T) SM_EVN_GRP_TTX + 1)    /**<APP play require event */
#define SM_EVN_TTX_APP_STOP_REQ             ((SM_EVN_TYPE_T) SM_EVN_GRP_TTX + 2)    /**<APP stop require event */
#define SM_EVN_TTX_APP_CLOSE_REQ            ((SM_EVN_TYPE_T) SM_EVN_GRP_TTX + 3)    /**<APP close require event */
#define SM_EVN_TTX_DRV_OPENED               ((SM_EVN_TYPE_T) SM_EVN_GRP_TTX + 4)    /**<Drive opened event */
#define SM_EVN_TTX_DRV_PLAYED               ((SM_EVN_TYPE_T) SM_EVN_GRP_TTX + 5)    /**<Drive played event*/
#define SM_EVN_TTX_DRV_STOPPED              ((SM_EVN_TYPE_T) SM_EVN_GRP_TTX + 6)    /**<Drive stopped event*/
#define SM_EVN_TTX_DRV_CLOSED               ((SM_EVN_TYPE_T) SM_EVN_GRP_TTX + 7)    /**<Drive closed event*/
#define SM_EVN_TTX_DRV_ERR                  ((SM_EVN_TYPE_T) SM_EVN_GRP_TTX + 8)    /**<Drive Error event*/
#define SM_EVN_TTX_SCDB_RECORD_DEL          ((SM_EVN_TYPE_T) SM_EVN_GRP_TTX + 9)    /**<Scdb record elete event*/
#define SM_EVN_TTX_NOT_AUTHORIZED           ((SM_EVN_TYPE_T) SM_EVN_GRP_TTX + 10)    /**<Not authorized event*/
#define SM_EVN_TTX_INTERNAL_ERR             ((SM_EVN_TYPE_T) SM_EVN_GRP_TTX + 11)    /**<Internal error event*/

/* Notify information to upper layer application.The notify function can see:
    typedef INT32 (*x_stream_nfy_fct)( HANDLE_T        h_stream,
                                                       SM_COND_T       e_nfy_cond,
                                                       VOID*           pv_nfy_tag,
                                                       SM_EVN_TYPE_T   e_event,
                                                       UINT32          ui4_data );

ui4_data contains pointer points to structure SM_TTXH_EVN_WGL_UPDATE_T
*/
#define SM_EVN_TTX_WGL_UPDATE_NFY           ((SM_EVN_TYPE_T) SM_EVN_GRP_TTX + 12)   

/**Notify information if stream status is changed.
    typedef INT32 (*x_stream_nfy_fct)( HANDLE_T        h_stream,
                                                       SM_COND_T       e_nfy_cond,
                                                       VOID*           pv_nfy_tag,
                                                       SM_EVN_TYPE_T   e_event,
                                                       UINT32          ui4_data );

ui4_data contains pointer points to structure SM_TTXH_EVN_STREAM_UPDATE_T
*/
#define SM_EVN_TTX_STREAM_UPDATE_NFY        ((SM_EVN_TYPE_T) SM_EVN_GRP_TTX + 13)    

/**
    Notify information if below information of SM_TTX_PAGE_BASIC_INFO_T is updated. 
    BOOL                                    b_existed;
    BOOL                                    b_newsflash;
    BOOL                                    b_subtitle;
    BOOL                                    b_suppress_header;
    BOOL                                    b_inhibit_display;
    BOOL                                    b_display_row24;
    BOOL                                    b_has_side_pnl;
    BOOL                                    b_has_flof_info;
    BOOL                                    b_has_top_info;
    UINT8                                   ui1_left_side_pnl_col_num;
    SM_TTX_PAGE_TYPE_T            e_page_type;

    The notify function can see:
    typedef INT32 (*x_stream_nfy_fct)( HANDLE_T        h_stream,
                                                       SM_COND_T       e_nfy_cond,
                                                       VOID*           pv_nfy_tag,
                                                       SM_EVN_TYPE_T   e_event,
                                                       UINT32          ui4_data );
    
    ui4_data contains pointer points to structure SM_TTXH_EVN_CUR_PAGE_UPDATE_T
*/
#define SM_EVN_TTX_CUR_PAGE_UPDATE_NFY      ((SM_EVN_TYPE_T) SM_EVN_GRP_TTX + 14)    

/**Notify information if last page is received.    The notify function can see:
    typedef INT32 (*x_stream_nfy_fct)( HANDLE_T        h_stream,
                                                       SM_COND_T       e_nfy_cond,
                                                       VOID*           pv_nfy_tag,
                                                       SM_EVN_TYPE_T   e_event,
                                                       UINT32          ui4_data );

    ui4_data contains pointer points to structure SM_TTXH_EVN_SUBPAGE_UPDATE_T
*/
#define SM_EVN_TTX_SUBPAGE_UPDATE_NFY       ((SM_EVN_TYPE_T) SM_EVN_GRP_TTX + 15)    

/**
    Notify information if newsflash update.The notify function can see:
    typedef INT32 (*x_stream_nfy_fct)( HANDLE_T        h_stream,
                                                       SM_COND_T       e_nfy_cond,
                                                       VOID*           pv_nfy_tag,
                                                       SM_EVN_TYPE_T   e_event,
                                                       UINT32          ui4_data );
                                                       
    ui4_data contains pointer points to structure SM_TTXH_EVN_NEWSFLASH_UPDATE_T
*/
#define SM_EVN_TTX_NEWSFLASH_UPDATE_NFY       ((SM_EVN_TYPE_T) SM_EVN_GRP_TTX + 16)    

/**
    Notify information if teletext x_rated update.The notify function can see:
    typedef INT32 (*x_stream_nfy_fct)( HANDLE_T        h_stream,
                                                       SM_COND_T       e_nfy_cond,
                                                       VOID*           pv_nfy_tag,
                                                       SM_EVN_TYPE_T   e_event,
                                                       UINT32          ui4_data );
                                                       
    ui4_data contains pointer points to structure SM_EVN_TTX_X_RATED_UPDATE_NFY
*/
#define SM_EVN_TTX_X_RATED_UPDATE_NFY       ((SM_EVN_TYPE_T) SM_EVN_GRP_TTX + 17)  

/*-----------------------------------------------------------------------------
                    structure
-----------------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
/*! @struct SM_TTXH_EVN_WGL_UPDATE_T
 *  @brief This struct contains the ttx widget update information 
 *  @code
 *  typedef struct _SM_TTXH_EVN_WGL_UPDATE_T
 *  {
 *      UINT8                   ui1_wgl_id;
 *      WGL_TTX_NFY_REASON_T    e_reason;
 *      UINT32                  ui4_data;
 *  } SM_TTXH_EVN_WGL_UPDATE_T;
 *  @endcode
 *  @li@c  ui1_wgl_id                      -The widget id to update,from 0
 *  @li@c  e_reason                         -The widget to update reason type.
 *  @li@c  ui4_data                          -Contains the notify data
 */
/*------------------------------------------------------------------*/
typedef struct _SM_TTXH_EVN_WGL_UPDATE_T
{
    /* Widget id */
    UINT8                   ui1_wgl_id;

    /* Widget notify reason */
    WGL_TTX_NFY_REASON_T    e_reason;

    /* Widget notify data */
    UINT32                  ui4_data;
} SM_TTXH_EVN_WGL_UPDATE_T;


#define SM_TTXH_EVN_STREAM_UPDATE_MASK_REC_PAGES        0x01    /**<Recieved normal page notify mask flag*/
#define SM_TTXH_EVN_STREAM_UPDATE_MASK_REC_SUBTITLE     0x02    /**<Recieved subtitle page notify mask flag*/
#define SM_TTXH_EVN_STREAM_UPDATE_MASK_TOP_UPDATE       0x04    /**<Recieved TOP page notify mask flag */

/*------------------------------------------------------------------*/
/*! @struct SM_TTXH_EVN_STREAM_UPDATE_T
 *  @brief This struct contains the ttx stream notify information
 *  @code
 *  typedef struct _SM_TTXH_EVN_STREAM_UPDATE_T
 *  {
 *      UINT8                   ui1_mask;
 *      BOOL                    b_rec_pages;
 *      BOOL                    b_rec_subtitle;
 *      BOOL                    b_top_update;
 *  } SM_TTXH_EVN_STREAM_UPDATE_T;
 *  @endcode
 *  @li@c  ui1_mask                           -Contains the update type information
 *  @li@c  b_rec_pages                       -True :it recieved the normal page
 *  @li@c  b_rec_subtitle                     -True:it recieved the subtitle page
 *  @li@c  b_top_update                      -True:it recieved the top page
 */
/*------------------------------------------------------------------*/
typedef struct _SM_TTXH_EVN_STREAM_UPDATE_T
{
    /* Mask of update stream */
    UINT8                   ui1_mask;

    /* received pages */
    BOOL                    b_rec_pages;

    /* received subtitle pages */
    BOOL                    b_rec_subtitle;

    /* Whether TOP information is updated */
    BOOL                    b_top_update;
} SM_TTXH_EVN_STREAM_UPDATE_T;

/*------------------------------------------------------------------*/
/*! @struct SM_TTXH_EVN_CUR_PAGE_UPDATE_T
 *  @brief This struct contains the updating page event information
 *  @code
 *  typedef struct _SM_TTXH_EVN_CUR_PAGE_UPDATE_T
 *  {
 *      UINT8                   ui1_wgl_id;
 *  } SM_TTXH_EVN_CUR_PAGE_UPDATE_T;
 *  @endcode
 *  @li@c  ui1_wgl_id                 -The widget that is to update
 */
/*------------------------------------------------------------------*/
typedef struct _SM_TTXH_EVN_CUR_PAGE_UPDATE_T
{
    /* Widget id */
    UINT8                   ui1_wgl_id;
} SM_TTXH_EVN_CUR_PAGE_UPDATE_T;

/*------------------------------------------------------------------*/
/*! @struct SM_TTXH_EVN_SUBPAGE_UPDATE_T
 *  @brief This struct contains the update subpage event information
 *  @code
 *  typedef struct _SM_TTXH_EVN_SUBPAGE_UPDATE_T
 *  {
 *      UINT8                   ui1_wgl_id;
 *      SM_TTX_PAGE_ADDR_T      t_page_addr;
 *  } SM_TTXH_EVN_SUBPAGE_UPDATE_T;
 *  @endcode
 *  @li@c  ui1_wgl_id                       -The widget id,from 0
 *  @li@c  t_page_addr                     -The page address that is to update
 */
/*------------------------------------------------------------------*/
typedef struct _SM_TTXH_EVN_SUBPAGE_UPDATE_T
{
    /* Widget id */
    UINT8                   ui1_wgl_id;

    /* Page address */
    SM_TTX_PAGE_ADDR_T      t_page_addr;
} SM_TTXH_EVN_SUBPAGE_UPDATE_T;

/*------------------------------------------------------------------*/
/*! @struct SM_TTXH_EVN_NEWSFLASH_UPDATE_T
 *  @brief This struct contains the newflash page update information
 *  @code
 *  typedef struct _SM_TTXH_EVN_NEWSFLASH_UPDATE_T
 *  {
 *      SM_TTX_PAGE_ADDR_T      t_page_addr;
 *  }SM_TTXH_EVN_NEWSFLASH_UPDATE_T;
 *  @endcode
 *  @li@c  t_page_addr                -Page addr that is newflash type and to update
 */
/*------------------------------------------------------------------*/
typedef struct _SM_TTXH_EVN_NEWSFLASH_UPDATE_T
{
    /*Page address*/
    SM_TTX_PAGE_ADDR_T      t_page_addr;
}SM_TTXH_EVN_NEWSFLASH_UPDATE_T;

#endif /* _U_SM_TTX_EVENT_H_ */

/*----------------------------------------------------------------------------*/
/*! @} */                /* end of groupMW_STRM_MNGR_TTX_HDLR */
/*----------------------------------------------------------------------------*/


