/* 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.
 */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/*! @addtogroup groupMW_DRM_DIVX
 *  @{  
 */
/*----------------------------------------------------------------------------*/

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

#include "x_common.h"
#include "x_drm.h"
#include "u_divx_drm.h"

#ifdef __cplusplus
extern "C" {
#endif
/*-----------------------------------------------------------------------------
                    macros, defines, typedefs, enums
 ----------------------------------------------------------------------------*/
/* This defines the divx drm group. */
#define DRM_GRP_DIVX_DRM (2 << DRM_CODE_BITS)                                               /**< DIVX DRM GROUP */

/* The following lists all divx drm commands. */
#define DRM_CMD_CODE_DIVX_DRM_STRD_CHUNK  ((DRM_CMD_CODE_T) (DRM_GRP_DIVX_DRM | 0))         /**< DIVX DRM CMD STRD CHUNK */
#define DRM_CMD_CODE_DIVX_DRM_REGISTRATION_CODE  ((DRM_CMD_CODE_T) (DRM_GRP_DIVX_DRM | 1))  /**< DIVX DRM CMD REGISTRATION CODE */
#define DRM_CMD_CODE_DIVX_DRM_DEACTIVATION_CODE  ((DRM_CMD_CODE_T) (DRM_GRP_DIVX_DRM | 2))  /**< DIVX DRM CMD DEACTIVATION CODE */

/* The following lists all drm set divx drm types. */
#define DRM_SET_TYPE_DIVX_DRM_PLAYBACK ((DRM_SET_TYPE_T)(DRM_GRP_DIVX_DRM | 0))             /**< DIVX DRM SET TYPE PLAYBACK */

/* The following lists all drm get divx drm types. */
#define DRM_GET_TYPE_DIVX_DRM_BASIC_INFO ((DRM_GET_TYPE_T)(DRM_GRP_DIVX_DRM | 0))           /**< DIVX DRM GET TYPE BASIC INFO */
#define DRM_GET_TYPE_DIVX_DRM_CRYPTO_INFO ((DRM_GET_TYPE_T)(DRM_GRP_DIVX_DRM | 1))          /**< DIVX DRM GET TYPE CRYPTO INFO */

/*---------------------------------------------------------------------------*/
/*! 
 *  @brief  This union defines divx drm info.
 *  @code
 *  typedef union _DIVX_DRM_UNION_INFO_T
 *    DIVX_DRM_REGISTRATION_INFO_T* pt_divx_drm_registration_info;
 *    DIVX_DRM_DEACTIVATION_INFO_T* pt_divx_drm_deactivation_info;    
 *    DIVX_DRM_BASIC_INFO_T* pt_divx_drm_basic_info;
 *    DIVX_DRM_CRYPTO_INFO_T* pt_divx_drm_crypto_info;
 *    DRM_OUTPUT_SIGNAL_PROTECTION_INFO_T* pt_drm_output_signal_protection_info;
 *  } DIVX_DRM_UNION_INFO_T;
 *  @endcode
 *  @li@c  pt_divx_drm_registration_info            - divx drm registration info.
 *  @li@c  pt_divx_drm_deactivation_info            - divx drm deactivation info.
 *  @li@c  pt_divx_drm_basic_info                   - divx drm basic info.
 *  @li@c  pt_divx_drm_crypto_info                  - divx drm crypto info.
 *  @li@c  pt_drm_output_signal_protection_info     - divx drm signal protection info. 
 */
/*---------------------------------------------------------------------------*/
typedef union _DIVX_DRM_UNION_INFO_T{
    DIVX_DRM_REGISTRATION_INFO_T* pt_divx_drm_registration_info;
    DIVX_DRM_DEACTIVATION_INFO_T* pt_divx_drm_deactivation_info;    
    DIVX_DRM_BASIC_INFO_T* pt_divx_drm_basic_info;
    DIVX_DRM_CRYPTO_INFO_T* pt_divx_drm_crypto_info;
    DRM_OUTPUT_SIGNAL_PROTECTION_INFO_T* pt_drm_output_signal_protection_info;
} DIVX_DRM_UNION_INFO_T;

/* This defines the divx drm generic group. */
#define DRM_GRP_DIVX_DRM_GENERIC (3 << DRM_CODE_BITS)                                                      /**< DIVX DRM GENERIC GROUP */

/* The following lists all drm set divx drm generic types. */
#define DRM_SET_TYPE_DIVX_DRM_GENERIC_DEACTIVATION ((DRM_SET_TYPE_T)(DRM_GRP_DIVX_DRM_GENERIC | 0))        /**< DIVX DRM GENERIC SET TYPE DEACTIVATION */
#define DRM_SET_TYPE_DIVX_DRM_GENERIC_MEMORY_RW_FUNC ((DRM_SET_TYPE_T)(DRM_GRP_DIVX_DRM_GENERIC | 1))      /**< DIVX DRM GENERIC SET MEMORY RW FUNC */


/* The following lists all drm get divx drm generic types. */
#define DRM_GET_TYPE_DIVX_DRM_GENERIC_REGISTRATION_INFO ((DRM_GET_TYPE_T)(DRM_GRP_DIVX_DRM_GENERIC | 0))   /**< DIVX DRM GENERIC GET TYPE REGISTRATION INFO */
#define DRM_GET_TYPE_DIVX_DRM_GENERIC_UI_HELP_INFO ((DRM_GET_TYPE_T)(DRM_GRP_DIVX_DRM_GENERIC | 1))        /**< DIVX DRM GENERIC UI HELP INFO */

#undef DBG_MODULE_NAME_PREFIX

#define DBG_MODULE_NAME_PREFIX x_divx_drm_get_log_prefix()

/*-----------------------------------------------------------------------------
                    extern data declarations
 ----------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------
                    data declarations
 ----------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------
                    functions declarations
 ----------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/*! @brief  This API initializes the divx drm.
 *
 *  @param  [in] pt_divx_drm_init_config  Reference to the divx drm 
 *               configuration structure.
 *
 *  @return  INT32
 */
/*---------------------------------------------------------------------------*/
extern INT32 x_divx_drm_init (
    DIVX_DRM_INIT_CONFIG_T* pt_divx_drm_init_config);

extern CHAR* x_divx_drm_get_log_prefix(VOID);

#ifndef __KERNEL__
/*---------------------------------------------------------------------------*/
/*! @brief  This API provides the divx drm memory info.
 *
 *  @param  [in, out] pui2_divx_drm_memory_offset  Reference to the divx drm 
 *                    offset in whole eeprom.
 *  @param  [in, out] pui2_divx_drm_memory_size_byte  Reference to the divx 
 *                    drm size in byte.
 *
 *  @return  VOID
 */
/*---------------------------------------------------------------------------*/
extern VOID x_divx_drm_mem_info (
    UINT16* pui2_divx_drm_memory_offset,
    UINT16* pui2_divx_drm_memory_size_byte);
#endif

#ifdef __cplusplus
}
#endif

#endif /* _X_DIVX_DRM_H_ */

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