Skip to contentSkip to conversation

diagrams for drm docs

PATCH New Daniel Vetter 1 participant 8 messages Dec 19, 2016

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover diagrams for drm docs

Hi all,

So this is my first stab at doing some overview diagrams for drm. Pretty much like what it looks like, both input and output. Well there's one layout issue where I couldn't convince DOT to do what I want it to do. All based on Markus' kernel-figures script.

I think the script needs a bit more work&polish, but I'm probably not the best one to do that. I can take a stab at improving things a bit, but I think better if Jani/Jon/Markus help out here.

Cheers, Daniel

Daniel Vetter (5):
HACKS: pass stderr along in kfigure.py drm/doc: Add KMS overview graphs drm/doc: Consistent kerneldoc include order drm/doc: diagram for mode objects and properties drm/doc: atomic overview, with graph

Markus Heiser (1):
docs-rst: automatically convert Graphviz and SVG images

 Documentation/conf.py                 |   2 +-
 Documentation/doc-guide/hello.dot     |   3 +
 Documentation/doc-guide/sphinx.rst    |  90 +++++-
 Documentation/doc-guide/svg_image.svg |  10 +
 Documentation/gpu/drm-internals.rst   |   6 +-
 Documentation/gpu/drm-kms-helpers.rst |  28 +-
 Documentation/gpu/drm-kms.rst         | 269 ++++++++++++++++--
 Documentation/gpu/drm-mm.rst          |  24 +-
 Documentation/process/changes.rst     |   8 +-
 Documentation/sphinx/kfigure.py       | 511 ++++++++++++++++++++++++++++++++++
 10 files changed, 903 insertions(+), 48 deletions(-)
 create mode 100644 Documentation/doc-guide/hello.dot
 create mode 100644 Documentation/doc-guide/svg_image.svg
 create mode 100644 Documentation/sphinx/kfigure.py
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/6 docs-rst: automatically convert Graphviz and SVG images

From: Markus Heiser <[email protected]>

This patch brings scalable figure, image handling and a concept to embed *render* markups:

* DOT (http://www.graphviz.org)
* SVG

For image handling use the 'image' replacement::

.. kernel-image:: svg_image.svg
:alt: simple SVG image

For figure handling use the 'figure' replacement::

.. kernel-figure:: svg_image.svg
:alt: simple SVG image

SVG image example

Embed *render* markups (or languages) like Graphviz's **DOT** is provided by the *render* directive.::

.. kernel-render:: DOT

     :alt: foobar digraph
     :caption: Embedded **DOT** (Graphviz) code.

     digraph foo {
      "bar" -> "baz";
     }

The *render* directive is a concept to integrate *render* markups and languages, yet supported markups:

* DOT: render embedded Graphviz's **DOT**
* SVG: render embedded Scalable Vector Graphics (**SVG**)

v2: s/DOC/DOT/ in a few places.

---
 Documentation/conf.py                 |   2 +-
 Documentation/doc-guide/hello.dot     |   3 +
 Documentation/doc-guide/sphinx.rst    |  90 +++++-
 Documentation/doc-guide/svg_image.svg |  10 +
 Documentation/process/changes.rst     |   8 +-
 Documentation/sphinx/kfigure.py       | 505 ++++++++++++++++++++++++++++++++++
 6 files changed, 612 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/doc-guide/hello.dot
 create mode 100644 Documentation/doc-guide/svg_image.svg
 create mode 100644 Documentation/sphinx/kfigure.py
Documentation/conf.py +1 -1
index bb5a9082598d..23f291a8f857 100644
@@ -34,7 +34,7 @@ from load_config import loadConfig
 # Add any Sphinx extension module names here, as strings. They can be
 # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
 # ones.
-extensions = ['kerneldoc', 'rstFlatTable', 'kernel_include', 'cdomain']
+extensions = ['kerneldoc', 'rstFlatTable', 'kernel_include', 'cdomain', 'kfigure']
 
 # The name of the math extension changed on Sphinx 1.4
 if major == 1 and minor > 3:
Documentation/doc-guide/hello.dot new file +3 -0
new file mode 100644
index 000000000000..504621dfc595
@@ -0,0 +1,3 @@
+graph G {
+      Hello -- World
+}
Documentation/doc-guide/sphinx.rst +88 -2

99 lines not on this page · raw message

Documentation/doc-guide/svg_image.svg new file +10 -0
new file mode 100644
index 000000000000..5405f85b8137
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- originate: https://commons.wikimedia.org/wiki/File:Variable_Resistor.svg -->
+<svg xmlns="http://www.w3.org/2000/svg"
+	version="1.1" baseProfile="full"
+	width="70px" height="40px" viewBox="0 0 700 400">
+	<line x1="0" y1="200" x2="700" y2="200" stroke="black" stroke-width="20px"/>
+	<rect x="100" y="100" width="500" height="200" fill="white" stroke="black" stroke-width="20px"/>
+	<line x1="180" y1="370" x2="500" y2="50" stroke="black" stroke-width="15px"/>
+	<polygon points="585 0 525 25 585 50" transform="rotate(135 525 25)"/>
+</svg>
Documentation/process/changes.rst +5 -3
index 56ce66114665..de284ca05587 100644
@@ -318,9 +318,11 @@ PDF outputs, it is recommended to use version 1.4.6.
 .. note::
 
   Please notice that, for PDF and LaTeX output, you'll also need ``XeLaTeX``
-  version 3.14159265. Depending on the distribution, you may also need
-  to install a series of ``texlive`` packages that provide the minimal
-  set of functionalities required for ``XeLaTex`` to work.
+  version 3.14159265. Depending on the distribution, you may also need to
+  install a series of ``texlive`` packages that provide the minimal set of
+  functionalities required for ``XeLaTex`` to work. For PDF output you'll also
+  need CairoSVG (http://cairosvg.org) or alternatively ``convert(1)`` from
+  ImageMagick (https://www.imagemagick.org).
 
 Other tools
 -----------
Documentation/sphinx/kfigure.py new file +505 -0

505 lines not on this page · raw message

Signature · 1 line
2.11.0
#2 lore raw

PATCH 2/6 HACKS: pass stderr along in kfigure.py

In reply to Daniel Vetter

Some addition comments on the implementation:
- Also needs to be hacked up for svg conversion.
- Inline kernel-render creates temp files and caches them, doesn't seem that good an idea. Probably should switch over to using pipes.
- Reimplements sphinx' depency tracking. Might be fixable if we just use pipes (and using the sphinx functions to open/read files).
- Linenumbers are off, but no idea how to fix that.
- Script looks a bit complicated to me, but I don't have python clue.

---
 Documentation/sphinx/kfigure.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
Documentation/sphinx/kfigure.py +8 -2
index 76425b461a40..d6819337edf6 100644
@@ -50,6 +50,7 @@ import os
 from os import path
 import subprocess
 from hashlib import sha1
+import sys
 
 from docutils import nodes
 from docutils.statemachine import ViewList
@@ -278,11 +279,16 @@ def dot2format(dot_fname, out_fname):
 
     """
     out_format = path.splitext(out_fname)[1][1:]
-    cmd = [dot_cmd, '-T%s' % out_format, dot_fname]
+    cmd = [dot_cmd, '-T%s' % out_format, dot_fname, '-v']
     exit_code = 42
     with open(out_fname, "w") as out:
-        exit_code = subprocess.call(
+        p = subprocess.Popen(
             cmd, stdout = out, stderr = subprocess.PIPE )
+        meh, err = p.communicate()
+
+        sys.stderr.write(err)
+
+        exit_code = p.returncode
         out.flush()
     return bool(exit_code == 0)
 
Signature · 1 line
2.11.0
#3 lore raw

PATCH 3/6 drm/doc: Add KMS overview graphs

In reply to Daniel Vetter

Oh, the shiny and pretties!

Cc Laurent Pinchart <[email protected]>
---
 Documentation/gpu/drm-kms-helpers.rst |   4 ++
 Documentation/gpu/drm-kms.rst         | 132 ++++++++++++++++++++++++++++++++++
 2 files changed, 136 insertions(+)
Documentation/gpu/drm-kms-helpers.rst +4 -0
index 03040aa14fe8..012b6ff3ec3f 100644
@@ -114,6 +114,8 @@ Framebuffer CMA Helper Functions Reference
 .. kernel-doc:: drivers/gpu/drm/drm_fb_cma_helper.c
    :export:
 
+.. _drm_bridges:
+
 Bridges
 =======
 
@@ -139,6 +141,8 @@ Bridge Helper Reference
 .. kernel-doc:: drivers/gpu/drm/drm_bridge.c
    :export:
 
+.. _drm_panel_helper:
+
 Panel Helper Reference
 ======================
 
Documentation/gpu/drm-kms.rst +132 -0

138 lines not on this page · raw message

Signature · 1 line
2.11.0
#4 lore raw

PATCH 4/6 drm/doc: Consistent kerneldoc include order

In reply to Daniel Vetter

First overview text (if there is any), then headers (since generally you want to start out with the data structures), then all the other stuff with functions.

Most of this is pre-shpinx, since with the old docbook only the overview stuff was pulled in directly. Everything else was put in a per-section index, so include order didn't really matter.

---
 Documentation/gpu/drm-internals.rst   |  6 +++---
 Documentation/gpu/drm-kms-helpers.rst | 22 +++++++++++-----------
 Documentation/gpu/drm-kms.rst         | 30 +++++++++++++++---------------
 Documentation/gpu/drm-mm.rst          | 24 ++++++++++++------------
 4 files changed, 41 insertions(+), 41 deletions(-)
Documentation/gpu/drm-internals.rst +3 -3
index e35920db1f4c..29d6bf7bb1ac 100644
@@ -140,12 +140,12 @@ Device Instance and Driver Handling
 .. kernel-doc:: drivers/gpu/drm/drm_drv.c
    :doc: driver instance overview
 
-.. kernel-doc:: drivers/gpu/drm/drm_drv.c
-   :export:
-
 .. kernel-doc:: include/drm/drm_drv.h
    :internal:
 
+.. kernel-doc:: drivers/gpu/drm/drm_drv.c
+   :export:
+
 Driver Load
 -----------
 
Documentation/gpu/drm-kms-helpers.rst +11 -11
index 012b6ff3ec3f..050ebe81d256 100644
@@ -37,10 +37,10 @@ Modeset Helper Reference for Common Vtables
 ===========================================
 
 .. kernel-doc:: include/drm/drm_modeset_helper_vtables.h
-   :internal:
+   :doc: overview
 
 .. kernel-doc:: include/drm/drm_modeset_helper_vtables.h
-   :doc: overview
+   :internal:
 
 Atomic Modeset Helper Functions Reference
 =========================================
@@ -84,27 +84,27 @@ Legacy CRTC/Modeset Helper Functions Reference
 Simple KMS Helper Reference
 ===========================
 
+.. kernel-doc:: drivers/gpu/drm/drm_simple_kms_helper.c
+   :doc: overview
+
 .. kernel-doc:: include/drm/drm_simple_kms_helper.h
    :internal:
 
 .. kernel-doc:: drivers/gpu/drm/drm_simple_kms_helper.c
    :export:
 
-.. kernel-doc:: drivers/gpu/drm/drm_simple_kms_helper.c
-   :doc: overview
-
 fbdev Helper Functions Reference
 ================================
 
 .. kernel-doc:: drivers/gpu/drm/drm_fb_helper.c
    :doc: fbdev helpers
 
-.. kernel-doc:: drivers/gpu/drm/drm_fb_helper.c
-   :export:
-
 .. kernel-doc:: include/drm/drm_fb_helper.h
    :internal:
 
+.. kernel-doc:: drivers/gpu/drm/drm_fb_helper.c
+   :export:
+
 Framebuffer CMA Helper Functions Reference
 ==========================================
 
@@ -146,15 +146,15 @@ Bridge Helper Reference
 Panel Helper Reference
 ======================
 
+.. kernel-doc:: drivers/gpu/drm/drm_panel.c
+   :doc: drm panel
+
 .. kernel-doc:: include/drm/drm_panel.h
    :internal:
 
 .. kernel-doc:: drivers/gpu/drm/drm_panel.c
    :export:
 
-.. kernel-doc:: drivers/gpu/drm/drm_panel.c
-   :doc: drm panel
-
 Display Port Helper Functions Reference
 =======================================
 
Documentation/gpu/drm-kms.rst +15 -15
index 2bdd266da4a9..05a346492e07 100644
@@ -152,12 +152,12 @@ panels are still in-flux and not really fully sorted out yet.
 KMS Core Structures and Functions
 =================================
 
-.. kernel-doc:: drivers/gpu/drm/drm_mode_config.c
-   :export:
-
 .. kernel-doc:: include/drm/drm_mode_config.h
    :internal:
 
+.. kernel-doc:: drivers/gpu/drm/drm_mode_config.c
+   :export:
+
 Modeset Base Object Abstraction
 ===============================
 
@@ -170,21 +170,21 @@ Modeset Base Object Abstraction
 Atomic Mode Setting Function Reference
 ======================================
 
-.. kernel-doc:: drivers/gpu/drm/drm_atomic.c
-   :export:
-
 .. kernel-doc:: include/drm/drm_atomic.h
    :internal:
 
+.. kernel-doc:: drivers/gpu/drm/drm_atomic.c
+   :export:
+
 CRTC Abstraction
 ================
 
-.. kernel-doc:: drivers/gpu/drm/drm_crtc.c
-   :export:
-
 .. kernel-doc:: include/drm/drm_crtc.h
    :internal:
 
+.. kernel-doc:: drivers/gpu/drm/drm_crtc.c
+   :export:
+
 Frame Buffer Abstraction
 ========================
 
@@ -194,12 +194,12 @@ Frame Buffer Abstraction
 Frame Buffer Functions Reference
 --------------------------------
 
-.. kernel-doc:: drivers/gpu/drm/drm_framebuffer.c
-   :export:
-
 .. kernel-doc:: include/drm/drm_framebuffer.h
    :internal:
 
+.. kernel-doc:: drivers/gpu/drm/drm_framebuffer.c
+   :export:
+
 DRM Format Handling
 ===================
 
@@ -502,8 +502,8 @@ operation handler.
 Vertical Blanking and Interrupt Handling Functions Reference
 ------------------------------------------------------------
 
-.. kernel-doc:: drivers/gpu/drm/drm_irq.c
-   :export:
-
 .. kernel-doc:: include/drm/drm_irq.h
    :internal:
+
+.. kernel-doc:: drivers/gpu/drm/drm_irq.c
+   :export:
Documentation/gpu/drm-mm.rst +12 -12
index cb5daffcd6be..1ac599559e28 100644
@@ -342,36 +342,36 @@ from the client in libdrm.
 GEM Function Reference
 ----------------------
 
-.. kernel-doc:: drivers/gpu/drm/drm_gem.c
-   :export:
-
 .. kernel-doc:: include/drm/drm_gem.h
    :internal:
 
+.. kernel-doc:: drivers/gpu/drm/drm_gem.c
+   :export:
+
 GEM CMA Helper Functions Reference
 ----------------------------------
 
 .. kernel-doc:: drivers/gpu/drm/drm_gem_cma_helper.c
    :doc: cma helpers
 
-.. kernel-doc:: drivers/gpu/drm/drm_gem_cma_helper.c
-   :export:
-
 .. kernel-doc:: include/drm/drm_gem_cma_helper.h
    :internal:
 
+.. kernel-doc:: drivers/gpu/drm/drm_gem_cma_helper.c
+   :export:
+
 VMA Offset Manager
 ==================
 
 .. kernel-doc:: drivers/gpu/drm/drm_vma_manager.c
    :doc: vma offset manager
 
-.. kernel-doc:: drivers/gpu/drm/drm_vma_manager.c
-   :export:
-
 .. kernel-doc:: include/drm/drm_vma_manager.h
    :internal:
 
+.. kernel-doc:: drivers/gpu/drm/drm_vma_manager.c
+   :export:
+
 PRIME Buffer Sharing
 ====================
 
@@ -447,8 +447,8 @@ LRU Scan/Eviction Support
 DRM MM Range Allocator Function References
 ------------------------------------------
 
-.. kernel-doc:: drivers/gpu/drm/drm_mm.c
-   :export:
-
 .. kernel-doc:: include/drm/drm_mm.h
    :internal:
+
+.. kernel-doc:: drivers/gpu/drm/drm_mm.c
+   :export:
Signature · 1 line
2.11.0
#5 lore raw

PATCH 5/6 drm/doc: diagram for mode objects and properties

In reply to Daniel Vetter

Resulted in confusion a few times in the past.

Cc Laurent Pinchart <[email protected]>
Cc Manasi Navare <[email protected]>
---
 Documentation/gpu/drm-kms.rst | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
Documentation/gpu/drm-kms.rst +22 -0
index 05a346492e07..07d288fa37b2 100644
@@ -161,6 +161,28 @@ KMS Core Structures and Functions
 Modeset Base Object Abstraction
 ===============================
 
+.. kernel-render:: DOT
+   :alt: Mode Objects and Properties
+   :caption: Mode Objects and Properties
+
+   digraph {
+      node [shape=box]
+
+      "drm_property A" -> "drm_mode_object A"
+      "drm_property A" -> "drm_mode_object B"
+      "drm_property B" -> "drm_mode_object A"
+   }
+
+The base structure for all KMS objects is :c:type:`struct drm_mode_object
+<drm_mode_object>`. One of the base services is provides is tracking properties,
+which are especially important for the atomic IOCTL (see `Atomic Mode
+Setting`_). The somewhat surprising part here is that properties are not
+directly instantiated on each object, but free-standing mode objects themselves,
+represented by :c:type:`struct drm_property <drm_property>`, which only specify
+the type and value range of a property. Any given property can be attached
+multiple times to different objects using :c:func:`drm_object_attach_property()
+<drm_object_attach_property>`.
+
 .. kernel-doc:: include/drm/drm_mode_object.h
    :internal:
 
Signature · 1 line
2.11.0
#6 lore raw

PATCH 6/6 drm/doc: atomic overview, with graph

In reply to Daniel Vetter

I want to split up a few more things and document some details better (like how exactly to subclass drm_atomic_state). And maybe also split up the helpers a bit per-topic, but this should be a ok-ish start for better atomic overview.

One thing I failed at is getting DOT to layout the overview graph how I want it. The highlevel structure I want is:

Free-standing State

Current State

i.e. one over the other. Currently it lays it out side-by-side, but not even that really - "Current State" is somewhat offset below. Makes the graph look like garbage, and also way too wide for proper rendering. Ideas appreciated.

Cc Laurent Pinchart <[email protected]>
Cc Harry Wentland <[email protected]>
---
 Documentation/gpu/drm-kms-helpers.rst |  2 +
 Documentation/gpu/drm-kms.rst         | 85 ++++++++++++++++++++++++++++++++++-
 2 files changed, 86 insertions(+), 1 deletion(-)
Documentation/gpu/drm-kms-helpers.rst +2 -0
index 050ebe81d256..ac53c0b893f6 100644
@@ -42,6 +42,8 @@ Modeset Helper Reference for Common Vtables
 .. kernel-doc:: include/drm/drm_modeset_helper_vtables.h
    :internal:
 
+.. _drm_atomic_helper:
+
 Atomic Modeset Helper Functions Reference
 =========================================
 
Documentation/gpu/drm-kms.rst +84 -1

92 lines not on this page · raw message

Signature · 1 line
2.11.0
#7 lore raw

PATCH 1/1 drm/doc: atomic overview, with graph

In reply to Daniel Vetter

I want to split up a few more things and document some details better (like how exactly to subclass drm_atomic_state). And maybe also split up the helpers a bit per-topic, but this should be a ok-ish start for better atomic overview.

One thing I failed at is getting DOT to layout the overview graph how I want it. The highlevel structure I want is:

Free-standing State

Current State

i.e. one over the other. Currently it lays it out side-by-side, but not even that really - "Current State" is somewhat offset below. Makes the graph look like garbage, and also way too wide for proper rendering. Ideas appreciated.

Cc Laurent Pinchart <[email protected]>
Cc Harry Wentland <[email protected]>
---
 Documentation/gpu/drm-kms-helpers.rst |  2 +
 Documentation/gpu/drm-kms.rst         | 85 ++++++++++++++++++++++++++++++++++-
 2 files changed, 86 insertions(+), 1 deletion(-)
Documentation/gpu/drm-kms-helpers.rst +2 -0
index 050ebe81d256..ac53c0b893f6 100644
@@ -42,6 +42,8 @@ Modeset Helper Reference for Common Vtables
 .. kernel-doc:: include/drm/drm_modeset_helper_vtables.h
    :internal:
 
+.. _drm_atomic_helper:
+
 Atomic Modeset Helper Functions Reference
 =========================================
 
Documentation/gpu/drm-kms.rst +84 -1

92 lines not on this page · raw message

Signature · 1 line
2.11.0