From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Vetter Subject: Re: [PATCHv4 10/13] drm: Add drm_crtc_init_with_planes() Date: Fri, 28 Mar 2014 18:56:43 +0100 Message-ID: <20140328175643.GL22327@phenom.ffwll.local> References: <1395967478-30549-1-git-send-email-matthew.d.roper@intel.com> <1395967478-30549-11-git-send-email-matthew.d.roper@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-ee0-f44.google.com (mail-ee0-f44.google.com [74.125.83.44]) by gabe.freedesktop.org (Postfix) with ESMTP id B126E6ED80 for ; Fri, 28 Mar 2014 10:56:47 -0700 (PDT) Received: by mail-ee0-f44.google.com with SMTP id e49so4416611eek.3 for ; Fri, 28 Mar 2014 10:56:47 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1395967478-30549-11-git-send-email-matthew.d.roper@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Matt Roper Cc: dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org On Thu, Mar 27, 2014 at 05:44:35PM -0700, Matt Roper wrote: > Add a new drm_crtc_init_with_planes() to allow drivers to provide > specific primary and cursor planes at CRTC initialization. The existing > drm_crtc_init() interface remains to avoid driver churn in existing > drivers; it will initialize the CRTC with a plane helper-created primary > plane and no cursor plane. > > Signed-off-by: Matt Roper > --- > drivers/gpu/drm/drm_crtc.c | 44 +++++++++++++++++++++++++++++++++++++++++--- > include/drm/drm_crtc.h | 11 +++++++++++ > 2 files changed, 52 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c > index 24226de..a983311 100644 > --- a/drivers/gpu/drm/drm_crtc.c > +++ b/drivers/gpu/drm/drm_crtc.c > @@ -37,6 +37,7 @@ > #include > #include > #include > +#include > > #include "drm_crtc_internal.h" > > @@ -692,9 +693,12 @@ void drm_framebuffer_remove(struct drm_framebuffer *fb) > EXPORT_SYMBOL(drm_framebuffer_remove); > > /** > - * drm_crtc_init - Initialise a new CRTC object > + * drm_crtc_init_with_planes - Initialise a new CRTC object with > + * specified primary and cursor planes. > * @dev: DRM device > * @crtc: CRTC object to init > + * @primary: Primary plane for CRTC > + * @cursor: Cursor plane for CRTC > * @funcs: callbacks for the new CRTC > * > * Inits a new object created as base part of a driver crtc object. > @@ -702,8 +706,10 @@ EXPORT_SYMBOL(drm_framebuffer_remove); > * Returns: > * Zero on success, error code on failure. > */ > -int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, > - const struct drm_crtc_funcs *funcs) > +int drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *crtc, > + struct drm_plane *primary, > + struct drm_plane *cursor, > + const struct drm_crtc_funcs *funcs) > { > int ret; > > @@ -724,11 +730,41 @@ int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, > list_add_tail(&crtc->head, &dev->mode_config.crtc_list); > dev->mode_config.num_crtc++; > > + crtc->primary = primary; > + if (primary) > + primary->possible_crtcs = 1 << drm_crtc_index(crtc); > + > + crtc->cursor = cursor; > + if (cursor) > + cursor->possible_crtcs = 1 << drm_crtc_index(crtc); > + > out: > drm_modeset_unlock_all(dev); > > return ret; > } > +EXPORT_SYMBOL(drm_crtc_init_with_planes); > + > +/** > + * drm_crtc_init - Legacy CRTC initialization function > + * @dev: DRM device > + * @crtc: CRTC object to init > + * @funcs: callbacks for the new CRTC > + * > + * Initialize a CRTC object with a default helper-provided primary plane and no > + * cursor plane. > + * > + * Returns: > + * Zero on success, error code on failure. > + */ > +int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, > + const struct drm_crtc_funcs *funcs) > +{ > + struct drm_plane *primary; > + > + primary = drm_primary_helper_create_plane(dev, NULL, 0); > + return drm_crtc_init_with_planes(dev, crtc, primary, NULL, funcs); > +} > EXPORT_SYMBOL(drm_crtc_init); I think we should move the drm_crtc_init to drm_plane_helpers.c to be perfectly strict with the "nothing in drm core should depend upon helpers" rule for avoiding midlayer mistakes. -Daniel > > /** > @@ -2248,6 +2284,8 @@ int drm_mode_set_config_internal(struct drm_mode_set *set) > > ret = crtc->funcs->set_config(set); > if (ret == 0) { > + crtc->primary->crtc = crtc; > + > /* crtc->fb must be updated by ->set_config, enforces this. */ > WARN_ON(fb != crtc->fb); > } > diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h > index 78cf825..e7ed766 100644 > --- a/include/drm/drm_crtc.h > +++ b/include/drm/drm_crtc.h > @@ -270,6 +270,8 @@ struct drm_crtc_funcs { > * @dev: parent DRM device > * @head: list management > * @base: base KMS object for ID tracking etc. > + * @primary: primary plane for this CRTC > + * @cursor: cursor plane for this CRTC > * @enabled: is this CRTC enabled? > * @mode: current mode timings > * @hwmode: mode timings as programmed to hw regs > @@ -305,6 +307,10 @@ struct drm_crtc { > > struct drm_mode_object base; > > + /* primary and cursor planes for CRTC */ > + struct drm_plane *primary; > + struct drm_plane *cursor; > + > /* framebuffer the connector is currently bound to */ > struct drm_framebuffer *fb; > > @@ -826,6 +832,11 @@ extern void drm_modeset_lock_all(struct drm_device *dev); > extern void drm_modeset_unlock_all(struct drm_device *dev); > extern void drm_warn_on_modeset_not_all_locked(struct drm_device *dev); > > +extern int drm_crtc_init_with_planes(struct drm_device *dev, > + struct drm_crtc *crtc, > + struct drm_plane *primary, > + struct drm_plane *cursor, > + const struct drm_crtc_funcs *funcs); > extern int drm_crtc_init(struct drm_device *dev, > struct drm_crtc *crtc, > const struct drm_crtc_funcs *funcs); > -- > 1.8.5.1 > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/dri-devel -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch