/* 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 u_inp_hdlr.h 
 *  $RCSfile: $
 *  $Revision: #1 $
 *  $Date: 2015/05/29 $
 *  $Author: brianpc.huang $
 *  
 *  @par Description:
 * 1. If a possible type is DEV_AVC_COMBI, inp_hdler will open DSM for this type,
 *    and start to monitor its signal status
 * 2. when DSM reports signal status,
 *      2.1 if preferred type with signal, inp_hdler will select this type to connect
 *      2.2 if preferred type without signal, inp_hdler will select the first one with signal
 * 3. If one DEV_AVC_COMBI type includes several types, inp_hdlr should provide a way to
 *    interate specific type regardless of it with or without signal.
 * 4. If a possible type is not DEV_AVC_COMBI, inp_hdler will select this type to connect
 */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/*! @defgroup groupMW_SVCTX_INP_HDLR Input Handler
 *
 *  @ingroup groupMW_SVCTX
 *  @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_SVCTX
 *  @{ 
 */
/*----------------------------------------------------------------------------*/
#ifndef _U_INP_HDLR_H_
#define _U_INP_HDLR_H_
/*-----------------------------------------------------------------------------
 *  include files
 *---------------------------------------------------------------------------*/
#include "u_common.h"
#include "u_device_type.h"
#include "u_svctx.h"
#include "u_avc_handler.h"
/*-----------------------------------------------------------------------------
 * structure, constants, macro definitions
 *---------------------------------------------------------------------------*/
#define SRC_TYPE_AVC                ((SRC_TYPE_T) 4)    /**<        */

/*------------------------------------------------------------------*/
/*! @enum SRC_AVC_HINT_TYPE_T
 *  @brief  Specify AVC hint type
 *  @code
 *  typedef enum
 *  {
 *      SRC_AVC_HINT_NONE = 0,
 *      SRC_AVC_HINT_SPECIFIC_DEVICE_ONLY,
 *      SRC_AVC_HINT_SPECIFIC_DEVICE_FIRST,
 *      SRC_AVC_HINT_BETTER_QUALITY_DEVICE_FIRST
 *  } SRC_AVC_HINT_TYPE_T;
 *  @endcode
 *  @li@c  SRC_AVC_HINT_NONE                                 -AVC hint type none
 *  @li@c  SRC_AVC_HINT_SPECIFIC_DEVICE_ONLY                 -AVC hint type specific device only
 *  @li@c  SRC_AVC_HINT_SPECIFIC_DEVICE_FIRST                -AVC hint type specific device first
 *  @li@c  SRC_AVC_HINT_BETTER_QUALITY_DEVICE_FIRST     -AVC hint type better quality device first
 */
/*------------------------------------------------------------------*/
typedef enum
{
    SRC_AVC_HINT_NONE = 0,
    SRC_AVC_HINT_SPECIFIC_DEVICE_ONLY,
    SRC_AVC_HINT_SPECIFIC_DEVICE_FIRST,
    SRC_AVC_HINT_BETTER_QUALITY_DEVICE_FIRST
} SRC_AVC_HINT_TYPE_T;

/*------------------------------------------------------------------*/
/*! @struct  SRC_AVC_HINT_T
 *  @brief  Contain AVC hint info
 *  @code
 *  typedef struct _SRC_AVC_HINT_T
 *  {
 *      DEVICE_TYPE_T                   e_dev_type;
 *      SRC_AVC_HINT_TYPE_T             e_type;
 *  } SRC_AVC_HINT_T;
 *  @endcode
 *  @li@c  e_dev_type                                        -AVC hint device type
 *  @li@c  e_type                                            -AVC hint type
 */
/*------------------------------------------------------------------*/
typedef struct _SRC_AVC_HINT_T
{
    DEVICE_TYPE_T                   e_dev_type;
    SRC_AVC_HINT_TYPE_T             e_type;
} SRC_AVC_HINT_T;

/*------------------------------------------------------------------*/
/*! @enum SRC_AVC_CHG_TYPE_T
 *  @brief  Specify AVC source change type
 *  @code
 *  typedef enum
 *  {
 *      SRC_AVC_CHG_MANUAL = 0,
 *      SRC_AVC_CHG_SCART_PIN8_AUTO
 *  } SRC_AVC_CHG_TYPE_T;
 *  @endcode
 *  @li@c  SRC_AVC_CHG_MANUAL                      -AVC source change type manual
 *  @li@c  SRC_AVC_CHG_SCART_PIN8_AUTO     -AVC source change type auto by scart PIN8
 */
/*------------------------------------------------------------------*/
typedef enum
{
    SRC_AVC_CHG_MANUAL = 0,
    SRC_AVC_CHG_SCART_PIN8_AUTO
} SRC_AVC_CHG_TYPE_T;

/*------------------------------------------------------------------*/
/*! @struct  SRC_AVC_T
 *  @brief  Contain AVC info
 *  @code
 *  typedef struct _SRC_AVC_T  
 *  {
 *      DEVICE_TYPE_T                   e_video_type;  
 *      SRC_AVC_HINT_T                  t_video_hint;
 *      DEVICE_TYPE_T                   e_audio_type;  
 *      SRC_AVC_HINT_T                  t_audio_hint;
 *      AVC_HANDLER_SCART_MODE_T        e_scart_mode;
 *      SRC_AVC_CHG_TYPE_T              e_src_chg_type;
 *  } SRC_AVC_T;
 *  @endcode
 *  @li@c  e_video_type                                      -AVC info video type
 *  @li@c  t_video_hint                                      -AVC info video hint
 *  @li@c  e_audio_type                                      -AVC info audio type
 *  @li@c  t_audio_hint                                      -AVC info audio hint
 *  @li@c  e_scart_mode                                      -AVC info scart mode
 *  @li@c  e_src_chg_type                                    -AVC info source change type
 */
/*------------------------------------------------------------------*/
typedef struct _SRC_AVC_T  /* SRC_DESC_T's pv_details when e_type = SRC_TYPE_AVC*/
{
    DEVICE_TYPE_T                   e_video_type;  /* e.g DEV_AVC_COMBI     */
    SRC_AVC_HINT_T                  t_video_hint;

    DEVICE_TYPE_T                   e_audio_type;  /* e.g DEV_AVC_AUDIO_INP */
    SRC_AVC_HINT_T                  t_audio_hint;

    AVC_HANDLER_SCART_MODE_T        e_scart_mode;

    SRC_AVC_CHG_TYPE_T              e_src_chg_type; /* user manual change or monitor Scart PIN8 auto change */
} SRC_AVC_T;

/*------------------------------------------------------------------*/
/*! @struct  SRC_AVC_INFO_T
 *  @brief  Contain AVC info
 *  @code
 *  typedef struct _SRC_AVC_INFO_T
 *  {
 *      DEVICE_TYPE_T                   e_type;
 *      SRC_AVC_HINT_T                  t_hint;
 *  } SRC_AVC_INFO_T;
 *  @endcode
 *  @li@c  e_type                                            -AVC info type
 *  @li@c  t_hint                                            -AVC info hint type
 */
/*------------------------------------------------------------------*/
typedef struct _SRC_AVC_INFO_T
{
    DEVICE_TYPE_T                   e_type;
    SRC_AVC_HINT_T                  t_hint;
} SRC_AVC_INFO_T;

/*------------------------------------------------------------------*/
/*! @enum VIDEO_DEVICE_AUDIO_COND_T
 *  @brief  Specify video device audio condition type
 *  @code
 *  typedef enum
 *  {
 *      VIDEO_DEVICE_AUDIO_COND_UNKNOWN = 0,
 *      VIDEO_DEVICE_AUDIO_COND_WITH_AUDIO,
 *      VIDEO_DEVICE_AUDIO_COND_NO_AUDIO
 *  } VIDEO_DEVICE_AUDIO_COND_T;
 *  @endcode
 *  @li@c  VIDEO_DEVICE_AUDIO_COND_UNKNOWN       -video device audio condition type unknown
 *  @li@c  VIDEO_DEVICE_AUDIO_COND_WITH_AUDIO   -video device audio condition type with audio
 *  @li@c  VIDEO_DEVICE_AUDIO_COND_NO_AUDIO      -video device audio condition type no audio
 */
/*------------------------------------------------------------------*/
typedef enum
{
    VIDEO_DEVICE_AUDIO_COND_UNKNOWN = 0,
    VIDEO_DEVICE_AUDIO_COND_WITH_AUDIO,
    VIDEO_DEVICE_AUDIO_COND_NO_AUDIO
} VIDEO_DEVICE_AUDIO_COND_T;

/*------------------------------------------------------------------*/
/*! @brief        Typedef for the input handle iterate devices in combi callback function. 
 *  @param [in] ui2_num_dev             - device number
 *  @param [in] ui2_idx                      - index
 *  @param [in] e_dev_type               - device type
 *  @param [in] b_in_using                 - in using or not
 *  @param [in] b_with_video_signal   - with video signal or not
 *  @param [in] b_with_audio_signal   - with audio signal or not
 *  @note
 *  @see
 *  @return None
 */
/*------------------------------------------------------------------*/
typedef VOID (*x_inp_hdlr_iterate_devices_in_combi_fct)(
                    UINT16                      ui2_num_dev,
                    UINT16                      ui2_idx,
                    DEVICE_TYPE_T               e_dev_type,
                    BOOL                        b_in_using,
                    BOOL                        b_with_video_signal,
                    BOOL                        b_with_audio_signal
                    );

#define SVCTX_GRP_INP                                     (3<<SVCTX_TYPE_CODE_BITS)    /**<        */
/* Input handler set types *********************************************************/
#define SVCTX_INP_SET_TYPE_IGNORE                         ((SVCTX_SET_TYPE_T)(SVCTX_GRP_INP | 0))    /**<        */
#define SVCTX_INP_SET_TYPE_NEXT_DEVICE_IN_VIDEO_COMBI     ((SVCTX_SET_TYPE_T)(SVCTX_GRP_INP | 1))    /**<        */
#define SVCTX_INP_SET_TYPE_NEXT_DEVICE_IN_AUDIO_COMBI     ((SVCTX_SET_TYPE_T)(SVCTX_GRP_INP | 2))    /**<        */
#define SVCTX_INP_SET_TYPE_NEXT_SIGNALED_IN_VIDEO_COMBI   ((SVCTX_SET_TYPE_T)(SVCTX_GRP_INP | 3))    /**<        */
#define SVCTX_INP_SET_TYPE_NEXT_SIGNALED_IN_AUDIO_COMBI   ((SVCTX_SET_TYPE_T)(SVCTX_GRP_INP | 4))    /**<        */
#define SVCTX_INP_SET_TYPE_SELECT_DEVICE_IN_VIDEO_COMBI   ((SVCTX_SET_TYPE_T)(SVCTX_GRP_INP | 5))    /**<        */
#define SVCTX_INP_SET_TYPE_SELECT_DEVICE_IN_AUDIO_COMBI   ((SVCTX_SET_TYPE_T)(SVCTX_GRP_INP | 6))    /**<        */
#define SVCTX_INP_SET_TYPE_AUDIO_SRC_INFO                 ((SVCTX_SET_TYPE_T)(SVCTX_GRP_INP | 7)) /* type = SRC_AVC_INFO_T*             size = sizeof(SRC_AVC_INFO_T)            */    /**<        */

/* Input handler get types *********************************************************/
#define SVCTX_INP_GET_TYPE_IGNORE                         ((SVCTX_GET_TYPE_T)(SVCTX_GRP_INP | 0))    /**<        */
#define SVCTX_INP_GET_TYPE_ITERATE_DEVICES_IN_VIDEO_COMBI ((SVCTX_GET_TYPE_T)(SVCTX_GRP_INP | 1))    /**<        */
#define SVCTX_INP_GET_TYPE_ITERATE_DEVICES_IN_AUDIO_COMBI ((SVCTX_GET_TYPE_T)(SVCTX_GRP_INP | 2))    /**<        */
#define SVCTX_INP_GET_TYPE_VIDEO_DEVICE_AUDIO_COND        ((SVCTX_GET_TYPE_T)(SVCTX_GRP_INP | 3)) /* type = VIDEO_DEVICE_AUDIO_COND_T*  size = sizeof(VIDEO_DEVICE_AUDIO_COND_T) */    /**<        */
#define SVCTX_INP_GET_TYPE_SRC_AVC_INFO                   ((SVCTX_GET_TYPE_T)(SVCTX_GRP_INP | 4)) /* type = SRC_AVC_T*                  size = sizeof(SRC_AVC_T)                 */    /**<        */
#endif /* _U_INP_HDLR_H_ */
/*----------------------------------------------------------------------------*/
/*! @} */                                              /* end of groupMW_SVCTX_INP_HDLR*/
/*----------------------------------------------------------------------------*/

