* [PATCH v2] drm/bochs: fix framebuffer setup.
@ 2019-06-27 8:12 Gerd Hoffmann
2019-06-27 8:59 ` Daniel Vetter
2019-06-27 12:12 ` Thomas Zimmermann
0 siblings, 2 replies; 3+ messages in thread
From: Gerd Hoffmann @ 2019-06-27 8:12 UTC (permalink / raw)
To: dri-devel
Cc: tzimmermann, Gerd Hoffmann, David Airlie, Daniel Vetter,
open list:DRM DRIVER FOR BOCHS VIRTUAL GPU, open list
The driver doesn't consider framebuffer pitch and offset, leading to a
wrong display in case offset != 0 or pitch != width * bpp. Fix it.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
drivers/gpu/drm/bochs/bochs.h | 2 +-
drivers/gpu/drm/bochs/bochs_hw.c | 14 ++++++++++----
drivers/gpu/drm/bochs/bochs_kms.c | 3 ++-
3 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/bochs/bochs.h b/drivers/gpu/drm/bochs/bochs.h
index cc35d492142c..2a65434500ee 100644
--- a/drivers/gpu/drm/bochs/bochs.h
+++ b/drivers/gpu/drm/bochs/bochs.h
@@ -86,7 +86,7 @@ void bochs_hw_setmode(struct bochs_device *bochs,
void bochs_hw_setformat(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 x, int y, int stride, u64 addr);
int bochs_hw_load_edid(struct bochs_device *bochs);
/* bochs_mm.c */
diff --git a/drivers/gpu/drm/bochs/bochs_hw.c b/drivers/gpu/drm/bochs/bochs_hw.c
index 791ab2f79947..ebfea8744fe6 100644
--- a/drivers/gpu/drm/bochs/bochs_hw.c
+++ b/drivers/gpu/drm/bochs/bochs_hw.c
@@ -255,16 +255,22 @@ void bochs_hw_setformat(struct bochs_device *bochs,
}
void bochs_hw_setbase(struct bochs_device *bochs,
- int x, int y, u64 addr)
+ int x, int y, int stride, u64 addr)
{
- unsigned long offset = (unsigned long)addr +
+ unsigned long offset;
+ unsigned int vx, vy, vwidth;
+
+ bochs->stride = stride;
+ offset = (unsigned long)addr +
y * bochs->stride +
x * (bochs->bpp / 8);
- int vy = offset / bochs->stride;
- int vx = (offset % bochs->stride) * 8 / bochs->bpp;
+ vy = offset / bochs->stride;
+ vx = (offset % bochs->stride) * 8 / bochs->bpp;
+ vwidth = stride * 8 / bochs->bpp;
DRM_DEBUG_DRIVER("x %d, y %d, addr %llx -> offset %lx, vx %d, vy %d\n",
x, y, addr, offset, vx, vy);
+ bochs_dispi_write(bochs, VBE_DISPI_INDEX_VIRT_WIDTH, vwidth);
bochs_dispi_write(bochs, VBE_DISPI_INDEX_X_OFFSET, vx);
bochs_dispi_write(bochs, VBE_DISPI_INDEX_Y_OFFSET, vy);
}
diff --git a/drivers/gpu/drm/bochs/bochs_kms.c b/drivers/gpu/drm/bochs/bochs_kms.c
index 5904eddc83a5..bc19dbd531ef 100644
--- a/drivers/gpu/drm/bochs/bochs_kms.c
+++ b/drivers/gpu/drm/bochs/bochs_kms.c
@@ -36,7 +36,8 @@ static void bochs_plane_update(struct bochs_device *bochs,
bochs_hw_setbase(bochs,
state->crtc_x,
state->crtc_y,
- gbo->bo.offset);
+ state->fb->pitches[0],
+ state->fb->offsets[0] + gbo->bo.offset);
bochs_hw_setformat(bochs, state->fb->format);
}
--
2.18.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] drm/bochs: fix framebuffer setup.
2019-06-27 8:12 [PATCH v2] drm/bochs: fix framebuffer setup Gerd Hoffmann
@ 2019-06-27 8:59 ` Daniel Vetter
2019-06-27 12:12 ` Thomas Zimmermann
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Vetter @ 2019-06-27 8:59 UTC (permalink / raw)
To: Gerd Hoffmann
Cc: dri-devel, tzimmermann, David Airlie, Daniel Vetter,
open list:DRM DRIVER FOR BOCHS VIRTUAL GPU, open list
On Thu, Jun 27, 2019 at 10:12:06AM +0200, Gerd Hoffmann wrote:
> The driver doesn't consider framebuffer pitch and offset, leading to a
> wrong display in case offset != 0 or pitch != width * bpp. Fix it.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Yeah this looks more like it.
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
> drivers/gpu/drm/bochs/bochs.h | 2 +-
> drivers/gpu/drm/bochs/bochs_hw.c | 14 ++++++++++----
> drivers/gpu/drm/bochs/bochs_kms.c | 3 ++-
> 3 files changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/bochs/bochs.h b/drivers/gpu/drm/bochs/bochs.h
> index cc35d492142c..2a65434500ee 100644
> --- a/drivers/gpu/drm/bochs/bochs.h
> +++ b/drivers/gpu/drm/bochs/bochs.h
> @@ -86,7 +86,7 @@ void bochs_hw_setmode(struct bochs_device *bochs,
> void bochs_hw_setformat(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 x, int y, int stride, u64 addr);
> int bochs_hw_load_edid(struct bochs_device *bochs);
>
> /* bochs_mm.c */
> diff --git a/drivers/gpu/drm/bochs/bochs_hw.c b/drivers/gpu/drm/bochs/bochs_hw.c
> index 791ab2f79947..ebfea8744fe6 100644
> --- a/drivers/gpu/drm/bochs/bochs_hw.c
> +++ b/drivers/gpu/drm/bochs/bochs_hw.c
> @@ -255,16 +255,22 @@ void bochs_hw_setformat(struct bochs_device *bochs,
> }
>
> void bochs_hw_setbase(struct bochs_device *bochs,
> - int x, int y, u64 addr)
> + int x, int y, int stride, u64 addr)
> {
> - unsigned long offset = (unsigned long)addr +
> + unsigned long offset;
> + unsigned int vx, vy, vwidth;
> +
> + bochs->stride = stride;
Might be nice to ditch these global/not-so-atomic things like
bochs->stride/bpp eventually.
-Daniel
> + offset = (unsigned long)addr +
> y * bochs->stride +
> x * (bochs->bpp / 8);
> - int vy = offset / bochs->stride;
> - int vx = (offset % bochs->stride) * 8 / bochs->bpp;
> + vy = offset / bochs->stride;
> + vx = (offset % bochs->stride) * 8 / bochs->bpp;
> + vwidth = stride * 8 / bochs->bpp;
>
> DRM_DEBUG_DRIVER("x %d, y %d, addr %llx -> offset %lx, vx %d, vy %d\n",
> x, y, addr, offset, vx, vy);
> + bochs_dispi_write(bochs, VBE_DISPI_INDEX_VIRT_WIDTH, vwidth);
> bochs_dispi_write(bochs, VBE_DISPI_INDEX_X_OFFSET, vx);
> bochs_dispi_write(bochs, VBE_DISPI_INDEX_Y_OFFSET, vy);
> }
> diff --git a/drivers/gpu/drm/bochs/bochs_kms.c b/drivers/gpu/drm/bochs/bochs_kms.c
> index 5904eddc83a5..bc19dbd531ef 100644
> --- a/drivers/gpu/drm/bochs/bochs_kms.c
> +++ b/drivers/gpu/drm/bochs/bochs_kms.c
> @@ -36,7 +36,8 @@ static void bochs_plane_update(struct bochs_device *bochs,
> bochs_hw_setbase(bochs,
> state->crtc_x,
> state->crtc_y,
> - gbo->bo.offset);
> + state->fb->pitches[0],
> + state->fb->offsets[0] + gbo->bo.offset);
> bochs_hw_setformat(bochs, state->fb->format);
> }
>
> --
> 2.18.1
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] drm/bochs: fix framebuffer setup.
2019-06-27 8:12 [PATCH v2] drm/bochs: fix framebuffer setup Gerd Hoffmann
2019-06-27 8:59 ` Daniel Vetter
@ 2019-06-27 12:12 ` Thomas Zimmermann
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Zimmermann @ 2019-06-27 12:12 UTC (permalink / raw)
To: Gerd Hoffmann, dri-devel
Cc: David Airlie, open list, open list:DRM DRIVER FOR BOCHS VIRTUAL GPU
[-- Attachment #1.1: Type: text/plain, Size: 3069 bytes --]
Hi
Am 27.06.19 um 10:12 schrieb Gerd Hoffmann:
> The driver doesn't consider framebuffer pitch and offset, leading to a
> wrong display in case offset != 0 or pitch != width * bpp. Fix it.
Thanks
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> drivers/gpu/drm/bochs/bochs.h | 2 +-
> drivers/gpu/drm/bochs/bochs_hw.c | 14 ++++++++++----
> drivers/gpu/drm/bochs/bochs_kms.c | 3 ++-
> 3 files changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/bochs/bochs.h b/drivers/gpu/drm/bochs/bochs.h
> index cc35d492142c..2a65434500ee 100644
> --- a/drivers/gpu/drm/bochs/bochs.h
> +++ b/drivers/gpu/drm/bochs/bochs.h
> @@ -86,7 +86,7 @@ void bochs_hw_setmode(struct bochs_device *bochs,
> void bochs_hw_setformat(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 x, int y, int stride, u64 addr);
> int bochs_hw_load_edid(struct bochs_device *bochs);
>
> /* bochs_mm.c */
> diff --git a/drivers/gpu/drm/bochs/bochs_hw.c b/drivers/gpu/drm/bochs/bochs_hw.c
> index 791ab2f79947..ebfea8744fe6 100644
> --- a/drivers/gpu/drm/bochs/bochs_hw.c
> +++ b/drivers/gpu/drm/bochs/bochs_hw.c
> @@ -255,16 +255,22 @@ void bochs_hw_setformat(struct bochs_device *bochs,
> }
>
> void bochs_hw_setbase(struct bochs_device *bochs,
> - int x, int y, u64 addr)
> + int x, int y, int stride, u64 addr)
> {
> - unsigned long offset = (unsigned long)addr +
> + unsigned long offset;
> + unsigned int vx, vy, vwidth;
> +
> + bochs->stride = stride;
> + offset = (unsigned long)addr +
> y * bochs->stride +
> x * (bochs->bpp / 8);
> - int vy = offset / bochs->stride;
> - int vx = (offset % bochs->stride) * 8 / bochs->bpp;
> + vy = offset / bochs->stride;
> + vx = (offset % bochs->stride) * 8 / bochs->bpp;
> + vwidth = stride * 8 / bochs->bpp;
>
> DRM_DEBUG_DRIVER("x %d, y %d, addr %llx -> offset %lx, vx %d, vy %d\n",
> x, y, addr, offset, vx, vy);
> + bochs_dispi_write(bochs, VBE_DISPI_INDEX_VIRT_WIDTH, vwidth);
> bochs_dispi_write(bochs, VBE_DISPI_INDEX_X_OFFSET, vx);
> bochs_dispi_write(bochs, VBE_DISPI_INDEX_Y_OFFSET, vy);
> }
> diff --git a/drivers/gpu/drm/bochs/bochs_kms.c b/drivers/gpu/drm/bochs/bochs_kms.c
> index 5904eddc83a5..bc19dbd531ef 100644
> --- a/drivers/gpu/drm/bochs/bochs_kms.c
> +++ b/drivers/gpu/drm/bochs/bochs_kms.c
> @@ -36,7 +36,8 @@ static void bochs_plane_update(struct bochs_device *bochs,
> bochs_hw_setbase(bochs,
> state->crtc_x,
> state->crtc_y,
> - gbo->bo.offset);
> + state->fb->pitches[0],
> + state->fb->offsets[0] + gbo->bo.offset);
> bochs_hw_setformat(bochs, state->fb->format);
> }
>
>
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Linux GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah
HRB 21284 (AG Nürnberg)
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-06-27 12:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-27 8:12 [PATCH v2] drm/bochs: fix framebuffer setup Gerd Hoffmann
2019-06-27 8:59 ` Daniel Vetter
2019-06-27 12:12 ` Thomas Zimmermann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®