0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 #ifndef DRM_ATOMIC_HELPER_H_
0029 #define DRM_ATOMIC_HELPER_H_
0030
0031 #include <drm/drm_crtc.h>
0032 #include <drm/drm_modeset_helper_vtables.h>
0033 #include <drm/drm_modeset_helper.h>
0034 #include <drm/drm_atomic_state_helper.h>
0035 #include <drm/drm_util.h>
0036
0037 struct drm_atomic_state;
0038 struct drm_private_obj;
0039 struct drm_private_state;
0040
0041 int drm_atomic_helper_check_modeset(struct drm_device *dev,
0042 struct drm_atomic_state *state);
0043 int drm_atomic_helper_check_plane_state(struct drm_plane_state *plane_state,
0044 const struct drm_crtc_state *crtc_state,
0045 int min_scale,
0046 int max_scale,
0047 bool can_position,
0048 bool can_update_disabled);
0049 int drm_atomic_helper_check_crtc_state(struct drm_crtc_state *crtc_state,
0050 bool can_disable_primary_plane);
0051 int drm_atomic_helper_check_planes(struct drm_device *dev,
0052 struct drm_atomic_state *state);
0053 int drm_atomic_helper_check(struct drm_device *dev,
0054 struct drm_atomic_state *state);
0055 void drm_atomic_helper_commit_tail(struct drm_atomic_state *state);
0056 void drm_atomic_helper_commit_tail_rpm(struct drm_atomic_state *state);
0057 int drm_atomic_helper_commit(struct drm_device *dev,
0058 struct drm_atomic_state *state,
0059 bool nonblock);
0060 int drm_atomic_helper_async_check(struct drm_device *dev,
0061 struct drm_atomic_state *state);
0062 void drm_atomic_helper_async_commit(struct drm_device *dev,
0063 struct drm_atomic_state *state);
0064
0065 int drm_atomic_helper_wait_for_fences(struct drm_device *dev,
0066 struct drm_atomic_state *state,
0067 bool pre_swap);
0068
0069 void drm_atomic_helper_wait_for_vblanks(struct drm_device *dev,
0070 struct drm_atomic_state *old_state);
0071
0072 void drm_atomic_helper_wait_for_flip_done(struct drm_device *dev,
0073 struct drm_atomic_state *old_state);
0074
0075 void
0076 drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev,
0077 struct drm_atomic_state *old_state);
0078
0079 void
0080 drm_atomic_helper_calc_timestamping_constants(struct drm_atomic_state *state);
0081
0082 void drm_atomic_helper_commit_modeset_disables(struct drm_device *dev,
0083 struct drm_atomic_state *state);
0084 void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,
0085 struct drm_atomic_state *old_state);
0086
0087 int drm_atomic_helper_prepare_planes(struct drm_device *dev,
0088 struct drm_atomic_state *state);
0089
0090 #define DRM_PLANE_COMMIT_ACTIVE_ONLY BIT(0)
0091 #define DRM_PLANE_COMMIT_NO_DISABLE_AFTER_MODESET BIT(1)
0092
0093 void drm_atomic_helper_commit_planes(struct drm_device *dev,
0094 struct drm_atomic_state *state,
0095 uint32_t flags);
0096 void drm_atomic_helper_cleanup_planes(struct drm_device *dev,
0097 struct drm_atomic_state *old_state);
0098 void drm_atomic_helper_commit_planes_on_crtc(struct drm_crtc_state *old_crtc_state);
0099 void
0100 drm_atomic_helper_disable_planes_on_crtc(struct drm_crtc_state *old_crtc_state,
0101 bool atomic);
0102
0103 int __must_check drm_atomic_helper_swap_state(struct drm_atomic_state *state,
0104 bool stall);
0105
0106
0107 int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
0108 bool nonblock);
0109 void drm_atomic_helper_wait_for_dependencies(struct drm_atomic_state *state);
0110 void drm_atomic_helper_fake_vblank(struct drm_atomic_state *state);
0111 void drm_atomic_helper_commit_hw_done(struct drm_atomic_state *state);
0112 void drm_atomic_helper_commit_cleanup_done(struct drm_atomic_state *state);
0113
0114
0115 int drm_atomic_helper_update_plane(struct drm_plane *plane,
0116 struct drm_crtc *crtc,
0117 struct drm_framebuffer *fb,
0118 int crtc_x, int crtc_y,
0119 unsigned int crtc_w, unsigned int crtc_h,
0120 uint32_t src_x, uint32_t src_y,
0121 uint32_t src_w, uint32_t src_h,
0122 struct drm_modeset_acquire_ctx *ctx);
0123 int drm_atomic_helper_disable_plane(struct drm_plane *plane,
0124 struct drm_modeset_acquire_ctx *ctx);
0125 int drm_atomic_helper_set_config(struct drm_mode_set *set,
0126 struct drm_modeset_acquire_ctx *ctx);
0127
0128 int drm_atomic_helper_disable_all(struct drm_device *dev,
0129 struct drm_modeset_acquire_ctx *ctx);
0130 void drm_atomic_helper_shutdown(struct drm_device *dev);
0131 struct drm_atomic_state *
0132 drm_atomic_helper_duplicate_state(struct drm_device *dev,
0133 struct drm_modeset_acquire_ctx *ctx);
0134 struct drm_atomic_state *drm_atomic_helper_suspend(struct drm_device *dev);
0135 int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
0136 struct drm_modeset_acquire_ctx *ctx);
0137 int drm_atomic_helper_resume(struct drm_device *dev,
0138 struct drm_atomic_state *state);
0139
0140 int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
0141 struct drm_framebuffer *fb,
0142 struct drm_pending_vblank_event *event,
0143 uint32_t flags,
0144 struct drm_modeset_acquire_ctx *ctx);
0145 int drm_atomic_helper_page_flip_target(
0146 struct drm_crtc *crtc,
0147 struct drm_framebuffer *fb,
0148 struct drm_pending_vblank_event *event,
0149 uint32_t flags,
0150 uint32_t target,
0151 struct drm_modeset_acquire_ctx *ctx);
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164 #define drm_atomic_crtc_for_each_plane(plane, crtc) \
0165 drm_for_each_plane_mask(plane, (crtc)->dev, (crtc)->state->plane_mask)
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177 #define drm_atomic_crtc_state_for_each_plane(plane, crtc_state) \
0178 drm_for_each_plane_mask(plane, (crtc_state)->state->dev, (crtc_state)->plane_mask)
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195 #define drm_atomic_crtc_state_for_each_plane_state(plane, plane_state, crtc_state) \
0196 drm_for_each_plane_mask(plane, (crtc_state)->state->dev, (crtc_state)->plane_mask) \
0197 for_each_if ((plane_state = \
0198 __drm_atomic_get_current_plane_state((crtc_state)->state, \
0199 plane)))
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213 static inline bool
0214 drm_atomic_plane_disabling(struct drm_plane_state *old_plane_state,
0215 struct drm_plane_state *new_plane_state)
0216 {
0217
0218
0219
0220
0221
0222 WARN_ON((new_plane_state->crtc == NULL && new_plane_state->fb != NULL) ||
0223 (new_plane_state->crtc != NULL && new_plane_state->fb == NULL));
0224
0225 return old_plane_state->crtc && !new_plane_state->crtc;
0226 }
0227
0228 u32 *
0229 drm_atomic_helper_bridge_propagate_bus_fmt(struct drm_bridge *bridge,
0230 struct drm_bridge_state *bridge_state,
0231 struct drm_crtc_state *crtc_state,
0232 struct drm_connector_state *conn_state,
0233 u32 output_fmt,
0234 unsigned int *num_input_fmts);
0235
0236 #endif