From patchwork Tue Jul 23 12:20:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QXJ0dXIgxZp3aWdvxYQ=?= X-Patchwork-Id: 169528 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8806713ilk; Tue, 23 Jul 2019 05:20:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqxiJIVp7/5gDN1DJSqYaNRSCoXXiGwlv4t3h0aNf9Kzvf8sp34vUXd/AdsqvnPPafog8tfv X-Received: by 2002:aa7:8a92:: with SMTP id a18mr5599438pfc.216.1563884435475; Tue, 23 Jul 2019 05:20:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563884435; cv=none; d=google.com; s=arc-20160816; b=C6KyxOPRYJ4wbaxuw3x7ISQIIO5O3zLoA234jBw2WajC9Q4ggn6QgIIybzeaDLawiw AvJEFcXW2vtdGz4VniqcWNO4reksNCrUEwlaPxBFMbnQ9fTYuKA9gJDh+JGVDmM7ZYRa 9Yt/+4N6+DTahzwEcf/RF4khfu5zzs20egkCpMOUpCI+YnIIU3J11IyvISQoTZGqKf65 fO6ax9uNKnMZx9PJCEYubT0B6R4rcG0hmvwJR1NGlrIK4uf3kecU7rTjzKIeTbCJYNl3 1cBqTo8Vi34PAkXGdxnzitEU3R6HZTorx35L9Udzsnhjt1JZvuSnimzdJ1eweKLehiZo HGHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type :content-transfer-encoding:mime-version:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=chTAxkeOxeztbYhH5EwlVhyZmCCDjcZAKWEH2LV9Maw=; b=HRj7jIr2n97x8xTRtsLKNC8jNnuzi/V/r5XHbj+oBj4p+9XL9uVO6yb3U5GjeKwDqW VYQ2T4ESZxVDAkrYe3aoCTnIRjp+7Cx1fkc1Wfz7z3d64GHFWI/Fvn+f4hbzGBJcGeiL 4Pu5mi74DP0AYxOg+T0ChRAYku+ylhWbhm+Nln94Nu62NGS5t4tvgSI9lxuroUatVc1y qeqfmOHpE1mjlKEhsx2HEVBvK4vZvkU5IyZ68dAWVYdXzKKH/OZWwxtTGnNhvekZcGPi GfZFdNhLbnID3HX8W6aigyqXXaurEq4idFrPm/JTdntj4UtWTcTUn8b8N7vxQqyysQuq Gz6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=SDJFh76X; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c7si11300135pjo.88.2019.07.23.05.20.35; Tue, 23 Jul 2019 05:20:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=SDJFh76X; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389754AbfGWMUe (ORCPT + 3 others); Tue, 23 Jul 2019 08:20:34 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:38689 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389745AbfGWMUd (ORCPT ); Tue, 23 Jul 2019 08:20:33 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20190723122031euoutp012c3b1f1f94ff74e276a9ce574cad9b3e~0CJq2kriK2865228652euoutp01i for ; Tue, 23 Jul 2019 12:20:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20190723122031euoutp012c3b1f1f94ff74e276a9ce574cad9b3e~0CJq2kriK2865228652euoutp01i DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1563884431; bh=chTAxkeOxeztbYhH5EwlVhyZmCCDjcZAKWEH2LV9Maw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SDJFh76Xs3O0baQ+0RL20r3do0CbUInP1yE9C2qSPh+QqXtvkarNdywgj+G3b0r3D 0jeLwfdDPZG3zUdPGvCwdRqcp4vqm2TInMmeG0b/1ACgCa19DCiMWld5J2YqvPVfoa A5cReIjq+1g2716hhh2jP0mYM5cENknB6YwwvNqo= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190723122030eucas1p1526085231fac50d83e0c3f4e901d27ac~0CJqHQ6G11172511725eucas1p1s; Tue, 23 Jul 2019 12:20:30 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id BA.75.04325.E8BF63D5; Tue, 23 Jul 2019 13:20:30 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20190723122029eucas1p2915f536d9ef43a7bd043a878a553439f~0CJpcU7GT2749027490eucas1p2e; Tue, 23 Jul 2019 12:20:29 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20190723122029eusmtrp1a31f44e38dd0815908164fafed0ac103~0CJpbZEWS2543625436eusmtrp1M; Tue, 23 Jul 2019 12:20:29 +0000 (GMT) X-AuditID: cbfec7f5-b75ff700000010e5-b1-5d36fb8eb2a1 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 44.51.04146.D8BF63D5; Tue, 23 Jul 2019 13:20:29 +0100 (BST) Received: from AMDC3555.DIGITAL.local (unknown [106.120.51.67]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20190723122028eusmtip253d509d660fc46b60b3b91f389d18d83~0CJozTE0j1733017330eusmtip2k; Tue, 23 Jul 2019 12:20:28 +0000 (GMT) From: =?utf-8?b?QXJ0dXIgxZp3aWdvxYQ=?= To: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: krzk@kernel.org, cw00.choi@samsung.com, myungjoo.ham@samsung.com, inki.dae@samsung.com, sw0312.kim@samsung.com, georgi.djakov@linaro.org, m.szyprowski@samsung.com Subject: [RFC PATCH 11/11] drm: exynos: mixer: Add interconnect support Date: Tue, 23 Jul 2019 14:20:16 +0200 Message-Id: <20190723122016.30279-12-a.swigon@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190723122016.30279-1-a.swigon@partner.samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA01SfSyUcRzvd8/LPY7jccR3va5b14tNekG/lVrJ1rX+kH8z6YknWlx2D0r9 EbmQMLkaIaxaOBMOV3lbXYdarVtLspWpYdFW8hojdeeh/Pf5fl5+n+93+zGEwkqtYs5o4nmt hotR0jLS1DHzxjtn1j9su6FEhs0djVJcV1BD4Q8TXylcanlD4a7JERrntxppnNeXS2KrtVaK jf3dFH7XVEzj8WwLwgXWNgmutvRK8ceUChoX6IfpAy5qo+Earf7U3UKr+653StT19y+rn/1o kahzGgxIPW5cd0x6XBYQycecSeS1PvtPyqINbbVUnG7jhbSB92Qysq7NRA4MsL4wr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p4SPRN3sIIkRAROMUpsXX4OrIpZYBOjxN3jE9lBqoQF3CUeTprH BGKzCKhKPPmxEWwsr4CTxP/lc1ggVshLrN5wAGwqJ1C862g72BlCAo4S27a/ZoSoF5Q4OfMJ UD0H0AJ1ifXzhEDCzECtzVtnM09gFJyFpGoWQtUsJFULGJlXMYqklhbnpucWG+oVJ+YWl+al 6yXn525iBMbptmM/N+9gvLQx+BCjAAejEg/vhj2msUKsiWXFlbmHGCU4mJVEeAMbzGKFeFMS K6tSi/Lji0pzUosPMZoCvTaRWUo0OR+YQvJK4g1NDc0tLA3Njc2NzSyUxHk7BA7GCAmkJ5ak ZqemFqQWwfQxcXBKNTC6lT5elvdbzu0Th+GCz/3v7ljmGXv11Ul6/uSfl+xZ0HRI737Xy/rC iZe/Lv4wX/5IxrvOztrDz7YpdEXN5/CNjjs0ad313b4VLz5eLjlhGmzwOTR9fubniX2BX9Vn 3NvV32UgEXz0t+rc0tRPzov3xgXtfzsloFRVcT/PxBD3iNfftr+d4OuvxFKckWioxVxUnAgA zexhSukCAAA= X-CMS-MailID: 20190723122029eucas1p2915f536d9ef43a7bd043a878a553439f X-Msg-Generator: CA X-RootMTR: 20190723122029eucas1p2915f536d9ef43a7bd043a878a553439f X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20190723122029eucas1p2915f536d9ef43a7bd043a878a553439f References: <20190723122016.30279-1-a.swigon@partner.samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org From: Marek Szyprowski This patch adds interconnect support to exynos-mixer. Please note that the mixer works the same as before when CONFIG_INTERCONNECT is 'n'. Co-developed-by: Artur Świgoń Signed-off-by: Artur Świgoń Signed-off-by: Marek Szyprowski --- drivers/gpu/drm/exynos/exynos_mixer.c | 68 +++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c index 7b24338fad3c..fb763854b300 100644 --- a/drivers/gpu/drm/exynos/exynos_mixer.c +++ b/drivers/gpu/drm/exynos/exynos_mixer.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -97,6 +98,7 @@ struct mixer_context { struct exynos_drm_crtc *crtc; struct exynos_drm_plane planes[MIXER_WIN_NR]; unsigned long flags; + struct icc_path *soc_path; int irq; void __iomem *mixer_regs; @@ -931,6 +933,37 @@ static void mixer_disable_vblank(struct exynos_drm_crtc *crtc) mixer_reg_writemask(mixer_ctx, MXR_INT_EN, 0, MXR_INT_EN_VSYNC); } +static void mixer_set_memory_bandwidth(struct exynos_drm_crtc *crtc) +{ + struct drm_display_mode *mode = &crtc->base.state->adjusted_mode; + struct mixer_context *ctx = crtc->ctx; + unsigned long bw, bandwidth = 0; + int i, j, sub; + + for (i = 0; i < MIXER_WIN_NR; i++) { + struct drm_plane *plane = &ctx->planes[i].base; + const struct drm_format_info *format; + + if (plane->state && plane->state->crtc && plane->state->fb) { + format = plane->state->fb->format; + bw = mode->hdisplay * mode->vdisplay * + drm_mode_vrefresh(mode); + if (mode->flags & DRM_MODE_FLAG_INTERLACE) + bw /= 2; + for (j = 0; j < format->num_planes; j++) { + sub = j ? (format->vsub * format->hsub) : 1; + bandwidth += format->cpp[j] * bw / sub; + } + } + } + + /* add 20% safety margin */ + bandwidth = 5UL * bandwidth / 4; + + pr_info("exynos-mixer: safe bandwidth %ld Bps\n", bandwidth); + icc_set_bw(ctx->soc_path, 0, Bps_to_icc(bandwidth)); +} + static void mixer_atomic_begin(struct exynos_drm_crtc *crtc) { struct mixer_context *ctx = crtc->ctx; @@ -982,6 +1015,7 @@ static void mixer_atomic_flush(struct exynos_drm_crtc *crtc) if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags)) return; + mixer_set_memory_bandwidth(crtc); mixer_enable_sync(mixer_ctx); exynos_crtc_handle_event(crtc); } @@ -1029,6 +1063,7 @@ static void mixer_disable(struct exynos_drm_crtc *crtc) for (i = 0; i < MIXER_WIN_NR; i++) mixer_disable_plane(crtc, &ctx->planes[i]); + mixer_set_memory_bandwidth(crtc); exynos_drm_pipe_clk_enable(crtc, false); pm_runtime_put(ctx->dev); @@ -1220,12 +1255,22 @@ static int mixer_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; const struct mixer_drv_data *drv; struct mixer_context *ctx; + struct icc_path *path; int ret; + /* + * Returns NULL if CONFIG_INTERCONNECT is disabled. + * May return ERR_PTR(-EPROBE_DEFER). + */ + path = of_icc_get(dev, NULL); + if (IS_ERR(path)) + return PTR_ERR(path); + ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); if (!ctx) { DRM_DEV_ERROR(dev, "failed to alloc mixer context.\n"); - return -ENOMEM; + ret = -ENOMEM; + goto err; } drv = of_device_get_match_data(dev); @@ -1233,6 +1278,7 @@ static int mixer_probe(struct platform_device *pdev) ctx->pdev = pdev; ctx->dev = dev; ctx->mxr_ver = drv->version; + ctx->soc_path = path; if (drv->is_vp_enabled) __set_bit(MXR_BIT_VP_ENABLED, &ctx->flags); @@ -1242,17 +1288,29 @@ static int mixer_probe(struct platform_device *pdev) platform_set_drvdata(pdev, ctx); ret = component_add(&pdev->dev, &mixer_component_ops); - if (!ret) - pm_runtime_enable(dev); + if (ret < 0) + goto err; + + pm_runtime_enable(dev); + + return 0; + +err: + icc_put(path); return ret; } static int mixer_remove(struct platform_device *pdev) { - pm_runtime_disable(&pdev->dev); + struct device *dev = &pdev->dev; + struct mixer_context *ctx = dev_get_drvdata(dev); - component_del(&pdev->dev, &mixer_component_ops); + pm_runtime_disable(dev); + + component_del(dev, &mixer_component_ops); + + icc_put(ctx->soc_path); return 0; }