Made bitmap view and path AppMessage targets. Picture files can now be
[AROS.git] / arch / arm-native / ceboot / hardware.c
blob71dc6d5a539d08b1d6e1e197a8c40a9e24ea7858
1 #include <hardware/vbe.h>
2 #include <runtime.h>
4 #include <stdio.h>
5 #include <windows.h>
7 #include "bootstrap.h"
8 #include "winapi.h"
10 #define D(x) x
12 /* FIXME: Masks/shifts are preliminary and not tested */
13 static const char ModeTable[2][8] =
15 {5, 0, 6, 5, 5, 11, 0, 0},
16 {5, 0, 5, 5, 5, 10, 0, 0}
19 static int SetFormat(struct vbe_mode *info, unsigned char mode)
21 if ((mode > 0) && (mode < FORMAT_OTHER))
23 mode--;
25 memcpy(&info->red_mask_size, ModeTable[mode], 8);
26 memcpy(&info->linear_red_mask_size, ModeTable[mode], 8);
28 return 0;
30 else
32 DisplayError("Unknown display format %d\n"
33 "Screen size %d x %d, BPP %d, BytesPerLine %d",
34 mode, info->x_resolution, info->y_resolution, info->bits_per_pixel, info->bytes_per_scanline);
36 return -1;
40 int GetFBInfo(struct vbe_mode *info)
42 HDC hdc;
43 int ret;
44 RawFrameBufferInfo fb;
45 GXDeviceInfo dev;
47 D(fprintf(stderr, "[Video] Getting framebuffer information...\n"));
49 hdc = GetDC(NULL);
50 ret = ExtEscape(hdc, GETRAWFRAMEBUFFER, 0, NULL, sizeof(fb), (char *)&fb);
51 if (ret > 0)
53 ReleaseDC(NULL, hdc);
55 D(fprintf(stderr, "[Video] GETRAWFRAMEBUFFER worked, addr %p, size %d x %d\n",
56 fb.pFramePointer, fb.cxPixels, fb.cyPixels));
57 D(fprintf(stderr, "[Video] Format %d, BPP %d, BytesPerPixel %d, BytesPerLine %d\n",
58 fb.wFormat, fb.wBPP, fb.cxStride, fb.cyStride));
60 info->bytes_per_scanline = fb.cyStride;
61 info->x_resolution = fb.cxPixels;
62 info->y_resolution = fb.cyPixels;
63 info->bits_per_pixel = fb.wBPP;
64 info->phys_base = (unsigned int)fb.pFramePointer; /* FIXME: Convert to physical! */
65 info->linear_bytes_per_scanline = fb.cyStride;
67 return SetFormat(info, fb.wFormat);
71 * HaRET also tries GAPI at this point. However:
72 * 1. Some documentation says that GAPI is deprecated
73 * 2. I don't want to bother with runtime linking, current code works quite fine.
76 dev.Version = 100;
77 ret = ExtEscape(hdc, GETGXINFO, 0, NULL, sizeof(dev), (char *)&dev);
78 ReleaseDC(NULL, hdc);
79 if (ret > 0)
81 D(fprintf(stderr, "[Video] GETGXINFO worked, addr %p, size %ld x %ld\n",
82 dev.pvFrameBuffer, dev.cxWidth, dev.cyHeight));
83 D(fprintf(stderr, "[Video] Format %ld, BPP %ld, BytesPerLine %ld\n",
84 dev.ffFormat, dev.cBPP, dev.cbStride));
86 info->bytes_per_scanline = dev.cbStride;
87 info->x_resolution = dev.cxWidth;
88 info->y_resolution = dev.cyHeight;
89 info->bits_per_pixel = dev.cBPP;
90 info->phys_base = (unsigned int)dev.pvFrameBuffer; /* FIXME: Convert to physical! */
91 info->linear_bytes_per_scanline = dev.cbStride;
93 return SetFormat(info, dev.ffFormat);
96 DisplayError("Failed to get framebuffer information");
97 return -1;