Re: [PATCH v4 2/2] drm/virtio: add edid support
On Tue, Oct 30, 2018 at 10:38:04AM +0100, Daniel Vetter wrote: > On Tue, Oct 30, 2018 at 07:32:06AM +0100, Gerd Hoffmann wrote: > > linux guest driver implementation of the VIRTIO_GPU_F_EDID feature. > > > > Signed-off-by: Gerd Hoffmann > > Like with bochs, I think drm_do_get_edid() here is overkill and fairly > pointless. Like with bochs it makes sense to use drm_do_get_edid(), because it handles edid override and other common stuff. Not that this should actually be needed for virtual devices, but I think it still makes sense for consistency with other drivers, and it might be handy for testing too. cheers, Gerd ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v4 2/2] drm/virtio: add edid support
On Wed, Nov 21, 2018 at 09:54:22AM +0100, Gerd Hoffmann wrote: > On Tue, Oct 30, 2018 at 10:38:04AM +0100, Daniel Vetter wrote: > > On Tue, Oct 30, 2018 at 07:32:06AM +0100, Gerd Hoffmann wrote: > > > linux guest driver implementation of the VIRTIO_GPU_F_EDID feature. > > > > > > Signed-off-by: Gerd Hoffmann > > > > Like with bochs, I think drm_do_get_edid() here is overkill and fairly > > pointless. > > Like with bochs it makes sense to use drm_do_get_edid(), because it > handles edid override and other common stuff. Not that this should > actually be needed for virtual devices, but I think it still makes sense > for consistency with other drivers, and it might be handy for testing > too. Yeah Jani corrected me here, I forgot that we reworked all this quite a bit. I checked the kerneldoc, it's up-to-date, so all good. Ack: me fwiw. Cheers, Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v4 2/2] drm/virtio: add edid support
On Tue, Oct 30, 2018 at 07:32:06AM +0100, Gerd Hoffmann wrote: > linux guest driver implementation of the VIRTIO_GPU_F_EDID feature. > > Signed-off-by: Gerd Hoffmann Like with bochs, I think drm_do_get_edid() here is overkill and fairly pointless. -Daniel > --- > drivers/gpu/drm/virtio/virtgpu_drv.h | 3 ++ > drivers/gpu/drm/virtio/virtgpu_display.c | 12 ++ > drivers/gpu/drm/virtio/virtgpu_drv.c | 1 + > drivers/gpu/drm/virtio/virtgpu_kms.c | 8 > drivers/gpu/drm/virtio/virtgpu_vq.c | 67 > > 5 files changed, 91 insertions(+) > > diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h > b/drivers/gpu/drm/virtio/virtgpu_drv.h > index d29f0c7c76..852078419d 100644 > --- a/drivers/gpu/drm/virtio/virtgpu_drv.h > +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h > @@ -114,6 +114,7 @@ struct virtio_gpu_output { > struct drm_encoder enc; > struct virtio_gpu_display_one info; > struct virtio_gpu_update_cursor cursor; > + struct edid *edid; > int cur_x; > int cur_y; > bool enabled; > @@ -204,6 +205,7 @@ struct virtio_gpu_device { > spinlock_t ctx_id_idr_lock; > > bool has_virgl_3d; > + bool has_edid; > > struct work_struct config_changed_work; > > @@ -298,6 +300,7 @@ int virtio_gpu_cmd_get_capset_info(struct > virtio_gpu_device *vgdev, int idx); > int virtio_gpu_cmd_get_capset(struct virtio_gpu_device *vgdev, > int idx, int version, > struct virtio_gpu_drv_cap_cache **cache_p); > +int virtio_gpu_cmd_get_edids(struct virtio_gpu_device *vgdev); > void virtio_gpu_cmd_context_create(struct virtio_gpu_device *vgdev, uint32_t > id, > uint32_t nlen, const char *name); > void virtio_gpu_cmd_context_destroy(struct virtio_gpu_device *vgdev, > diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c > b/drivers/gpu/drm/virtio/virtgpu_display.c > index 8f8fed471e..b5580b11a0 100644 > --- a/drivers/gpu/drm/virtio/virtgpu_display.c > +++ b/drivers/gpu/drm/virtio/virtgpu_display.c > @@ -169,6 +169,12 @@ static int virtio_gpu_conn_get_modes(struct > drm_connector *connector) > struct drm_display_mode *mode = NULL; > int count, width, height; > > + if (output->edid) { > + count = drm_add_edid_modes(connector, output->edid); > + if (count) > + return count; > + } > + > width = le32_to_cpu(output->info.r.width); > height = le32_to_cpu(output->info.r.height); > count = drm_add_modes_noedid(connector, XRES_MAX, YRES_MAX); > @@ -287,6 +293,8 @@ static int vgdev_output_init(struct virtio_gpu_device > *vgdev, int index) > drm_connector_init(dev, connector, _gpu_connector_funcs, > DRM_MODE_CONNECTOR_VIRTUAL); > drm_connector_helper_add(connector, _gpu_conn_helper_funcs); > + if (vgdev->has_edid) > + drm_connector_attach_edid_property(connector); > > drm_encoder_init(dev, encoder, _gpu_enc_funcs, >DRM_MODE_ENCODER_VIRTUAL, NULL); > @@ -378,6 +386,10 @@ int virtio_gpu_modeset_init(struct virtio_gpu_device > *vgdev) > > void virtio_gpu_modeset_fini(struct virtio_gpu_device *vgdev) > { > + int i; > + > + for (i = 0 ; i < vgdev->num_scanouts; ++i) > + kfree(vgdev->outputs[i].edid); > virtio_gpu_fbdev_fini(vgdev); > drm_mode_config_cleanup(vgdev->ddev); > } > diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c > b/drivers/gpu/drm/virtio/virtgpu_drv.c > index d9287c144f..f7f32a885a 100644 > --- a/drivers/gpu/drm/virtio/virtgpu_drv.c > +++ b/drivers/gpu/drm/virtio/virtgpu_drv.c > @@ -80,6 +80,7 @@ static unsigned int features[] = { >*/ > VIRTIO_GPU_F_VIRGL, > #endif > + VIRTIO_GPU_F_EDID, > }; > static struct virtio_driver virtio_gpu_driver = { > .feature_table = features, > diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c > b/drivers/gpu/drm/virtio/virtgpu_kms.c > index 65060c0852..f6cbbb27e4 100644 > --- a/drivers/gpu/drm/virtio/virtgpu_kms.c > +++ b/drivers/gpu/drm/virtio/virtgpu_kms.c > @@ -44,6 +44,8 @@ static void virtio_gpu_config_changed_work_func(struct > work_struct *work) > virtio_cread(vgdev->vdev, struct virtio_gpu_config, >events_read, _read); > if (events_read & VIRTIO_GPU_EVENT_DISPLAY) { > + if (vgdev->has_edid) > + virtio_gpu_cmd_get_edids(vgdev); > virtio_gpu_cmd_get_display_info(vgdev); > drm_helper_hpd_irq_event(vgdev->ddev); > events_clear |= VIRTIO_GPU_EVENT_DISPLAY; > @@ -174,6 +176,10 @@ int virtio_gpu_driver_load(struct drm_device *dev, > unsigned long flags) > #else > DRM_INFO("virgl 3d acceleration not supported by guest\n"); > #endif > + if (virtio_has_feature(vgdev->vdev, VIRTIO_GPU_F_EDID)) { > + vgdev->has_edid = true; > +
[PATCH v4 2/2] drm/virtio: add edid support
linux guest driver implementation of the VIRTIO_GPU_F_EDID feature. Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/virtio/virtgpu_drv.h | 3 ++ drivers/gpu/drm/virtio/virtgpu_display.c | 12 ++ drivers/gpu/drm/virtio/virtgpu_drv.c | 1 + drivers/gpu/drm/virtio/virtgpu_kms.c | 8 drivers/gpu/drm/virtio/virtgpu_vq.c | 67 5 files changed, 91 insertions(+) diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h index d29f0c7c76..852078419d 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.h +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h @@ -114,6 +114,7 @@ struct virtio_gpu_output { struct drm_encoder enc; struct virtio_gpu_display_one info; struct virtio_gpu_update_cursor cursor; + struct edid *edid; int cur_x; int cur_y; bool enabled; @@ -204,6 +205,7 @@ struct virtio_gpu_device { spinlock_t ctx_id_idr_lock; bool has_virgl_3d; + bool has_edid; struct work_struct config_changed_work; @@ -298,6 +300,7 @@ int virtio_gpu_cmd_get_capset_info(struct virtio_gpu_device *vgdev, int idx); int virtio_gpu_cmd_get_capset(struct virtio_gpu_device *vgdev, int idx, int version, struct virtio_gpu_drv_cap_cache **cache_p); +int virtio_gpu_cmd_get_edids(struct virtio_gpu_device *vgdev); void virtio_gpu_cmd_context_create(struct virtio_gpu_device *vgdev, uint32_t id, uint32_t nlen, const char *name); void virtio_gpu_cmd_context_destroy(struct virtio_gpu_device *vgdev, diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c b/drivers/gpu/drm/virtio/virtgpu_display.c index 8f8fed471e..b5580b11a0 100644 --- a/drivers/gpu/drm/virtio/virtgpu_display.c +++ b/drivers/gpu/drm/virtio/virtgpu_display.c @@ -169,6 +169,12 @@ static int virtio_gpu_conn_get_modes(struct drm_connector *connector) struct drm_display_mode *mode = NULL; int count, width, height; + if (output->edid) { + count = drm_add_edid_modes(connector, output->edid); + if (count) + return count; + } + width = le32_to_cpu(output->info.r.width); height = le32_to_cpu(output->info.r.height); count = drm_add_modes_noedid(connector, XRES_MAX, YRES_MAX); @@ -287,6 +293,8 @@ static int vgdev_output_init(struct virtio_gpu_device *vgdev, int index) drm_connector_init(dev, connector, _gpu_connector_funcs, DRM_MODE_CONNECTOR_VIRTUAL); drm_connector_helper_add(connector, _gpu_conn_helper_funcs); + if (vgdev->has_edid) + drm_connector_attach_edid_property(connector); drm_encoder_init(dev, encoder, _gpu_enc_funcs, DRM_MODE_ENCODER_VIRTUAL, NULL); @@ -378,6 +386,10 @@ int virtio_gpu_modeset_init(struct virtio_gpu_device *vgdev) void virtio_gpu_modeset_fini(struct virtio_gpu_device *vgdev) { + int i; + + for (i = 0 ; i < vgdev->num_scanouts; ++i) + kfree(vgdev->outputs[i].edid); virtio_gpu_fbdev_fini(vgdev); drm_mode_config_cleanup(vgdev->ddev); } diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c b/drivers/gpu/drm/virtio/virtgpu_drv.c index d9287c144f..f7f32a885a 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.c +++ b/drivers/gpu/drm/virtio/virtgpu_drv.c @@ -80,6 +80,7 @@ static unsigned int features[] = { */ VIRTIO_GPU_F_VIRGL, #endif + VIRTIO_GPU_F_EDID, }; static struct virtio_driver virtio_gpu_driver = { .feature_table = features, diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c index 65060c0852..f6cbbb27e4 100644 --- a/drivers/gpu/drm/virtio/virtgpu_kms.c +++ b/drivers/gpu/drm/virtio/virtgpu_kms.c @@ -44,6 +44,8 @@ static void virtio_gpu_config_changed_work_func(struct work_struct *work) virtio_cread(vgdev->vdev, struct virtio_gpu_config, events_read, _read); if (events_read & VIRTIO_GPU_EVENT_DISPLAY) { + if (vgdev->has_edid) + virtio_gpu_cmd_get_edids(vgdev); virtio_gpu_cmd_get_display_info(vgdev); drm_helper_hpd_irq_event(vgdev->ddev); events_clear |= VIRTIO_GPU_EVENT_DISPLAY; @@ -174,6 +176,10 @@ int virtio_gpu_driver_load(struct drm_device *dev, unsigned long flags) #else DRM_INFO("virgl 3d acceleration not supported by guest\n"); #endif + if (virtio_has_feature(vgdev->vdev, VIRTIO_GPU_F_EDID)) { + vgdev->has_edid = true; + DRM_INFO("EDID support available.\n"); + } ret = virtio_find_vqs(vgdev->vdev, 2, vqs, callbacks, names, NULL); if (ret) { @@ -219,6 +225,8 @@ int virtio_gpu_driver_load(struct drm_device *dev, unsigned long flags) if (num_capsets)