187313834SIngo Weinhold/*****************************************************************************\
287313834SIngo Weinhold * Tseng Labs ET6000, ET6100 and ET6300 graphics driver for BeOS 5.
387313834SIngo Weinhold * Copyright (c) 2003-2004, Evgeniy Vladimirovich Bobkov.
487313834SIngo Weinhold\*****************************************************************************/
587313834SIngo Weinhold
687313834SIngo Weinhold#include "GlobalData.h"
787313834SIngo Weinhold#include "generic.h"
887313834SIngo Weinhold#include <sys/ioctl.h>
987313834SIngo Weinhold
1087313834SIngo Weinhold
1187313834SIngo Weinhold/*****************************************************************************/
1287313834SIngo Weinhold/*
1387313834SIngo Weinhold * The code to actually configure the display.
1487313834SIngo Weinhold */
1587313834SIngo Weinholdstatic status_t doSetDisplayMode(display_mode *dm) {
1687313834SIngo WeinholdET6000DisplayMode mode;
1787313834SIngo Weinhold
1887313834SIngo Weinhold    mode.magic = ET6000_PRIVATE_DATA_MAGIC;
1987313834SIngo Weinhold    mode.mode = *dm;
2087313834SIngo Weinhold    mode.pciConfigSpace = si->pciConfigSpace;
2187313834SIngo Weinhold
2287313834SIngo Weinhold    return ioctl(fd, ET6000_SET_DISPLAY_MODE, &mode, sizeof(mode));
2387313834SIngo Weinhold}
2487313834SIngo Weinhold/*****************************************************************************/
2587313834SIngo Weinhold/*
2687313834SIngo Weinhold * The exported mode setting routine. First validate the mode,
2787313834SIngo Weinhold * then call our private routine to hammer the registers.
2887313834SIngo Weinhold */
2987313834SIngo Weinholdstatus_t SET_DISPLAY_MODE(display_mode *mode_to_set) {
3087313834SIngo Weinholddisplay_mode bounds, target;
3187313834SIngo Weinholdstatus_t result;
3287313834SIngo Weinholduint8 bpp;
3387313834SIngo Weinhold
3487313834SIngo Weinhold    /* ask for the specific mode */
3587313834SIngo Weinhold    target = bounds = *mode_to_set;
3687313834SIngo Weinhold    if (PROPOSE_DISPLAY_MODE(&target, &bounds, &bounds) != B_OK) /* ==B_ERROR???/// */
3787313834SIngo Weinhold	return B_ERROR;
3887313834SIngo Weinhold
3987313834SIngo Weinhold    result = doSetDisplayMode(&target);
4087313834SIngo Weinhold
4187313834SIngo Weinhold    if (result == B_OK) {
4287313834SIngo Weinhold        switch (target.space) {
4387313834SIngo Weinhold            case B_RGB24_LITTLE:
4487313834SIngo Weinhold            case B_RGB24_BIG:
4587313834SIngo Weinhold                bpp = 3;
4687313834SIngo Weinhold                break;
4787313834SIngo Weinhold            case B_RGB16_LITTLE:
4887313834SIngo Weinhold            case B_RGB16_BIG:
4987313834SIngo Weinhold            case B_RGB15_LITTLE:
5087313834SIngo Weinhold            case B_RGB15_BIG:
5187313834SIngo Weinhold                bpp = 2;
5287313834SIngo Weinhold                break;
53450c95c5SFrançois Revol			default:
54450c95c5SFrançois Revol				return B_BAD_VALUE;
5587313834SIngo Weinhold        }
5687313834SIngo Weinhold        si->fbc.bytes_per_row = target.virtual_width * bpp;
5787313834SIngo Weinhold        si->dm = target;
5887313834SIngo Weinhold        si->bytesPerPixel = bpp;
5987313834SIngo Weinhold        et6000aclInit(bpp);
6087313834SIngo Weinhold    }
6187313834SIngo Weinhold
6287313834SIngo Weinhold    return result;
6387313834SIngo Weinhold}
6487313834SIngo Weinhold/*****************************************************************************/
65