thrdisplay.c
来自「TI公司的算法标准 Framework5的源代码」· C语言 代码 · 共 212 行
C
212 行
/*
* Copyright 2002 by Texas Instruments Incorporated.
* All rights reserved. Property of Texas Instruments Incorporated.
* Restricted rights to use, duplicate or disclose this code are
* granted through contract.
*
*/
/* "@(#) RF5_IEK 2.00.02 12-11-02 (swat-c19)" */
/*
* ======== thrDisplay.c ========
*/
#include <std.h>
#include <string.h>
// DSP/BIOS includes
#include <tsk.h>
// CSL includes
#include <csl_dat.h>
// RF5 module includes
#include <scom.h>
#include <utl.h>
// application includes
#include "appResources.h" /* application-wide common info */
// Thread include
#include "thrDisplay.h"
#pragma DATA_SECTION(bufRGBdoubled1,".EXTPROCBUFF");
#pragma DATA_SECTION(bufRGBdoubled2,".EXTPROCBUFF");
#pragma DATA_ALIGN(bufRGBdoubled1,MEMALIGN);
#pragma DATA_ALIGN(bufRGBdoubled2,MEMALIGN);
// Display Thread object
ThrDisplay thrDisplay;
Uint16 bufRGBdoubled1[OPF_SIZE_IN_PIXELS];
Uint16 bufRGBdoubled2[OPF_SIZE_IN_PIXELS];
// Local function prototypes
static Bool openDisplay( Void );
static Void putOutputFrame( MdUns *src );
/*
* ======== thrDisplayInit ========
*
*/
Void thrDisplayInit()
{
SCOM_Handle scomReceive;
thrDisplay.flipflop = 0;
thrDisplay.hVout = NULL;
/* create your receiving SCOM queue */
scomReceive = SCOM_create( "scomDisplay", &SCOM_ATTRS );
UTL_assert( scomReceive != NULL);
if (openDisplay() == FALSE) {
UTL_logError("Display failed to open\n");
SYS_abort("Display failed to open");
}
}
/*
* ======== thrDisplayStartup ========
*
*/
Void thrDisplayStartup()
{
}
// Local helper funtions
/*
* ======== openDisplay ========
*
* Open up VGA display driver
*/
static Bool openDisplay( Void )
{
IEKC64_STATUS status;
static Bool firstTime = TRUE;
if (firstTime == TRUE) {
firstTime = FALSE;
thrDisplay.videoOut.Standard = VIDEO_STANDARD;
thrDisplay.videoOut.Resolution = VIDEO_OUTPUT_RES;
thrDisplay.videoOut.FrameFormat = RGB565PIXEL;
thrDisplay.videoOut.VideoOutSelect = VGA;
// Let's open and start generation
status = VOUT_open( &thrDisplay.videoOut,&thrDisplay.hVout );
if (!IEKC64_SUCCESS( status ))
{
UTL_logError1( "VOUT_open() failed with 0x%08X\n", status );
return (FALSE);
}
status = VOUT_start( thrDisplay.hVout );
if (!IEKC64_SUCCESS( status ))
{
UTL_logError1( "VOUT_start() failed with 0x%08X\n", status );
return (FALSE);
}
// Clear the buffers
memset( bufRGBdoubled1,0x00,OPF_SIZE_IN_PIXELS*OPF_PXLSIZE );
memset( bufRGBdoubled2,0x00,OPF_SIZE_IN_PIXELS*OPF_PXLSIZE );
}
return (TRUE);
}
/*
* ======== putOutputFrame ========
*
* The image from the processing thread is a full
* 720x480 (4 CIF images).
*
* -----------------------------
* | | |
* | | |
* | | |
* | CHANNEL 1 | CHANNEL 2 |
* | | |
* | | |
* | | |
* -----------------------------
* | | |
* | | |
* | | |
* | CHANNEL 3 | CHANNEL 4 |
* | | |
* | | |
* | | |
* -----------------------------
*/
static Void putOutputFrame( MdUns *src )
{
Uint16 *dst;
Uint16 *dstCurrent;
Int Id;
if (thrDisplay.flipflop==0)
dst = &bufRGBdoubled2[0];
else
dst = &bufRGBdoubled1[0];
dstCurrent = dst;
// 720*480 output frame
// T-L
// Older versions had a wrap-around issue with one column of pixels.
// This line fixes it in software
dstCurrent += 4;
//Copy data from input buffer to output buffer
Id = DAT_copy2d(DAT_1D2D, src, dstCurrent, RGBF_WIDTH*RGBF_PXLSIZE,
RGBF_HEIGHT, OPF_WIDTH*OPF_PXLSIZE);
//Wait for transfer to finish
DAT_wait(Id);
//Output frame
VOUT_putFrame(thrDisplay.hVout,dst,IEKC64_VIDEO_NO_WAIT);
thrDisplay.flipflop ^= 1;
}
/*
* ======== thrDisplayRun ========
*
* Main function of Display Thread.
*/
Void thrDisplayRun()
{
SCOM_Handle scomReceive, scomSend;
UTL_logDebug1("thrDisplayRun: task = 0x%x", TSK_self());
// create the SCOM links (one for receiving and another for sending)
scomReceive = SCOM_open( "scomDisplay" );
scomSend = SCOM_open( "scomToProcessFromDisplay" );
UTL_assert( scomReceive != NULL );
UTL_assert( scomSend != NULL );
// Main loop
while (TRUE) {
ScomProcToDisp *scombufDisp;
// get a full buffer from the ProcToDisp link
scombufDisp = SCOM_getMsg( scomReceive, SYS_FOREVER );
// Display
putOutputFrame( scombufDisp->bufRGB );
// send back descriptors of now used up source channels to Process
SCOM_putMsg( scomSend, scombufDisp );
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?