📄 active.c
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
//
//
// (C) Copyright 2006 Marvell International Ltd.
// All Rights Reserved
//
/*
** INTEL CONFIDENTIAL
** Copyright 2000-2006 Intel Corporation All Rights Reserved.
**
** The source code contained or described herein and all documents
** related to the source code (Material) are owned by Intel Corporation
** or its suppliers or licensors. Title to the Material remains with
** Intel Corporation or its suppliers and licensors. The Material contains
** trade secrets and proprietary and confidential information of Intel
** or its suppliers and licensors. The Material is protected by worldwide
** copyright and trade secret laws and treaty provisions. No part of the
** Material may be used, copied, reproduced, modified, published, uploaded,
** posted, transmitted, distributed, or disclosed in any way without Intel抯
** prior express written permission.
**
** No license under any patent, copyright, trade secret or other intellectual
** property right is granted to or conferred upon you by disclosure or
** delivery of the Materials, either expressly, by implication, inducement,
** estoppel or otherwise. Any license under such intellectual property rights
** must be express and approved by Intel in writing.
*/
#include "lcd_plat.h"
#include "runtime_context.h"
#include "ost.h"
#include "ioctl_cfg.h"
PXA_STATUS_T ActiveInit(active_lcd_t *lcd, UINT32 base_phy)
{
PXA_STATUS_T status;
UINT32 buf_size;
UINT32 pcds[CLK_OPTION_MAX];
UINT32 i;
UINT32 out_size;
buf_size = lcd->panel->config.width * lcd->panel->config.height * (lcd->panel->config.bpp >> 3);
status = lcd->panel->init(lcd->panel);
PXA_LCDInitDMADescriptor(&lcd->dma_descs[0], lcd->dma_descs[0].FDADR, base_phy, buf_size);
PXA_LCDActiveInitController(lcd->lcd_regs, &lcd->panel->config, &lcd->dma_descs[0]);
for (i = 0; i < CLK_OPTION_MAX; i++)
pcds[i] = lcd->panel->config.timing.PCD[i];
KernelIoControl(IOCTL_LCD_PCDS, pcds, sizeof(pcds), NULL, 0, &out_size);
status = lcd->panel->post_init(lcd->panel);
lcd->cursor.status = CursorOn;
PXA_LCDActiveCursorOn(lcd->lcd_regs, &lcd->dma_descs[0],lcd->cursor.status,0, 0, 0);
return status;
}
void ActiveResume(active_lcd_t *lcd)
{
lcd->panel->set_power_mode(lcd->panel, 1);
PXA_LCDActiveInitController(lcd->lcd_regs, &lcd->panel->config, &lcd->dma_descs[0]);
lcd->cursor.status = CursorOn;
PXA_LCDActiveCursorOn(lcd->lcd_regs, &lcd->dma_descs[0],lcd->cursor.status,0, 0, 0);
}
void ActiveSuspend(active_lcd_t *lcd)
{
PXA_LCDTurnOffBaseFrame(lcd->lcd_regs, 0, 0, 0);
PXA_OST_DelayMilliSeconds(40);
PXA_LCDSuspendController(lcd->lcd_regs, 0);
lcd->panel->set_power_mode(lcd->panel, 0);
}
void ActiveFlip(active_lcd_t *lcd, UINT32 frame_phy_addr)
{
lcd->dma_descs[0].FSADR = FSADR_SRCADDR(frame_phy_addr);
PXA_LCDActiveFlip(lcd->lcd_regs, &lcd->dma_descs[0]);
}
PXA_STATUS_T ActiveOverlay1Enable(active_lcd_t *lcd, overlay_t *overlay, UINT32 phy_addrs)
{
PXA_LCDInitDMADescriptor(&lcd->dma_descs[1], lcd->dma_descs[1].FDADR, phy_addrs, 0);
return PXA_LCDActiveOverlay1Enable(lcd->lcd_regs, overlay, &lcd->dma_descs[1]);
}
PXA_STATUS_T ActiveOverlay1DynChange(active_lcd_t *lcd, overlay_t *overlay, UINT32 phy_addrs, UINT32 change_flag)
{
return PXA_LCDActiveOverlay1DynChange(lcd->lcd_regs, overlay, &lcd->dma_descs[1], phy_addrs, change_flag);
}
void ActiveOverlay1Disable(active_lcd_t *lcd)
{
PXA_LCDActiveOverlay1Disable(lcd->lcd_regs);
}
PXA_STATUS_T ActiveOverlay2Enable(active_lcd_t *lcd, overlay_t *overlay, UINT32 phy_addrs[3])
{
UINT i;
for (i = 0; i < 3; i++)
PXA_LCDInitDMADescriptor(&lcd->dma_descs[2 + i], lcd->dma_descs[2 + i].FDADR, phy_addrs[i], 0);
return PXA_LCDActiveOverlay2Enable(lcd->lcd_regs, overlay, &lcd->dma_descs[2]);
}
PXA_STATUS_T ActiveOverlay2DynChange(active_lcd_t *lcd, overlay_t *overlay, UINT32 phy_addrs[3], UINT32 change_flag)
{
return PXA_LCDActiveOverlay2DynChange(lcd->lcd_regs, overlay, &lcd->dma_descs[2], phy_addrs, change_flag);
}
void ActiveOverlay2Disable(active_lcd_t *lcd)
{
PXA_LCDActiveOverlay2Disable(lcd->lcd_regs);
}
void ActiveCursorSetShape( active_lcd_t *lcd ,UINT8 *mask, UINT8 *palette, int xHot, int yHot, int cX, int cY )
{
// NKDbgPrintfW( TEXT("ActiveCursorSetShape mask=%x,x=%d,y=%d\r\n"),mask,lcd->cursor.x,lcd->cursor.y);
if( cX == CURSOR_SIZE_32 && cY == CURSOR_SIZE_32 ) {
lcd->cursor.mode= 0;
lcd->dma_descs[5].LDCMD = LDCMD_LEN(CURSOR_BUF_SIZE/4);
}
else if( cX == CURSOR_SIZE_64 && cY == CURSOR_SIZE_64 ) {
lcd->cursor.mode =0x3;
lcd->dma_descs[5].LDCMD = LDCMD_LEN(CURSOR_BUF_SIZE);
}
else return;//cX=cY=0,Mask!=NULL, means CursorOff
lcd->cursor.xHot = xHot;
lcd->cursor.yHot = yHot;
lcd->cursor.cX = cX;
lcd->cursor.cY = cY;
if( mask != NULL )
{
memcpy(lcd->cursor.cursor_buf,mask,cX*cY/4);
if( lcd->cursor.status== CursorOff )
{
lcd->cursor.status = CursorBusy;
PXA_LCDActiveCursorOn(lcd->lcd_regs, &lcd->dma_descs[0],TRUE, lcd->cursor.x, lcd->cursor.y, lcd->cursor.mode);
lcd->cursor.status = CursorOn;
}
} else if( lcd->cursor.status==CursorOn )
{
lcd->cursor.status = CursorBusy;
PXA_LCDActiveCursorOn(lcd->lcd_regs, &lcd->dma_descs[0],FALSE , 0, 0, lcd->cursor.mode);
lcd->cursor.status = CursorOff;
}
}
void ActiveCursorOn( active_lcd_t *lcd, BOOL on_off )
{
// NKDbgPrintfW( TEXT("ActiveCursorOn %x\r\n"),on_off);
if( on_off )
{
if( lcd->cursor.status== CursorOff )
{
lcd->cursor.status = CursorBusy;
PXA_LCDActiveCursorOn(lcd->lcd_regs, &lcd->dma_descs[0],TRUE,lcd->cursor.x, lcd->cursor.y, lcd->cursor.mode);
lcd->cursor.status = CursorOn;
}
} else if( lcd->cursor.status==CursorOn )
{
lcd->cursor.status = CursorBusy;
PXA_LCDActiveCursorOn(lcd->lcd_regs, &lcd->dma_descs[0],FALSE , 0, 0, lcd->cursor.mode);
lcd->cursor.status = CursorOff;
}
}
void ActiveCursorMove( active_lcd_t *lcd, int x, int y )
{
// NKDbgPrintfW( TEXT("%d,%d "),x,y);
if( x>=0 && x<(int)(lcd->panel->config.width) ) lcd->cursor.x = x;
if( y>=0 && y<(int)(lcd->panel->config.height) ) lcd->cursor.y = y;
if(lcd->cursor.status == CursorOn ) PXA_LCDActiveCursorMove( lcd->lcd_regs, &lcd->dma_descs[0],lcd->cursor.x, lcd->cursor.y, lcd->cursor.mode);
}
lcd_t *ActiveCreate(active_panel_t* panel)
{
PHYSICAL_ADDRESS phy_addr;
DMA_ADAPTER_OBJECT adapter;
UINT32 descs_phy;
UINT i;
active_lcd_t *lcd = (active_lcd_t*)malloc(sizeof(active_lcd_t));
if (!lcd)
return 0;
lcd->lcd_regs = (lcd_registers_t*)PXA_CTX_GetRegAddr(PXA_PERIPHERAL_REGIDX_LCD);
lcd->dma_descs = (lcd_dma_descriptor_t*)HalAllocateCommonBuffer(&adapter, sizeof(lcd_dma_descriptor_t) * LCD_DMA_CH_MAX + CURSOR_BUF_SIZE + PALETTE_BUF_SIZE, &phy_addr, FALSE);
descs_phy = (UINT32)phy_addr.LowPart;
for (i = 0; i < LCD_DMA_CH_MAX; i++)
PXA_LCDInitDMADescriptor(&lcd->dma_descs[i], descs_phy + i * sizeof(lcd_dma_descriptor_t), 0, 0);
lcd->dma_descs[7].FIDR = lcd->dma_descs[7].FDADR; //save it in FIDR.
lcd->dma_descs[7].FDADR = lcd->dma_descs[5].FDADR;
lcd->dma_descs[5].FSADR = descs_phy + sizeof(lcd_dma_descriptor_t) * LCD_DMA_CH_MAX;
lcd->dma_descs[7].FSADR = descs_phy + sizeof(lcd_dma_descriptor_t) * LCD_DMA_CH_MAX + CURSOR_BUF_SIZE;
lcd->dma_descs[5].LDCMD = LDCMD_LEN(CURSOR_BUF_SIZE/4); //buffer is 64x64 but cursor is 32x32
lcd->dma_descs[7].LDCMD = LDCMD_LEN(PALETTE_BUF_SIZE)|LDCMD_PAL;
lcd->cursor.cursor_buf = (UINT8 *)lcd->dma_descs + sizeof(lcd_dma_descriptor_t) * LCD_DMA_CH_MAX;
lcd->cursor.palette_buf = (UINT8 *)lcd->dma_descs + sizeof(lcd_dma_descriptor_t) * LCD_DMA_CH_MAX + CURSOR_BUF_SIZE;
for( i=0; i<4; i++ ) lcd->cursor.palette_buf[i]=0;
for( i=4; i<7; i++ ) lcd->cursor.palette_buf[i]=0xff;
lcd->cursor.palette_buf[7]=0;
for( i=0; i<CURSOR_BUF_SIZE; i++ ) lcd->cursor.cursor_buf[i]=0xaa; //set all bits of cursor as transparent.
lcd->cursor.x = 0;
lcd->cursor.y = 0;
lcd->cursor.status = CursorOff;
lcd->cursor.xHot = 0;
lcd->cursor.yHot = 0;
lcd->cursor.cX = CURSOR_SIZE_32;
lcd->cursor.cY = CURSOR_SIZE_32;
lcd->cursor.mode =0; //32x32 2bpp 2color.
(void*)lcd->base.init = (void*)ActiveInit;
(void*)lcd->base.resume = (void*)ActiveResume;
(void*)lcd->base.suspend = (void*)ActiveSuspend;
(void*)lcd->base.flip = (void*)ActiveFlip;
(void*)lcd->base.overlay1_enable = (void*)ActiveOverlay1Enable;
(void*)lcd->base.overlay1_disable = (void*)ActiveOverlay1Disable;
(void*)lcd->base.overlay1_dyn_change = (void*)ActiveOverlay1DynChange;
(void*)lcd->base.overlay2_enable = (void*)ActiveOverlay2Enable;
(void*)lcd->base.overlay2_disable = (void*)ActiveOverlay2Disable;
(void*)lcd->base.overlay2_dyn_change = (void*)ActiveOverlay2DynChange;
(void*)lcd->base.cursor_set_shape = (void*)ActiveCursorSetShape;
(void*)lcd->base.cursor_on = (void*)ActiveCursorOn;
(void*)lcd->base.cursor_move = (void*)ActiveCursorMove;
lcd->panel = panel;
return (lcd_t*)lcd;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -