From patchwork Fri Sep 8 06:02:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hoegeun Kwon X-Patchwork-Id: 9943201 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 77916600CB for ; Fri, 8 Sep 2017 06:03:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69CED284C7 for ; Fri, 8 Sep 2017 06:03:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E88228501; Fri, 8 Sep 2017 06:03:20 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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 E171F284C7 for ; Fri, 8 Sep 2017 06:03:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 62B916EA7B; Fri, 8 Sep 2017 06:03:14 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9A38B6EA75 for ; Fri, 8 Sep 2017 06:03:11 +0000 (UTC) Received: from epcas1p1.samsung.com (unknown [182.195.41.45]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20170908060309epoutp019ced40f7b048d6fbb6821290fd9e96da~iTaNkrp7-1786417864epoutp015; Fri, 8 Sep 2017 06:03:09 +0000 (GMT) Received: from epsmges1p1.samsung.com (unknown [182.195.40.67]) by epcas1p3.samsung.com (KnoxPortal) with ESMTP id 20170908060309epcas1p357a9cf8dbad74aee8d7cdcc560903fb1~iTaNFH5hS1585615856epcas1p3c; Fri, 8 Sep 2017 06:03:09 +0000 (GMT) Received: from epcas1p4.samsung.com ( [182.195.41.48]) by epsmges1p1.samsung.com (Symantec Messaging Gateway) with SMTP id 87.97.22848.D9232B95; Fri, 8 Sep 2017 15:03:09 +0900 (KST) Received: from epsmgms2p1new.samsung.com (unknown [182.195.42.142]) by epcas1p3.samsung.com (KnoxPortal) with ESMTP id 20170908060308epcas1p3016314e10d2ba9fb5129cd2b398086f4~iTaM3Bown0913909139epcas1p3L; Fri, 8 Sep 2017 06:03:08 +0000 (GMT) X-AuditID: b6c32a35-f798c6d000005940-4b-59b2329d1956 Received: from epmmp2 ( [203.254.227.17]) by epsmgms2p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 64.25.11757.C9232B95; Fri, 8 Sep 2017 15:03:08 +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 <0OVY00KW1655VA30@mmp2.samsung.com>; Fri, 08 Sep 2017 15:03:08 +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, mchehab@kernel.org, s.nawrocki@samsung.com, m.szyprowski@samsung.com Subject: [PATCH v3 3/6] drm/exynos/gsc: Add hardware rotation limits Date: Fri, 08 Sep 2017 15:02:37 +0900 Message-id: <1504850560-27950-4-git-send-email-hoegeun.kwon@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1504850560-27950-1-git-send-email-hoegeun.kwon@samsung.com> X-Brightmail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6vVpX6pnE/Paund9N3oep9NSIYdjYiU2gfsDtM0p6YsDAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrELMWRmVeSWpSXmKPExsVy+t9jQd05RpsiDTZ1G1vcWneO1aL33Ekm i/fLehgt5h8Bcq98fc9m8X55F5vFpPsTWCz6H79mtjh/fgO7xabH11gtLu+aw2bRs2Erq8WM 8/uYLNYeuctusfT6RSaLZZv+MFm07j3CbnH4TTurxcuPJ1gchD3WzFvD6LFpVSebx/ZvD1g9 7ncfZ/LYvKTeo2/LKkaPz5vkAtijuGxSUnMyy1KL9O0SuDJm9+9kL9hnWtHx7BF7A+MKrS5G Tg4JAROJjd1n2boYuTiEBNYxSjzashrK+c4osfroDUaQKjYBXYmvPdeZQBIiAh8ZJZ6tb2QH cZgF2pkkZt5+CeRwcAgLuEi87WUDaWARUJVoPXCHGcTmFfCQmHR5LivEOjmJk8cmg9mcAp4S rfcvgS0QAqrZc3ox+wRGngWMDKsYJVMLinPTc4uNCgzzUsv1ihNzi0vz0vWS83M3MQJDetth rb4djPeXxB9iFOBgVOLhtQjeGCnEmlhWXJl7iFGCg1lJhPe/7qZIId6UxMqq1KL8+KLSnNTi Q4zSHCxK4ryZfTMihQTSE0tSs1NTC1KLYLJMHJxSDYycojw71ktFfhMMWqP/Np0htH9+hDDj 2bmsRxd53v9/2bxz+amt5RZnf91r9lVQjvzpaP7g56OCLpPz68M4F/vn3am4zh1rLZgcemHb qT+hrSY9R1JYt1ypKBf6Nct7PY9VxhaHcwkR/ZnnZ7ds4HrpuKske8+XKfya+/9M13N8efjU xBQ/oTlKLMUZiYZazEXFiQAbIKwVZQIAAA== X-CMS-MailID: 20170908060308epcas1p3016314e10d2ba9fb5129cd2b398086f4 X-Msg-Generator: CA X-Sender-IP: 182.195.42.142 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: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20170908060308epcas1p3016314e10d2ba9fb5129cd2b398086f4 X-RootMTR: 20170908060308epcas1p3016314e10d2ba9fb5129cd2b398086f4 References: <1504850560-27950-1-git-send-email-hoegeun.kwon@samsung.com> Cc: devicetree@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Hoegeun Kwon , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org 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: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 | 93 +++++++++++++++++++++++---------- include/uapi/drm/exynos_drm.h | 2 + 2 files changed, 66 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..a4fb347 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -150,6 +151,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 +1411,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 +1443,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 +1450,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 +1481,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,12 +1675,34 @@ 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; struct gsc_context *ctx; struct resource *res; struct exynos_drm_ippdrv *ippdrv; + const struct gsc_driverdata *drv_data = of_device_get_match_data(dev); int ret; ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); @@ -1722,6 +1762,7 @@ static int gsc_probe(struct platform_device *pdev) dev_err(dev, "failed to init property list.\n"); return ret; } + ctx->ippdrv.prop_list.rot_max = drv_data->rot_max; DRM_DEBUG_KMS("id[%d]ippdrv[%pK]\n", ctx->id, ippdrv); @@ -1784,12 +1825,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; }; /**