From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Jani Nikula <jani.nikula@intel.com>
Cc: <intel-gfx@lists.freedesktop.org>,
<intel-xe@lists.freedesktop.org>, <lucas.demarchi@intel.com>,
<ville.syrjala@linux.intel.com>,
<joonas.lahtinen@linux.intel.com>, <tursulin@ursulin.net>
Subject: Re: [PATCH v3 2/7] drm/i915/display: add generic to_intel_display() macro
Date: Tue, 16 Apr 2024 12:06:38 -0400 [thread overview]
Message-ID: <Zh6iDvIMmmB3lcHV@intel.com> (raw)
In-Reply-To: <11bb764f479cd3638f0701d4466ae47dfd8def81.1712665176.git.jani.nikula@intel.com>
On Tue, Apr 09, 2024 at 03:26:44PM +0300, Jani Nikula wrote:
> Convert various pointers to struct intel_display * using _Generic().
>
> Add some macro magic to make adding new conversions easier, and somewhat
> abstract the need to cast each generic association. The cast is required
> because all associations needs to compile, regardless of the type and
> the generic selection.
>
> The use of *p in the generic selection assignment expression removes the
> need to add separate associations for const pointers.
>
> Note: This intentionally does *not* cover struct drm_i915_private or
> struct xe_device. They are not to be used in the long run, so avoid
> using this macro for them.
>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
I also missed this. This magic is great, let move with this already
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> ---
> .../drm/i915/display/intel_display_types.h | 37 +++++++++++++++++++
> 1 file changed, 37 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
> index 0f4bd5710796..1be98c4219b0 100644
> --- a/drivers/gpu/drm/i915/display/intel_display_types.h
> +++ b/drivers/gpu/drm/i915/display/intel_display_types.h
> @@ -2197,4 +2197,41 @@ static inline int to_bpp_x16(int bpp)
> return bpp << 4;
> }
>
> +/*
> + * Conversion functions/macros from various pointer types to struct
> + * intel_display pointer.
> + */
> +#define __drm_device_to_intel_display(p) \
> + (&to_i915(p)->display)
> +#define __intel_connector_to_intel_display(p) \
> + __drm_device_to_intel_display((p)->base.dev)
> +#define __intel_crtc_to_intel_display(p) \
> + __drm_device_to_intel_display((p)->base.dev)
> +#define __intel_crtc_state_to_intel_display(p) \
> + __drm_device_to_intel_display((p)->uapi.crtc->dev)
> +#define __intel_digital_port_to_intel_display(p) \
> + __drm_device_to_intel_display((p)->base.base.dev)
> +#define __intel_dp_to_intel_display(p) \
> + __drm_device_to_intel_display(dp_to_dig_port(p)->base.base.dev)
> +#define __intel_encoder_to_intel_display(p) \
> + __drm_device_to_intel_display((p)->base.dev)
> +#define __intel_hdmi_to_intel_display(p) \
> + __drm_device_to_intel_display(hdmi_to_dig_port(p)->base.base.dev)
> +
> +/* Helper for generic association. Map types to conversion functions/macros. */
> +#define __assoc(type, p) \
> + struct type: __##type##_to_intel_display((struct type *)(p))
> +
> +/* Convert various pointer types to struct intel_display pointer. */
> +#define to_intel_display(p) \
> + _Generic(*p, \
> + __assoc(drm_device, p), \
> + __assoc(intel_connector, p), \
> + __assoc(intel_crtc, p), \
> + __assoc(intel_crtc_state, p), \
> + __assoc(intel_digital_port, p), \
> + __assoc(intel_dp, p), \
> + __assoc(intel_encoder, p), \
> + __assoc(intel_hdmi, p))
> +
> #endif /* __INTEL_DISPLAY_TYPES_H__ */
> --
> 2.39.2
>
next prev parent reply other threads:[~2024-04-16 16:07 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-09 12:26 [PATCH v3 0/7] drm/i915: better high level abstraction for display Jani Nikula
2024-04-09 12:26 ` [PATCH v3 1/7] drm/i915/display: add intel_display -> drm_device backpointer Jani Nikula
2024-04-16 16:05 ` Rodrigo Vivi
2024-04-09 12:26 ` [PATCH v3 2/7] drm/i915/display: add generic to_intel_display() macro Jani Nikula
2024-04-16 16:06 ` Rodrigo Vivi [this message]
2024-04-09 12:26 ` [PATCH v3 3/7] drm/i915: add generic __to_intel_display() Jani Nikula
2024-04-16 16:08 ` Rodrigo Vivi
2024-04-09 12:26 ` [PATCH v3 4/7] drm/xe/display: " Jani Nikula
2024-04-16 16:10 ` Rodrigo Vivi
2024-04-17 9:53 ` Jani Nikula
2024-04-17 13:04 ` Jani Nikula
2024-04-09 12:26 ` [PATCH v3 5/7] drm/i915/display: accept either i915 or display for feature tests Jani Nikula
2024-04-16 16:14 ` Rodrigo Vivi
2024-04-17 13:05 ` Jani Nikula
2024-04-09 12:26 ` [PATCH v3 6/7] drm/i915/de: allow intel_display and drm_i915_private for de functions Jani Nikula
2024-04-16 16:16 ` Rodrigo Vivi
2024-04-17 13:05 ` Jani Nikula
2024-04-09 12:26 ` [PATCH v3 7/7] drm/i915/quirks: convert struct drm_i915_private to struct intel_display Jani Nikula
2024-04-16 16:17 ` Rodrigo Vivi
2024-04-09 12:42 ` ✓ CI.Patch_applied: success for drm/i915: better high level abstraction for display (rev2) Patchwork
2024-04-09 12:42 ` ✗ CI.checkpatch: warning " Patchwork
2024-04-09 12:43 ` ✓ CI.KUnit: success " Patchwork
2024-04-09 12:55 ` ✓ CI.Build: " Patchwork
2024-04-09 12:58 ` ✓ CI.Hooks: " Patchwork
2024-04-09 12:59 ` ✗ CI.checksparse: warning " Patchwork
2024-04-09 13:26 ` ✓ CI.BAT: success " Patchwork
2024-04-09 15:26 ` ✓ CI.FULL: " Patchwork
2024-04-16 16:24 ` [PATCH v3 0/7] drm/i915: better high level abstraction for display Rodrigo Vivi
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=Zh6iDvIMmmB3lcHV@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=jani.nikula@intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=lucas.demarchi@intel.com \
--cc=tursulin@ursulin.net \
--cc=ville.syrjala@linux.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;
as well as URLs for NNTP newsgroup(s).