From: Thomas Zimmermann <tzimmermann@suse.de>
To: kraxel@redhat.com, airlied@redhat.com, daniel@ffwll.ch,
sam@ravnborg.org, javierm@redhat.com,
dri-devel@lists.freedesktop.org
Cc: Thomas Zimmermann <tzimmermann@suse.de>,
virtualization@lists.linux-foundation.org
Subject: [PATCH 02/17] drm/cirrus: Replace cpp value with format
Date: Wed, 15 Feb 2023 17:15:02 +0100 [thread overview]
Message-ID: <20230215161517.5113-3-tzimmermann@suse.de> (raw)
In-Reply-To: <20230215161517.5113-1-tzimmermann@suse.de>
Using components per pixel to describe a color format is obsolete.
Use the format info and 4CC value instead.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/gpu/drm/tiny/cirrus.c | 50 ++++++++++++++++++-----------------
1 file changed, 26 insertions(+), 24 deletions(-)
diff --git a/drivers/gpu/drm/tiny/cirrus.c b/drivers/gpu/drm/tiny/cirrus.c
index 7fb21db8416d..67e83fa42a32 100644
--- a/drivers/gpu/drm/tiny/cirrus.c
+++ b/drivers/gpu/drm/tiny/cirrus.c
@@ -58,7 +58,7 @@ struct cirrus_device {
struct drm_device dev;
struct drm_simple_display_pipe pipe;
struct drm_connector conn;
- unsigned int cpp;
+ const struct drm_format_info *format;
unsigned int pitch;
void __iomem *vram;
void __iomem *mmio;
@@ -126,34 +126,34 @@ static void wreg_hdr(struct cirrus_device *cirrus, u8 val)
iowrite8(val, cirrus->mmio + VGA_DAC_MASK);
}
-static int cirrus_convert_to(struct drm_framebuffer *fb)
+static const struct drm_format_info *cirrus_convert_to(struct drm_framebuffer *fb)
{
- if (fb->format->cpp[0] == 4 && fb->pitches[0] > CIRRUS_MAX_PITCH) {
+ if (fb->format->format == DRM_FORMAT_XRGB8888 && fb->pitches[0] > CIRRUS_MAX_PITCH) {
if (fb->width * 3 <= CIRRUS_MAX_PITCH)
/* convert from XR24 to RG24 */
- return 3;
+ return drm_format_info(DRM_FORMAT_RGB888);
else
/* convert from XR24 to RG16 */
- return 2;
+ return drm_format_info(DRM_FORMAT_RGB565);
}
- return 0;
+ return NULL;
}
-static int cirrus_cpp(struct drm_framebuffer *fb)
+static const struct drm_format_info *cirrus_format(struct drm_framebuffer *fb)
{
- int convert_cpp = cirrus_convert_to(fb);
+ const struct drm_format_info *format = cirrus_convert_to(fb);
- if (convert_cpp)
- return convert_cpp;
- return fb->format->cpp[0];
+ if (format)
+ return format;
+ return fb->format;
}
static int cirrus_pitch(struct drm_framebuffer *fb)
{
- int convert_cpp = cirrus_convert_to(fb);
+ const struct drm_format_info *format = cirrus_convert_to(fb);
- if (convert_cpp)
- return convert_cpp * fb->width;
+ if (format)
+ return drm_format_info_min_pitch(format, 0, fb->width);
return fb->pitches[0];
}
@@ -263,20 +263,20 @@ static int cirrus_mode_set(struct cirrus_device *cirrus,
sr07 &= 0xe0;
hdr = 0;
- cirrus->cpp = cirrus_cpp(fb);
- switch (cirrus->cpp * 8) {
- case 8:
+ cirrus->format = cirrus_format(fb);
+ switch (cirrus->format->format) {
+ case DRM_FORMAT_C8:
sr07 |= 0x11;
break;
- case 16:
+ case DRM_FORMAT_RGB565:
sr07 |= 0x17;
hdr = 0xc1;
break;
- case 24:
+ case DRM_FORMAT_RGB888:
sr07 |= 0x15;
hdr = 0xc5;
break;
- case 32:
+ case DRM_FORMAT_XRGB8888:
sr07 |= 0x19;
hdr = 0xc5;
break;
@@ -329,13 +329,15 @@ static int cirrus_fb_blit_rect(struct drm_framebuffer *fb,
iosys_map_set_vaddr_iomem(&dst, cirrus->vram);
iosys_map_incr(&dst, drm_fb_clip_offset(cirrus->pitch, fb->format, rect));
- if (cirrus->cpp == fb->format->cpp[0]) {
+ if (cirrus->format == fb->format) {
drm_fb_memcpy(&dst, fb->pitches, vmap, fb, rect);
- } else if (fb->format->cpp[0] == 4 && cirrus->cpp == 2) {
+ } else if (fb->format->format == DRM_FORMAT_XRGB8888 &&
+ cirrus->format->format == DRM_FORMAT_RGB565) {
drm_fb_xrgb8888_to_rgb565(&dst, &cirrus->pitch, vmap, fb, rect, false);
- } else if (fb->format->cpp[0] == 4 && cirrus->cpp == 3) {
+ } else if (fb->format->format == DRM_FORMAT_XRGB8888 &&
+ cirrus->format->format == DRM_FORMAT_RGB565) {
drm_fb_xrgb8888_to_rgb888(&dst, &cirrus->pitch, vmap, fb, rect);
} else {
@@ -450,7 +452,7 @@ static void cirrus_pipe_update(struct drm_simple_display_pipe *pipe,
struct drm_crtc *crtc = &pipe->crtc;
struct drm_rect rect;
- if (state->fb && cirrus->cpp != cirrus_cpp(state->fb))
+ if (state->fb && cirrus->format != cirrus_format(state->fb))
cirrus_mode_set(cirrus, &crtc->mode, state->fb);
if (drm_atomic_helper_damage_merged(old_state, state, &rect))
--
2.39.1
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
next prev parent reply other threads:[~2023-02-15 16:15 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-15 16:15 [PATCH 00/17] cirrus: Modernize the cirrus driver Thomas Zimmermann
2023-02-15 16:15 ` [PATCH 01/17] drm/cirrus: Compute blit destination offset in single location Thomas Zimmermann
2023-02-15 16:15 ` Thomas Zimmermann [this message]
2023-02-15 16:15 ` [PATCH 03/17] drm/cirrus: Use drm_fb_blit() to update scanout buffer Thomas Zimmermann
2023-02-15 16:15 ` [PATCH 04/17] drm/cirrus: Move drm_dev_{enter, exit}() into DRM helpers Thomas Zimmermann
2023-02-15 16:15 ` [PATCH 05/17] drm/cirrus: Split cirrus_mode_set() into smaller functions Thomas Zimmermann
2023-02-15 16:15 ` [PATCH 06/17] drm/cirrus: Integrate connector into pipeline code Thomas Zimmermann
2023-02-15 16:15 ` [PATCH 07/17] drm/cirrus: Move primary-plane format arrays Thomas Zimmermann
2023-02-15 16:15 ` [PATCH 08/17] drm/cirrus: Convert to regular atomic helpers Thomas Zimmermann
2023-02-15 16:15 ` [PATCH 09/17] drm/cirrus: Enable damage clipping on primary plane Thomas Zimmermann
2023-02-15 16:15 ` [PATCH 10/17] drm/cirrus: Inline cirrus_fb_blit_rect() Thomas Zimmermann
2023-02-15 16:15 ` [PATCH 11/17] drm/cirrus: Remove format test from cirrus_fb_create() Thomas Zimmermann
2023-02-15 16:15 ` [PATCH 12/17] drm/cirrus: Remove size " Thomas Zimmermann
2023-02-15 16:15 ` [PATCH 13/17] drm/cirrus: Test mode against video-memory size in device-wide mode_valid Thomas Zimmermann
2023-02-15 16:15 ` [PATCH 14/17] drm/cirrus: Inline cirrus_check_size() into primary-plane atomic_check Thomas Zimmermann
2023-02-15 16:15 ` [PATCH 15/17] drm/cirrus: Introduce struct cirrus_primary_plane_state Thomas Zimmermann
2023-02-15 16:15 ` [PATCH 16/17] drm/cirrus: Store HW format/pitch in primary-plane state Thomas Zimmermann
2023-02-15 16:15 ` [PATCH 17/17] drm/cirrus: Use VGA macro constants to unblank Thomas Zimmermann
2023-02-16 11:33 ` Gerd Hoffmann
2023-02-16 12:03 ` Thomas Zimmermann
2023-02-16 12:33 ` Gerd Hoffmann
2023-02-16 12:52 ` Ville Syrjälä
2023-02-16 13:19 ` Gerd Hoffmann
2023-02-16 13:21 ` Thomas Zimmermann
2023-02-16 17:20 ` Ville Syrjälä
2023-02-17 8:23 ` Thomas Zimmermann
2023-02-20 14:22 ` Thomas Zimmermann
2023-02-20 15:39 ` Gerd Hoffmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230215161517.5113-3-tzimmermann@suse.de \
--to=tzimmermann@suse.de \
--cc=airlied@redhat.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=javierm@redhat.com \
--cc=kraxel@redhat.com \
--cc=sam@ravnborg.org \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).