diff options
Diffstat (limited to 'Documentation/DocBook/drm.tmpl')
-rw-r--r-- | Documentation/DocBook/drm.tmpl | 117 |
1 files changed, 86 insertions, 31 deletions
diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index b0300529ab13..f9df3b872c16 100644 --- a/Documentation/DocBook/drm.tmpl +++ b/Documentation/DocBook/drm.tmpl | |||
@@ -743,6 +743,10 @@ char *date;</synopsis> | |||
743 | These two operations are mandatory for GEM drivers that support DRM | 743 | These two operations are mandatory for GEM drivers that support DRM |
744 | PRIME. | 744 | PRIME. |
745 | </para> | 745 | </para> |
746 | <sect4> | ||
747 | <title>DRM PRIME Helper Functions Reference</title> | ||
748 | !Pdrivers/gpu/drm/drm_prime.c PRIME Helpers | ||
749 | </sect4> | ||
746 | </sect3> | 750 | </sect3> |
747 | <sect3 id="drm-gem-objects-mapping"> | 751 | <sect3 id="drm-gem-objects-mapping"> |
748 | <title>GEM Objects Mapping</title> | 752 | <title>GEM Objects Mapping</title> |
@@ -978,10 +982,25 @@ int max_width, max_height;</synopsis> | |||
978 | If the parameters are deemed valid, drivers then create, initialize and | 982 | If the parameters are deemed valid, drivers then create, initialize and |
979 | return an instance of struct <structname>drm_framebuffer</structname>. | 983 | return an instance of struct <structname>drm_framebuffer</structname>. |
980 | If desired the instance can be embedded in a larger driver-specific | 984 | If desired the instance can be embedded in a larger driver-specific |
981 | structure. The new instance is initialized with a call to | 985 | structure. Drivers must fill its <structfield>width</structfield>, |
982 | <function>drm_framebuffer_init</function> which takes a pointer to DRM | 986 | <structfield>height</structfield>, <structfield>pitches</structfield>, |
983 | frame buffer operations (struct | 987 | <structfield>offsets</structfield>, <structfield>depth</structfield>, |
984 | <structname>drm_framebuffer_funcs</structname>). Frame buffer operations are | 988 | <structfield>bits_per_pixel</structfield> and |
989 | <structfield>pixel_format</structfield> fields from the values passed | ||
990 | through the <parameter>drm_mode_fb_cmd2</parameter> argument. They | ||
991 | should call the <function>drm_helper_mode_fill_fb_struct</function> | ||
992 | helper function to do so. | ||
993 | </para> | ||
994 | |||
995 | <para> | ||
996 | The initailization of the new framebuffer instance is finalized with a | ||
997 | call to <function>drm_framebuffer_init</function> which takes a pointer | ||
998 | to DRM frame buffer operations (struct | ||
999 | <structname>drm_framebuffer_funcs</structname>). Note that this function | ||
1000 | publishes the framebuffer and so from this point on it can be accessed | ||
1001 | concurrently from other threads. Hence it must be the last step in the | ||
1002 | driver's framebuffer initialization sequence. Frame buffer operations | ||
1003 | are | ||
985 | <itemizedlist> | 1004 | <itemizedlist> |
986 | <listitem> | 1005 | <listitem> |
987 | <synopsis>int (*create_handle)(struct drm_framebuffer *fb, | 1006 | <synopsis>int (*create_handle)(struct drm_framebuffer *fb, |
@@ -1022,16 +1041,16 @@ int max_width, max_height;</synopsis> | |||
1022 | </itemizedlist> | 1041 | </itemizedlist> |
1023 | </para> | 1042 | </para> |
1024 | <para> | 1043 | <para> |
1025 | After initializing the <structname>drm_framebuffer</structname> | 1044 | The lifetime of a drm framebuffer is controlled with a reference count, |
1026 | instance drivers must fill its <structfield>width</structfield>, | 1045 | drivers can grab additional references with |
1027 | <structfield>height</structfield>, <structfield>pitches</structfield>, | 1046 | <function>drm_framebuffer_reference</function> </para> and drop them |
1028 | <structfield>offsets</structfield>, <structfield>depth</structfield>, | 1047 | again with <function>drm_framebuffer_unreference</function>. For |
1029 | <structfield>bits_per_pixel</structfield> and | 1048 | driver-private framebuffers for which the last reference is never |
1030 | <structfield>pixel_format</structfield> fields from the values passed | 1049 | dropped (e.g. for the fbdev framebuffer when the struct |
1031 | through the <parameter>drm_mode_fb_cmd2</parameter> argument. They | 1050 | <structname>drm_framebuffer</structname> is embedded into the fbdev |
1032 | should call the <function>drm_helper_mode_fill_fb_struct</function> | 1051 | helper struct) drivers can manually clean up a framebuffer at module |
1033 | helper function to do so. | 1052 | unload time with |
1034 | </para> | 1053 | <function>drm_framebuffer_unregister_private</function>. |
1035 | </sect2> | 1054 | </sect2> |
1036 | <sect2> | 1055 | <sect2> |
1037 | <title>Output Polling</title> | 1056 | <title>Output Polling</title> |
@@ -1043,6 +1062,22 @@ int max_width, max_height;</synopsis> | |||
1043 | operation. | 1062 | operation. |
1044 | </para> | 1063 | </para> |
1045 | </sect2> | 1064 | </sect2> |
1065 | <sect2> | ||
1066 | <title>Locking</title> | ||
1067 | <para> | ||
1068 | Beside some lookup structures with their own locking (which is hidden | ||
1069 | behind the interface functions) most of the modeset state is protected | ||
1070 | by the <code>dev-<mode_config.lock</code> mutex and additionally | ||
1071 | per-crtc locks to allow cursor updates, pageflips and similar operations | ||
1072 | to occur concurrently with background tasks like output detection. | ||
1073 | Operations which cross domains like a full modeset always grab all | ||
1074 | locks. Drivers there need to protect resources shared between crtcs with | ||
1075 | additional locking. They also need to be careful to always grab the | ||
1076 | relevant crtc locks if a modset functions touches crtc state, e.g. for | ||
1077 | load detection (which does only grab the <code>mode_config.lock</code> | ||
1078 | to allow concurrent screen updates on live crtcs). | ||
1079 | </para> | ||
1080 | </sect2> | ||
1046 | </sect1> | 1081 | </sect1> |
1047 | 1082 | ||
1048 | <!-- Internals: kms initialization and cleanup --> | 1083 | <!-- Internals: kms initialization and cleanup --> |
@@ -1126,6 +1161,12 @@ int max_width, max_height;</synopsis> | |||
1126 | any new rendering to the frame buffer until the page flip completes. | 1161 | any new rendering to the frame buffer until the page flip completes. |
1127 | </para> | 1162 | </para> |
1128 | <para> | 1163 | <para> |
1164 | If a page flip can be successfully scheduled the driver must set the | ||
1165 | <code>drm_crtc-<fb</code> field to the new framebuffer pointed to | ||
1166 | by <code>fb</code>. This is important so that the reference counting | ||
1167 | on framebuffers stays balanced. | ||
1168 | </para> | ||
1169 | <para> | ||
1129 | If a page flip is already pending, the | 1170 | If a page flip is already pending, the |
1130 | <methodname>page_flip</methodname> operation must return | 1171 | <methodname>page_flip</methodname> operation must return |
1131 | -<errorname>EBUSY</errorname>. | 1172 | -<errorname>EBUSY</errorname>. |
@@ -1141,23 +1182,13 @@ int max_width, max_height;</synopsis> | |||
1141 | the <methodname>page_flip</methodname> operation will be called with a | 1182 | the <methodname>page_flip</methodname> operation will be called with a |
1142 | non-NULL <parameter>event</parameter> argument pointing to a | 1183 | non-NULL <parameter>event</parameter> argument pointing to a |
1143 | <structname>drm_pending_vblank_event</structname> instance. Upon page | 1184 | <structname>drm_pending_vblank_event</structname> instance. Upon page |
1144 | flip completion the driver must fill the | 1185 | flip completion the driver must call <methodname>drm_send_vblank_event</methodname> |
1145 | <parameter>event</parameter>::<structfield>event</structfield> | 1186 | to fill in the event and send to wake up any waiting processes. |
1146 | <structfield>sequence</structfield>, <structfield>tv_sec</structfield> | 1187 | This can be performed with |
1147 | and <structfield>tv_usec</structfield> fields with the associated | ||
1148 | vertical blanking count and timestamp, add the event to the | ||
1149 | <parameter>drm_file</parameter> list of events to be signaled, and wake | ||
1150 | up any waiting process. This can be performed with | ||
1151 | <programlisting><![CDATA[ | 1188 | <programlisting><![CDATA[ |
1152 | struct timeval now; | ||
1153 | |||
1154 | event->event.sequence = drm_vblank_count_and_time(..., &now); | ||
1155 | event->event.tv_sec = now.tv_sec; | ||
1156 | event->event.tv_usec = now.tv_usec; | ||
1157 | |||
1158 | spin_lock_irqsave(&dev->event_lock, flags); | 1189 | spin_lock_irqsave(&dev->event_lock, flags); |
1159 | list_add_tail(&event->base.link, &event->base.file_priv->event_list); | 1190 | ... |
1160 | wake_up_interruptible(&event->base.file_priv->event_wait); | 1191 | drm_send_vblank_event(dev, pipe, event); |
1161 | spin_unlock_irqrestore(&dev->event_lock, flags); | 1192 | spin_unlock_irqrestore(&dev->event_lock, flags); |
1162 | ]]></programlisting> | 1193 | ]]></programlisting> |
1163 | </para> | 1194 | </para> |
@@ -1619,12 +1650,16 @@ void intel_crt_init(struct drm_device *dev) | |||
1619 | make its properties available to applications. | 1650 | make its properties available to applications. |
1620 | </para> | 1651 | </para> |
1621 | </sect2> | 1652 | </sect2> |
1653 | <sect2> | ||
1654 | <title>KMS API Functions</title> | ||
1655 | !Edrivers/gpu/drm/drm_crtc.c | ||
1656 | </sect2> | ||
1622 | </sect1> | 1657 | </sect1> |
1623 | 1658 | ||
1624 | <!-- Internals: mid-layer helper functions --> | 1659 | <!-- Internals: kms helper functions --> |
1625 | 1660 | ||
1626 | <sect1> | 1661 | <sect1> |
1627 | <title>Mid-layer Helper Functions</title> | 1662 | <title>Mode Setting Helper Functions</title> |
1628 | <para> | 1663 | <para> |
1629 | The CRTC, encoder and connector functions provided by the drivers | 1664 | The CRTC, encoder and connector functions provided by the drivers |
1630 | implement the DRM API. They're called by the DRM core and ioctl handlers | 1665 | implement the DRM API. They're called by the DRM core and ioctl handlers |
@@ -2106,6 +2141,26 @@ void intel_crt_init(struct drm_device *dev) | |||
2106 | </listitem> | 2141 | </listitem> |
2107 | </itemizedlist> | 2142 | </itemizedlist> |
2108 | </sect2> | 2143 | </sect2> |
2144 | <sect2> | ||
2145 | <title>Modeset Helper Functions Reference</title> | ||
2146 | !Edrivers/gpu/drm/drm_crtc_helper.c | ||
2147 | </sect2> | ||
2148 | <sect2> | ||
2149 | <title>fbdev Helper Functions Reference</title> | ||
2150 | !Pdrivers/gpu/drm/drm_fb_helper.c fbdev helpers | ||
2151 | !Edrivers/gpu/drm/drm_fb_helper.c | ||
2152 | !Iinclude/drm/drm_fb_helper.h | ||
2153 | </sect2> | ||
2154 | <sect2> | ||
2155 | <title>Display Port Helper Functions Reference</title> | ||
2156 | !Pdrivers/gpu/drm/drm_dp_helper.c dp helpers | ||
2157 | !Iinclude/drm/drm_dp_helper.h | ||
2158 | !Edrivers/gpu/drm/drm_dp_helper.c | ||
2159 | </sect2> | ||
2160 | <sect2> | ||
2161 | <title>EDID Helper Functions Reference</title> | ||
2162 | !Edrivers/gpu/drm/drm_edid.c | ||
2163 | </sect2> | ||
2109 | </sect1> | 2164 | </sect1> |
2110 | 2165 | ||
2111 | <!-- Internals: vertical blanking --> | 2166 | <!-- Internals: vertical blanking --> |