xref: /dflybsd-src/sys/dev/drm/i915/intel_frontbuffer.h (revision 71f41f3eaecc1bac4c44cc81622db5b5dddc7dc4)
1*71f41f3eSFrançois Tigeot /*
2*71f41f3eSFrançois Tigeot  * Copyright (c) 2014-2016 Intel Corporation
3*71f41f3eSFrançois Tigeot  *
4*71f41f3eSFrançois Tigeot  * Permission is hereby granted, free of charge, to any person obtaining a
5*71f41f3eSFrançois Tigeot  * copy of this software and associated documentation files (the "Software"),
6*71f41f3eSFrançois Tigeot  * to deal in the Software without restriction, including without limitation
7*71f41f3eSFrançois Tigeot  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*71f41f3eSFrançois Tigeot  * and/or sell copies of the Software, and to permit persons to whom the
9*71f41f3eSFrançois Tigeot  * Software is furnished to do so, subject to the following conditions:
10*71f41f3eSFrançois Tigeot  *
11*71f41f3eSFrançois Tigeot  * The above copyright notice and this permission notice (including the next
12*71f41f3eSFrançois Tigeot  * paragraph) shall be included in all copies or substantial portions of the
13*71f41f3eSFrançois Tigeot  * Software.
14*71f41f3eSFrançois Tigeot  *
15*71f41f3eSFrançois Tigeot  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16*71f41f3eSFrançois Tigeot  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17*71f41f3eSFrançois Tigeot  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18*71f41f3eSFrançois Tigeot  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19*71f41f3eSFrançois Tigeot  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20*71f41f3eSFrançois Tigeot  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21*71f41f3eSFrançois Tigeot  * IN THE SOFTWARE.
22*71f41f3eSFrançois Tigeot  */
23*71f41f3eSFrançois Tigeot 
24*71f41f3eSFrançois Tigeot #ifndef __INTEL_FRONTBUFFER_H__
25*71f41f3eSFrançois Tigeot #define __INTEL_FRONTBUFFER_H__
26*71f41f3eSFrançois Tigeot 
27*71f41f3eSFrançois Tigeot struct drm_i915_private;
28*71f41f3eSFrançois Tigeot struct drm_i915_gem_object;
29*71f41f3eSFrançois Tigeot 
30*71f41f3eSFrançois Tigeot void intel_frontbuffer_flip_prepare(struct drm_i915_private *dev_priv,
31*71f41f3eSFrançois Tigeot 				    unsigned frontbuffer_bits);
32*71f41f3eSFrançois Tigeot void intel_frontbuffer_flip_complete(struct drm_i915_private *dev_priv,
33*71f41f3eSFrançois Tigeot 				     unsigned frontbuffer_bits);
34*71f41f3eSFrançois Tigeot void intel_frontbuffer_flip(struct drm_i915_private *dev_priv,
35*71f41f3eSFrançois Tigeot 			    unsigned frontbuffer_bits);
36*71f41f3eSFrançois Tigeot 
37*71f41f3eSFrançois Tigeot void __intel_fb_obj_invalidate(struct drm_i915_gem_object *obj,
38*71f41f3eSFrançois Tigeot 			       enum fb_op_origin origin,
39*71f41f3eSFrançois Tigeot 			       unsigned int frontbuffer_bits);
40*71f41f3eSFrançois Tigeot void __intel_fb_obj_flush(struct drm_i915_gem_object *obj,
41*71f41f3eSFrançois Tigeot 			  bool retire,
42*71f41f3eSFrançois Tigeot 			  enum fb_op_origin origin,
43*71f41f3eSFrançois Tigeot 			  unsigned int frontbuffer_bits);
44*71f41f3eSFrançois Tigeot 
45*71f41f3eSFrançois Tigeot /**
46*71f41f3eSFrançois Tigeot  * intel_fb_obj_invalidate - invalidate frontbuffer object
47*71f41f3eSFrançois Tigeot  * @obj: GEM object to invalidate
48*71f41f3eSFrançois Tigeot  * @origin: which operation caused the invalidation
49*71f41f3eSFrançois Tigeot  *
50*71f41f3eSFrançois Tigeot  * This function gets called every time rendering on the given object starts and
51*71f41f3eSFrançois Tigeot  * frontbuffer caching (fbc, low refresh rate for DRRS, panel self refresh) must
52*71f41f3eSFrançois Tigeot  * be invalidated. For ORIGIN_CS any subsequent invalidation will be delayed
53*71f41f3eSFrançois Tigeot  * until the rendering completes or a flip on this frontbuffer plane is
54*71f41f3eSFrançois Tigeot  * scheduled.
55*71f41f3eSFrançois Tigeot  */
56*71f41f3eSFrançois Tigeot static inline void intel_fb_obj_invalidate(struct drm_i915_gem_object *obj,
57*71f41f3eSFrançois Tigeot 					   enum fb_op_origin origin)
58*71f41f3eSFrançois Tigeot {
59*71f41f3eSFrançois Tigeot 	unsigned int frontbuffer_bits;
60*71f41f3eSFrançois Tigeot 
61*71f41f3eSFrançois Tigeot 	frontbuffer_bits = atomic_read(&obj->frontbuffer_bits);
62*71f41f3eSFrançois Tigeot 	if (!frontbuffer_bits)
63*71f41f3eSFrançois Tigeot 		return;
64*71f41f3eSFrançois Tigeot 
65*71f41f3eSFrançois Tigeot 	__intel_fb_obj_invalidate(obj, origin, frontbuffer_bits);
66*71f41f3eSFrançois Tigeot }
67*71f41f3eSFrançois Tigeot 
68*71f41f3eSFrançois Tigeot /**
69*71f41f3eSFrançois Tigeot  * intel_fb_obj_flush - flush frontbuffer object
70*71f41f3eSFrançois Tigeot  * @obj: GEM object to flush
71*71f41f3eSFrançois Tigeot  * @retire: set when retiring asynchronous rendering
72*71f41f3eSFrançois Tigeot  * @origin: which operation caused the flush
73*71f41f3eSFrançois Tigeot  *
74*71f41f3eSFrançois Tigeot  * This function gets called every time rendering on the given object has
75*71f41f3eSFrançois Tigeot  * completed and frontbuffer caching can be started again. If @retire is true
76*71f41f3eSFrançois Tigeot  * then any delayed flushes will be unblocked.
77*71f41f3eSFrançois Tigeot  */
78*71f41f3eSFrançois Tigeot static inline void intel_fb_obj_flush(struct drm_i915_gem_object *obj,
79*71f41f3eSFrançois Tigeot 				      bool retire,
80*71f41f3eSFrançois Tigeot 				      enum fb_op_origin origin)
81*71f41f3eSFrançois Tigeot {
82*71f41f3eSFrançois Tigeot 	unsigned int frontbuffer_bits;
83*71f41f3eSFrançois Tigeot 
84*71f41f3eSFrançois Tigeot 	frontbuffer_bits = atomic_read(&obj->frontbuffer_bits);
85*71f41f3eSFrançois Tigeot 	if (!frontbuffer_bits)
86*71f41f3eSFrançois Tigeot 		return;
87*71f41f3eSFrançois Tigeot 
88*71f41f3eSFrançois Tigeot 	__intel_fb_obj_flush(obj, retire, origin, frontbuffer_bits);
89*71f41f3eSFrançois Tigeot }
90*71f41f3eSFrançois Tigeot 
91*71f41f3eSFrançois Tigeot #endif /* __INTEL_FRONTBUFFER_H__ */
92