From patchwork Wed Dec 28 21:19:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 9495147 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 9AA2560414 for ; Tue, 3 Jan 2017 16:09:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 836B0271BC for ; Tue, 3 Jan 2017 16:09:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 785682780C; Tue, 3 Jan 2017 16:09:00 +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_SIGNED, 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 D5978271BC for ; Tue, 3 Jan 2017 16:08:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E9AEE6E5C8; Tue, 3 Jan 2017 16:08:52 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf0-x236.google.com (mail-lf0-x236.google.com [IPv6:2a00:1450:4010:c07::236]) by gabe.freedesktop.org (Postfix) with ESMTPS id E67B86E03F for ; Wed, 28 Dec 2016 21:19:51 +0000 (UTC) Received: by mail-lf0-x236.google.com with SMTP id y21so210873751lfa.1 for ; Wed, 28 Dec 2016 13:19:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:organization:user-agent:in-reply-to :references:mime-version:content-transfer-encoding; bh=paQnzu1hfpwCCYwN/8w7vpm+EwrJ0WN9gwJJMz+FY1o=; b=ILk3LV1FPlan88njHKujr/ERpL0oS4kIkYzCvUdJEyLkKvkEovPxChDVCJCD+BhTjr 8Oi8LAu63aa4aQRplexiFeB3DHP+PNGJPegi4muro8+GQIJTDGqPRZE5sTVZ3CEIUQz7 gfca6kpwmiVDNB9PTazhGocmOu468n/KSY1MVl1yaq3AD5gaJityyavzSy4+bpQyM036 htCGJXY4pLCJXDd1GUpgZ2GYvoT3hb/lM98U15XdIkwe1dx7kaNMMnUFtS0dXXbkGfWJ JGeDdljVqseoQT2lcpXvmTnK00PoJNGtYPXlyhH/j2zAxKarpJnAHEwNVHRrYU6tyZCI zAEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:organization :user-agent:in-reply-to:references:mime-version :content-transfer-encoding; bh=paQnzu1hfpwCCYwN/8w7vpm+EwrJ0WN9gwJJMz+FY1o=; b=ZC8t0Oi9NbwkTOKkmzc9InK/GzxlpzKALpx3/t+ROLn7lbG79XNksaWGkCeOSLaG+F IbrEyJMp90E50OCCdjjbP6WL89Bvow+gbFiCG8seI11JKyaw+MMKZhWuPkuSFWzkY02t SOY5W3xD316gdtGdVoSTL3TINNIXZfto+l+3VSLCxLeRTL87nI560isX35n9ifpvQ2AV ZaZLoiDkHhYoG4E+zCtZIArVl7HjnDLhJbhLuRSTa6bgPawYC/5YcVTXQXb0BAdvJUDI jITy4t6lCwnOmL4K8GW4WVd307S84Ldy+6RjDcD6RDhYOF2l+xyFgJNoKIlvHAlaHad2 4tNA== X-Gm-Message-State: AIkVDXJuBAB79NpaMmoaf4diyWNXIO/8InFztub0VV9JUN3JVT/6Ct36Enw/YwFxtS9szg== X-Received: by 10.25.165.144 with SMTP id o138mr13862543lfe.172.1482959989846; Wed, 28 Dec 2016 13:19:49 -0800 (PST) Received: from wasted.cogentembedded.com ([31.173.84.130]) by smtp.gmail.com with ESMTPSA id m129sm12424802lfe.6.2016.12.28.13.19.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Dec 2016 13:19:49 -0800 (PST) From: Sergei Shtylyov To: laurent.pinchart@ideasonboard.com, airlied@linux.ie, dri-devel@lists.freedesktop.org, linux-renesas-soc@vger.kernel.org Subject: [PATCH 1/2] drm: rcar-du: support less VSPs than CRTCs Date: Thu, 29 Dec 2016 00:19:47 +0300 Message-ID: <1844861.8doEdlf3qj@wasted.cogentembedded.com> Organization: Cogent Embedded Inc. User-Agent: KMail/4.14.10 (Linux/4.8.13-100.fc23.x86_64; KDE/4.14.20; x86_64; ; ) In-Reply-To: <18781159.4YChoBxRU5@wasted.cogentembedded.com> References: <18781159.4YChoBxRU5@wasted.cogentembedded.com> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 03 Jan 2017 16:03:01 +0000 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 Renesas R-Car E2 (R8A7791) SoC only has 1 VSPD but still 2 DU ports. Since we are going to use the R-Car gen2 VSPDs as the DU compositors, we'll have to also support this case. Now that the number of VSPDs can be less than the number of the DU ports, 'struct rcar_du_device_info' needs a new field which we'll have to set for the SoCs where we've already used the VSPD compositor... Signed-off-by: Sergei Shtylyov --- drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 17 ++++++- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 2 drivers/gpu/drm/rcar-du/rcar_du_drv.h | 2 drivers/gpu/drm/rcar-du/rcar_du_kms.c | 2 drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 76 ++++++++++++++++++++++----------- drivers/gpu/drm/rcar-du/rcar_du_vsp.h | 2 6 files changed, 75 insertions(+), 26 deletions(-) Index: linux/drivers/gpu/drm/rcar-du/rcar_du_crtc.c =================================================================== --- linux.orig/drivers/gpu/drm/rcar-du/rcar_du_crtc.c +++ linux/drivers/gpu/drm/rcar-du/rcar_du_crtc.c @@ -255,8 +255,21 @@ static void rcar_du_crtc_update_planes(s /* If VSP+DU integration is enabled the plane assignment is fixed. */ if (rcar_du_has(rcdu, RCAR_DU_FEATURE_VSP1_SOURCE)) { if (rcdu->info->gen < 3) { - dspr = (rcrtc->index % 2) + 1; - hwplanes = 1 << (rcrtc->index % 2); + if (rcrtc->vsp->vsp) { + dspr = (rcrtc->index % 2) + 1; + hwplanes = 1 << (rcrtc->index % 2); + } else { + for (i = 0; i < rcrtc->vsp->num_planes; ++i) { + struct rcar_du_vsp_plane *plane = + &rcrtc->vsp->planes[i]; + + if (plane->plane.state->crtc != + &rcrtc->crtc) + continue; + dspr |= (plane->index + 5) << 4 * i; + hwplanes |= 1 << (plane->index + 4); + } + } } else { dspr = (rcrtc->index % 2) ? 3 : 1; hwplanes = 1 << ((rcrtc->index % 2) ? 2 : 0); Index: linux/drivers/gpu/drm/rcar-du/rcar_du_drv.c =================================================================== --- linux.orig/drivers/gpu/drm/rcar-du/rcar_du_drv.c +++ linux/drivers/gpu/drm/rcar-du/rcar_du_drv.c @@ -109,6 +109,7 @@ static const struct rcar_du_device_info }, }, .num_lvds = 1, + .num_vspds = 2, }; static const struct rcar_du_device_info rcar_du_r8a7792_info = { @@ -201,6 +202,7 @@ static const struct rcar_du_device_info }, }, .num_lvds = 1, + .num_vspds = 4, }; static const struct of_device_id rcar_du_of_table[] = { Index: linux/drivers/gpu/drm/rcar-du/rcar_du_drv.h =================================================================== --- linux.orig/drivers/gpu/drm/rcar-du/rcar_du_drv.h +++ linux/drivers/gpu/drm/rcar-du/rcar_du_drv.h @@ -59,6 +59,7 @@ struct rcar_du_output_routing { * @num_crtcs: total number of CRTCs * @routes: array of CRTC to output routes, indexed by output (RCAR_DU_OUTPUT_*) * @num_lvds: number of internal LVDS encoders + * @num_vspds: number of VSPDs */ struct rcar_du_device_info { unsigned int gen; @@ -67,6 +68,7 @@ struct rcar_du_device_info { unsigned int num_crtcs; struct rcar_du_output_routing routes[RCAR_DU_OUTPUT_MAX]; unsigned int num_lvds; + unsigned int num_vspds; }; #define RCAR_DU_MAX_CRTCS 4 Index: linux/drivers/gpu/drm/rcar-du/rcar_du_kms.c =================================================================== --- linux.orig/drivers/gpu/drm/rcar-du/rcar_du_kms.c +++ linux/drivers/gpu/drm/rcar-du/rcar_du_kms.c @@ -611,6 +611,8 @@ int rcar_du_modeset_init(struct rcar_du_ vsp->index = i; vsp->dev = rcdu; + vsp->group = &rcdu->groups[i / 2]; + rcdu->crtcs[i].vsp = vsp; ret = rcar_du_vsp_init(vsp); Index: linux/drivers/gpu/drm/rcar-du/rcar_du_vsp.c =================================================================== --- linux.orig/drivers/gpu/drm/rcar-du/rcar_du_vsp.c +++ linux/drivers/gpu/drm/rcar-du/rcar_du_vsp.c @@ -51,6 +51,9 @@ void rcar_du_vsp_enable(struct rcar_du_c .colorkey = 0, }; + if (!crtc->vsp->vsp) + return; + if (rcdu->info->gen >= 3) state.hwindex = (crtc->index % 2) ? 2 : 0; else @@ -71,17 +74,20 @@ void rcar_du_vsp_enable(struct rcar_du_c void rcar_du_vsp_disable(struct rcar_du_crtc *crtc) { - vsp1_du_setup_lif(crtc->vsp->vsp, 0, 0); + if (crtc->vsp->vsp) + vsp1_du_setup_lif(crtc->vsp->vsp, 0, 0); } void rcar_du_vsp_atomic_begin(struct rcar_du_crtc *crtc) { - vsp1_du_atomic_begin(crtc->vsp->vsp); + if (crtc->vsp->vsp) + vsp1_du_atomic_begin(crtc->vsp->vsp); } void rcar_du_vsp_atomic_flush(struct rcar_du_crtc *crtc) { - vsp1_du_atomic_flush(crtc->vsp->vsp); + if (crtc->vsp->vsp) + vsp1_du_atomic_flush(crtc->vsp->vsp); } /* Keep the two tables in sync. */ @@ -180,7 +186,8 @@ static void rcar_du_vsp_plane_setup(stru } } - vsp1_du_atomic_update(plane->vsp->vsp, plane->index, &cfg); + if (plane->vsp->vsp) + vsp1_du_atomic_update(plane->vsp->vsp, plane->index, &cfg); } static int rcar_du_vsp_plane_atomic_check(struct drm_plane *plane, @@ -216,10 +223,29 @@ static void rcar_du_vsp_plane_atomic_upd { struct rcar_du_vsp_plane *rplane = to_rcar_vsp_plane(plane); - if (plane->state->crtc) - rcar_du_vsp_plane_setup(rplane); - else - vsp1_du_atomic_update(rplane->vsp->vsp, rplane->index, NULL); + if (rplane->vsp->vsp) { + if (plane->state->crtc) + rcar_du_vsp_plane_setup(rplane); + else + vsp1_du_atomic_update(rplane->vsp->vsp, rplane->index, + NULL); + } else { + struct rcar_du_plane_state state = { + .format = rcar_du_format_info(DRM_FORMAT_ARGB8888), + .source = RCAR_DU_PLANE_MEMORY, + .alpha = 255, + .colorkey = 0, + }; + + state.state = *(plane->state); + + if (!plane->state->crtc) + return; + + state.hwindex = rplane->index + 4; + + __rcar_du_plane_setup(rplane->vsp->group, &state); + } } static const struct drm_plane_helper_funcs rcar_du_vsp_plane_helper_funcs = { @@ -324,23 +350,25 @@ int rcar_du_vsp_init(struct rcar_du_vsp unsigned int i; int ret; - /* Find the VSP device and initialize it. */ - np = of_parse_phandle(rcdu->dev->of_node, "vsps", vsp->index); - if (!np) { - dev_err(rcdu->dev, "vsps node not found\n"); - return -ENXIO; - } + if (vsp->index < rcdu->info->num_vspds) { + /* Find the VSP device and initialize it. */ + np = of_parse_phandle(rcdu->dev->of_node, "vsps", vsp->index); + if (!np) { + dev_err(rcdu->dev, "vsps node not found\n"); + return -ENXIO; + } - pdev = of_find_device_by_node(np); - of_node_put(np); - if (!pdev) - return -ENXIO; - - vsp->vsp = &pdev->dev; - - ret = vsp1_du_init(vsp->vsp); - if (ret < 0) - return ret; + pdev = of_find_device_by_node(np); + of_node_put(np); + if (!pdev) + return -ENXIO; + + vsp->vsp = &pdev->dev; + + ret = vsp1_du_init(vsp->vsp); + if (ret < 0) + return ret; + } /* The VSP2D (Gen3) has 5 RPFs, but the VSP1D (Gen2) is limited to * 4 RPFs. Index: linux/drivers/gpu/drm/rcar-du/rcar_du_vsp.h =================================================================== --- linux.orig/drivers/gpu/drm/rcar-du/rcar_du_vsp.h +++ linux/drivers/gpu/drm/rcar-du/rcar_du_vsp.h @@ -19,6 +19,7 @@ struct rcar_du_format_info; struct rcar_du_vsp; +struct rcar_du_group; struct rcar_du_vsp_plane { struct drm_plane plane; @@ -31,6 +32,7 @@ struct rcar_du_vsp { struct device *vsp; struct rcar_du_device *dev; struct rcar_du_vsp_plane *planes; + struct rcar_du_group* group; unsigned int num_planes; };