Exemplo n.º 1
0
        private void SetScanoutRegion(int buffer)
        {
            LinuxWindowInfo wnd = WindowInfo as LinuxWindowInfo;

            if (wnd == null)
            {
                throw new InvalidOperationException();
            }

            unsafe
            {
                ModeInfo *mode         = wnd.DisplayDevice.pConnector->modes;
                int       connector_id = wnd.DisplayDevice.pConnector->connector_id;
                int       crtc_id      = wnd.DisplayDevice.Id;

                int x = 0;
                int y = 0;
                int connector_count = 1;
                int ret             = Drm.ModeSetCrtc(fd, crtc_id, buffer, x, y,
                                                      &connector_id, connector_count, mode);

                if (ret != 0)
                {
                    Debug.Print("[KMS] Drm.ModeSetCrtc{0}, {1}, {2}, {3}, {4:x}, {5}, {6:x}) failed. Error: {7}",
                                fd, crtc_id, buffer, x, y, (IntPtr)connector_id, connector_count, (IntPtr)mode, ret);
                }
            }
        }
Exemplo n.º 2
0
        private unsafe static void GetModes(LinuxDisplay display, DisplayResolution[] modes, out DisplayResolution current)
        {
            int mode_count = display.pConnector->count_modes;

            Debug.Print("[KMS] Display supports {0} mode(s)", mode_count);
            for (int i = 0; i < mode_count; i++)
            {
                ModeInfo *mode = display.pConnector->modes + i;
                if (mode != null)
                {
                    Debug.Print("Mode {0}: {1}x{2} @{3}", i,
                                mode->hdisplay, mode->vdisplay, mode->vrefresh);
                    DisplayResolution res = GetDisplayResolution(mode);
                    modes[i] = res;
                }
            }

            if (display.pCrtc->mode_valid != 0)
            {
                ModeInfo cmode = display.pCrtc->mode;
                current = GetDisplayResolution(&cmode);
            }
            else
            {
                current = GetDisplayResolution(display.pConnector->modes);
            }
            Debug.Print("Current mode: {0}", current.ToString());
        }
Exemplo n.º 3
0
 private unsafe static DisplayResolution GetDisplayResolution(ModeInfo *mode)
 {
     return(new DisplayResolution(
                0, 0,
                mode->hdisplay, mode->vdisplay,
                32, // This is actually part of the framebuffer, not the DisplayResolution
                mode->vrefresh));
 }
Exemplo n.º 4
0
 private unsafe static ModeInfo *GetModeInfo(LinuxDisplay display, DisplayResolution resolution)
 {
     for (int i = 0; i < display.pConnector->count_modes; i++)
     {
         ModeInfo *mode = display.pConnector->modes + i;
         if (mode != null &&
             mode->hdisplay == resolution.Width &&
             mode->vdisplay == resolution.Height)
         {
             return(mode);
         }
     }
     return(null);
 }
Exemplo n.º 5
0
 public override bool TryChangeResolution(DisplayDevice device, DisplayResolution resolution)
 {
     unsafe
     {
         LinuxDisplay display      = (LinuxDisplay)device.Id;
         ModeInfo *   mode         = GetModeInfo(display, resolution);
         int          connector_id = display.pConnector->connector_id;
         if (mode != null)
         {
             return(Drm.ModeSetCrtc(FD, display.Id, 0, 0, 0,
                                    &connector_id, 1, mode) == 0);
         }
         return(false);
     }
 }
Exemplo n.º 6
0
 unsafe public static extern int ModeSetCrtc(int fd, int crtcId, int bufferId,
                                             int x, int y, int *connectors, int count, ModeInfo *mode);