Linux Audio

Check our new training course

Loading...
Note: File does not exist in v4.6.
  1/*
  2 * Copyright (c) 2014-2016 Intel Corporation
  3 *
  4 * Permission is hereby granted, free of charge, to any person obtaining a
  5 * copy of this software and associated documentation files (the "Software"),
  6 * to deal in the Software without restriction, including without limitation
  7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8 * and/or sell copies of the Software, and to permit persons to whom the
  9 * Software is furnished to do so, subject to the following conditions:
 10 *
 11 * The above copyright notice and this permission notice (including the next
 12 * paragraph) shall be included in all copies or substantial portions of the
 13 * Software.
 14 *
 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21 * IN THE SOFTWARE.
 22 */
 23
 24#ifndef __INTEL_FRONTBUFFER_H__
 25#define __INTEL_FRONTBUFFER_H__
 26
 27#include <linux/atomic.h>
 28#include <linux/kref.h>
 29
 30#include "i915_active.h"
 31
 32struct drm_i915_private;
 33struct drm_i915_gem_object;
 34
 35enum fb_op_origin {
 36	ORIGIN_GTT,
 37	ORIGIN_CPU,
 38	ORIGIN_CS,
 39	ORIGIN_FLIP,
 40	ORIGIN_DIRTYFB,
 41};
 42
 43struct intel_frontbuffer {
 44	struct kref ref;
 45	atomic_t bits;
 46	struct i915_active write;
 47	struct drm_i915_gem_object *obj;
 48};
 49
 50void intel_frontbuffer_flip_prepare(struct drm_i915_private *i915,
 51				    unsigned frontbuffer_bits);
 52void intel_frontbuffer_flip_complete(struct drm_i915_private *i915,
 53				     unsigned frontbuffer_bits);
 54void intel_frontbuffer_flip(struct drm_i915_private *i915,
 55			    unsigned frontbuffer_bits);
 56
 57struct intel_frontbuffer *
 58intel_frontbuffer_get(struct drm_i915_gem_object *obj);
 59
 60void __intel_fb_invalidate(struct intel_frontbuffer *front,
 61			   enum fb_op_origin origin,
 62			   unsigned int frontbuffer_bits);
 63
 64/**
 65 * intel_frontbuffer_invalidate - invalidate frontbuffer object
 66 * @front: GEM object to invalidate
 67 * @origin: which operation caused the invalidation
 68 *
 69 * This function gets called every time rendering on the given object starts and
 70 * frontbuffer caching (fbc, low refresh rate for DRRS, panel self refresh) must
 71 * be invalidated. For ORIGIN_CS any subsequent invalidation will be delayed
 72 * until the rendering completes or a flip on this frontbuffer plane is
 73 * scheduled.
 74 */
 75static inline bool intel_frontbuffer_invalidate(struct intel_frontbuffer *front,
 76						enum fb_op_origin origin)
 77{
 78	unsigned int frontbuffer_bits;
 79
 80	if (!front)
 81		return false;
 82
 83	frontbuffer_bits = atomic_read(&front->bits);
 84	if (!frontbuffer_bits)
 85		return false;
 86
 87	__intel_fb_invalidate(front, origin, frontbuffer_bits);
 88	return true;
 89}
 90
 91void __intel_fb_flush(struct intel_frontbuffer *front,
 92		      enum fb_op_origin origin,
 93		      unsigned int frontbuffer_bits);
 94
 95/**
 96 * intel_frontbuffer_flush - flush frontbuffer object
 97 * @front: GEM object to flush
 98 * @origin: which operation caused the flush
 99 *
100 * This function gets called every time rendering on the given object has
101 * completed and frontbuffer caching can be started again.
102 */
103static inline void intel_frontbuffer_flush(struct intel_frontbuffer *front,
104					   enum fb_op_origin origin)
105{
106	unsigned int frontbuffer_bits;
107
108	if (!front)
109		return;
110
111	frontbuffer_bits = atomic_read(&front->bits);
112	if (!frontbuffer_bits)
113		return;
114
115	__intel_fb_flush(front, origin, frontbuffer_bits);
116}
117
118void intel_frontbuffer_track(struct intel_frontbuffer *old,
119			     struct intel_frontbuffer *new,
120			     unsigned int frontbuffer_bits);
121
122void intel_frontbuffer_put(struct intel_frontbuffer *front);
123
124#endif /* __INTEL_FRONTBUFFER_H__ */