0
|
1 |
// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// e32test\video\t_vidmode.cpp
|
|
15 |
// Tests the video driver kernel extension
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
#include <hal.h>
|
|
20 |
#include <e32svr.h>
|
|
21 |
#include <videodriver.h>
|
|
22 |
|
|
23 |
GLDEF_C TInt E32Main()
|
|
24 |
{
|
|
25 |
TBuf<256> cmd;
|
|
26 |
User::CommandLine(cmd);
|
|
27 |
TLex lex(cmd);
|
|
28 |
TInt mode;
|
|
29 |
lex.Val(mode);
|
|
30 |
|
|
31 |
TInt screens;
|
|
32 |
HAL::Get(HAL::EDisplayNumberOfScreens, screens);
|
|
33 |
for(TInt i=0;i<screens;i++)
|
|
34 |
{
|
|
35 |
TInt nmodes;
|
|
36 |
HAL::Get(i, HAL::EDisplayNumModes, nmodes);
|
|
37 |
if (mode<0 || mode>=nmodes)
|
|
38 |
return KErrArgument;
|
|
39 |
|
|
40 |
HAL::Set(i, HAL::EDisplayMode, mode);
|
|
41 |
|
|
42 |
TInt xres, yres, bpp, addr;
|
|
43 |
bpp=mode;
|
|
44 |
HAL::Get(i, HAL::EDisplayXPixels, xres);
|
|
45 |
HAL::Get(i, HAL::EDisplayYPixels, yres);
|
|
46 |
HAL::Get(i, HAL::EDisplayBitsPerPixel, bpp);
|
|
47 |
HAL::Get(i, HAL::EDisplayMemoryAddress, addr);
|
|
48 |
|
|
49 |
TInt bpl=mode;
|
|
50 |
HAL::Get(i, HAL::EDisplayOffsetBetweenLines, bpl);
|
|
51 |
|
|
52 |
TInt ofp=mode;
|
|
53 |
HAL::Get(i, HAL::EDisplayOffsetToFirstPixel, ofp);
|
|
54 |
|
|
55 |
RDebug::Print(_L("xres=%d yres=%d bpp=%d"), xres, yres, bpp);
|
|
56 |
RDebug::Print(_L("addr=%08x bpl=%d ofp=%d"), addr, bpl, ofp);
|
|
57 |
|
|
58 |
TInt xb, yb;
|
|
59 |
for (yb=0; yb<yres/16; ++yb)
|
|
60 |
{
|
|
61 |
for (xb=0; xb<xres/16; ++xb)
|
|
62 |
{
|
|
63 |
// TUint c=(5*(xb+yb))&0xff;
|
|
64 |
TUint c=(xb*xb+yb*yb)&0xff;
|
|
65 |
TUint r=c&7;
|
|
66 |
TUint g=(c>>3)&7;
|
|
67 |
TUint b=(c>>6);
|
|
68 |
TUint c16=(b<<14)|(g<<8)|(r<<2);
|
|
69 |
c16 |= (c16<<16);
|
|
70 |
TUint c8=c|(c<<8);
|
|
71 |
c8 |= (c8<<16);
|
|
72 |
TUint c32=(b<<22)|(g<<13)|(r<<5);
|
|
73 |
TInt baddr=addr+ofp+yb*16*bpl+xb*16*bpp/8;
|
|
74 |
TInt l;
|
|
75 |
for (l=0; l<16; ++l, baddr+=bpl)
|
|
76 |
{
|
|
77 |
TUint32* p=(TUint32*)baddr;
|
|
78 |
if (bpp==8)
|
|
79 |
*p++=c8, *p++=c8, *p++=c8, *p++=c8;
|
|
80 |
else if (bpp==16)
|
|
81 |
*p++=c16, *p++=c16, *p++=c16, *p++=c16,
|
|
82 |
*p++=c16, *p++=c16, *p++=c16, *p++=c16;
|
|
83 |
// c16+=((l&3==3))?0x20:0x00;
|
|
84 |
else
|
|
85 |
*p++=c32+0x0, *p++=c32+0x1, *p++=c32+0x2, *p++=c32+0x3,
|
|
86 |
*p++=c32+0x4, *p++=c32+0x5, *p++=c32+0x6, *p++=c32+0x7,
|
|
87 |
*p++=c32+0x8, *p++=c32+0x9, *p++=c32+0xa, *p++=c32+0xb,
|
|
88 |
*p++=c32+0xc, *p++=c32+0xd, *p++=c32+0xe, *p++=c32+0xf,
|
|
89 |
c32+=0x100;
|
|
90 |
}
|
|
91 |
}
|
|
92 |
}
|
|
93 |
}
|
|
94 |
|
|
95 |
return KErrNone;
|
|
96 |
}
|