baseport/syborg/fb/syborg_fb.cpp
changeset 46 b6935a90ca64
parent 16 73107a0bc259
equal deleted inserted replaced
45:01c1ffcc4fca 46:b6935a90ca64
     8 *
     8 *
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
       
    13 *
       
    14 * Accenture Ltd - Syborg framebuffer improvements, now auto determines frame size from board model, performance and memory improvements
    13 *
    15 *
    14 * Description: Minimalistic frame buffer driver
    16 * Description: Minimalistic frame buffer driver
    15 *
    17 *
    16 */
    18 */
    17 
    19 
   112   iPowerUpDfc.Enque();
   114   iPowerUpDfc.Enque();
   113 }
   115 }
   114 
   116 
   115 void DLcdPowerHandler::PowerUpLcd(TBool aSecure)
   117 void DLcdPowerHandler::PowerUpLcd(TBool aSecure)
   116 {
   118 {
   117 #if 1
   119 
   118   WriteReg(iPortAddr, FB_ENABLED, 0);
   120   WriteReg(iPortAddr, FB_ENABLED, 0);
   119   WriteReg(iPortAddr, FB_BASE, aSecure ? iSecurevRamPhys : ivRamPhys);
   121   WriteReg(iPortAddr, FB_BASE, aSecure ? iSecurevRamPhys : ivRamPhys);
   120   WriteReg(iPortAddr, FB_WIDTH, iVideoInfo.iSizeInPixels.iWidth);
   122 
   121   WriteReg(iPortAddr, FB_BLANK, 0);
   123   WriteReg(iPortAddr, FB_BLANK, 0);
   122   WriteReg(iPortAddr, FB_BPP, 32);
   124   WriteReg(iPortAddr, FB_BPP, 32);
   123   WriteReg(iPortAddr, FB_COLOR_ORDER, 0);
   125   WriteReg(iPortAddr, FB_COLOR_ORDER, 0);
   124   WriteReg(iPortAddr, FB_BYTE_ORDER, 0);
   126   WriteReg(iPortAddr, FB_BYTE_ORDER, 0);
   125   WriteReg(iPortAddr, FB_PIXEL_ORDER, 0);
   127   WriteReg(iPortAddr, FB_PIXEL_ORDER, 0);
   126   WriteReg(iPortAddr, FB_INT_MASK, 0);
   128   WriteReg(iPortAddr, FB_INT_MASK, 0);
   127   WriteReg(iPortAddr, FB_ENABLED, 1);
   129   WriteReg(iPortAddr, FB_ENABLED, 1);
   128   WriteReg(iPortAddr, FB_HEIGHT, iVideoInfo.iSizeInPixels.iHeight);
   130 
   129 #endif
   131   // We don't write the Height and Width of the framebuffer, this is controlled by the board model
       
   132 
   130 }
   133 }
   131 
   134 
   132 void DLcdPowerHandler::PowerDownLcd()
   135 void DLcdPowerHandler::PowerDownLcd()
   133 {
   136 {
   134   WriteReg(iPortAddr, FB_BLANK, 1);
   137   WriteReg(iPortAddr, FB_BLANK, 1);
   200 
   203 
   201 	  aInfo.iOffsetToFirstPixel = KConfigOffsetToFirstPixel;
   204 	  aInfo.iOffsetToFirstPixel = KConfigOffsetToFirstPixel;
   202 
   205 
   203 	  aInfo.iIsPalettized       = KConfigIsPalettized;
   206 	  aInfo.iIsPalettized       = KConfigIsPalettized;
   204 
   207 
   205 	  aInfo.iOffsetBetweenLines = KConfigOffsetBetweenLines;
   208 	  aInfo.iOffsetBetweenLines = iVideoInfo.iSizeInPixels.iWidth*4; //Offset depends on width of framebuffer
   206 
   209 
   207 	  aInfo.iBitsPerPixel       = KConfigBitsPerPixel;
   210 	  aInfo.iBitsPerPixel       = KConfigBitsPerPixel;
   208 	}
   211 	}
   209   return KErrNone;
   212   return KErrNone;
   210 }
   213 }
   211 
   214 
   212 TInt DLcdPowerHandler::AllocateFrameBuffer()
   215 TInt DLcdPowerHandler::AllocateFrameBuffer()
   213 {
   216 {
   214 	// Allocate physical RAM for video
   217 // Allocate physical RAM for video
   215 
   218 	
   216 // Added only the comments
   219 	//read width and height of display from board model and allocate size
   217 	TInt vSize = TSyborg::VideoRamSize(); // Maximum display now 854 x 854
   220 	TInt width = ReadReg(iPortAddr, FB_WIDTH);
   218 
   221 	TInt height = ReadReg(iPortAddr, FB_HEIGHT);
       
   222 	
       
   223 	TInt vSize = 4*width*height; //*4 as 32bits per pixel
   219 
   224 
   220 	NKern::ThreadEnterCS();
   225 	NKern::ThreadEnterCS();
   221 	TInt r = Epoc::AllocPhysicalRam(vSize,Syborg::VideoRamPhys);
   226 	TInt r = Epoc::AllocPhysicalRam(vSize,Syborg::VideoRamPhys);
   222 	if (r != KErrNone)
   227 	if (r != KErrNone)
   223 	{
   228 	{
   253 	if(r2 != KErrNone)
   258 	if(r2 != KErrNone)
   254 	  return r2;
   259 	  return r2;
   255 
   260 
   256 	TUint* pV2 = (TUint*)iSecureChunk->LinearAddress();
   261 	TUint* pV2 = (TUint*)iSecureChunk->LinearAddress();
   257 
   262 
   258 	iVideoInfo.iSizeInPixels.iWidth  = KConfigLcdWidth;
   263 	//width and height set by reading board model
   259 	iVideoInfo.iSizeInPixels.iHeight = KConfigLcdHeight;
   264 	iVideoInfo.iSizeInPixels.iWidth  = width;
       
   265 	iVideoInfo.iSizeInPixels.iHeight = height;
       
   266 
       
   267 	//offset between lines depends on width of screen
       
   268 	iVideoInfo.iOffsetBetweenLines = width*4;
       
   269 
   260 	iVideoInfo.iDisplayMode = KConfigLcdDisplayMode;
   270 	iVideoInfo.iDisplayMode = KConfigLcdDisplayMode;
   261 
       
   262 	iVideoInfo.iOffsetToFirstPixel = KConfigOffsetToFirstPixel;
   271 	iVideoInfo.iOffsetToFirstPixel = KConfigOffsetToFirstPixel;
   263 	iVideoInfo.iOffsetBetweenLines = KConfigOffsetBetweenLines;
   272 	
   264 
       
   265 	iVideoInfo.iIsPalettized = KConfigIsPalettized;
   273 	iVideoInfo.iIsPalettized = KConfigIsPalettized;
   266 	iVideoInfo.iBitsPerPixel = KConfigBitsPerPixel;
   274 	iVideoInfo.iBitsPerPixel = KConfigBitsPerPixel;
   267 	iVideoInfo.iSizeInTwips.iWidth = KConfigLcdWidthInTwips;
   275 	iVideoInfo.iSizeInTwips.iWidth = KConfigLcdWidthInTwips;
   268 	iVideoInfo.iSizeInTwips.iHeight = KConfigLcdHeightInTwips;
   276 	iVideoInfo.iSizeInTwips.iHeight = KConfigLcdHeightInTwips;
   269 	iVideoInfo.iIsMono = KConfigIsMono;
   277 	iVideoInfo.iIsMono = KConfigIsMono;
   271 	iVideoInfo.iIsPixelOrderLandscape = KConfigPixelOrderLandscape;
   279 	iVideoInfo.iIsPixelOrderLandscape = KConfigPixelOrderLandscape;
   272 	iVideoInfo.iIsPixelOrderRGB = KConfigPixelOrderRGB;
   280 	iVideoInfo.iIsPixelOrderRGB = KConfigPixelOrderRGB;
   273 
   281 
   274 	iSecureVideoInfo = iVideoInfo;
   282 	iSecureVideoInfo = iVideoInfo;
   275 	iSecureVideoInfo.iVideoAddress = (TInt)pV2;
   283 	iSecureVideoInfo.iVideoAddress = (TInt)pV2;
   276 
       
   277 #if 0
       
   278 	WriteReg(iPortAddr, FB_ENABLED, 0);
       
   279 	WriteReg(IPortAddr, FB_INT_MASK, 0);
       
   280 	WriteReg(iPortAddr, FB_BASE, iSecureDisplay ? iSecurevRamPhys : ivRamPhys);
       
   281 	WriteReg(iPortAddr, FB_WIDTH, iVideoInfo.iSizeInPixels.iWidth);
       
   282 	WriteReg(iPortAddr, FB_HEIGHT, iVideoInfo.iSizeInPixels.iHeight);
       
   283 	WriteReg(iPortAddr, FB_BLANK, 0);
       
   284 	WriteReg(iPortAddr, FB_ENABLED, 1);
       
   285 #endif
       
   286 	
   284 	
   287 	return KErrNone;
   285 	return KErrNone;
   288 }
   286 }
   289 
   287 
   290 
   288 
   430 {
   428 {
   431 	iDfcQ = Kern::DfcQue0();	// use low priority DFC queue for this driver 
   429 	iDfcQ = Kern::DfcQue0();	// use low priority DFC queue for this driver 
   432 
   430 
   433 	iPortAddr = KHwBaseClcd;
   431 	iPortAddr = KHwBaseClcd;
   434 
   432 
   435 	// !@!
       
   436 #if 0	
       
   437 	// Map the video RAM
       
   438 	TInt vSize = TSyborg::VideoRamSize();
       
   439 	ivRamPhys = TSyborg::VideoRamPhys();
       
   440 
       
   441 	TInt r = DPlatChunkHw::New(iChunk,ivRamPhys,vSize,EMapAttrUserRw|EMapAttrBufferedC);
       
   442 	if(r != KErrNone)
       
   443 	  return r;
       
   444 
       
   445 	TUint* pV = (TUint*)iChunk->LinearAddress();
       
   446 
       
   447 	iSecurevRamPhys = ivRamPhys + vSize;
       
   448 	TInt r2 = DPlatChunkHw::New(iSecureChunk,iSecurevRamPhys,vSize,EMapAttrUserRw|EMapAttrBufferedC);
       
   449 	if(r2 != KErrNone)
       
   450 	  return r2;
       
   451 
       
   452 	TUint* pV2 = (TUint*)iSecureChunk->LinearAddress();
       
   453 #endif
       
   454 
       
   455 	iVideoInfo.iSizeInPixels.iWidth  = KConfigLcdWidth;
       
   456 	iVideoInfo.iSizeInPixels.iHeight = KConfigLcdHeight;
       
   457 	iVideoInfo.iDisplayMode = KConfigLcdDisplayMode;
       
   458 
       
   459 	iVideoInfo.iOffsetToFirstPixel = KConfigOffsetToFirstPixel;
       
   460 	iVideoInfo.iOffsetBetweenLines = KConfigOffsetBetweenLines;
       
   461 
       
   462 	iVideoInfo.iIsPalettized = KConfigIsPalettized;
       
   463 	iVideoInfo.iBitsPerPixel = KConfigBitsPerPixel;
       
   464 	iVideoInfo.iSizeInTwips.iWidth = KConfigLcdWidthInTwips;
       
   465 	iVideoInfo.iSizeInTwips.iHeight = KConfigLcdHeightInTwips;
       
   466 	iVideoInfo.iIsMono = KConfigIsMono;
       
   467 	// !@!	iVideoInfo.iVideoAddress = (TInt)pV;
       
   468 	iVideoInfo.iIsPixelOrderLandscape = KConfigPixelOrderLandscape;
       
   469 	iVideoInfo.iIsPixelOrderRGB = KConfigPixelOrderRGB;
       
   470 
       
   471 	iSecureVideoInfo = iVideoInfo;
       
   472 	// !@! iSecureVideoInfo.iVideoAddress = (TInt)pV2;
       
   473 
       
   474 	AllocateFrameBuffer();
   433 	AllocateFrameBuffer();
   475 	TInt r = Kern::AddHalEntry(EHalGroupDisplay,DoHalFunction,this);
   434 	TInt r = Kern::AddHalEntry(EHalGroupDisplay,DoHalFunction,this);
   476 	if(r != KErrNone)
   435 	if(r != KErrNone)
   477 	  return r;
   436 	  return r;
   478 
   437