From: Jani Nikula <jani.nikula@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Subject: Re: [PATCH 5/7] drm/i915: add _PICK macro for the "a + index * (b - a)" macros
Date: Thu, 15 Jun 2017 23:26:06 +0300 [thread overview]
Message-ID: <8737b1xajl.fsf@intel.com> (raw)
In-Reply-To: <20170613193350.10528-6-paulo.r.zanoni@intel.com>
On Tue, 13 Jun 2017, Paulo Zanoni <paulo.r.zanoni@intel.com> wrote:
> Instead of duplicating the macro everywhere, add a single definition
> for it and call it just like we do with the _PICK3 macros.
>
> Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
> ---
> drivers/gpu/drm/i915/i915_reg.h | 15 ++++++++-------
> 1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> index d271098..3e46ba1 100644
> --- a/drivers/gpu/drm/i915/i915_reg.h
> +++ b/drivers/gpu/drm/i915/i915_reg.h
> @@ -48,25 +48,26 @@ static inline bool i915_mmio_reg_valid(i915_reg_t reg)
> return !i915_mmio_reg_equal(reg, INVALID_MMIO_REG);
> }
>
> +#define _PICK(__index, a, b) ((a) + (__index) * ((b) - (a)))
The change overall is good but I'd name this in a way that emphasizes
the registers are evenly spaced. _LINEAR?
BR,
Jani.
> #define _PICK3(__index, ...) (((const u32 []){ __VA_ARGS__ })[__index])
>
> -#define _PIPE(pipe, a, b) ((a) + (pipe)*((b)-(a)))
> +#define _PIPE(pipe, a, b) _PICK(pipe, a, b)
> #define _MMIO_PIPE(pipe, a, b) _MMIO(_PIPE(pipe, a, b))
> #define _MMIO_PIPE3(pipe, ...) _MMIO(_PICK3(pipe, __VA_ARGS__))
>
> -#define _PLANE(plane, a, b) _PIPE(plane, a, b)
> -#define _MMIO_PLANE(plane, a, b) _MMIO_PIPE(plane, a, b)
> +#define _PLANE(plane, a, b) _PICK(plane, a, b)
> +#define _MMIO_PLANE(plane, a, b) _MMIO(_PLANE(plane, a, b))
>
> -#define _TRANS(tran, a, b) ((a) + (tran)*((b)-(a)))
> +#define _TRANS(tran, a, b) _PICK(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(port, a, b)
> #define _MMIO_PORT(port, a, b) _MMIO(_PORT(port, a, b))
> #define _MMIO_PORT3(port, ...) _MMIO(_PICK3(port, __VA_ARGS__))
> #define _MMIO_PORT3_LN(port, ln, a0, a1, b, c, d, e, f) \
> _MMIO(_PICK3(port, a0, b, c, d, e, f) + (ln * (a1 - a0)))
>
> -#define _PLL(pll, a, b) ((a) + (pll)*((b)-(a)))
> +#define _PLL(pll, a, b) _PICK(pll, a, b)
> #define _MMIO_PLL(pll, a, b) _MMIO(_PLL(pll, a, b))
>
> #define _PHY3(phy, ...) _PICK3(phy, __VA_ARGS__)
> @@ -6415,7 +6416,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(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))
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2017-06-15 20:26 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-13 19:33 [PATCH 0/7] Reorganize the register picking macros Paulo Zanoni
2017-06-13 19:33 ` [PATCH 1/7] drm/i915: reorder " Paulo Zanoni
2017-06-14 17:22 ` Rodrigo Vivi
2017-06-13 19:33 ` [PATCH 2/7] drm/i915: _MMIO_PORT3 takes a port as an argument Paulo Zanoni
2017-06-14 17:23 ` Rodrigo Vivi
2017-06-13 19:33 ` [PATCH 3/7] drm/i915: use variable arguments for the macros that call _PICK Paulo Zanoni
2017-06-14 17:25 ` Rodrigo Vivi
2017-06-13 19:33 ` [PATCH 4/7] drm/i915: rename _PICK to _PICK3 Paulo Zanoni
2017-06-15 20:22 ` Jani Nikula
2017-06-13 19:33 ` [PATCH 5/7] drm/i915: add _PICK macro for the "a + index * (b - a)" macros Paulo Zanoni
2017-06-15 20:26 ` Jani Nikula [this message]
2017-06-19 10:14 ` Chauhan, Madhav
2017-06-13 19:33 ` [PATCH 6/7] drm/i915: also move version 2 of the register picking macros up Paulo Zanoni
2017-06-15 20:37 ` Jani Nikula
2017-06-13 19:33 ` [PATCH 7/7] drm/i915: extract a _PICK2 macro Paulo Zanoni
2017-06-14 15:16 ` Ville Syrjälä
2017-06-14 17:34 ` Paulo Zanoni
2017-06-14 17:38 ` Rodrigo Vivi
2017-06-15 20:33 ` Jani Nikula
2017-06-13 19:49 ` ✓ Fi.CI.BAT: success for Reorganize the register picking macros 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=8737b1xajl.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=paulo.r.zanoni@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 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.