title: Why does KMS drmModeSetCrtc() fail with permission denied while running in X11 session?
body: <p>The title already implies the question, so what is blocking the execution from the sample program in this repo <a href="https://github.com/dvdhrm/docs/tree/master/drm-howto" rel="noreferrer">https://github.com/dvdhrm/docs/tree/master/drm-howto</a></p>
  
  <p>It's a simple program showing KMS in action, so I downloaded it, compiled it and gave it a run. This was the output:</p>
  
  <pre><code>michael@lord:~/Downloads/docs/drm-howto$ sudo ./modeset
  [sudo] password for michael: 
  using card '/dev/dri/card0'
  mode for connector 59 is 1920x1080
  ignoring unused connector 68
  ignoring unused connector 71
  ignoring unused connector 75
  cannot set CRTC for connector 59 (13): Permission denied
  exiting
  </code></pre>
  
  <p>Also note that I have a running X11 session on my machine.
  It seems X is already using the device <code>/dev/dri/card0</code> and blocks it for all other programs.</p>
  
  <p>Here is my video card:</p>
  
  <pre><code>michael@lord:~/Downloads/docs/drm-howto$ lspci | grep VGA
  00:02.0 VGA compatible controller: Intel Corporation UHD Graphics 620 (rev 07)
  </code></pre>
  
  <p>I have also added <code>i915.modeset=1</code> into <code>/etc/initramfs-tools/modules</code> and rebuilt it with <code>sudo update-initramfs -u</code> so it loads the driver from inside my kernel and not from the xorg side.</p>
  
  <p>There is also the possibility that my driver doesn't support KMS but <code>lspci</code> has shown that I only have an internal intel graphics card installed. So I sticked with the xorg core display driver package which is installed by default from <code>xserver-xorg-core</code>.</p>
  
  <p>None of these changes have taken affect.
  The only way I can execute those examples is by killing the xorg session and let it run in tty.</p>
  
  <p>Any ideas?</p>