xref: /dflybsd-src/sys/dev/drm/i915/intel_frontbuffer.h (revision a85cb24f18e3804e75ab8bcda7692564d0563317)
171f41f3eSFrançois Tigeot /*
271f41f3eSFrançois Tigeot  * Copyright (c) 2014-2016 Intel Corporation
371f41f3eSFrançois Tigeot  *
471f41f3eSFrançois Tigeot  * Permission is hereby granted, free of charge, to any person obtaining a
571f41f3eSFrançois Tigeot  * copy of this software and associated documentation files (the "Software"),
671f41f3eSFrançois Tigeot  * to deal in the Software without restriction, including without limitation
771f41f3eSFrançois Tigeot  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
871f41f3eSFrançois Tigeot  * and/or sell copies of the Software, and to permit persons to whom the
971f41f3eSFrançois Tigeot  * Software is furnished to do so, subject to the following conditions:
1071f41f3eSFrançois Tigeot  *
1171f41f3eSFrançois Tigeot  * The above copyright notice and this permission notice (including the next
1271f41f3eSFrançois Tigeot  * paragraph) shall be included in all copies or substantial portions of the
1371f41f3eSFrançois Tigeot  * Software.
1471f41f3eSFrançois Tigeot  *
1571f41f3eSFrançois Tigeot  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1671f41f3eSFrançois Tigeot  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1771f41f3eSFrançois Tigeot  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1871f41f3eSFrançois Tigeot  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1971f41f3eSFrançois Tigeot  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2071f41f3eSFrançois Tigeot  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
2171f41f3eSFrançois Tigeot  * IN THE SOFTWARE.
2271f41f3eSFrançois Tigeot  */
2371f41f3eSFrançois Tigeot 
2471f41f3eSFrançois Tigeot #ifndef __INTEL_FRONTBUFFER_H__
2571f41f3eSFrançois Tigeot #define __INTEL_FRONTBUFFER_H__
2671f41f3eSFrançois Tigeot 
2771f41f3eSFrançois Tigeot struct drm_i915_private;
2871f41f3eSFrançois Tigeot struct drm_i915_gem_object;
2971f41f3eSFrançois Tigeot 
3071f41f3eSFrançois Tigeot void intel_frontbuffer_flip_prepare(struct drm_i915_private *dev_priv,
3171f41f3eSFrançois Tigeot 				    unsigned frontbuffer_bits);
3271f41f3eSFrançois Tigeot void intel_frontbuffer_flip_complete(struct drm_i915_private *dev_priv,
3371f41f3eSFrançois Tigeot 				     unsigned frontbuffer_bits);
3471f41f3eSFrançois Tigeot void intel_frontbuffer_flip(struct drm_i915_private *dev_priv,
3571f41f3eSFrançois Tigeot 			    unsigned frontbuffer_bits);
3671f41f3eSFrançois Tigeot 
3771f41f3eSFrançois Tigeot void __intel_fb_obj_invalidate(struct drm_i915_gem_object *obj,
3871f41f3eSFrançois Tigeot 			       enum fb_op_origin origin,
3971f41f3eSFrançois Tigeot 			       unsigned int frontbuffer_bits);
4071f41f3eSFrançois Tigeot void __intel_fb_obj_flush(struct drm_i915_gem_object *obj,
4171f41f3eSFrançois Tigeot 			  enum fb_op_origin origin,
4271f41f3eSFrançois Tigeot 			  unsigned int frontbuffer_bits);
4371f41f3eSFrançois Tigeot 
4471f41f3eSFrançois Tigeot /**
4571f41f3eSFrançois Tigeot  * intel_fb_obj_invalidate - invalidate frontbuffer object
4671f41f3eSFrançois Tigeot  * @obj: GEM object to invalidate
4771f41f3eSFrançois Tigeot  * @origin: which operation caused the invalidation
4871f41f3eSFrançois Tigeot  *
4971f41f3eSFrançois Tigeot  * This function gets called every time rendering on the given object starts and
5071f41f3eSFrançois Tigeot  * frontbuffer caching (fbc, low refresh rate for DRRS, panel self refresh) must
5171f41f3eSFrançois Tigeot  * be invalidated. For ORIGIN_CS any subsequent invalidation will be delayed
5271f41f3eSFrançois Tigeot  * until the rendering completes or a flip on this frontbuffer plane is
5371f41f3eSFrançois Tigeot  * scheduled.
5471f41f3eSFrançois Tigeot  */
intel_fb_obj_invalidate(struct drm_i915_gem_object * obj,enum fb_op_origin origin)554be47400SFrançois Tigeot static inline bool intel_fb_obj_invalidate(struct drm_i915_gem_object *obj,
5671f41f3eSFrançois Tigeot 					   enum fb_op_origin origin)
5771f41f3eSFrançois Tigeot {
5871f41f3eSFrançois Tigeot 	unsigned int frontbuffer_bits;
5971f41f3eSFrançois Tigeot 
6071f41f3eSFrançois Tigeot 	frontbuffer_bits = atomic_read(&obj->frontbuffer_bits);
6171f41f3eSFrançois Tigeot 	if (!frontbuffer_bits)
624be47400SFrançois Tigeot 		return false;
6371f41f3eSFrançois Tigeot 
6471f41f3eSFrançois Tigeot 	__intel_fb_obj_invalidate(obj, origin, frontbuffer_bits);
654be47400SFrançois Tigeot 	return true;
6671f41f3eSFrançois Tigeot }
6771f41f3eSFrançois Tigeot 
6871f41f3eSFrançois Tigeot /**
6971f41f3eSFrançois Tigeot  * intel_fb_obj_flush - flush frontbuffer object
7071f41f3eSFrançois Tigeot  * @obj: GEM object to flush
7171f41f3eSFrançois Tigeot  * @origin: which operation caused the flush
7271f41f3eSFrançois Tigeot  *
7371f41f3eSFrançois Tigeot  * This function gets called every time rendering on the given object has
74*a85cb24fSFrançois Tigeot  * completed and frontbuffer caching can be started again.
7571f41f3eSFrançois Tigeot  */
intel_fb_obj_flush(struct drm_i915_gem_object * obj,enum fb_op_origin origin)7671f41f3eSFrançois Tigeot static inline void intel_fb_obj_flush(struct drm_i915_gem_object *obj,
7771f41f3eSFrançois Tigeot 				      enum fb_op_origin origin)
7871f41f3eSFrançois Tigeot {
7971f41f3eSFrançois Tigeot 	unsigned int frontbuffer_bits;
8071f41f3eSFrançois Tigeot 
8171f41f3eSFrançois Tigeot 	frontbuffer_bits = atomic_read(&obj->frontbuffer_bits);
8271f41f3eSFrançois Tigeot 	if (!frontbuffer_bits)
8371f41f3eSFrançois Tigeot 		return;
8471f41f3eSFrançois Tigeot 
85*a85cb24fSFrançois Tigeot 	__intel_fb_obj_flush(obj, origin, frontbuffer_bits);
8671f41f3eSFrançois Tigeot }
8771f41f3eSFrançois Tigeot 
8871f41f3eSFrançois Tigeot #endif /* __INTEL_FRONTBUFFER_H__ */
89