1dff96888SDirk Hohndel (VMware) /* SPDX-License-Identifier: GPL-2.0 OR MIT */ 2fb1d9738SJakob Bornecrantz /************************************************************************** 3fb1d9738SJakob Bornecrantz * 4*6703e28fSZack Rusin * Copyright 2009-2023 VMware, Inc., Palo Alto, CA., USA 5fb1d9738SJakob Bornecrantz * 6fb1d9738SJakob Bornecrantz * Permission is hereby granted, free of charge, to any person obtaining a 7fb1d9738SJakob Bornecrantz * copy of this software and associated documentation files (the 8fb1d9738SJakob Bornecrantz * "Software"), to deal in the Software without restriction, including 9fb1d9738SJakob Bornecrantz * without limitation the rights to use, copy, modify, merge, publish, 10fb1d9738SJakob Bornecrantz * distribute, sub license, and/or sell copies of the Software, and to 11fb1d9738SJakob Bornecrantz * permit persons to whom the Software is furnished to do so, subject to 12fb1d9738SJakob Bornecrantz * the following conditions: 13fb1d9738SJakob Bornecrantz * 14fb1d9738SJakob Bornecrantz * The above copyright notice and this permission notice (including the 15fb1d9738SJakob Bornecrantz * next paragraph) shall be included in all copies or substantial portions 16fb1d9738SJakob Bornecrantz * of the Software. 17fb1d9738SJakob Bornecrantz * 18fb1d9738SJakob Bornecrantz * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19fb1d9738SJakob Bornecrantz * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20fb1d9738SJakob Bornecrantz * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 21fb1d9738SJakob Bornecrantz * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, 22fb1d9738SJakob Bornecrantz * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 23fb1d9738SJakob Bornecrantz * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 24fb1d9738SJakob Bornecrantz * USE OR OTHER DEALINGS IN THE SOFTWARE. 25fb1d9738SJakob Bornecrantz * 26fb1d9738SJakob Bornecrantz **************************************************************************/ 27fb1d9738SJakob Bornecrantz 28fb1d9738SJakob Bornecrantz #ifndef VMWGFX_KMS_H_ 29fb1d9738SJakob Bornecrantz #define VMWGFX_KMS_H_ 30fb1d9738SJakob Bornecrantz 319338203cSLaurent Pinchart #include <drm/drm_encoder.h> 32720cf96dSVille Syrjälä #include <drm/drm_framebuffer.h> 33fcd70cd3SDaniel Vetter #include <drm/drm_probe_helper.h> 34d5c1f011SSam Ravnborg 35fb1d9738SJakob Bornecrantz #include "vmwgfx_drv.h" 36fb1d9738SJakob Bornecrantz 37e41774c0SDeepak Rawat /** 38e41774c0SDeepak Rawat * struct vmw_du_update_plane - Closure structure for vmw_du_helper_plane_update 39e41774c0SDeepak Rawat * @plane: Plane which is being updated. 40e41774c0SDeepak Rawat * @old_state: Old state of plane. 41e41774c0SDeepak Rawat * @dev_priv: Device private. 42e41774c0SDeepak Rawat * @du: Display unit on which to update the plane. 43e41774c0SDeepak Rawat * @vfb: Framebuffer which is blitted to display unit. 44e41774c0SDeepak Rawat * @out_fence: Out fence for resource finish. 45e41774c0SDeepak Rawat * @mutex: The mutex used to protect resource reservation. 46e41774c0SDeepak Rawat * @cpu_blit: True if need cpu blit. 47e41774c0SDeepak Rawat * @intr: Whether to perform waits interruptible if possible. 48e41774c0SDeepak Rawat * 49e41774c0SDeepak Rawat * This structure loosely represent the set of operations needed to perform a 50e41774c0SDeepak Rawat * plane update on a display unit. Implementer will define that functionality 51e41774c0SDeepak Rawat * according to the function callbacks for this structure. In brief it involves 52e41774c0SDeepak Rawat * surface/buffer object validation, populate FIFO commands and command 53e41774c0SDeepak Rawat * submission to the device. 54e41774c0SDeepak Rawat */ 55e41774c0SDeepak Rawat struct vmw_du_update_plane { 56e41774c0SDeepak Rawat /** 57e41774c0SDeepak Rawat * @calc_fifo_size: Calculate fifo size. 58e41774c0SDeepak Rawat * 59e41774c0SDeepak Rawat * Determine fifo size for the commands needed for update. The number of 60e41774c0SDeepak Rawat * damage clips on display unit @num_hits will be passed to allocate 61e41774c0SDeepak Rawat * sufficient fifo space. 62e41774c0SDeepak Rawat * 63e41774c0SDeepak Rawat * Return: Fifo size needed 64e41774c0SDeepak Rawat */ 65e41774c0SDeepak Rawat uint32_t (*calc_fifo_size)(struct vmw_du_update_plane *update, 66e41774c0SDeepak Rawat uint32_t num_hits); 6736cc79bcSSinclair Yeh 68e41774c0SDeepak Rawat /** 69e41774c0SDeepak Rawat * @post_prepare: Populate fifo for resource preparation. 70e41774c0SDeepak Rawat * 71e41774c0SDeepak Rawat * Some surface resource or buffer object need some extra cmd submission 72e41774c0SDeepak Rawat * like update GB image for proxy surface and define a GMRFB for screen 7305436815STom Rix * object. That should be done here as this callback will be 74e41774c0SDeepak Rawat * called after FIFO allocation with the address of command buufer. 75e41774c0SDeepak Rawat * 76e41774c0SDeepak Rawat * This callback is optional. 77e41774c0SDeepak Rawat * 78e41774c0SDeepak Rawat * Return: Size of commands populated to command buffer. 79e41774c0SDeepak Rawat */ 80e41774c0SDeepak Rawat uint32_t (*post_prepare)(struct vmw_du_update_plane *update, void *cmd); 81e41774c0SDeepak Rawat 82e41774c0SDeepak Rawat /** 83e41774c0SDeepak Rawat * @pre_clip: Populate fifo before clip. 84e41774c0SDeepak Rawat * 85e41774c0SDeepak Rawat * This is where pre clip related command should be populated like 86e41774c0SDeepak Rawat * surface copy/DMA, etc. 87e41774c0SDeepak Rawat * 88e41774c0SDeepak Rawat * This callback is optional. 89e41774c0SDeepak Rawat * 90e41774c0SDeepak Rawat * Return: Size of commands populated to command buffer. 91e41774c0SDeepak Rawat */ 92e41774c0SDeepak Rawat uint32_t (*pre_clip)(struct vmw_du_update_plane *update, void *cmd, 93e41774c0SDeepak Rawat uint32_t num_hits); 94e41774c0SDeepak Rawat 95e41774c0SDeepak Rawat /** 96e41774c0SDeepak Rawat * @clip: Populate fifo for clip. 97e41774c0SDeepak Rawat * 98e41774c0SDeepak Rawat * This is where to populate clips for surface copy/dma or blit commands 99e41774c0SDeepak Rawat * if needed. This will be called times have damage in display unit, 100e41774c0SDeepak Rawat * which is one if doing full update. @clip is the damage in destination 101e41774c0SDeepak Rawat * coordinates which is crtc/DU and @src_x, @src_y is damage clip src in 102e41774c0SDeepak Rawat * framebuffer coordinate. 103e41774c0SDeepak Rawat * 104e41774c0SDeepak Rawat * This callback is optional. 105e41774c0SDeepak Rawat * 106e41774c0SDeepak Rawat * Return: Size of commands populated to command buffer. 107e41774c0SDeepak Rawat */ 108e41774c0SDeepak Rawat uint32_t (*clip)(struct vmw_du_update_plane *update, void *cmd, 109e41774c0SDeepak Rawat struct drm_rect *clip, uint32_t src_x, uint32_t src_y); 110e41774c0SDeepak Rawat 111e41774c0SDeepak Rawat /** 112e41774c0SDeepak Rawat * @post_clip: Populate fifo after clip. 113e41774c0SDeepak Rawat * 114e41774c0SDeepak Rawat * This is where to populate display unit update commands or blit 115e41774c0SDeepak Rawat * commands. 116e41774c0SDeepak Rawat * 117e41774c0SDeepak Rawat * Return: Size of commands populated to command buffer. 118e41774c0SDeepak Rawat */ 119e41774c0SDeepak Rawat uint32_t (*post_clip)(struct vmw_du_update_plane *update, void *cmd, 120e41774c0SDeepak Rawat struct drm_rect *bb); 121e41774c0SDeepak Rawat 122e41774c0SDeepak Rawat struct drm_plane *plane; 123e41774c0SDeepak Rawat struct drm_plane_state *old_state; 124e41774c0SDeepak Rawat struct vmw_private *dev_priv; 125e41774c0SDeepak Rawat struct vmw_display_unit *du; 126e41774c0SDeepak Rawat struct vmw_framebuffer *vfb; 127e41774c0SDeepak Rawat struct vmw_fence_obj **out_fence; 128e41774c0SDeepak Rawat struct mutex *mutex; 129e41774c0SDeepak Rawat bool cpu_blit; 130e41774c0SDeepak Rawat bool intr; 131e41774c0SDeepak Rawat }; 13236cc79bcSSinclair Yeh 1331a4b172aSThomas Hellstrom /** 13443d1e627SDeepak Rawat * struct vmw_du_update_plane_surface - closure structure for surface 13543d1e627SDeepak Rawat * @base: base closure structure. 13643d1e627SDeepak Rawat * @cmd_start: FIFO command start address (used by SOU only). 13743d1e627SDeepak Rawat */ 13843d1e627SDeepak Rawat struct vmw_du_update_plane_surface { 13943d1e627SDeepak Rawat struct vmw_du_update_plane base; 14043d1e627SDeepak Rawat /* This member is to handle special case SOU surface update */ 14143d1e627SDeepak Rawat void *cmd_start; 14243d1e627SDeepak Rawat }; 14343d1e627SDeepak Rawat 14443d1e627SDeepak Rawat /** 145bc7be607SDeepak Rawat * struct vmw_du_update_plane_buffer - Closure structure for buffer object 146bc7be607SDeepak Rawat * @base: Base closure structure. 147bc7be607SDeepak Rawat * @fb_left: x1 for fb damage bounding box. 148bc7be607SDeepak Rawat * @fb_top: y1 for fb damage bounding box. 149bc7be607SDeepak Rawat */ 150bc7be607SDeepak Rawat struct vmw_du_update_plane_buffer { 151bc7be607SDeepak Rawat struct vmw_du_update_plane base; 152bc7be607SDeepak Rawat int fb_left, fb_top; 153bc7be607SDeepak Rawat }; 154bc7be607SDeepak Rawat 155bc7be607SDeepak Rawat /** 1561a4b172aSThomas Hellstrom * struct vmw_kms_dirty - closure structure for the vmw_kms_helper_dirty 1571a4b172aSThomas Hellstrom * function. 1581a4b172aSThomas Hellstrom * 1591a4b172aSThomas Hellstrom * @fifo_commit: Callback that is called once for each display unit after 1601a4b172aSThomas Hellstrom * all clip rects. This function must commit the fifo space reserved by the 1611a4b172aSThomas Hellstrom * helper. Set up by the caller. 1621a4b172aSThomas Hellstrom * @clip: Callback that is called for each cliprect on each display unit. 1631a4b172aSThomas Hellstrom * Set up by the caller. 1641a4b172aSThomas Hellstrom * @fifo_reserve_size: Fifo size that the helper should try to allocat for 1651a4b172aSThomas Hellstrom * each display unit. Set up by the caller. 1661a4b172aSThomas Hellstrom * @dev_priv: Pointer to the device private. Set up by the helper. 1671a4b172aSThomas Hellstrom * @unit: The current display unit. Set up by the helper before a call to @clip. 1681a4b172aSThomas Hellstrom * @cmd: The allocated fifo space. Set up by the helper before the first @clip 1691a4b172aSThomas Hellstrom * call. 17091e9f352SDeepak Rawat * @crtc: The crtc for which to build dirty commands. 1711a4b172aSThomas Hellstrom * @num_hits: Number of clip rect commands for this display unit. 1721a4b172aSThomas Hellstrom * Cleared by the helper before the first @clip call. Updated by the @clip 1731a4b172aSThomas Hellstrom * callback. 1741a4b172aSThomas Hellstrom * @fb_x: Clip rect left side in framebuffer coordinates. 1751a4b172aSThomas Hellstrom * @fb_y: Clip rect right side in framebuffer coordinates. 1761a4b172aSThomas Hellstrom * @unit_x1: Clip rect left side in crtc coordinates. 1771a4b172aSThomas Hellstrom * @unit_y1: Clip rect top side in crtc coordinates. 1781a4b172aSThomas Hellstrom * @unit_x2: Clip rect right side in crtc coordinates. 1791a4b172aSThomas Hellstrom * @unit_y2: Clip rect bottom side in crtc coordinates. 1801a4b172aSThomas Hellstrom * 1811a4b172aSThomas Hellstrom * The clip rect coordinates are updated by the helper for each @clip call. 1821a4b172aSThomas Hellstrom * Note that this may be derived from if more info needs to be passed between 1831a4b172aSThomas Hellstrom * helper caller and helper callbacks. 1841a4b172aSThomas Hellstrom */ 1851a4b172aSThomas Hellstrom struct vmw_kms_dirty { 1861a4b172aSThomas Hellstrom void (*fifo_commit)(struct vmw_kms_dirty *); 1871a4b172aSThomas Hellstrom void (*clip)(struct vmw_kms_dirty *); 1881a4b172aSThomas Hellstrom size_t fifo_reserve_size; 1891a4b172aSThomas Hellstrom struct vmw_private *dev_priv; 1901a4b172aSThomas Hellstrom struct vmw_display_unit *unit; 1911a4b172aSThomas Hellstrom void *cmd; 19291e9f352SDeepak Rawat struct drm_crtc *crtc; 1931a4b172aSThomas Hellstrom u32 num_hits; 1941a4b172aSThomas Hellstrom s32 fb_x; 1951a4b172aSThomas Hellstrom s32 fb_y; 1961a4b172aSThomas Hellstrom s32 unit_x1; 1971a4b172aSThomas Hellstrom s32 unit_y1; 1981a4b172aSThomas Hellstrom s32 unit_x2; 1991a4b172aSThomas Hellstrom s32 unit_y2; 2001a4b172aSThomas Hellstrom }; 201c8261a96SSinclair Yeh 20256d1c78dSJakob Bornecrantz #define VMWGFX_NUM_DISPLAY_UNITS 8 20356d1c78dSJakob Bornecrantz 204fb1d9738SJakob Bornecrantz 205fb1d9738SJakob Bornecrantz #define vmw_framebuffer_to_vfb(x) \ 206fb1d9738SJakob Bornecrantz container_of(x, struct vmw_framebuffer, base) 207c8261a96SSinclair Yeh #define vmw_framebuffer_to_vfbs(x) \ 208c8261a96SSinclair Yeh container_of(x, struct vmw_framebuffer_surface, base.base) 209c8261a96SSinclair Yeh #define vmw_framebuffer_to_vfbd(x) \ 210f1d34bfdSThomas Hellstrom container_of(x, struct vmw_framebuffer_bo, base.base) 211fb1d9738SJakob Bornecrantz 212fb1d9738SJakob Bornecrantz /** 213fb1d9738SJakob Bornecrantz * Base class for framebuffers 214fb1d9738SJakob Bornecrantz * 215fb1d9738SJakob Bornecrantz * @pin is called the when ever a crtc uses this framebuffer 216fb1d9738SJakob Bornecrantz * @unpin is called 217fb1d9738SJakob Bornecrantz */ 218fb1d9738SJakob Bornecrantz struct vmw_framebuffer { 219fb1d9738SJakob Bornecrantz struct drm_framebuffer base; 220f1d34bfdSThomas Hellstrom bool bo; 22190ff18bcSThomas Hellstrom uint32_t user_handle; 222fb1d9738SJakob Bornecrantz }; 223fb1d9738SJakob Bornecrantz 224c8261a96SSinclair Yeh /* 225c8261a96SSinclair Yeh * Clip rectangle 226c8261a96SSinclair Yeh */ 227c8261a96SSinclair Yeh struct vmw_clip_rect { 228c8261a96SSinclair Yeh int x1, x2, y1, y2; 229c8261a96SSinclair Yeh }; 230fb1d9738SJakob Bornecrantz 231c8261a96SSinclair Yeh struct vmw_framebuffer_surface { 232c8261a96SSinclair Yeh struct vmw_framebuffer base; 233c8261a96SSinclair Yeh struct vmw_surface *surface; 23409881d29SZack Rusin struct vmw_bo *buffer; 235c8261a96SSinclair Yeh struct list_head head; 236f1d34bfdSThomas Hellstrom bool is_bo_proxy; /* true if this is proxy surface for DMA buf */ 237c8261a96SSinclair Yeh }; 238c8261a96SSinclair Yeh 239c8261a96SSinclair Yeh 240f1d34bfdSThomas Hellstrom struct vmw_framebuffer_bo { 241c8261a96SSinclair Yeh struct vmw_framebuffer base; 24209881d29SZack Rusin struct vmw_bo *buffer; 243c8261a96SSinclair Yeh }; 244c8261a96SSinclair Yeh 245fb1d9738SJakob Bornecrantz 246d8713d66SLee Jones static const uint32_t __maybe_unused vmw_primary_plane_formats[] = { 24736cc79bcSSinclair Yeh DRM_FORMAT_XRGB1555, 24836cc79bcSSinclair Yeh DRM_FORMAT_RGB565, 24936cc79bcSSinclair Yeh DRM_FORMAT_XRGB8888, 25036cc79bcSSinclair Yeh DRM_FORMAT_ARGB8888, 25136cc79bcSSinclair Yeh }; 252fb1d9738SJakob Bornecrantz 253d8713d66SLee Jones static const uint32_t __maybe_unused vmw_cursor_plane_formats[] = { 25436cc79bcSSinclair Yeh DRM_FORMAT_ARGB8888, 25536cc79bcSSinclair Yeh }; 256bfc2638dSJakob Bornecrantz 2579c2542a4SSinclair Yeh 2589c2542a4SSinclair Yeh #define vmw_crtc_state_to_vcs(x) container_of(x, struct vmw_crtc_state, base) 259cc5ec459SSinclair Yeh #define vmw_plane_state_to_vps(x) container_of(x, struct vmw_plane_state, base) 260d7721ca7SSinclair Yeh #define vmw_connector_state_to_vcs(x) \ 261d7721ca7SSinclair Yeh container_of(x, struct vmw_connector_state, base) 262485d98d4SMartin Krastev #define vmw_plane_to_vcp(x) container_of(x, struct vmw_cursor_plane, base) 2639c2542a4SSinclair Yeh 2649c2542a4SSinclair Yeh /** 2659c2542a4SSinclair Yeh * Derived class for crtc state object 2669c2542a4SSinclair Yeh * 2679c2542a4SSinclair Yeh * @base DRM crtc object 2689c2542a4SSinclair Yeh */ 2699c2542a4SSinclair Yeh struct vmw_crtc_state { 2709c2542a4SSinclair Yeh struct drm_crtc_state base; 2719c2542a4SSinclair Yeh }; 2729c2542a4SSinclair Yeh 27340f9e40bSMichael Banack struct vmw_cursor_plane_state { 27440f9e40bSMichael Banack struct ttm_buffer_object *bo; 27540f9e40bSMichael Banack struct ttm_bo_kmap_obj map; 27640f9e40bSMichael Banack bool mapped; 277bb6780aaSMichael Banack s32 hotspot_x; 278bb6780aaSMichael Banack s32 hotspot_y; 27940f9e40bSMichael Banack }; 28040f9e40bSMichael Banack 281fb1d9738SJakob Bornecrantz /** 282cc5ec459SSinclair Yeh * Derived class for plane state object 283cc5ec459SSinclair Yeh * 284cc5ec459SSinclair Yeh * @base DRM plane object 285cc5ec459SSinclair Yeh * @surf Display surface for STDU 286f1d34bfdSThomas Hellstrom * @bo display bo for SOU 287cc5ec459SSinclair Yeh * @content_fb_type Used by STDU. 288f1d34bfdSThomas Hellstrom * @bo_size Size of the bo, used by Screen Object Display Unit 289cc5ec459SSinclair Yeh * @pinned pin count for STDU display surface 290cc5ec459SSinclair Yeh */ 291cc5ec459SSinclair Yeh struct vmw_plane_state { 292cc5ec459SSinclair Yeh struct drm_plane_state base; 293cc5ec459SSinclair Yeh struct vmw_surface *surf; 29409881d29SZack Rusin struct vmw_bo *bo; 295cc5ec459SSinclair Yeh 296cc5ec459SSinclair Yeh int content_fb_type; 297f1d34bfdSThomas Hellstrom unsigned long bo_size; 298cc5ec459SSinclair Yeh 299cc5ec459SSinclair Yeh int pinned; 300810b3e16SSinclair Yeh 301810b3e16SSinclair Yeh /* For CPU Blit */ 302810b3e16SSinclair Yeh unsigned int cpp; 303485d98d4SMartin Krastev 30492f59ac4SMichael Banack bool surf_mapped; 30540f9e40bSMichael Banack struct vmw_cursor_plane_state cursor; 306cc5ec459SSinclair Yeh }; 307cc5ec459SSinclair Yeh 308d7721ca7SSinclair Yeh 309d7721ca7SSinclair Yeh /** 310d7721ca7SSinclair Yeh * Derived class for connector state object 311d7721ca7SSinclair Yeh * 312d7721ca7SSinclair Yeh * @base DRM connector object 313d7721ca7SSinclair Yeh * @is_implicit connector property 314d7721ca7SSinclair Yeh * 315d7721ca7SSinclair Yeh */ 316d7721ca7SSinclair Yeh struct vmw_connector_state { 317d7721ca7SSinclair Yeh struct drm_connector_state base; 318d7721ca7SSinclair Yeh 3193e79ecdaSDeepak Rawat /** 3203e79ecdaSDeepak Rawat * @gui_x: 3213e79ecdaSDeepak Rawat * 3223e79ecdaSDeepak Rawat * vmwgfx connector property representing the x position of this display 3233e79ecdaSDeepak Rawat * unit (connector is synonymous to display unit) in overall topology. 3243e79ecdaSDeepak Rawat * This is what the device expect as xRoot while creating screen. 3253e79ecdaSDeepak Rawat */ 3263e79ecdaSDeepak Rawat int gui_x; 3273e79ecdaSDeepak Rawat 3283e79ecdaSDeepak Rawat /** 3293e79ecdaSDeepak Rawat * @gui_y: 3303e79ecdaSDeepak Rawat * 3313e79ecdaSDeepak Rawat * vmwgfx connector property representing the y position of this display 3323e79ecdaSDeepak Rawat * unit (connector is synonymous to display unit) in overall topology. 3333e79ecdaSDeepak Rawat * This is what the device expect as yRoot while creating screen. 3343e79ecdaSDeepak Rawat */ 3353e79ecdaSDeepak Rawat int gui_y; 336d7721ca7SSinclair Yeh }; 337d7721ca7SSinclair Yeh 338cc5ec459SSinclair Yeh /** 339485d98d4SMartin Krastev * Derived class for cursor plane object 340485d98d4SMartin Krastev * 341485d98d4SMartin Krastev * @base DRM plane object 34253bc3f6fSMichael Banack * @cursor.cursor_mobs Cursor mobs available for re-use 343485d98d4SMartin Krastev */ 344485d98d4SMartin Krastev struct vmw_cursor_plane { 345485d98d4SMartin Krastev struct drm_plane base; 34653bc3f6fSMichael Banack 34753bc3f6fSMichael Banack struct ttm_buffer_object *cursor_mobs[3]; 348485d98d4SMartin Krastev }; 349485d98d4SMartin Krastev 350485d98d4SMartin Krastev /** 351fb1d9738SJakob Bornecrantz * Base class display unit. 352fb1d9738SJakob Bornecrantz * 353fb1d9738SJakob Bornecrantz * Since the SVGA hw doesn't have a concept of a crtc, encoder or connector 354fb1d9738SJakob Bornecrantz * so the display unit is all of them at the same time. This is true for both 355fb1d9738SJakob Bornecrantz * legacy multimon and screen objects. 356fb1d9738SJakob Bornecrantz */ 357fb1d9738SJakob Bornecrantz struct vmw_display_unit { 358fb1d9738SJakob Bornecrantz struct drm_crtc crtc; 359fb1d9738SJakob Bornecrantz struct drm_encoder encoder; 360fb1d9738SJakob Bornecrantz struct drm_connector connector; 36136cc79bcSSinclair Yeh struct drm_plane primary; 362485d98d4SMartin Krastev struct vmw_cursor_plane cursor; 363fb1d9738SJakob Bornecrantz 364fb1d9738SJakob Bornecrantz struct vmw_surface *cursor_surface; 36509881d29SZack Rusin struct vmw_bo *cursor_bo; 366fb1d9738SJakob Bornecrantz size_t cursor_age; 367fb1d9738SJakob Bornecrantz 368fb1d9738SJakob Bornecrantz int cursor_x; 369fb1d9738SJakob Bornecrantz int cursor_y; 370fb1d9738SJakob Bornecrantz 371fb1d9738SJakob Bornecrantz int hotspot_x; 372fb1d9738SJakob Bornecrantz int hotspot_y; 3738fbf9d92SThomas Hellstrom s32 core_hotspot_x; 3748fbf9d92SThomas Hellstrom s32 core_hotspot_y; 375fb1d9738SJakob Bornecrantz 376fb1d9738SJakob Bornecrantz unsigned unit; 377626ab771SJakob Bornecrantz 378626ab771SJakob Bornecrantz /* 379626ab771SJakob Bornecrantz * Prefered mode tracking. 380626ab771SJakob Bornecrantz */ 381626ab771SJakob Bornecrantz unsigned pref_width; 382626ab771SJakob Bornecrantz unsigned pref_height; 383626ab771SJakob Bornecrantz bool pref_active; 384626ab771SJakob Bornecrantz struct drm_display_mode *pref_mode; 385cd2b89e7SThomas Hellstrom 386cd2b89e7SThomas Hellstrom /* 387cd2b89e7SThomas Hellstrom * Gui positioning 388cd2b89e7SThomas Hellstrom */ 389cd2b89e7SThomas Hellstrom int gui_x; 390cd2b89e7SThomas Hellstrom int gui_y; 3916987427aSThomas Hellstrom bool is_implicit; 3926dd687b4SThomas Hellstrom int set_gui_x; 3936dd687b4SThomas Hellstrom int set_gui_y; 394fb1d9738SJakob Bornecrantz }; 395fb1d9738SJakob Bornecrantz 39673a88250SThomas Hellstrom struct vmw_validation_ctx { 39773a88250SThomas Hellstrom struct vmw_resource *res; 39809881d29SZack Rusin struct vmw_bo *buf; 39973a88250SThomas Hellstrom }; 40073a88250SThomas Hellstrom 4012fcd5a73SJakob Bornecrantz #define vmw_crtc_to_du(x) \ 4022fcd5a73SJakob Bornecrantz container_of(x, struct vmw_display_unit, crtc) 403626ab771SJakob Bornecrantz #define vmw_connector_to_du(x) \ 404626ab771SJakob Bornecrantz container_of(x, struct vmw_display_unit, connector) 405626ab771SJakob Bornecrantz 406626ab771SJakob Bornecrantz 407fb1d9738SJakob Bornecrantz /* 408fb1d9738SJakob Bornecrantz * Shared display unit functions - vmwgfx_kms.c 409fb1d9738SJakob Bornecrantz */ 410c8261a96SSinclair Yeh void vmw_du_cleanup(struct vmw_display_unit *du); 411626ab771SJakob Bornecrantz void vmw_du_crtc_save(struct drm_crtc *crtc); 412626ab771SJakob Bornecrantz void vmw_du_crtc_restore(struct drm_crtc *crtc); 4137ea77283SMaarten Lankhorst int vmw_du_crtc_gamma_set(struct drm_crtc *crtc, 414626ab771SJakob Bornecrantz u16 *r, u16 *g, u16 *b, 4156d124ff8SDaniel Vetter uint32_t size, 4166d124ff8SDaniel Vetter struct drm_modeset_acquire_ctx *ctx); 4179c2542a4SSinclair Yeh int vmw_du_connector_set_property(struct drm_connector *connector, 4189c2542a4SSinclair Yeh struct drm_property *property, 4199c2542a4SSinclair Yeh uint64_t val); 420d7721ca7SSinclair Yeh int vmw_du_connector_atomic_set_property(struct drm_connector *connector, 421d7721ca7SSinclair Yeh struct drm_connector_state *state, 422d7721ca7SSinclair Yeh struct drm_property *property, 423d7721ca7SSinclair Yeh uint64_t val); 424d7721ca7SSinclair Yeh int 425d7721ca7SSinclair Yeh vmw_du_connector_atomic_get_property(struct drm_connector *connector, 426d7721ca7SSinclair Yeh const struct drm_connector_state *state, 427d7721ca7SSinclair Yeh struct drm_property *property, 428d7721ca7SSinclair Yeh uint64_t *val); 4299a69a9acSMaarten Lankhorst int vmw_du_connector_dpms(struct drm_connector *connector, int mode); 430626ab771SJakob Bornecrantz void vmw_du_connector_save(struct drm_connector *connector); 431626ab771SJakob Bornecrantz void vmw_du_connector_restore(struct drm_connector *connector); 432626ab771SJakob Bornecrantz enum drm_connector_status 433626ab771SJakob Bornecrantz vmw_du_connector_detect(struct drm_connector *connector, bool force); 434626ab771SJakob Bornecrantz int vmw_du_connector_fill_modes(struct drm_connector *connector, 435626ab771SJakob Bornecrantz uint32_t max_width, uint32_t max_height); 4361a4b172aSThomas Hellstrom int vmw_kms_helper_dirty(struct vmw_private *dev_priv, 4371a4b172aSThomas Hellstrom struct vmw_framebuffer *framebuffer, 4381a4b172aSThomas Hellstrom const struct drm_clip_rect *clips, 4391a4b172aSThomas Hellstrom const struct drm_vmw_rect *vclips, 4401a4b172aSThomas Hellstrom s32 dest_x, s32 dest_y, 4411a4b172aSThomas Hellstrom int num_clips, 4421a4b172aSThomas Hellstrom int increment, 4431a4b172aSThomas Hellstrom struct vmw_kms_dirty *dirty); 444cd2b89e7SThomas Hellstrom 4452724b2d5SThomas Hellstrom void vmw_kms_helper_validation_finish(struct vmw_private *dev_priv, 4461a4b172aSThomas Hellstrom struct drm_file *file_priv, 4472724b2d5SThomas Hellstrom struct vmw_validation_context *ctx, 4481a4b172aSThomas Hellstrom struct vmw_fence_obj **out_fence, 4491a4b172aSThomas Hellstrom struct drm_vmw_fence_rep __user * 4501a4b172aSThomas Hellstrom user_fence_rep); 45110b1e0caSThomas Hellstrom int vmw_kms_readback(struct vmw_private *dev_priv, 45210b1e0caSThomas Hellstrom struct drm_file *file_priv, 45310b1e0caSThomas Hellstrom struct vmw_framebuffer *vfb, 45410b1e0caSThomas Hellstrom struct drm_vmw_fence_rep __user *user_fence_rep, 45510b1e0caSThomas Hellstrom struct drm_vmw_rect *vclips, 45610b1e0caSThomas Hellstrom uint32_t num_clips); 457fd006a43SThomas Hellstrom struct vmw_framebuffer * 458fd006a43SThomas Hellstrom vmw_kms_new_framebuffer(struct vmw_private *dev_priv, 45909881d29SZack Rusin struct vmw_bo *bo, 460fd006a43SThomas Hellstrom struct vmw_surface *surface, 461fd006a43SThomas Hellstrom bool only_2d, 462dabdcdc9SDaniel Vetter const struct drm_mode_fb_cmd2 *mode_cmd); 463a278724aSThomas Hellstrom void vmw_guess_mode_timing(struct drm_display_mode *mode); 4649d9486e4SThomas Hellstrom void vmw_kms_update_implicit_fb(struct vmw_private *dev_priv); 4659d9486e4SThomas Hellstrom void vmw_kms_create_implicit_placement_property(struct vmw_private *dev_priv); 46675c06855SThomas Hellstrom 46736cc79bcSSinclair Yeh /* Universal Plane Helpers */ 46836cc79bcSSinclair Yeh void vmw_du_primary_plane_destroy(struct drm_plane *plane); 46936cc79bcSSinclair Yeh void vmw_du_cursor_plane_destroy(struct drm_plane *plane); 47036cc79bcSSinclair Yeh 47106ec4190SSinclair Yeh /* Atomic Helpers */ 472060e2ad5SSinclair Yeh int vmw_du_primary_plane_atomic_check(struct drm_plane *plane, 4737c11b99aSMaxime Ripard struct drm_atomic_state *state); 474060e2ad5SSinclair Yeh int vmw_du_cursor_plane_atomic_check(struct drm_plane *plane, 4757c11b99aSMaxime Ripard struct drm_atomic_state *state); 476060e2ad5SSinclair Yeh void vmw_du_cursor_plane_atomic_update(struct drm_plane *plane, 477977697e2SMaxime Ripard struct drm_atomic_state *state); 478060e2ad5SSinclair Yeh int vmw_du_cursor_plane_prepare_fb(struct drm_plane *plane, 479060e2ad5SSinclair Yeh struct drm_plane_state *new_state); 480485d98d4SMartin Krastev void vmw_du_cursor_plane_cleanup_fb(struct drm_plane *plane, 481485d98d4SMartin Krastev struct drm_plane_state *old_state); 482060e2ad5SSinclair Yeh void vmw_du_plane_cleanup_fb(struct drm_plane *plane, 483060e2ad5SSinclair Yeh struct drm_plane_state *old_state); 484cc5ec459SSinclair Yeh void vmw_du_plane_reset(struct drm_plane *plane); 485cc5ec459SSinclair Yeh struct drm_plane_state *vmw_du_plane_duplicate_state(struct drm_plane *plane); 486cc5ec459SSinclair Yeh void vmw_du_plane_destroy_state(struct drm_plane *plane, 487cc5ec459SSinclair Yeh struct drm_plane_state *state); 488060e2ad5SSinclair Yeh void vmw_du_plane_unpin_surf(struct vmw_plane_state *vps, 489060e2ad5SSinclair Yeh bool unreference); 490060e2ad5SSinclair Yeh 49106ec4190SSinclair Yeh int vmw_du_crtc_atomic_check(struct drm_crtc *crtc, 49229b77ad7SMaxime Ripard struct drm_atomic_state *state); 49306ec4190SSinclair Yeh void vmw_du_crtc_atomic_begin(struct drm_crtc *crtc, 494f6ebe9f9SMaxime Ripard struct drm_atomic_state *state); 49506ec4190SSinclair Yeh void vmw_du_crtc_atomic_flush(struct drm_crtc *crtc, 496f6ebe9f9SMaxime Ripard struct drm_atomic_state *state); 4979c2542a4SSinclair Yeh void vmw_du_crtc_reset(struct drm_crtc *crtc); 4989c2542a4SSinclair Yeh struct drm_crtc_state *vmw_du_crtc_duplicate_state(struct drm_crtc *crtc); 4999c2542a4SSinclair Yeh void vmw_du_crtc_destroy_state(struct drm_crtc *crtc, 5009c2542a4SSinclair Yeh struct drm_crtc_state *state); 501d7721ca7SSinclair Yeh void vmw_du_connector_reset(struct drm_connector *connector); 502d7721ca7SSinclair Yeh struct drm_connector_state * 503d7721ca7SSinclair Yeh vmw_du_connector_duplicate_state(struct drm_connector *connector); 504d7721ca7SSinclair Yeh 505d7721ca7SSinclair Yeh void vmw_du_connector_destroy_state(struct drm_connector *connector, 506d7721ca7SSinclair Yeh struct drm_connector_state *state); 507fb1d9738SJakob Bornecrantz 508fb1d9738SJakob Bornecrantz /* 509d8bd19d2SJakob Bornecrantz * Legacy display unit functions - vmwgfx_ldu.c 510fb1d9738SJakob Bornecrantz */ 511c8261a96SSinclair Yeh int vmw_kms_ldu_init_display(struct vmw_private *dev_priv); 512c8261a96SSinclair Yeh int vmw_kms_ldu_close_display(struct vmw_private *dev_priv); 513f1d34bfdSThomas Hellstrom int vmw_kms_ldu_do_bo_dirty(struct vmw_private *dev_priv, 514c8261a96SSinclair Yeh struct vmw_framebuffer *framebuffer, 515f1d34bfdSThomas Hellstrom unsigned int flags, unsigned int color, 516c8261a96SSinclair Yeh struct drm_clip_rect *clips, 517f1d34bfdSThomas Hellstrom unsigned int num_clips, int increment); 5186bf6bf03SThomas Hellstrom int vmw_kms_update_proxy(struct vmw_resource *res, 5196bf6bf03SThomas Hellstrom const struct drm_clip_rect *clips, 5206bf6bf03SThomas Hellstrom unsigned num_clips, 5216bf6bf03SThomas Hellstrom int increment); 522fb1d9738SJakob Bornecrantz 52356d1c78dSJakob Bornecrantz /* 52456d1c78dSJakob Bornecrantz * Screen Objects display functions - vmwgfx_scrn.c 52556d1c78dSJakob Bornecrantz */ 526c8261a96SSinclair Yeh int vmw_kms_sou_init_display(struct vmw_private *dev_priv); 527c8261a96SSinclair Yeh int vmw_kms_sou_do_surface_dirty(struct vmw_private *dev_priv, 528c8261a96SSinclair Yeh struct vmw_framebuffer *framebuffer, 529c8261a96SSinclair Yeh struct drm_clip_rect *clips, 53010b1e0caSThomas Hellstrom struct drm_vmw_rect *vclips, 53110b1e0caSThomas Hellstrom struct vmw_resource *srf, 53210b1e0caSThomas Hellstrom s32 dest_x, 53310b1e0caSThomas Hellstrom s32 dest_y, 534c8261a96SSinclair Yeh unsigned num_clips, int inc, 53591e9f352SDeepak Rawat struct vmw_fence_obj **out_fence, 53691e9f352SDeepak Rawat struct drm_crtc *crtc); 537f1d34bfdSThomas Hellstrom int vmw_kms_sou_do_bo_dirty(struct vmw_private *dev_priv, 538c8261a96SSinclair Yeh struct vmw_framebuffer *framebuffer, 539c8261a96SSinclair Yeh struct drm_clip_rect *clips, 540897b8180SThomas Hellstrom struct drm_vmw_rect *vclips, 541f1d34bfdSThomas Hellstrom unsigned int num_clips, int increment, 54210b1e0caSThomas Hellstrom bool interruptible, 54391e9f352SDeepak Rawat struct vmw_fence_obj **out_fence, 54491e9f352SDeepak Rawat struct drm_crtc *crtc); 54510b1e0caSThomas Hellstrom int vmw_kms_sou_readback(struct vmw_private *dev_priv, 54610b1e0caSThomas Hellstrom struct drm_file *file_priv, 54710b1e0caSThomas Hellstrom struct vmw_framebuffer *vfb, 54810b1e0caSThomas Hellstrom struct drm_vmw_fence_rep __user *user_fence_rep, 54910b1e0caSThomas Hellstrom struct drm_vmw_rect *vclips, 55091e9f352SDeepak Rawat uint32_t num_clips, 55191e9f352SDeepak Rawat struct drm_crtc *crtc); 55235c05125SSinclair Yeh 55335c05125SSinclair Yeh /* 55435c05125SSinclair Yeh * Screen Target Display Unit functions - vmwgfx_stdu.c 55535c05125SSinclair Yeh */ 55635c05125SSinclair Yeh int vmw_kms_stdu_init_display(struct vmw_private *dev_priv); 5576bf6bf03SThomas Hellstrom int vmw_kms_stdu_surface_dirty(struct vmw_private *dev_priv, 55835c05125SSinclair Yeh struct vmw_framebuffer *framebuffer, 55935c05125SSinclair Yeh struct drm_clip_rect *clips, 5606bf6bf03SThomas Hellstrom struct drm_vmw_rect *vclips, 5616bf6bf03SThomas Hellstrom struct vmw_resource *srf, 5626bf6bf03SThomas Hellstrom s32 dest_x, 5636bf6bf03SThomas Hellstrom s32 dest_y, 5646bf6bf03SThomas Hellstrom unsigned num_clips, int inc, 56591e9f352SDeepak Rawat struct vmw_fence_obj **out_fence, 56691e9f352SDeepak Rawat struct drm_crtc *crtc); 5676bf6bf03SThomas Hellstrom int vmw_kms_stdu_dma(struct vmw_private *dev_priv, 56835c05125SSinclair Yeh struct drm_file *file_priv, 56935c05125SSinclair Yeh struct vmw_framebuffer *vfb, 5706bf6bf03SThomas Hellstrom struct drm_vmw_fence_rep __user *user_fence_rep, 5716bf6bf03SThomas Hellstrom struct drm_clip_rect *clips, 5726bf6bf03SThomas Hellstrom struct drm_vmw_rect *vclips, 5736bf6bf03SThomas Hellstrom uint32_t num_clips, 5746bf6bf03SThomas Hellstrom int increment, 5756bf6bf03SThomas Hellstrom bool to_surface, 57691e9f352SDeepak Rawat bool interruptible, 57791e9f352SDeepak Rawat struct drm_crtc *crtc); 578b5ec427eSJakob Bornecrantz 579e41774c0SDeepak Rawat int vmw_du_helper_plane_update(struct vmw_du_update_plane *update); 580e41774c0SDeepak Rawat 581e41774c0SDeepak Rawat /** 582e41774c0SDeepak Rawat * vmw_du_translate_to_crtc - Translate a rect from framebuffer to crtc 583e41774c0SDeepak Rawat * @state: Plane state. 584e41774c0SDeepak Rawat * @r: Rectangle to translate. 585e41774c0SDeepak Rawat */ 586e41774c0SDeepak Rawat static inline void vmw_du_translate_to_crtc(struct drm_plane_state *state, 587e41774c0SDeepak Rawat struct drm_rect *r) 588e41774c0SDeepak Rawat { 589e41774c0SDeepak Rawat int translate_crtc_x = -((state->src_x >> 16) - state->crtc_x); 590e41774c0SDeepak Rawat int translate_crtc_y = -((state->src_y >> 16) - state->crtc_y); 591e41774c0SDeepak Rawat 592e41774c0SDeepak Rawat drm_rect_translate(r, translate_crtc_x, translate_crtc_y); 593e41774c0SDeepak Rawat } 594e41774c0SDeepak Rawat 595fb1d9738SJakob Bornecrantz #endif 596