From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: Sean Paul <sean@poorly.run>, Mark Rutland <mark.rutland@arm.com>,
devicetree <devicetree@vger.kernel.org>,
Jacopo Mondi <jacopo@jmondi.org>,
Rob Herring <robh+dt@kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
dri-devel <dri-devel@lists.freedesktop.org>,
Douglas Anderson <dianders@chromium.org>,
"open list:ARM/Rockchip SoC..."
<linux-rockchip@lists.infradead.org>,
Boris Brezillon <boris.brezillon@collabora.com>,
Sean Paul <seanpaul@chromium.org>,
Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>,
kernel@collabora.com, Ezequiel Garcia <ezequiel@collabora.com>
Subject: Re: [PATCH v4 2/3] drm/rockchip: Add optional support for CRTC gamma LUT
Date: Thu, 10 Oct 2019 20:36:07 +0300 [thread overview]
Message-ID: <20191010173607.GH1208@intel.com> (raw)
In-Reply-To: <CAKb7UvhWWYcpmyMZgerdJiG=sZjQUBVkeEwev+PdYzBW6+xsbQ@mail.gmail.com>
On Thu, Oct 10, 2019 at 12:23:05PM -0400, Ilia Mirkin wrote:
> On Thu, Oct 10, 2019 at 12:01 PM Sean Paul <sean@poorly.run> wrote:
> > > > > +static int vop_crtc_atomic_check(struct drm_crtc *crtc,
> > > > > + struct drm_crtc_state *crtc_state)
> > > > > +{
> > > > > + struct vop *vop = to_vop(crtc);
> > > > > +
> > > > > + if (vop->lut_regs && crtc_state->color_mgmt_changed &&
> > > > > + crtc_state->gamma_lut) {
> > > > > + unsigned int len;
> > > > > +
> > > > > + len = drm_color_lut_size(crtc_state->gamma_lut);
> > > > > + if (len != crtc->gamma_size) {
> > > > > + DRM_DEBUG_KMS("Invalid LUT size; got %d, expected %d\n",
> > > > > + len, crtc->gamma_size);
> > > > > + return -EINVAL;
> > > > > + }
> > > >
> > > > Overflow is avoided in drm_mode_gamma_set_ioctl(), so I don't think you need
> > > > this function.
> > > >
> > >
> > > But that only applies to the legacy path. Isn't this needed to ensure
> > > a gamma blob
> > > has the right size?
> >
> > Yeah, good point, we check the element size in the atomic path, but not the max
> > size. I haven't looked at enough color lut stuff to have an opinion whether this
> > check would be useful in a helper function or not, something to consider, I
> > suppose.
>
> Some implementations support multiple sizes (e.g. 256 and 1024) but
> not anything in between. It would be difficult to expose this
> generically, I would imagine.
> The 256 size is kind of special, since
> basically all legacy usage assumes that 256 is the one true quantity
> of LUT entries...
What we do currently in i915 is:
crtc->gamma_size = 256
GAMMA_LUT_SIZE = platform specific (256, 129, 257, 2^10, or 2^18+1 (lol))
DEGAMMA_LUT_SIZE = platform specific (0, 33, 65, or 2^10)
i915 will accept:
- gamma lut of size 256, iff ctm==NULL and degamma==NULL (the so
called "legacy gamma" mode)
- (de)gamma_lut of size (DE)GAMMA_LUT_SIZE if it passes the
checks done by drm_color_lut_check()
Ie. just one or two gamma modes per platform is exposed. And that's
about all we can do with the current uapi even though our hardware
supports many more modes.
The resulting precision, interpolation vs. truncation behaviour,
and handling of out of gamut values are all totally unspecified
and userspace just has to make a guess.
We also cheat with the 2^10 sized LUTs a bit due to the hw sharing
the same LUT for gamma and degamma, and so if you enable both at
the same time we throw away every second entry and each stage
only gets a 2^9 entry LUT in the end.
Oh and for the 2^18+1 monstrosity we cheat even more and
throw away ~99.8% of the entries :(
This here was my idea for extending the uapi so that we
could expose the full hw capabilities and let userspace
decide which mode suits it best without having to guess
what it'll get:
https://github.com/vsyrjala/linux/commits/gamma_mode_prop
Maybe in a few years I'll find time to get back to it...
--
Ville Syrjälä
Intel
next prev parent reply other threads:[~2019-10-10 17:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-08 23:00 [PATCH v4 0/3] RK3288 Gamma LUT Ezequiel Garcia
2019-10-08 23:00 ` [PATCH v4 1/3] dt-bindings: display: rockchip: document VOP gamma LUT address Ezequiel Garcia
2019-10-08 23:00 ` [PATCH v4 2/3] drm/rockchip: Add optional support for CRTC gamma LUT Ezequiel Garcia
2019-10-09 18:01 ` Sean Paul
2019-10-10 0:45 ` Ezequiel Garcia
2019-10-10 16:00 ` Sean Paul
2019-10-10 16:23 ` Ilia Mirkin
2019-10-10 17:36 ` Ville Syrjälä [this message]
2019-10-08 23:00 ` [PATCH v4 3/3] ARM: dts: rockchip: Add RK3288 VOP gamma LUT address Ezequiel Garcia
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=20191010173607.GH1208@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=boris.brezillon@collabora.com \
--cc=devicetree@vger.kernel.org \
--cc=dianders@chromium.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=ezequiel@collabora.com \
--cc=ezequiel@vanguardiasur.com.ar \
--cc=imirkin@alum.mit.edu \
--cc=jacopo@jmondi.org \
--cc=kernel@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=robh+dt@kernel.org \
--cc=sean@poorly.run \
--cc=seanpaul@chromium.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).