From patchwork Wed Sep 13 11:41:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hoegeun Kwon X-Patchwork-Id: 9951195 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 B014B6024A for ; Wed, 13 Sep 2017 11:42:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A22FA28EE2 for ; Wed, 13 Sep 2017 11:42:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 966D028EEF; Wed, 13 Sep 2017 11:42:36 +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 029C428EE2 for ; Wed, 13 Sep 2017 11:42:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751923AbdIMLmb (ORCPT ); Wed, 13 Sep 2017 07:42:31 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:41004 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751545AbdIMLmR (ORCPT ); Wed, 13 Sep 2017 07:42:17 -0400 Received: from epcas1p3.samsung.com (unknown [182.195.41.47]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20170913114215epoutp04f1c5a79523b6ce78bee00dd9aceb125b~j6Qt6gAIz0267902679epoutp04T; Wed, 13 Sep 2017 11:42:15 +0000 (GMT) Received: from epsmges2p1.samsung.com (unknown [182.195.40.67]) by epcas1p2.samsung.com (KnoxPortal) with ESMTP id 20170913114215epcas1p2a329bd170d799454d5065421b10bb50a~j6Qtnxmju0176601766epcas1p2J; Wed, 13 Sep 2017 11:42:15 +0000 (GMT) Received: from epcas2p2.samsung.com ( [182.195.41.54]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id 80.DB.10950.79919B95; Wed, 13 Sep 2017 20:42:15 +0900 (KST) Received: from epsmgms2p2new.samsung.com (unknown [182.195.42.143]) by epcas2p1.samsung.com (KnoxPortal) with ESMTP id 20170913114215epcas2p17ade0c243f3b9cfeaec5175ba6747885~j6QtM_Fl72541825418epcas2p1P; Wed, 13 Sep 2017 11:42:15 +0000 (GMT) X-AuditID: b6c32a45-f79466d000002ac6-e6-59b91997f540 Received: from epmmp1.local.host ( [203.254.227.16]) by epsmgms2p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 48.99.10338.69919B95; Wed, 13 Sep 2017 20:42:15 +0900 (KST) Received: from localhost.localdomain ([10.113.63.38]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OW7004DTV6CH850@mmp1.samsung.com>; Wed, 13 Sep 2017 20:42:14 +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, robin.murphy@arm.com Cc: dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, a.hajda@samsung.com, Hoegeun Kwon Subject: [PATCH v4 3/4] drm/exynos/gsc: Add hardware rotation limits Date: Wed, 13 Sep 2017 20:41:54 +0900 Message-id: <1505302915-15699-4-git-send-email-hoegeun.kwon@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1505302915-15699-1-git-send-email-hoegeun.kwon@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpkk+LIzCtJLcpLzFFi42LZdljTTHe65M5Ig21vFSxurTvHatF77iST xftlPYwW848AuVe+vmezeL+8i81i0v0JLBb9j18zW5w/v4HdYtPja6wWl3fNYbPo2bCV1WLG +X1MFmuP3GW3WHr9IpPFsk1/mCxa9x5htzj44QmrxeE37awWLz+eYHEQ8Vgzbw2jx6ZVnWwe 2789YPW4332cyWPzknqPvi2rGD0+b5ILYI9KtclITUxJLVJIzUvOT8nMS7dV8g6Od443NTMw 1DW0tDBXUshLzE21VXLxCdB1y8wBekhJoSwxpxQoFJBYXKykb2dTlF9akqqQkV9cYqsUbWho pGdoYK5nZGSkZ2Ica2VkClSSkJrRfPM2c8ER84q2PyfZGxj/aXcxcnJICJhITHrRxgZhi0lc uLceyObiEBLYwSjR8amNHcL5zigx620nC0zH2aUPWSASuxklds5dwAhXNf/JESaQKjYBXYmv PdeZQBIiAu1MEktOvGAGcZhBnIfnNrCDVAkLuEjsfLONFcRmEVCV+HDgMVg3r4CHxLyND6Cu kpM4eWwyWA2ngKfEsq4JYOskBL6zScxYvQbI4QByXCQWrBKCqBeWeHV8CzuELS3xbNVGRgi7 XuLyjpNQvQ2MEv0TZ0MVGUuc6moEW8wswCfRcfgvO8RMXomONqiZHhK/+ncxQ9iOEq9WzWSF eHkOo0T3xR7WCYzSCxgZVjGKpRYU56anFhsVGOoVJ+YWl+al6yXn525iBCc/LdcdjDPO+Rxi FOBgVOLhXXFne6QQa2JZcWXuIUYJDmYlEV4m/p2RQrwpiZVVqUX58UWlOanFhxhNgWEzkVlK NDkfmJjzSuINTSwNTMzMjMzNLICJQ5y3ftu1CCGB9MSS1OzU1ILUIpg+Jg5OqQbGppL065GJ 5TNSviX2y08OiVzuG1W1kz1LXqH405a7E09LLTDKPxtyZt+sCXuXqalW+F75XfJAs1aMe6p5 wd6GDR/PVZS9vezfw3V7TTy3OYO3zWzWygcZS4pXhz4112S1ePTI6PDVJWa1ja+0Qg+VCU14 eLtfYtuaqKiJOVp+0wReeebavdZSYinOSDTUYi4qTgQAvwAeQJQDAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrBLMWRmVeSWpSXmKPExsVy+t9jAd3pkjsjDR62cljcWneO1aL33Ekm i/fLehgt5h8Bcq98fc9m8X55F5vFpPsTWCz6H79mtjh/fgO7xabH11gtLu+aw2bRs2Erq8WM 8/uYLNYeuctusfT6RSaLZZv+MFm07j3CbnHwwxNWi8Nv2lktXn48weIg4rFm3hpGj02rOtk8 tn97wOpxv/s4k8fmJfUefVtWMXp83iQXwB7FZZOSmpNZllqkb5fAldF88zZzwRHzirY/J9kb GP9pdzFyckgImEicXfqQpYuRi0NIYCejxJHzW6Gc74wSkzc8YAepYhPQlfjac50JJCEi0M4k 8fLvfTCHGcSZefslWJWwgIvEzjfbWEFsFgFViQ8HHjOB2LwCHhLzNj5gg9gnJ3Hy2GSwGk4B T4llXRMYQWwhoJpXB9eyT2DkWcDIsIpRMrWgODc9t9iowCgvtVyvODG3uDQvXS85P3cTIzC8 tx3W6t/B+HhJ/CFGAQ5GJR7eFXe2RwqxJpYVV+YeYpTgYFYS4WXi3xkpxJuSWFmVWpQfX1Sa k1p8iFGag0VJnDezb0akkEB6YklqdmpqQWoRTJaJg1OqgdHo9UPbLZG3fzicvr3Bt/3s96VM GTcXPz0hZRO+30Fm2jwZM8nNb4QszE51X/xazjWjw8FDlWNHxk2znqfN1i5BieeKDtecOv1u gc3F9xK2sz6o7PiUsu6S7P/mz5lGu08rbb0osdbKrcGrYZ9vybSWsj0iPifs17H9CKo7uNVy JT9LtqhIaZQSS3FGoqEWc1FxIgAkWwp5awIAAA== X-CMS-MailID: 20170913114215epcas2p17ade0c243f3b9cfeaec5175ba6747885 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: 20170913114215epcas2p17ade0c243f3b9cfeaec5175ba6747885 X-RootMTR: 20170913114215epcas2p17ade0c243f3b9cfeaec5175ba6747885 References: <1505302915-15699-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 | 104 +++++++++++++++++++++++--------- include/uapi/drm/exynos_drm.h | 2 + 2 files changed, 77 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..66a19d7 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,42 @@ 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 struct gsc_driverdata gsc_exynos5_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, + }, + { + .compatible = "samsung,exynos5-gsc", + .data = &gsc_exynos5_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); @@ -1723,6 +1771,10 @@ static int gsc_probe(struct platform_device *pdev) return ret; } + ctx->ippdrv.prop_list.rot_max = drv_data->rot_max; + if (drv_data == &gsc_exynos5_drvdata) + dev_info(dev, "compatible 'exynos5-gsc' is deprecated\n"); + DRM_DEBUG_KMS("id[%d]ippdrv[%pK]\n", ctx->id, ippdrv); mutex_init(&ctx->lock); @@ -1784,12 +1836,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; }; /**