2 * Copyright (C) 2006-2017 Oracle Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
25 #include "vboxvideo_guest.h"
26 #include "vboxvideo_vbe.h"
27 #include "hgsmi_channels.h"
30 * Set a video mode via an HGSMI request. The views must have been
31 * initialised first using @a VBoxHGSMISendViewInfo and if the mode is being
32 * set on the first display then it must be set first using registers.
33 * @param ctx The context containing the heap to use
34 * @param display The screen number
35 * @param origin_x The horizontal displacement relative to the first scrn
36 * @param origin_y The vertical displacement relative to the first screen
37 * @param start_offset The offset of the visible area of the framebuffer
38 * relative to the framebuffer start
39 * @param pitch The offset in bytes between the starts of two adjecent
40 * scan lines in video RAM
41 * @param width The mode width
42 * @param height The mode height
43 * @param bpp The colour depth of the mode
46 void hgsmi_process_display_info(struct gen_pool
*ctx
, u32 display
,
47 s32 origin_x
, s32 origin_y
, u32 start_offset
,
48 u32 pitch
, u32 width
, u32 height
,
51 struct vbva_infoscreen
*p
;
53 p
= hgsmi_buffer_alloc(ctx
, sizeof(*p
), HGSMI_CH_VBVA
,
58 p
->view_index
= display
;
59 p
->origin_x
= origin_x
;
60 p
->origin_y
= origin_y
;
61 p
->start_offset
= start_offset
;
65 p
->bits_per_pixel
= bpp
;
68 hgsmi_buffer_submit(ctx
, p
);
69 hgsmi_buffer_free(ctx
, p
);
73 * Report the rectangle relative to which absolute pointer events should be
74 * expressed. This information remains valid until the next VBVA resize event
75 * for any screen, at which time it is reset to the bounding rectangle of all
77 * @param ctx The context containing the heap to use.
78 * @param origin_x Upper left X co-ordinate relative to the first screen.
79 * @param origin_y Upper left Y co-ordinate relative to the first screen.
80 * @param width Rectangle width.
81 * @param height Rectangle height.
82 * @returns 0 on success, -errno on failure
84 int hgsmi_update_input_mapping(struct gen_pool
*ctx
, s32 origin_x
, s32 origin_y
,
85 u32 width
, u32 height
)
87 struct vbva_report_input_mapping
*p
;
89 p
= hgsmi_buffer_alloc(ctx
, sizeof(*p
), HGSMI_CH_VBVA
,
90 VBVA_REPORT_INPUT_MAPPING
);
99 hgsmi_buffer_submit(ctx
, p
);
100 hgsmi_buffer_free(ctx
, p
);
106 * Get most recent video mode hints.
107 * @param ctx The context containing the heap to use.
108 * @param screens The number of screens to query hints for, starting at 0.
109 * @param hints Array of vbva_modehint structures for receiving the hints.
110 * @returns 0 on success, -errno on failure
112 int hgsmi_get_mode_hints(struct gen_pool
*ctx
, unsigned int screens
,
113 struct vbva_modehint
*hints
)
115 struct vbva_query_mode_hints
*p
;
121 size
= screens
* sizeof(struct vbva_modehint
);
122 p
= hgsmi_buffer_alloc(ctx
, sizeof(*p
) + size
, HGSMI_CH_VBVA
,
123 VBVA_QUERY_MODE_HINTS
);
127 p
->hints_queried_count
= screens
;
128 p
->hint_structure_guest_size
= sizeof(struct vbva_modehint
);
129 p
->rc
= VERR_NOT_SUPPORTED
;
131 hgsmi_buffer_submit(ctx
, p
);
133 if (RT_FAILURE(p
->rc
)) {
134 hgsmi_buffer_free(ctx
, p
);
138 memcpy(hints
, ((u8
*)p
) + sizeof(struct vbva_query_mode_hints
), size
);
139 hgsmi_buffer_free(ctx
, p
);