From: Gerd Hoffmann <kraxel@redhat.com>
To: dri-devel@lists.freedesktop.org
Cc: michel@daenzer.net, imirkin@alum.mit.edu,
Gerd Hoffmann <kraxel@redhat.com>,
Gustavo Padovan <gustavo@padovan.org>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Sean Paul <sean@poorly.run>, David Airlie <airlied@linux.ie>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH v3 1/5] drm: move native byte order quirk to new drm_mode_legacy_fb_format2 function
Date: Wed, 19 Sep 2018 13:12:48 +0200 [thread overview]
Message-ID: <20180919111252.7932-2-kraxel@redhat.com> (raw)
In-Reply-To: <20180919111252.7932-1-kraxel@redhat.com>
Turns out we need the pixel format fixup not only for the addfb ioctl,
but also for fbdev emulation code.
Ideally we would place it in drm_mode_legacy_fb_format(). That would
create alot of churn though, and most drivers don't care because they
never ever run on a big endian platform. So add a new
drm_mode_legacy_fb_format2() function instead.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
include/drm/drm_fourcc.h | 2 ++
drivers/gpu/drm/drm_fourcc.c | 28 ++++++++++++++++++++++++++++
drivers/gpu/drm/drm_framebuffer.c | 15 +++------------
3 files changed, 33 insertions(+), 12 deletions(-)
diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h
index fac831c401..4b82bb6576 100644
--- a/include/drm/drm_fourcc.h
+++ b/include/drm/drm_fourcc.h
@@ -88,6 +88,8 @@ const struct drm_format_info *
drm_get_format_info(struct drm_device *dev,
const struct drm_mode_fb_cmd2 *mode_cmd);
uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth);
+uint32_t drm_mode_legacy_fb_format2(uint32_t bpp, uint32_t depth,
+ bool native);
int drm_format_num_planes(uint32_t format);
int drm_format_plane_cpp(uint32_t format, int plane);
int drm_format_horz_chroma_subsampling(uint32_t format);
diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
index be1d6aaef6..1c1aaa8b23 100644
--- a/drivers/gpu/drm/drm_fourcc.c
+++ b/drivers/gpu/drm/drm_fourcc.c
@@ -96,6 +96,34 @@ uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth)
EXPORT_SYMBOL(drm_mode_legacy_fb_format);
/**
+ * drm_mode_legacy_fb_format2 - compute drm fourcc code from legacy description
+ * @bpp: bits per pixels
+ * @depth: bit depth per pixel
+ * @native: use host native byte order
+ *
+ * Computes a drm fourcc pixel format code for the given @bpp/@depth values.
+ * Useful in fbdev emulation code, since that deals in those values.
+ */
+uint32_t drm_mode_legacy_fb_format2(uint32_t bpp, uint32_t depth,
+ bool native)
+{
+ uint32_t fmt = drm_mode_legacy_fb_format(bpp, depth);
+
+ if (native) {
+ if (fmt == DRM_FORMAT_XRGB8888)
+ fmt = DRM_FORMAT_HOST_XRGB8888;
+ if (fmt == DRM_FORMAT_ARGB8888)
+ fmt = DRM_FORMAT_HOST_ARGB8888;
+ if (fmt == DRM_FORMAT_RGB565)
+ fmt = DRM_FORMAT_HOST_RGB565;
+ if (fmt == DRM_FORMAT_XRGB1555)
+ fmt = DRM_FORMAT_HOST_XRGB1555;
+ }
+ return fmt;
+}
+EXPORT_SYMBOL(drm_mode_legacy_fb_format2);
+
+/**
* drm_get_format_name - fill a string with a drm fourcc format's name
* @format: format to compute name of
* @buf: caller-supplied buffer
diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
index 1ee3d6b442..f72e3dffc7 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -111,12 +111,14 @@ int drm_mode_addfb(struct drm_device *dev, struct drm_mode_fb_cmd *or,
struct drm_file *file_priv)
{
struct drm_mode_fb_cmd2 r = {};
+ bool native = dev->mode_config.quirk_addfb_prefer_host_byte_order;
int ret;
if (!drm_core_check_feature(dev, DRIVER_MODESET))
return -EOPNOTSUPP;
- r.pixel_format = drm_mode_legacy_fb_format(or->bpp, or->depth);
+ r.pixel_format = drm_mode_legacy_fb_format2(or->bpp, or->depth,
+ native);
if (r.pixel_format == DRM_FORMAT_INVALID) {
DRM_DEBUG("bad {bpp:%d, depth:%d}\n", or->bpp, or->depth);
return -EINVAL;
@@ -133,17 +135,6 @@ int drm_mode_addfb(struct drm_device *dev, struct drm_mode_fb_cmd *or,
r.pixel_format == DRM_FORMAT_XRGB2101010)
r.pixel_format = DRM_FORMAT_XBGR2101010;
- if (dev->mode_config.quirk_addfb_prefer_host_byte_order) {
- if (r.pixel_format == DRM_FORMAT_XRGB8888)
- r.pixel_format = DRM_FORMAT_HOST_XRGB8888;
- if (r.pixel_format == DRM_FORMAT_ARGB8888)
- r.pixel_format = DRM_FORMAT_HOST_ARGB8888;
- if (r.pixel_format == DRM_FORMAT_RGB565)
- r.pixel_format = DRM_FORMAT_HOST_RGB565;
- if (r.pixel_format == DRM_FORMAT_XRGB1555)
- r.pixel_format = DRM_FORMAT_HOST_XRGB1555;
- }
-
ret = drm_mode_addfb2(dev, &r, file_priv);
if (ret)
return ret;
--
2.9.3
next parent reply other threads:[~2018-09-19 11:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20180919111252.7932-1-kraxel@redhat.com>
2018-09-19 11:12 ` Gerd Hoffmann [this message]
2018-09-21 9:39 ` [PATCH v3 1/5] drm: move native byte order quirk to new drm_mode_legacy_fb_format2 function Daniel Vetter
2018-09-19 11:12 ` [PATCH v3 2/5] drm: use drm_mode_legacy_fb_format2 in drm_gem_fbdev_fb_create Gerd Hoffmann
2018-09-19 11:12 ` [PATCH v3 3/5] drm/bochs: fix DRM_FORMAT_* handling for big endian machines Gerd Hoffmann
2018-09-19 11:12 ` [PATCH v3 4/5] drm/bochs: support changing byteorder at mode set time Gerd Hoffmann
2018-09-19 11:12 ` [PATCH v3 5/5] drm/virtio: fix DRM_FORMAT_* handling 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=20180919111252.7932-2-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=airlied@linux.ie \
--cc=dri-devel@lists.freedesktop.org \
--cc=gustavo@padovan.org \
--cc=imirkin@alum.mit.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=michel@daenzer.net \
--cc=sean@poorly.run \
/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