- Timestamp:
- Mar 24, 2016 8:06:24 PM (9 years ago)
- Location:
- trunk/src/VBox/Additions/x11/vboxvideo
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/x11/vboxvideo/getmode.c
r60133 r60190 228 228 229 229 #undef COMPARE_AND_MAYBE_SET 230 231 #ifdef VBOXVIDEO_13 232 # ifdef RT_OS_LINUX 233 /** We have this for two purposes: one is to ensure that the X server is woken 234 * up when we get a video ACPI event. Two is to grab ACPI video events to 235 * prevent gnome-settings-daemon from seeing them, as older versions ignored 236 * the time stamp and handled them at the wrong time. */ 237 static void acpiEventHandler(int fd, void *pvData) 238 { 239 ScreenPtr pScreen = (ScreenPtr)pvData; 240 VBOXPtr pVBox = VBOXGetRec(xf86Screens[pScreen->myNum]); 241 struct input_event event; 242 ssize_t rc; 243 244 do 245 rc = read(fd, &event, sizeof(event)); 246 while (rc > 0 || (rc == -1 && errno == EINTR)); 247 /* Why do they return EAGAIN instead of zero bytes read like everyone else does? */ 248 VBVXASSERT(rc != -1 || errno == EAGAIN, ("Reading ACPI input event failed.\n")); 249 } 250 251 void vbvxSetUpLinuxACPI(ScreenPtr pScreen) 252 { 253 VBOXPtr pVBox = VBOXGetRec(xf86Screens[pScreen->myNum]); 254 struct dirent *pDirent; 255 DIR *pDir; 256 int fd = -1; 257 258 if (pVBox->fdACPIDevices != -1 || pVBox->hACPIEventHandler != NULL) 259 FatalError("ACPI input file descriptor not initialised correctly.\n"); 260 pDir = opendir("/dev/input"); 261 if (pDir == NULL) 262 return; 263 for (pDirent = readdir(pDir); pDirent != NULL; pDirent = readdir(pDir)) 264 { 265 if (strncmp(pDirent->d_name, "event", sizeof("event") - 1) == 0) 266 { 267 #define BITS_PER_BLOCK (sizeof(unsigned long) * 8) 268 char szFile[64] = "/dev/input/"; 269 char szDevice[64] = ""; 270 unsigned long afKeys[KEY_MAX / BITS_PER_BLOCK]; 271 272 strncat(szFile, pDirent->d_name, sizeof(szFile) - sizeof("/dev/input/")); 273 if (fd != -1) 274 close(fd); 275 fd = open(szFile, O_RDONLY | O_NONBLOCK); 276 if ( fd == -1 277 || ioctl(fd, EVIOCGNAME(sizeof(szDevice)), szDevice) == -1 278 || strcmp(szDevice, "Video Bus") != 0) 279 continue; 280 if ( ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(afKeys)), afKeys) == -1 281 || (( afKeys[KEY_SWITCHVIDEOMODE / BITS_PER_BLOCK] 282 >> KEY_SWITCHVIDEOMODE % BITS_PER_BLOCK) & 1) == 0) 283 break; 284 if (ioctl(fd, EVIOCGRAB, (void *)1) != 0) 285 break; 286 pVBox->hACPIEventHandler 287 = xf86AddGeneralHandler(fd, acpiEventHandler, pScreen); 288 if (pVBox->hACPIEventHandler == NULL) 289 break; 290 pVBox->fdACPIDevices = fd; 291 fd = -1; 292 break; 293 #undef BITS_PER_BLOCK 294 } 295 } 296 if (fd != -1) 297 close(fd); 298 closedir(pDir); 299 } 300 301 void vbvxCleanUpLinuxACPI(ScreenPtr pScreen) 302 { 303 VBOXPtr pVBox = VBOXGetRec(xf86Screens[pScreen->myNum]); 304 if (pVBox->fdACPIDevices != -1) 305 close(pVBox->fdACPIDevices); 306 pVBox->fdACPIDevices = -1; 307 xf86RemoveGeneralHandler(pVBox->hACPIEventHandler); 308 pVBox->hACPIEventHandler = NULL; 309 } 310 # endif /* RT_OS_LINUX */ 311 #endif /* VBOXVIDEO_13 */ -
trunk/src/VBox/Additions/x11/vboxvideo/vboxvideo.c
r60180 r60190 141 141 VBOXPtr pVBox = (VBOXPtr)xnfcalloc(sizeof(VBOXRec), 1); 142 142 pScrn->driverPrivate = pVBox; 143 #if defined(VBOXVIDEO_13) && defined(RT_OS_LINUX) 144 pVBox->fdACPIDevices = -1; 145 #endif 143 146 } 144 147 } … … 1094 1097 TRACE_ENTRY(); 1095 1098 1099 /* Initialise our guest library if possible: ignore failure. */ 1100 VbglR3Init(); 1096 1101 if (!VBOXMapVidMem(pScrn)) 1097 1102 return (FALSE); … … 1134 1139 pScrn->vtSema = TRUE; 1135 1140 1141 #if defined(VBOXVIDEO_13) && defined(RT_OS_LINUX) 1142 vbvxSetUpLinuxACPI(pScreen); 1143 #endif 1144 1136 1145 if (!VBoxHGSMIIsSupported()) 1137 1146 { … … 1333 1342 1334 1343 pScreen->CloseScreen = pVBox->CloseScreen; 1344 #if defined(VBOXVIDEO_13) && defined(RT_OS_LINUX) 1345 vbvxCleanUpLinuxACPI(pScreen); 1346 #endif 1335 1347 #ifndef XF86_SCRN_INTERFACE 1336 1348 ret = pScreen->CloseScreen(pScreen->myNum, pScreen); … … 1338 1350 ret = pScreen->CloseScreen(pScreen); 1339 1351 #endif 1352 VbglR3Term(); 1340 1353 return ret; 1341 1354 } -
trunk/src/VBox/Additions/x11/vboxvideo/vboxvideo.h
r60180 r60190 194 194 /** Array of structures for receiving mode hints. */ 195 195 VBVAMODEHINT *paVBVAModeHints; 196 #ifndef VBOXVIDEO_13 196 #ifdef VBOXVIDEO_13 197 # ifdef RT_OS_LINUX 198 /** Input device file descriptor for getting ACPI hot-plug events. */ 199 int fdACPIDevices; 200 /** Input handler handle for ACPI hot-plug listener. */ 201 void *hACPIEventHandler; 202 # endif 203 #else 197 204 /** Has VBoxClient registered with us for setting video modes? */ 198 205 bool fHaveVBoxClient; … … 251 258 extern void vbvxReadSizesAndCursorIntegrationFromProperties(ScrnInfoPtr pScrn, bool *pfNeedUpdate); 252 259 extern void vbvxReadSizesAndCursorIntegrationFromHGSMI(ScrnInfoPtr pScrn, bool *pfNeedUpdate); 260 extern void vbvxSetUpLinuxACPI(ScreenPtr pScreen); 261 extern void vbvxCleanUpLinuxACPI(ScreenPtr pScreen); 253 262 254 263 /* EDID generation */
Note:
See TracChangeset
for help on using the changeset viewer.