Copyright clean-up (part 1):
[AROS.git] / arch / arm-native / ceboot / hardware.c
blobf36b12ad0d95324f399be0dba9a7ba52fc9d220e
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <hardware/vbe.h>
7 #include <runtime.h>
9 #include <stdio.h>
10 #include <windows.h>
12 #include "bootstrap.h"
13 #include "winapi.h"
15 #define D(x) x
17 /* FIXME: Masks/shifts are preliminary and not tested */
18 static const char ModeTable[2][8] =
20 {5, 0, 6, 5, 5, 11, 0, 0},
21 {5, 0, 5, 5, 5, 10, 0, 0}
24 static int SetFormat(struct vbe_mode *info, unsigned char mode)
26 if ((mode > 0) && (mode < FORMAT_OTHER))
28 mode--;
30 memcpy(&info->red_mask_size, ModeTable[mode], 8);
31 memcpy(&info->linear_red_mask_size, ModeTable[mode], 8);
33 return 0;
35 else
37 DisplayError("Unknown display format %d\n"
38 "Screen size %d x %d, BPP %d, BytesPerLine %d",
39 mode, info->x_resolution, info->y_resolution, info->bits_per_pixel, info->bytes_per_scanline);
41 return -1;
45 int GetFBInfo(struct vbe_mode *info)
47 HDC hdc;
48 int ret;
49 RawFrameBufferInfo fb;
50 GXDeviceInfo dev;
52 D(fprintf(stderr, "[Video] Getting framebuffer information...\n"));
54 hdc = GetDC(NULL);
55 ret = ExtEscape(hdc, GETRAWFRAMEBUFFER, 0, NULL, sizeof(fb), (char *)&fb);
56 if (ret > 0)
58 ReleaseDC(NULL, hdc);
60 D(fprintf(stderr, "[Video] GETRAWFRAMEBUFFER worked, addr %p, size %d x %d\n",
61 fb.pFramePointer, fb.cxPixels, fb.cyPixels));
62 D(fprintf(stderr, "[Video] Format %d, BPP %d, BytesPerPixel %d, BytesPerLine %d\n",
63 fb.wFormat, fb.wBPP, fb.cxStride, fb.cyStride));
65 info->bytes_per_scanline = fb.cyStride;
66 info->x_resolution = fb.cxPixels;
67 info->y_resolution = fb.cyPixels;
68 info->bits_per_pixel = fb.wBPP;
69 info->phys_base = (unsigned int)fb.pFramePointer; /* FIXME: Convert to physical! */
70 info->linear_bytes_per_scanline = fb.cyStride;
72 return SetFormat(info, fb.wFormat);
76 * HaRET also tries GAPI at this point. However:
77 * 1. Some documentation says that GAPI is deprecated
78 * 2. I don't want to bother with runtime linking, current code works quite fine.
81 dev.Version = 100;
82 ret = ExtEscape(hdc, GETGXINFO, 0, NULL, sizeof(dev), (char *)&dev);
83 ReleaseDC(NULL, hdc);
84 if (ret > 0)
86 D(fprintf(stderr, "[Video] GETGXINFO worked, addr %p, size %ld x %ld\n",
87 dev.pvFrameBuffer, dev.cxWidth, dev.cyHeight));
88 D(fprintf(stderr, "[Video] Format %ld, BPP %ld, BytesPerLine %ld\n",
89 dev.ffFormat, dev.cBPP, dev.cbStride));
91 info->bytes_per_scanline = dev.cbStride;
92 info->x_resolution = dev.cxWidth;
93 info->y_resolution = dev.cyHeight;
94 info->bits_per_pixel = dev.cBPP;
95 info->phys_base = (unsigned int)dev.pvFrameBuffer; /* FIXME: Convert to physical! */
96 info->linear_bytes_per_scanline = dev.cbStride;
98 return SetFormat(info, dev.ffFormat);
101 DisplayError("Failed to get framebuffer information");
102 return -1;