From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Anholt Subject: Re: [PATCH 1/2] drm/bridge: Refactor out the panel wrapper from the lvds-encoder bridge. Date: Thu, 27 Apr 2017 10:27:38 -0700 Message-ID: <87inlphib9.fsf@eliezer.anholt.net> References: <20170427163601.7313-1-eric@anholt.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1357688047==" Return-path: Received: from anholt.net (anholt.net [50.246.234.109]) by gabe.freedesktop.org (Postfix) with ESMTP id 1F1E46E6C2 for ; Thu, 27 Apr 2017 17:27:41 +0000 (UTC) In-Reply-To: <20170427163601.7313-1-eric@anholt.net> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: dri-devel@lists.freedesktop.org Cc: Yannick Fertre , linux-kernel@vger.kernel.org List-Id: dri-devel@lists.freedesktop.org --===============1357688047== Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" --=-=-= Content-Type: text/plain Eric Anholt writes: > Many DRM drivers have common code to make a stub connector > implementation that wraps a drm_panel. By wrapping the panel in a DRM > bridge, all of the connector code (including calls during encoder > enable/disable) goes away. > > Signed-off-by: Eric Anholt > +/** > + * drm_panel_bridge_add - Creates a drm_bridge and drm_connector that > + * just call the appropriate functions from drm_panel. > + * > + * @dev: The struct device of the panel device. This is used for > + * registering the drm_bridge. > + * @panel: The drm_panel being wrapped. Must be non-NULL. > + * @connector_type: The DRM_MODE_CONNECTOR_* for the connector to be > + * created. > + * > + * For drivers converting from directly using drm_panel: The expected > + * usage pattern is that during either encoder module probe or DSI > + * host attach, a drm_panel will be looked up through > + * drm_of_find_panel_or_bridge(). drm_panel_bridge_add() is used to > + * wrap that panel in the new bridge, and the result can then be > + * passed to drm_bridge_attach(). The drm_panel_prepare() and related > + * functions can be dropped from the encoder driver (they're now > + * called by the KMS helpers before calling into the encoder), along > + * with connector creation. > + */ > +struct drm_bridge *drm_panel_bridge_add(struct device *dev, > + struct drm_panel *panel, > + u32 connector_type) > +{ > + struct panel_bridge *panel_bridge = > + devm_kzalloc(dev, sizeof(*panel_bridge), GFP_KERNEL); > + int ret; > + > + if (!dev || !panel) > + return ERR_PTR(EINVAL); > + > + panel_bridge->dev = dev; > + panel_bridge->connector_type = connector_type; > + panel_bridge->panel = panel; > + > + panel_bridge->bridge.funcs = &panel_bridge_bridge_funcs; > + panel_bridge->bridge.of_node = dev->of_node; > + > + ret = drm_bridge_add(&panel_bridge->bridge); > + if (ret) > + return ERR_PTR(ret); > + > + return &panel_bridge->bridge; > +} > +EXPORT_SYMBOL(drm_panel_bridge_add); > + > +void drm_panel_bridge_remove(struct device *dev, struct drm_bridge *bridge) > +{ > + drm_bridge_remove(bridge); > + devm_kfree(dev, bridge); > +} > +EXPORT_SYMBOL(drm_panel_bridge_remove); Working with this interface in another driver, I want to drop the "struct device" argument, since we can get the struct device from panel->dev. It keeps the user of the driver from needing to keep track of the panel/device it needs to hand to drm_panel_bridge_remove(). --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE/JuuFDWp9/ZkuCBXtdYpNtH8nugFAlkCKgsACgkQtdYpNtH8 nugKXQ/9GU/C4iIxCfBzdbza08gj3VAs9zXH+UaRQpcch1RbYmTcFxeEKkC4f37t p3D5BdKfV5HjeuDauEXMl6x3inKvU8srf03DRz9c7s4BFkXftpPvbiRctMtvsWGW kFpALx8IubK30O6+g6bqIHxsjBvD3XDSoDRZqD3ZhgwxzimwwUWZDisUH6Y5HBL9 7xVKq93eZK68a/YTbKnr/Mf0bhyHkMFIFAFsfYLOQF3+apeMSmTooIO1hzyQ/AD0 GNa2AGcxq9+eqH/4qQ/eW2E+YO3PX8qUjhiyD2Rvc+CVt3GNea4hJ4UM/WzXUiqr Bnhbn7JH1E1VFOnTMuNLPVO0Wb2YQxj6tukk4IhY3OjEg5vhs6yATz+GlRD2PBn9 rc9fkFue0vxWKtXXxwXM4tDMfrRVATKbt2emrRYK6iac4qyPbHNjMwKfj4vnnwbe kXQt/3bAVRYqIUYmHhxCu7p3pDJIGkOwvCpQXWXHEamm2Hr6jyErzb6jdqHZEQdi cE3Poo1QkuixRqBRJSPUezJGt7iGgEv4s+Uos1V5fwOBUgfCK52kk9qL2RTJI2MH Z/7+ifo9KhWUTXaspKvt7xGvaAiDeHO+0sK30IEq/KfKmQOQGnJAH11yv0nPT9QP yuRB42KgaBfmmnhwRxiW3CRgqrIGWzj5+XG4uw2ukAyDa+maem0= =cICM -----END PGP SIGNATURE----- --=-=-=-- --===============1357688047== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVsCg== --===============1357688047==--