diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2015-12-04 03:46:02 -0500 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2015-12-08 10:13:53 -0500 |
commit | 9953f41799bdad34c367196541a7a9a3b6e13a6c (patch) | |
tree | e62fed2a5d00212790419757a728e66b1e43dff5 /include/drm | |
parent | c6b0ca3ea8366d1954c7825d0f67bc833b8e10df (diff) |
drm: Kerneldoc for drm_mode_config_funcs
The meat here is definitely the detailed specs for what atomic_check
and atomic_commit are supposed to do.
And another candidate for a core vfunc that should be in a helper really
(output_poll_changed this time around).
v2: Feedback from Eric on irc:
- spelling fixes.
- spec what async should do
- copy the event related paragraphs from page_flip and adjust
- make it clear that a successful async commit is not allowed to leave
the pipe dead or disabled.
v3: Use FIXME comments to annotate functions that we should move to
some helpers.
v4: Suggestions from Thierry.
Cc: Eric Anholt <eric@anholt.net>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1449218769-16577-22-git-send-email-daniel.vetter@ffwll.ch
Reviewed-by: Thierry Reding <treding@nvidia.com>
Diffstat (limited to 'include/drm')
-rw-r--r-- | include/drm/drm_crtc.h | 243 |
1 files changed, 233 insertions, 10 deletions
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index f09391f9cac0..4f587a5bc88f 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h | |||
@@ -1715,31 +1715,254 @@ struct drm_mode_set { | |||
1715 | 1715 | ||
1716 | /** | 1716 | /** |
1717 | * struct drm_mode_config_funcs - basic driver provided mode setting functions | 1717 | * struct drm_mode_config_funcs - basic driver provided mode setting functions |
1718 | * @fb_create: create a new framebuffer object | ||
1719 | * @output_poll_changed: function to handle output configuration changes | ||
1720 | * @atomic_check: check whether a given atomic state update is possible | ||
1721 | * @atomic_commit: commit an atomic state update previously verified with | ||
1722 | * atomic_check() | ||
1723 | * @atomic_state_alloc: allocate a new atomic state | ||
1724 | * @atomic_state_clear: clear the atomic state | ||
1725 | * @atomic_state_free: free the atomic state | ||
1726 | * | 1718 | * |
1727 | * Some global (i.e. not per-CRTC, connector, etc) mode setting functions that | 1719 | * Some global (i.e. not per-CRTC, connector, etc) mode setting functions that |
1728 | * involve drivers. | 1720 | * involve drivers. |
1729 | */ | 1721 | */ |
1730 | struct drm_mode_config_funcs { | 1722 | struct drm_mode_config_funcs { |
1723 | /** | ||
1724 | * @fb_create: | ||
1725 | * | ||
1726 | * Create a new framebuffer object. The core does basic checks on the | ||
1727 | * requested metadata, but most of that is left to the driver. See | ||
1728 | * struct &drm_mode_fb_cmd2 for details. | ||
1729 | * | ||
1730 | * RETURNS: | ||
1731 | * | ||
1732 | * A new framebuffer with an initial reference count of 1 or a negative | ||
1733 | * error code encoded with ERR_PTR(). | ||
1734 | */ | ||
1731 | struct drm_framebuffer *(*fb_create)(struct drm_device *dev, | 1735 | struct drm_framebuffer *(*fb_create)(struct drm_device *dev, |
1732 | struct drm_file *file_priv, | 1736 | struct drm_file *file_priv, |
1733 | const struct drm_mode_fb_cmd2 *mode_cmd); | 1737 | const struct drm_mode_fb_cmd2 *mode_cmd); |
1738 | |||
1739 | /** | ||
1740 | * @output_poll_changed: | ||
1741 | * | ||
1742 | * Callback used by helpers to inform the driver of output configuration | ||
1743 | * changes. | ||
1744 | * | ||
1745 | * Drivers implementing fbdev emulation with the helpers can call | ||
1746 | * drm_fb_helper_hotplug_changed from this hook to inform the fbdev | ||
1747 | * helper of output changes. | ||
1748 | * | ||
1749 | * FIXME: | ||
1750 | * | ||
1751 | * Except that there's no vtable for device-level helper callbacks | ||
1752 | * there's no reason this is a core function. | ||
1753 | */ | ||
1734 | void (*output_poll_changed)(struct drm_device *dev); | 1754 | void (*output_poll_changed)(struct drm_device *dev); |
1735 | 1755 | ||
1756 | /** | ||
1757 | * @atomic_check: | ||
1758 | * | ||
1759 | * This is the only hook to validate an atomic modeset update. This | ||
1760 | * function must reject any modeset and state changes which the hardware | ||
1761 | * or driver doesn't support. This includes but is of course not limited | ||
1762 | * to: | ||
1763 | * | ||
1764 | * - Checking that the modes, framebuffers, scaling and placement | ||
1765 | * requirements and so on are within the limits of the hardware. | ||
1766 | * | ||
1767 | * - Checking that any hidden shared resources are not oversubscribed. | ||
1768 | * This can be shared PLLs, shared lanes, overall memory bandwidth, | ||
1769 | * display fifo space (where shared between planes or maybe even | ||
1770 | * CRTCs). | ||
1771 | * | ||
1772 | * - Checking that virtualized resources exported to userspace are not | ||
1773 | * oversubscribed. For various reasons it can make sense to expose | ||
1774 | * more planes, crtcs or encoders than which are physically there. One | ||
1775 | * example is dual-pipe operations (which generally should be hidden | ||
1776 | * from userspace if when lockstepped in hardware, exposed otherwise), | ||
1777 | * where a plane might need 1 hardware plane (if it's just on one | ||
1778 | * pipe), 2 hardware planes (when it spans both pipes) or maybe even | ||
1779 | * shared a hardware plane with a 2nd plane (if there's a compatible | ||
1780 | * plane requested on the area handled by the other pipe). | ||
1781 | * | ||
1782 | * - Check that any transitional state is possible and that if | ||
1783 | * requested, the update can indeed be done in the vblank period | ||
1784 | * without temporarily disabling some functions. | ||
1785 | * | ||
1786 | * - Check any other constraints the driver or hardware might have. | ||
1787 | * | ||
1788 | * - This callback also needs to correctly fill out the &drm_crtc_state | ||
1789 | * in this update to make sure that drm_atomic_crtc_needs_modeset() | ||
1790 | * reflects the nature of the possible update and returns true if and | ||
1791 | * only if the update cannot be applied without tearing within one | ||
1792 | * vblank on that CRTC. The core uses that information to reject | ||
1793 | * updates which require a full modeset (i.e. blanking the screen, or | ||
1794 | * at least pausing updates for a substantial amount of time) if | ||
1795 | * userspace has disallowed that in its request. | ||
1796 | * | ||
1797 | * - The driver also does not need to repeat basic input validation | ||
1798 | * like done for the corresponding legacy entry points. The core does | ||
1799 | * that before calling this hook. | ||
1800 | * | ||
1801 | * See the documentation of @atomic_commit for an exhaustive list of | ||
1802 | * error conditions which don't have to be checked at the | ||
1803 | * ->atomic_check() stage? | ||
1804 | * | ||
1805 | * See the documentation for struct &drm_atomic_state for how exactly | ||
1806 | * an atomic modeset update is described. | ||
1807 | * | ||
1808 | * Drivers using the atomic helpers can implement this hook using | ||
1809 | * drm_atomic_helper_check(), or one of the exported sub-functions of | ||
1810 | * it. | ||
1811 | * | ||
1812 | * RETURNS: | ||
1813 | * | ||
1814 | * 0 on success or one of the below negative error codes: | ||
1815 | * | ||
1816 | * - -EINVAL, if any of the above constraints are violated. | ||
1817 | * | ||
1818 | * - -EDEADLK, when returned from an attempt to acquire an additional | ||
1819 | * &drm_modeset_lock through drm_modeset_lock(). | ||
1820 | * | ||
1821 | * - -ENOMEM, if allocating additional state sub-structures failed due | ||
1822 | * to lack of memory. | ||
1823 | * | ||
1824 | * - -EINTR, -EAGAIN or -ERESTARTSYS, if the IOCTL should be restarted. | ||
1825 | * This can either be due to a pending signal, or because the driver | ||
1826 | * needs to completely bail out to recover from an exceptional | ||
1827 | * situation like a GPU hang. From a userspace point all errors are | ||
1828 | * treated equally. | ||
1829 | */ | ||
1736 | int (*atomic_check)(struct drm_device *dev, | 1830 | int (*atomic_check)(struct drm_device *dev, |
1737 | struct drm_atomic_state *a); | 1831 | struct drm_atomic_state *state); |
1832 | |||
1833 | /** | ||
1834 | * @atomic_commit: | ||
1835 | * | ||
1836 | * This is the only hook to commit an atomic modeset update. The core | ||
1837 | * guarantees that @atomic_check has been called successfully before | ||
1838 | * calling this function, and that nothing has been changed in the | ||
1839 | * interim. | ||
1840 | * | ||
1841 | * See the documentation for struct &drm_atomic_state for how exactly | ||
1842 | * an atomic modeset update is described. | ||
1843 | * | ||
1844 | * Drivers using the atomic helpers can implement this hook using | ||
1845 | * drm_atomic_helper_commit(), or one of the exported sub-functions of | ||
1846 | * it. | ||
1847 | * | ||
1848 | * Asynchronous commits (as indicated with the async parameter) must | ||
1849 | * do any preparatory work which might result in an unsuccessful commit | ||
1850 | * in the context of this callback. The only exceptions are hardware | ||
1851 | * errors resulting in -EIO. But even in that case the driver must | ||
1852 | * ensure that the display pipe is at least running, to avoid | ||
1853 | * compositors crashing when pageflips don't work. Anything else, | ||
1854 | * specifically committing the update to the hardware, should be done | ||
1855 | * without blocking the caller. For updates which do not require a | ||
1856 | * modeset this must be guaranteed. | ||
1857 | * | ||
1858 | * The driver must wait for any pending rendering to the new | ||
1859 | * framebuffers to complete before executing the flip. It should also | ||
1860 | * wait for any pending rendering from other drivers if the underlying | ||
1861 | * buffer is a shared dma-buf. Asynchronous commits must not wait for | ||
1862 | * rendering in the context of this callback. | ||
1863 | * | ||
1864 | * An application can request to be notified when the atomic commit has | ||
1865 | * completed. These events are per-CRTC and can be distinguished by the | ||
1866 | * CRTC index supplied in &drm_event to userspace. | ||
1867 | * | ||
1868 | * The drm core will supply a struct &drm_event in the event | ||
1869 | * member of each CRTC's &drm_crtc_state structure. This can be handled by the | ||
1870 | * drm_crtc_send_vblank_event() function, which the driver should call on | ||
1871 | * the provided event upon completion of the atomic commit. Note that if | ||
1872 | * the driver supports vblank signalling and timestamping the vblank | ||
1873 | * counters and timestamps must agree with the ones returned from page | ||
1874 | * flip events. With the current vblank helper infrastructure this can | ||
1875 | * be achieved by holding a vblank reference while the page flip is | ||
1876 | * pending, acquired through drm_crtc_vblank_get() and released with | ||
1877 | * drm_crtc_vblank_put(). Drivers are free to implement their own vblank | ||
1878 | * counter and timestamp tracking though, e.g. if they have accurate | ||
1879 | * timestamp registers in hardware. | ||
1880 | * | ||
1881 | * NOTE: | ||
1882 | * | ||
1883 | * Drivers are not allowed to shut down any display pipe successfully | ||
1884 | * enabled through an atomic commit on their own. Doing so can result in | ||
1885 | * compositors crashing if a page flip is suddenly rejected because the | ||
1886 | * pipe is off. | ||
1887 | * | ||
1888 | * RETURNS: | ||
1889 | * | ||
1890 | * 0 on success or one of the below negative error codes: | ||
1891 | * | ||
1892 | * - -EBUSY, if an asynchronous updated is requested and there is | ||
1893 | * an earlier updated pending. Drivers are allowed to support a queue | ||
1894 | * of outstanding updates, but currently no driver supports that. | ||
1895 | * Note that drivers must wait for preceding updates to complete if a | ||
1896 | * synchronous update is requested, they are not allowed to fail the | ||
1897 | * commit in that case. | ||
1898 | * | ||
1899 | * - -ENOMEM, if the driver failed to allocate memory. Specifically | ||
1900 | * this can happen when trying to pin framebuffers, which must only | ||
1901 | * be done when committing the state. | ||
1902 | * | ||
1903 | * - -ENOSPC, as a refinement of the more generic -ENOMEM to indicate | ||
1904 | * that the driver has run out of vram, iommu space or similar GPU | ||
1905 | * address space needed for framebuffer. | ||
1906 | * | ||
1907 | * - -EIO, if the hardware completely died. | ||
1908 | * | ||
1909 | * - -EINTR, -EAGAIN or -ERESTARTSYS, if the IOCTL should be restarted. | ||
1910 | * This can either be due to a pending signal, or because the driver | ||
1911 | * needs to completely bail out to recover from an exceptional | ||
1912 | * situation like a GPU hang. From a userspace point of view all errors are | ||
1913 | * treated equally. | ||
1914 | * | ||
1915 | * This list is exhaustive. Specifically this hook is not allowed to | ||
1916 | * return -EINVAL (any invalid requests should be caught in | ||
1917 | * @atomic_check) or -EDEADLK (this function must not acquire | ||
1918 | * additional modeset locks). | ||
1919 | */ | ||
1738 | int (*atomic_commit)(struct drm_device *dev, | 1920 | int (*atomic_commit)(struct drm_device *dev, |
1739 | struct drm_atomic_state *a, | 1921 | struct drm_atomic_state *state, |
1740 | bool async); | 1922 | bool async); |
1923 | |||
1924 | /** | ||
1925 | * @atomic_state_alloc: | ||
1926 | * | ||
1927 | * This optional hook can be used by drivers that want to subclass struct | ||
1928 | * &drm_atomic_state to be able to track their own driver-private global | ||
1929 | * state easily. If this hook is implemented, drivers must also | ||
1930 | * implement @atomic_state_clear and @atomic_state_free. | ||
1931 | * | ||
1932 | * RETURNS: | ||
1933 | * | ||
1934 | * A new &drm_atomic_state on success or NULL on failure. | ||
1935 | */ | ||
1741 | struct drm_atomic_state *(*atomic_state_alloc)(struct drm_device *dev); | 1936 | struct drm_atomic_state *(*atomic_state_alloc)(struct drm_device *dev); |
1937 | |||
1938 | /** | ||
1939 | * @atomic_state_clear: | ||
1940 | * | ||
1941 | * This hook must clear any driver private state duplicated into the | ||
1942 | * passed-in &drm_atomic_state. This hook is called when the caller | ||
1943 | * encountered a &drm_modeset_lock deadlock and needs to drop all | ||
1944 | * already acquired locks as part of the deadlock avoidance dance | ||
1945 | * implemented in drm_modeset_lock_backoff(). | ||
1946 | * | ||
1947 | * Any duplicated state must be invalidated since a concurrent atomic | ||
1948 | * update might change it, and the drm atomic interfaces always apply | ||
1949 | * updates as relative changes to the current state. | ||
1950 | * | ||
1951 | * Drivers that implement this must call drm_atomic_state_default_clear() | ||
1952 | * to clear common state. | ||
1953 | */ | ||
1742 | void (*atomic_state_clear)(struct drm_atomic_state *state); | 1954 | void (*atomic_state_clear)(struct drm_atomic_state *state); |
1955 | |||
1956 | /** | ||
1957 | * @atomic_state_free: | ||
1958 | * | ||
1959 | * This hook needs driver private resources and the &drm_atomic_state | ||
1960 | * itself. Note that the core first calls drm_atomic_state_clear() to | ||
1961 | * avoid code duplicate between the clear and free hooks. | ||
1962 | * | ||
1963 | * Drivers that implement this must call drm_atomic_state_default_free() | ||
1964 | * to release common resources. | ||
1965 | */ | ||
1743 | void (*atomic_state_free)(struct drm_atomic_state *state); | 1966 | void (*atomic_state_free)(struct drm_atomic_state *state); |
1744 | }; | 1967 | }; |
1745 | 1968 | ||