#ifndef __PHSTBDFB_UTILS_H__    /* Multi-include protection.   <FILENAME>_H */
#define __PHSTBDFB_UTILS_H__
/*****************************************************************************/
/* Copyright (c) 2008 NXP B.V.                                               */
/*                                                                           */
/* This library is free software; you can redistribute it and/or             */
/* modify it under the terms of the GNU Lesser General Public                */
/* License as published by the Free Software Foundation, using               */
/* version 2.1 of the License.                                               */
/*                                                                           */
/* This library 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 the GNU          */
/* Lesser General Public License for more details.                           */
/*                                                                           */
/* You should have received a copy of the GNU Lesser General Public          */
/* License along with this library; if not, write to the Free Software       */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA   */
/*                                                                           */
/*****************************************************************************/
/*
   NXP STB22X Driver

   Code is derived from TI Davinci driver.

   TI Davinci driver

   (c) Copyright 2007  Telio AG

   Written by Denis Oliver Kropp <dok@directfb.org>

   Code is derived from VMWare driver.

   (c) Copyright 2001-2007  The DirectFB Organization (directfb.org)
   (c) Copyright 2000-2004  Convergence (integrated media) GmbH

   All rights reserved.

   Written by Denis Oliver Kropp <dok@directfb.org>,
              Andreas Hundt <andi@fischlustig.de>,
              Sven Neumann <neo@directfb.org>,
              Ville Syrjälä <syrjala@sci.fi> and
              Claudio Ciccani <klan@users.sf.net>.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library 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 the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, write to the
   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.
*//**
    @file   phStbDFB_utils.h
    @brief  Header File supporting utility functions.

@b  Component:  phStbDFB.

*//*

Rev Date        Author      Comments
--------------------------------------------------------------------------------
  1 20080103    laird       New version for DirectFB 1.1.1
  2 20080902    laird       Update Copyright headers.
  3 20080904    laird       Add common Zorder functions.
  4 20080905    laird       Add another Zorder function.
  5 20081023    neill       Remove unused Zorder function
  6 20090226    boudy       Add support for UDA3000
--------------------------------------------------------------------------------
    For consistency and standardisation retain the Section Separators.
*/

/*******************
* INCLUDE FILES    *
********************/
#include "phStbDFB_internal.h"

/**************************************************************************
* EXPORTED MACROS                               PH_STBDFB_<_WORD>+        *
***************************************************************************/

/*********************************************************************
* EXPORTED TYPEDEFS                           [p]phStbDfb_<Word>+_t  *
**********************************************************************/

/**************************************************************************
* EXPORTED DATA                          g[k|p|kp|pk|kpk]phStbDfb_<Word>+ *
***************************************************************************/

/****************************************************************************
* EXPORTED FUNCTION PROTOTYPES                         phStbDfb[_<Word>+]   *
*****************************************************************************/

/**
 * This takes a CoreLayer and maps it the correct Video Renderer layer id as
 * they map in different ways.
 *
 * @param layer  The layer id to translate.
 *
 * @return our layer id:
 *
 * Video1 (DirectFB 3)
 * Video2 (DirectFB 2)
 * Gfx 1 (DirectFB 0)
 * Gfx 2 (DirectFB 1)
 */
extern uint32_t phStbDFB_dfb_to_renderer_translated(CoreLayer* layer);

/**
 * Return the number of Video Dencs assigned to this VideoRenderer.
 *
 * @param rendererNum The renderer we are using.
 *
 * @retval The number of dencs found.
 */
extern uint32_t phStbDFB_GetNumberVideoDencs(uint32_t rendererNum);

/**
 * Initialise the given video denc and fill in the encoder description.
 *
 * @param screen_data The Screen Data object we are using.
 * @param encoder     The encoder we are initialising.
 * @param pEncDesc    The filled in encoder description.
 *
 * @retval DFB_OK when the setup successful otherwise failed.
 */
extern DFBResult phStbDFB_InitVideoDenc(phStbDFB_ScreenData_t *screen_data,
                                        uint32_t encoder,
                                        DFBScreenEncoderDescription *pEncDesc);
/**
 * Do we have a scart switch on board.
 *
 * @retval True  We have a scart switch
 *         False We do not have a scart switch on board.
 */
extern bool phStbDFB_AK470XInstalled(void);

/**
 * Setup the scart switch
 *
 * @param pAvSwitchSettings The scart switch settings to use
 *
 * @retval DFB_OK if set up, else not succesful.
 */
extern DFBResult phStbDFB_SetupAK470X(av_switch_data *pAvSwitchSettings);

/**
 * Get the scart switch setup.
 *
 * @param pAvSwitchSettings The current scart switch settings
 *
 * @retval DFB_OK if ok, else not ok.
 */
extern DFBResult phStbDFB_GetSetupAK470X(av_switch_data *pAvSwitchSettings);

/**
 * Do we have a scart switch on board.
 *
 * @retval True  We have a scart switch
 *         False We do not have a scart switch on board.
 */
extern bool phStbDFB_UDA3000Installed(void);

/**
 * Setup the scart switch
 *
 * @param pAvSwitchSettings The scart switch settings to use
 *
 * @retval DFB_OK if set up, else not succesful.
 */
extern DFBResult phStbDFB_SetupUDA3000(phStbScartSwitch_data_t *pAvSwitchSettings);

/**
 * Get the scart switch setup.
 *
 * @param pAvSwitchSettings The current scart switch settings
 *
 * @retval DFB_OK if ok, else not ok.
 */
extern DFBResult phStbDFB_GetSetupUDA3000(phStbScartSwitch_data_t *pAvSwitchSettings);

/**
 * Setup the specified video denc
 *
 * @param screen_data    The Screen Data object we are using.
 * @param encoder        The encoder we are initialising.
 * @param pDencSettings  The video denc settings to use.
 *
 * @retval DFB_OK when succesful, otherwise not successful.
 */
extern DFBResult phStbDFB_SetupDenc(phStbDFB_ScreenData_t *screen_data,
                                    uint32_t encoder,
                                    struct videodenc_var_screeninfo *pDencSettings);

/**
 * Setup the specified video denc setup
 *
 * @param screen_data    The Screen Data object we are using.
 * @param encoder        The encoder we are initialising.
 * @param pDencSettings  The specified video denc settings.
 *
 * @retval DFB_OK when succesful, otherwise not successful.
 */
extern DFBResult phStbDFB_GetDencSetup(phStbDFB_ScreenData_t *screen_data,
                                       uint32_t encoder,
                                       struct videodenc_var_screeninfo *pDencSettings);

/**
 * Set the power mode of the video dencs
 *
 * @param screen      The screen object.
 * @param driver_data The driver data.
 * @param screen_data The screen data.
 * @param mode        The DirectFB power mode to use.
 *
 * @retval DFB_OK when the surface is a layer surface or DFB_ITEMNOTFOUND if not.
 */
extern DFBResult phStbDFB_Utils_SetPowerMode(CoreScreen             *screen,
                                             void                   *driver_data,
                                             void                   *screen_data,
                                             DFBScreenPowerMode      mode );

/**
 * Set the Gamma value on the specified video denc.
 *
 * @param screen_data  The screen data.
 * @param encoder      The encoder we are setting up.
 * @param pGammaValues The gamma values to use.
 *
 * @retval DFB_OK when the surface is a layer surface or DFB_ITEMNOTFOUND if not.
 */
extern DFBResult phStbDFB_SetupDencGamma(phStbDFB_ScreenData_t *screen_data,
                                         uint32_t encoder,
                                         unsigned int *pGammaValues);

/**
 * Get the ZOrder of the specified layer
 *
 * @param layer        The layer to find.
 *
 * @retval The level of the specified layer.
 */
extern uint32_t phStbDFB_GetZOrder(CoreLayer *layer);

/**
 * Set the ZOrder of the specified layer
 *
 * @param layer        The layer to use.
 * @param value        The zorder value to use.
 *
 * @retval The level of the specified layer.
 */
extern DFBResult phStbDFB_SetZOrder(CoreLayer *layer,
                                    uint32_t value);

#endif //__PHSTBDFB_UTILS_H__
