From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Philipp Zabel <p.zabel@pengutronix.de>
Cc: kernel@pengutronix.de, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 2/7] drm/simple_kms_helper: add drmm_simple_encoder_alloc()
Date: Sat, 5 Dec 2020 20:58:29 +0200 [thread overview]
Message-ID: <X8vYVeD/1j7oAyph@pendragon.ideasonboard.com> (raw)
In-Reply-To: <e1fa81a821ee6e5c296cc0e89d9d90a28534b79a.camel@pengutronix.de>
Hi Philipp,
On Fri, Dec 04, 2020 at 11:13:33AM +0100, Philipp Zabel wrote:
> On Fri, 2020-12-04 at 11:19 +0200, Laurent Pinchart wrote:
> > On Fri, Sep 11, 2020 at 03:57:19PM +0200, 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>
> > > ---
> > > drivers/gpu/drm/drm_simple_kms_helper.c | 12 ++++++++++++
> > > include/drm/drm_simple_kms_helper.h | 24 ++++++++++++++++++++++++
> > > 2 files changed, 36 insertions(+)
> > >
> > > diff --git a/drivers/gpu/drm/drm_simple_kms_helper.c b/drivers/gpu/drm/drm_simple_kms_helper.c
> > > index 74946690aba4..3cbbfb0f9b51 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,17 @@ int drm_simple_encoder_init(struct drm_device *dev,
> > > }
> > > EXPORT_SYMBOL(drm_simple_encoder_init);
> > >
> > > +static const struct drm_encoder_funcs drmm_simple_encoder_funcs_empty = { };
> > > +
> > > +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,
> > > + &drmm_simple_encoder_funcs_empty,
> > > + encoder_type, NULL);
> > > +}
> > > +EXPORT_SYMBOL(__drmm_simple_encoder_alloc);
> >
> > Do we need this ? Wouldn't it be better support a NULL drm_encoder_funcs
> > in the core (if we don't already) and use drmm_encoder_alloc() directly
> > in drivers ?
>
> I could change it to remove the empty drm_encoder_funcs, and prepend
> something like this:
>
> ----------8<----------
> From 12147d90a8ae48dabc16ca8750fa0f629cc46570 Mon Sep 17 00:00:00 2001
> From: Philipp Zabel <p.zabel@pengutronix.de>
> Date: Fri, 4 Dec 2020 10:49:41 +0100
> Subject: [PATCH] drm/encoder: make encoder control functions optional
>
> Simple managed encoders do not require the .destroy callback,
> make the whole funcs structure optional.
>
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
That's perfect.
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> drivers/gpu/drm/drm_encoder.c | 4 ++--
> drivers/gpu/drm/drm_mode_config.c | 5 +++--
> include/drm/drm_encoder.h | 2 +-
> 3 files changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_encoder.c b/drivers/gpu/drm/drm_encoder.c
> index e555281f43d4..b0b86a3c08f5 100644
> --- a/drivers/gpu/drm/drm_encoder.c
> +++ b/drivers/gpu/drm/drm_encoder.c
> @@ -72,7 +72,7 @@ int drm_encoder_register_all(struct drm_device *dev)
> int ret = 0;
>
> drm_for_each_encoder(encoder, dev) {
> - if (encoder->funcs->late_register)
> + if (encoder->funcs && encoder->funcs->late_register)
> ret = encoder->funcs->late_register(encoder);
> if (ret)
> return ret;
> @@ -86,7 +86,7 @@ void drm_encoder_unregister_all(struct drm_device *dev)
> struct drm_encoder *encoder;
>
> drm_for_each_encoder(encoder, dev) {
> - if (encoder->funcs->early_unregister)
> + if (encoder->funcs && encoder->funcs->early_unregister)
> encoder->funcs->early_unregister(encoder);
> }
> }
> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> index f1affc1bb679..87e144155456 100644
> --- a/drivers/gpu/drm/drm_mode_config.c
> +++ b/drivers/gpu/drm/drm_mode_config.c
> @@ -195,7 +195,7 @@ void drm_mode_config_reset(struct drm_device *dev)
> crtc->funcs->reset(crtc);
>
> drm_for_each_encoder(encoder, dev)
> - if (encoder->funcs->reset)
> + if (encoder->funcs && encoder->funcs->reset)
> encoder->funcs->reset(encoder);
>
> drm_connector_list_iter_begin(dev, &conn_iter);
> @@ -487,7 +487,8 @@ void drm_mode_config_cleanup(struct drm_device *dev)
>
> list_for_each_entry_safe(encoder, enct, &dev->mode_config.encoder_list,
> head) {
> - encoder->funcs->destroy(encoder);
> + if (encoder->funcs)
> + encoder->funcs->destroy(encoder);
> }
>
> drm_connector_list_iter_begin(dev, &conn_iter);
> diff --git a/include/drm/drm_encoder.h b/include/drm/drm_encoder.h
> index 5dfa5f7a80a7..833123637fbf 100644
> --- a/include/drm/drm_encoder.h
> +++ b/include/drm/drm_encoder.h
> @@ -89,7 +89,7 @@ struct drm_encoder_funcs {
> * @head: list management
> * @base: base KMS object
> * @name: human readable name, can be overwritten by the driver
> - * @funcs: control functions
> + * @funcs: control functions, can be NULL for simple managed encoders
> * @helper_private: mid-layer private data
> *
> * CRTCs drive pixels to encoders, which convert them into signals
--
Regards,
Laurent Pinchart
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2020-12-05 18:58 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-11 13:57 [PATCH v3 1/7] drm: add drmm_encoder_alloc() Philipp Zabel
2020-09-11 13:57 ` [PATCH v3 2/7] drm/simple_kms_helper: add drmm_simple_encoder_alloc() Philipp Zabel
2020-12-04 9:19 ` Laurent Pinchart
2020-12-04 10:13 ` Philipp Zabel
2020-12-05 18:58 ` Laurent Pinchart [this message]
2020-09-11 13:57 ` [PATCH v3 3/7] drm/plane: add drmm_universal_plane_alloc() Philipp Zabel
2020-12-04 9:22 ` Laurent Pinchart
2020-09-11 13:57 ` [PATCH v3 4/7] drm/crtc: add drmm_crtc_alloc_with_planes() Philipp Zabel
2020-12-04 9:23 ` Laurent Pinchart
2020-09-11 13:57 ` [PATCH v3 5/7] drm/imx: use drmm_simple_encoder_alloc() Philipp Zabel
2020-09-16 9:08 ` Daniel Vetter
2020-09-16 10:22 ` Philipp Zabel
2020-09-11 13:57 ` [PATCH v3 6/7] drm/imx: use drmm_universal_plane_alloc() Philipp Zabel
2020-09-11 13:57 ` [PATCH v3 7/7] drm/imx: ipuv3-crtc: use drmm_crtc_alloc_with_planes() Philipp Zabel
2020-12-04 9:17 ` [PATCH v3 1/7] drm: add drmm_encoder_alloc() Laurent Pinchart
2020-12-04 10:12 ` Philipp Zabel
2020-12-05 18:57 ` Laurent Pinchart
2020-12-09 0:22 ` Daniel Vetter
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=X8vYVeD/1j7oAyph@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel@pengutronix.de \
--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