📄 ddi_display_controller_s6b0724.c
字号:
pPrevLcdifDmaDesc = NULL;
pThisLcdifDmaDesc = pLcdifDmaDesc;
iCmdIdx = 0;
iDescIdx = 0;
while(u32NumActivePage>0)
{
ddi_lcdif_SetupDma(pThisLcdifDmaDesc, pPrevLcdifDmaDesc,
CMD_MODE, &u32ControllerCommandBuf[iCmdIdx], /*3*/4);
iCmdIdx++;
pPrevLcdifDmaDesc = pThisLcdifDmaDesc;
iDescIdx++;
pThisLcdifDmaDesc = &g_ddi_display_DmaDescChain[iDescIdx];
ddi_lcdif_SetupDma(pThisLcdifDmaDesc, pPrevLcdifDmaDesc,
DATA_MODE, pu8Buf, u32NumActiveColumn);
pu8Buf += u32NumActiveColumn;
pPrevLcdifDmaDesc = pThisLcdifDmaDesc;
iDescIdx++;
pThisLcdifDmaDesc = &g_ddi_display_DmaDescChain[iDescIdx];
u32NumActivePage--;
}
return ddi_lcdif_WriteDma(pLcdifDmaDesc, iDescIdx);
}
////////////////////////////////////////////////////////////////////////////////
//! \fn static RtStatus_t ddi_display_controller_Draw(void *pBuf, uint32_t u32XDst, uint32_t u32YDst,
//! uint32_t *pu32Width, uint32_t *pu32Height)
//!
//! \brief Implements the draw function.
//!
//! \fntype Function
//!
//! \param[in] pBuf - Pointer to the bitmap data to be drawn
//! \param[in] u32XDst - X coordinate of upper left corner of the destination region
//! \param[in] u32YDst - Y coordinate of upper left corner of the destination region
//! \param[in] pu32Width - Width of the destination region
//! \param[in] pu32Height - Height of the destination region
//!
//! This function allows for a controller support module to implement the ddi_display_Draw() function.
//! When ddi_display_Draw is called, this function will run instead. This should be implemented
//! whenever a display controller has special DMA handling functionality (as with 1bpp vertical).
//!
//! \retval SUCCESS No error
//!
//! \retval ERROR_DDI_DISPLAY_PLACEMENT - There was an error placing the given
//! region on the display that clipping could not compensate for.
//!
////////////////////////////////////////////////////////////////////////////////
static RtStatus_t ddi_display_controller_Draw(void *pBuf,
uint32_t u32XDst, uint32_t u32YDst,
uint32_t *pu32Width, uint32_t *pu32Height)
{
#define SetPageAddrCmd 0xB0
#define SetColumnAddrMSBCmd 0x10
#define SetColumnAddrLSBCmd 0x00
#define u32StartPage 0
#define u32StartColumn 0
uint32_t u32TotalWidth = g_ddi_display_u16ScreenWidth;
uint32_t u32TotalHeight = g_ddi_display_u16ScreenHeight;
uint32_t ii, u32Data;
DDI_DISPLAY_WORD_TYPE VertCommand; // Command byte for vertical setup
DDI_DISPLAY_WORD_TYPE HorzCommand; // Command byte for horizontal setup
// Truncate the height
*pu32Height &= ~0x07;
// Check for zero sized region
if( !*pu32Width || !*pu32Height
|| u32XDst >= u32TotalWidth
|| u32YDst >= u32TotalHeight
|| (u32YDst&0x07) != 0
)
{
return ERROR_DDI_DISPLAY_PLACEMENT;
}
// Check for clipping
if( u32XDst + *pu32Width > u32TotalWidth)
{
// FIXME - Must do a DrawRegion type xfer for this
// since the clipped pixels will not be contiguous
return ERROR_DDI_DISPLAY_PLACEMENT;
}
// Check for clipping
if( u32YDst + *pu32Height > u32TotalHeight )
{
*pu32Height = ((u32TotalHeight - u32YDst)/8)*8;
}
u32NumActivePage = (*pu32Height)/8;
u32NumActiveColumn = (*pu32Width);
VertCommand = u32StartPage + (u32YDst/8);
HorzCommand = u32StartColumn + u32XDst;
// Setup DMA commands and data for each page
for(ii=0; ii<u32NumActivePage; ii++)
{
u32Data = ((CMD_SET_LOWER_COLUMN_ADDRESS(HorzCommand)));
u32Data |= ((CMD_SET_HIGHER_COLUMN_ADDRESS(HorzCommand))<<8);
u32Data |= ((CMD_SET_PAGE_ADDRESS(VertCommand ))<<16);
u32Data |= 0xE3000000; // nop
u32ControllerCommandBuf[ii] = u32Data;
VertCommand++;
}
return SetupAndStartDma(g_ddi_display_pDmaDescChain, (uint8_t *)pBuf);
}
////////////////////////////////////////////////////////////////////////////////
//! \fn RtStatus_t SendControllerBitmapType(gfx_BitmapTypeEnum_t eBitmapType)
//!
//! \brief Sets up the controller for the specified bitmap format
//!
//! \fntype Function
//!
//! \param[in] eBitmapType - The new bitmap format
//!
//! This function sends the appropriate commands to the display controller
//! to set it up for the new bitmap type format.
//!
//! \retval SUCCESS No error
//!
//! \retval ERROR_DDI_DISPLAY_CONTROLLER_BITMAP_TYPE_UNSUPPORTED - The specified bitmap
//! type is not supported by the controller
//!
////////////////////////////////////////////////////////////////////////////////
static RtStatus_t SendControllerBitmapType(gfx_BitmapTypeEnum_t eBitmapType)
{
// Only 1-bit vertical mode supported
if( eBitmapType != BITMAP_TYPE_1BPP_VERTICAL )
return ERROR_DDI_DISPLAY_CONTROLLER_BITMAP_TYPE_UNSUPPORTED;
return SUCCESS;
}
////////////////////////////////////////////////////////////////////////////////
//! \fn static RtStatus_t SendControllerResolution(uint16_t u16Width, uint16_t u16Height, ddi_display_Rotation_t eRotation)
//!
//! \brief Sets up the controller for the specified resolution
//!
//! \fntype Function
//!
//! \param[in] u16Width - Desired width of the display
//! \param[in] u16Height - Desired height of the display
//! \param[in] eRotation Desired orientation of the display
//!
//! The display driver is built with a default width and height for each
//! controller. Most controllers support displays of varying screen
//! dimensions. In order to support all possible dimensions without rebuilding
//! the display libraries, this function can set the dimensions of the display
//! to match the actual display in use. This function only needs to be called
//! once to set the dimensions for the currently set screen orientation. If the
//! display is rotated after the dimensions are set, then the dimensions will
//! be adjusted accordingly in the display driver. There is no need to reset
//! the dimensions after rotating the display.
//!
//! \retval SUCCESS No error
//!
//! \retval ERROR_DDI_DISPLAY_CONTROLLER_RESOLUTION - The specified resolution is
//! not supported by the controller
//!
////////////////////////////////////////////////////////////////////////////////
static RtStatus_t SendControllerResolution(uint16_t u16Width, uint16_t u16Height, ddi_display_Rotation_t eRotation)
{
if(eRotation!=DDI_DISPLAY_ROTATION_NONE)
{
return ERROR_DDI_DISPLAY_CONTROLLER_ROTATION;
}
// max dimensions are rotation specific
if( u16Width > DDI_DISPLAY_CONTROLLER_MAX_WIDTH || u16Height > DDI_DISPLAY_CONTROLLER_MAX_HEIGHT )
return ERROR_DDI_DISPLAY_CONTROLLER_RESOLUTION;
return SUCCESS;
}
////////////////////////////////////////////////////////////////////////////////
//! \fn static RtStatus_t SendControllerRotation(ddi_display_Rotation_t eRotation)
//!
//! \brief Sets up the controller for the specified rotation
//!
//! \fntype Function
//!
//! \param[in] eRotation - Desired orientation of the display
//!
//! When the display driver is instructed to orient the screen to a new
//! rotation, this function sends a command to the controller to indicate this change.
//!
//! \retval SUCCESS No error
//!
//! \retval ERROR_DDI_DISPLAY_CONTROLLER_ROTATION - The specified rotation is
//! not supported by the controller
//!
////////////////////////////////////////////////////////////////////////////////
static RtStatus_t SendControllerRotation(ddi_display_Rotation_t eRotation)
{
RtStatus_t ret = SUCCESS;
if(eRotation!=DDI_DISPLAY_ROTATION_NONE)
{
ret = ERROR_DDI_DISPLAY_CONTROLLER_ROTATION;
}
return ret;
}
////////////////////////////////////////////////////////////////////////////////
//! \fn RtStatus_t ddi_display_controller_SendCommand(ddi_display_controller_CommandType_t eType, ...)
//!
//! \brief Sends the specified command to the controller
//!
//! \fntype Function
//!
//! \param[in] eType - Type of command to send
//! \param[in] ... Variable argument list - The rest of the arguments are specific
//! to the type of command is to be sent. Refer to
//! ddi_display_controller.h for command types and their
//! corresponding argument lists.
//!
//! \retval SUCCESS No error
//!
//! \retval ERROR_DDI_DISPLAY_CONTROLLER_COMMAND_UNSUPPORTED - This
//! controller does not support the given command type
//!
//! \retval ERROR_DDI_DISPLAY_CONTROLLER_BITMAP_TYPE_UNSUPPORTED - This
//! controller does not support the given bitmap color type
//!
//! \retval ERROR_DDI_DISPLAY_CONTROLLER_ROTATION - The specified rotation is
//! not supported by the controller
//!
//! \retval ERROR_DDI_DISPLAY_PLACEMENT - There was an error placing the given
//! region on the display that clipping could not compensate for.
//!
////////////////////////////////////////////////////////////////////////////////
RtStatus_t ddi_display_controller_SendCommand(ddi_display_controller_CommandType_t eType, ...)
{
RtStatus_t ret = SUCCESS;
va_list valist;
va_start(valist, eType);
switch(eType)
{
case DDI_DISPLAY_CONTROLLER_INIT:
{
gfx_BitmapTypeEnum_t eBitmapType = va_arg(valist, gfx_BitmapTypeEnum_t);
uint32_t u32ScreenWidth = va_arg(valist, uint32_t);
uint32_t u32ScreenHeight = va_arg(valist, uint32_t);
SendControllerInitSeq(eBitmapType, u32ScreenWidth, u32ScreenHeight);
InitPwmBacklight();
}
break;
case DDI_DISPLAY_CONTROLLER_OUTPUT_ENABLE:
SendControllerOutputEnable(va_arg(valist, bool));
break;
case DDI_DISPLAY_CONTROLLER_SET_CONTRAST:
SendControllerContrast(va_arg(valist, uint32_t));
break;
case DDI_DISPLAY_CONTROLLER_SET_BRIGHTNESS:
SetPwmBrightness(va_arg(valist, uint32_t));
break;
case DDI_DISPLAY_CONTROLLER_SET_ROTATION:
ret = SendControllerRotation(va_arg(valist, ddi_display_Rotation_t));
break;
case DDI_DISPLAY_CONTROLLER_SET_RESOLUTION:
{
uint16_t u16Width = va_arg(valist, uint16_t);
uint16_t u16Height = va_arg(valist, uint16_t);
ddi_display_Rotation_t eRotation = va_arg(valist, ddi_display_Rotation_t);
ret = SendControllerResolution(u16Width, u16Height, eRotation);
break;
}
case DDI_DISPLAY_CONTROLLER_SET_BITMAP_TYPE:
ret = SendControllerBitmapType(va_arg(valist, gfx_BitmapTypeEnum_t));
break;
case DDI_DISPLAY_CONTROLLER_SET_LOW_POWER_MODE:
SetControllerLowPowerMode(va_arg(valist, bool));
break;
case DDI_DISPLAY_CONTROLLER_DRAW:
{
uint8_t *pu8Buf;
uint32_t u32XDst;
uint32_t u32YDst;
uint32_t *pu32Width;
uint32_t *pu32Height;
pu8Buf = va_arg(valist, uint8_t *);
u32XDst = va_arg(valist, uint32_t);
u32YDst = va_arg(valist, uint32_t);
pu32Width = va_arg(valist, uint32_t *);
pu32Height = va_arg(valist, uint32_t *);
ret = ddi_display_controller_Draw(pu8Buf, u32XDst, u32YDst, pu32Width, pu32Height);
break;
}
default:
ret = ERROR_DDI_DISPLAY_CONTROLLER_COMMAND_UNSUPPORTED;
break;
}
va_end(valist);
return ret;
}
///////////////////////////////////////////////////////////////////////////////
// End of file
///////////////////////////////////////////////////////////////////////////////
//! @}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -