📄 dp_api_command_functions.c
字号:
/*********************************************************************************
*********************************************************************************
**
** Name : dp_api_command_functions.c
** Title : Display pipeline API command function module
** Author : T. Whalley
** Created : June 2001
**
** Copyright : 2001 by Imagination Technologies Limited. All rights reserved
** : No part of this software, either material or conceptual
** : may be copied or distributed, transmitted, transcribed,
** : stored in a retrieval system or translated into any
** : human or computer language in any form by any means,
** : electronic, mechanical, manual or other-wise, or
** : disclosed to third parties without the express written
** : permission of Imagination Technologies Limited, Unit 8,
** : HomePark Industrial Estate, King's Langley, Hertfordshire,
** : WD4 8LZ, U.K.
**
** Description : Contains all command function definitions for generic
** display pipeline API.
**
** Platform : Platform independent (modify 'types.h' accordingly)
** $Log: dp_api_command_functions.c $
**
*********************************************************************************
*********************************************************************************/
#include <stdio.h>
#include "dp_types.h"
#include "dp_init_marathon.h"
#include "dp_hardware.h"
#include "dp_hardware_dispatcher.h"
#include "sccoef.h"
#if defined PCI_BRIDGE_SIM
#include "windows.h"
#include "tvichw32.h"
#endif
#if DP_USE_INTERRUPTS
#include "img_defs.h"
#include "uih_api.h"
#include "debug_log.h"
#endif
#if defined DP_SIMULATION_MODE
#include "windows.h"
#include "stdio.h"
#endif
DP_UINT_16 DP_ui16DisplayWidth;
DP_UINT_16 DP_ui16DisplayHeight;
DP_BOOL DP_SourceFrameSizeSet [ DP_NO_OF_STREAMS ];
DP_BOOL DP_DestinationFrameSizeSet [ DP_NO_OF_STREAMS ];
DP_BOOL DP_ExternalInterlacedFields [ DP_NO_OF_STREAMS ];
DP_BOOL DP_IsPlaneBeingScaled [ DP_NO_OF_STREAMS ];
DP_SourceDataTypes DP_StreamSourceDataTypes [ DP_NO_OF_STREAMS ];
DP_pScalerModifier DP_pCurrentScalerModifier [ DP_NO_OF_STREAMS ];
DP_UINT_16 DP_SourceImageWidth [ DP_NO_OF_STREAMS ];
DP_UINT_16 DP_SourceImageHeight [ DP_NO_OF_STREAMS ];
DP_BOOL DP_bIsPipelineInitialised = DP_FALSE;
DP_BOOL DP_bIsDisplayInterlaced = DP_FALSE;
DP_UINT_32 DP_ISRCounter = 0;
#if defined DP_SIMULATION_MODE
DP_INT_8 ai8DumpComment [ 200 ];
/***********************************************************************************************
*
* Function Name : DP_GenerateTimingsFromVESAGTF
* Inputs : psOutputTimings - pointer to a DP_TimingSettings structure, which is
* completed by the function (with Display Pipeline native
* timing variables)
* psInputTimings - pointer to a DP_VESAGTFSettings structure which must be
* filled with the required GTF timing figures prior to
* calling this function.
* Outputs : Completed DP_TimingSettings structure - see 'Inputs', above.
* Returns : Nothing.
* Globals Used : None.
* Description : Provides internally usable timing figures from VESA GTF figures.
* DEVELOPMENT USAGE ONLY.
*
***********************************************************************************************/
void DP_GenerateTimingsFromVESAGTF ( DP_TimingSettings * psOutputTimings,
DP_VESAGTFSettings * psInputTimings )
{
psOutputTimings->ui16HBPS = psInputTimings->ui16HorizontalBackPorch;
psOutputTimings->ui16HT = psInputTimings->ui16HorizontalActive +
psInputTimings->ui16HorizontalBackPorch +
psInputTimings->ui16HorizontalBorder1 +
psInputTimings->ui16HorizontalBorder2 +
psInputTimings->ui16HorizontalFrontPorch +
psInputTimings->ui16HorizontalSync;
psOutputTimings->ui16HAS = psInputTimings->ui16HorizontalSync +
psInputTimings->ui16HorizontalBackPorch +
psInputTimings->ui16HorizontalBorder1;
psOutputTimings->ui16HRBS = psOutputTimings->ui16HT -
( psInputTimings->ui16HorizontalBorder2 +
psInputTimings->ui16HorizontalFrontPorch );
psOutputTimings->ui16HLBS = psInputTimings->ui16HorizontalSync +
psInputTimings->ui16HorizontalBackPorch;
psOutputTimings->ui16HFPS = psOutputTimings->ui16HT -
psInputTimings->ui16HorizontalFrontPorch;
psOutputTimings->ui16VBPS = psInputTimings->ui16VerticalBackPorch;
psOutputTimings->ui16VT = psInputTimings->ui16VerticalActive +
psInputTimings->ui16VerticalBackPorch +
psInputTimings->ui16VerticalBorder1 +
psInputTimings->ui16VerticalBorder2 +
psInputTimings->ui16VerticalFrontPorch +
psInputTimings->ui16VerticalSync;
psOutputTimings->ui16VAS = psInputTimings->ui16VerticalSync +
psInputTimings->ui16VerticalBackPorch +
psInputTimings->ui16VerticalBorder1;
psOutputTimings->ui16VBBS = psOutputTimings->ui16VT -
( psInputTimings->ui16VerticalBorder2 +
psInputTimings->ui16VerticalFrontPorch );
psOutputTimings->ui16VTBS = psInputTimings->ui16VerticalSync +
psInputTimings->ui16VerticalBackPorch;
psOutputTimings->ui16VFPS = psOutputTimings->ui16VT -
psInputTimings->ui16VerticalFrontPorch;
}
/***********************************************************************************************
*
* Function Name : DP_CalculateStride
* Inputs :
*
*
* Outputs :
* Returns :
* Globals Used :
* Description : Calculates stride from pixel colour format, the size of the picture and the
* the number of padding bytes used.
* DEVELOPMENT USAGE ONLY
*
***********************************************************************************************/
DP_UINT_32 DP_CalculateStride ( DP_PixelColourFormats ePixelFormat,
DP_UINT_32 ui32PictureWidthInPixels,
DP_UINT_32 ui32BytesOfRedundantInformationOnRightHandEdge )
{
DP_UINT_32 ui32StrideIn16ByteWords;
DP_UINT_8 aui8BytesPerPixel [ DP_PIXEL_COLOUR_FORMAT_NUMBER_OF_MODES ] =
{
1, /* DP_PIXEL_COLOUR_FORMAT_8_BIT_INDEXED */
1, /* DP_PIXEL_COLOUR_FORMAT_4_BIT_INDEXED_4_BIT_ALPHA */
2, /* DP_PIXEL_COLOUR_FORMAT_8_BIT_INDEXED_8_BIT_ALPHA */
1, /* DP_PIXEL_COLOUR_FORMAT_8_BIT_RGB_332 */
2, /* DP_PIXEL_COLOUR_FORMAT_12_BIT_RGB_444_4_BIT_ALPHA */
2, /* DP_PIXEL_COLOUR_FORMAT_15_BIT_RGB_555_1_BIT_ALPHA */
3, /* DP_PIXEL_COLOUR_FORMAT_24_BIT_RGB_888 */
3, /* DP_PIXEL_COLOUR_FORMAT_24_BIT_RGB_888_8_BIT_ALPHA */
2, /* DP_PIXEL_COLOUR_FORMAT_16_BIT_YUV_420_PLANAR */
2, /* DP_PIXEL_COLOUR_FORMAT_16_BIT_YUV_422_UY0VY1 */
2, /* DP_PIXEL_COLOUR_FORMAT_16_BIT_YUV_422_VY0UY1 */
2, /* DP_PIXEL_COLOUR_FORMAT_16_BIT_YUV_422_Y0UY1V */
2 /* DP_PIXEL_COLOUR_FORMAT_16_BIT_YUV_422_Y0VY1U */
};
ui32StrideIn16ByteWords = ( ui32PictureWidthInPixels * aui8BytesPerPixel [ ePixelFormat ] ) + ui32BytesOfRedundantInformationOnRightHandEdge;
/* Return the value in words, not bytes */
ui32StrideIn16ByteWords = ( ui32StrideIn16ByteWords / 16 );
return ui32StrideIn16ByteWords;
}
#endif
/***********************************************************************************************
*
* Function Name : DP_InitialiseDisplay
* Inputs : sInitialisationData - A populated DP_InitData structure is passed to the
* function, providing the initialisation details
* required by the display pipeline before normal
* operation can begin.
* Outputs : None.
* Returns : DP_UINT_16 - Returns one of the defined display pipeline error
* codes, according to the success of the function and
* whether the compiler directive DP_ERROR_CHECKING
* is enabled. See API specification for more details
* on error types.
*
* Description : This function must be called prior to the use of any other DP API query or
* command functions.
*
***********************************************************************************************/
DP_UINT_16 DP_InitialiseDisplay ( DP_InitData sInitialisationData )
{
#if defined DP_ERROR_CHECKING
DP_UINT_16 ui16ReturnValue = DP_STANDARD_CODE_NO_ERROR;
DP_UINT_16 ui16CommandResult = DP_STANDARD_CODE_NO_ERROR;
#else
DP_UINT_16 ui16ReturnValue = DP_ERR_NO_ERROR_CHECKING;
DP_UINT_16 ui16CommandResult = DP_STANDARD_CODE_NO_ERROR;
#endif
DP_UINT_16 ui16i;
DP_UINT_8 ui8CurrentDrawOrderCount;
DP_Interrupts sInterruptEnables;
#if defined DP_SIMULATION_MODE
PDUMPINIT;
sprintf ( &ai8DumpComment[0], "DP_InitialiseDisplay \n" );
printf ( ai8DumpComment );
PDumpComment( ai8DumpComment );
DP_SimulateDMAEngine ( DP_DMA_ENGINE_SIMULATOR_INITIALISE );
#endif
/* Reset DMA Engine interface */
DP_MEMSET ( &(DP_DispatcherBufferStorage[0]), 0x00, 2 * DP_SIZE_OF_DISPATCHER_BUFFER_IN_BYTES );
DP_ui16DispatcherBufferSize [0] = 0;
DP_ui16DispatcherBufferSize [1] = 0;
DP_eBufferStates [0] = DP_DMA_BUFFER_STATE_FREE;
DP_eBufferStates [1] = DP_DMA_BUFFER_STATE_FREE;
DP_ui8DispatcherBufferOffset [0] = 2; /* The buffers are both started with offsets */
DP_ui8DispatcherBufferOffset [1] = 2; /* applied in order to avoid confusion with */
/* the normal DMA control register reset values */
/* of zero. If the offsets start at zero, one */
/* of the buffers can get stuck in the 'LIMBO' */
/* state until the DMA engine starts to operate.*/
/* Start off by applying a software reset */
DP_CommandSequence ( DP_COMMAND_SEQUENCE_OPERATIONS_SINGLE_COMMAND_INSTANT,
(DP_FieldTarget *) &DP_asGlobalFieldTargets [DP_GLOBAL_FIELD_CONTROL_SOFTWARE_RESET],
(DP_UINT_32) (DP_TRUE & 0x01) );
DP_CommandSequence ( DP_COMMAND_SEQUENCE_OPERATIONS_SINGLE_COMMAND_INSTANT,
(DP_FieldTarget *) &DP_asGlobalFieldTargets [DP_GLOBAL_FIELD_CONTROL_SOFTWARE_RESET],
(DP_UINT_32) (DP_FALSE & 0x01) );
/* Ensure that the display pipeline is in fully powered down mode */
DP_SetDisplayEnabled ( DP_DISPLAY_FULLY_POWERED_DOWN );
/* Disable all interrupts */
sInterruptEnables.eCursor2Underrun = DP_OFF;
sInterruptEnables.eCursor1Underrun = DP_OFF;
sInterruptEnables.ePlane6Underrun = DP_OFF;
sInterruptEnables.ePlane5Underrun = DP_OFF;
sInterruptEnables.ePlane4Underrun = DP_OFF;
sInterruptEnables.ePlane3Underrun = DP_OFF;
sInterruptEnables.ePlane2Underrun = DP_OFF;
sInterruptEnables.ePlane1Underrun = DP_OFF;
sInterruptEnables.ePlane2BufferOverrun = DP_OFF;
sInterruptEnables.ePlane1BufferOverrun = DP_OFF;
sInterruptEnables.eVerticalBlanking_FirstField = DP_OFF;
sInterruptEnables.eVerticalBlanking_SecondField = DP_OFF;
sInterruptEnables.eHorizontalBlanking_FirstField = DP_OFF;
sInterruptEnables.eHorizontalBlanking_SecondField = DP_OFF;
DP_EnableInterrupts ( &sInterruptEnables );
/* Clear any interrupts which are currently pending */
DP_CheckInterrupts ( &sInterruptEnables );
#if DP_USE_INTERRUPTS
/* Register PDP ISR with UIH */
UIH_RegisterPeripheralISR ( DP_INTERRUPT_BIT_POSITION, DP_ISR );
#endif
/* Now set all timing / initialisation fields */
DP_CommandSequence ( DP_COMMAND_SEQUENCE_OPERATIONS_NEW_SEQUENCE,
DP_NULL,
DP_NULL );
/* Main control block */
#if INTERLACEDENABLED
ui16CommandResult = DP_CommandSequence ( DP_COMMAND_SEQUENCE_OPERATIONS_ADD_COMMAND,
(DP_FieldTarget *) &DP_asGlobalFieldTargets [DP_GLOBAL_FIELD_CONTROL_INTERLACE_ENABLED],
sInitialisationData.bInterlaceOn ? (DP_UINT_32) 0x1 : (DP_UINT_32) 0x0 );
DP_bIsDisplayInterlaced = sInitialisationData.bInterlaceOn;
#if defined DP_ERROR_CHECKING
if ( ui16CommandResult == DP_STANDARD_CODE_NO_ERROR )
{
#else
if (( ui16CommandResult > DP_CRITICAL_ERROR_END_MARKER ) || ( ui16CommandResult == DP_STANDARD_CODE_NO_ERROR ))
{
#endif
ui16CommandResult = DP_CommandSequence ( DP_COMMAND_SEQUENCE_OPERATIONS_ADD_COMMAND,
(DP_FieldTarget *) &DP_asGlobalFieldTargets [DP_GLOBAL_FIELD_CONTROL_FIELD_POLARITY],
sInitialisationData.bFieldPolarity ? (DP_UINT_32) 0x1 : (DP_UINT_32) 0x0 );
}
#endif // interlaced enabled!
#if defined DP_ERROR_CHECKING
if ( ui16CommandResult == DP_STANDARD_CODE_NO_ERROR )
{
#else
if (( ui16CommandResult > DP_CRITICAL_ERROR_END_MARKER ) || ( ui16CommandResult == DP_STANDARD_CODE_NO_ERROR ))
{
#endif
ui16CommandResult = DP_CommandSequence ( DP_COMMAND_SEQUENCE_OPERATIONS_ADD_COMMAND,
(DP_FieldTarget *) &DP_asGlobalFieldTargets [DP_GLOBAL_FIELD_CONTROL_COMPOSITE_OUTPUT_ENABLE],
sInitialisationData.bCompositeSyncEnable ? (DP_UINT_32) 0x1 : (DP_UINT_32) 0x0 );
}
#if defined DP_ERROR_CHECKING
if ( ui16CommandResult == DP_STANDARD_CODE_NO_ERROR )
{
#else
if (( ui16CommandResult > DP_CRITICAL_ERROR_END_MARKER ) || ( ui16CommandResult == DP_STANDARD_CODE_NO_ERROR ))
{
#endif
ui16CommandResult = DP_CommandSequence ( DP_COMMAND_SEQUENCE_OPERATIONS_ADD_COMMAND,
(DP_FieldTarget *) &DP_asGlobalFieldTargets [DP_GLOBAL_FIELD_CONTROL_VSYNC_SLAVE],
sInitialisationData.bVerticalSyncSlaved ? (DP_UINT_32) 0x1 : (DP_UINT_32) 0x0 );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -