Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Jani Nikula <jani.nikula@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915: abstract and document register picking macros
Date: Fri, 29 Jun 2018 07:38:39 -0700	[thread overview]
Message-ID: <20180629143839.GE5309@intel.com> (raw)
In-Reply-To: <20180629102039.2435-1-jani.nikula@intel.com>

On Fri, Jun 29, 2018 at 01:20:39PM +0300, Jani Nikula wrote:
> Try to describe what the pick variants do, and which to prefer. No
> functional changes.
> 
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

> 
> ---
> 
> Let the naming bikeshed fest begin!
> ---
>  drivers/gpu/drm/i915/i915_reg.h | 28 ++++++++++++++++++++++------
>  1 file changed, 22 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> index c30cfcd90754..7dc774682922 100644
> --- a/drivers/gpu/drm/i915/i915_reg.h
> +++ b/drivers/gpu/drm/i915/i915_reg.h
> @@ -139,19 +139,35 @@ static inline bool i915_mmio_reg_valid(i915_reg_t reg)
>  	return !i915_mmio_reg_equal(reg, INVALID_MMIO_REG);
>  }
>  
> +/*
> + * Given the first two numbers __a and __b of arbitrarily many evenly spaced
> + * numbers, pick the 0-based __index'th value.
> + *
> + * Always prefer this over _PICK() if the numbers are evenly spaced.
> + */
> +#define _PICK_EVEN(__index, __a, __b) ((__a) + (__index) * ((__b) - (__a)))
> +
> +/*
> + * Given the arbitrary numbers in varargs, pick the 0-based __index'th number.
> + *
> + * Always prefer _PICK_EVEN() over this if the numbers are evenly spaced.
> + */
>  #define _PICK(__index, ...) (((const u32 []){ __VA_ARGS__ })[__index])
>  
> -#define _PIPE(pipe, a, b) ((a) + (pipe) * ((b) - (a)))
> +/*
> + * Named helper wrappers around _PICK_EVEN() and _PICK().
> + */
> +#define _PIPE(pipe, a, b) _PICK_EVEN(pipe, a, b)
>  #define _MMIO_PIPE(pipe, a, b) _MMIO(_PIPE(pipe, a, b))
> -#define _PLANE(plane, a, b) _PIPE(plane, a, b)
> +#define _PLANE(plane, a, b) _PICK_EVEN(plane, a, b)
>  #define _MMIO_PLANE(plane, a, b) _MMIO_PIPE(plane, a, b)
> -#define _TRANS(tran, a, b) ((a) + (tran) * ((b) - (a)))
> +#define _TRANS(tran, a, b) _PICK_EVEN(tran, a, b)
>  #define _MMIO_TRANS(tran, a, b) _MMIO(_TRANS(tran, a, b))
> -#define _PORT(port, a, b) ((a) + (port) * ((b) - (a)))
> +#define _PORT(port, a, b) _PICK_EVEN(port, a, b)
>  #define _MMIO_PORT(port, a, b) _MMIO(_PORT(port, a, b))
>  #define _MMIO_PIPE3(pipe, a, b, c) _MMIO(_PICK(pipe, a, b, c))
>  #define _MMIO_PORT3(pipe, a, b, c) _MMIO(_PICK(pipe, a, b, c))
> -#define _PLL(pll, a, b) ((a) + (pll) * ((b) - (a)))
> +#define _PLL(pll, a, b) _PICK_EVEN(pll, a, b)
>  #define _MMIO_PLL(pll, a, b) _MMIO(_PLL(pll, a, b))
>  #define _PHY3(phy, ...) _PICK(phy, __VA_ARGS__)
>  #define _MMIO_PHY3(phy, a, b, c) _MMIO(_PHY3(phy, a, b, c))
> @@ -6874,7 +6890,7 @@ enum {
>  #define _PS_ECC_STAT_2B     0x68AD0
>  #define _PS_ECC_STAT_1C     0x691D0
>  
> -#define _ID(id, a, b) ((a) + (id) * ((b) - (a)))
> +#define _ID(id, a, b) _PICK_EVEN(id, a, b)
>  #define SKL_PS_CTRL(pipe, id) _MMIO_PIPE(pipe,        \
>  			_ID(id, _PS_1A_CTRL, _PS_2A_CTRL),       \
>  			_ID(id, _PS_1B_CTRL, _PS_2B_CTRL))
> -- 
> 2.11.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2018-06-29 14:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-29 10:20 [PATCH] drm/i915: abstract and document register picking macros Jani Nikula
2018-06-29 10:31 ` ✗ Fi.CI.CHECKPATCH: warning for " Patchwork
2018-06-29 10:51 ` ✓ Fi.CI.BAT: success " Patchwork
2018-06-29 14:09 ` ✓ Fi.CI.IGT: " Patchwork
2018-06-29 14:38 ` Rodrigo Vivi [this message]
2018-07-02 14:44   ` [PATCH] " Jani Nikula

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=20180629143839.GE5309@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@intel.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