2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
6 #include <hardware/vbe.h>
12 #include "bootstrap.h"
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
))
30 memcpy(&info
->red_mask_size
, ModeTable
[mode
], 8);
31 memcpy(&info
->linear_red_mask_size
, ModeTable
[mode
], 8);
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
);
45 int GetFBInfo(struct vbe_mode
*info
)
49 RawFrameBufferInfo fb
;
52 D(fprintf(stderr
, "[Video] Getting framebuffer information...\n"));
55 ret
= ExtEscape(hdc
, GETRAWFRAMEBUFFER
, 0, NULL
, sizeof(fb
), (char *)&fb
);
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.
82 ret
= ExtEscape(hdc
, GETGXINFO
, 0, NULL
, sizeof(dev
), (char *)&dev
);
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");