Merge branch 'char-misc-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/gregk...
[pandora-kernel.git] / Documentation / DocBook / drm.tmpl
index 7c11d79..196b8b9 100644 (file)
     </variablelist>
     <para>
       In this specific case, the driver requires AGP and supports
-      IRQs.  DMA, as discussed later, is handled by device specific ioctls
+      IRQs.  DMA, as discussed later, is handled by device-specific ioctls
       in this case.  It also supports the kernel mode setting APIs, though
       unlike in the actual i915 driver source, this example unconditionally
       exports KMS capability.
       to perform output discovery &amp; configuration at load time.
       Likewise, if user-level drivers unaware of memory management are
       in use, memory management and command buffer setup may need to
-      be omitted.  These requirements are driver specific, and care
+      be omitted.  These requirements are driver-specific, and care
       needs to be taken to keep both old and new applications and
       libraries working.  The i915 driver supports the "modeset"
       module parameter to control whether advanced features are
       <title>Driver private &amp; performance counters</title>
       <para>
        The driver private hangs off the main drm_device structure and
-       can be used for tracking various device specific bits of
+       can be used for tracking various device-specific bits of
        information, like register offsets, command buffer status,
        register state for suspend/resume, etc.  At load time, a
        driver may simply allocate one and set drm_device.dev_priv
     <sect2>
       <title>Configuring the device</title>
       <para>
-       Obviously, device configuration is device specific.
+       Obviously, device configuration is device-specific.
        However, there are several common operations: finding a
        device's PCI resources, mapping them, and potentially setting
        up an IRQ handler.
       <para>
        Once you have a register map, you may use the DRM_READn() and
        DRM_WRITEn() macros to access the registers on your device, or
-       use driver specific versions to offset into your MMIO space
-       relative to a driver specific base pointer (see I915_READ for
+       use driver-specific versions to offset into your MMIO space
+       relative to a driver-specific base pointer (see I915_READ for
        an example).
       </para>
       <para>
          and devices with dedicated video RAM (VRAM), i.e. most discrete
          graphics devices.  If your device has dedicated RAM, supporting
          TTM is desirable.  TTM also integrates tightly with your
-         driver specific buffer execution function.  See the radeon
+         driver-specific buffer execution function.  See the radeon
          driver for examples.
        </para>
        <para>
          created by the memory manager at runtime.  Your global TTM should
          have a type of TTM_GLOBAL_TTM_MEM.  The size field for the global
          object should be sizeof(struct ttm_mem_global), and the init and
-         release hooks should point at your driver specific init and
+         release hooks should point at your driver-specific init and
          release routines, which probably eventually call
          ttm_mem_global_init and ttm_mem_global_release, respectively.
        </para>
          provide a pool for buffer object allocation by clients and the
          kernel itself.  The type of this object should be TTM_GLOBAL_TTM_BO,
          and its size should be sizeof(struct ttm_bo_global).  Again,
-         driver specific init and release functions may be provided,
+         driver-specific init and release functions may be provided,
          likely eventually calling ttm_bo_global_init() and
          ttm_bo_global_release(), respectively.  Also, like the previous
          object, ttm_global_item_ref() is used to create an initial reference
          a GTT DRM MM object, which provides an address space pool for
          object allocation.  In a KMS configuration, the driver
          needs to allocate and initialize a command ring buffer following
-         basic GEM initialization.  Most UMA devices have a so-called
+         core GEM initialization.  A UMA device usually has what is called a
          "stolen" memory region, which provides space for the initial
          framebuffer and large, contiguous memory regions required by the
-         device.  This space is not typically managed by GEM, and must
+         device.  This space is not typically managed by GEM, and it must
          be initialized separately into its own DRM MM object.
        </para>
        <para>
-         Initialization is driver specific, and depends on
-         the architecture of the device.  In the case of Intel
+         Initialization is driver-specific. In the case of Intel
          integrated graphics chips like 965GM, GEM initialization can
          be done by calling the internal GEM init function,
          i915_gem_do_init().  Since the 965GM is a UMA device
     <sect2>
       <title>Output configuration</title>
       <para>
-       The final initialization task is output configuration.  This involves
-       finding and initializing the CRTCs, encoders and connectors
-       for your device, creating an initial configuration and
-       registering a framebuffer console driver.
+       The final initialization task is output configuration.  This involves:
+       <itemizedlist>
+         <listitem>
+           Finding and initializing the CRTCs, encoders, and connectors
+           for the device.
+         </listitem>
+         <listitem>
+           Creating an initial configuration.
+         </listitem>
+         <listitem>
+           Registering a framebuffer console driver.
+         </listitem>
+       </itemizedlist>
       </para>
       <sect3>
        <title>Output discovery and initialization</title>
        <para>
          Several core functions exist to create CRTCs, encoders, and
-         connectors, namely drm_crtc_init(), drm_connector_init(), and
+         connectors, namely: drm_crtc_init(), drm_connector_init(), and
          drm_encoder_init(), along with several "helper" functions to
          perform common tasks.
        </para>
@@ -553,10 +561,10 @@ void intel_crt_init(struct drm_device *dev)
        </programlisting>
        <para>
          In the example above (again, taken from the i915 driver), a
-         CRT connector and encoder combination is created.  A device
-         specific i2c bus is also created, for fetching EDID data and
+         CRT connector and encoder combination is created.  A device-specific
+         i2c bus is also created for fetching EDID data and
          performing monitor detection.  Once the process is complete,
-         the new connector is registered with sysfs, to make its
+         the new connector is registered with sysfs to make its
          properties available to applications.
        </para>
        <sect4>
@@ -565,8 +573,8 @@ void intel_crt_init(struct drm_device *dev)
            Since many PC-class graphics devices have similar display output
            designs, the DRM provides a set of helper functions to make
            output management easier.  The core helper routines handle
-           encoder re-routing and disabling of unused functions following
-           mode set.  Using the helpers is optional, but recommended for
+           encoder re-routing and the disabling of unused functions following
+           mode setting.  Using the helpers is optional, but recommended for
            devices with PC-style architectures (i.e. a set of display planes
            for feeding pixels to encoders which are in turn routed to
            connectors).  Devices with more complex requirements needing
@@ -578,17 +586,25 @@ void intel_crt_init(struct drm_device *dev)
          </para>
        </sect4>
        <para>
-         For each encoder, CRTC, and connector, several functions must
-         be provided, depending on the object type.  Encoder objects
-         need to provide a DPMS (basically on/off) function, mode fixup
-         (for converting requested modes into native hardware timings),
-         and prepare, set and commit functions for use by the core DRM
-         helper functions.  Connector helpers need to provide mode fetch and
-         validity functions as well as an encoder matching function for
-         returning an ideal encoder for a given connector.  The core
-         connector functions include a DPMS callback, (deprecated)
-         save/restore routines, detection, mode probing, property handling,
-         and cleanup functions.
+         Each encoder object needs to provide:
+         <itemizedlist>
+           <listitem>
+             A DPMS (basically on/off) function.
+           </listitem>
+           <listitem>
+             A mode-fixup function (for converting requested modes into
+             native hardware timings).
+           </listitem>
+           <listitem>
+             Functions (prepare, set, and commit) for use by the core DRM
+             helper functions.
+           </listitem>
+         </itemizedlist>
+         Connector helpers need to provide functions (mode-fetch, validity,
+         and encoder-matching) for returning an ideal encoder for a given
+         connector.  The core connector functions include a DPMS callback,
+         save/restore routines (deprecated), detection, mode probing,
+         property handling, and cleanup functions.
        </para>
 <!--!Edrivers/char/drm/drm_crtc.h-->
 <!--!Edrivers/char/drm/drm_crtc.c-->
@@ -603,22 +619,33 @@ void intel_crt_init(struct drm_device *dev)
     <title>VBlank event handling</title>
     <para>
       The DRM core exposes two vertical blank related ioctls:
-      DRM_IOCTL_WAIT_VBLANK and DRM_IOCTL_MODESET_CTL.
+      <variablelist>
+        <varlistentry>
+          <term>DRM_IOCTL_WAIT_VBLANK</term>
+          <listitem>
+            <para>
+              This takes a struct drm_wait_vblank structure as its argument,
+              and it is used to block or request a signal when a specified
+              vblank event occurs.
+            </para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>DRM_IOCTL_MODESET_CTL</term>
+          <listitem>
+            <para>
+              This should be called by application level drivers before and
+              after mode setting, since on many devices the vertical blank
+              counter is reset at that time.  Internally, the DRM snapshots
+              the last vblank count when the ioctl is called with the
+              _DRM_PRE_MODESET command, so that the counter won't go backwards
+              (which is dealt with when _DRM_POST_MODESET is used).
+            </para>
+          </listitem>
+        </varlistentry>
+      </variablelist>
 <!--!Edrivers/char/drm/drm_irq.c-->
     </para>
-    <para>
-      DRM_IOCTL_WAIT_VBLANK takes a struct drm_wait_vblank structure
-      as its argument, and is used to block or request a signal when a
-      specified vblank event occurs.
-    </para>
-    <para>
-      DRM_IOCTL_MODESET_CTL should be called by application level
-      drivers before and after mode setting, since on many devices, the
-      vertical blank counter is reset at that time.  Internally,
-      the DRM snapshots the last vblank count when the ioctl is called
-      with the _DRM_PRE_MODESET command so that the counter won't go
-      backwards (which is dealt with when _DRM_POST_MODESET is used).
-    </para>
     <para>
       To support the functions above, the DRM core provides several
       helper functions for tracking vertical blank counters, and
@@ -635,10 +662,10 @@ void intel_crt_init(struct drm_device *dev)
       a client calls the vblank wait ioctl above.
     </para>
     <para>
-      Devices that don't provide a count register may simply use an
+      A device that doesn't provide a count register may simply use an
       internal atomic counter incremented on every vertical blank
-      interrupt, and can make their enable and disable vblank
-      functions into no-ops.
+      interrupt (and then treat the enable_vblank() and disable_vblank()
+      callbacks as no-ops).
     </para>
   </sect1>
 
@@ -677,41 +704,46 @@ void intel_crt_init(struct drm_device *dev)
       <para>
        GEM-enabled drivers must provide gem_init_object() and
        gem_free_object() callbacks to support the core memory
-       allocation routines.  They should also provide several driver
-       specific ioctls to support command execution, pinning, buffer
+       allocation routines.  They should also provide several driver-specific
+       ioctls to support command execution, pinning, buffer
        read &amp; write, mapping, and domain ownership transfers.
       </para>
       <para>
-       On a fundamental level, GEM involves several operations: memory
-       allocation and freeing, command execution, and aperture management
-       at command execution time.  Buffer object allocation is relatively
+       On a fundamental level, GEM involves several operations:
+       <itemizedlist>
+         <listitem>Memory allocation and freeing</listitem>
+         <listitem>Command execution</listitem>
+         <listitem>Aperture management at command execution time</listitem>
+       </itemizedlist>
+       Buffer object allocation is relatively
        straightforward and largely provided by Linux's shmem layer, which
        provides memory to back each object.  When mapped into the GTT
        or used in a command buffer, the backing pages for an object are
        flushed to memory and marked write combined so as to be coherent
-       with the GPU.  Likewise, when the GPU finishes rendering to an object,
-       if the CPU accesses it, it must be made coherent with the CPU's view
+       with the GPU.  Likewise, if the CPU accesses an object after the GPU
+       has finished rendering to the object, then the object must be made
+       coherent with the CPU's view
        of memory, usually involving GPU cache flushing of various kinds.
-       This core CPU&lt;-&gt;GPU coherency management is provided by the GEM
-       set domain function, which evaluates an object's current domain and
+       This core CPU&lt;-&gt;GPU coherency management is provided by a
+       device-specific ioctl, which evaluates an object's current domain and
        performs any necessary flushing or synchronization to put the object
        into the desired coherency domain (note that the object may be busy,
-       i.e. an active render target; in that case, the set domain function
+       i.e. an active render target; in that case, setting the domain
        blocks the client and waits for rendering to complete before
        performing any necessary flushing operations).
       </para>
       <para>
        Perhaps the most important GEM function is providing a command
        execution interface to clients.  Client programs construct command
-       buffers containing references to previously allocated memory objects
-       and submit them to GEM.  At that point, GEM takes care to bind
+       buffers containing references to previously allocated memory objects,
+       and then submit them to GEM.  At that point, GEM takes care to bind
        all the objects into the GTT, execute the buffer, and provide
        necessary synchronization between clients accessing the same buffers.
        This often involves evicting some objects from the GTT and re-binding
        others (a fairly expensive operation), and providing relocation
        support which hides fixed GTT offsets from clients.  Clients must
        take care not to submit command buffers that reference more objects
-       than can fit in the GTT or GEM will reject them and no rendering
+       than can fit in the GTT; otherwise, GEM will reject them and no rendering
        will occur.  Similarly, if several objects in the buffer require
        fence registers to be allocated for correct rendering (e.g. 2D blits
        on pre-965 chips), care must be taken not to require more fence
@@ -763,21 +795,19 @@ void intel_crt_init(struct drm_device *dev)
   <sect1>
     <title>Framebuffer management</title>
     <para>
-      In order to set a mode on a given CRTC, encoder and connector
-      configuration, clients need to provide a framebuffer object which
-      provides a source of pixels for the CRTC to deliver to the encoder(s)
-      and ultimately the connector(s) in the configuration.  A framebuffer
-      is fundamentally a driver specific memory object, made into an opaque
-      handle by the DRM addfb function.  Once an fb has been created this
-      way it can be passed to the KMS mode setting routines for use in
-      a configuration.
+      Clients need to provide a framebuffer object which provides a source
+      of pixels for a CRTC to deliver to the encoder(s) and ultimately the
+      connector(s). A framebuffer is fundamentally a driver-specific memory
+      object, made into an opaque handle by the DRM's addfb() function.
+      Once a framebuffer has been created this way, it may be passed to the
+      KMS mode setting routines for use in a completed configuration.
     </para>
   </sect1>
 
   <sect1>
     <title>Command submission &amp; fencing</title>
     <para>
-      This should cover a few device specific command submission
+      This should cover a few device-specific command submission
       implementations.
     </para>
   </sect1>
@@ -810,8 +840,8 @@ void intel_crt_init(struct drm_device *dev)
     <para>
       The DRM core exports several interfaces to applications,
       generally intended to be used through corresponding libdrm
-      wrapper functions.  In addition, drivers export device specific
-      interfaces for use by userspace drivers &amp; device aware
+      wrapper functions.  In addition, drivers export device-specific
+      interfaces for use by userspace drivers &amp; device-aware
       applications through ioctls and sysfs files.
     </para>
     <para>
@@ -820,8 +850,8 @@ void intel_crt_init(struct drm_device *dev)
       management, memory management, and output management.
     </para>
     <para>
-      Cover generic ioctls and sysfs layout here.  Only need high
-      level info, since man pages should cover the rest.
+      Cover generic ioctls and sysfs layout here.  We only need high-level
+      info, since man pages should cover the rest.
     </para>
   </chapter>