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
19struct SVGA3dCmdHeader;
20struct ttm_buffer_object;
21struct vmw_bo;
22struct vmw_cursor;
23struct vmw_private;
24struct vmw_surface;
25struct vmw_user_object;
26
27#define vmw_plane_to_vcp(x) container_of(x, struct vmw_cursor_plane, base)
28
29static const u32 __maybe_unused vmw_cursor_plane_formats[] = {
30 DRM_FORMAT_ARGB8888,
31};
32
33enum vmw_cursor_update_type {
34 VMW_CURSOR_UPDATE_NONE = 0,
35 VMW_CURSOR_UPDATE_LEGACY,
36 VMW_CURSOR_UPDATE_GB_ONLY,
37 VMW_CURSOR_UPDATE_MOB,
38};
39
40struct vmw_cursor_plane_state {
41 enum vmw_cursor_update_type update_type;
42 bool changed;
43 bool surface_changed;
44 struct vmw_bo *mob;
45 struct {
46 s32 hotspot_x;
47 s32 hotspot_y;
48 u32 id;
49 } legacy;
50};
51
52/**
53 * Derived class for cursor plane object
54 *
55 * @base DRM plane object
56 * @cursor.cursor_mobs Cursor mobs available for re-use
57 */
58struct vmw_cursor_plane {
59 struct drm_plane base;
60
61 struct vmw_bo *cursor_mobs[3];
62};
63
64struct vmw_surface_metadata;
65void *vmw_cursor_snooper_create(struct drm_file *file_priv,
66 struct vmw_surface_metadata *metadata);
67void vmw_cursor_cmd_dma_snoop(SVGA3dCmdHeader *header,
68 struct vmw_surface *srf,
69 struct ttm_buffer_object *bo);
70
71void vmw_cursor_plane_destroy(struct drm_plane *plane);
72
73int vmw_cursor_plane_atomic_check(struct drm_plane *plane,
74 struct drm_atomic_state *state);
75void vmw_cursor_plane_atomic_update(struct drm_plane *plane,
76 struct drm_atomic_state *state);
77int vmw_cursor_plane_prepare_fb(struct drm_plane *plane,
78 struct drm_plane_state *new_state);
79void vmw_cursor_plane_cleanup_fb(struct drm_plane *plane,
80 struct drm_plane_state *old_state);
81
82#endif /* VMWGFX_CURSOR_H */
83

source code of linux/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.h