Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4278008ybp; Mon, 14 Oct 2019 01:58:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqyG0ITpPWIXRrE9DpBbUCGCPD9Hb19OUY8Rs2mqLkn77u/d4u44AX9Cz0znHp06CCSWYnLp X-Received: by 2002:a50:ed90:: with SMTP id h16mr26965263edr.185.1571043497756; Mon, 14 Oct 2019 01:58:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571043497; cv=none; d=google.com; s=arc-20160816; b=rTXVYbmmoaRqu2xxGKoer831DqpttcKjGU7uzbr0GZGRVjT2iGd7g/KrHI12Sbz5+8 h1u+zpwajDRa0BIMCv2ChONkG16SD2caXmUqIh48bUVI4+JprdDUrhJtpwTWdtZFp6Qe BrrpN+ImQijHc5kflpJzLHQ+MILB7igF/eVwvw+4Y+e2RWiJcNFfii8tINx2zlAJN5E6 frfJ5fpBIGWNQCL6hTq1eIoSghqh/H5IPWFUQ88OT/ubDKRXXN4KYKaO1J0Zp4KdNnIZ 6Yu6oaxjw2R3XVRFUcdEuMeQan5ylZ+Gwv+R5F27fsD1FxnzlL/dsL7UvfoLiYcHQvqA ovWg== 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=9F9gOYnMz1+3hKjqRaXRapzlcu7Wa8gomJLsrlXQKa0=; b=QTH7ebbk4kyfIrSlTbpjAFL3BTFs2gvWivIItDPX/ahgmeo+z9f2/N1SMWRQkF/kvH l0fQSvtnWEMJTWV6OPxhvaKSWtHF40xpuOYR5pCYzqVSCVN6gJwR92154/adkTmn0d7I h6RmqsJCGDWBLQdEhDMqSM8ESe0+Fz+eS3ZLXXik260L5jaiSewhb/2xTTKOdf3PqMbw YJQsMIAOE5ylvQedNtXnAAONOOduSnhO2e510EdGtY0a2e1jJc8cVjRAy4PRIPjFcwVN kWRdAh5H1r04dgd9+fKctT/v4C73/EfmugBZ8yeFivPvcRrzaZkju0Sw5DTuCorKnqfO vEmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=H3fsufQY; 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 v25si10573111edy.392.2019.10.14.01.57.54; Mon, 14 Oct 2019 01:58:17 -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=H3fsufQY; 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 S1730613AbfJNI4K (ORCPT + 99 others); Mon, 14 Oct 2019 04:56:10 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:37418 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730354AbfJNI4K (ORCPT ); Mon, 14 Oct 2019 04:56:10 -0400 Received: by mail-ed1-f65.google.com with SMTP id r4so14109328edy.4 for ; Mon, 14 Oct 2019 01:56:09 -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=9F9gOYnMz1+3hKjqRaXRapzlcu7Wa8gomJLsrlXQKa0=; b=H3fsufQY+jqDLcAODQvS6dik5keKPPlV2l5p8CI7y+FRxa4pGXYxJjncbozWnJXz6G ceDsHxGT9HNEGu4vcQsYHfkpiTXCYlvrJL4wrEsl2Ov72zkFDOjo+IJt5uyvUQusaUds 9xbzdg1w3vJK3LNLxoAHppF0MzZm0Od1SGiEU= 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=9F9gOYnMz1+3hKjqRaXRapzlcu7Wa8gomJLsrlXQKa0=; b=LWH7R3zmv6qhSw9UvDSzsnBNFLuutaIw+8woOAhHmGIWQMvH43onzBm1kHNkQwQbpq IHOhVX+8gIclvdC0WG/HvMIxyynp/xfL6kTOVfXPlNegJDyaTG27ddemkGYORtdYjdsG 3600JvrI4aXHJpWZywcLBmAfbG7d0B0EP8MWPu1CJrxCCBmBJurSk/3zLrMRuD/XzDdJ E5iXtLOH68gnQHDMTxpB51+rrxCTA/psBAWqtnKkgdNxpPzrCnuKnjOHtU3XU9w1I85B D30j+W7vvFBACUfYKMdkEjz3ZurmSBIfSXbmxXrV0YZV0+xrjsfB7IYVzQGB9PfIqM6Q pO7w== X-Gm-Message-State: APjAAAV9uK07HdYknkt33HXMz6ePKjrgHVBbKQqAGL4fz1zN1n/qALM6 JDRAbfQecoKa6xwxxVLHGQ+Ldg== X-Received: by 2002:a17:906:5388:: with SMTP id g8mr27299623ejo.278.1571043368485; Mon, 14 Oct 2019 01:56:08 -0700 (PDT) Received: from phenom.ffwll.local (212-51-149-96.fiber7.init7.net. [212.51.149.96]) by smtp.gmail.com with ESMTPSA id v22sm3077031edm.89.2019.10.14.01.56.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 01:56:07 -0700 (PDT) Date: Mon, 14 Oct 2019 10:56:05 +0200 From: Daniel Vetter To: "james qian wang (Arm Technology China)" Cc: Liviu Dudau , "airlied@linux.ie" , Brian Starkey , "maarten.lankhorst@linux.intel.com" , "sean@poorly.run" , "imirkin@alum.mit.edu" , nd , Ayan Halder , "Oscar Zhang (Arm Technology China)" , "Tiannan Zhu (Arm Technology China)" , Mihail Atanassov , "Jonathan Chai (Arm Technology China)" , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "Julien Yin (Arm Technology China)" , "Channing Chen (Arm Technology China)" , "Yiqi Kang (Arm Technology China)" , "Thomas Sun (Arm Technology China)" , "Lowry Li (Arm Technology China)" , Ben Davis Subject: Re: [PATCH v2 1/4] drm/komeda: Add a new helper drm_color_ctm_s31_32_to_qm_n() Message-ID: <20191014085605.GF11828@phenom.ffwll.local> Mail-Followup-To: "james qian wang (Arm Technology China)" , Liviu Dudau , "airlied@linux.ie" , Brian Starkey , "maarten.lankhorst@linux.intel.com" , "sean@poorly.run" , "imirkin@alum.mit.edu" , nd , Ayan Halder , "Oscar Zhang (Arm Technology China)" , "Tiannan Zhu (Arm Technology China)" , Mihail Atanassov , "Jonathan Chai (Arm Technology China)" , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "Julien Yin (Arm Technology China)" , "Channing Chen (Arm Technology China)" , "Yiqi Kang (Arm Technology China)" , "Thomas Sun (Arm Technology China)" , "Lowry Li (Arm Technology China)" , Ben Davis References: <20191011054240.17782-1-james.qian.wang@arm.com> <20191011054240.17782-2-james.qian.wang@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191011054240.17782-2-james.qian.wang@arm.com> X-Operating-System: Linux phenom 5.2.0-2-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 Fri, Oct 11, 2019 at 05:43:09AM +0000, james qian wang (Arm Technology China) wrote: > Add a new helper function drm_color_ctm_s31_32_to_qm_n() for driver to > convert S31.32 sign-magnitude to Qm.n 2's complement that supported by > hardware. > > Signed-off-by: james qian wang (Arm Technology China) > --- > drivers/gpu/drm/drm_color_mgmt.c | 23 +++++++++++++++++++++++ > include/drm/drm_color_mgmt.h | 2 ++ > 2 files changed, 25 insertions(+) > > diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c > index 4ce5c6d8de99..3d533d0b45af 100644 > --- a/drivers/gpu/drm/drm_color_mgmt.c > +++ b/drivers/gpu/drm/drm_color_mgmt.c > @@ -132,6 +132,29 @@ uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision) > } > EXPORT_SYMBOL(drm_color_lut_extract); > > +/** > + * drm_color_ctm_s31_32_to_qm_n > + * > + * @user_input: input value > + * @m: number of integer bits > + * @n: number of fractinal bits > + * > + * Convert and clamp S31.32 sign-magnitude to Qm.n 2's complement. What's the Q meaning here? Also maybe specify that the higher bits above m+n are cleared to all 0 or all 1. Unit test would be lovely too. Anyway: Reviewed-by: Daniel Vetter > + */ > +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] */ > + val = clamp_val(mag, 0, negative ? BIT(n + m) : BIT(n + m) - 1); > + > + return negative ? 0ll - val : val; > +} > +EXPORT_SYMBOL(drm_color_ctm_s31_32_to_qm_n); > + > /** > * drm_crtc_enable_color_mgmt - enable color management properties > * @crtc: DRM CRTC > diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h > index d1c662d92ab7..60fea5501886 100644 > --- a/include/drm/drm_color_mgmt.h > +++ b/include/drm/drm_color_mgmt.h > @@ -30,6 +30,8 @@ struct drm_crtc; > struct drm_plane; > > uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision); > +uint64_t drm_color_ctm_s31_32_to_qm_n(uint64_t user_input, > + uint32_t m, uint32_t n); > > void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, > uint degamma_lut_size, > -- > 2.20.1 > > _______________________________________________ > 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