📄 tmhdvo.c
字号:
}
rval = hdvoLoadSTMParameters(setup->stmParameters);
tmAssert(rval == TMLIBDEV_OK, rval);
if (rval != TMLIBDEV_OK)
return rval;
#endif
/* Now that we have a clock (generated by STM, we can call the BSP init
* function. This is requied by peripherals such as the saa7125 which need
* a clock before being brought out of reset.
*/
rval = HDVOsetup_board(setup->videoStandard,
setup->adapterType,
setup->videoType,
setup->videoSubtype,
setup->description);
if (rval != TMLIBDEV_OK) {
tmAssert((rval == TMLIBDEV_OK), rval);
return rval;
}
mdxParameters = (UInt8 *)
((setup->context->mdxAddr3 << 20)
| (setup->context->mdxAddr2 << 10)
| (setup->context->mdxAddr1));
rval = hdvoLoadMDXParameters(mdxParameters);
tmAssert(rval == TMLIBDEV_OK, rval);
if (rval != TMLIBDEV_OK)
return rval;
#ifndef DISABLE_LOAD_DATA
rval = hdvoLoadDataSegment(setup->kernelDataAddr, setup->kernelDataSize);
tmAssert(rval == TMLIBDEV_OK, rval);
if (rval != TMLIBDEV_OK)
return rval;
#endif
#ifndef DISABLE_LOAD_CODE
#ifndef HDVO_UNFORMATED_UCODE
rval = hdvoLoadMicroCode(setup->kernelProg0Addr, setup->kernelProgSize);
tmAssert(rval == TMLIBDEV_OK, rval);
#else
rval = hdvoLoadMicroCode(setup->kernelProg0Addr,
setup->kernelProg1Addr,
setup->kernelProg2Addr,
setup->kernelProgSize);
tmAssert(rval == TMLIBDEV_OK, rval);
#endif /* HDVO_UNFORMATED_UCODE */
if (rval != TMLIBDEV_OK)
return rval;
#endif
#ifndef DISABLE_LOAD_CONTEXT
rval = hdvoLoadContext(setup->context);
tmAssert(rval == TMLIBDEV_OK, rval);
if (rval != TMLIBDEV_OK)
return rval;
#endif
/*
* Enable the MCP.
*/
#ifndef DISABLE_LOAD_CODE
hdvoEnableMCP_CTRL_MCP_Enable();
#endif
return rval;
}
/*****************************************************************************/
/*
* Function : hdvoClose
* Resets HDVO. De-install the interrupt handler
*
* Parameters : 1. Instance
*
* Function Result: Return TMLIBDEV_OK on success
* TMLIBDEV_ERR_NOT_OWNER; Someone else already has the
* device control
* BOARD_ERR_NULL_FUNCTION; the respective BSP initFunc
* pointer is Null.
*
* Precondition : HDVO is open by hdvoOpen().
*
* Postcondtion : HDVO interrupts are disabled. Ready to be opened by
* someone.
*/
tmLibdevErr_t
hdvoClose(Int instance)
{
tmLibdevErr_t rval = TMLIBDEV_OK;
tmAssert(hdvoInstance == instance, TMLIBDEV_ERR_NOT_OWNER);
AppModel_suspend_scheduling();
/*
* Completely reset hdvo. We can't simply disable the MCP as streaming out
* will continue to read from the memories causing whatever is in them to be
* displayed.
*/
hdvoReset();
rval = intClose(intHDVO);
tmAssert(rval == TMLIBDEV_OK, rval);
if (gpioInstance != 0)
{
gpioClose(gpioInstance);
gpioInstance = 0;
}
/* atomic by nature */
interruptInstalled = False;
if (boardHDVOConfig->termFunc)
rval = boardHDVOConfig->termFunc();
else {
rval = BOARD_ERR_NULL_FUNCTION;
goto hdvoCloseExit;
}
hdvoInstance--;
capabilities.unitCapabilities[hdvoUnitName].numCurrentInstances--;
hdvoCloseExit:
AppModel_resume_scheduling();
return rval;
}
#ifdef HDVO_NOKERNEL
/*****************************************************************************/
/*
* Function : hdvoReloadCode
* Loading the MCP context structure
* Loading the MCP initialised data segment
* Loading the MCP program memory
*
* Parameters : 1. Instance
* 2. Pointer to the hdvo setup block hdvoInstanceSetup_t
*
* Function Result: Return zero on success
* TMLIBDEV_ERR_NOT_OWNER; Someone else already has the
* device control
* TMLIBDEV_ERR_NULL_PARAMETER; the setup parameter is Null.
* BOARD_ERR_NULL_FUNCTION; the respective BSP initFunc
* pointer is Null.
*
* Precondition : Require hdvoOpen() and hdvoInstanceSetup() to be called
* first.
*/
tmLibdevErr_t
hdvoReloadCode(Int instance, hdvoInstanceSetup_t * setup)
{
tmLibdevErr_t rval = TMLIBDEV_OK;
tmAssert(hdvoInstance == instance, TMLIBDEV_ERR_NOT_OWNER);
if (hdvoInstance != instance)
return TMLIBDEV_ERR_NOT_OWNER;
tmAssert(setup, TMLIBDEV_ERR_NULL_PARAMETER);
tmAssert(setup->context, TMLIBDEV_ERR_NULL_PARAMETER);
tmAssert(!(((UInt32) setup->context) & 0xf), HDVO_ERR_ADDRESS_NOT_ALIGNED);
hdvoDisableMCP_CTRL_MCP_Enable();
hdvoAckMCP_CTRL_Reset_MCP();
#if 1
hdvoEnableDHI_CTRL_Load_Conf_Enable();
hdvoIssueProcessingStep(HDVO_SYNCHRONOUS_ISSUE);
hdvoIssueProcessingStep(HDVO_SYNCHRONOUS_ISSUE);
while(hdvoCheckDHI_HSTATUS2_HTS());
/*
* load context, dataSegment, and microcode.
*/
#ifndef DISABLE_LOAD_DATA
rval = hdvoLoadDataSegment(setup->kernelDataAddr, setup->kernelDataSize);
tmAssert(rval == TMLIBDEV_OK, rval);
if (rval != TMLIBDEV_OK)
return rval;
#endif
#ifndef DISABLE_LOAD_CODE
#ifndef HDVO_UNFORMATED_UCODE
rval = hdvoLoadMicroCode(setup->kernelProg0Addr, setup->kernelProgSize);
tmAssert(rval == TMLIBDEV_OK, rval);
if (rval != TMLIBDEV_OK)
return rval;
#else
rval = hdvoLoadMicroCode(setup->kernelProg0Addr,
setup->kernelProg1Addr,
setup->kernelProg2Addr,
setup->kernelProgSize);
tmAssert(rval == TMLIBDEV_OK, rval);
if (rval != TMLIBDEV_OK)
return rval;
#endif /* HDVO_UNFORMATED_UCODE */
#endif
#ifndef DISABLE_LOAD_CONTEXT
rval = hdvoLoadContext(setup->context);
tmAssert(rval == TMLIBDEV_OK, rval);
if (rval != TMLIBDEV_OK)
return rval;
#endif
#endif
/*
* Enable the MCP.
*/
hdvoEnableMCP_CTRL_MCP_Enable();
return (rval);
}
#endif
/*****************************************************************************/
/*
* Function : hdvoSetupHDVO_CLK
* Sets the HDVO output pixel clk value in the streaming
* out parameter table.
*
* Parameters : 1. Instance
* 2. HDVO output clock frequency
* 3. Pointer to the streaming out parameters
*
* Function Result: Return zero on success
* TMLIBDEV_ERR_NOT_OWNER; Someone else already has the
* device
* TMLIBDEV_ERR_NULL_PARAMETER; The pointer to the stm
* parameters is Null.
*
* Precondition : Require hdvoOpen() to be called first.
*/
tmLibdevErr_t
hdvoSetHDVO_CLK(int instance, UInt hdvoClockFrequency,
UInt8 *stmParameters)
{
tmLibdevErr_t rval = TMLIBDEV_OK;
UInt32 stmPARAM;
UInt8 divmux;
tmAssert(hdvoInstance == instance, TMLIBDEV_ERR_NOT_OWNER);
if (hdvoInstance != instance)
return TMLIBDEV_ERR_NOT_OWNER;
tmAssert(stmParameters, TMLIBDEV_ERR_NULL_PARAMETER);
if (!stmParameters)
return TMLIBDEV_ERR_NULL_PARAMETER;
rval = hdvoCalculateFrequency(hdvoClockFrequency,
&stmPARAM, &divmux);
stmParameters[2] = stmPARAM & 0xff;
stmParameters[3] = (stmPARAM >> 8) & 0xff;
stmParameters[4] = (stmPARAM >> 16) & 0xff;
stmParameters[5] = (stmPARAM >> 24) & 0xff;
stmParameters[6] = divmux;
return rval;
}
/*****************************************************************************/
/*
* Function : hdvoSetFrequency
* Sets the HDVO output pixel clk value in the context
* structure.
*
* This function should be used to update the hdvo pixel
* clock whilst the device is running (ie. after the
* hdvoInstanceSetup() function has been called).
*
* Parameters : 1. Instance
* 2. HDVO output clock frequency
* 3. Pointer to the hdvo context structure
*
* Function Result: Return zero on success
* TMLIBDEV_ERR_NOT_OWNER; Someone else already has the
* device
* TMLIBDEV_ERR_NULL_PARAMETER; The pointer to the context is
* Null.
*
* Precondition : Require hdvoOpen() to be called first.
*/
tmLibdevErr_t hdvoSetFrequency(int instance, UInt32 hdvoClockFrequency,
phdvoContext_t context)
{
tmLibdevErr_t rval = TMLIBDEV_OK;
UInt32 stmPARAM;
UInt8 divmux;
tmAssert(hdvoInstance == instance, TMLIBDEV_ERR_NOT_OWNER);
if (hdvoInstance != instance)
return TMLIBDEV_ERR_NOT_OWNER;
tmAssert(context, TMLIBDEV_ERR_NULL_PARAMETER);
if (!context)
return TMLIBDEV_ERR_NULL_PARAMETER;
rval = hdvoCalculateFrequency(hdvoClockFrequency,
&stmPARAM, &divmux);
context->frequency[0] = stmPARAM & 0xff;
context->frequency[1] = (stmPARAM >> 8) & 0xff;
context->frequency[2] = (stmPARAM >> 16) & 0xff;
context->frequency[3] = (stmPARAM >> 24) & 0xff;
context->frequency[4] = divmux;
return rval;
}
/*****************************************************************************/
/***************************************************************************/
/* */
/* INTERNAL FUNCTIONS */
/* */
/***************************************************************************/
/***************************************************************************/
/*
* Function : hdvoCalculateFrequency
* Calculates the hdvo frequency parameters.
*
* Parameters : 1. Desired frequency
* 2. Pointer to store 32 bit frequency values
* 3. Pointer to PLL_T/mux values
*
* Function Result: Return TMLIBDEV_OK on success.
*
* Precondition :
*
* Postcondition :
*/
static float TWO31 = (float) 2147483648;
static float TWO32DIV9 = (float) 2*(2147483648/9);
tmLibdevErr_t hdvoCalculateFrequency(UInt32 hdvoClockFrequency,
UInt32 *freq, UInt8 * divmux)
{
pprocCapabilities_t procCap;
float freqDSPCPU;
float freqDDS;
float freqHDVO_CLK = (float) hdvoClockFrequency;
float freqSTM;
procGetCapabilities(&procCap);
DP(("hdvoSetFrequency: CPU running at %3.2f MHz\n",
0.000001 * (float) procCap->cpuClockFrequency));
freqDSPCPU = (float) procCap->cpuClockFrequency;
DP(("hdvoSetFrequency: HDVO_CLK set to %.0fHz\n", freqHDVO_CLK));
freqDDS = freqHDVO_CLK;
freqSTM = TWO31 + TWO32DIV9*(freqDDS/freqDSPCPU);
*freq = (UInt32) freqSTM;
DP(("hdvoSetFrequency:STM frequency (Dec, Hex) = %.0f, %x\n",
freqSTM, *freq));
*divmux = 0;
return TMLIBDEV_OK;
}
/***************************************************************************/
/*
* Function : hdvoLoadSTMGamma
* Loads the streaming out gamma parameters
*
* Parameters : Pointer to the gamma correction table
*
* Function Result: Return TMLIBDEV_OK on success.
* HDVO_ERR_ADDRESS_NOT_ALIGNED is the gamma table is not
* aligned on a 16 byte boundary.
*
* Precondition : MCP should not be running.
*
* Postcondition :
*/
#ifndef DISABLE_LOAD_STM_GAMMA
tmLibdevErr_t
hdvoLoadSTMGamma(UInt8 *gammaTable)
{
tmLibdevErr_t rval;
/*
* Check the Gamma table is on a 16 byte boundary.
*/
tmAssert(gammaTable, TMLIBDEV_ERR_NULL_PARAMETER);
if (((UInt32) gammaTable) & 0x0f) {
tmAssert(!(((UInt32) gammaTable) & 0x0f), HDVO_ERR_ADDRESS_NOT_ALIGNED);
return HDVO_ERR_ADDRESS_NOT_ALIGNED;
}
/*
* Copyback the gamma table
*/
_cache_copyback(gammaTable, HDVO_NUMBER_STM_GAMMA_PARAMETERS);
/*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -