From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB8E9C433FE for ; Fri, 4 Dec 2020 09:19:47 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 48223225AB for ; Fri, 4 Dec 2020 09:19:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 48223225AB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 948A16E135; Fri, 4 Dec 2020 09:19:46 +0000 (UTC) Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by gabe.freedesktop.org (Postfix) with ESMTPS id D44756E135 for ; Fri, 4 Dec 2020 09:19:45 +0000 (UTC) Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 59F9599A; Fri, 4 Dec 2020 10:19:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1607073584; bh=WT8rjDRvI24mB14z16W9GZCi/3Wu8EJ+JvtfGRKYotY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ghPn6kbiuHqbfdsMPIkTVCWZCIn3/BtxYeKYYFhx21BmOKSUMeZjAz+70GCo9RwBI zzPfFd6tK0VnvpybanHuYxU4W65HZGS3a524kF1LDjzXo1AU0MbfwJGEdcxTcpCBx0 0WnUe4Ih/0jKEUE/P01Kgu6lpNXtlF0ofID90YeM= Date: Fri, 4 Dec 2020 11:19:43 +0200 From: Laurent Pinchart To: Philipp Zabel Subject: Re: [PATCH v3 2/7] drm/simple_kms_helper: add drmm_simple_encoder_alloc() Message-ID: <20201204091943.GE4109@pendragon.ideasonboard.com> References: <20200911135724.25833-1-p.zabel@pengutronix.de> <20200911135724.25833-2-p.zabel@pengutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200911135724.25833-2-p.zabel@pengutronix.de> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kernel@pengutronix.de, dri-devel@lists.freedesktop.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hi Philipp, Thank you for the patch. 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 > --- > 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 > #include > #include > +#include > #include > #include > #include > @@ -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 ? > + > 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), \ > + offsetof(type, member), \ > + encoder_type)) > + > #endif /* __LINUX_DRM_SIMPLE_KMS_HELPER_H */ -- Regards, Laurent Pinchart _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel