Community
cancel
Showing results for 
Search instead for 
Did you mean: 
DScho4
Beginner
1,380 Views

Problem with setting rotation modes using IEGD driver on Windows 7

Hi, I am able to use the gui utility to set the rotated modes on my device but am not able to programtically change the rotation following the example in the IEGD SDK.

The problem I am seeing is that the calls to ChangeDisplay Settings are failing with BADMODE ( -2 ) return code as a result of the mode not being valid when swapping width and height values. Call sequence looks like this with error checking removed:

hdc = GetDC( Null );

rot_flip.port_number = (((

rot_flip.flip = 0;

rot_flip.rotation = 90;

rot_flip.rotation = 0;

ExtEscape(hdc, INTEL_ESCAPE_SET_ROTATION_FLIP , input_size, rot_flip, 0, null);uint)hdc >> (PRIMARY * 4)) & 0x0f);

ReleaseDC(hdc);

int mode_num = 0;

// loop to refresh all available modes for this rotation setting

while(true)

{

if (EnumDisplaySettings(null, mode_num++, dm_enum) == 0)

{

break<font co...

0 Kudos
4 Replies
DScho4
Beginner
89 Views

I was able to figure it out ... needed to get an internal dc using ExtEscape and from there derive the port number. Once I had the port number right eveything else worked.

No need to respond.

FMcNu1
Valued Contributor I
89 Views

Hi Sholten:

Welcome to the Intel® Embedded Community.

Glad you figured it out. And thanks for sharing the solution with the community!

Thanks

Felix

Kirk_B_Intel
Employee
89 Views

We use the following example code to show people how to rotate. It is a bit old so the api calls may need to be adjusted a bit to current calling convention but the logic is correct:

# include # include

// ............................................................................# define INTEL_ESCAPE_ROTATION_FLIP 0x2000E

# define IEGD_ANALOG_PORT 5

typedef struct _iegd_esc_set_rotation_flip { unsigned long port_number; unsigned long rotation; /* rotation in degrees (0, 90, 180, 270) */ unsigned long flip; /* horizontal flip, zero or non-zero */} iegd_esc_set_rotation_flip_t;

// ............................................................................

void main(int argc, char *argv[]){ if (argc != 3) { printf("Usage : \%s <0|90|180|270> <0|1>\n", argv[0]); return; }

// ........................................................................ DEVMODE devModeCur; if (! EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devModeCur)) { printf("Error ! EnumDisplaySettings() failed with error=\%lu\n", GetLastError()); }

printf("Current Mode : mailto:\%dx\%dx\%d@\%d\n mailto:\%dx\%dx\%d@\%d\n" rel="nofollow">\%dx\%dx\%d@\%d\n", devModeCur.dmPelsWidth, devModeCur.dmPelsHeight, devModeCur.dmBitsPerPel, devModeCur.dmDisplayFrequency);

// ........................................................................ DEVMODE devModeRot; ZeroMemory(&devModeRot, sizeof(DEVMODE));

devModeRot.dmSize = sizeof(DEVMODE); devModeRot.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY; devModeRot.dmBitsPerPel = devModeCur.dmBitsPerPel;

devModeRot.dmDisplayFrequency = devModeCur.dmDisplayFrequency;

// ........................................................................ iegd_esc_rotation_flip_t rotFlip;

rotFlip.port_number = IEGD_ANALOG_PORT; rotFlip.rotation = atoi(argv[1]); rotFlip.flip = atoi(argv[2]);

switch (rotFlip.rotation) { case 0 : case 180 : { if (devModeCur.dmPelsWidth < devModeCur.dmPelsHeight) { // We are in rotated mode devModeRot.dmPelsWidth = devModeCur.dmPelsHeight; devModeRot.dmPelsHeight = devModeCur.dmPelsWidth; } else { devModeRot.dmPelsWidth = devModeCur.dmPelsWidth; devModeRot.dmPelsHeight = devModeCur.dmPelsHeight; }

break; }

case 90 : case 270 : { if (devModeCur.dmPelsWidth < devModeCur.dmPelsHeight) { // We are already in rotated mode devModeRot.dmPelsWidth = devModeCur.dmPelsWidth; devModeRot.dmPelsHeight = devModeCur.dmPelsHeight; } else { devModeRot.dmPelsWidth = devModeCur.dmPelsHeight; devModeRot.dmPelsHeight = devModeCur.dmPelsWidth; }

break; } default : printf("Error ! Invalid paramter = \%d\n", rotFlip.rotation); return; }

if (devModeRot.dmPelsWidth < 640) { printf("Error ! width(\%d) < 640\n", devModeRot.dmPelsWidth); return; }

printf("Rotation=\%d, Flip=\%d\n", rotFlip.rotation, rotFlip.flip);

// ........................................................................ HDC hDC = GetDC(NULL); if (hDC == NULL) { printf("Error ! CreateDC() failed with error=\%d\n", GetLastError()); return; }

int retCode = ExtEscape(hDC, INTEL_ESCAPE_SET_ROTATION_FLIP, sizeof(iegd_esc_rotation_flip_t), (char *)&rotFlip, 0, NULL);

if (retCode <= 0)<br/> { printf("Error ! ExtEscape(INTEL_ESCAPE_SET_ROTATION_FLIP) returned \%d\n", retCode); return; }

ReleaseDC(NULL, hDC);

// ........................................................................ DWORD modeNum = 0;

while (1) { DEVMODE devModeEnum;

if (! EnumDisplaySettings(NULL, modeNum, &devModeEnum)) break;

modeNum++;

Kirk_B_Intel
Employee
89 Views

}

// ........................................................................

long status;

if (devModeCur.dmPelsWidth == devModeRot.dmPelsWidth) { if (devModeRot.dmBitsPerPel == 16) devModeRot.dmBitsPerPel = 32; else if (devModeRot.dmBitsPerPel == 32) devModeRot.dmBitsPerPel = 16;

status = ChangeDisplaySettings(&devModeRot, 0);

if (devModeRot.dmBitsPerPel == 16) devModeRot.dmBitsPerPel = 32; else if (devModeRot.dmBitsPerPel == 32) devModeRot.dmBitsPerPel = 16; }

printf("New Mode : mailto:\%dx\%dx\%d@\%d\n mailto:\%dx\%dx\%d@\%d\n" rel="nofollow">\%dx\%dx\%d@\%d\n", devModeRot.dmPelsWidth, devModeRot.dmPelsHeight, devModeRot.dmBitsPerPel, devModeRot.dmDisplayFrequency);

status = ChangeDisplaySettings(&devModeRot, CDS_RESET | CDS_UPDATEREGISTRY | CDS_GLOBAL); if (status != DISP_CHANGE_SUCCESSFUL) { printf("Error ! ChangeDisplaySettings() failed with status=\%d\n", status); }

modeNum = 0;

while (1) { DEVMODE devModeEnum;

if (! EnumDisplaySettings(NULL, modeNum, &devModeEnum)) break;

modeNum++; }}

Reply