Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  * Copyright (c) 2016 Intel Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Permission to use, copy, modify, distribute, and sell this software and its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * documentation for any purpose is hereby granted without fee, provided that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * the above copyright notice appear in all copies and that both that copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * notice and this permission notice appear in supporting documentation, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * that the name of the copyright holders not be used in advertising or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * publicity pertaining to distribution of the software without specific,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * written prior permission.  The copyright holders make no representations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * about the suitability of this software for any purpose.  It is provided "as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  * is" without express or implied warranty.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * OF THIS SOFTWARE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #ifndef __DRM_FRAMEBUFFER_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #define __DRM_FRAMEBUFFER_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include <linux/ctype.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #include <drm/drm_mode_object.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) struct drm_clip_rect;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) struct drm_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) struct drm_file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) struct drm_format_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) struct drm_framebuffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) struct drm_gem_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  * struct drm_framebuffer_funcs - framebuffer hooks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) struct drm_framebuffer_funcs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	 * @destroy:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	 * Clean up framebuffer resources, specifically also unreference the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	 * backing storage. The core guarantees to call this function for every
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	 * framebuffer successfully created by calling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	 * &drm_mode_config_funcs.fb_create. Drivers must also call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	 * drm_framebuffer_cleanup() to release DRM core resources for this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	 * framebuffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	void (*destroy)(struct drm_framebuffer *framebuffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	 * @create_handle:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	 * Create a buffer handle in the driver-specific buffer manager (either
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	 * GEM or TTM) valid for the passed-in &struct drm_file. This is used by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	 * the core to implement the GETFB IOCTL, which returns (for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	 * sufficiently priviledged user) also a native buffer handle. This can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	 * be used for seamless transitions between modesetting clients by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	 * copying the current screen contents to a private buffer and blending
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	 * between that and the new contents.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	 * GEM based drivers should call drm_gem_handle_create() to create the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	 * handle.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	 * RETURNS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	 * 0 on success or a negative error code on failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	int (*create_handle)(struct drm_framebuffer *fb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 			     struct drm_file *file_priv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 			     unsigned int *handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	 * @dirty:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	 * Optional callback for the dirty fb IOCTL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	 * Userspace can notify the driver via this callback that an area of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	 * framebuffer has changed and should be flushed to the display
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	 * hardware. This can also be used internally, e.g. by the fbdev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	 * emulation, though that's not the case currently.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	 * See documentation in drm_mode.h for the struct drm_mode_fb_dirty_cmd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	 * for more information as all the semantics and arguments have a one to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	 * one mapping on this function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	 * Atomic drivers should use drm_atomic_helper_dirtyfb() to implement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	 * this hook.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	 * RETURNS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	 * 0 on success or a negative error code on failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	int (*dirty)(struct drm_framebuffer *framebuffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		     struct drm_file *file_priv, unsigned flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		     unsigned color, struct drm_clip_rect *clips,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		     unsigned num_clips);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  * struct drm_framebuffer - frame buffer object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)  * Note that the fb is refcounted for the benefit of driver internals,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)  * for example some hw, disabling a CRTC/plane is asynchronous, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)  * scanout does not actually complete until the next vblank.  So some
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)  * cleanup (like releasing the reference(s) on the backing GEM bo(s))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)  * should be deferred.  In cases like this, the driver would like to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)  * hold a ref to the fb even though it has already been removed from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)  * userspace perspective. See drm_framebuffer_get() and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)  * drm_framebuffer_put().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)  * The refcount is stored inside the mode object @base.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) struct drm_framebuffer {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	 * @dev: DRM device this framebuffer belongs to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	struct drm_device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	 * @head: Place on the &drm_mode_config.fb_list, access protected by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	 * &drm_mode_config.fb_lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	struct list_head head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	 * @base: base modeset object structure, contains the reference count.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	struct drm_mode_object base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	 * @comm: Name of the process allocating the fb, used for fb dumping.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	char comm[TASK_COMM_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	 * @format: framebuffer format information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	const struct drm_format_info *format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	 * @funcs: framebuffer vfunc table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	const struct drm_framebuffer_funcs *funcs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	 * @pitches: Line stride per buffer. For userspace created object this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	 * is copied from drm_mode_fb_cmd2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	unsigned int pitches[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	 * @offsets: Offset from buffer start to the actual pixel data in bytes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	 * per buffer. For userspace created object this is copied from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	 * drm_mode_fb_cmd2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	 * Note that this is a linear offset and does not take into account
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	 * tiling or buffer laytou per @modifier. It meant to be used when the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	 * actual pixel data for this framebuffer plane starts at an offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	 * e.g.  when multiple planes are allocated within the same backing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	 * storage buffer object. For tiled layouts this generally means it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	 * @offsets must at least be tile-size aligned, but hardware often has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	 * stricter requirements.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	 * This should not be used to specifiy x/y pixel offsets into the buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	 * data (even for linear buffers). Specifying an x/y pixel offset is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	 * instead done through the source rectangle in &struct drm_plane_state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	unsigned int offsets[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	 * @modifier: Data layout modifier. This is used to describe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	 * tiling, or also special layouts (like compression) of auxiliary
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	 * buffers. For userspace created object this is copied from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	 * drm_mode_fb_cmd2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	uint64_t modifier;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	 * @width: Logical width of the visible area of the framebuffer, in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	 * pixels.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	unsigned int width;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	 * @height: Logical height of the visible area of the framebuffer, in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	 * pixels.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	unsigned int height;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	 * @flags: Framebuffer flags like DRM_MODE_FB_INTERLACED or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	 * DRM_MODE_FB_MODIFIERS.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	int flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	 * @hot_x: X coordinate of the cursor hotspot. Used by the legacy cursor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	 * IOCTL when the driver supports cursor through a DRM_PLANE_TYPE_CURSOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	 * universal plane.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	int hot_x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	 * @hot_y: Y coordinate of the cursor hotspot. Used by the legacy cursor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	 * IOCTL when the driver supports cursor through a DRM_PLANE_TYPE_CURSOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	 * universal plane.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	int hot_y;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	 * @filp_head: Placed on &drm_file.fbs, protected by &drm_file.fbs_lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	struct list_head filp_head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	 * @obj: GEM objects backing the framebuffer, one per plane (optional).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	 * This is used by the GEM framebuffer helpers, see e.g.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	 * drm_gem_fb_create().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	struct drm_gem_object *obj[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) #define obj_to_fb(x) container_of(x, struct drm_framebuffer, base)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) int drm_framebuffer_init(struct drm_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 			 struct drm_framebuffer *fb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 			 const struct drm_framebuffer_funcs *funcs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) struct drm_framebuffer *drm_framebuffer_lookup(struct drm_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 					       struct drm_file *file_priv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 					       uint32_t id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) void drm_framebuffer_remove(struct drm_framebuffer *fb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) void drm_framebuffer_cleanup(struct drm_framebuffer *fb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) void drm_framebuffer_unregister_private(struct drm_framebuffer *fb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)  * drm_framebuffer_get - acquire a framebuffer reference
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)  * @fb: DRM framebuffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)  * This function increments the framebuffer's reference count.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) static inline void drm_framebuffer_get(struct drm_framebuffer *fb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	drm_mode_object_get(&fb->base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)  * drm_framebuffer_put - release a framebuffer reference
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)  * @fb: DRM framebuffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)  * This function decrements the framebuffer's reference count and frees the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)  * framebuffer if the reference count drops to zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) static inline void drm_framebuffer_put(struct drm_framebuffer *fb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	drm_mode_object_put(&fb->base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)  * drm_framebuffer_read_refcount - read the framebuffer reference count.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)  * @fb: framebuffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)  * This functions returns the framebuffer's reference count.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) static inline uint32_t drm_framebuffer_read_refcount(const struct drm_framebuffer *fb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	return kref_read(&fb->base.refcount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)  * drm_framebuffer_assign - store a reference to the fb
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)  * @p: location to store framebuffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)  * @fb: new framebuffer (maybe NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)  * This functions sets the location to store a reference to the framebuffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)  * unreferencing the framebuffer that was previously stored in that location.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) static inline void drm_framebuffer_assign(struct drm_framebuffer **p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 					  struct drm_framebuffer *fb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	if (fb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 		drm_framebuffer_get(fb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	if (*p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 		drm_framebuffer_put(*p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	*p = fb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)  * drm_for_each_fb - iterate over all framebuffers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)  * @fb: the loop cursor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)  * @dev: the DRM device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)  * Iterate over all framebuffers of @dev. User must hold
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)  * &drm_mode_config.fb_lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) #define drm_for_each_fb(fb, dev) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	for (WARN_ON(!mutex_is_locked(&(dev)->mode_config.fb_lock)),		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	     fb = list_first_entry(&(dev)->mode_config.fb_list,	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 					  struct drm_framebuffer, head);	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	     &fb->head != (&(dev)->mode_config.fb_list);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	     fb = list_next_entry(fb, head))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) int drm_framebuffer_plane_width(int width,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 				const struct drm_framebuffer *fb, int plane);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) int drm_framebuffer_plane_height(int height,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 				 const struct drm_framebuffer *fb, int plane);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)  * struct drm_afbc_framebuffer - a special afbc frame buffer object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)  * A derived class of struct drm_framebuffer, dedicated for afbc use cases.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) struct drm_afbc_framebuffer {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	 * @base: base framebuffer structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	struct drm_framebuffer base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	 * @block_width: width of a single afbc block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	u32 block_width;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	 * @block_height: height of a single afbc block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	u32 block_height;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	 * @aligned_width: aligned frame buffer width
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	u32 aligned_width;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 	 * @aligned_height: aligned frame buffer height
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	u32 aligned_height;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	 * @offset: offset of the first afbc header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	u32 offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	 * @afbc_size: minimum size of afbc buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	u32 afbc_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) #define fb_to_afbc_fb(x) container_of(x, struct drm_afbc_framebuffer, base)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) #endif