udlfb.txt 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. What is udlfb?
  2. ===============
  3. This is a driver for DisplayLink USB 2.0 era graphics chips.
  4. DisplayLink chips provide simple hline/blit operations with some compression,
  5. pairing that with a hardware framebuffer (16MB) on the other end of the
  6. USB wire. That hardware framebuffer is able to drive the VGA, DVI, or HDMI
  7. monitor with no CPU involvement until a pixel has to change.
  8. The CPU or other local resource does all the rendering; optinally compares the
  9. result with a local shadow of the remote hardware framebuffer to identify
  10. the minimal set of pixels that have changed; and compresses and sends those
  11. pixels line-by-line via USB bulk transfers.
  12. Because of the efficiency of bulk transfers and a protocol on top that
  13. does not require any acks - the effect is very low latency that
  14. can support surprisingly high resolutions with good performance for
  15. non-gaming and non-video applications.
  16. Mode setting, EDID read, etc are other bulk or control transfers. Mode
  17. setting is very flexible - able to set nearly arbitrary modes from any timing.
  18. Advantages of USB graphics in general:
  19. * Ability to add a nearly arbitrary number of displays to any USB 2.0
  20. capable system. On Linux, number of displays is limited by fbdev interface
  21. (FB_MAX is currently 32). Of course, all USB devices on the same
  22. host controller share the same 480Mbs USB 2.0 interface.
  23. Advantages of supporting DisplayLink chips with kernel framebuffer interface:
  24. * The actual hardware functionality of DisplayLink chips matches nearly
  25. one-to-one with the fbdev interface, making the driver quite small and
  26. tight relative to the functionality it provides.
  27. * X servers and other applications can use the standard fbdev interface
  28. from user mode to talk to the device, without needing to know anything
  29. about USB or DisplayLink's protocol at all. A "displaylink" X driver
  30. and a slightly modified "fbdev" X driver are among those that already do.
  31. Disadvantages:
  32. * Fbdev's mmap interface assumes a real hardware framebuffer is mapped.
  33. In the case of USB graphics, it is just an allocated (virtual) buffer.
  34. Writes need to be detected and encoded into USB bulk transfers by the CPU.
  35. Accurate damage/changed area notifications work around this problem.
  36. In the future, hopefully fbdev will be enhanced with an small standard
  37. interface to allow mmap clients to report damage, for the benefit
  38. of virtual or remote framebuffers.
  39. * Fbdev does not arbitrate client ownership of the framebuffer well.
  40. * Fbcon assumes the first framebuffer it finds should be consumed for console.
  41. * It's not clear what the future of fbdev is, given the rise of KMS/DRM.
  42. How to use it?
  43. ==============
  44. Udlfb, when loaded as a module, will match against all USB 2.0 generation
  45. DisplayLink chips (Alex and Ollie family). It will then attempt to read the EDID
  46. of the monitor, and set the best common mode between the DisplayLink device
  47. and the monitor's capabilities.
  48. If the DisplayLink device is successful, it will paint a "green screen" which
  49. means that from a hardware and fbdev software perspective, everything is good.
  50. At that point, a /dev/fb? interface will be present for user-mode applications
  51. to open and begin writing to the framebuffer of the DisplayLink device using
  52. standard fbdev calls. Note that if mmap() is used, by default the user mode
  53. application must send down damage notifcations to trigger repaints of the
  54. changed regions. Alternatively, udlfb can be recompiled with experimental
  55. defio support enabled, to support a page-fault based detection mechanism
  56. that can work without explicit notifcation.
  57. The most common client of udlfb is xf86-video-displaylink or a modified
  58. xf86-video-fbdev X server. These servers have no real DisplayLink specific
  59. code. They write to the standard framebuffer interface and rely on udlfb
  60. to do its thing. The one extra feature they have is the ability to report
  61. rectangles from the X DAMAGE protocol extension down to udlfb via udlfb's
  62. damage interface (which will hopefully be standardized for all virtual
  63. framebuffers that need damage info). These damage notifications allow
  64. udlfb to efficiently process the changed pixels.
  65. Module Options
  66. ==============
  67. Special configuration for udlfb is usually unnecessary. There are a few
  68. options, however.
  69. From the command line, pass options to modprobe
  70. modprobe udlfb fb_defio=0 console=1 shadow=1
  71. Or modify options on the fly at /sys/module/udlfb/parameters directory via
  72. sudo nano fb_defio
  73. change the parameter in place, and save the file.
  74. Unplug/replug USB device to apply with new settings
  75. Or for permanent option, create file like /etc/modprobe.d/udlfb.conf with text
  76. options udlfb fb_defio=0 console=1 shadow=1
  77. Accepted boolean options:
  78. fb_defio Make use of the fb_defio (CONFIG_FB_DEFERRED_IO) kernel
  79. module to track changed areas of the framebuffer by page faults.
  80. Standard fbdev applications that use mmap but that do not
  81. report damage, should be able to work with this enabled.
  82. Disable when running with X server that supports reporting
  83. changed regions via ioctl, as this method is simpler,
  84. more stable, and higher performance.
  85. default: fb_defio=1
  86. console Allow fbcon to attach to udlfb provided framebuffers.
  87. Can be disabled if fbcon and other clients
  88. (e.g. X with --shared-vt) are in conflict.
  89. default: console=1
  90. shadow Allocate a 2nd framebuffer to shadow what's currently across
  91. the USB bus in device memory. If any pixels are unchanged,
  92. do not transmit. Spends host memory to save USB transfers.
  93. Enabled by default. Only disable on very low memory systems.
  94. default: shadow=1
  95. Sysfs Attributes
  96. ================
  97. Udlfb creates several files in /sys/class/graphics/fb?
  98. Where ? is the sequential framebuffer id of the particular DisplayLink device
  99. edid If a valid EDID blob is written to this file (typically
  100. by a udev rule), then udlfb will use this EDID as a
  101. backup in case reading the actual EDID of the monitor
  102. attached to the DisplayLink device fails. This is
  103. especially useful for fixed panels, etc. that cannot
  104. communicate their capabilities via EDID. Reading
  105. this file returns the current EDID of the attached
  106. monitor (or last backup value written). This is
  107. useful to get the EDID of the attached monitor,
  108. which can be passed to utilities like parse-edid.
  109. metrics_bytes_rendered 32-bit count of pixel bytes rendered
  110. metrics_bytes_identical 32-bit count of how many of those bytes were found to be
  111. unchanged, based on a shadow framebuffer check
  112. metrics_bytes_sent 32-bit count of how many bytes were transferred over
  113. USB to communicate the resulting changed pixels to the
  114. hardware. Includes compression and protocol overhead
  115. metrics_cpu_kcycles_used 32-bit count of CPU cycles used in processing the
  116. above pixels (in thousands of cycles).
  117. metrics_reset Write-only. Any write to this file resets all metrics
  118. above to zero. Note that the 32-bit counters above
  119. roll over very quickly. To get reliable results, design
  120. performance tests to start and finish in a very short
  121. period of time (one minute or less is safe).
  122. --
  123. Bernie Thompson <bernie@plugable.com>