From patchwork Mon Aug 15 06:09:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ying Liu X-Patchwork-Id: 9280331 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 EBCA7600CB for ; Mon, 15 Aug 2016 06:09:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5C7228759 for ; Mon, 15 Aug 2016 06:09:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C8C352890A; Mon, 15 Aug 2016 06:09:50 +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=BAD_ENC_HEADER,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,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 1BC9328759 for ; Mon, 15 Aug 2016 06:09:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F17E16E37A; Mon, 15 Aug 2016 06:09:47 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0080.outbound.protection.outlook.com [104.47.33.80]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8D9986E379 for ; Mon, 15 Aug 2016 06:09:45 +0000 (UTC) Received: from BN3PR0301CA0027.namprd03.prod.outlook.com (10.160.180.165) by BY1PR0301MB0840.namprd03.prod.outlook.com (10.160.193.146) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.557.21; Mon, 15 Aug 2016 06:09:43 +0000 Received: from BN1BFFO11FD029.protection.gbl (2a01:111:f400:7c10::1:199) by BN3PR0301CA0027.outlook.office365.com (2a01:111:e400:4000::37) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.557.21 via Frontend Transport; Mon, 15 Aug 2016 06:09:42 +0000 Authentication-Results: spf=softfail (sender IP is 192.88.168.50) smtp.mailfrom=gmail.com; gmail.com; dkim=none (message not signed) header.d=none; gmail.com; dmarc=fail action=none header.from=gmail.com; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning gmail.com discourages use of 192.88.168.50 as permitted sender) Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1BFFO11FD029.mail.protection.outlook.com (10.58.144.92) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.567.7 via Frontend Transport; Mon, 15 Aug 2016 06:09:43 +0000 Received: from victor.ap.freescale.net (victor.ap.freescale.net [10.192.241.62]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id u7F69cI5004791; Sun, 14 Aug 2016 23:09:39 -0700 From: Liu Ying To: Subject: [PATCH] drm/imx: Add active primary plane reconfiguration support Date: Mon, 15 Aug 2016 14:09:13 +0800 Message-ID: <1471241353-26269-1-git-send-email-gnuiyl@gmail.com> X-Mailer: git-send-email 2.7.4 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131157149837796380; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(199003)(189002)(81442002)(76482005)(97736004)(61266001)(47776003)(106466001)(73972006)(50986999)(87572001)(105596002)(356003)(7846002)(305945005)(81166006)(68736007)(87936001)(19580395003)(229853001)(8676002)(81156014)(50226002)(19580405001)(83322999)(73392002)(48376002)(55446002)(110136002)(8936002)(50466002)(6260500002)(33646002)(77096005)(189998001)(2351001)(86362001)(575784001)(5003940100001)(82202001)(104016004)(92566002)(626004)(2906002)(4326007)(586003)(36756003); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR0301MB0840; H:tx30smr01.am.freescale.net; FPR:; SPF:SoftFail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD029; 1:4Fi1W4j+k2lbdWfKT3H3AKJtTJy3gMwnOMOcZl6p2K02Ww4QUtZnA4BsWNk1IbWWiJyOaLLXwXy2xqBlU3oH1Tk8f16Wh54TqSff/60BnkNCAAqlf4ewepEBEcPK9lzIAKo8W24rthaiC1JKffsFDpbdQkKqNxhmycgS+jmRAIY/s3B7jSQuE7NVi2xPH7rbH1ef1KJzDhPhUuVrbK5ulstat+joSC/QXCsPoiId0j5kgap+uKzAWbz0MJfDts0ansNE0tVzROCkGyiwgQE8GjaTdpuW44pUlHi7nTuvyI5i2Op6rGFXQRtolDaOgkJw4X/4dGmceSpaF/mRn+hEHYs0IpjjvtoH/c7TqtEbsSHukhZzFlbF4/95LpT4bYMxqPQD0hStfrRYvMfqbEqTKSPJXRAOmE24KKVhzyvY8YgnM9kEyPp6nxl94OhQSGB9O/G7JI9aUTwH/bkowZhX9Q+Yi7a/QjvcjWTZbCvAEzbhWe8/hA2Z2olfTJHa4B+9E1Jf3g5a3Y1eT1HSZ5Wbx/U5yndeGMc6s+unqPYS+CJAnO+QyhSOr9KfkgvQBLcjEJFCOfLhW6E3/ngGjnRW+hs1/G3MmKbQeVC+J0iGo99b1AX5nDdz1u/7E4//IInyAKemCiYN9/5PGEGzW4hNrQ== MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 03c6539b-f177-48c3-42bd-08d3c4d2c04a X-Microsoft-Exchange-Diagnostics: 1; BY1PR0301MB0840; 2:SmjjkEEMXdwPkiCt18SL2F1iPsm9jQzDWKHc5xWE2qpupwVDpQ7SM8rZD6kESyiOiZLIoNk+Guz9CYq2cXFiu+LahIgB5hEHBeV0Ot9/fM2PyNDSYkaligAVOjV56y2L52JSwDGX6Cpl+W0BU+WbxAIPU3uKsJDqlgMX6pGHbgODqTJh4nE8MoHvLd2vGxK1; 3:Vh4HnYNJnYrKJYyACclqxC/x3Fq+akLzNPlv5GVgO+Cz2GiWCG6ZkHx4YV1+Xh8lSqvBnKdkMKQuHB7EBZIlfBeY0JMoIcVbyw8QGL52SSnYlyot2hHQmeg4L/YQHejh4gVLrbckYFZ4CuPomQejkDw7AZqRq36vnk9ctZVG+7+lMmel5lQFyeqKXgcrIhzy2xYelouDQUPBxqXjXaT3E+paBVbizD7XjOdzk59gQO0=; 25:Nba6oHJ0gkg66MiBvmhqqH/MBqedfjetcZFtuGMB+XBgPrkOSJuDu8xM/eYcogkyUyj6a+NCWY3l0MYhrGrSLR8CnTl321Q63qdDa8jQVpqtm7R7sRH003bo0mje+p/Dt7hPldBA/QDVUmtDPsdLsop/RdB04Vk4BTAy8n4p+mstb0QEcARxwmb7kNr/k2H6H9uQvUmRBI+tHN433e8Ge7lIMBvdwalb3y34kvnKojzFAoXx4IkoZWs722huLPUcCxGhnx2q5EFOt2dsPCX8zin0IzZXhQbP4HKEvg29bRdPekZMesG7y9PoDTdVnmlrUKBbb+jjfc77tXqbQLiRa5wc6TZGJP8Xt8R/zOherJqvej03gViu273de9Cc4bM3Al9Y3yb55r5L9BPyvB1RdM2ozQKj0BErDiloLN2R4X8= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0301MB0840; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0301MB0840; 31:xOyoaFLFkRP/1lMb0DgxLFr3BUrHfA6wRYsRpAQRlLHejEvfZLku2r/hoInCfYjO7LgyU/0UrXxWBmDN5fhHafWQx/SHNNxVyi6p049qNFVncpN3jWLQy2SawjGYA8ahHA7qis/QNKEsq85kO9AA6Q01z0zaNIzZzIDjj3wYMTpwbxZr1QoUM0GMCM+BsDFGVLakDYnyl59U5eh12l2vy4aqL4LrgB17v0A3PpZInpM=; 4:APbf2SEtygrAAtNArMXFHBz9hDBevtyeLprd+tVdd/yrL9JTBztyHVb8LmjB4OMeXEX0LhBADcwf1pwzgWPySeDD8AUwK3pl3Suh7vzN6U/oPIN5YhrJK6vdfs0PNb67IXw6r+pq4DH2GnOBjDB9QbDVbTKiUd9SAEKka6Ve+GrnbnwQfW3b6lvkl4M0JVI1ttHMkhDeWTvrMkh8Pq+P0rUt7uBa7lZ/Yculcgk3HOQ/5DBgrIOC1G0JX+k+3R7mosR7okuOFNsbOQtJxC7d9z3AMoaXP7zDfIwo4RMvb5TKL4yNxX+/gMtfCjk4GgQFx4kcmB76Jm272FQcXZSpWQ79S2IY1R2FySupWrNS7x1yjxfVaGn+/toY6hgpnQA0BCNmsN9i2mm5ioBcyx1graDOnkYc45Qe3KOWKKYmFFkcp0Hsp2wDeHzkoS+8sZWqY+rrcAqVMJE0l1SKStFfqTMGzCpWKWYbkbSS2DdMmAYVIrhkC4JE6acdkBw7lCao X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(13018025)(13023025)(13024025)(13017025)(13015025)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:BY1PR0301MB0840; BCL:0; PCL:0; RULEID:(400006); SRVR:BY1PR0301MB0840; X-Forefront-PRVS: 0035B15214 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY1PR0301MB0840; 23:+S1GXZW6JlfLdo8uYsLQK6uv43+gL+dE4YKJaE+?= =?us-ascii?Q?WIPRjKiIblUHlkUu14NMcBs1+8xC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tr41yhaiJo2nTR8++L6imIPLZAIYCx7Nqe+3zzj+JxK3YCe0NCXcCUF2Na4ZI/WaODHcLL+1cPRsAj6sXLQXV5C/PcOTqi449bjihs2AugLAAA7WUEHAkkoq1Pa0b28CjA9ApUo9mS6Wq6qzGZDozQhllHI SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2016 06:09:43.5924 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0301MB0840 Cc: Daniel Vetter , Peter Senna Tschudin , Russell King 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 We don't support configuring active primary plane on-the-fly for imx-drm. The relevant CRTC should be disabled before the plane configuration. Of course, the plane itself should be disabled as well. For overlay plane, we currently reject active plane reconfiguration. This patch adds active plane reconfiguration support by forcing CRTC mode change and disabling-enabling plane in plane's ->atomic_update callback. Suggested-by: Daniel Vetter Cc: Philipp Zabel Cc: David Airlie Cc: Russell King Cc: Daniel Vetter Cc: Peter Senna Tschudin Signed-off-by: Liu Ying --- drivers/gpu/drm/imx/imx-drm-core.c | 26 +++++++++++++++++++++- drivers/gpu/drm/imx/ipuv3-plane.c | 44 +++++++++++++++++++++++++++++--------- 2 files changed, 59 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c index 6dc0ef4..c10c3ea 100644 --- a/drivers/gpu/drm/imx/imx-drm-core.c +++ b/drivers/gpu/drm/imx/imx-drm-core.c @@ -147,10 +147,34 @@ static void imx_drm_output_poll_changed(struct drm_device *drm) drm_fbdev_cma_hotplug_event(imxdrm->fbhelper); } +static int imx_drm_atomic_check(struct drm_device *dev, + struct drm_atomic_state *state) +{ + int ret; + + ret = drm_atomic_helper_check_modeset(dev, state); + if (ret) + return ret; + + ret = drm_atomic_helper_check_planes(dev, state); + if (ret) + return ret; + + /* + * Check modeset again in case crtc_state->mode_changed is + * updated in plane's ->atomic_check callback. + */ + ret = drm_atomic_helper_check_modeset(dev, state); + if (ret) + return ret; + + return ret; +} + static const struct drm_mode_config_funcs imx_drm_mode_config_funcs = { .fb_create = drm_fb_cma_create, .output_poll_changed = imx_drm_output_poll_changed, - .atomic_check = drm_atomic_helper_check, + .atomic_check = imx_drm_atomic_check, .atomic_commit = drm_atomic_helper_commit, }; diff --git a/drivers/gpu/drm/imx/ipuv3-plane.c b/drivers/gpu/drm/imx/ipuv3-plane.c index 4ad67d0..d4dde4a 100644 --- a/drivers/gpu/drm/imx/ipuv3-plane.c +++ b/drivers/gpu/drm/imx/ipuv3-plane.c @@ -319,13 +319,21 @@ static int ipu_plane_atomic_check(struct drm_plane *plane, return -EINVAL; /* - * since we cannot touch active IDMAC channels, we do not support - * resizing the enabled plane or changing its format + * For primary plane, we support resizing active plane or changing + * its format by forcing CRTC mode change and disabling-enabling plane + * in plane's ->atomic_update callback. + * For overlay plane, we currently reject the active plane resizing + * or format change. */ if (old_fb && (state->src_w != old_state->src_w || state->src_h != old_state->src_h || - fb->pixel_format != old_fb->pixel_format)) - return -EINVAL; + fb->pixel_format != old_fb->pixel_format)) { + if (plane->type == DRM_PLANE_TYPE_PRIMARY) { + crtc_state->mode_changed = true; + } else { + return -EINVAL; + } + } eba = drm_plane_state_to_eba(state); @@ -335,8 +343,13 @@ static int ipu_plane_atomic_check(struct drm_plane *plane, if (fb->pitches[0] < 1 || fb->pitches[0] > 16384) return -EINVAL; - if (old_fb && fb->pitches[0] != old_fb->pitches[0]) - return -EINVAL; + if (old_fb && fb->pitches[0] != old_fb->pitches[0]) { + if (plane->type == DRM_PLANE_TYPE_PRIMARY) { + crtc_state->mode_changed = true; + } else { + return -EINVAL; + } + } switch (fb->pixel_format) { case DRM_FORMAT_YUV420: @@ -371,8 +384,13 @@ static int ipu_plane_atomic_check(struct drm_plane *plane, if (fb->pitches[1] < 1 || fb->pitches[1] > 16384) return -EINVAL; - if (old_fb && old_fb->pitches[1] != fb->pitches[1]) - return -EINVAL; + if (old_fb && old_fb->pitches[1] != fb->pitches[1]) { + if (plane->type == DRM_PLANE_TYPE_PRIMARY) { + crtc_state->mode_changed = true; + } else { + return -EINVAL; + } + } } return 0; @@ -392,8 +410,14 @@ static void ipu_plane_atomic_update(struct drm_plane *plane, enum ipu_color_space ics; if (old_state->fb) { - ipu_plane_atomic_set_base(ipu_plane, old_state); - return; + struct drm_crtc_state *crtc_state = state->crtc->state; + + if (!crtc_state->mode_changed) { + ipu_plane_atomic_set_base(ipu_plane, old_state); + return; + } + + ipu_disable_plane(plane); } switch (ipu_plane->dp_flow) {