|
| 1 | +// SPDX-License-Identifier: GPL-2.0 OR MIT |
| 2 | +/************************************************************************** |
| 3 | + * |
| 4 | + * Copyright (c) 2018 VMware, Inc., Palo Alto, CA., USA |
| 5 | + * All Rights Reserved. |
| 6 | + * |
| 7 | + * Permission is hereby granted, free of charge, to any person obtaining a |
| 8 | + * copy of this software and associated documentation files (the |
| 9 | + * "Software"), to deal in the Software without restriction, including |
| 10 | + * without limitation the rights to use, copy, modify, merge, publish, |
| 11 | + * distribute, sub license, and/or sell copies of the Software, and to |
| 12 | + * permit persons to whom the Software is furnished to do so, subject to |
| 13 | + * the following conditions: |
| 14 | + * |
| 15 | + * The above copyright notice and this permission notice (including the |
| 16 | + * next paragraph) shall be included in all copies or substantial portions |
| 17 | + * of the Software. |
| 18 | + * |
| 19 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 20 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 21 | + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
| 22 | + * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, |
| 23 | + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 24 | + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
| 25 | + * USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 26 | + * |
| 27 | + * Authors: |
| 28 | + * Deepak Rawat <drawat@vmware.com> |
| 29 | + * |
| 30 | + **************************************************************************/ |
| 31 | + |
| 32 | +#include <drm/drm_damage_helper.h> |
| 33 | + |
| 34 | +/** |
| 35 | + * DOC: overview |
| 36 | + * |
| 37 | + * FB_DAMAGE_CLIPS is an optional plane property which provides a means to |
| 38 | + * specify a list of damage rectangles on a plane in framebuffer coordinates of |
| 39 | + * the framebuffer attached to the plane. In current context damage is the area |
| 40 | + * of plane framebuffer that has changed since last plane update (also called |
| 41 | + * page-flip), irrespective of whether currently attached framebuffer is same as |
| 42 | + * framebuffer attached during last plane update or not. |
| 43 | + * |
| 44 | + * FB_DAMAGE_CLIPS is a hint to kernel which could be helpful for some drivers |
| 45 | + * to optimize internally especially for virtual devices where each framebuffer |
| 46 | + * change needs to be transmitted over network, usb, etc. |
| 47 | + * |
| 48 | + * Since FB_DAMAGE_CLIPS is a hint so it is an optional property. User-space can |
| 49 | + * ignore damage clips property and in that case driver will do a full plane |
| 50 | + * update. In case damage clips are provided then it is guaranteed that the area |
| 51 | + * inside damage clips will be updated to plane. For efficiency driver can do |
| 52 | + * full update or can update more than specified in damage clips. Since driver |
| 53 | + * is free to read more, user-space must always render the entire visible |
| 54 | + * framebuffer. Otherwise there can be corruptions. Also, if a user-space |
| 55 | + * provides damage clips which doesn't encompass the actual damage to |
| 56 | + * framebuffer (since last plane update) can result in incorrect rendering. |
| 57 | + * |
| 58 | + * FB_DAMAGE_CLIPS is a blob property with the layout of blob data is simply an |
| 59 | + * array of &drm_mode_rect. Unlike plane &drm_plane_state.src coordinates, |
| 60 | + * damage clips are not in 16.16 fixed point. Similar to plane src in |
| 61 | + * framebuffer, damage clips cannot be negative. In damage clip, x1/y1 are |
| 62 | + * inclusive and x2/y2 are exclusive. While kernel does not error for overlapped |
| 63 | + * damage clips, it is strongly discouraged. |
| 64 | + * |
| 65 | + * Drivers that are interested in damage interface for plane should enable |
| 66 | + * FB_DAMAGE_CLIPS property by calling drm_plane_enable_fb_damage_clips(). |
| 67 | + */ |
| 68 | + |
| 69 | +/** |
| 70 | + * drm_plane_enable_fb_damage_clips - Enables plane fb damage clips property. |
| 71 | + * @plane: Plane on which to enable damage clips property. |
| 72 | + * |
| 73 | + * This function lets driver to enable the damage clips property on a plane. |
| 74 | + */ |
| 75 | +void drm_plane_enable_fb_damage_clips(struct drm_plane *plane) |
| 76 | +{ |
| 77 | + struct drm_device *dev = plane->dev; |
| 78 | + struct drm_mode_config *config = &dev->mode_config; |
| 79 | + |
| 80 | + drm_object_attach_property(&plane->base, config->prop_fb_damage_clips, |
| 81 | + 0); |
| 82 | +} |
| 83 | +EXPORT_SYMBOL(drm_plane_enable_fb_damage_clips); |
0 commit comments