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

/*-----------------------------------------------------------------------------
 * Copyright (c) 2005, MediaTek Inc.
 * All rights reserved.
 *
 * Unauthorized use, practice, perform, copy, distribution, reproduction,
 * or disclosure of this information in whole or in part is prohibited.
 *-----------------------------------------------------------------------------
 * $RCSfile: u_sb_atsc_eng.h,v $
 * $Revision: #1 $
 * $Date: 2015/11/10 $
 * $Author: dtvbm11 $
 *
 * Description:
 *         This header file contains exported definitions and delcarations of
 *         SVL Builder ATSC engine.
 *---------------------------------------------------------------------------*/
 
#ifndef _U_SB_ATSC_ENG_H_
#define _U_SB_ATSC_ENG_H_
/*----------------------------------------------------------------------------*/
/*! @defgroup groupMW_SB_ATSC_ENG ATSC Engine
 *
 *  @ingroup groupMW_SVL_BLDR
 *  @brief The atsc engine module is the module of terrestrial svl builder engine
 *  %MW Application API would be used by Application, lot of these APIs would
 *   be wrapped from Exported API. Using these APIs, application could create scan engine
 *   or start scan from the exported API of svl builder.
 *   
 *  @see groupMW_SVL_BLDR
 *  @{ 
 */
/*----------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------
                    include files
 ----------------------------------------------------------------------------*/
#include "u_common.h"

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

#define ATSC_ENG_NAME               "sb_atsc"  /**<  Define the ATSC build engine name */
#define ATSC_DEFAULT_TUNER          "CT_ATSC"  /**<  Define the ATSC Tuner engine name */

#if 0 
#define SB_VNET_ALL                 ((UINT32)   (0x00000001))
#define SB_VNET_ACTIVE              MAKE_BIT_MASK_32 (1)
#define SB_VNET_EPG                 MAKE_BIT_MASK_32 (2)
#define SB_VNET_VISIBLE             MAKE_BIT_MASK_32 (3)
#define SB_VNET_FAVORITE1           MAKE_BIT_MASK_32 (4)
#define SB_VNET_FAVORITE2           MAKE_BIT_MASK_32 (5)
#define SB_VNET_FAVORITE3           MAKE_BIT_MASK_32 (6)
#define SB_VNET_FAVORITE4           MAKE_BIT_MASK_32 (7)
#define SB_VNET_BLOCKED             MAKE_BIT_MASK_32 (8)
#endif

#define SB_ATSC_SCAN_START_IDX(value)       ((UINT16) ((value >> 16) & 0xFFFF))
#define SB_ATSC_SCAN_STOP_IDX(value)        ((UINT16) (value & 0xFFFF))

#define SCAN_START_IDX(value)       ((UINT8)   ((value >> 16) & 0xFFFF)) /**<  MACRO to get the start index of 32 bit value */
#define SCAN_STOP_IDX(value)        ((UINT8)   (value & 0xFFFF))         /**<  MACRO to get the stop index of 32 bit value */
#define DEFAULT_START_IDX           ((UINT8)     2)
#define SB_MAX_SCAN_IDX             ((UINT8)    69)

/*
 *  The structure SB_ATSC_OPEN_DATA_T is used as the argument
 *  pv_open_data of the API c_sb_open_builder()/x_sb_open_builder()
 *  when opening an SVL Builder with ATSC engine.
 *
 *  ui4_svl_id          The id of SVL to be loaded.
 *  ps_svl_name         The name of SVL to be loaded.
 *  ps_file_name        The file name from which the SVL/TSL
 *                      will be loaded.
 *  b_use_orig          A flag. When set to true, use the existed SVL,
 *                      instead of reloading it.  When set to false,
 *                      overwrite the SVL (if exists) by reloading.
 */
 
/*------------------------------------------------------------------*/
/*! @struct SB_ATSC_OPEN_DATA_T
 *  @brief It is used as the argument pv_open_data of the API c_sb_open_builder()/x_sb_open_builder() when opening an SVL Builder with ATSC engine.
 *  @code
 *  typedef struct _SB_ATSC_OPEN_DATA_T
 *  {
 *      UINT16                          ui2_svl_id;
 *      CHAR*                           ps_svl_name;
 *      CHAR*                           ps_file_name;
 *      CHAR*                           ps_tuner_name;    
 *      BOOL                            b_use_orig;
 *  }   SB_ISDB_OPEN_DATA_T;
 *  @endcode
 *  @li@c  ui2_svl_id                                        - The id of SVL to be loaded.
 *  @li@c  ps_svl_name                                       - The name of SVL to be loaded.
 *  @li@c  ps_file_name                                      - The file name from which the SVL/TSL will be loaded.
 *  @li@c  ps_tuner_name                                     - The name of tuner to be connectted.
 *  @li@c  b_use_orig                                        - A flag. When set to true, use the existed SVL, instead of reloading it
 */
/*------------------------------------------------------------------*/
typedef struct _SB_ATSC_OPEN_DATA_T
{
    UINT16      ui2_svl_id;
    CHAR*       ps_svl_name;
    CHAR*       ps_file_name;
    CHAR*       ps_tuner_name;    
    BOOL        b_use_orig;
} SB_ATSC_OPEN_DATA_T;


/* ATSC scan type */
/*------------------------------------------------------------------*/
/*! @enum SB_ATSC_SCAN_TYPE_T
 *  @brief It contains different scan types that are used to initialize scan parameters.
 *  @code
 *  typedef enum
 *  {
 *     SB_ATSC_SCAN_TYPE_UNKNOWN = 0,
 *     SB_ATSC_SCAN_TYPE_FULL_MODE,
 *     SB_ATSC_SCAN_TYPE_QUICK_MODE,
 *     SB_ATSC_SCAN_TYPE_ADD_ON_MODE,
 *     SB_ATSC_SCAN_TYPE_SINGLE_RF_CHANNEL,
 *     SB_ATSC_SCAN_TYPE_RANGE_RF_CHANNEL,    
 *     SB_ATSC_SCAN_TYPE_NUM 
 *  } SB_ATSC_SCAN_TYPE_T;
 *  @endcode
 *  @li@c  SB_ATSC_SCAN_TYPE_UNKNOWN                         - Unknown.
 *  @li@c  SB_ISDB_SCAN_TYPE_FULL_MODE                       - Scan all frequency of all bands. It means from first scan index to last.
 *  @li@c  SB_ATSC_SCAN_TYPE_QUICK_MODE                      - Scan all frequency with skip the frequency that already scanned
 *  @li@c  SB_ATSC_SCAN_TYPE_ADD_ON_MODE                     - Add digital channels
 *  @li@c  SB_ATSC_SCAN_TYPE_SINGLE_RF_CHANNEL               - Single Rf scan
 *  @li@c  SB_ATSC_SCAN_TYPE_RANGE_RF_CHANNEL                - Range scan
 *  @li@c  SB_ATSC_SCAN_TYPE_NUM                             - The number of scan type.
 */
/*------------------------------------------------------------------*/
typedef enum
{
    SB_ATSC_SCAN_TYPE_UNKNOWN = 0,
    SB_ATSC_SCAN_TYPE_FULL_MODE,
    SB_ATSC_SCAN_TYPE_QUICK_MODE,
    SB_ATSC_SCAN_TYPE_ADD_ON_MODE,
    SB_ATSC_SCAN_TYPE_SINGLE_RF_CHANNEL,
    SB_ATSC_SCAN_TYPE_RANGE_RF_CHANNEL,    
    SB_ATSC_SCAN_TYPE_NUM /* number of scan types */
} SB_ATSC_SCAN_TYPE_T;

/* frequency plan FOR at */
#define SB_ATSC_FREQ_PLAN_ANTANNA  ((UINT8) 0x7)

/*
 *  The structure SB_ATSC_SCAN_DATA_T is used as the argument 
 *  pv_scan_data of the API x_sb_start_scan() when scaning 
 *  a media.
 *
 *  e_scan_type     Specifies the way to scan.
 *
 *  ui4_scan_info   Contains the required scan information. 
 * 
 *                  The most significant two bytes indicate the index where
 *                  an engine should start scan while the least significant
 *                  two bytes indicate the index where an engine should 
 *                  stop scan.
 *
 *                  For SB_ATSC_SCAN_TYPE_FULL_MODE, SB_ATSC_SCAN_TYPE_QUICK_MODE,
 *                  SB_ATSC_SCAN_TYPE_ADD_ON_MODE, and 
 *                  SB_ATSC_SCAN_TYPE_SINGLE_RF_CHANNEL modes, only the most 
 *                  significant two bytes are taken.       
 *
 *  ps_tuner_name   An optional parameter.  If not NULL, it will be
 *                  used to perform the connection routines. 
 */
/*------------------------------------------------------------------*/
/*! @struct SB_ATSC_SCAN_DATA_T
 *  @brief The sub information for the range of scan index in ATSC scan process.
 *  @code
 *      struct {
 *          UINT16              ui2_start_scan_idx;
 *          UINT16              ui2_end_scan_idx;
 *      } SB_ATSC_SCAN_DATA_T;
 *  @endcode
 *  @li@c  ui2_start_scan_idx                                - The start index in this scan process.
 *  @li@c  ui2_end_scan_idx                                  - The end index in this scan process.
 */
/*------------------------------------------------------------------*/
typedef struct _SB_ATSC_SCAN_DATA_T
{
    SB_ATSC_SCAN_TYPE_T     e_scan_type;
    UINT32                  ui4_scan_info; 
} SB_ATSC_SCAN_DATA_T;

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

#endif /* _U_SB_ATSC_ENG_H_ */
