linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "james qian wang (Arm Technology China)" <james.qian.wang@arm.com>
To: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: Liviu Dudau <Liviu.Dudau@arm.com>,
	"airlied@linux.ie" <airlied@linux.ie>,
	Brian Starkey <Brian.Starkey@arm.com>,
	"maarten.lankhorst@linux.intel.com" 
	<maarten.lankhorst@linux.intel.com>,
	"sean@poorly.run" <sean@poorly.run>,
	"Jonathan Chai (Arm Technology China)" <Jonathan.Chai@arm.com>,
	"Julien Yin (Arm Technology China)" <Julien.Yin@arm.com>,
	"Thomas Sun (Arm Technology China)" <thomas.Sun@arm.com>,
	"Lowry Li (Arm Technology China)" <Lowry.Li@arm.com>,
	Ayan Halder <Ayan.Halder@arm.com>,
	"Tiannan Zhu (Arm Technology China)" <Tiannan.Zhu@arm.com>,
	"Yiqi Kang (Arm Technology China)" <Yiqi.Kang@arm.com>,
	nd <nd@arm.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>, Ben Davis <Ben.Davis@arm.com>,
	"Oscar Zhang (Arm Technology China)" <Oscar.Zhang@arm.com>,
	"Channing Chen (Arm Technology China)" <Channing.Chen@arm.com>,
	Mihail Atanassov <Mihail.Atanassov@arm.com>
Subject: Re: [PATCH v2 1/4] drm/komeda: Add a new helper drm_color_ctm_s31_32_to_qm_n()
Date: Tue, 15 Oct 2019 08:04:26 +0000	[thread overview]
Message-ID: <20191015080420.GA22242@jamwan02-TSP300> (raw)
In-Reply-To: <CAKb7Uvh7y20oikYR+UpabgXLHJM2i+2DPVyYSwE37d=NpheUGg@mail.gmail.com>

On Mon, Oct 14, 2019 at 11:48:38PM -0400, Ilia Mirkin wrote:
> On Mon, Oct 14, 2019 at 9:16 PM james qian wang (Arm Technology China)
> <james.qian.wang@arm.com> wrote:
> > On Mon, Oct 14, 2019 at 11:58:48AM -0400, Ilia Mirkin wrote:
> > > On Fri, Oct 11, 2019 at 1:43 AM james qian wang (Arm Technology China)
> > > <james.qian.wang@arm.com> wrote:
> > > > + *
> > > > + * Convert and clamp S31.32 sign-magnitude to Qm.n 2's complement.
> > > > + */
> > > > +uint64_t drm_color_ctm_s31_32_to_qm_n(uint64_t user_input,
> > > > +                                     uint32_t m, uint32_t n)
> > > > +{
> > > > +       u64 mag = (user_input & ~BIT_ULL(63)) >> (32 - n);
> > > > +       bool negative = !!(user_input & BIT_ULL(63));
> > > > +       s64 val;
> > > > +
> > > > +       /* the range of signed 2s complement is [-2^n+m, 2^n+m - 1] */
> > >
> > > This implies that n = 32, m = 0 would actually yield a 33-bit 2's
> > > complement number. Is that what you meant?
> >
> > Yes, since m doesn't include sign-bit So a Q0.32 is a 33bit value.
> 
> This goes counter to what the wikipedia page says [
> https://en.wikipedia.org/wiki/Q_(number_format) ]:
> 
> (reformatted slightly for text-only consumption):
> 
> """
> For example, a Q15.1 format number:
> 
> - requires 15+1 = 16 bits
> - its range is [-2^14, 2^14 - 2^-1] = [-16384.0, +16383.5] = [0x8000,
> 0x8001 ... 0xFFFF, 0x0000, 0x0001 ... 0x7FFE, 0x7FFF]
> - its resolution is 2^-1 = 0.5
> """
> 
> This suggests that the proper way to represent a standard 32-bit 2's
> complement integer would be Q32.0.
>

Yes you're right, I will send a new version to correct this code
according to the Wiki.

Thanks
James

>   -ilia

  reply	other threads:[~2019-10-15  8:04 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-11  5:43 [PATCH v2 0/4] drm/komeda: Enable CRTC color-mgmt james qian wang (Arm Technology China)
2019-10-11  5:43 ` [PATCH v2 1/4] drm/komeda: Add a new helper drm_color_ctm_s31_32_to_qm_n() james qian wang (Arm Technology China)
2019-10-14  8:56   ` Daniel Vetter
2019-10-14  9:58     ` james qian wang (Arm Technology China)
2019-10-14 15:33       ` Daniel Vetter
2019-10-14 15:58   ` Ilia Mirkin
2019-10-15  1:16     ` james qian wang (Arm Technology China)
2019-10-15  3:48       ` Ilia Mirkin
2019-10-15  8:04         ` james qian wang (Arm Technology China) [this message]
2019-10-15  8:21       ` Mihail Atanassov
2019-10-15  8:59         ` james qian wang (Arm Technology China)
2019-10-11  5:43 ` [PATCH v2 2/4] drm/komeda: Add drm_lut_to_fgamma_coeffs() james qian wang (Arm Technology China)
2019-10-11  5:43 ` [PATCH v2 3/4] drm/komeda: Add drm_ctm_to_coeffs() james qian wang (Arm Technology China)
2019-10-11  5:43 ` [PATCH v2 4/4] drm/komeda: Adds gamma and color-transform support for DOU-IPS james qian wang (Arm Technology China)
2019-10-11  6:21   ` sandy.huang

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=20191015080420.GA22242@jamwan02-TSP300 \
    --to=james.qian.wang@arm.com \
    --cc=Ayan.Halder@arm.com \
    --cc=Ben.Davis@arm.com \
    --cc=Brian.Starkey@arm.com \
    --cc=Channing.Chen@arm.com \
    --cc=Jonathan.Chai@arm.com \
    --cc=Julien.Yin@arm.com \
    --cc=Liviu.Dudau@arm.com \
    --cc=Lowry.Li@arm.com \
    --cc=Mihail.Atanassov@arm.com \
    --cc=Oscar.Zhang@arm.com \
    --cc=Tiannan.Zhu@arm.com \
    --cc=Yiqi.Kang@arm.com \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=imirkin@alum.mit.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=nd@arm.com \
    --cc=sean@poorly.run \
    --cc=thomas.Sun@arm.com \
    /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).