os/kernelhwsrv/kerneltest/e32test/video/t_vidmode.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/video/t_vidmode.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,96 @@
     1.4 +// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32test\video\t_vidmode.cpp
    1.18 +// Tests the video driver kernel extension
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +#include <hal.h>
    1.23 +#include <e32svr.h>
    1.24 +#include <videodriver.h>
    1.25 +
    1.26 +GLDEF_C TInt E32Main()
    1.27 +	{
    1.28 +	TBuf<256> cmd;
    1.29 +	User::CommandLine(cmd);
    1.30 +	TLex lex(cmd);
    1.31 +	TInt mode;
    1.32 +	lex.Val(mode);
    1.33 +
    1.34 +	TInt screens;
    1.35 +	HAL::Get(HAL::EDisplayNumberOfScreens, screens);
    1.36 +	for(TInt i=0;i<screens;i++)
    1.37 +		{
    1.38 +		TInt nmodes;
    1.39 +		HAL::Get(i, HAL::EDisplayNumModes, nmodes);
    1.40 +		if (mode<0 || mode>=nmodes)
    1.41 +			return KErrArgument;
    1.42 +
    1.43 +		HAL::Set(i, HAL::EDisplayMode, mode);
    1.44 +
    1.45 +		TInt xres, yres, bpp, addr;
    1.46 +		bpp=mode;
    1.47 +		HAL::Get(i, HAL::EDisplayXPixels, xres);
    1.48 +		HAL::Get(i, HAL::EDisplayYPixels, yres);
    1.49 +		HAL::Get(i, HAL::EDisplayBitsPerPixel, bpp);
    1.50 +		HAL::Get(i, HAL::EDisplayMemoryAddress, addr);
    1.51 +
    1.52 +		TInt bpl=mode;
    1.53 +		HAL::Get(i, HAL::EDisplayOffsetBetweenLines, bpl);
    1.54 +
    1.55 +		TInt ofp=mode;
    1.56 +		HAL::Get(i, HAL::EDisplayOffsetToFirstPixel, ofp);
    1.57 +
    1.58 +		RDebug::Print(_L("xres=%d yres=%d bpp=%d"), xres, yres, bpp);
    1.59 +		RDebug::Print(_L("addr=%08x bpl=%d ofp=%d"), addr, bpl, ofp);
    1.60 +
    1.61 +		TInt xb, yb;
    1.62 +		for (yb=0; yb<yres/16; ++yb)
    1.63 +			{
    1.64 +			for (xb=0; xb<xres/16; ++xb)
    1.65 +				{
    1.66 +	//			TUint c=(5*(xb+yb))&0xff;
    1.67 +				TUint c=(xb*xb+yb*yb)&0xff;
    1.68 +				TUint r=c&7;
    1.69 +				TUint g=(c>>3)&7;
    1.70 +				TUint b=(c>>6);
    1.71 +				TUint c16=(b<<14)|(g<<8)|(r<<2);
    1.72 +				c16 |= (c16<<16);
    1.73 +				TUint c8=c|(c<<8);
    1.74 +				c8 |= (c8<<16);
    1.75 +				TUint c32=(b<<22)|(g<<13)|(r<<5);
    1.76 +				TInt baddr=addr+ofp+yb*16*bpl+xb*16*bpp/8;
    1.77 +				TInt l;
    1.78 +				for (l=0; l<16; ++l, baddr+=bpl)
    1.79 +					{
    1.80 +					TUint32* p=(TUint32*)baddr;
    1.81 +					if (bpp==8)
    1.82 +						*p++=c8, *p++=c8, *p++=c8, *p++=c8;
    1.83 +					else if (bpp==16)
    1.84 +						*p++=c16, *p++=c16, *p++=c16, *p++=c16,
    1.85 +						*p++=c16, *p++=c16, *p++=c16, *p++=c16;
    1.86 +	//					c16+=((l&3==3))?0x20:0x00;
    1.87 +					else
    1.88 +						*p++=c32+0x0, *p++=c32+0x1, *p++=c32+0x2, *p++=c32+0x3,
    1.89 +						*p++=c32+0x4, *p++=c32+0x5, *p++=c32+0x6, *p++=c32+0x7,
    1.90 +						*p++=c32+0x8, *p++=c32+0x9, *p++=c32+0xa, *p++=c32+0xb,
    1.91 +						*p++=c32+0xc, *p++=c32+0xd, *p++=c32+0xe, *p++=c32+0xf,
    1.92 +						c32+=0x100;
    1.93 +					}
    1.94 +				}
    1.95 +			}
    1.96 +		}
    1.97 +
    1.98 +	return KErrNone;
    1.99 +	}