Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: MIT
0002 /* Copyright (C) 2006-2017 Oracle Corporation */
0003 
0004 #include <linux/vbox_err.h>
0005 #include "vbox_drv.h"
0006 #include "vboxvideo_guest.h"
0007 #include "vboxvideo_vbe.h"
0008 #include "hgsmi_channels.h"
0009 
0010 /**
0011  * hgsmi_process_display_info - Set a video mode via an HGSMI request.
0012  *                              The views must have been initialised first
0013  *                              using @a VBoxHGSMISendViewInfo and if the mode
0014  *                              is being set on the first display then it must
0015  *                              be set first using registers.
0016  * @ctx:           The context containing the heap to use.
0017  * @display:       The screen number.
0018  * @origin_x:      The horizontal displacement relative to the first scrn.
0019  * @origin_y:      The vertical displacement relative to the first screen.
0020  * @start_offset:  The offset of the visible area of the framebuffer
0021  *                 relative to the framebuffer start.
0022  * @pitch:         The offset in bytes between the starts of two adjecent
0023  *                 scan lines in video RAM.
0024  * @width:         The mode width.
0025  * @height:        The mode height.
0026  * @bpp:           The colour depth of the mode.
0027  * @flags:         Flags.
0028  */
0029 void hgsmi_process_display_info(struct gen_pool *ctx, u32 display,
0030                 s32 origin_x, s32 origin_y, u32 start_offset,
0031                 u32 pitch, u32 width, u32 height,
0032                 u16 bpp, u16 flags)
0033 {
0034     struct vbva_infoscreen *p;
0035 
0036     p = hgsmi_buffer_alloc(ctx, sizeof(*p), HGSMI_CH_VBVA,
0037                    VBVA_INFO_SCREEN);
0038     if (!p)
0039         return;
0040 
0041     p->view_index = display;
0042     p->origin_x = origin_x;
0043     p->origin_y = origin_y;
0044     p->start_offset = start_offset;
0045     p->line_size = pitch;
0046     p->width = width;
0047     p->height = height;
0048     p->bits_per_pixel = bpp;
0049     p->flags = flags;
0050 
0051     hgsmi_buffer_submit(ctx, p);
0052     hgsmi_buffer_free(ctx, p);
0053 }
0054 
0055 /**
0056  * hgsmi_update_input_mapping - Report the rectangle relative to which absolute
0057  *                              pointer events should be expressed.  This
0058  *                              information remains valid until the next VBVA
0059  *                              resize event for any screen, at which time it is
0060  *                              reset to the bounding rectangle of all virtual
0061  *                              screens.
0062  * Return: 0 or negative errno value.
0063  * @ctx:       The context containing the heap to use.
0064  * @origin_x:  Upper left X co-ordinate relative to the first screen.
0065  * @origin_y:  Upper left Y co-ordinate relative to the first screen.
0066  * @width:     Rectangle width.
0067  * @height:    Rectangle height.
0068  */
0069 int hgsmi_update_input_mapping(struct gen_pool *ctx, s32 origin_x, s32 origin_y,
0070                    u32 width, u32 height)
0071 {
0072     struct vbva_report_input_mapping *p;
0073 
0074     p = hgsmi_buffer_alloc(ctx, sizeof(*p), HGSMI_CH_VBVA,
0075                    VBVA_REPORT_INPUT_MAPPING);
0076     if (!p)
0077         return -ENOMEM;
0078 
0079     p->x = origin_x;
0080     p->y = origin_y;
0081     p->cx = width;
0082     p->cy = height;
0083 
0084     hgsmi_buffer_submit(ctx, p);
0085     hgsmi_buffer_free(ctx, p);
0086 
0087     return 0;
0088 }
0089 
0090 /**
0091  * hgsmi_get_mode_hints - Get most recent video mode hints.
0092  * Return: 0 or negative errno value.
0093  * @ctx:      The context containing the heap to use.
0094  * @screens:  The number of screens to query hints for, starting at 0.
0095  * @hints:    Array of vbva_modehint structures for receiving the hints.
0096  */
0097 int hgsmi_get_mode_hints(struct gen_pool *ctx, unsigned int screens,
0098              struct vbva_modehint *hints)
0099 {
0100     struct vbva_query_mode_hints *p;
0101     size_t size;
0102 
0103     if (WARN_ON(!hints))
0104         return -EINVAL;
0105 
0106     size = screens * sizeof(struct vbva_modehint);
0107     p = hgsmi_buffer_alloc(ctx, sizeof(*p) + size, HGSMI_CH_VBVA,
0108                    VBVA_QUERY_MODE_HINTS);
0109     if (!p)
0110         return -ENOMEM;
0111 
0112     p->hints_queried_count = screens;
0113     p->hint_structure_guest_size = sizeof(struct vbva_modehint);
0114     p->rc = VERR_NOT_SUPPORTED;
0115 
0116     hgsmi_buffer_submit(ctx, p);
0117 
0118     if (p->rc < 0) {
0119         hgsmi_buffer_free(ctx, p);
0120         return -EIO;
0121     }
0122 
0123     memcpy(hints, ((u8 *)p) + sizeof(struct vbva_query_mode_hints), size);
0124     hgsmi_buffer_free(ctx, p);
0125 
0126     return 0;
0127 }