From patchwork Thu Aug 25 09:04:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 9298981 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C69FA607F0 for ; Thu, 25 Aug 2016 09:05:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7F1E291D5 for ; Thu, 25 Aug 2016 09:05:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AADA72922A; Thu, 25 Aug 2016 09:05:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6065A291D5 for ; Thu, 25 Aug 2016 09:05:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BB9406E37F; Thu, 25 Aug 2016 09:05:20 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 288B26E37F for ; Thu, 25 Aug 2016 09:05:19 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id q128so6446066wma.1 for ; Thu, 25 Aug 2016 02:05:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ylKVz5Ho7PLLhqcq+d1CD0r0vn4hRHUsX7SElLAakAw=; b=oeQzShd3o9XEzMGLWwFcUFGR4LBCshJhn7bhfjbJMTQTTAedo5TCGyflgGONN8u2KL i1HJuLW1uuUV2bZUHo+a1jUGnPhvd0SYIr20I8ZDXn0bjwUmfo6QUTToUwTPoYlGHrA0 d1mUDVs8NBJsq/8I24zASWdYvmPN3e/0sDqjqwtupjvfCCmY4kmthlMj1KUDtk7DYfrB tOTNEKiiKmskb4nTr8Bvk3MzYIpggzEA93mYyCLdepXNwYCoayBYyDpgzZ3BNqOU89tq jwoPJpC7thlOrhy5/fyiK5Pooc/m2NjxvWFTyffUonc6vv2wWQm9lLuY1V/YrGQIIRDu r9Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ylKVz5Ho7PLLhqcq+d1CD0r0vn4hRHUsX7SElLAakAw=; b=mxPT07mo98COOUejqKE1zRigd3JkADQ1DhzAS+2hJL2SHcfAo7wdO9rjMEYgdtnrvg MNjWrI/1wa4ooRoDpazsMD3fNR7xwO7kQo3sPsbx0ITfT9tlzVpTzJ9wGwzH3SqC+RMh lhsMDE2FnQR6+uYPQ9YJYSTijb7Gz/JM1m7YIPpHmE8ngYxae0xeZu0qz0AuqqisliEC izHqKWiLWcqAW79UTN5WxrWb1allaP2ZYzaXSbXPEwq98GCPDmTXIp2U9ciDVjSDCTLo Hp3go/p/KiKUDT6miNIll7GLeDtfTHcP48TC/hchsRnQGd7xH0GZG5/7L3HYLTpokrZZ LGyQ== X-Gm-Message-State: AEkoousBJR/aKB3pUTy+94E+qI6/OwlN7Z0emmRSSDxegCTvqSML5U3JRgJptmvygQZIHQ== X-Received: by 10.194.87.34 with SMTP id u2mr7229240wjz.118.1472115917777; Thu, 25 Aug 2016 02:05:17 -0700 (PDT) Received: from NewMoon.iit.local ([90.147.180.254]) by smtp.gmail.com with ESMTPSA id a203sm44917428wma.0.2016.08.25.02.05.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 25 Aug 2016 02:05:17 -0700 (PDT) From: Andrea Merello To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 3/3] drm: simple_kms_helper: add support for bridges Date: Thu, 25 Aug 2016 11:04:34 +0200 Message-Id: <1472115874-6219-3-git-send-email-andrea.merello@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1472115874-6219-1-git-send-email-andrea.merello@gmail.com> References: <1472115874-6219-1-git-send-email-andrea.merello@gmail.com> MIME-Version: 1.0 Cc: Andrea Merello X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Introduce drm_simple_display_pipe_attach_bridge() and drm_simple_display_pipe_detach_bridge() in order to make it possible to use drm encoders with the simple display pipes managed by simple_kms_helpers Suggested-by: Daniel Vetter Signed-off-by: Andrea Merello Reviewed-by: Daniel Vetter Cc: Noralf Trønnes Cc: Daniel Vetter Cc: David Airlie --- drivers/gpu/drm/drm_simple_kms_helper.c | 40 +++++++++++++++++++++++++++++++++ include/drm/drm_simple_kms_helper.h | 5 +++++ 2 files changed, 45 insertions(+) diff --git a/drivers/gpu/drm/drm_simple_kms_helper.c b/drivers/gpu/drm/drm_simple_kms_helper.c index 3301e4a..8e9858b 100644 --- a/drivers/gpu/drm/drm_simple_kms_helper.c +++ b/drivers/gpu/drm/drm_simple_kms_helper.c @@ -140,6 +140,46 @@ static const struct drm_plane_funcs drm_simple_kms_plane_funcs = { }; /** + * drm_simple_display_pipe_attach_bridge - Attach a bridge to the display pipe + * @pipe: simple display pipe object + * @bridge: bridge to attach + * + * Makes it possible to still use the drm_simple_display_pipe helpers when + * a DRM bridge has to be used. + * + * Note that you probably want to initialize the pipe by passing a NULL + * connector to drm_simple_display_pipe_init(). + * + * Returns: + * Zero on success, negative error code on failure. + */ +int drm_simple_display_pipe_attach_bridge(struct drm_simple_display_pipe *pipe, + struct drm_bridge *bridge) +{ + bridge->encoder = &pipe->encoder; + pipe->encoder.bridge = bridge; + return drm_bridge_attach(pipe->encoder.dev, bridge); +} +EXPORT_SYMBOL(drm_simple_display_pipe_attach_bridge); + +/** + * drm_simple_display_pipe_detach_bridge - Detach the bridge from the display pipe + * @pipe: simple display pipe object + * + * Detaches the drm bridge previously attached with + * drm_simple_display_pipe_attach_bridge() + */ +void drm_simple_display_pipe_detach_bridge(struct drm_simple_display_pipe *pipe) +{ + if (WARN_ON(!pipe->encoder.bridge)) + return; + + drm_bridge_detach(pipe->encoder.bridge); + pipe->encoder.bridge = NULL; +} +EXPORT_SYMBOL(drm_simple_display_pipe_detach_bridge); + +/** * drm_simple_display_pipe_init - Initialize a simple display pipeline * @dev: DRM device * @pipe: simple display pipe object to initialize diff --git a/include/drm/drm_simple_kms_helper.h b/include/drm/drm_simple_kms_helper.h index 2690397..5245d1f 100644 --- a/include/drm/drm_simple_kms_helper.h +++ b/include/drm/drm_simple_kms_helper.h @@ -85,6 +85,11 @@ struct drm_simple_display_pipe { const struct drm_simple_display_pipe_funcs *funcs; }; +int drm_simple_display_pipe_attach_bridge(struct drm_simple_display_pipe *pipe, + struct drm_bridge *bridge); + +void drm_simple_display_pipe_detach_bridge(struct drm_simple_display_pipe *pipe); + int drm_simple_display_pipe_init(struct drm_device *dev, struct drm_simple_display_pipe *pipe, const struct drm_simple_display_pipe_funcs *funcs,