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

/*-----------------------------------------------------------------------------
 * $RCSfile: x_irrc.h,v $
 * $Revision: #1 $
 * $Date: 2015/11/10 $
 * $Author: dtvbm11 $
 *
 * Description: 
 *         This header file contains IRRC (InfraRed Remote Control) driver
 *         specific definitions, which are exported.
 *---------------------------------------------------------------------------*/

#ifndef _X_IRRC_H_
#define _X_IRRC_H_


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

#include "x_common.h"
#include "x_irrc_btn_def.h"
#include "x_rm.h"


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

/* Get operations */
#define IRRC_GET_TYPE_GROUP_ID              (RM_GET_TYPE_LAST_ENTRY + ((DRV_GET_TYPE_T) 0))
#define IRRC_GET_TYPE_REPETITION_TIME       (RM_GET_TYPE_LAST_ENTRY + ((DRV_GET_TYPE_T) 1))
#define IRRC_GET_TYPE_RAW_DATA_TO_EVT_CODE  (RM_GET_TYPE_LAST_ENTRY + ((DRV_GET_TYPE_T) 2))
#define IRRC_GET_TYPE_RAW_BITS_TO_EVT_CODE  (RM_GET_TYPE_LAST_ENTRY + ((DRV_GET_TYPE_T) 3))
#define IRRC_GET_TYPE_SYS_CODE_FILTER       (RM_GET_TYPE_LAST_ENTRY + ((DRV_GET_TYPE_T) 4))
#define IRRC_GET_TYPE_PROTOCOL              (RM_GET_TYPE_LAST_ENTRY + ((DRV_GET_TYPE_T) 5))

/* Set operations */
#define IRRC_SET_TYPE_GROUP_ID              (RM_SET_TYPE_LAST_ENTRY + ((DRV_SET_TYPE_T) 0))
#define IRRC_SET_TYPE_RESET                 (RM_SET_TYPE_LAST_ENTRY + ((DRV_SET_TYPE_T) 1))
#define IRRC_SET_TYPE_NFY_FCT               (RM_SET_TYPE_LAST_ENTRY + ((DRV_SET_TYPE_T) 2))
#define IRRC_SET_TYPE_POWER_DOWN            (RM_SET_TYPE_LAST_ENTRY + ((DRV_SET_TYPE_T) 3))
#define IRRC_SET_TYPE_SYS_CODE_FILTER       (RM_SET_TYPE_LAST_ENTRY + ((DRV_SET_TYPE_T) 4))
#define IRRC_SET_TYPE_PROTOCOL              (RM_SET_TYPE_LAST_ENTRY + ((DRV_GET_TYPE_T) 5))
#define IRRC_SET_TYPE_LED_DRIVER_CONTROL               (RM_SET_TYPE_LAST_ENTRY + ((DRV_GET_TYPE_T) 6))
/* Definition of maximum raw data size */
#define IRRC_MAX_DATA_SIZE                  ((UINT8) 12) /* byte */

/* Definition of IRRC protocol */
typedef enum
{
    IRRC_LED_DRIVER_CTRL_OFF = 0,
    IRRC_LED_DRIVER_CTRL_ON ,
}   IRRC_DRIVER_LED_CTRL_T;


typedef enum
{
    IRRC_PROTOCOL_NEC = 0,
    IRRC_PROTOCOL_RC5,
    IRRC_PROTOCOL_RC6,
    IRRC_PROTOCOL_FUNAI_FACTORY
}   IRRC_PROTOCOL_T;
              
/* Notify conditions */
typedef enum
{
    IRRC_COND_BTN_UP = 0,
    IRRC_COND_BTN_DOWN
}   IRRC_COND_T;

/* Definition for raw data to event code conversion */
typedef struct _IRRC_RAW_DATA_TO_EVT_CODE_T
{
    UINT8       ui1_sys_code; /* Input */
    UINT8       ui1_cmd_code; /* Input */
    UINT32      ui4_evt_code; /* Output => If input data is invalid, this field is set to BTN_INVALID */
}   IRRC_RAW_DATA_TO_EVT_CODE_T;

/* Definition for raw bits to event code conversion */
typedef struct _IRRC_RAW_BITS_TO_EVT_CODE_T
{
    UINT32      ui4_raw_bits; /* Input */
    UINT32      ui4_evt_code; /* Output => If input data is invalid, this field is set to BTN_INVALID */
}   IRRC_RAW_BITS_TO_EVT_CODE_T;

/* System code filter */
typedef struct _IRRC_SYS_CODE_FILTER_T
{
    BOOL        b_enable;
    BOOL        b_positive_filter;
    SIZE_T      z_filter_arr_size;
    UINT32*     pui4_filter_arr;
}   IRRC_SYS_CODE_FILTER_T;

typedef struct _RAW_DATA_T
{    
    IRRC_PROTOCOL_T     e_protocol;
    SIZE_T              z_data_len; /* byte */
    UINT8               aui1_data[IRRC_MAX_DATA_SIZE];   
}   RAW_DATA_T;

/* Notify function */
typedef VOID (*x_irrc_nfy_fct) (VOID*       pv_nfy_tag,
                                IRRC_COND_T e_nfy_cond,
                                UINT32      ui4_evt_code,
                                RAW_DATA_T* pt_data);

/* Notify info setting */
typedef struct _IRRC_NFY_INFO_T
{
    VOID*           pv_tag;
    x_irrc_nfy_fct  pf_irrc_nfy;
}   IRRC_NFY_INFO_T;

#endif /* _X_IRRC_H_ */

