* [PATCH 0/2] drm/bochs: add edid support. @ 2018-10-01 12:19 Gerd Hoffmann 2018-10-01 12:19 ` Gerd Hoffmann 2018-10-01 12:19 ` Gerd Hoffmann 0 siblings, 2 replies; 6+ messages in thread From: Gerd Hoffmann @ 2018-10-01 12:19 UTC (permalink / raw) To: dri-devel; +Cc: Gerd Hoffmann Gerd Hoffmann (2): drm: virtual connectors can have edid too drm/bochs: add edid support. drivers/gpu/drm/bochs/bochs.h | 1 + drivers/gpu/drm/bochs/bochs_hw.c | 38 ++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/bochs/bochs_kms.c | 16 +++++++++++++--- drivers/gpu/drm/drm_connector.c | 3 +-- 4 files changed, 53 insertions(+), 5 deletions(-) -- 2.9.3 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] drm: virtual connectors can have edid too 2018-10-01 12:19 [PATCH 0/2] drm/bochs: add edid support Gerd Hoffmann @ 2018-10-01 12:19 ` Gerd Hoffmann 2018-10-01 12:19 ` Gerd Hoffmann 1 sibling, 0 replies; 6+ messages in thread From: Gerd Hoffmann @ 2018-10-01 12:19 UTC (permalink / raw) To: dri-devel Cc: Gerd Hoffmann, Gustavo Padovan, Maarten Lankhorst, Sean Paul, David Airlie, open list Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> --- drivers/gpu/drm/drm_connector.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 6011d769d5..95cbbf7ee5 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -254,8 +254,7 @@ int drm_connector_init(struct drm_device *dev, config->num_connector++; spin_unlock_irq(&config->connector_list_lock); - if (connector_type != DRM_MODE_CONNECTOR_VIRTUAL && - connector_type != DRM_MODE_CONNECTOR_WRITEBACK) + if (connector_type != DRM_MODE_CONNECTOR_WRITEBACK) drm_object_attach_property(&connector->base, config->edid_property, 0); -- 2.9.3 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 1/2] drm: virtual connectors can have edid too @ 2018-10-01 12:19 ` Gerd Hoffmann 0 siblings, 0 replies; 6+ messages in thread From: Gerd Hoffmann @ 2018-10-01 12:19 UTC (permalink / raw) To: dri-devel Cc: Gerd Hoffmann, Gustavo Padovan, Maarten Lankhorst, Sean Paul, David Airlie, open list Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> --- drivers/gpu/drm/drm_connector.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 6011d769d5..95cbbf7ee5 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -254,8 +254,7 @@ int drm_connector_init(struct drm_device *dev, config->num_connector++; spin_unlock_irq(&config->connector_list_lock); - if (connector_type != DRM_MODE_CONNECTOR_VIRTUAL && - connector_type != DRM_MODE_CONNECTOR_WRITEBACK) + if (connector_type != DRM_MODE_CONNECTOR_WRITEBACK) drm_object_attach_property(&connector->base, config->edid_property, 0); -- 2.9.3 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] drm: virtual connectors can have edid too 2018-10-01 12:19 ` Gerd Hoffmann (?) @ 2018-10-01 17:17 ` Daniel Vetter -1 siblings, 0 replies; 6+ messages in thread From: Daniel Vetter @ 2018-10-01 17:17 UTC (permalink / raw) To: Gerd Hoffmann; +Cc: dri-devel, David Airlie, open list, Sean Paul On Mon, Oct 01, 2018 at 02:19:10PM +0200, Gerd Hoffmann wrote: > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> This will add edid support to all virtual connectors. Probably a bit much, and I don't think what everyone else wants for their virtual hw drivers. I think better to wrap a new drm_connector_attach_edid_property(), which virtual drivers can call when needed. Also: Might be good to update the kerneldoc, and perhaps double-check no userspace will go boom on this change (yes I'm paranoid). -Daniel > --- > drivers/gpu/drm/drm_connector.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c > index 6011d769d5..95cbbf7ee5 100644 > --- a/drivers/gpu/drm/drm_connector.c > +++ b/drivers/gpu/drm/drm_connector.c > @@ -254,8 +254,7 @@ int drm_connector_init(struct drm_device *dev, > config->num_connector++; > spin_unlock_irq(&config->connector_list_lock); > > - if (connector_type != DRM_MODE_CONNECTOR_VIRTUAL && > - connector_type != DRM_MODE_CONNECTOR_WRITEBACK) > + if (connector_type != DRM_MODE_CONNECTOR_WRITEBACK) > drm_object_attach_property(&connector->base, > config->edid_property, > 0); > -- > 2.9.3 > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] drm/bochs: add edid support. 2018-10-01 12:19 [PATCH 0/2] drm/bochs: add edid support Gerd Hoffmann @ 2018-10-01 12:19 ` Gerd Hoffmann 2018-10-01 12:19 ` Gerd Hoffmann 1 sibling, 0 replies; 6+ messages in thread From: Gerd Hoffmann @ 2018-10-01 12:19 UTC (permalink / raw) To: dri-devel Cc: Gerd Hoffmann, David Airlie, open list:DRM DRIVER FOR BOCHS VIRTUAL GPU, open list Recent qemu (latest master branch, upcoming 3.1 release) got support for EDID data. This patch adds guest driver support. EDID support in qemu is not (yet) enabled by default, so please use 'qemu -device VGA,edid=on' for testing. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> --- drivers/gpu/drm/bochs/bochs.h | 1 + drivers/gpu/drm/bochs/bochs_hw.c | 38 ++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/bochs/bochs_kms.c | 16 +++++++++++++--- 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/bochs/bochs.h b/drivers/gpu/drm/bochs/bochs.h index 375bf92cd0..055d7b437a 100644 --- a/drivers/gpu/drm/bochs/bochs.h +++ b/drivers/gpu/drm/bochs/bochs.h @@ -70,6 +70,7 @@ struct bochs_device { u16 yres_virtual; u32 stride; u32 bpp; + struct edid *edid; /* drm */ struct drm_device *dev; diff --git a/drivers/gpu/drm/bochs/bochs_hw.c b/drivers/gpu/drm/bochs/bochs_hw.c index a39b0343c1..21a769e48c 100644 --- a/drivers/gpu/drm/bochs/bochs_hw.c +++ b/drivers/gpu/drm/bochs/bochs_hw.c @@ -47,6 +47,41 @@ static void bochs_dispi_write(struct bochs_device *bochs, u16 reg, u16 val) } } +static int bochs_load_edid(struct bochs_device *bochs) +{ + uint8_t *blob; + size_t i, len; + uint8_t num_exts; + + if (!bochs->mmio) + return -1; + + if ((readb(bochs->mmio+0) != 0x00 || + readb(bochs->mmio+1) != 0xff)) + return -1; + + num_exts = readb(bochs->mmio + 126); + len = EDID_LENGTH * (1 + num_exts); + if (len > 0x400 /* vga register offset */) + return -1; + + kfree(bochs->edid); + bochs->edid = kmalloc(len, GFP_KERNEL); + blob = (void *)bochs->edid; + for (i = 0; i < len; i++) { + blob[i] = readb(bochs->mmio+i); + } + + if (!drm_edid_is_valid(bochs->edid)) { + DRM_ERROR("EDID is not valid, ignoring.\n"); + kfree(bochs->edid); + bochs->edid = NULL; + return -1; + } + + return 0; +} + int bochs_hw_init(struct drm_device *dev, uint32_t flags) { struct bochs_device *bochs = dev->dev_private; @@ -133,6 +168,9 @@ int bochs_hw_init(struct drm_device *dev, uint32_t flags) } noext: + if (bochs_load_edid(bochs) == 0) + DRM_INFO("Found EDID data blob.\n"); + return 0; } diff --git a/drivers/gpu/drm/bochs/bochs_kms.c b/drivers/gpu/drm/bochs/bochs_kms.c index ca5a9afdd5..008c5f0aaf 100644 --- a/drivers/gpu/drm/bochs/bochs_kms.c +++ b/drivers/gpu/drm/bochs/bochs_kms.c @@ -181,10 +181,17 @@ static void bochs_encoder_init(struct drm_device *dev) static int bochs_connector_get_modes(struct drm_connector *connector) { - int count; + struct bochs_device *bochs = + container_of(connector, struct bochs_device, connector); + int count = 0; - count = drm_add_modes_noedid(connector, 8192, 8192); - drm_set_preferred_mode(connector, defx, defy); + if (bochs->edid) + count = drm_add_edid_modes(connector, bochs->edid); + + if (!count) { + count = drm_add_modes_noedid(connector, 8192, 8192); + drm_set_preferred_mode(connector, defx, defy); + } return count; } @@ -239,6 +246,9 @@ static void bochs_connector_init(struct drm_device *dev) drm_connector_helper_add(connector, &bochs_connector_connector_helper_funcs); drm_connector_register(connector); + + if (bochs->edid) + drm_connector_update_edid_property(connector, bochs->edid); } -- 2.9.3 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] drm/bochs: add edid support. @ 2018-10-01 12:19 ` Gerd Hoffmann 0 siblings, 0 replies; 6+ messages in thread From: Gerd Hoffmann @ 2018-10-01 12:19 UTC (permalink / raw) To: dri-devel Cc: Gerd Hoffmann, David Airlie, open list:DRM DRIVER FOR BOCHS VIRTUAL GPU, open list Recent qemu (latest master branch, upcoming 3.1 release) got support for EDID data. This patch adds guest driver support. EDID support in qemu is not (yet) enabled by default, so please use 'qemu -device VGA,edid=on' for testing. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> --- drivers/gpu/drm/bochs/bochs.h | 1 + drivers/gpu/drm/bochs/bochs_hw.c | 38 ++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/bochs/bochs_kms.c | 16 +++++++++++++--- 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/bochs/bochs.h b/drivers/gpu/drm/bochs/bochs.h index 375bf92cd0..055d7b437a 100644 --- a/drivers/gpu/drm/bochs/bochs.h +++ b/drivers/gpu/drm/bochs/bochs.h @@ -70,6 +70,7 @@ struct bochs_device { u16 yres_virtual; u32 stride; u32 bpp; + struct edid *edid; /* drm */ struct drm_device *dev; diff --git a/drivers/gpu/drm/bochs/bochs_hw.c b/drivers/gpu/drm/bochs/bochs_hw.c index a39b0343c1..21a769e48c 100644 --- a/drivers/gpu/drm/bochs/bochs_hw.c +++ b/drivers/gpu/drm/bochs/bochs_hw.c @@ -47,6 +47,41 @@ static void bochs_dispi_write(struct bochs_device *bochs, u16 reg, u16 val) } } +static int bochs_load_edid(struct bochs_device *bochs) +{ + uint8_t *blob; + size_t i, len; + uint8_t num_exts; + + if (!bochs->mmio) + return -1; + + if ((readb(bochs->mmio+0) != 0x00 || + readb(bochs->mmio+1) != 0xff)) + return -1; + + num_exts = readb(bochs->mmio + 126); + len = EDID_LENGTH * (1 + num_exts); + if (len > 0x400 /* vga register offset */) + return -1; + + kfree(bochs->edid); + bochs->edid = kmalloc(len, GFP_KERNEL); + blob = (void *)bochs->edid; + for (i = 0; i < len; i++) { + blob[i] = readb(bochs->mmio+i); + } + + if (!drm_edid_is_valid(bochs->edid)) { + DRM_ERROR("EDID is not valid, ignoring.\n"); + kfree(bochs->edid); + bochs->edid = NULL; + return -1; + } + + return 0; +} + int bochs_hw_init(struct drm_device *dev, uint32_t flags) { struct bochs_device *bochs = dev->dev_private; @@ -133,6 +168,9 @@ int bochs_hw_init(struct drm_device *dev, uint32_t flags) } noext: + if (bochs_load_edid(bochs) == 0) + DRM_INFO("Found EDID data blob.\n"); + return 0; } diff --git a/drivers/gpu/drm/bochs/bochs_kms.c b/drivers/gpu/drm/bochs/bochs_kms.c index ca5a9afdd5..008c5f0aaf 100644 --- a/drivers/gpu/drm/bochs/bochs_kms.c +++ b/drivers/gpu/drm/bochs/bochs_kms.c @@ -181,10 +181,17 @@ static void bochs_encoder_init(struct drm_device *dev) static int bochs_connector_get_modes(struct drm_connector *connector) { - int count; + struct bochs_device *bochs = + container_of(connector, struct bochs_device, connector); + int count = 0; - count = drm_add_modes_noedid(connector, 8192, 8192); - drm_set_preferred_mode(connector, defx, defy); + if (bochs->edid) + count = drm_add_edid_modes(connector, bochs->edid); + + if (!count) { + count = drm_add_modes_noedid(connector, 8192, 8192); + drm_set_preferred_mode(connector, defx, defy); + } return count; } @@ -239,6 +246,9 @@ static void bochs_connector_init(struct drm_device *dev) drm_connector_helper_add(connector, &bochs_connector_connector_helper_funcs); drm_connector_register(connector); + + if (bochs->edid) + drm_connector_update_edid_property(connector, bochs->edid); } -- 2.9.3 ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-10-01 17:17 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-10-01 12:19 [PATCH 0/2] drm/bochs: add edid support Gerd Hoffmann 2018-10-01 12:19 ` [PATCH 1/2] drm: virtual connectors can have edid too Gerd Hoffmann 2018-10-01 12:19 ` Gerd Hoffmann 2018-10-01 17:17 ` Daniel Vetter 2018-10-01 12:19 ` [PATCH 2/2] drm/bochs: add edid support Gerd Hoffmann 2018-10-01 12:19 ` Gerd Hoffmann
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.