/* 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 
 *  $RCSfile: $
 *  $Revision: #1 $
 *  $Date: 2015/06/02 $
 *  $Author: cong.wang $
 *  
 *  @par Description:
 *         This header file contains DIVX DRM specific definitions,
 *         which are exported.
 */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/*! @defgroup groupMW_DRM_DIVX DIVX Digital Rights Management
 *
 *  @ingroup groupMW_DRM
 *  @brief Provides a unified interface for DIVX DRM
 *
 *  @see groupMW
 *  @{ 
 */
/*----------------------------------------------------------------------------*/

#ifndef _U_DIVX_DRM_H_
#define _U_DIVX_DRM_H_
/*-----------------------------------------------------------------------------
                    include files
 ----------------------------------------------------------------------------*/

#include "u_common.h"
#include "u_drm.h"

#ifdef __cplusplus
extern "C" {
#endif
/*-----------------------------------------------------------------------------
                    macros, defines, typedefs, enums
 ----------------------------------------------------------------------------*/
#define DRM_TYPE_DIVX_DRM ((DRM_TYPE_T)1) /**< This defines the divx drm type. */ 

/*---------------------------------------------------------------------------*/
/*! @struct DIVX_DRM_INIT_CONFIG_T
 *  @brief  This structure defines the divx drm initial configuration.
 *  @code
 *  typedef struct _DIVX_DRM_INIT_CONFIG_T
 *  {
 *      UINT16 ui2_divx_drm_memory_offset;
 *      UINT16 ui2_divx_drm_memory_size_byte;
 *      UINT8 ui1_divx_drm_model_id_low_byte;
 *      UINT8 ui1_divx_drm_model_id_high_byte;    
 *  } DIVX_DRM_INIT_CONFIG_T;
 *  @endcode
 *  @li@c  ui2_divx_drm_memory_offset      - drm memory offset of the whole 
 *                                           EEPROM.
 *  @li@c  ui2_divx_drm_memory_size_byte   - drm memory size.
 *  @li@c  ui1_divx_drm_model_id_low_byte  - low byte of drm model id.
 *  @li@c  ui1_divx_drm_model_id_high_byte - high byte of drm model id.
 */
/*---------------------------------------------------------------------------*/
typedef struct _DIVX_DRM_INIT_CONFIG_T
{
    UINT16 ui2_divx_drm_memory_offset;
    UINT16 ui2_divx_drm_memory_size_byte;
    UINT8 ui1_divx_drm_model_id_low_byte;
    UINT8 ui1_divx_drm_model_id_high_byte;    
} DIVX_DRM_INIT_CONFIG_T;

/*---------------------------------------------------------------------------*/
/*! @struct DIVX_DRM_REGISTRATION_INFO_T
 *  @brief  This structure defines the divx drm registration info.
 *  @code
 *  typedef struct _DIVX_DRM_REGISTRATION_INFO_T
 *  {
 *      CHAR s_registration_code[11];
 *  } DIVX_DRM_REGISTRATION_INFO_T;
 *  @endcode
 *  @li@c  s_registration_code  - divx drm registration code.
 */
/*---------------------------------------------------------------------------*/
typedef struct _DIVX_DRM_REGISTRATION_INFO_T
{
    CHAR s_registration_code[11/*DRM_REGISTRATION_CODE_BYTES*/];
} DIVX_DRM_REGISTRATION_INFO_T;

/*---------------------------------------------------------------------------*/
/*! @struct DIVX_DRM_DEACTIVATION_INFO_T
 *  @brief  This structure defines the divx drm deactivation info.
 *  @code
 *  typedef struct _DIVX_DRM_DEACTIVATION_INFO_T
 *  {
 *      CHAR s_deactivation_code[9];
 *  } DIVX_DRM_DEACTIVATION_INFO_T;
 *  @endcode
 *  @li@c  s_deactivation_code  - divx drm deactivation code.
 */
/*---------------------------------------------------------------------------*/
typedef struct _DIVX_DRM_DEACTIVATION_INFO_T
{
    CHAR s_deactivation_code[9];
} DIVX_DRM_DEACTIVATION_INFO_T;

/*---------------------------------------------------------------------------*/
/*! @struct DIVX_DRM_UI_HELP_INFO_T
 *  @brief  This structure defines the divx drm UI info.
 *  @code
 *  typedef struct _DIVX_DRM_UI_HELP_INFO_T
 *  {
 *  #define DIVX_DRM_REGISTRATION_CODE_HIDE ((UINT32)1 << 0)
 *  #define DIVX_DRM_DEACTIVATION_CONFIRMATION ((UINT32)1 << 1)
 *      UINT32 ui4_divx_drm_ui_help_info;
 *  } DIVX_DRM_UI_HELP_INFO_T;
 *  @endcode
 *  @li@c  ui4_divx_drm_ui_help_info  - flag to indicate divx drm ui display.
 */
/*---------------------------------------------------------------------------*/
typedef struct _DIVX_DRM_UI_HELP_INFO_T
{
#define DIVX_DRM_REGISTRATION_CODE_HIDE ((UINT32)1 << 0)
#define DIVX_DRM_DEACTIVATION_CONFIRMATION ((UINT32)1 << 1)
#define DIVX_DRM_HAVE_REGISTERED ((UINT32)1 << 2)
    UINT32 ui4_divx_drm_ui_help_info;
} DIVX_DRM_UI_HELP_INFO_T;

/*---------------------------------------------------------------------------*/
/*! 
 *  @brief  This defines the divx drm memory read function pointer.
 *  @code
 *  typedef 
BOOL (*divx_drm_memory_read_func)(UINT8* pui1_divx_drm_mem);
 *  @endcode
 */
/*---------------------------------------------------------------------------*/
typedef 
BOOL (*divx_drm_memory_read_func)(UINT8* pui1_divx_drm_mem);

/*---------------------------------------------------------------------------*/
/*! 
 *  @brief  This defines the divx drm memory write function pointer.
 *  @code
 *  typedef 
BOOL (*divx_drm_memory_write_func)(UINT8* pui1_divx_drm_mem);
 *  @endcode
 */
/*---------------------------------------------------------------------------*/
typedef 
BOOL (*divx_drm_memory_write_func)(UINT8* pui1_divx_drm_mem);

/*---------------------------------------------------------------------------*/
/*! @struct DIVX_DRM_MEMORY_RW_FUNC_INFO_T
 *  @brief  This structure defines the divx drm memory r/w functions.
 *  @code
 *  typedef struct _DIVX_DRM_MEMORY_RW_FUNC_INFO_T
 *  {
 *     divx_drm_memory_read_func pfn_divx_drm_memory_read_func;
 *     divx_drm_memory_read_func pfn_divx_drm_memory_write_func;
 *  } DIVX_DRM_MEMORY_RW_FUNC_INFO_T;
 *  @endcode
 *  @li@c  pfn_divx_drm_memory_read_func   - divx drm memory read function pointer.
 *  @li@c  pfn_divx_drm_memory_write_func  - divx drm memory write function pointer.
 */
/*---------------------------------------------------------------------------*/
typedef struct _DIVX_DRM_MEMORY_RW_FUNC_INFO_T
{
    divx_drm_memory_read_func pfn_divx_drm_memory_read_func;
    divx_drm_memory_read_func pfn_divx_drm_memory_write_func;
} DIVX_DRM_MEMORY_RW_FUNC_INFO_T;

/*---------------------------------------------------------------------------*/
/*! @struct DIVX_DRM_BASIC_INFO_T
 *  @brief  This structure defines the divx drm basic info.
 *  @code
 *  typedef struct _DIVX_DRM_BASIC_INFO_T
 *  {
 *  #define DIVX_DRM_RENTAL ((UINT8)1 << 0)
 *  #define DIVX_DRM_RENTAL_EXPIRED ((UINT8)1 << 1)
 *  #define DIVX_DRM_AUTH_ERROR ((UINT8)1 << 2)
 *      UINT8 ui1_flag;
 *      UINT8 ui1_use_count;
 *      UINT8 ui1_use_limit;
 *  } DIVX_DRM_BASIC_INFO_T;
 *  @endcode
 *  @li@c  ui1_flag       - flag to indicate divx drm ui display.
 *  @li@c  ui1_use_count  - use count of the dive drm clip.
 *  @li@c  ui1_use_limit  - use limit of the dive drm clip.
 */
/*---------------------------------------------------------------------------*/
typedef struct _DIVX_DRM_BASIC_INFO_T
{
#define DIVX_DRM_RENTAL ((UINT8)1 << 0)
#define DIVX_DRM_RENTAL_EXPIRED ((UINT8)1 << 1)
#define DIVX_DRM_AUTH_ERROR ((UINT8)1 << 2)
#define DIVX_DRM_VER_ERROR ((UINT8)1 << 3)

    UINT8 ui1_flag;
    UINT8 ui1_use_count;
    UINT8 ui1_use_limit;
} DIVX_DRM_BASIC_INFO_T;

/*---------------------------------------------------------------------------*/
/*! 
 *  @brief  This union defines divx drm generic info.
 *  @code
 *  typedef union _DIVX_DRM_UNION_GENERIC_INFO_T
 *  {
 *      DIVX_DRM_REGISTRATION_INFO_T t_divx_drm_registration_info;
 *      DIVX_DRM_DEACTIVATION_INFO_T t_divx_drm_deactivation_info;
 *      DIVX_DRM_UI_HELP_INFO_T t_divx_drm_ui_help_info;
 *      DIVX_DRM_MEMORY_RW_FUNC_INFO_T t_divx_drm_memory_rw_func_info; 
 *  } DIVX_DRM_UNION_GENERIC_INFO_T;
 *  @endcode
 *  @li@c  t_divx_drm_registration_info  - divx drm registration info.
 *  @li@c  t_divx_drm_deactivation_info  - divx drm deactivation info.
 *  @li@c  t_divx_drm_ui_help_info       - divx drm ui help info.
 *  @li@c  t_divx_drm_eeprom_rw_func_info   - divx drm memory r/w func info. 
 */
/*---------------------------------------------------------------------------*/
typedef union _DIVX_DRM_UNION_GENERIC_INFO_T
{
    DIVX_DRM_REGISTRATION_INFO_T t_divx_drm_registration_info;
    DIVX_DRM_DEACTIVATION_INFO_T t_divx_drm_deactivation_info;
    DIVX_DRM_UI_HELP_INFO_T t_divx_drm_ui_help_info;
    DIVX_DRM_MEMORY_RW_FUNC_INFO_T t_divx_drm_memory_rw_func_info;
} DIVX_DRM_UNION_GENERIC_INFO_T;

/*-----------------------------------------------------------------------------
                    extern data declarations
 ----------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------
                    data declarations
 ----------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------
                    functions declarations
 ----------------------------------------------------------------------------*/

#ifdef __cplusplus
}
#endif

#endif /* _U_DIVX_DRM_H_ */

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