From patchwork Thu Sep 7 09:39:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hoegeun Kwon X-Patchwork-Id: 9941943 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 A487C602B3 for ; Thu, 7 Sep 2017 09:40:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D3B22654B for ; Thu, 7 Sep 2017 09:40:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81B0D285EF; Thu, 7 Sep 2017 09:40:16 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A482D2654B for ; Thu, 7 Sep 2017 09:40:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755240AbdIGJkO (ORCPT ); Thu, 7 Sep 2017 05:40:14 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:35881 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755084AbdIGJjQ (ORCPT ); Thu, 7 Sep 2017 05:39:16 -0400 Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20170907093914epoutp03974f7a8dbcfebbaef71cd3bd3b30af22~iCtlsEQeu1480414804epoutp03S; Thu, 7 Sep 2017 09:39:14 +0000 (GMT) Received: from epsmges2p4.samsung.com (unknown [182.195.40.69]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20170907093913epcas1p148e2d4f9d50c5c558000eb2a3827b58c~iCtkg2rqI1791917919epcas1p1S; Thu, 7 Sep 2017 09:39:13 +0000 (GMT) Received: from epcas2p3.samsung.com ( [182.195.41.55]) by epsmges2p4.samsung.com (Symantec Messaging Gateway) with SMTP id AD.D0.13866.1C311B95; Thu, 7 Sep 2017 18:39:13 +0900 (KST) Received: from epsmgms2p2new.samsung.com (unknown [182.195.42.143]) by epcas2p1.samsung.com (KnoxPortal) with ESMTP id 20170907093912epcas2p198ae12fc11fb2b8a7a9e8d6be817e796~iCtkFAghN1868618686epcas2p1q; Thu, 7 Sep 2017 09:39:12 +0000 (GMT) X-AuditID: b6c32a48-f79a16d00000362a-a5-59b113c1bfc5 Received: from epmmp2 ( [203.254.227.17]) by epsmgms2p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 31.B3.10338.0C311B95; Thu, 7 Sep 2017 18:39:12 +0900 (KST) Received: from localhost.localdomain ([10.113.63.38]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OVW0040KLH91X70@mmp2.samsung.com>; Thu, 07 Sep 2017 18:39:12 +0900 (KST) From: Hoegeun Kwon To: inki.dae@samsung.com, airlied@linux.ie, kgene@kernel.org, krzk@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, m.szyprowski@samsung.com Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Hoegeun Kwon Subject: [PATCH v2 3/3] drm/exynos/gsc: Add hardware rotation limits Date: Thu, 07 Sep 2017 18:39:03 +0900 Message-id: <1504777143-29834-4-git-send-email-hoegeun.kwon@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1504777143-29834-1-git-send-email-hoegeun.kwon@samsung.com> X-Brightmail-Tracker: H4sIAAAA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xRmJhlrMRcWJAKVMJZJ6AwAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrDLMWRmVeSWpSXmKPExsVy+t9jQd0DwhsjDT5P1rToPXeSyeL9sh5G i/lHzrFaXPn6ns3i/fIuNotJ9yewWPQ/fs1scf78BnaLTY+vsVpc3jWHzWLG+X1MFmuP3GW3 WHr9IpNF694j7BYvP55gceD3WDNvDaPHplWdbB7bvz1g9bjffZzJY/OSeo++LasYPT5vkgtg j+KySUnNySxLLdK3S+DKODBtP2PBfNOKQz8eMzUwftPsYuTkkBAwkfh49R0jiC0ksI5R4sPa yC5GLiD7O6PE2fvTmUASbAK6El97rjOBJEQEDjNKdL07ywjiMAtcZpRY1fMDrF1YwEWifecB li5GDg4WAVWJj/9UQcK8Ah4S+2e+Y4XYJidx8thkVpASTgFPiUdHTSAWe0gcfb+BZQIjzwJG hlWMkqkFxbnpucVGBUZ5qeV6xYm5xaV56XrJ+bmbGIFhuu2wVv8OxsdL4g8xCnAwKvHw7mDc ECnEmlhWXJl7iFGCg1lJhPchw8ZIId6UxMqq1KL8+KLSnNTiQ4zSHCxK4ryZfTMihQTSE0tS s1NTC1KLYLJMHJxSDYxT9AOLYwWZnuz73jxpZerpfezJ7P9c48y6/Fk3/5jQseHJtC3Tnmoa hPxabnyxos+0NvmD5FG9qGzJnLzf/rMSan0+hG0//6LPdW3egnfHsnQethkmX2Z3N/i1Jccs pEVRWTHxyMzMeWlTyiY+mtrjsvHaXSW1gNcr0362Pji/vi36WWCUHasSS3FGoqEWc1FxIgDl RKoZTwIAAA== X-CMS-MailID: 20170907093912epcas2p198ae12fc11fb2b8a7a9e8d6be817e796 X-Msg-Generator: CA X-Sender-IP: 182.195.42.143 X-Local-Sender: =?UTF-8?B?6raM7ZqM6re8G1RpemVuIFBsYXRmb3JtIExhYihTL1fshLw=?= =?UTF-8?B?7YSwKRvsgrzshLHsoITsnpAbRW5naW5lZXI=?= X-Global-Sender: =?UTF-8?B?SG9lZ2V1biBLd29uG1RpemVuIFBsYXRmb3JtIExhYi4bU2Ft?= =?UTF-8?B?c3VuZyBFbGVjdHJvbmljcxtFbmdpbmVlcg==?= X-Sender-Code: =?UTF-8?B?QzEwG1RFTEUbQzEwVjgxMTE=?= CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20170907093912epcas2p198ae12fc11fb2b8a7a9e8d6be817e796 X-RootMTR: 20170907093912epcas2p198ae12fc11fb2b8a7a9e8d6be817e796 References: <1504777143-29834-1-git-send-email-hoegeun.kwon@samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The gscaler has hardware rotation limits that need to be hardcoded into driver. Distinguish them and add them to the property list. The hardware rotation limits are related to the cropped source size. When swap occurs, use rot_max size instead of crop_max size. Also the scaling limits are related to pos size, use pos size to check the limits. Signed-off-by: Hoegeun Kwon --- drivers/gpu/drm/exynos/exynos_drm_gsc.c | 100 +++++++++++++++++++++++--------- include/uapi/drm/exynos_drm.h | 2 + 2 files changed, 73 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c b/drivers/gpu/drm/exynos/exynos_drm_gsc.c index 0506b2b..590a645 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c @@ -150,6 +150,15 @@ struct gsc_context { bool suspended; }; +/* + * struct gsc_driverdata - per device type driver data for init time. + * + * @rot_max: rotation max resolution. + */ +struct gsc_driverdata { + struct drm_exynos_sz rot_max; +}; + /* 8-tap Filter Coefficient */ static const int h_coef_8t[GSC_COEF_RATIO][GSC_COEF_ATTR][GSC_COEF_H_8T] = { { /* Ratio <= 65536 (~8:8) */ @@ -1401,6 +1410,23 @@ static int gsc_ippdrv_check_property(struct device *dev, bool swap; int i; + config = &property->config[EXYNOS_DRM_OPS_DST]; + + /* check for degree */ + switch (config->degree) { + case EXYNOS_DRM_DEGREE_90: + case EXYNOS_DRM_DEGREE_270: + swap = true; + break; + case EXYNOS_DRM_DEGREE_0: + case EXYNOS_DRM_DEGREE_180: + swap = false; + break; + default: + DRM_ERROR("invalid degree.\n"); + goto err_property; + } + for_each_ipp_ops(i) { if ((i == EXYNOS_DRM_OPS_SRC) && (property->cmd == IPP_CMD_WB)) @@ -1416,21 +1442,6 @@ static int gsc_ippdrv_check_property(struct device *dev, goto err_property; } - /* check for degree */ - switch (config->degree) { - case EXYNOS_DRM_DEGREE_90: - case EXYNOS_DRM_DEGREE_270: - swap = true; - break; - case EXYNOS_DRM_DEGREE_0: - case EXYNOS_DRM_DEGREE_180: - swap = false; - break; - default: - DRM_ERROR("invalid degree.\n"); - goto err_property; - } - /* check for buffer bound */ if ((pos->x + pos->w > sz->hsize) || (pos->y + pos->h > sz->vsize)) { @@ -1438,21 +1449,27 @@ static int gsc_ippdrv_check_property(struct device *dev, goto err_property; } + /* + * The rotation hardware limits are related to the cropped + * source size. So use rot_max size to check the limits when + * swap happens. And also the scaling limits are related to pos + * size, use pos size to check the limits. + */ /* check for crop */ if ((i == EXYNOS_DRM_OPS_SRC) && (pp->crop)) { if (swap) { if ((pos->h < pp->crop_min.hsize) || - (sz->vsize > pp->crop_max.hsize) || + (pos->h > pp->rot_max.hsize) || (pos->w < pp->crop_min.vsize) || - (sz->hsize > pp->crop_max.vsize)) { + (pos->w > pp->rot_max.vsize)) { DRM_ERROR("out of crop size.\n"); goto err_property; } } else { if ((pos->w < pp->crop_min.hsize) || - (sz->hsize > pp->crop_max.hsize) || + (pos->w > pp->crop_max.hsize) || (pos->h < pp->crop_min.vsize) || - (sz->vsize > pp->crop_max.vsize)) { + (pos->h > pp->crop_max.vsize)) { DRM_ERROR("out of crop size.\n"); goto err_property; } @@ -1463,17 +1480,17 @@ static int gsc_ippdrv_check_property(struct device *dev, if ((i == EXYNOS_DRM_OPS_DST) && (pp->scale)) { if (swap) { if ((pos->h < pp->scale_min.hsize) || - (sz->vsize > pp->scale_max.hsize) || + (pos->h > pp->scale_max.hsize) || (pos->w < pp->scale_min.vsize) || - (sz->hsize > pp->scale_max.vsize)) { + (pos->w > pp->scale_max.vsize)) { DRM_ERROR("out of scale size.\n"); goto err_property; } } else { if ((pos->w < pp->scale_min.hsize) || - (sz->hsize > pp->scale_max.hsize) || + (pos->w > pp->scale_max.hsize) || (pos->h < pp->scale_min.vsize) || - (sz->vsize > pp->scale_max.vsize)) { + (pos->h > pp->scale_max.vsize)) { DRM_ERROR("out of scale size.\n"); goto err_property; } @@ -1657,6 +1674,27 @@ static void gsc_ippdrv_stop(struct device *dev, enum drm_exynos_ipp_cmd cmd) gsc_write(cfg, GSC_ENABLE); } +static struct gsc_driverdata gsc_exynos5250_drvdata = { + .rot_max = { 2048, 2048 }, +}; + +static struct gsc_driverdata gsc_exynos5420_drvdata = { + .rot_max = { 2016, 2016 }, +}; + +static const struct of_device_id exynos_drm_gsc_of_match[] = { + { + .compatible = "samsung,exynos5250-gsc", + .data = &gsc_exynos5250_drvdata, + }, + { + .compatible = "samsung,exynos5420-gsc", + .data = &gsc_exynos5420_drvdata, + }, + { }, +}; +MODULE_DEVICE_TABLE(of, exynos_drm_gsc_of_match); + static int gsc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -1670,12 +1708,22 @@ static int gsc_probe(struct platform_device *pdev) return -ENOMEM; if (dev->of_node) { + const struct of_device_id *match; + struct gsc_driverdata *driver_data; + ctx->sysreg = syscon_regmap_lookup_by_phandle(dev->of_node, "samsung,sysreg"); if (IS_ERR(ctx->sysreg)) { dev_warn(dev, "failed to get system register.\n"); ctx->sysreg = NULL; } + + match = of_match_node(exynos_drm_gsc_of_match, dev->of_node); + if (!match) + return -ENODEV; + + driver_data = (struct gsc_driverdata *)match->data; + ctx->ippdrv.prop_list.rot_max = driver_data->rot_max; } /* clock control */ @@ -1784,12 +1832,6 @@ static int __maybe_unused gsc_runtime_resume(struct device *dev) SET_RUNTIME_PM_OPS(gsc_runtime_suspend, gsc_runtime_resume, NULL) }; -static const struct of_device_id exynos_drm_gsc_of_match[] = { - { .compatible = "samsung,exynos5-gsc" }, - { }, -}; -MODULE_DEVICE_TABLE(of, exynos_drm_gsc_of_match); - struct platform_driver gsc_driver = { .probe = gsc_probe, .remove = gsc_remove, diff --git a/include/uapi/drm/exynos_drm.h b/include/uapi/drm/exynos_drm.h index cb3e9f9..d5d5518 100644 --- a/include/uapi/drm/exynos_drm.h +++ b/include/uapi/drm/exynos_drm.h @@ -192,6 +192,7 @@ enum drm_exynos_planer { * @crop_max: crop max resolution. * @scale_min: scale min resolution. * @scale_max: scale max resolution. + * @rot_max: rotation max resolution. */ struct drm_exynos_ipp_prop_list { __u32 version; @@ -210,6 +211,7 @@ struct drm_exynos_ipp_prop_list { struct drm_exynos_sz crop_max; struct drm_exynos_sz scale_min; struct drm_exynos_sz scale_max; + struct drm_exynos_sz rot_max; }; /**