/* 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 c_cap.h 
 *  $RCSfile: $
 *  $Revision: #1 $
 *  $Date: 2015/05/29 $
 *  $Author: brianpc.huang $
 *  
 *  @par Description:
 *         This file exports all capture library API and constant for 
 *         other module using.
 */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/*! @defgroup groupMW_CAP Capture Logo
 *
 *  @ingroup groupMW
 *  @brief Provides external function TV Application
 *
 *  %MW Application API would be used by TV Application, lot of these APIs would
 *   be wrapped from Exported API
 *
 *  @see groupMW
 *  @{ 
 */
/*----------------------------------------------------------------------------*/

#ifndef _C_CAP_H_
#define _C_CAP_H_


/*-----------------------------------------------------------------------------
                    include files
 ----------------------------------------------------------------------------*/
#include "u_common.h"
#include "u_handle.h"
#include "u_cap.h"
/*-----------------------------------------------------------------------------
                    macros, defines, typedefs, enums
 ----------------------------------------------------------------------------*/

#ifdef __cplusplus
extern "C" {
#endif

/*-----------------------------------------------------------------------------
                    functions declarations
 ----------------------------------------------------------------------------*/

/*------------------------------------------------------------------*/
/*! @brief      x_cap_nfy_fct
 *              This function is the callback function of capture library.
 *  @param [in] h_handle     Specifies which handle will be notified. 
 *  @param [in] pv_tag       The client data specified by the client when callback has been called, the callback function will send it again.. 
 *  @param [in] e_event      It identifies the event type of notification. 
 *  @param [in] pv_data      Specified the notification data which is followed with the notification event. 
 */
/*------------------------------------------------------------------*/
typedef VOID (*c_cap_nfy_fct) (
                                HANDLE_T                h_handle,  /* (I) Specifies which handle will be notified. */
                                const VOID*             pv_tag,    /* (I) The client data specified by the client when callback has been called, the callback function will send it again.. */
                                CAP_EVENT_TYPE_T        e_event,   /* (I) It identifies the event type of notification. */
                                const VOID*             pv_data);  /* (I) specify the notification data which is followed with the notification event. */

/*------------------------------------------------------------------*/
/*! @brief      c_cap_cust_fct
 *              This function is the function of capture library.
 *  @param [in] ui4_source   Specifies the source which will be captured. 
 *  @param [in] e_event      It identifies the event type of notification. 
 *  @param [in] pv_data      Specified the notification data which is followed with the notification event. 
 */
/*------------------------------------------------------------------*/
typedef BOOL (*c_cap_cust_fct) (
                                CAP_SRC_TYPE_T          e_source,    /* (I) Specifies the source which will be captured. */
                                CAP_EVENT_TYPE_T        e_event,     /* (I) It identifies the event type of notification. */
                                const VOID*             pv_data);    /* (I) specify the notification data which is followed with the notification event. */


/*------------------------------------------------------------------*/
/*! @brief  c_cap_open
 *             This function will freeze the screen , and return the capture handle. 
 *  @param [in] e_source             Specifies the source which will be captured.
 *  @param [in] pf_nfy               Specified the callback function to receive the notification of image library.
 *  @param [in] pv_nfy_tag           The client data specified by the client and the callback function will send it again.
 *  @param [in] pf_cust              Specified the function to customize user's operation when creating handle.
 *  @param [in] pv_cust_tag          The client data specified by the client and the callback function will send it again.
 *  @param [out] ph_cap              Specified the capture handle which retrieve capture information about the source.
 *  @return Return the error code.
 *  @retval CAPR_OK                  Success. The capture open operation is successful. 
 */
/*------------------------------------------------------------------*/
extern INT32 c_cap_open (
                            CAP_SRC_TYPE_T  e_source,        /* (I) specifies the open mode of the open operation*/ 
                            c_cap_nfy_fct   pf_nfy,          /* (I) specify the callback function to receive the notification of image library. */ 
                            const VOID*     pv_nfy_tag,      /* (I) The client data specified by the client and the callback function will send it again. */ 
                            c_cap_cust_fct  pf_cust,         /* (I) Specified the function to customize user's operation when creating handle. */ 
                            const VOID*     pv_cust_tag,     /* (I) The client data specified by the client and the callback function will send it again. */ 
                            HANDLE_T*       ph_cap);         /* (O) Specified the capture handle which retrieve capture information about the source. */

                   
/*------------------------------------------------------------------*/
/*! @brief  c_cap_capture
 *              This function will open an image memory block, parse the image header, and return the image handle.
 *  @param [in] h_cap               Specifies which handle will do the operation.
 *  @param [in] t_cap_info          Specifies the output image detail information.
 *  @return Return the error code.
 *  @retval CAPR_OK                 Success. The capture operation is successful. 
 */
/*------------------------------------------------------------------*/
extern INT32 c_cap_capture ( 
                           HANDLE_T                     h_cap,           /* (I) Specifies which handle will do the operation. */ 
                           const CAP_CAPTURE_INFO_T*    pt_cap_info);     /* (I) Specifies the output image detail information. */ 
                    


/*------------------------------------------------------------------*/
/*! @brief  c_cap_get_capture_data
 *             After the capture operation done, save the image to the specified path.
 *  @param [in]  h_cap               Specified the capture operation handle.
 *  @param [out] pc_buf              Specified the buffer to be output.
 *  @param [out] pui4_len            Specified the length to be output.
 *  @return Return the error code.
 *  @retval CAPR_OK                 Success. The image file opening is successful. 
 *  @retval CAPR_INV_HANDLE         FAIL. The image handle is invalid.
 *  @retval CAPR_FCT_NOT_SUPPORT    FAIL. This function is not supported.
 *  @retval CAPR_INV_ARG            FAIL. Invalid arguments.
 *  @retval CAPR_INTERNAL_ERR       FAIL. Semaphore lock is failed.
 */
/*------------------------------------------------------------------*/
extern INT32 c_cap_get_capture_data (
                              HANDLE_T      h_cap,     /* (I) Specified the capture operation handle. */ 
                              UCHAR*        pc_buf,    /* (I) Specified the buffer to save. */ 
                              UINT32*       pui4_len);  /* (I) Specified the buffer length to save. */ 

/*------------------------------------------------------------------*/
/*! @brief  c_cap_save
 *             After the capture operation done, save the image to the specified path.
 *  @param [in] h_cap               Specified the capture operation handle.
 *  @param [in] ps_path             Specified the path to save.
 *  @return Return the error code.
 *  @retval CAPR_OK                 Success. The image file opening is successful. 
 *  @retval CAPR_INV_HANDLE         FAIL. The image handle is invalid.
 *  @retval CAPR_FCT_NOT_SUPPORT    FAIL. This function is not supported.
 *  @retval CAPR_INV_ARG            FAIL. Invalid arguments.
 *  @retval CAPR_INTERNAL_ERR       FAIL. Semaphore lock is failed.
 */
/*------------------------------------------------------------------*/
extern INT32 c_cap_save (HANDLE_T                       h_cap,          /* (I) Specified the capture operation handle. */ 
                         const CAP_LOGO_SAVE_INFO_T*    pt_save_info);   /* (I) Specified the path to save. */ 


extern INT32 c_cap_save_64 (HANDLE_T                       h_cap,          /* (I) Specified the capture operation handle. */ 
                         const CAP_LOGO_SAVE_INFO_EX_T*    pt_save_info);   /* (I) Specified the path to save. */ 
/*------------------------------------------------------------------*/
/*! @brief   c_cap_close
 *               This function close the capture handle and free the resource.
 *  @param [in] h_cap               Specified the already opened image handle.
 *  @return Return the error code.
 *  @retval CAPR_OK                 Success. The API execution is successful. 
 *  @retval CAPR_INV_HANDLE         FAIL. The capture handle is invalid.
 *  @retval CAPR_INV_ARG            FAIL. The pathe is NULL.
 *  @retval CAPR_FCT_NOT_SUPPORT    FAIL. This function is not supported.
 */
/*------------------------------------------------------------------*/
extern INT32 c_cap_close (HANDLE_T          h_cap); /* (O) retrieve the height of the image. */ 

                                                     
/*------------------------------------------------------------------*/
/*! @brief      c_cap_sync_stop_capture
 *                  This function sync stops the capture operation.
 *  @param [in] h_cap       Specified the capture handle that want to stop.
 *  @return Return the error code.
 *  @retval CAPR_OK                 Success. The API execution is successful. 
 *  @retval CAPR_INV_ARG            FAIL. Invalid arguments.
 *  @retval CAPR_INV_HANDLE         FAIL. The capture handle is invalid.
 *  @retval CAPR_FCT_NOT_SUPPORT    FAIL. This function is not supported.
 *  @retval CAPR_INTERNAL_ERR       FAIL. Semaphore lock is failed.
 */
/*------------------------------------------------------------------*/
extern INT32 c_cap_sync_stop_capture (  HANDLE_T     h_cap);           /* (I) specify the capture handle that want to stop. */ 


                        
/*------------------------------------------------------------------*/
/*! @brief      c_cap_sync_stop_save
 *                  This function can stop these types IMG_STOP_OP_TYPE_T of image operation.
 *  @param [in] h_cap               Specified the image handle that want to stop.
 *  @return Return the error code.
 *  @retval CAPR_OK                 Success. The API execution is successful. 
 *  @retval CAPR_INV_ARG            FAIL. Invalid arguments.
 *  @retval CAPR_INV_HANDLE         FAIL. The capture handle is invalid.
 *  @retval CAPR_FCT_NOT_SUPPORT    FAIL. This function is not supported.
 *  @retval CAPR_INTERNAL_ERR       FAIL. Semaphore lock is failed.
 */
/*------------------------------------------------------------------*/
extern INT32 c_cap_sync_stop_save (  HANDLE_T     h_cap);           /* (I) Specify the capture handle that want to stop. */ 


/* This API will start decoding the primary image or thumbnail to the target surface h_dst_surf, and it will not return until decoding image is complete. */          
/*------------------------------------------------------------------*/
/*! @brief   c_cap_async_stop_capture
 *               This API will async stop capture operation.
 *  @param [in] h_cap                   Specified the capture handle that want to async stop.
 *  @return Return the error code.
 *  @retval CAPR_OK                     Success. The API execution is successful. 
 */
/*------------------------------------------------------------------*/
extern INT32 c_cap_async_stop_capture ( HANDLE_T             h_cap);        /* (I) specify the capture handle that want to async stop. */ 

                        
/*------------------------------------------------------------------*/
/*! @brief   c_cap_async_stop_save
 *               This API will async stop saving operation.
 *  @param [in] h_cap           Specified the image handle that want to decode.
 *  @return Return the error code.
 *  @retval CAPR_OK                     Success. The API execution is successful. 
 */
/*------------------------------------------------------------------*/
extern INT32 c_cap_async_stop_save ( HANDLE_T             h_cap);        /* (I) Specify the image handle that want to aysnc stop saving. */ 
                            

/*------------------------------------------------------------------*/
/*! @brief   c_cap_set_boot_logo
 *               This API will select specified picture captured as bootup logo.
 *  @param [in] ps_path                 Specified the image path name that want to set as bootup logo.
 *  @return Return the error code.
 *  @retval CAPR_OK                     Success. The API execution is successful. 
 */
/*------------------------------------------------------------------*/
extern INT32 c_cap_select_as_bootlogo (const CAP_LOGO_SELECT_INFO_T* pt_select_info);        /* (I) Specified the image path name that want to set as bootup logo. */ 


extern INT32 c_cap_select_as_bootlogo_64 (const CAP_LOGO_SELECT_INFO_EX_T* pt_select_info);  
/*------------------------------------------------------------------*/
/*! @brief   c_cap_query_capabilty
 *               This API will select specified picture captured as bootup logo.
 *  @param [in] pt_cap_info                 Specified the address to store the logo info.
 *  @return Return the error code.
 *  @retval CAPR_OK                     Success. The API execution is successful. 
 */
/*------------------------------------------------------------------*/
extern INT32 c_cap_query_capabilty(CAP_CAPABILITY_INFO_T*  pt_cap_info); /* (I) specify the already opened image handle. */ 

#ifdef __cplusplus
}
#endif

#endif /* _C_CAP_H_ */
/*----------------------------------------------------------------------------*/
/*! @} */   /* end of  groupMW_CAP*/
/*----------------------------------------------------------------------------*/
