drm/virtio: Add hotplug_mode_update and suggested_x/y properties (v2)
Subsystems (3)
v2 cover drm/virtio: Add hotplug_mode_update and suggested_x/y properties (v2)
These properties provide a way to influence the userspace with regard to positioning of the outputs and also enable it to look for new preferred modes when hotplug interrupts occur.
These properties are currently used by other virtual GPU drivers such as vmwgfx and qxl.
Testcase: After positioning the VMM's (e.g, Qemu) windows on various monitors and launching the Guest VM, run the get-state tool (tools/ get-state.py) associated with Mutter to ensure that the Hosts' and Guests' outputs are aligned.
v2: Fixed the sparse check warning associated with patch #1 and
also improved the commit message in patch #2.
Vivek Kasireddy (2):
drm/virtio: Attach and set suggested_x/y properties for the connector
(v2)
drm/virtio: Add hotplug_mode_update property to ensure position info
is read (v2)
drivers/gpu/drm/virtio/virtgpu_display.c | 19 +++++++++++++++++++ drivers/gpu/drm/virtio/virtgpu_drv.h | 2 ++ drivers/gpu/drm/virtio/virtgpu_vq.c | 14 ++++++++++++++ 3 files changed, 35 insertions(+)
Signature · 1 line
2.37.2
PATCH v2 1/2 drm/virtio: Attach and set suggested_x/y properties for the connector (v2)
These properties provide a way to suggest to the userspace the preferred positions for the outputs. Mutter already uses these properties to determine the best positions for the outputs.
v2: Fix the sparse check warnings by wrapping the x and y values with
le32_to_cpu().
--- drivers/gpu/drm/virtio/virtgpu_display.c | 5 +++++ drivers/gpu/drm/virtio/virtgpu_vq.c | 14 ++++++++++++++ 2 files changed, 19 insertions(+)
drivers/gpu/drm/virtio/virtgpu_display.c +5 -0
@@ -282,6 +282,10 @@ static int vgdev_output_init(struct virtio_gpu_device *vgdev, int index)drm_connector_helper_add (connector, &virtio_gpu_conn_helper_funcs);if (vgdev->has_edid)drm_connector_attach_edid_property (connector); +drm_object_attach_property (&connector->base, + dev->mode_config.suggested_x_property,0 ); +drm_object_attach_property (&connector->base, + dev->mode_config.suggested_y_property,0 );drm_simple_encoder_init (dev, encoder,DRM_MODE_ENCODER_VIRTUAL );drm_encoder_helper_add (encoder, &virtio_gpu_enc_helper_funcs);
@@ -350,6 +354,7 @@ int virtio_gpu_modeset_init(struct virtio_gpu_device *vgdev) vgdev->ddev->mode_config.max_height =YRES_MAX ; vgdev->ddev->mode_config.fb_modifiers_not_supported = true; +drm_mode_create_suggested_offset_properties (vgdev->ddev);for (i =0 ; i < vgdev->num_scanouts; ++i)vgdev_output_init (vgdev, i);
drivers/gpu/drm/virtio/virtgpu_vq.c +14 -0
@@ -645,6 +645,19 @@ virtio_gpu_cmd_resource_attach_backing(struct virtio_gpu_device *vgdev,virtio_gpu_queue_fenced_ctrl_buffer (vgdev, vbuf, fence); } +static void virtio_gpu_update_output_position (struct virtio_gpu_output *output) +{ +struct drm_connector *connector = &output->conn; +struct drm_device *dev = connector->dev; + +drm_object_property_set_value (&connector->base, + dev->mode_config.suggested_x_property, +le32_to_cpu (output->info.r.x)); +drm_object_property_set_value (&connector->base, + dev->mode_config.suggested_y_property, +le32_to_cpu (output->info.r.y)); +} +static void virtio_gpu_cmd_get_display_info_cb (struct virtio_gpu_device *vgdev,struct virtio_gpu_vbuffer *vbuf) {
@@ -655,6 +668,7 @@ static void virtio_gpu_cmd_get_display_info_cb(struct virtio_gpu_device *vgdev,spin_lock (&vgdev->display_info_lock);for (i =0 ; i < vgdev->num_scanouts; i++) { vgdev->outputs[i].info = resp->pmodes[i]; +virtio_gpu_update_output_position (&vgdev->outputs[i]);if (resp->pmodes[i].enabled) { DRM_DEBUG("output %d: %dx%d+%d+%d", i, le32_to_cpu(resp->pmodes[i].r.width),
Signature · 1 line
2.37.2
PATCH v2 2/2 drm/virtio: Add hotplug_mode_update property to ensure position info is read (v2)
In reply to Vivek KasireddySome compositors (mainly Mutter) needs this property to be set in order to read suggested_x/y values. This property, along with suggested_x/y will be useful for virtual GPU drivers to share the Host output/window layout with the Guest compositor.
v2: Improve the commit message.
--- drivers/gpu/drm/virtio/virtgpu_display.c | 14 ++++++++++++++ drivers/gpu/drm/virtio/virtgpu_drv.h | 2 ++ 2 files changed, 16 insertions(+)
drivers/gpu/drm/virtio/virtgpu_display.c +14 -0
@@ -286,6 +286,8 @@ static int vgdev_output_init(struct virtio_gpu_device *vgdev, int index) dev->mode_config.suggested_x_property, 0);drm_object_attach_property (&connector->base, dev->mode_config.suggested_y_property,0 ); +drm_object_attach_property (&connector->base, + vgdev->hotplug_mode_update_property,1 );drm_simple_encoder_init (dev, encoder,DRM_MODE_ENCODER_VIRTUAL );drm_encoder_helper_add (encoder, &virtio_gpu_enc_helper_funcs);
@@ -336,6 +338,17 @@ static const struct drm_mode_config_funcs virtio_gpu_mode_funcs = { .atomic_commit = drm_atomic_helper_commit, }; +static void +virtio_gpu_create_hotplug_mode_update_property (struct virtio_gpu_device *vgdev) +{ +if (vgdev->hotplug_mode_update_property) +return ; + + vgdev->hotplug_mode_update_property = +drm_property_create_range (vgdev->ddev,DRM_MODE_PROP_IMMUTABLE , +"hotplug_mode_update" ,0 ,1 ); +} +int virtio_gpu_modeset_init (struct virtio_gpu_device *vgdev) {int i, ret;
@@ -355,6 +368,7 @@ int virtio_gpu_modeset_init(struct virtio_gpu_device *vgdev) vgdev->ddev->mode_config.fb_modifiers_not_supported = true;drm_mode_create_suggested_offset_properties (vgdev->ddev); +virtio_gpu_create_hotplug_mode_update_property (vgdev);for (i =0 ; i < vgdev->num_scanouts; ++i)vgdev_output_init (vgdev, i);
drivers/gpu/drm/virtio/virtgpu_drv.h +2 -0
@@ -260,6 +260,8 @@ struct virtio_gpu_device {uint64_t capset_id_mask;struct list_head cap_cache; +struct drm_property *hotplug_mode_update_property; +/* protects uuid state when exporting */ spinlock_t resource_export_lock;/* protects map state and host_visible_mm */
Signature · 1 line
2.37.2