diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2016-01-04 01:53:36 -0500 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2016-01-05 10:21:35 -0500 |
commit | df7d678bea8ba8904bdb293c8e96aa9488f7dbee (patch) | |
tree | a3b9ad6d31b65713b25062e236e8dd2ac24d3fd5 | |
parent | 4cba68507cf58db99752cf79198beb4a85a9f8ce (diff) |
drm/docs: more leftovers from the big vtable documentation pile
Another pile of vfuncs from the old gpu.tmpl xml documentation that
I've forgotten to delete. I spotted a few more things to
clarify/extend in the new kerneldoc while going through this once
more.
v2: Spelling fixes (Thierry).
v3: More spelling fixes and use Thierry's proposal to clarify why
drivers need to validate modes both in ->mode_fixup and ->mode_valid.
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Thierry Reding <treding@nvidia.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
-rw-r--r-- | Documentation/DocBook/gpu.tmpl | 188 | ||||
-rw-r--r-- | include/drm/drm_modeset_helper_vtables.h | 44 |
2 files changed, 41 insertions, 191 deletions
diff --git a/Documentation/DocBook/gpu.tmpl b/Documentation/DocBook/gpu.tmpl index 225a246c5f53..faa5e0d4208d 100644 --- a/Documentation/DocBook/gpu.tmpl +++ b/Documentation/DocBook/gpu.tmpl | |||
@@ -1579,194 +1579,6 @@ void intel_crt_init(struct drm_device *dev) | |||
1579 | entities. | 1579 | entities. |
1580 | </para> | 1580 | </para> |
1581 | <sect2> | 1581 | <sect2> |
1582 | <title>Legacy CRTC Helper Operations</title> | ||
1583 | <itemizedlist> | ||
1584 | <listitem id="drm-helper-crtc-mode-fixup"> | ||
1585 | <synopsis>bool (*mode_fixup)(struct drm_crtc *crtc, | ||
1586 | const struct drm_display_mode *mode, | ||
1587 | struct drm_display_mode *adjusted_mode);</synopsis> | ||
1588 | <para> | ||
1589 | Let CRTCs adjust the requested mode or reject it completely. This | ||
1590 | operation returns true if the mode is accepted (possibly after being | ||
1591 | adjusted) or false if it is rejected. | ||
1592 | </para> | ||
1593 | <para> | ||
1594 | The <methodname>mode_fixup</methodname> operation should reject the | ||
1595 | mode if it can't reasonably use it. The definition of "reasonable" | ||
1596 | is currently fuzzy in this context. One possible behaviour would be | ||
1597 | to set the adjusted mode to the panel timings when a fixed-mode | ||
1598 | panel is used with hardware capable of scaling. Another behaviour | ||
1599 | would be to accept any input mode and adjust it to the closest mode | ||
1600 | supported by the hardware (FIXME: This needs to be clarified). | ||
1601 | </para> | ||
1602 | </listitem> | ||
1603 | <listitem> | ||
1604 | <synopsis>int (*mode_set_base)(struct drm_crtc *crtc, int x, int y, | ||
1605 | struct drm_framebuffer *old_fb)</synopsis> | ||
1606 | <para> | ||
1607 | Move the CRTC on the current frame buffer (stored in | ||
1608 | <literal>crtc->fb</literal>) to position (x,y). Any of the frame | ||
1609 | buffer, x position or y position may have been modified. | ||
1610 | </para> | ||
1611 | <para> | ||
1612 | This helper operation is optional. If not provided, the | ||
1613 | <function>drm_crtc_helper_set_config</function> function will fall | ||
1614 | back to the <methodname>mode_set</methodname> helper operation. | ||
1615 | </para> | ||
1616 | <note><para> | ||
1617 | FIXME: Why are x and y passed as arguments, as they can be accessed | ||
1618 | through <literal>crtc->x</literal> and | ||
1619 | <literal>crtc->y</literal>? | ||
1620 | </para></note> | ||
1621 | </listitem> | ||
1622 | <listitem> | ||
1623 | <synopsis>void (*prepare)(struct drm_crtc *crtc);</synopsis> | ||
1624 | <para> | ||
1625 | Prepare the CRTC for mode setting. This operation is called after | ||
1626 | validating the requested mode. Drivers use it to perform | ||
1627 | device-specific operations required before setting the new mode. | ||
1628 | </para> | ||
1629 | </listitem> | ||
1630 | <listitem> | ||
1631 | <synopsis>int (*mode_set)(struct drm_crtc *crtc, struct drm_display_mode *mode, | ||
1632 | struct drm_display_mode *adjusted_mode, int x, int y, | ||
1633 | struct drm_framebuffer *old_fb);</synopsis> | ||
1634 | <para> | ||
1635 | Set a new mode, position and frame buffer. Depending on the device | ||
1636 | requirements, the mode can be stored internally by the driver and | ||
1637 | applied in the <methodname>commit</methodname> operation, or | ||
1638 | programmed to the hardware immediately. | ||
1639 | </para> | ||
1640 | <para> | ||
1641 | The <methodname>mode_set</methodname> operation returns 0 on success | ||
1642 | or a negative error code if an error occurs. | ||
1643 | </para> | ||
1644 | </listitem> | ||
1645 | <listitem> | ||
1646 | <synopsis>void (*commit)(struct drm_crtc *crtc);</synopsis> | ||
1647 | <para> | ||
1648 | Commit a mode. This operation is called after setting the new mode. | ||
1649 | Upon return the device must use the new mode and be fully | ||
1650 | operational. | ||
1651 | </para> | ||
1652 | </listitem> | ||
1653 | </itemizedlist> | ||
1654 | </sect2> | ||
1655 | <sect2> | ||
1656 | <title>Encoder Helper Operations</title> | ||
1657 | <itemizedlist> | ||
1658 | <listitem> | ||
1659 | <synopsis>bool (*mode_fixup)(struct drm_encoder *encoder, | ||
1660 | const struct drm_display_mode *mode, | ||
1661 | struct drm_display_mode *adjusted_mode);</synopsis> | ||
1662 | <para> | ||
1663 | Let encoders adjust the requested mode or reject it completely. This | ||
1664 | operation returns true if the mode is accepted (possibly after being | ||
1665 | adjusted) or false if it is rejected. See the | ||
1666 | <link linkend="drm-helper-crtc-mode-fixup">mode_fixup CRTC helper | ||
1667 | operation</link> for an explanation of the allowed adjustments. | ||
1668 | </para> | ||
1669 | </listitem> | ||
1670 | <listitem> | ||
1671 | <synopsis>void (*prepare)(struct drm_encoder *encoder);</synopsis> | ||
1672 | <para> | ||
1673 | Prepare the encoder for mode setting. This operation is called after | ||
1674 | validating the requested mode. Drivers use it to perform | ||
1675 | device-specific operations required before setting the new mode. | ||
1676 | </para> | ||
1677 | </listitem> | ||
1678 | <listitem> | ||
1679 | <synopsis>void (*mode_set)(struct drm_encoder *encoder, | ||
1680 | struct drm_display_mode *mode, | ||
1681 | struct drm_display_mode *adjusted_mode);</synopsis> | ||
1682 | <para> | ||
1683 | Set a new mode. Depending on the device requirements, the mode can | ||
1684 | be stored internally by the driver and applied in the | ||
1685 | <methodname>commit</methodname> operation, or programmed to the | ||
1686 | hardware immediately. | ||
1687 | </para> | ||
1688 | </listitem> | ||
1689 | <listitem> | ||
1690 | <synopsis>void (*commit)(struct drm_encoder *encoder);</synopsis> | ||
1691 | <para> | ||
1692 | Commit a mode. This operation is called after setting the new mode. | ||
1693 | Upon return the device must use the new mode and be fully | ||
1694 | operational. | ||
1695 | </para> | ||
1696 | </listitem> | ||
1697 | </itemizedlist> | ||
1698 | </sect2> | ||
1699 | <sect2> | ||
1700 | <title>Connector Helper Operations</title> | ||
1701 | <itemizedlist> | ||
1702 | <listitem> | ||
1703 | <synopsis>struct drm_encoder *(*best_encoder)(struct drm_connector *connector);</synopsis> | ||
1704 | <para> | ||
1705 | Return a pointer to the best encoder for the connecter. Device that | ||
1706 | map connectors to encoders 1:1 simply return the pointer to the | ||
1707 | associated encoder. This operation is mandatory. | ||
1708 | </para> | ||
1709 | </listitem> | ||
1710 | <listitem> | ||
1711 | <synopsis>int (*get_modes)(struct drm_connector *connector);</synopsis> | ||
1712 | <para> | ||
1713 | Fill the connector's <structfield>probed_modes</structfield> list | ||
1714 | by parsing EDID data with <function>drm_add_edid_modes</function>, | ||
1715 | adding standard VESA DMT modes with <function>drm_add_modes_noedid</function>, | ||
1716 | or calling <function>drm_mode_probed_add</function> directly for every | ||
1717 | supported mode and return the number of modes it has detected. This | ||
1718 | operation is mandatory. | ||
1719 | </para> | ||
1720 | <para> | ||
1721 | Note that the caller function will automatically add standard VESA | ||
1722 | DMT modes up to 1024x768 if the <methodname>get_modes</methodname> | ||
1723 | helper operation returns no mode and if the connector status is | ||
1724 | connector_status_connected. There is no need to call | ||
1725 | <function>drm_add_edid_modes</function> manually in that case. | ||
1726 | </para> | ||
1727 | <para> | ||
1728 | The <structfield>vrefresh</structfield> value is computed by | ||
1729 | <function>drm_helper_probe_single_connector_modes</function>. | ||
1730 | </para> | ||
1731 | <para> | ||
1732 | When parsing EDID data, <function>drm_add_edid_modes</function> fills the | ||
1733 | connector <structfield>display_info</structfield> | ||
1734 | <structfield>width_mm</structfield> and | ||
1735 | <structfield>height_mm</structfield> fields. When creating modes | ||
1736 | manually the <methodname>get_modes</methodname> helper operation must | ||
1737 | set the <structfield>display_info</structfield> | ||
1738 | <structfield>width_mm</structfield> and | ||
1739 | <structfield>height_mm</structfield> fields if they haven't been set | ||
1740 | already (for instance at initialization time when a fixed-size panel is | ||
1741 | attached to the connector). The mode <structfield>width_mm</structfield> | ||
1742 | and <structfield>height_mm</structfield> fields are only used internally | ||
1743 | during EDID parsing and should not be set when creating modes manually. | ||
1744 | </para> | ||
1745 | </listitem> | ||
1746 | <listitem> | ||
1747 | <synopsis>int (*mode_valid)(struct drm_connector *connector, | ||
1748 | struct drm_display_mode *mode);</synopsis> | ||
1749 | <para> | ||
1750 | Verify whether a mode is valid for the connector. Return MODE_OK for | ||
1751 | supported modes and one of the enum drm_mode_status values (MODE_*) | ||
1752 | for unsupported modes. This operation is optional. | ||
1753 | </para> | ||
1754 | <para> | ||
1755 | As the mode rejection reason is currently not used beside for | ||
1756 | immediately removing the unsupported mode, an implementation can | ||
1757 | return MODE_BAD regardless of the exact reason why the mode is not | ||
1758 | valid. | ||
1759 | </para> | ||
1760 | <note><para> | ||
1761 | Note that the <methodname>mode_valid</methodname> helper operation is | ||
1762 | only called for modes detected by the device, and | ||
1763 | <emphasis>not</emphasis> for modes set by the user through the CRTC | ||
1764 | <methodname>set_config</methodname> operation. | ||
1765 | </para></note> | ||
1766 | </listitem> | ||
1767 | </itemizedlist> | ||
1768 | </sect2> | ||
1769 | <sect2> | ||
1770 | <title>Atomic Modeset Helper Functions Reference</title> | 1582 | <title>Atomic Modeset Helper Functions Reference</title> |
1771 | <sect3> | 1583 | <sect3> |
1772 | <title>Overview</title> | 1584 | <title>Overview</title> |
diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h index 29e0dc50031d..a126a0d7aed4 100644 --- a/include/drm/drm_modeset_helper_vtables.h +++ b/include/drm/drm_modeset_helper_vtables.h | |||
@@ -131,6 +131,20 @@ struct drm_crtc_helper_funcs { | |||
131 | * Atomic drivers which need to inspect and adjust more state should | 131 | * Atomic drivers which need to inspect and adjust more state should |
132 | * instead use the @atomic_check callback. | 132 | * instead use the @atomic_check callback. |
133 | * | 133 | * |
134 | * Also beware that neither core nor helpers filter modes before | ||
135 | * passing them to the driver: While the list of modes that is | ||
136 | * advertised to userspace is filtered using the connector's | ||
137 | * ->mode_valid() callback, neither the core nor the helpers do any | ||
138 | * filtering on modes passed in from userspace when setting a mode. It | ||
139 | * is therefore possible for userspace to pass in a mode that was | ||
140 | * previously filtered out using ->mode_valid() or add a custom mode | ||
141 | * that wasn't probed from EDID or similar to begin with. Even though | ||
142 | * this is an advanced feature and rarely used nowadays, some users rely | ||
143 | * on being able to specify modes manually so drivers must be prepared | ||
144 | * to deal with it. Specifically this means that all drivers need not | ||
145 | * only validate modes in ->mode_valid() but also in ->mode_fixup() to | ||
146 | * make sure invalid modes passed in from userspace are rejected. | ||
147 | * | ||
134 | * RETURNS: | 148 | * RETURNS: |
135 | * | 149 | * |
136 | * True if an acceptable configuration is possible, false if the modeset | 150 | * True if an acceptable configuration is possible, false if the modeset |
@@ -188,7 +202,9 @@ struct drm_crtc_helper_funcs { | |||
188 | * This callback is used by the legacy CRTC helpers to set a new | 202 | * This callback is used by the legacy CRTC helpers to set a new |
189 | * framebuffer and scanout position. It is optional and used as an | 203 | * framebuffer and scanout position. It is optional and used as an |
190 | * optimized fast-path instead of a full mode set operation with all the | 204 | * optimized fast-path instead of a full mode set operation with all the |
191 | * resulting flickering. Since it can't update other planes it's | 205 | * resulting flickering. If it is not present |
206 | * drm_crtc_helper_set_config() will fall back to a full modeset, using | ||
207 | * the ->mode_set() callback. Since it can't update other planes it's | ||
192 | * incompatible with atomic modeset support. | 208 | * incompatible with atomic modeset support. |
193 | * | 209 | * |
194 | * This callback is only used by the CRTC helpers and deprecated. | 210 | * This callback is only used by the CRTC helpers and deprecated. |
@@ -439,6 +455,20 @@ struct drm_encoder_helper_funcs { | |||
439 | * Atomic drivers which need to inspect and adjust more state should | 455 | * Atomic drivers which need to inspect and adjust more state should |
440 | * instead use the @atomic_check callback. | 456 | * instead use the @atomic_check callback. |
441 | * | 457 | * |
458 | * Also beware that neither core nor helpers filter modes before | ||
459 | * passing them to the driver: While the list of modes that is | ||
460 | * advertised to userspace is filtered using the connector's | ||
461 | * ->mode_valid() callback, neither the core nor the helpers do any | ||
462 | * filtering on modes passed in from userspace when setting a mode. It | ||
463 | * is therefore possible for userspace to pass in a mode that was | ||
464 | * previously filtered out using ->mode_valid() or add a custom mode | ||
465 | * that wasn't probed from EDID or similar to begin with. Even though | ||
466 | * this is an advanced feature and rarely used nowadays, some users rely | ||
467 | * on being able to specify modes manually so drivers must be prepared | ||
468 | * to deal with it. Specifically this means that all drivers need not | ||
469 | * only validate modes in ->mode_valid() but also in ->mode_fixup() to | ||
470 | * make sure invalid modes passed in from userspace are rejected. | ||
471 | * | ||
442 | * RETURNS: | 472 | * RETURNS: |
443 | * | 473 | * |
444 | * True if an acceptable configuration is possible, false if the modeset | 474 | * True if an acceptable configuration is possible, false if the modeset |
@@ -640,8 +670,16 @@ struct drm_connector_helper_funcs { | |||
640 | * In this function drivers then parse the modes in the EDID and add | 670 | * In this function drivers then parse the modes in the EDID and add |
641 | * them by calling drm_add_edid_modes(). But connectors that driver a | 671 | * them by calling drm_add_edid_modes(). But connectors that driver a |
642 | * fixed panel can also manually add specific modes using | 672 | * fixed panel can also manually add specific modes using |
643 | * drm_mode_probed_add(). Finally drivers that support audio probably | 673 | * drm_mode_probed_add(). Drivers which manually add modes should also |
644 | * want to update the ELD data, too, using drm_edid_to_eld(). | 674 | * make sure that the @display_info, @width_mm and @height_mm fields of the |
675 | * struct #drm_connector are filled in. | ||
676 | * | ||
677 | * Virtual drivers that just want some standard VESA mode with a given | ||
678 | * resolution can call drm_add_modes_noedid(), and mark the preferred | ||
679 | * one using drm_set_preferred_mode(). | ||
680 | * | ||
681 | * Finally drivers that support audio probably want to update the ELD | ||
682 | * data, too, using drm_edid_to_eld(). | ||
645 | * | 683 | * |
646 | * This function is only called after the ->detect() hook has indicated | 684 | * This function is only called after the ->detect() hook has indicated |
647 | * that a sink is connected and when the EDID isn't overridden through | 685 | * that a sink is connected and when the EDID isn't overridden through |