Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp432946imm; Fri, 21 Sep 2018 02:41:26 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaKQpLIK2vWFecPa7LqlJXyno5QEBEszfDCNSxccXObi0yW1CLDPuFsoqvaO8SKbd30qH9M X-Received: by 2002:a17:902:74c7:: with SMTP id f7-v6mr6557458plt.45.1537522886506; Fri, 21 Sep 2018 02:41:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537522886; cv=none; d=google.com; s=arc-20160816; b=l71+LZh7BpCuP/ra6VmvnooC/OojYoqcKRig5/i1IS4ORcQFoGnFkBhTMSvLd7nEdA OvT07RWg363JG1Oi8mFKPi75CiCrBBIn6ofvsYNFuLhy199tMVagMlNMY19KHWxYpKfG iTN9UCqEzIsSaBvf0aCnmRHJrpzzIIVQYGqGyLc/fcDtCLoBLXuhPary38tUMlIRd4A7 27MOeqAQywrAra+8Js8q848ICtMPoCfCCogDnh6dklUst3oNQKTqoC52+V4M+S0f70Vf doJkyN07mw1S2mF792nNAdP+kpncywneaWE58Zuq8BuktD3CbmpVMEfw2cA+cXL/bqfb qMFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=oSAHoG/a6415PxtuE+QzDq5QP9XDfyoeGZ6LrJoVhfY=; b=ce8S0Kj0VVanXNB2+3n4MLyidunX0ukmdNEcF9M/e7Hkt3cBKumrTWdC/zLtzeJDTY a4huxaM/VLjQHRuk/QV8HiXgY/aQnK7g0ra0sX4YPYu54P7XS8NCx3k8I/5o3D6SLtgQ fl9ug5crRIAmwCisx/SDgniU0D6Ie9tkRV6j+IbH33Rc7/kIECLdsA0TeQ5FbWN+IdpK NZ8gXnrmx0SaUM/b4eeto+/wfFt6sRCo6R+FENdCQ4s7/fA4N7LGFDHZmqT4FKujlrUd LqHzS2SpNLiMBNBJnsLMDVTwn3vzGdTqYzYDtCAr/a075TxiLO42FkcDjQTvfSfjXZxr 1Stw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=HCDvPQ+l; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o10-v6si26606820pgg.195.2018.09.21.02.41.10; Fri, 21 Sep 2018 02:41:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=HCDvPQ+l; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389602AbeIUP1O (ORCPT + 99 others); Fri, 21 Sep 2018 11:27:14 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:35445 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389434AbeIUP1N (ORCPT ); Fri, 21 Sep 2018 11:27:13 -0400 Received: by mail-ed1-f68.google.com with SMTP id y20-v6so10222276edq.2 for ; Fri, 21 Sep 2018 02:39:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=oSAHoG/a6415PxtuE+QzDq5QP9XDfyoeGZ6LrJoVhfY=; b=HCDvPQ+lvHVLcIG7H8CorWa6iSpijUHJsbx1d/9PMIutM88mKFEHgPUO8CfG40zvp0 4BOiZhbHVICXTRaI/OC/iIcJ337oJtn0al78PZd31+uSJfcnkOLarulRqe2q+ZOIeuTL MzPgyWJAYQtKIj7Sj8Kczbng75YhHaIhTsr6s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=oSAHoG/a6415PxtuE+QzDq5QP9XDfyoeGZ6LrJoVhfY=; b=ES7zhjzReeAexE9EDzVXQ+IuLoWzOlEXWp1ETRP8Rm/bEYnFJcUSEKJBEB+BuEd2KU elZErok1S0cb4GRTuSuXYU8hTF2l3LgIcQVVnG/Qcv04lOlhzjcYu2O0NcxMrOm/XUfw 1fG+6zYx1XQdAo7ajLYOE8hq3LY8PDOuFCYY4c4OSEkBHXXMNz3Qbn839JkwYBZaaLCG pdW/OEUjP0bShkjDS7kC7rYZEl/SpG8pW1eDahptn+c4+EZijJaX810jsw5tTJzSIEn+ sD0UmoqAPS4MWnDxXUhrzuo7kwgg/Vroh00uOEdbYzNEdV7mkRtoHeI0ACQCYdBQwgNd S1AA== X-Gm-Message-State: APzg51AhRZwPYKeNPYx+PCuPCoJBxXDHFmuMiqKum5MxCX90v6eqod2/ bTUmxpPlvuc/J/UQKLX6IE/ubg== X-Received: by 2002:a50:90c5:: with SMTP id d5-v6mr3113498eda.76.1537522750532; Fri, 21 Sep 2018 02:39:10 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id w2-v6sm2082113edw.83.2018.09.21.02.39.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Sep 2018 02:39:09 -0700 (PDT) Date: Fri, 21 Sep 2018 11:39:07 +0200 From: Daniel Vetter To: Gerd Hoffmann Cc: dri-devel@lists.freedesktop.org, David Airlie , michel@daenzer.net, open list , Sean Paul Subject: Re: [PATCH v3 1/5] drm: move native byte order quirk to new drm_mode_legacy_fb_format2 function Message-ID: <20180921093907.GE11082@phenom.ffwll.local> Mail-Followup-To: Gerd Hoffmann , dri-devel@lists.freedesktop.org, David Airlie , michel@daenzer.net, open list , Sean Paul References: <20180919111252.7932-1-kraxel@redhat.com> <20180919111252.7932-2-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180919111252.7932-2-kraxel@redhat.com> X-Operating-System: Linux phenom 4.14.0-1-amd64 User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 19, 2018 at 01:12:48PM +0200, Gerd Hoffmann wrote: > 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 > --- > 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) A _2 function is a bit meh imo. What about legacy_fb_format_native() instead, which unconditionally gives you the native format, and then pulling the if (native) out? Or slightly more future proof (given that we have the nouveau hack too): drm_device_legacy_fb_format(drm_device *dev, bpp, depth); to make it clear that this is the device-specific conversion function. -Daniel > +{ > + 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 > > _______________________________________________ > 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