From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A82EDC4320E for ; Wed, 1 Sep 2021 18:13:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D403610A4 for ; Wed, 1 Sep 2021 18:13:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344396AbhIASOV (ORCPT ); Wed, 1 Sep 2021 14:14:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232459AbhIASOU (ORCPT ); Wed, 1 Sep 2021 14:14:20 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDE2AC061575 for ; Wed, 1 Sep 2021 11:13:22 -0700 (PDT) Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 98EFA559; Wed, 1 Sep 2021 20:13:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1630520000; bh=BDl0EmauITqkvN6b/L6wjyoZWA3yqKvMu0HJWSPXVEU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ucoRfpQEdOL5uWiJHPl4jRLJICaNAL5SCAJcbYTw57fqz6f46uYHeDfj1y/scMT25 wijEhCS5NbSCTmWwQB44Jf1aPl7ADNgmaqlr6CVpNDLt5XVCxwDJo8rkGYgnpChKr8 NxkykMaOVW8YiPowN9atrwmqi+FyI5NJjXJGKXMc= Date: Wed, 1 Sep 2021 21:13:04 +0300 From: Laurent Pinchart To: Alyssa Rosenzweig Cc: dri-devel@lists.freedesktop.org, Neil Armstrong , David Airlie , Daniel Vetter , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Rob Clark , Sean Paul , Sandy Huang , Heiko =?utf-8?Q?St=C3=BCbner?= , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Abhinav Kumar , Dmitry Baryshkov , Lee Jones , Stephen Boyd , Kalyan Thota , Ville =?utf-8?B?U3lyasOkbMOk?= , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/5] drm: Add drm_fixed_16_16 helper Message-ID: References: <20210901175431.14060-1-alyssa@rosenzweig.io> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210901175431.14060-1-alyssa@rosenzweig.io> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Alyssa, Thank you for the patch. On Wed, Sep 01, 2021 at 01:54:27PM -0400, Alyssa Rosenzweig wrote: > This constructs a fixed 16.16 rational, useful to specify the minimum > and maximum scaling in drm_atomic_helper_check_plane_state. It is > open-coded as a macro in multiple drivers, so let's share the helper. > > Signed-off-by: Alyssa Rosenzweig > --- > include/drm/drm_fixed.h | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/include/drm/drm_fixed.h b/include/drm/drm_fixed.h > index 553210c02ee0..df1f369b4918 100644 > --- a/include/drm/drm_fixed.h > +++ b/include/drm/drm_fixed.h > @@ -208,4 +208,9 @@ static inline s64 drm_fixp_exp(s64 x) > return sum; > } > Missing documentation :-) > +static inline int drm_fixed_16_16(s32 mult, s32 div) You should return a s32. The function name isn't very explicit, and departs from the naming scheme of other functions in the same file. As fixed-point numbers are stored in a s64 for the drm_fixp_* helpers, we shouldn't rese the drm_fixp_ prefix, maybe drm_fixp_s16_16_ would be a good prefix. The function should probably be named drm_fixp_s16_16 from_fraction() then, but then the same logic should possibly be replicated to ensure optimal precision. I wonder if it wouldn't be best to simply use drm_fixp_from_fraction() and shift the result right by 16 bits. > +{ > + return (mult << 16) / div; > +} > + > #endif -- Regards, Laurent Pinchart