BTRFS: Implement BTree::Path and change _Find.
[haiku.git] / src / add-ons / accelerants / et6x00 / SetDisplayMode.c
blob4f426c8c9849406767f622ae6e9c2f83d3c0df57
1 /*****************************************************************************\
2 * Tseng Labs ET6000, ET6100 and ET6300 graphics driver for BeOS 5.
3 * Copyright (c) 2003-2004, Evgeniy Vladimirovich Bobkov.
4 \*****************************************************************************/
6 #include "GlobalData.h"
7 #include "generic.h"
8 #include <sys/ioctl.h>
11 /*****************************************************************************/
13 * The code to actually configure the display.
15 static status_t doSetDisplayMode(display_mode *dm) {
16 ET6000DisplayMode mode;
18 mode.magic = ET6000_PRIVATE_DATA_MAGIC;
19 mode.mode = *dm;
20 mode.pciConfigSpace = si->pciConfigSpace;
22 return ioctl(fd, ET6000_SET_DISPLAY_MODE, &mode, sizeof(mode));
24 /*****************************************************************************/
26 * The exported mode setting routine. First validate the mode,
27 * then call our private routine to hammer the registers.
29 status_t SET_DISPLAY_MODE(display_mode *mode_to_set) {
30 display_mode bounds, target;
31 status_t result;
32 uint8 bpp;
34 /* ask for the specific mode */
35 target = bounds = *mode_to_set;
36 if (PROPOSE_DISPLAY_MODE(&target, &bounds, &bounds) != B_OK) /* ==B_ERROR???/// */
37 return B_ERROR;
39 result = doSetDisplayMode(&target);
41 if (result == B_OK) {
42 switch (target.space) {
43 case B_RGB24_LITTLE:
44 case B_RGB24_BIG:
45 bpp = 3;
46 break;
47 case B_RGB16_LITTLE:
48 case B_RGB16_BIG:
49 case B_RGB15_LITTLE:
50 case B_RGB15_BIG:
51 bpp = 2;
52 break;
53 default:
54 return B_BAD_VALUE;
56 si->fbc.bytes_per_row = target.virtual_width * bpp;
57 si->dm = target;
58 si->bytesPerPixel = bpp;
59 et6000aclInit(bpp);
62 return result;
64 /*****************************************************************************/