Lines Matching +full:conf +full:- +full:ds

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"
124 VhostUserGpuCursorPos *pos = &msg->payload.cursor_pos; in vhost_user_gpu_handle_cursor()
127 if (pos->scanout_id >= g->parent_obj.conf.max_outputs) { in vhost_user_gpu_handle_cursor()
130 s = &g->parent_obj.scanout[pos->scanout_id]; in vhost_user_gpu_handle_cursor()
132 if (msg->request == VHOST_USER_GPU_CURSOR_UPDATE) { in vhost_user_gpu_handle_cursor()
133 VhostUserGpuCursorUpdate *up = &msg->payload.cursor_update; in vhost_user_gpu_handle_cursor()
134 if (!s->current_cursor) { in vhost_user_gpu_handle_cursor()
135 s->current_cursor = cursor_alloc(64, 64); in vhost_user_gpu_handle_cursor()
138 s->current_cursor->hot_x = up->hot_x; in vhost_user_gpu_handle_cursor()
139 s->current_cursor->hot_y = up->hot_y; in vhost_user_gpu_handle_cursor()
141 memcpy(s->current_cursor->data, up->data, in vhost_user_gpu_handle_cursor()
144 dpy_cursor_define(s->con, s->current_cursor); in vhost_user_gpu_handle_cursor()
147 dpy_mouse_set(s->con, pos->x, pos->y, in vhost_user_gpu_handle_cursor()
148 msg->request != VHOST_USER_GPU_CURSOR_POS_HIDE); in vhost_user_gpu_handle_cursor()
154 qemu_chr_fe_write(&g->vhost_chr, (uint8_t *)msg, in vhost_user_gpu_send_msg()
155 VHOST_USER_GPU_HDR_SIZE + msg->size); in vhost_user_gpu_send_msg()
175 switch (msg->request) { in vhost_user_gpu_handle_display()
178 .request = msg->request, in vhost_user_gpu_handle_display()
196 .request = msg->request, in vhost_user_gpu_handle_display()
209 VhostUserGpuEdidRequest *m = &msg->payload.edid_req; in vhost_user_gpu_handle_display()
212 .request = msg->request, in vhost_user_gpu_handle_display()
217 if (m->scanout_id >= g->parent_obj.conf.max_outputs) { in vhost_user_gpu_handle_display()
218 error_report("invalid scanout: %d", m->scanout_id); in vhost_user_gpu_handle_display()
223 virtio_gpu_base_generate_edid(VIRTIO_GPU_BASE(g), m->scanout_id, &resp); in vhost_user_gpu_handle_display()
229 VhostUserGpuScanout *m = &msg->payload.scanout; in vhost_user_gpu_handle_display()
231 if (m->scanout_id >= g->parent_obj.conf.max_outputs) { in vhost_user_gpu_handle_display()
235 g->parent_obj.enable = 1; in vhost_user_gpu_handle_display()
236 s = &g->parent_obj.scanout[m->scanout_id]; in vhost_user_gpu_handle_display()
237 con = s->con; in vhost_user_gpu_handle_display()
239 if (m->width == 0) { in vhost_user_gpu_handle_display()
242 s->ds = qemu_create_displaysurface(m->width, m->height); in vhost_user_gpu_handle_display()
250 VhostUserGpuDMABUFScanout *m = &msg->payload.dmabuf_scanout; in vhost_user_gpu_handle_display()
251 int fd = qemu_chr_fe_get_msgfd(&g->vhost_chr); in vhost_user_gpu_handle_display()
255 if (m->scanout_id >= g->parent_obj.conf.max_outputs) { in vhost_user_gpu_handle_display()
256 error_report("invalid scanout: %d", m->scanout_id); in vhost_user_gpu_handle_display()
263 g->parent_obj.enable = 1; in vhost_user_gpu_handle_display()
264 con = g->parent_obj.scanout[m->scanout_id].con; in vhost_user_gpu_handle_display()
265 dmabuf = g->dmabuf[m->scanout_id]; in vhost_user_gpu_handle_display()
273 if (fd == -1) { in vhost_user_gpu_handle_display()
275 g->dmabuf[m->scanout_id] = NULL; in vhost_user_gpu_handle_display()
279 if (msg->request == VHOST_USER_GPU_DMABUF_SCANOUT2) { in vhost_user_gpu_handle_display()
280 VhostUserGpuDMABUFScanout2 *m2 = &msg->payload.dmabuf_scanout2; in vhost_user_gpu_handle_display()
281 modifier = m2->modifier; in vhost_user_gpu_handle_display()
284 dmabuf = qemu_dmabuf_new(m->width, m->height, in vhost_user_gpu_handle_display()
285 m->fd_stride, 0, 0, in vhost_user_gpu_handle_display()
286 m->fd_width, m->fd_height, in vhost_user_gpu_handle_display()
287 m->fd_drm_fourcc, modifier, in vhost_user_gpu_handle_display()
288 fd, false, m->fd_flags & in vhost_user_gpu_handle_display()
292 g->dmabuf[m->scanout_id] = dmabuf; in vhost_user_gpu_handle_display()
296 VhostUserGpuUpdate *m = &msg->payload.update; in vhost_user_gpu_handle_display()
298 if (m->scanout_id >= g->parent_obj.conf.max_outputs || in vhost_user_gpu_handle_display()
299 !g->parent_obj.scanout[m->scanout_id].con) { in vhost_user_gpu_handle_display()
300 error_report("invalid scanout update: %d", m->scanout_id); in vhost_user_gpu_handle_display()
305 con = g->parent_obj.scanout[m->scanout_id].con; in vhost_user_gpu_handle_display()
311 g->backend_blocked = true; in vhost_user_gpu_handle_display()
312 dpy_gl_update(con, m->x, m->y, m->width, m->height); in vhost_user_gpu_handle_display()
317 VhostUserGpuUpdate *m = &msg->payload.update; in vhost_user_gpu_handle_display()
319 if (m->scanout_id >= g->parent_obj.conf.max_outputs) { in vhost_user_gpu_handle_display()
322 s = &g->parent_obj.scanout[m->scanout_id]; in vhost_user_gpu_handle_display()
323 con = s->con; in vhost_user_gpu_handle_display()
326 m->width, in vhost_user_gpu_handle_display()
327 m->height, in vhost_user_gpu_handle_display()
328 (uint32_t *)m->data, in vhost_user_gpu_handle_display()
329 m->width * 4); in vhost_user_gpu_handle_display()
332 image, NULL, s->ds->image, in vhost_user_gpu_handle_display()
333 0, 0, 0, 0, m->x, m->y, m->width, m->height); in vhost_user_gpu_handle_display()
336 if (qemu_console_surface(con) != s->ds) { in vhost_user_gpu_handle_display()
337 dpy_gfx_replace_surface(con, s->ds); in vhost_user_gpu_handle_display()
339 dpy_gfx_update(con, m->x, m->y, m->width, m->height); in vhost_user_gpu_handle_display()
345 g_warning("unhandled message %d %d", msg->request, msg->size); in vhost_user_gpu_handle_display()
362 r = qemu_chr_fe_read_all(&g->vhost_chr, in vhost_user_gpu_chr_read()
369 r = qemu_chr_fe_read_all(&g->vhost_chr, in vhost_user_gpu_chr_read()
376 r = qemu_chr_fe_read_all(&g->vhost_chr, in vhost_user_gpu_chr_read()
385 r = qemu_chr_fe_read_all(&g->vhost_chr, in vhost_user_gpu_chr_read()
386 (uint8_t *)&msg->payload, size); in vhost_user_gpu_chr_read()
392 msg->request = request; in vhost_user_gpu_chr_read()
393 msg->flags = flags; in vhost_user_gpu_chr_read()
394 msg->size = size; in vhost_user_gpu_chr_read()
411 qemu_set_fd_handler(g->vhost_gpu_fd, in vhost_user_gpu_update_blocked()
420 if (g->backend_blocked) { in vhost_user_gpu_gl_flushed()
422 g->backend_blocked = false; in vhost_user_gpu_gl_flushed()
434 if (qemu_socketpair(PF_UNIX, SOCK_STREAM, 0, sv) == -1) { in vhost_user_gpu_do_set_socket()
440 if (!chr || qemu_chr_add_client(chr, sv[0]) == -1) { in vhost_user_gpu_do_set_socket()
444 if (!qemu_chr_fe_init(&g->vhost_chr, chr, errp)) { in vhost_user_gpu_do_set_socket()
447 if (vhost_user_gpu_set_socket(&g->vhost->dev, sv[1]) < 0) { in vhost_user_gpu_do_set_socket()
448 error_setg(errp, "Failed to set vhost-user-gpu socket"); in vhost_user_gpu_do_set_socket()
449 qemu_chr_fe_deinit(&g->vhost_chr, false); in vhost_user_gpu_do_set_socket()
453 g->vhost_gpu_fd = sv[0]; in vhost_user_gpu_do_set_socket()
479 ret = vhost_dev_get_config(&g->vhost->dev, in vhost_user_gpu_get_config()
488 vgconfig->num_scanouts = b->virtio_config.num_scanouts; in vhost_user_gpu_get_config()
489 vgconfig->events_read = b->virtio_config.events_read; in vhost_user_gpu_get_config()
490 vgconfig->events_clear = b->virtio_config.events_clear; in vhost_user_gpu_get_config()
503 if (vgconfig->events_clear) { in vhost_user_gpu_set_config()
504 b->virtio_config.events_read &= ~vgconfig->events_clear; in vhost_user_gpu_set_config()
507 ret = vhost_dev_set_config(&g->vhost->dev, config_data, in vhost_user_gpu_set_config()
511 error_report("vhost-user-gpu: set device config space failed"); in vhost_user_gpu_set_config()
522 if (val & VIRTIO_CONFIG_S_DRIVER_OK && vdev->vm_running) { in vhost_user_gpu_set_status()
527 vhost_user_backend_start(g->vhost); in vhost_user_gpu_set_status()
530 if (g->vhost_gpu_fd != -1) { in vhost_user_gpu_set_status()
532 qemu_chr_fe_deinit(&g->vhost_chr, true); in vhost_user_gpu_set_status()
533 g->vhost_gpu_fd = -1; in vhost_user_gpu_set_status()
535 vhost_user_backend_stop(g->vhost); in vhost_user_gpu_set_status()
545 * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 in vhost_user_gpu_guest_notifier_pending()
553 return vhost_virtqueue_pending(&g->vhost->dev, idx); in vhost_user_gpu_guest_notifier_pending()
562 * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 in vhost_user_gpu_guest_notifier_mask()
570 vhost_virtqueue_mask(&g->vhost->dev, vdev, idx, mask); in vhost_user_gpu_guest_notifier_mask()
578 g->vhost = VHOST_USER_BACKEND(object_new(TYPE_VHOST_USER_BACKEND)); in vhost_user_gpu_instance_init()
580 OBJECT(g->vhost), "chardev"); in vhost_user_gpu_instance_init()
588 object_unref(OBJECT(g->vhost)); in vhost_user_gpu_instance_finalize()
598 vhost_user_backend_stop(g->vhost); in vhost_user_gpu_reset()
604 error_report("vhost-user-gpu: unhandled backend config change"); in vhost_user_gpu_config_change()
605 return -1; in vhost_user_gpu_config_change()
618 vhost_dev_set_config_notifier(&g->vhost->dev, &config_ops); in vhost_user_gpu_device_realize()
619 if (vhost_user_backend_dev_init(g->vhost, vdev, 2, errp) < 0) { in vhost_user_gpu_device_realize()
624 g->parent_obj.conf.flags |= 1 << VIRTIO_GPU_FLAG_DMABUF_ENABLED; in vhost_user_gpu_device_realize()
625 if (virtio_has_feature(g->vhost->dev.features, VIRTIO_GPU_F_VIRGL)) { in vhost_user_gpu_device_realize()
626 g->parent_obj.conf.flags |= 1 << VIRTIO_GPU_FLAG_VIRGL_ENABLED; in vhost_user_gpu_device_realize()
628 if (virtio_has_feature(g->vhost->dev.features, VIRTIO_GPU_F_EDID)) { in vhost_user_gpu_device_realize()
629 g->parent_obj.conf.flags |= 1 << VIRTIO_GPU_FLAG_EDID_ENABLED; in vhost_user_gpu_device_realize()
632 g->parent_obj.conf.flags &= ~(1 << VIRTIO_GPU_FLAG_EDID_ENABLED); in vhost_user_gpu_device_realize()
639 g->vhost_gpu_fd = -1; in vhost_user_gpu_device_realize()
645 return g->vhost ? &g->vhost->dev : NULL; in vhost_user_gpu_get_vhost()
649 VIRTIO_GPU_BASE_PROPERTIES(VhostUserGPU, parent_obj.conf),
660 vgc->gl_flushed = vhost_user_gpu_gl_flushed; in vhost_user_gpu_class_init()
662 vdc->realize = vhost_user_gpu_device_realize; in vhost_user_gpu_class_init()
663 vdc->reset = vhost_user_gpu_reset; in vhost_user_gpu_class_init()
664 vdc->set_status = vhost_user_gpu_set_status; in vhost_user_gpu_class_init()
665 vdc->guest_notifier_mask = vhost_user_gpu_guest_notifier_mask; in vhost_user_gpu_class_init()
666 vdc->guest_notifier_pending = vhost_user_gpu_guest_notifier_pending; in vhost_user_gpu_class_init()
667 vdc->get_config = vhost_user_gpu_get_config; in vhost_user_gpu_class_init()
668 vdc->set_config = vhost_user_gpu_set_config; in vhost_user_gpu_class_init()
669 vdc->get_vhost = vhost_user_gpu_get_vhost; in vhost_user_gpu_class_init()