Lines Matching +full:- +full:m
2 * vhost-user GPU Device
7 * Marc-André Lureau <marcandre.lureau@redhat.com>
10 * See the COPYING file in the top-level directory.
14 #include "qemu/error-report.h"
16 #include "hw/qdev-properties.h"
17 #include "hw/virtio/virtio-gpu.h"
18 #include "chardev/char-fe.h"
21 #include "standard-headers/drm/drm_fourcc.h"
111 static VhostUserGpuMsg m __attribute__ ((unused)); variable
113 (sizeof(m.request) + sizeof(m.size) + sizeof(m.flags))
125 VhostUserGpuCursorPos *pos = &msg->payload.cursor_pos; in vhost_user_gpu_handle_cursor()
128 if (pos->scanout_id >= g->parent_obj.conf.max_outputs) { in vhost_user_gpu_handle_cursor()
131 s = &g->parent_obj.scanout[pos->scanout_id]; in vhost_user_gpu_handle_cursor()
133 if (msg->request == VHOST_USER_GPU_CURSOR_UPDATE) { in vhost_user_gpu_handle_cursor()
134 VhostUserGpuCursorUpdate *up = &msg->payload.cursor_update; in vhost_user_gpu_handle_cursor()
135 if (!s->current_cursor) { in vhost_user_gpu_handle_cursor()
136 s->current_cursor = cursor_alloc(64, 64); in vhost_user_gpu_handle_cursor()
139 s->current_cursor->hot_x = up->hot_x; in vhost_user_gpu_handle_cursor()
140 s->current_cursor->hot_y = up->hot_y; in vhost_user_gpu_handle_cursor()
142 memcpy(s->current_cursor->data, up->data, in vhost_user_gpu_handle_cursor()
145 dpy_cursor_define(s->con, s->current_cursor); in vhost_user_gpu_handle_cursor()
148 dpy_mouse_set(s->con, pos->x, pos->y, in vhost_user_gpu_handle_cursor()
149 msg->request != VHOST_USER_GPU_CURSOR_POS_HIDE); in vhost_user_gpu_handle_cursor()
155 qemu_chr_fe_write(&g->vhost_chr, (uint8_t *)msg, in vhost_user_gpu_send_msg()
156 VHOST_USER_GPU_HDR_SIZE + msg->size); in vhost_user_gpu_send_msg()
176 switch (msg->request) { in vhost_user_gpu_handle_display()
179 .request = msg->request, in vhost_user_gpu_handle_display()
197 .request = msg->request, in vhost_user_gpu_handle_display()
210 VhostUserGpuEdidRequest *m = &msg->payload.edid_req; in vhost_user_gpu_handle_display() local
213 .request = msg->request, in vhost_user_gpu_handle_display()
218 if (m->scanout_id >= g->parent_obj.conf.max_outputs) { in vhost_user_gpu_handle_display()
219 error_report("invalid scanout: %d", m->scanout_id); in vhost_user_gpu_handle_display()
224 virtio_gpu_base_generate_edid(VIRTIO_GPU_BASE(g), m->scanout_id, &resp); in vhost_user_gpu_handle_display()
230 VhostUserGpuScanout *m = &msg->payload.scanout; in vhost_user_gpu_handle_display() local
232 if (m->scanout_id >= g->parent_obj.conf.max_outputs) { in vhost_user_gpu_handle_display()
236 g->parent_obj.enable = 1; in vhost_user_gpu_handle_display()
237 s = &g->parent_obj.scanout[m->scanout_id]; in vhost_user_gpu_handle_display()
238 con = s->con; in vhost_user_gpu_handle_display()
240 if (m->width == 0) { in vhost_user_gpu_handle_display()
243 s->ds = qemu_create_displaysurface(m->width, m->height); in vhost_user_gpu_handle_display()
251 VhostUserGpuDMABUFScanout *m = &msg->payload.dmabuf_scanout; in vhost_user_gpu_handle_display() local
252 int fd = qemu_chr_fe_get_msgfd(&g->vhost_chr); in vhost_user_gpu_handle_display()
254 uint32_t stride = m->fd_stride; in vhost_user_gpu_handle_display()
258 if (m->scanout_id >= g->parent_obj.conf.max_outputs) { in vhost_user_gpu_handle_display()
259 error_report("invalid scanout: %d", m->scanout_id); in vhost_user_gpu_handle_display()
266 g->parent_obj.enable = 1; in vhost_user_gpu_handle_display()
267 con = g->parent_obj.scanout[m->scanout_id].con; in vhost_user_gpu_handle_display()
268 dmabuf = g->dmabuf[m->scanout_id]; in vhost_user_gpu_handle_display()
276 if (fd == -1) { in vhost_user_gpu_handle_display()
278 g->dmabuf[m->scanout_id] = NULL; in vhost_user_gpu_handle_display()
282 if (msg->request == VHOST_USER_GPU_DMABUF_SCANOUT2) { in vhost_user_gpu_handle_display()
283 VhostUserGpuDMABUFScanout2 *m2 = &msg->payload.dmabuf_scanout2; in vhost_user_gpu_handle_display()
284 modifier = m2->modifier; in vhost_user_gpu_handle_display()
287 dmabuf = qemu_dmabuf_new(m->width, m->height, in vhost_user_gpu_handle_display()
289 m->fd_width, m->fd_height, in vhost_user_gpu_handle_display()
290 m->fd_drm_fourcc, modifier, in vhost_user_gpu_handle_display()
291 &fd, 1, false, m->fd_flags & in vhost_user_gpu_handle_display()
295 g->dmabuf[m->scanout_id] = dmabuf; in vhost_user_gpu_handle_display()
299 VhostUserGpuUpdate *m = &msg->payload.update; in vhost_user_gpu_handle_display() local
301 if (m->scanout_id >= g->parent_obj.conf.max_outputs || in vhost_user_gpu_handle_display()
302 !g->parent_obj.scanout[m->scanout_id].con) { in vhost_user_gpu_handle_display()
303 error_report("invalid scanout update: %d", m->scanout_id); in vhost_user_gpu_handle_display()
308 con = g->parent_obj.scanout[m->scanout_id].con; in vhost_user_gpu_handle_display()
314 g->backend_blocked = true; in vhost_user_gpu_handle_display()
315 dpy_gl_update(con, m->x, m->y, m->width, m->height); in vhost_user_gpu_handle_display()
320 VhostUserGpuUpdate *m = &msg->payload.update; in vhost_user_gpu_handle_display() local
322 if (m->scanout_id >= g->parent_obj.conf.max_outputs) { in vhost_user_gpu_handle_display()
325 s = &g->parent_obj.scanout[m->scanout_id]; in vhost_user_gpu_handle_display()
326 con = s->con; in vhost_user_gpu_handle_display()
329 m->width, in vhost_user_gpu_handle_display()
330 m->height, in vhost_user_gpu_handle_display()
331 (uint32_t *)m->data, in vhost_user_gpu_handle_display()
332 m->width * 4); in vhost_user_gpu_handle_display()
335 image, NULL, s->ds->image, in vhost_user_gpu_handle_display()
336 0, 0, 0, 0, m->x, m->y, m->width, m->height); in vhost_user_gpu_handle_display()
339 if (qemu_console_surface(con) != s->ds) { in vhost_user_gpu_handle_display()
340 dpy_gfx_replace_surface(con, s->ds); in vhost_user_gpu_handle_display()
342 dpy_gfx_update(con, m->x, m->y, m->width, m->height); in vhost_user_gpu_handle_display()
348 g_warning("unhandled message %d %d", msg->request, msg->size); in vhost_user_gpu_handle_display()
365 r = qemu_chr_fe_read_all(&g->vhost_chr, in vhost_user_gpu_chr_read()
372 r = qemu_chr_fe_read_all(&g->vhost_chr, in vhost_user_gpu_chr_read()
379 r = qemu_chr_fe_read_all(&g->vhost_chr, in vhost_user_gpu_chr_read()
388 r = qemu_chr_fe_read_all(&g->vhost_chr, in vhost_user_gpu_chr_read()
389 (uint8_t *)&msg->payload, size); in vhost_user_gpu_chr_read()
395 msg->request = request; in vhost_user_gpu_chr_read()
396 msg->flags = flags; in vhost_user_gpu_chr_read()
397 msg->size = size; in vhost_user_gpu_chr_read()
414 qemu_set_fd_handler(g->vhost_gpu_fd, in vhost_user_gpu_update_blocked()
423 if (g->backend_blocked) { in vhost_user_gpu_gl_flushed()
425 g->backend_blocked = false; in vhost_user_gpu_gl_flushed()
437 if (qemu_socketpair(PF_UNIX, SOCK_STREAM, 0, sv) == -1) { in vhost_user_gpu_do_set_socket()
443 if (!chr || qemu_chr_add_client(chr, sv[0]) == -1) { in vhost_user_gpu_do_set_socket()
447 if (!qemu_chr_fe_init(&g->vhost_chr, chr, errp)) { in vhost_user_gpu_do_set_socket()
450 if (vhost_user_gpu_set_socket(&g->vhost->dev, sv[1]) < 0) { in vhost_user_gpu_do_set_socket()
451 error_setg(errp, "Failed to set vhost-user-gpu socket"); in vhost_user_gpu_do_set_socket()
452 qemu_chr_fe_deinit(&g->vhost_chr, false); in vhost_user_gpu_do_set_socket()
456 g->vhost_gpu_fd = sv[0]; in vhost_user_gpu_do_set_socket()
482 ret = vhost_dev_get_config(&g->vhost->dev, in vhost_user_gpu_get_config()
491 vgconfig->num_scanouts = b->virtio_config.num_scanouts; in vhost_user_gpu_get_config()
492 vgconfig->events_read = b->virtio_config.events_read; in vhost_user_gpu_get_config()
493 vgconfig->events_clear = b->virtio_config.events_clear; in vhost_user_gpu_get_config()
506 if (vgconfig->events_clear) { in vhost_user_gpu_set_config()
507 b->virtio_config.events_read &= ~vgconfig->events_clear; in vhost_user_gpu_set_config()
510 ret = vhost_dev_set_config(&g->vhost->dev, config_data, in vhost_user_gpu_set_config()
514 error_report("vhost-user-gpu: set device config space failed"); in vhost_user_gpu_set_config()
525 if (val & VIRTIO_CONFIG_S_DRIVER_OK && vdev->vm_running) { in vhost_user_gpu_set_status()
530 vhost_user_backend_start(g->vhost); in vhost_user_gpu_set_status()
535 if (g->vhost_gpu_fd != -1) { in vhost_user_gpu_set_status()
537 qemu_chr_fe_deinit(&g->vhost_chr, true); in vhost_user_gpu_set_status()
538 g->vhost_gpu_fd = -1; in vhost_user_gpu_set_status()
540 ret = vhost_user_backend_stop(g->vhost); in vhost_user_gpu_set_status()
554 * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 in vhost_user_gpu_guest_notifier_pending()
562 return vhost_virtqueue_pending(&g->vhost->dev, idx); in vhost_user_gpu_guest_notifier_pending()
571 * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 in vhost_user_gpu_guest_notifier_mask()
579 vhost_virtqueue_mask(&g->vhost->dev, vdev, idx, mask); in vhost_user_gpu_guest_notifier_mask()
587 g->vhost = VHOST_USER_BACKEND(object_new(TYPE_VHOST_USER_BACKEND)); in vhost_user_gpu_instance_init()
589 OBJECT(g->vhost), "chardev"); in vhost_user_gpu_instance_init()
597 object_unref(OBJECT(g->vhost)); in vhost_user_gpu_instance_finalize()
607 vhost_user_backend_stop(g->vhost); in vhost_user_gpu_reset()
613 error_report("vhost-user-gpu: unhandled backend config change"); in vhost_user_gpu_config_change()
614 return -1; in vhost_user_gpu_config_change()
627 vhost_dev_set_config_notifier(&g->vhost->dev, &config_ops); in vhost_user_gpu_device_realize()
628 if (vhost_user_backend_dev_init(g->vhost, vdev, 2, errp) < 0) { in vhost_user_gpu_device_realize()
633 g->parent_obj.conf.flags |= 1 << VIRTIO_GPU_FLAG_DMABUF_ENABLED; in vhost_user_gpu_device_realize()
634 if (virtio_has_feature(g->vhost->dev.features, VIRTIO_GPU_F_VIRGL)) { in vhost_user_gpu_device_realize()
635 g->parent_obj.conf.flags |= 1 << VIRTIO_GPU_FLAG_VIRGL_ENABLED; in vhost_user_gpu_device_realize()
637 if (virtio_has_feature(g->vhost->dev.features, VIRTIO_GPU_F_EDID)) { in vhost_user_gpu_device_realize()
638 g->parent_obj.conf.flags |= 1 << VIRTIO_GPU_FLAG_EDID_ENABLED; in vhost_user_gpu_device_realize()
641 g->parent_obj.conf.flags &= ~(1 << VIRTIO_GPU_FLAG_EDID_ENABLED); in vhost_user_gpu_device_realize()
643 if (virtio_has_feature(g->vhost->dev.features, in vhost_user_gpu_device_realize()
645 g->parent_obj.conf.flags |= 1 << VIRTIO_GPU_FLAG_RESOURCE_UUID_ENABLED; in vhost_user_gpu_device_realize()
647 if (virtio_has_feature(g->vhost->dev.features, in vhost_user_gpu_device_realize()
649 g->parent_obj.conf.flags |= 1 << VIRTIO_GPU_FLAG_RESOURCE_UUID_ENABLED; in vhost_user_gpu_device_realize()
656 g->vhost_gpu_fd = -1; in vhost_user_gpu_device_realize()
662 return g->vhost ? &g->vhost->dev : NULL; in vhost_user_gpu_get_vhost()
676 vgc->gl_flushed = vhost_user_gpu_gl_flushed; in vhost_user_gpu_class_init()
678 vdc->realize = vhost_user_gpu_device_realize; in vhost_user_gpu_class_init()
679 vdc->reset = vhost_user_gpu_reset; in vhost_user_gpu_class_init()
680 vdc->set_status = vhost_user_gpu_set_status; in vhost_user_gpu_class_init()
681 vdc->guest_notifier_mask = vhost_user_gpu_guest_notifier_mask; in vhost_user_gpu_class_init()
682 vdc->guest_notifier_pending = vhost_user_gpu_guest_notifier_pending; in vhost_user_gpu_class_init()
683 vdc->get_config = vhost_user_gpu_get_config; in vhost_user_gpu_class_init()
684 vdc->set_config = vhost_user_gpu_set_config; in vhost_user_gpu_class_init()
685 vdc->get_vhost = vhost_user_gpu_get_vhost; in vhost_user_gpu_class_init()