1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */ 2 /************************************************************************** 3 * 4 * Copyright (c) 2024-2025 Broadcom. All Rights Reserved. The term 5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. 6 * 7 **************************************************************************/ 8 9 #ifndef VMWGFX_CURSOR_PLANE_H 10 #define VMWGFX_CURSOR_PLANE_H 11 12 #include "device_include/svga3d_cmd.h" 13 #include "drm/drm_file.h" 14 #include "drm/drm_fourcc.h" 15 #include "drm/drm_plane.h" 16 17 #include <linux/types.h> 18 19 struct SVGA3dCmdHeader; 20 struct ttm_buffer_object; 21 struct vmw_bo; 22 struct vmw_cursor; 23 struct vmw_private; 24 struct vmw_surface; 25 struct vmw_user_object; 26 27 #define vmw_plane_to_vcp(x) container_of(x, struct vmw_cursor_plane, base) 28 29 static const u32 __maybe_unused vmw_cursor_plane_formats[] = { 30 DRM_FORMAT_ARGB8888, 31 }; 32 33 enum vmw_cursor_update_type { 34 VMW_CURSOR_UPDATE_NONE = 0, 35 VMW_CURSOR_UPDATE_LEGACY, 36 VMW_CURSOR_UPDATE_MOB, 37 }; 38 39 struct vmw_cursor_plane_state { 40 enum vmw_cursor_update_type update_type; 41 bool changed; 42 bool surface_changed; 43 struct vmw_bo *mob; 44 struct { 45 s32 hotspot_x; 46 s32 hotspot_y; 47 u32 id; 48 } legacy; 49 }; 50 51 /** 52 * Derived class for cursor plane object 53 * 54 * @base DRM plane object 55 * @cursor.cursor_mobs Cursor mobs available for re-use 56 */ 57 struct vmw_cursor_plane { 58 struct drm_plane base; 59 60 struct vmw_bo *cursor_mobs[3]; 61 }; 62 63 struct vmw_surface_metadata; 64 void *vmw_cursor_snooper_create(struct drm_file *file_priv, 65 struct vmw_surface_metadata *metadata); 66 void vmw_cursor_cmd_dma_snoop(SVGA3dCmdHeader *header, 67 struct vmw_surface *srf, 68 struct ttm_buffer_object *bo); 69 70 void vmw_cursor_plane_destroy(struct drm_plane *plane); 71 72 int vmw_cursor_plane_atomic_check(struct drm_plane *plane, 73 struct drm_atomic_state *state); 74 void vmw_cursor_plane_atomic_update(struct drm_plane *plane, 75 struct drm_atomic_state *state); 76 int vmw_cursor_plane_prepare_fb(struct drm_plane *plane, 77 struct drm_plane_state *new_state); 78 void vmw_cursor_plane_cleanup_fb(struct drm_plane *plane, 79 struct drm_plane_state *old_state); 80 81 #endif /* VMWGFX_CURSOR_H */ 82