All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: imre.deak@intel.com
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/9] drm: Add helpers for x16 fixed point values
Date: Thu, 27 Jun 2024 18:41:46 +0300	[thread overview]
Message-ID: <875xtucs05.fsf@intel.com> (raw)
In-Reply-To: <ZnLIe+YFkDpMcXF7@ideak-desk.fi.intel.com>

On Wed, 19 Jun 2024, Imre Deak <imre.deak@intel.com> wrote:
> On Wed, Jun 19, 2024 at 01:10:09PM +0300, Jani Nikula wrote:
>> On Fri, 14 Jun 2024, Imre Deak <imre.deak@intel.com> wrote:
>> > Add helpers to convert between x16 fixed point and integer/fraction
>> > values. Also add the format/argument macros required to printk x16
>> > fixed point variables.
>> >
>> > These are needed by later patches dumping the Display Stream Compression
>> > configuration in DRM core and in the i915 driver to replace the
>> > corresponding bpp_x16 helpers defined locally in the driver.
>> >
>> > Signed-off-by: Imre Deak <imre.deak@intel.com>
>> > ---
>> >  drivers/gpu/drm/display/drm_dp_helper.c |  5 +++--
>> >  include/drm/drm_fixed.h                 | 23 +++++++++++++++++++++++
>> >  2 files changed, 26 insertions(+), 2 deletions(-)
>> >
>> > diff --git a/drivers/gpu/drm/display/drm_dp_helper.c b/drivers/gpu/drm/display/drm_dp_helper.c
>> > index 79a615667aab1..806f9c9764995 100644
>> > --- a/drivers/gpu/drm/display/drm_dp_helper.c
>> > +++ b/drivers/gpu/drm/display/drm_dp_helper.c
>> > @@ -35,6 +35,7 @@
>> >  #include <drm/display/drm_dp_helper.h>
>> >  #include <drm/display/drm_dp_mst_helper.h>
>> >  #include <drm/drm_edid.h>
>> > +#include <drm/drm_fixed.h>
>> >  #include <drm/drm_print.h>
>> >  #include <drm/drm_vblank.h>
>> >  #include <drm/drm_panel.h>
>> > @@ -4151,9 +4152,9 @@ int drm_dp_bw_overhead(int lane_count, int hactive,
>> >  	int symbol_cycles;
>> >  
>> >  	if (lane_count == 0 || hactive == 0 || bpp_x16 == 0) {
>> > -		DRM_DEBUG_KMS("Invalid BW overhead params: lane_count %d, hactive %d, bpp_x16 %d.%04d\n",
>> > +		DRM_DEBUG_KMS("Invalid BW overhead params: lane_count %d, hactive %d, bpp_x16 " DRM_X16_FMT "\n",
>> >  			      lane_count, hactive,
>> > -			      bpp_x16 >> 4, (bpp_x16 & 0xf) * 625);
>> > +			      DRM_X16_ARGS(bpp_x16));
>> >  		return 0;
>> >  	}
>> >  
>> > diff --git a/include/drm/drm_fixed.h b/include/drm/drm_fixed.h
>> > index 81572d32db0c2..0fe2a7f50d54e 100644
>> > --- a/include/drm/drm_fixed.h
>> > +++ b/include/drm/drm_fixed.h
>> > @@ -214,4 +214,27 @@ static inline s64 drm_fixp_exp(s64 x)
>> >  	return sum;
>> >  }
>> >  
>> > +static inline int drm_x16_from_int(int val_int)
>> > +{
>> > +	return val_int << 4;
>> > +}
>> > +
>> > +static inline int drm_x16_to_int(int val_x16)
>> > +{
>> > +	return val_x16 >> 4;
>> > +}
>> > +
>> > +static inline int drm_x16_to_int_roundup(int val_x16)
>> > +{
>> > +	return (val_x16 + 0xf) >> 4;
>> > +}
>> > +
>> > +static inline int drm_x16_to_frac(int val_x16)
>> > +{
>> > +	return val_x16 & 0xf;
>> > +}
>> 
>> Sad trombone about the completely different naming scheme compared to
>> the rest of the file.
>> 
>> Not saying the existing naming is great, but neither is this. And
>> there's no way to unify except by renaming *both* afterwards.
>> 
>> We could devise a scheme now that could be used for the existing stuff
>> later, without renaming the new stuff.
>
> Based on [1]'s short variant, we could have:
>
> dfixed*(fixed20_12 v)  -> drm_uq12*(drm_uq20_12_t v)
> drm_fixp*(s64 v)       -> drm_q32*(s64 v)
> drm_x16*(int v)        -> drm_q4*(int v)

I like it. If you're brave, add them with a generic prefix instead of
drm_ from the start, say fp_q4. ;)

BR,
Jani.

>
> Or instead of uq12/q32/q4 using ufp12/fp32/fp4.
>
> [1] https://en.wikipedia.org/wiki/Q_(number_format)
>
>> *shrug*
>> 
>> BR,
>> Jani.
>> 
>> 
>> 
>> > +
>> > +#define DRM_X16_FMT		"%d.%04d"
>> > +#define DRM_X16_ARGS(val_x16)	drm_x16_to_int(val_x16), (drm_x16_to_frac(val_x16) * 625)
>> > +
>> >  #endif
>> 
>> -- 
>> Jani Nikula, Intel

-- 
Jani Nikula, Intel

  parent reply	other threads:[~2024-06-27 15:41 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-14 17:39 [PATCH 0/9] drm/i915: Dump DSC state to dmesg/debugfs Imre Deak
2024-06-14 17:39 ` [PATCH 1/9] drm: Add helpers for x16 fixed point values Imre Deak
2024-06-19 10:10   ` Jani Nikula
2024-06-19 12:00     ` Imre Deak
2024-06-25 16:08       ` Imre Deak
2024-06-27 15:41       ` Jani Nikula [this message]
2024-06-28 14:09         ` Imre Deak
2024-06-14 17:39 ` [PATCH 2/9] drm/display/dsc: Add a helper to dump the DSC configuration Imre Deak
2024-06-14 17:39 ` [PATCH 3/9] drm/i915: Replace to_bpp_x16() with drm_x16_from_int() Imre Deak
2024-06-14 17:39 ` [PATCH 4/9] drm/i915: Replace to_bpp_int() with drm_x16_to_int() Imre Deak
2024-06-14 17:39 ` [PATCH 5/9] drm/i915: Replace to_bpp_int_roundup() with drm_x16_to_int_roundup() Imre Deak
2024-06-14 17:39 ` [PATCH 6/9] drm/i915: Replace to_bpp_frac() with drm_x16_to_frac() Imre Deak
2024-06-14 17:39 ` [PATCH 7/9] drm/i915: Replace BPP_X16_FMT()/ARGS() with DRM_X16_FMT()/ARGS() Imre Deak
2024-06-14 17:39 ` [PATCH 8/9] drm/i915: Dump DSC state to dmesg and debugfs/i915_display_info Imre Deak
2024-06-14 17:39 ` [PATCH 9/9] drm/i915: Remove DSC register dump Imre Deak
2024-06-14 19:07 ` ✗ Fi.CI.BUILD: warning for drm/i915: Dump DSC state to dmesg/debugfs Patchwork
2024-06-14 19:07 ` ✗ Fi.CI.CHECKPATCH: " Patchwork
2024-06-14 19:07 ` ✗ Fi.CI.SPARSE: " Patchwork
2024-06-14 19:27 ` ✓ Fi.CI.BAT: success " Patchwork
2024-06-17  7:59 ` ✗ Fi.CI.IGT: failure " Patchwork

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=875xtucs05.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=imre.deak@intel.com \
    --cc=intel-gfx@lists.freedesktop.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.