dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Philipp Zabel <p.zabel@pengutronix.de>
Cc: kernel@pengutronix.de, dri-devel@lists.freedesktop.org,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Subject: Re: [PATCH v4 03/19] drm/simple_kms_helper: add drmm_simple_encoder_alloc()
Date: Wed, 9 Dec 2020 21:04:12 +0100	[thread overview]
Message-ID: <20201209200412.GX401619@phenom.ffwll.local> (raw)
In-Reply-To: <20201208155451.8421-4-p.zabel@pengutronix.de>

On Tue, Dec 08, 2020 at 04:54:35PM +0100, Philipp Zabel wrote:
> Add an alternative to drm_simple_encoder_init() that allocates and
> initializes a simple encoder and registers drm_encoder_cleanup() with
> drmm_add_action_or_reset().
> 
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> Changes since v3:
>  - drop drmm_simple_encoder_funcs_empty, now that encoder control
>    functions are optional
> ---
>  drivers/gpu/drm/drm_simple_kms_helper.c |  9 +++++++++
>  include/drm/drm_simple_kms_helper.h     | 24 ++++++++++++++++++++++++
>  2 files changed, 33 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_simple_kms_helper.c b/drivers/gpu/drm/drm_simple_kms_helper.c
> index 743e57c1b44f..ccf0908eb82e 100644
> --- a/drivers/gpu/drm/drm_simple_kms_helper.c
> +++ b/drivers/gpu/drm/drm_simple_kms_helper.c
> @@ -9,6 +9,7 @@
>  #include <drm/drm_atomic.h>
>  #include <drm/drm_atomic_helper.h>
>  #include <drm/drm_bridge.h>
> +#include <drm/drm_managed.h>
>  #include <drm/drm_plane_helper.h>
>  #include <drm/drm_probe_helper.h>
>  #include <drm/drm_simple_kms_helper.h>
> @@ -71,6 +72,14 @@ int drm_simple_encoder_init(struct drm_device *dev,

Please also address the FIXME in the kerneldoc for drm_simple_encoder_init
and replace it with a recommendation to use this new function you're
adding here.

>  }
>  EXPORT_SYMBOL(drm_simple_encoder_init);
>  
> +void *__drmm_simple_encoder_alloc(struct drm_device *dev, size_t size,
> +				  size_t offset, int encoder_type)
> +{
> +	return __drmm_encoder_alloc(dev, size, offset, NULL, encoder_type,
> +				    NULL);
> +}
> +EXPORT_SYMBOL(__drmm_simple_encoder_alloc);
> +
>  static enum drm_mode_status
>  drm_simple_kms_crtc_mode_valid(struct drm_crtc *crtc,
>  			       const struct drm_display_mode *mode)
> diff --git a/include/drm/drm_simple_kms_helper.h b/include/drm/drm_simple_kms_helper.h
> index a026375464ff..e6dbf3161c2f 100644
> --- a/include/drm/drm_simple_kms_helper.h
> +++ b/include/drm/drm_simple_kms_helper.h
> @@ -185,4 +185,28 @@ int drm_simple_encoder_init(struct drm_device *dev,
>  			    struct drm_encoder *encoder,
>  			    int encoder_type);
>  
> +void *__drmm_simple_encoder_alloc(struct drm_device *dev, size_t size,
> +				  size_t offset, int encoder_type);
> +
> +/**
> + * drmm_simple_encoder_alloc - Allocate and initialize an encoder with basic
> + *                             functionality.
> + * @dev: drm device
> + * @type: the type of the struct which contains struct &drm_encoder
> + * @member: the name of the &drm_encoder within @type.
> + * @encoder_type: user visible type of the encoder
> + *
> + * Allocates and initializes an encoder that has no further functionality.
> + * Settings for possible CRTC and clones are left to their initial values.
> + * Cleanup is automatically handled through registering drm_encoder_cleanup()
> + * with drmm_add_action().
> + *
> + * Returns:
> + * Pointer to new encoder, or ERR_PTR on failure.
> + */
> +#define drmm_simple_encoder_alloc(dev, type, member, encoder_type) \
> +	((type *)__drmm_simple_encoder_alloc(dev, sizeof(type), \

Same comment about container_of. Also, since this is a dummy encoder, do
we really need the subclassing support here? I guess it makes sense for
consistency at least, which is always good.

With the nits addressed:

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> +					     offsetof(type, member), \
> +					     encoder_type))
> +
>  #endif /* __LINUX_DRM_SIMPLE_KMS_HELPER_H */
> -- 
> 2.20.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2020-12-09 20:04 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-08 15:54 [PATCH v4 00/19] drm: managed encoder/plane/crtc allocation Philipp Zabel
2020-12-08 15:54 ` [PATCH v4 01/19] drm/encoder: make encoder control functions optional Philipp Zabel
2020-12-08 18:48   ` Sam Ravnborg
2020-12-09 10:58     ` Philipp Zabel
2020-12-09 15:58       ` Daniel Vetter
2020-12-09 15:59         ` Daniel Vetter
2020-12-08 15:54 ` [PATCH v4 02/19] drm: add drmm_encoder_alloc() Philipp Zabel
2020-12-09 16:05   ` Daniel Vetter
2020-12-10 11:59     ` Philipp Zabel
2020-12-10 13:13       ` Daniel Vetter
2020-12-08 15:54 ` [PATCH v4 03/19] drm/simple_kms_helper: add drmm_simple_encoder_alloc() Philipp Zabel
2020-12-09 20:04   ` Daniel Vetter [this message]
2020-12-08 15:54 ` [PATCH v4 04/19] drm/plane: add drmm_universal_plane_alloc() Philipp Zabel
2020-12-09 20:08   ` Daniel Vetter
2020-12-08 15:54 ` [PATCH v4 05/19] drm/crtc: add drmm_crtc_alloc_with_planes() Philipp Zabel
2020-12-09 20:21   ` Daniel Vetter
2020-12-08 15:54 ` [PATCH v4 06/19] drm/imx: dw_hdmi-imx: move initialization into probe Philipp Zabel
2020-12-08 15:54 ` [PATCH v4 07/19] drm/imx: imx-ldb: use local connector variable Philipp Zabel
2020-12-08 15:54 ` [PATCH v4 08/19] drm/imx: imx-ldb: move initialization into probe Philipp Zabel
2020-12-08 15:54 ` [PATCH v4 09/19] drm/imx: imx-tve: use local encoder and connector variables Philipp Zabel
2020-12-08 15:54 ` [PATCH v4 10/19] drm/imx: imx-tve: move initialization into probe Philipp Zabel
2020-12-08 15:54 ` [PATCH v4 11/19] drm/imx: imx-tve: use devm_clk_register Philipp Zabel
2020-12-08 15:54 ` [PATCH v4 12/19] drm/imx: parallel-display: use local bridge and connector variables Philipp Zabel
2020-12-08 15:54 ` [PATCH v4 13/19] drm/imx: parallel-display: move initialization into probe Philipp Zabel
2020-12-08 15:54 ` [PATCH v4 14/19] drm/imx: dw_hdmi-imx: use drm managed resources Philipp Zabel
2020-12-08 15:54 ` [PATCH v4 15/19] drm/imx: imx-ldb: " Philipp Zabel
2020-12-08 15:54 ` [PATCH v4 16/19] drm/imx: imx-tve: " Philipp Zabel
2020-12-08 15:54 ` [PATCH v4 17/19] drm/imx: parallel-display: " Philipp Zabel
2020-12-08 15:54 ` [PATCH v4 18/19] drm/imx: ipuv3-plane: " Philipp Zabel
2020-12-08 15:54 ` [PATCH v4 19/19] drm/imx: ipuv3-crtc: " Philipp Zabel
2020-12-08 15:59 ` [PATCH v4 00/19] drm: managed encoder/plane/crtc allocation Philipp Zabel
2020-12-09 21:10   ` Daniel Vetter
2020-12-09 21:13     ` Daniel Vetter
2020-12-10 12:19       ` Laurent Pinchart
2020-12-11 10:19         ` Philipp Zabel

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=20201209200412.GX401619@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel@pengutronix.de \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=p.zabel@pengutronix.de \
    /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