@@ -6,6 +6,7 @@ extern "C" {
6
6
#endif
7
7
8
8
#include <inttypes.h>
9
+ #include <stddef.h>
9
10
#include <stdbool.h>
10
11
#include <unistd.h>
11
12
@@ -488,6 +489,103 @@ int32_t krun_set_gpu_options2(uint32_t ctx_id,
488
489
uint32_t virgl_flags ,
489
490
uint64_t shm_size );
490
491
492
+ /* Maximum number of displays. Same as VIRTIO_GPU_MAX_SCANOUTS defined in the virtio-gpu spec */
493
+ #define KRUN_MAX_DISPLAYS 16
494
+
495
+ /**
496
+ * Configure a display output for the VM.
497
+ *
498
+ * Note that to have display output a display backend must also be set (see krun_set_display_backend).
499
+ *
500
+ * Arguments:
501
+ * "ctx_id" - the configuration context ID.
502
+ * "width" - the width of the window/display
503
+ * "height" - the height of the window/display
504
+ *
505
+ * Returns:
506
+ * The id of the display (0 to KRUN_MAX_DISPLAYS - 1) on success or a negative error number on failure.
507
+ */
508
+ int32_t krun_add_display (uint32_t ctx_id , uint32_t width , uint32_t height );
509
+
510
+ /**
511
+ * Configure refresh rate for a display
512
+ *
513
+ *
514
+ * Arguments:
515
+ * "ctx_id" - the configuration context ID.
516
+ * "display_id" - the ID of the display (range: 0 to KRUN_MAX_DISPLAYS - 1)
517
+ * "refresh_rate" - refresh rate (in Hz)
518
+ *
519
+ * Returns:
520
+ * Zero on success or a negative error number on failure.
521
+ */
522
+ int32_t krun_display_set_refresh_rate (uint32_t ctx_id , uint32_t display_id , uint32_t refresh_rate );
523
+
524
+
525
+ /**
526
+ * Configure physical size of the display reported to the guest
527
+ *
528
+ * This overrides the DPI set by krun_set_display_dpi()
529
+ *
530
+ * Arguments:
531
+ * "ctx_id" - the configuration context ID.
532
+ * "display_id" - the ID of the display (range: 0 to KRUN_MAX_DISPLAYS - 1)
533
+ * "width_mm" - width of the display in millimeters
534
+ * "height_mm" - height of the display in millimeters
535
+ *
536
+ * Returns:
537
+ * Zero on success or a negative error number on failure.
538
+ */
539
+ int32_t krun_display_set_physical_size (uint32_t ctx_id , uint32_t display_id , uint16_t width_mm , uint16_t height_mm );
540
+
541
+
542
+ /**
543
+ * Configure DPI of the display reported to the guest
544
+ *
545
+ * This overrides the physical size of the display set by krun_set_display_physical_size()
546
+ *
547
+ * Arguments:
548
+ * "ctx_id" - the configuration context ID.
549
+ * "display_id" - the ID of the display (range: 0 to KRUN_MAX_DISPLAYS - 1)
550
+ * "dpi" - DPI (PPI) dots/pixels per inch of the display
551
+ *
552
+ * Returns:
553
+ * Zero on success or a negative error number on failure.
554
+ */
555
+ int32_t krun_display_set_dpi (uint32_t ctx_id , uint32_t display_id , uint32_t dpi );
556
+
557
+ /**
558
+ * Configure a custom EDID blob for a display
559
+ *
560
+ * This replaces the generated EDID with a custom one. Configuring an EDID blob makes all display parameters except
561
+ * width and height ignored.
562
+ *
563
+ * Note that libkrun doesn't do any checks if the EDID matches the width/height specified in krun_add_display().
564
+ *
565
+ * Arguments:
566
+ * "ctx_id" - the configuration context ID.
567
+ * "display_id" - the ID of the display (range: 0 to KRUN_MAX_DISPLAYS - 1)
568
+ * "edid_blob" - the EDID blob
569
+ * "blob_size" - the size of the blob in bytes
570
+ *
571
+ * Returns:
572
+ * Zero on success or a negative error number on failure.
573
+ */
574
+ int32_t krun_display_set_edid (uint32_t ctx_id , uint32_t display_id , const uint8_t * edid_blob , size_t blob_size );
575
+
576
+ /**
577
+ * Configures a krun_display_backend struct to be used for display output. (see libkrun_display.h)
578
+ *
579
+ * Arguments:
580
+ * "ctx_id" - the configuration context ID
581
+ * "display_backend" - Pointer to a krun_display_backend struct
582
+ * "backend_size" - sizeof() the krun_display_backend struct
583
+ *
584
+ * Returns:
585
+ * Zero on success or a negative error number (errno) on failure.
586
+ */
587
+ int32_t krun_set_display_backend (uint32_t ctx_id , const void * display_backend , size_t backend_size );
588
+
491
589
/**
492
590
* Enables or disables a virtio-snd device.
493
591
*
0 commit comments