All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4] drm/bochs: add edid support.
@ 2018-10-29 20:50 Gerd Hoffmann
  0 siblings, 0 replies; 6+ messages in thread
From: Gerd Hoffmann @ 2018-10-29 20:50 UTC (permalink / raw)
  To: dri-devel
  Cc: David Airlie, open list, jani.nikula,
	open list:DRM DRIVER FOR BOCHS VIRTUAL GPU, David Airlie

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     |  2 ++
 drivers/gpu/drm/bochs/bochs_hw.c  | 30 ++++++++++++++++++++++++++++++
 drivers/gpu/drm/bochs/bochs_kms.c | 20 +++++++++++++++++---
 3 files changed, 49 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/bochs/bochs.h b/drivers/gpu/drm/bochs/bochs.h
index e7a69077e4..577a8b917c 100644
--- a/drivers/gpu/drm/bochs/bochs.h
+++ b/drivers/gpu/drm/bochs/bochs.h
@@ -66,6 +66,7 @@ struct bochs_device {
 	u16 yres_virtual;
 	u32 stride;
 	u32 bpp;
+	struct edid *edid;
 
 	/* drm */
 	struct drm_device  *dev;
@@ -126,6 +127,7 @@ void bochs_hw_setmode(struct bochs_device *bochs,
 		      const struct drm_format_info *format);
 void bochs_hw_setbase(struct bochs_device *bochs,
 		      int x, int y, u64 addr);
+int bochs_hw_load_edid(struct bochs_device *bochs);
 
 /* bochs_mm.c */
 int bochs_mm_init(struct bochs_device *bochs);
diff --git a/drivers/gpu/drm/bochs/bochs_hw.c b/drivers/gpu/drm/bochs/bochs_hw.c
index cacff73a64..c90a0d492f 100644
--- a/drivers/gpu/drm/bochs/bochs_hw.c
+++ b/drivers/gpu/drm/bochs/bochs_hw.c
@@ -69,6 +69,35 @@ static void bochs_hw_set_little_endian(struct bochs_device *bochs)
 #define bochs_hw_set_native_endian(_b) bochs_hw_set_little_endian(_b)
 #endif
 
+static int bochs_get_edid_block(void *data, u8 *buf,
+				unsigned int block, size_t len)
+{
+	struct bochs_device *bochs = data;
+	size_t i, start = block * EDID_LENGTH;
+
+	if (start + len > 0x400 /* vga register offset */)
+		return -1;
+
+	for (i = 0; i < len; i++) {
+		buf[i] = readb(bochs->mmio + start + i);
+	}
+	return 0;
+}
+
+int bochs_hw_load_edid(struct bochs_device *bochs)
+{
+	if (!bochs->mmio)
+		return -1;
+
+	kfree(bochs->edid);
+	bochs->edid = drm_do_get_edid(&bochs->connector,
+				      bochs_get_edid_block, bochs);
+	if (bochs->edid == NULL)
+		return -1;
+
+	return 0;
+}
+
 int bochs_hw_init(struct drm_device *dev)
 {
 	struct bochs_device *bochs = dev->dev_private;
@@ -164,6 +193,7 @@ void bochs_hw_fini(struct drm_device *dev)
 	if (bochs->fb_map)
 		iounmap(bochs->fb_map);
 	pci_release_regions(dev->pdev);
+	kfree(bochs->edid);
 }
 
 void bochs_hw_setmode(struct bochs_device *bochs,
diff --git a/drivers/gpu/drm/bochs/bochs_kms.c b/drivers/gpu/drm/bochs/bochs_kms.c
index 9bc5b438ae..f87c284dd9 100644
--- a/drivers/gpu/drm/bochs/bochs_kms.c
+++ b/drivers/gpu/drm/bochs/bochs_kms.c
@@ -213,10 +213,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;
 }
 
@@ -271,6 +278,13 @@ static void bochs_connector_init(struct drm_device *dev)
 	drm_connector_helper_add(connector,
 				 &bochs_connector_connector_helper_funcs);
 	drm_connector_register(connector);
+
+	bochs_hw_load_edid(bochs);
+	if (bochs->edid) {
+		DRM_INFO("Found EDID data blob.\n");
+		drm_connector_attach_edid_property(connector);
+		drm_connector_update_edid_property(connector, bochs->edid);
+	}
 }
 
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v4] drm/bochs: add edid support.
  2018-10-29 20:50 ` Gerd Hoffmann
@ 2018-10-30  9:35   ` Daniel Vetter
  -1 siblings, 0 replies; 6+ messages in thread
From: Daniel Vetter @ 2018-10-30  9:35 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: dri-devel, David Airlie, open list,
	open list:DRM DRIVER FOR BOCHS VIRTUAL GPU, David Airlie

On Mon, Oct 29, 2018 at 09:50:48PM +0100, Gerd Hoffmann wrote:
> 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>

I liked v3 more, but Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> on
either wone.
-Daniel

> ---
>  drivers/gpu/drm/bochs/bochs.h     |  2 ++
>  drivers/gpu/drm/bochs/bochs_hw.c  | 30 ++++++++++++++++++++++++++++++
>  drivers/gpu/drm/bochs/bochs_kms.c | 20 +++++++++++++++++---
>  3 files changed, 49 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bochs/bochs.h b/drivers/gpu/drm/bochs/bochs.h
> index e7a69077e4..577a8b917c 100644
> --- a/drivers/gpu/drm/bochs/bochs.h
> +++ b/drivers/gpu/drm/bochs/bochs.h
> @@ -66,6 +66,7 @@ struct bochs_device {
>  	u16 yres_virtual;
>  	u32 stride;
>  	u32 bpp;
> +	struct edid *edid;
>  
>  	/* drm */
>  	struct drm_device  *dev;
> @@ -126,6 +127,7 @@ void bochs_hw_setmode(struct bochs_device *bochs,
>  		      const struct drm_format_info *format);
>  void bochs_hw_setbase(struct bochs_device *bochs,
>  		      int x, int y, u64 addr);
> +int bochs_hw_load_edid(struct bochs_device *bochs);
>  
>  /* bochs_mm.c */
>  int bochs_mm_init(struct bochs_device *bochs);
> diff --git a/drivers/gpu/drm/bochs/bochs_hw.c b/drivers/gpu/drm/bochs/bochs_hw.c
> index cacff73a64..c90a0d492f 100644
> --- a/drivers/gpu/drm/bochs/bochs_hw.c
> +++ b/drivers/gpu/drm/bochs/bochs_hw.c
> @@ -69,6 +69,35 @@ static void bochs_hw_set_little_endian(struct bochs_device *bochs)
>  #define bochs_hw_set_native_endian(_b) bochs_hw_set_little_endian(_b)
>  #endif
>  
> +static int bochs_get_edid_block(void *data, u8 *buf,
> +				unsigned int block, size_t len)
> +{
> +	struct bochs_device *bochs = data;
> +	size_t i, start = block * EDID_LENGTH;
> +
> +	if (start + len > 0x400 /* vga register offset */)
> +		return -1;
> +
> +	for (i = 0; i < len; i++) {
> +		buf[i] = readb(bochs->mmio + start + i);
> +	}
> +	return 0;
> +}
> +
> +int bochs_hw_load_edid(struct bochs_device *bochs)
> +{
> +	if (!bochs->mmio)
> +		return -1;
> +
> +	kfree(bochs->edid);
> +	bochs->edid = drm_do_get_edid(&bochs->connector,
> +				      bochs_get_edid_block, bochs);
> +	if (bochs->edid == NULL)
> +		return -1;
> +
> +	return 0;
> +}
> +
>  int bochs_hw_init(struct drm_device *dev)
>  {
>  	struct bochs_device *bochs = dev->dev_private;
> @@ -164,6 +193,7 @@ void bochs_hw_fini(struct drm_device *dev)
>  	if (bochs->fb_map)
>  		iounmap(bochs->fb_map);
>  	pci_release_regions(dev->pdev);
> +	kfree(bochs->edid);
>  }
>  
>  void bochs_hw_setmode(struct bochs_device *bochs,
> diff --git a/drivers/gpu/drm/bochs/bochs_kms.c b/drivers/gpu/drm/bochs/bochs_kms.c
> index 9bc5b438ae..f87c284dd9 100644
> --- a/drivers/gpu/drm/bochs/bochs_kms.c
> +++ b/drivers/gpu/drm/bochs/bochs_kms.c
> @@ -213,10 +213,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;
>  }
>  
> @@ -271,6 +278,13 @@ static void bochs_connector_init(struct drm_device *dev)
>  	drm_connector_helper_add(connector,
>  				 &bochs_connector_connector_helper_funcs);
>  	drm_connector_register(connector);
> +
> +	bochs_hw_load_edid(bochs);
> +	if (bochs->edid) {
> +		DRM_INFO("Found EDID data blob.\n");
> +		drm_connector_attach_edid_property(connector);
> +		drm_connector_update_edid_property(connector, bochs->edid);
> +	}
>  }
>  
>  
> -- 
> 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

* Re: [PATCH v4] drm/bochs: add edid support.
  2018-10-29 20:50 ` Gerd Hoffmann
  (?)
@ 2018-10-30  9:35 ` Daniel Vetter
  -1 siblings, 0 replies; 6+ messages in thread
From: Daniel Vetter @ 2018-10-30  9:35 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: David Airlie, David Airlie, open list, dri-devel,
	open list:DRM DRIVER FOR BOCHS VIRTUAL GPU

On Mon, Oct 29, 2018 at 09:50:48PM +0100, Gerd Hoffmann wrote:
> 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>

I liked v3 more, but Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> on
either wone.
-Daniel

> ---
>  drivers/gpu/drm/bochs/bochs.h     |  2 ++
>  drivers/gpu/drm/bochs/bochs_hw.c  | 30 ++++++++++++++++++++++++++++++
>  drivers/gpu/drm/bochs/bochs_kms.c | 20 +++++++++++++++++---
>  3 files changed, 49 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bochs/bochs.h b/drivers/gpu/drm/bochs/bochs.h
> index e7a69077e4..577a8b917c 100644
> --- a/drivers/gpu/drm/bochs/bochs.h
> +++ b/drivers/gpu/drm/bochs/bochs.h
> @@ -66,6 +66,7 @@ struct bochs_device {
>  	u16 yres_virtual;
>  	u32 stride;
>  	u32 bpp;
> +	struct edid *edid;
>  
>  	/* drm */
>  	struct drm_device  *dev;
> @@ -126,6 +127,7 @@ void bochs_hw_setmode(struct bochs_device *bochs,
>  		      const struct drm_format_info *format);
>  void bochs_hw_setbase(struct bochs_device *bochs,
>  		      int x, int y, u64 addr);
> +int bochs_hw_load_edid(struct bochs_device *bochs);
>  
>  /* bochs_mm.c */
>  int bochs_mm_init(struct bochs_device *bochs);
> diff --git a/drivers/gpu/drm/bochs/bochs_hw.c b/drivers/gpu/drm/bochs/bochs_hw.c
> index cacff73a64..c90a0d492f 100644
> --- a/drivers/gpu/drm/bochs/bochs_hw.c
> +++ b/drivers/gpu/drm/bochs/bochs_hw.c
> @@ -69,6 +69,35 @@ static void bochs_hw_set_little_endian(struct bochs_device *bochs)
>  #define bochs_hw_set_native_endian(_b) bochs_hw_set_little_endian(_b)
>  #endif
>  
> +static int bochs_get_edid_block(void *data, u8 *buf,
> +				unsigned int block, size_t len)
> +{
> +	struct bochs_device *bochs = data;
> +	size_t i, start = block * EDID_LENGTH;
> +
> +	if (start + len > 0x400 /* vga register offset */)
> +		return -1;
> +
> +	for (i = 0; i < len; i++) {
> +		buf[i] = readb(bochs->mmio + start + i);
> +	}
> +	return 0;
> +}
> +
> +int bochs_hw_load_edid(struct bochs_device *bochs)
> +{
> +	if (!bochs->mmio)
> +		return -1;
> +
> +	kfree(bochs->edid);
> +	bochs->edid = drm_do_get_edid(&bochs->connector,
> +				      bochs_get_edid_block, bochs);
> +	if (bochs->edid == NULL)
> +		return -1;
> +
> +	return 0;
> +}
> +
>  int bochs_hw_init(struct drm_device *dev)
>  {
>  	struct bochs_device *bochs = dev->dev_private;
> @@ -164,6 +193,7 @@ void bochs_hw_fini(struct drm_device *dev)
>  	if (bochs->fb_map)
>  		iounmap(bochs->fb_map);
>  	pci_release_regions(dev->pdev);
> +	kfree(bochs->edid);
>  }
>  
>  void bochs_hw_setmode(struct bochs_device *bochs,
> diff --git a/drivers/gpu/drm/bochs/bochs_kms.c b/drivers/gpu/drm/bochs/bochs_kms.c
> index 9bc5b438ae..f87c284dd9 100644
> --- a/drivers/gpu/drm/bochs/bochs_kms.c
> +++ b/drivers/gpu/drm/bochs/bochs_kms.c
> @@ -213,10 +213,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;
>  }
>  
> @@ -271,6 +278,13 @@ static void bochs_connector_init(struct drm_device *dev)
>  	drm_connector_helper_add(connector,
>  				 &bochs_connector_connector_helper_funcs);
>  	drm_connector_register(connector);
> +
> +	bochs_hw_load_edid(bochs);
> +	if (bochs->edid) {
> +		DRM_INFO("Found EDID data blob.\n");
> +		drm_connector_attach_edid_property(connector);
> +		drm_connector_update_edid_property(connector, bochs->edid);
> +	}
>  }
>  
>  
> -- 
> 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

* Re: [PATCH v4] drm/bochs: add edid support.
@ 2018-10-30  9:35   ` Daniel Vetter
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Vetter @ 2018-10-30  9:35 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: David Airlie, David Airlie, open list, dri-devel,
	open list:DRM DRIVER FOR BOCHS VIRTUAL GPU

On Mon, Oct 29, 2018 at 09:50:48PM +0100, Gerd Hoffmann wrote:
> 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>

I liked v3 more, but Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> on
either wone.
-Daniel

> ---
>  drivers/gpu/drm/bochs/bochs.h     |  2 ++
>  drivers/gpu/drm/bochs/bochs_hw.c  | 30 ++++++++++++++++++++++++++++++
>  drivers/gpu/drm/bochs/bochs_kms.c | 20 +++++++++++++++++---
>  3 files changed, 49 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bochs/bochs.h b/drivers/gpu/drm/bochs/bochs.h
> index e7a69077e4..577a8b917c 100644
> --- a/drivers/gpu/drm/bochs/bochs.h
> +++ b/drivers/gpu/drm/bochs/bochs.h
> @@ -66,6 +66,7 @@ struct bochs_device {
>  	u16 yres_virtual;
>  	u32 stride;
>  	u32 bpp;
> +	struct edid *edid;
>  
>  	/* drm */
>  	struct drm_device  *dev;
> @@ -126,6 +127,7 @@ void bochs_hw_setmode(struct bochs_device *bochs,
>  		      const struct drm_format_info *format);
>  void bochs_hw_setbase(struct bochs_device *bochs,
>  		      int x, int y, u64 addr);
> +int bochs_hw_load_edid(struct bochs_device *bochs);
>  
>  /* bochs_mm.c */
>  int bochs_mm_init(struct bochs_device *bochs);
> diff --git a/drivers/gpu/drm/bochs/bochs_hw.c b/drivers/gpu/drm/bochs/bochs_hw.c
> index cacff73a64..c90a0d492f 100644
> --- a/drivers/gpu/drm/bochs/bochs_hw.c
> +++ b/drivers/gpu/drm/bochs/bochs_hw.c
> @@ -69,6 +69,35 @@ static void bochs_hw_set_little_endian(struct bochs_device *bochs)
>  #define bochs_hw_set_native_endian(_b) bochs_hw_set_little_endian(_b)
>  #endif
>  
> +static int bochs_get_edid_block(void *data, u8 *buf,
> +				unsigned int block, size_t len)
> +{
> +	struct bochs_device *bochs = data;
> +	size_t i, start = block * EDID_LENGTH;
> +
> +	if (start + len > 0x400 /* vga register offset */)
> +		return -1;
> +
> +	for (i = 0; i < len; i++) {
> +		buf[i] = readb(bochs->mmio + start + i);
> +	}
> +	return 0;
> +}
> +
> +int bochs_hw_load_edid(struct bochs_device *bochs)
> +{
> +	if (!bochs->mmio)
> +		return -1;
> +
> +	kfree(bochs->edid);
> +	bochs->edid = drm_do_get_edid(&bochs->connector,
> +				      bochs_get_edid_block, bochs);
> +	if (bochs->edid == NULL)
> +		return -1;
> +
> +	return 0;
> +}
> +
>  int bochs_hw_init(struct drm_device *dev)
>  {
>  	struct bochs_device *bochs = dev->dev_private;
> @@ -164,6 +193,7 @@ void bochs_hw_fini(struct drm_device *dev)
>  	if (bochs->fb_map)
>  		iounmap(bochs->fb_map);
>  	pci_release_regions(dev->pdev);
> +	kfree(bochs->edid);
>  }
>  
>  void bochs_hw_setmode(struct bochs_device *bochs,
> diff --git a/drivers/gpu/drm/bochs/bochs_kms.c b/drivers/gpu/drm/bochs/bochs_kms.c
> index 9bc5b438ae..f87c284dd9 100644
> --- a/drivers/gpu/drm/bochs/bochs_kms.c
> +++ b/drivers/gpu/drm/bochs/bochs_kms.c
> @@ -213,10 +213,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;
>  }
>  
> @@ -271,6 +278,13 @@ static void bochs_connector_init(struct drm_device *dev)
>  	drm_connector_helper_add(connector,
>  				 &bochs_connector_connector_helper_funcs);
>  	drm_connector_register(connector);
> +
> +	bochs_hw_load_edid(bochs);
> +	if (bochs->edid) {
> +		DRM_INFO("Found EDID data blob.\n");
> +		drm_connector_attach_edid_property(connector);
> +		drm_connector_update_edid_property(connector, bochs->edid);
> +	}
>  }
>  
>  
> -- 
> 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
_______________________________________________
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 v4] drm/bochs: add edid support.
@ 2018-10-29 20:50 ` Gerd Hoffmann
  0 siblings, 0 replies; 6+ messages in thread
From: Gerd Hoffmann @ 2018-10-29 20:50 UTC (permalink / raw)
  To: dri-devel
  Cc: David Airlie, jani.nikula, 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     |  2 ++
 drivers/gpu/drm/bochs/bochs_hw.c  | 30 ++++++++++++++++++++++++++++++
 drivers/gpu/drm/bochs/bochs_kms.c | 20 +++++++++++++++++---
 3 files changed, 49 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/bochs/bochs.h b/drivers/gpu/drm/bochs/bochs.h
index e7a69077e4..577a8b917c 100644
--- a/drivers/gpu/drm/bochs/bochs.h
+++ b/drivers/gpu/drm/bochs/bochs.h
@@ -66,6 +66,7 @@ struct bochs_device {
 	u16 yres_virtual;
 	u32 stride;
 	u32 bpp;
+	struct edid *edid;
 
 	/* drm */
 	struct drm_device  *dev;
@@ -126,6 +127,7 @@ void bochs_hw_setmode(struct bochs_device *bochs,
 		      const struct drm_format_info *format);
 void bochs_hw_setbase(struct bochs_device *bochs,
 		      int x, int y, u64 addr);
+int bochs_hw_load_edid(struct bochs_device *bochs);
 
 /* bochs_mm.c */
 int bochs_mm_init(struct bochs_device *bochs);
diff --git a/drivers/gpu/drm/bochs/bochs_hw.c b/drivers/gpu/drm/bochs/bochs_hw.c
index cacff73a64..c90a0d492f 100644
--- a/drivers/gpu/drm/bochs/bochs_hw.c
+++ b/drivers/gpu/drm/bochs/bochs_hw.c
@@ -69,6 +69,35 @@ static void bochs_hw_set_little_endian(struct bochs_device *bochs)
 #define bochs_hw_set_native_endian(_b) bochs_hw_set_little_endian(_b)
 #endif
 
+static int bochs_get_edid_block(void *data, u8 *buf,
+				unsigned int block, size_t len)
+{
+	struct bochs_device *bochs = data;
+	size_t i, start = block * EDID_LENGTH;
+
+	if (start + len > 0x400 /* vga register offset */)
+		return -1;
+
+	for (i = 0; i < len; i++) {
+		buf[i] = readb(bochs->mmio + start + i);
+	}
+	return 0;
+}
+
+int bochs_hw_load_edid(struct bochs_device *bochs)
+{
+	if (!bochs->mmio)
+		return -1;
+
+	kfree(bochs->edid);
+	bochs->edid = drm_do_get_edid(&bochs->connector,
+				      bochs_get_edid_block, bochs);
+	if (bochs->edid == NULL)
+		return -1;
+
+	return 0;
+}
+
 int bochs_hw_init(struct drm_device *dev)
 {
 	struct bochs_device *bochs = dev->dev_private;
@@ -164,6 +193,7 @@ void bochs_hw_fini(struct drm_device *dev)
 	if (bochs->fb_map)
 		iounmap(bochs->fb_map);
 	pci_release_regions(dev->pdev);
+	kfree(bochs->edid);
 }
 
 void bochs_hw_setmode(struct bochs_device *bochs,
diff --git a/drivers/gpu/drm/bochs/bochs_kms.c b/drivers/gpu/drm/bochs/bochs_kms.c
index 9bc5b438ae..f87c284dd9 100644
--- a/drivers/gpu/drm/bochs/bochs_kms.c
+++ b/drivers/gpu/drm/bochs/bochs_kms.c
@@ -213,10 +213,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;
 }
 
@@ -271,6 +278,13 @@ static void bochs_connector_init(struct drm_device *dev)
 	drm_connector_helper_add(connector,
 				 &bochs_connector_connector_helper_funcs);
 	drm_connector_register(connector);
+
+	bochs_hw_load_edid(bochs);
+	if (bochs->edid) {
+		DRM_INFO("Found EDID data blob.\n");
+		drm_connector_attach_edid_property(connector);
+		drm_connector_update_edid_property(connector, bochs->edid);
+	}
 }
 
 
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v4] drm/bochs: add edid support.
@ 2018-10-29 20:50 ` Gerd Hoffmann
  0 siblings, 0 replies; 6+ messages in thread
From: Gerd Hoffmann @ 2018-10-29 20:50 UTC (permalink / raw)
  To: dri-devel
  Cc: David Airlie, open list,
	open list:DRM DRIVER FOR BOCHS VIRTUAL GPU, Gerd Hoffmann,
	David Airlie

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     |  2 ++
 drivers/gpu/drm/bochs/bochs_hw.c  | 30 ++++++++++++++++++++++++++++++
 drivers/gpu/drm/bochs/bochs_kms.c | 20 +++++++++++++++++---
 3 files changed, 49 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/bochs/bochs.h b/drivers/gpu/drm/bochs/bochs.h
index e7a69077e4..577a8b917c 100644
--- a/drivers/gpu/drm/bochs/bochs.h
+++ b/drivers/gpu/drm/bochs/bochs.h
@@ -66,6 +66,7 @@ struct bochs_device {
 	u16 yres_virtual;
 	u32 stride;
 	u32 bpp;
+	struct edid *edid;
 
 	/* drm */
 	struct drm_device  *dev;
@@ -126,6 +127,7 @@ void bochs_hw_setmode(struct bochs_device *bochs,
 		      const struct drm_format_info *format);
 void bochs_hw_setbase(struct bochs_device *bochs,
 		      int x, int y, u64 addr);
+int bochs_hw_load_edid(struct bochs_device *bochs);
 
 /* bochs_mm.c */
 int bochs_mm_init(struct bochs_device *bochs);
diff --git a/drivers/gpu/drm/bochs/bochs_hw.c b/drivers/gpu/drm/bochs/bochs_hw.c
index cacff73a64..c90a0d492f 100644
--- a/drivers/gpu/drm/bochs/bochs_hw.c
+++ b/drivers/gpu/drm/bochs/bochs_hw.c
@@ -69,6 +69,35 @@ static void bochs_hw_set_little_endian(struct bochs_device *bochs)
 #define bochs_hw_set_native_endian(_b) bochs_hw_set_little_endian(_b)
 #endif
 
+static int bochs_get_edid_block(void *data, u8 *buf,
+				unsigned int block, size_t len)
+{
+	struct bochs_device *bochs = data;
+	size_t i, start = block * EDID_LENGTH;
+
+	if (start + len > 0x400 /* vga register offset */)
+		return -1;
+
+	for (i = 0; i < len; i++) {
+		buf[i] = readb(bochs->mmio + start + i);
+	}
+	return 0;
+}
+
+int bochs_hw_load_edid(struct bochs_device *bochs)
+{
+	if (!bochs->mmio)
+		return -1;
+
+	kfree(bochs->edid);
+	bochs->edid = drm_do_get_edid(&bochs->connector,
+				      bochs_get_edid_block, bochs);
+	if (bochs->edid == NULL)
+		return -1;
+
+	return 0;
+}
+
 int bochs_hw_init(struct drm_device *dev)
 {
 	struct bochs_device *bochs = dev->dev_private;
@@ -164,6 +193,7 @@ void bochs_hw_fini(struct drm_device *dev)
 	if (bochs->fb_map)
 		iounmap(bochs->fb_map);
 	pci_release_regions(dev->pdev);
+	kfree(bochs->edid);
 }
 
 void bochs_hw_setmode(struct bochs_device *bochs,
diff --git a/drivers/gpu/drm/bochs/bochs_kms.c b/drivers/gpu/drm/bochs/bochs_kms.c
index 9bc5b438ae..f87c284dd9 100644
--- a/drivers/gpu/drm/bochs/bochs_kms.c
+++ b/drivers/gpu/drm/bochs/bochs_kms.c
@@ -213,10 +213,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;
 }
 
@@ -271,6 +278,13 @@ static void bochs_connector_init(struct drm_device *dev)
 	drm_connector_helper_add(connector,
 				 &bochs_connector_connector_helper_funcs);
 	drm_connector_register(connector);
+
+	bochs_hw_load_edid(bochs);
+	if (bochs->edid) {
+		DRM_INFO("Found EDID data blob.\n");
+		drm_connector_attach_edid_property(connector);
+		drm_connector_update_edid_property(connector, bochs->edid);
+	}
 }
 
 
-- 
2.9.3

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-10-30  9:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-29 20:50 [PATCH v4] drm/bochs: add edid support Gerd Hoffmann
2018-10-29 20:50 Gerd Hoffmann
2018-10-29 20:50 ` Gerd Hoffmann
2018-10-30  9:35 ` Daniel Vetter
2018-10-30  9:35 ` Daniel Vetter
2018-10-30  9:35   ` Daniel Vetter

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.