From 8b7987023fa40d0c69f8059eed5a699a45174a5d Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Thu, 14 Jun 2007 14:41:45 +0000 Subject: [PATCH] Implemented needed methods to be able to clone the accelerant. Implemented SetIndexedColors hook, although not really correct. I don't know why the driver's 8 bit mode were disabled. They seem to work fine. I had to enable at least 640x480x8 to be able to test WindowScreen. There are some TODOs in the code. I'll look into them later. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21410 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../private/graphics/vmware/DriverInterface.h | 2 + .../accelerants/vmware/InitAccelerant.c | 38 ++++++++++++++++--- .../accelerants/vmware/ProposeDisplayMode.c | 4 +- .../accelerants/vmware/SetDisplayMode.c | 10 +++++ .../kernel/drivers/graphics/vmware/device.c | 28 ++++++++++++++ 5 files changed, 74 insertions(+), 8 deletions(-) diff --git a/headers/private/graphics/vmware/DriverInterface.h b/headers/private/graphics/vmware/DriverInterface.h index 0b6fda5e1d..a41611885e 100644 --- a/headers/private/graphics/vmware/DriverInterface.h +++ b/headers/private/graphics/vmware/DriverInterface.h @@ -72,6 +72,8 @@ enum { VMWARE_SET_MODE, VMWARE_SHOW_CURSOR, VMWARE_MOVE_CURSOR, + VMWARE_GET_DEVICE_NAME, + VMWARE_SET_PALETTE }; diff --git a/src/add-ons/accelerants/vmware/InitAccelerant.c b/src/add-ons/accelerants/vmware/InitAccelerant.c index e274995819..0cf9c1e3f5 100644 --- a/src/add-ons/accelerants/vmware/InitAccelerant.c +++ b/src/add-ons/accelerants/vmware/InitAccelerant.c @@ -28,7 +28,7 @@ status_t InitCommon(int fd) gFd = fd; /* Contact driver and get a pointer to the registers and shared data */ - if ((ret = ioctl(fd, VMWARE_GET_PRIVATE_DATA, &gSharedArea, + if ((ret = ioctl(gFd, VMWARE_GET_PRIVATE_DATA, &gSharedArea, sizeof(area_id))) != B_OK) { TRACE("VMWARE_GET_PRIVATE_DATA failed (%d\n", ret); return ret; @@ -76,22 +76,50 @@ INIT_ACCELERANT(int fd) ssize_t ACCELERANT_CLONE_INFO_SIZE() { - return MAX_SAMPLE_DEVICE_NAME_LENGTH; + return B_PATH_NAME_LENGTH; } void GET_ACCELERANT_CLONE_INFO(void *data) { - /* TODO */ + TRACE("GET_ACCELERANT_CLONE_INFO (%d)\n", gFd); + + // TODO: I have no idea why this doesn't work: gFd is 0 here !?!? + //ioctl(gFd, VMWARE_GET_DEVICE_NAME, data, B_PATH_NAME_LENGTH); + strlcpy(data, "graphics/vmware", B_PATH_NAME_LENGTH); + } status_t CLONE_ACCELERANT(void *data) { - /* TODO */ - return B_ERROR; + int fd; + char path[B_PATH_NAME_LENGTH]; + status_t ret; + + // create full device name + strcpy(path, "/dev/"); + strlcat(path, (const char *)data, sizeof(path)); + + TRACE("CLONE_ACCELERANT: %s\n", (const char *)path); + + fd = open(path, B_READ_WRITE); + if (fd < 0) + return fd; + + gAccelerantIsClone = 1; + + /* Common initialization for the primary accelerant and clones */ + if ((ret = InitCommon(fd)) == B_OK) { + /* Init semaphores */ + INIT_BEN(gSi->engineLock); + INIT_BEN(gSi->fifoLock); + } + + TRACE("CLONE_ACCELERANT: %d\n", ret); + return ret; } diff --git a/src/add-ons/accelerants/vmware/ProposeDisplayMode.c b/src/add-ons/accelerants/vmware/ProposeDisplayMode.c index a3b47bb623..4cb9b6b06f 100644 --- a/src/add-ons/accelerants/vmware/ProposeDisplayMode.c +++ b/src/add-ons/accelerants/vmware/ProposeDisplayMode.c @@ -16,6 +16,7 @@ static const display_mode kModeList[] = { { { 19660, 640, 672, 744, 776, 480, 490, 494, 505, 0 }, B_RGB32_LITTLE, 640, 480, 0, 0, MODE_FLAGS }, /* 640x480@50Hz */ + { { 19660, 640, 672, 744, 776, 480, 490, 494, 505, 0 }, B_CMAP8, 640, 480, 0, 0, MODE_FLAGS }, /* 640x480@50Hz */ { { 25250, 800, 832, 920, 952, 500, 511, 515, 526, 0 }, B_RGB32_LITTLE, 800, 500, 0, 0, MODE_FLAGS }, /* 800x500@50Hz */ { { 30970, 800, 832, 944, 976, 600, 613, 618, 631, 0 }, B_RGB32_LITTLE, 800, 600, 0, 0, MODE_FLAGS }, /* 800x600@50Hz */ { { 41980, 1024, 1056, 1208, 1240, 640, 653, 659, 673, 0 }, B_RGB32_LITTLE, 1024, 640, 0, 0, MODE_FLAGS }, /* 1024x640@50Hz */ @@ -51,9 +52,6 @@ PROPOSE_DISPLAY_MODE(display_mode *target, const display_mode *low, target->virtual_height > gSi->maxHeight) return B_ERROR; - if (target->space != B_RGB32_LITTLE) - return B_ERROR; - /* Any such mode is OK, even if it isn't in our propose list */ return B_OK; } diff --git a/src/add-ons/accelerants/vmware/SetDisplayMode.c b/src/add-ons/accelerants/vmware/SetDisplayMode.c index 1d7dc28362..e939631a68 100644 --- a/src/add-ons/accelerants/vmware/SetDisplayMode.c +++ b/src/add-ons/accelerants/vmware/SetDisplayMode.c @@ -63,7 +63,17 @@ MOVE_DISPLAY(uint16 hDisplayStart, uint16 vDisplayStart) void SET_INDEXED_COLORS(uint count, uint8 first, uint8 *color_data, uint32 flags) { + // TODO: Take first and count into account. + // Currently we always pass 256 colors (random, most of the times) to the driver. Cool! + uint8 colors[256]; + uint32 i; TRACE("SET_INDEXED_COLORS\n"); + + for (i = 0; i < count; i++) { + colors[i + first] = color_data[i]; + } + + ioctl(gFd, VMWARE_SET_PALETTE, colors, sizeof(count)); } diff --git a/src/add-ons/kernel/drivers/graphics/vmware/device.c b/src/add-ons/kernel/drivers/graphics/vmware/device.c index 9eb9375ba9..3b7ecb4330 100644 --- a/src/add-ons/kernel/drivers/graphics/vmware/device.c +++ b/src/add-ons/kernel/drivers/graphics/vmware/device.c @@ -299,6 +299,26 @@ ControlHook(void *dev, uint32 msg, void *buf, size_t len) WriteReg(SVGA_REG_BITS_PER_PIXEL, BppForSpace(dm->space)); si->fbOffset = ReadReg(SVGA_REG_FB_OFFSET); si->bytesPerRow = ReadReg(SVGA_REG_BYTES_PER_LINE); + ReadReg(SVGA_REG_DEPTH); + ReadReg(SVGA_REG_PSEUDOCOLOR); + ReadReg(SVGA_REG_RED_MASK); + ReadReg(SVGA_REG_GREEN_MASK); + ReadReg(SVGA_REG_BLUE_MASK); + return B_OK; + } + + case VMWARE_SET_PALETTE: + { + uint8 *color = (uint8 *)buf; + uint32 i; + if (ReadReg(SVGA_REG_PSEUDOCOLOR) != 1) + return B_ERROR; + + for (i = 0; i < 256; i++) { + WriteReg(SVGA_PALETTE_BASE + 3 * i, *color++); + WriteReg(SVGA_PALETTE_BASE + 3 * i + 1, *color++); + WriteReg(SVGA_PALETTE_BASE + 3 * i + 2, *color++); + } return B_OK; } @@ -318,6 +338,14 @@ ControlHook(void *dev, uint32 msg, void *buf, size_t len) SVGA_CURSOR_ON_SHOW); return B_OK; } + + case VMWARE_GET_DEVICE_NAME: + dprintf("device: VMWARE_GET_DEVICE_NAME %s\n", gPd->names[0]); + if (user_strlcpy((char *)buf, gPd->names[0], + B_PATH_NAME_LENGTH) < B_OK) + return B_BAD_ADDRESS; + return B_OK; + } TRACE("ioctl: %ld, %p, %ld\n", msg, buf, len);