/* 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_avc.h,v $
 * $Revision: #1 $
 * $Date: 2015/05/29 $
 * $Author: brianpc.huang $
 *
 * Description:
 *         This header file contains AV Connectors driver specific
 *         definitions, which are exported.
 *---------------------------------------------------------------------------*/

#ifndef _X_AVC_H_
#define _X_AVC_H_

/*-----------------------------------------------------------------------------
                    include files
-----------------------------------------------------------------------------*/
#include "x_common.h"
#include "x_rm.h"
#include "x_rm_dev_types.h"

/*-----------------------------------------------------------------------------
                    macros, defines, typedefs, enums
-----------------------------------------------------------------------------*/
/* Get operations */
#define AVC_GET_TYPE_NO_CONN_DISC_NFY   		    (RM_GET_TYPE_LAST_ENTRY + ((DRV_GET_TYPE_T) 0))
#define AVC_GET_TYPE_SIGNAL_STATUS      		    (RM_GET_TYPE_LAST_ENTRY + ((DRV_GET_TYPE_T) 1))
#define AVC_GET_TYPE_SCART_PIN_8_STATUS 		    (RM_GET_TYPE_LAST_ENTRY + ((DRV_GET_TYPE_T) 2))
#define AVC_GET_TYPE_SCART_PIN_16_STATUS		    (RM_GET_TYPE_LAST_ENTRY + ((DRV_GET_TYPE_T) 3))
#define AVC_GET_TYPE_COMBI_SIGNAL_STATUS		    (RM_GET_TYPE_LAST_ENTRY + ((DRV_GET_TYPE_T) 4))
#define AVC_GET_TYPE_NUM_COMP_IDS       		    (RM_GET_TYPE_LAST_ENTRY + ((DRV_GET_TYPE_T) 5))
#define AVC_GET_TYPE_COMP_ID            		    (RM_GET_TYPE_LAST_ENTRY + ((DRV_GET_TYPE_T) 6))
#define AVC_GET_TYPE_CONT_COMBI_MON     		    (RM_GET_TYPE_LAST_ENTRY + ((DRV_GET_TYPE_T) 7))
#define AVC_GET_TYPE_SCART_INP_CAP				    (RM_GET_TYPE_LAST_ENTRY + ((DRV_GET_TYPE_T) 8))
#define AVC_GET_TYPE_SCART_BYPASS        		    (RM_GET_TYPE_LAST_ENTRY + ((DRV_GET_TYPE_T) 9))
#define AVC_GET_TYPE_SCART_OUTPUT        		    (RM_GET_TYPE_LAST_ENTRY + ((DRV_GET_TYPE_T)10))
#define AVC_GET_TYPE_CABLE_STATUS	                (RM_GET_TYPE_LAST_ENTRY + ((DRV_GET_TYPE_T)11))
#define AVC_GET_TYPE_COMBI_CABLE_STATUS             (RM_GET_TYPE_LAST_ENTRY + ((DRV_GET_TYPE_T)12))
#define AVC_GET_TYPE_SCART_INPUT_MODE               (RM_GET_TYPE_LAST_ENTRY + ((DRV_GET_TYPE_T)13))

/* Set operations */
#define AVC_SET_TYPE_NFY_FCT                 	    (RM_SET_TYPE_LAST_ENTRY + ((DRV_SET_TYPE_T) 0))
#define AVC_SET_TYPE_NO_CONN_DISC_NFY              ((RM_SET_TYPE_LAST_ENTRY + ((DRV_SET_TYPE_T) 1)) | RM_SET_TYPE_ARG_NO_REF)
#define AVC_SET_TYPE_SCART_BYPASS        		    (RM_SET_TYPE_LAST_ENTRY + ((DRV_SET_TYPE_T) 2))
#define AVC_SET_TYPE_SCART_OUTPUT        		    (RM_SET_TYPE_LAST_ENTRY + ((DRV_SET_TYPE_T) 3))

/* AV Connector driver flags */
#define AVC_FLAG_DEC_REQ_FOR_TV_SIG_DETECTION     	MAKE_BIT_MASK_32(16)
#define AVC_FLAG_DEC_REQ_FOR_COLOR_SYS_DETECTION  	MAKE_BIT_MASK_32(17)
#define AVC_FLAG_DEC_REQ_FOR_AUD_SIG_DETECTION    	MAKE_BIT_MASK_32(18)
#define AVC_FLAG_SCART_SOURCE                       MAKE_BIT_MASK_32(19)
#define AVC_FLAG_SCART_SINK                         MAKE_BIT_MASK_32(20)
#define AVC_FLAG_SCART_MONITOR                      MAKE_BIT_MASK_32(21)

/* Disconnect Reason */
#define AVC_DISC_REASON_SIGNAL_LOSS   		        (RM_DISC_REASON_LAST_ENTRY + ((UINT32) 0))

/* Connect Type */
#define AVC_CONN_TYPE_ANY             		        (RM_CONN_TYPE_LAST_ENTRY + ((DRV_CONN_TYPE_T)  0))

/* Signal state bitmask */
#define AVC_STATE_NONE                		        MAKE_BIT_MASK_32(0)
#define AVC_STATE_TV_SIGNAL           		        MAKE_BIT_MASK_32(1)
#define AVC_STATE_AUDIO_SIGNAL        		        MAKE_BIT_MASK_32(2)
#define AVC_STATE_TV_SIGNAL_UNKNOWN                 MAKE_BIT_MASK_32(3)

/* Cable state bitmask */
#define AVC_STATE_CABLE_NONE                        ((UINT32) 0)
#define AVC_STATE_CABLE_PLUGGED                     MAKE_BIT_MASK_32(1)
#define AVC_STATE_CABLE_UNKNOWN                     MAKE_BIT_MASK_32(2)

/* SCART input capability bitmask */
#define AVC_SCART_INP_CAP_S_VIDEO       	        MAKE_BIT_MASK_32(0)
#define AVC_SCART_INP_CAP_COMPOSITE     	        MAKE_BIT_MASK_32(1)
#define AVC_SCART_INP_CAP_RGB   			        MAKE_BIT_MASK_32(2)
#define AVC_SCART_INP_CAP_COMPONENT     	        MAKE_BIT_MASK_32(3)

typedef enum
{
    AVC_COND_SIGNAL_STATUS = 0,
    AVC_COND_CABLE_STATUS,
    AVC_COND_SCART_PIN_8_STATUS,
    AVC_COND_SCART_PIN_16_STATUS,
    AVC_COND_COMBI_SIGNAL_STATUS,
    AVC_COND_COMBI_CABLE_STATUS
}   AVC_COND_T;

typedef enum
{
    AVC_SCART_PIN_8_UNKNOWN = 0,
    AVC_SCART_PIN_8_NO_SIGNAL,    
    AVC_SCART_PIN_8_ASPECT_16_9,
    AVC_SCART_PIN_8_ASPECT_4_3
}   AVC_SCART_PIN_8_T;

typedef enum
{
    AVC_SCART_PIN_16_UNKNOWN = 0,
    AVC_SCART_PIN_16_COMPOSITE,
    AVC_SCART_PIN_16_RGB,
    AVC_SCART_PIN_16_TOGGLE
}   AVC_SCART_PIN_16_T;

typedef enum
{
    AVC_SCART_INPUT_MODE_CVBS,
    AVC_SCART_INPUT_MODE_SV,
    AVC_SCART_INPUT_MODE_RGB,
    AVC_SCART_INPUT_MODE_MIX,
    AVC_SCART_INPUT_MODE_UNKNOWN,
}   AVC_SCART_INPUT_MODE_T;


typedef enum
{
    AVC_SCART_BYPASS_TRUE = 0,
    AVC_SCART_BYPASS_FALSE
}   AVC_SCART_BYPASS_T;

typedef struct _AVC_SCART_OUTPUT_T
{
    DRV_TYPE_T      t_dev_type;
    UINT16          ui2_id;
}   AVC_SCART_OUTPUT_T;

typedef VOID (*x_avc_nfy_fct)(VOID*     	pv_nfy_tag,
    						  AVC_COND_T	e_nfy_cond,
    						  UINT32    	ui4_data_1,
    						  UINT32    	ui4_data_2);

typedef struct _AVC_NFY_INFO_T
{
    VOID*  				pv_tag;
    x_avc_nfy_fct  		pf_avc_nfy;
}   AVC_NFY_INFO_T;

typedef struct _AVC_INDEX_COMP_ID_T
{
    UINT16            	ui2_index;
    DRV_COMP_ID_T     	t_comp_id;
}   AVC_INDEX_COMP_ID_T;

typedef struct _AVC_COMBI_SIGNAL_STATUS_T
{
    UINT16				ui2_index;
    UINT32              ui4_signal_status;
}   AVC_COMBI_SIGNAL_STATUS_T;

typedef struct _AVC_COMBI_CABLE_STATUS_T
{
    UINT16              ui2_index;
    UINT32              ui4_cable_status;
}   AVC_COMBI_CABLE_STATUS_T;

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

#endif /* _X_AVC_H_ */

