1 /* SPDX-License-Identifier: MIT */
2 /* Copyright (C) 2006-2016 Oracle Corporation */
3 
4 #ifndef __VBOXVIDEO_GUEST_H__
5 #define __VBOXVIDEO_GUEST_H__
6 
7 #include <linux/genalloc.h>
8 #include "vboxvideo.h"
9 
10 /*
11  * Structure grouping the context needed for sending graphics acceleration
12  * information to the host via VBVA.  Each screen has its own VBVA buffer.
13  */
14 struct vbva_buf_ctx {
15 	/* Offset of the buffer in the VRAM section for the screen */
16 	u32 buffer_offset;
17 	/* Length of the buffer in bytes */
18 	u32 buffer_length;
19 	/* Set if we wrote to the buffer faster than the host could read it */
20 	bool buffer_overflow;
21 	/* VBVA record that we are currently preparing for the host, or NULL */
22 	struct vbva_record *record;
23 	/*
24 	 * Pointer to the VBVA buffer mapped into the current address space.
25 	 * Will be NULL if VBVA is not enabled.
26 	 */
27 	struct vbva_buffer *vbva;
28 };
29 
30 int hgsmi_report_flags_location(struct gen_pool *ctx, u32 location);
31 int hgsmi_send_caps_info(struct gen_pool *ctx, u32 caps);
32 int hgsmi_test_query_conf(struct gen_pool *ctx);
33 int hgsmi_query_conf(struct gen_pool *ctx, u32 index, u32 *value_ret);
34 int hgsmi_update_pointer_shape(struct gen_pool *ctx, u32 flags,
35 			       u32 hot_x, u32 hot_y, u32 width, u32 height,
36 			       u8 *pixels, u32 len);
37 int hgsmi_cursor_position(struct gen_pool *ctx, bool report_position,
38 			  u32 x, u32 y, u32 *x_host, u32 *y_host);
39 
40 bool vbva_enable(struct vbva_buf_ctx *vbva_ctx, struct gen_pool *ctx,
41 		 struct vbva_buffer *vbva, s32 screen);
42 void vbva_disable(struct vbva_buf_ctx *vbva_ctx, struct gen_pool *ctx,
43 		  s32 screen);
44 bool vbva_buffer_begin_update(struct vbva_buf_ctx *vbva_ctx,
45 			      struct gen_pool *ctx);
46 void vbva_buffer_end_update(struct vbva_buf_ctx *vbva_ctx);
47 bool vbva_write(struct vbva_buf_ctx *vbva_ctx, struct gen_pool *ctx,
48 		const void *p, u32 len);
49 void vbva_setup_buffer_context(struct vbva_buf_ctx *vbva_ctx,
50 			       u32 buffer_offset, u32 buffer_length);
51 
52 void hgsmi_process_display_info(struct gen_pool *ctx, u32 display,
53 				s32 origin_x, s32 origin_y, u32 start_offset,
54 				u32 pitch, u32 width, u32 height,
55 				u16 bpp, u16 flags);
56 int hgsmi_update_input_mapping(struct gen_pool *ctx, s32 origin_x, s32 origin_y,
57 			       u32 width, u32 height);
58 int hgsmi_get_mode_hints(struct gen_pool *ctx, unsigned int screens,
59 			 struct vbva_modehint *hints);
60 
61 #endif
62