From patchwork Tue May 18 09:50:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quanyang Wang X-Patchwork-Id: 12264489 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28E9AC433ED for ; Tue, 18 May 2021 10:13:37 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8182061185 for ; Tue, 18 May 2021 10:13:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8182061185 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=windriver.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=GnncOlWDRoaVZqMId+beApbg8G6587+V3oqs/jBDCP4=; b=ZJyVoL4pvYz9jPgMF2FEk9Nf2 YnLY6j/MRDMLBmuNgqPWUQgH8MRtJsfuswCy3h4qj68CM1AqvnNhKq7AOczrTPCmno4t5+nSSS2jF V5uFMmyEqGlCWJ3v9A6Js1jDvfP67WsPRU+NL52svUPI0nv5gg9k4c6TbIm0Davatr+v73WiVebw/ DrOsIlk1k6deJZe8qzDWsRWR1/ip9rtm7Q1P3rsSGeEa41s4h8M96BrkJxz5QHUc9eFwtd+uKSq5h cEgL/V4BYUZsbmXQs6m9rDeDe1yEIJpSyDcFi8tlBec6n2Q0cJxkBUw5bsGsGYd4gy5Cl9ogaOPsq m8B8s+3Ow==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1liwhU-000IcM-5n; Tue, 18 May 2021 10:11:44 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1liwOg-000Erp-8m for linux-arm-kernel@desiato.infradead.org; Tue, 18 May 2021 09:52:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=XpLMGnRiM4QTatSPLhHZrQ6zkkFDM3we1bXF5Wg4DJA=; b=4K0p/joF8opSMxNpgC2rv5rSfK P5J7Qhwa8x0Xre8Z/bPAxO+geiX9fhwbJvorNUeDs3E2+qZ1/hKpDal+c3tVetnT/5u48GSxLJNr4 iLKX8mNTOBK45H8Roah9xECXIxR2ccVsiIBnmgvtHW9j1oYndeAT+WWEWk++zpg42LKu0Y04arCfF XXKkp9oLP+WEUaCA7og+gelCjsYYiFMvHepsLOHe1YwKbKkGGM0SqUjiJr0HmvfNPTzxqnaL2DhBR mdlOQBrPOi1NfKePNmrXxc1eyeVYDEsXRaRWg1OeDdyF92IJ3j0BZ+F92dCxAEMeghuCSPzvS6MqT J996diAg==; Received: from mail-dm6nam11on2071.outbound.protection.outlook.com ([40.107.223.71] helo=NAM11-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1liwOd-00EWy9-CD for linux-arm-kernel@lists.infradead.org; Tue, 18 May 2021 09:52:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JHwww/bP2YBPaLLShsGdZ5W9lDtjH6z/Sw2kIe1FhG9zOO1wDlRrnSJcuwIDlG10thwBSTME2ltfAVunNfGZN6QTWKl3dXEMuNqpJ5i9ImGbFeu+Ut6HHoydNNTRAa942bz/RwqQwjN7456oCmF5lQWWTtwmbsMcjWYY1Q1x4uqhOd49+evFavQG1CehelnqXc8wZ6teLkpSF3zYoxOpoLnpUTxFo2Xr0QYqmaiq3F7C+S4RXhRmW0/9d4SPkVo9r0naWXa2OQEjBTSkLMAzHDlUurjXWwGqd2eLiwwtBn1m2YjF83lSVGiMp2SBc7eMjXXI/qKi5fk1FeGuRThRsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XpLMGnRiM4QTatSPLhHZrQ6zkkFDM3we1bXF5Wg4DJA=; b=D3R0xEA6PtIPh9dsoZ/voP257+3HyXvpMxVpz0vo0dnTRemvwRQ0FsX3WLQZV/kKr14v4vZ0Xp4nycQLcdkwmWrFivb3X4NSF243Jv41TzEjk4bVXlJbIWwe4KGP4IAyUwUoIaFS8zxdLYWapJ9b4jWDI8TL2R/PzHt8yS7spfrdsjgxRzIGQ/cqy6lIWdE6hZE0tfBSHBhLjMzYVYAB+nsqG41NqBjYXNZ0OraPZ0Q0dkkZOJ+1iUrWPEnYTiOflYvcJVBTnEljkeayI+NfrqJpn59/Lf1qV4nwMqJwxdgSsy8zM6Rjr1/ycuhi6U3udLXBeZXYlzwCK76THr7xnA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriversystems.onmicrosoft.com; s=selector2-windriversystems-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XpLMGnRiM4QTatSPLhHZrQ6zkkFDM3we1bXF5Wg4DJA=; b=Exee+QLOf3Fq8wu0ktC7dLtyxkhf4r/QHRfX4FlCEYC4cjgzus5430Jo1af5s+hG9rp+YMInmXtcllUBtCizq1n9Kz8VcF0eCic2AIh8d0lPkR7h4qAAeNIQwmu8OdBskLL4PMCmaqILs6Dw+OA1a4aqyzDGsu2ChPURL6hWoAA= Authentication-Results: crapouillou.net; dkim=none (message not signed) header.d=none;crapouillou.net; dmarc=none action=none header.from=windriver.com; Received: from DM5PR11MB0075.namprd11.prod.outlook.com (2603:10b6:4:6c::16) by DM6PR11MB3082.namprd11.prod.outlook.com (2603:10b6:5:6b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.26; Tue, 18 May 2021 09:52:13 +0000 Received: from DM5PR11MB0075.namprd11.prod.outlook.com ([fe80::7cf5:4b57:4804:20bf]) by DM5PR11MB0075.namprd11.prod.outlook.com ([fe80::7cf5:4b57:4804:20bf%5]) with mapi id 15.20.4129.031; Tue, 18 May 2021 09:52:13 +0000 From: quanyang.wang@windriver.com To: Paul Cercueil , Hyun Kwon , Laurent Pinchart , David Airlie , Daniel Vetter , Michal Simek Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Quanyang Wang Subject: [V2][PATCH 1/2] drm: xlnx: add is_layer_vid() to simplify the code Date: Tue, 18 May 2021 17:50:18 +0800 Message-Id: <20210518095019.3855369-2-quanyang.wang@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210518095019.3855369-1-quanyang.wang@windriver.com> References: <20210518095019.3855369-1-quanyang.wang@windriver.com> X-Originating-IP: [60.247.85.82] X-ClientProxiedBy: HK2PR04CA0090.apcprd04.prod.outlook.com (2603:1096:202:15::34) To DM5PR11MB0075.namprd11.prod.outlook.com (2603:10b6:4:6c::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pek-qwang2-d1.wrs.com (60.247.85.82) by HK2PR04CA0090.apcprd04.prod.outlook.com (2603:1096:202:15::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.35 via Frontend Transport; Tue, 18 May 2021 09:52:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2111573d-4606-49fe-8147-08d919e29cc9 X-MS-TrafficTypeDiagnostic: DM6PR11MB3082: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: m2uvKgKvvlVWK8Inok69DG/wGrA7I9sXv9BdmczEjH0mlDu53CL96x96xeLy+bk5xdgmWBIjbFBqkKGasVbVFQ7ferr9JFRHCASxCxKKgRuEQ+y33jk/cQzUt580nu+MKlROgt8wbO/HD32F3G6tG64nLh8xxWW6066+6+O5wYXfKnwE8KV95irU+VeJpSq4y8ooloSz/zWMRQnu+BLYRrDaMpGged5uYKYkdx4ArcVWlB6dNgYlDvIholL7M954rNlWSlO2NYRR1zF7s+NVUDY7q0Yy7jhoZus4z4nroxQvjqZMy0kHYhsHAx2ZAIc+ns6pai3kWv0WIAoEDo/7wY7f8dKAfnxkYBBkX9B/NVtyrOoo2DGtD3sHkfYrCqU+mEj0+8yPHigyUDYk7mtBPm4VPzSujmhEsqpirwu6y5iFDMKanzbLd+IwW6hy0B/w0iAokqM8pZ9g3hhmJQehUD2glP9kjx4Rg45hSh7YTZ7ZA5sEzwtr+9oz3F+cU+hxhRfiCkdW2cR8MdQ9jRBy+QGMXxQzyYZIuhQBO9nhDO5+zEmaitAn+ewe+WprfjYqXc09xx7ppRuNc/l3BrlArN0AQLGaLwwYRUr9NVze9ZGIFDLD9G8mCcYLUoSgNSkzuxBKs0VLeOsLNxeRUUYi6gPT3oCRIHH9H1NJ86WkiKQ= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR11MB0075.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(346002)(136003)(396003)(366004)(39850400004)(66556008)(52116002)(83380400001)(66946007)(66476007)(110136005)(38350700002)(478600001)(8936002)(5660300002)(38100700002)(6486002)(316002)(2906002)(2616005)(6512007)(9686003)(186003)(956004)(4326008)(1076003)(16526019)(36756003)(107886003)(8676002)(26005)(86362001)(6506007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: sYv56vXyakjx9dSvlpjJb5YiFp5jX7S0QCdBLKo6baEXWfFClI0Y2Wdr5EI/qDpFwi57uB69t6ZdQ+gmz4Ab4bxY7pFawLORctqqd/tSlOAGPeCcZZALMxGrfeNwPG6Muf0wIOuMCsrNbzx+EzgcandsiTIwmDdsz7ASB4iKU1q6rLLLPm9MF0B6fhxdrmDPy4XR48w0DKo2c7B5cLw7GkONBLohmy4Q31N/a6r9pL4VRYSoXrDIqc4o5EuINBaWlEEK33UzYb/4kuUheOd/oMr+03KVw10FVE0LIgbNBBZcNS0toI7Od6W2ksVlkbSM+gDkSLn27/NooPvynrnzeF3uWy3usDggW5bS1OHt8ZYjjv15nKZECLvrPCqj17O7w6SuaaPG8aOqPET0xRXGdqlVwG9iHXDyVwT2mt3iNdmhz5HHokKH6lscDAFohafDbhqgrFE7Jr9aOKuzuPaEqFvm8995YVRlUc0CAtuoj6EdtzMEIueuByyHLpvAg85pZCZbEeeLYuUirP8rvXJNZfGDl7DDHie68XMvCvYlpPEvssOMiXcQ4V6umvuarfh/w9YJk17zem82JFIjVA4qU+FUtARvShe5daoQGn3UW3ptdkgRGn/gZuncezZKy3C6CZtvMm233kAfSvudRU2H48DdemvVlUPdoj4b/H0xsMx1nhpfOhkyXBwReBht4xd/MVdrIv1zeKB0iYc89+UkNGggHHDmYwzff+zymMS5FE8TuqcRTg9irXXqMLmbROAsfKe/b8dqjuzZcWwnk8dKmGNh3BLL1qWjnvv54FqPl/PpwWRF61uAszhUl5Ywdq6Tfw28JSSHRQ+w0bJAVLQFrcccbh2qnEN6blU/qBvbDk9J6CJezuqA/j+HWnVruWqoC5s+cxi6N66+casXAApAIgiKLkHd9fYY3Gmb7l9R+ojVJyS71UpSNQpVJqPc9TJ/xz5rvVGKb/8J83y+ZuOVkE02XJwinrcT0quJNyzGz6bEufBWNgzKRIky/ES9VHm9u2DLfeomzNboDAqkr6zDlB3we22lEAmHBjaK7u3mxuwCgqJOeJ6JOVJF5awXL/ppjOP6Bpaq0924wEBfEt2v84alsgCArL+/Vwoic5pjmweMFQpdupb2/tAnbDmCR7PQMu0qXAy75GMqYyAGkT4qMfaf3bbjGAzp939x8F8JNaSmP0TwQcK5u3DHAHyJNXNWIOmlXPFpc1kP+OXgDadMzrPCwzfPmM1RL5ItmQtbtM2a2JafUk+UFf4ssAR763NsyK7IvnzW+2Enjcfiij3S0jlx8+d94g0RhRZzS5urSDpcE4ZNvS2Y9YrQ5MxdlRyq X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2111573d-4606-49fe-8147-08d919e29cc9 X-MS-Exchange-CrossTenant-AuthSource: DM5PR11MB0075.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2021 09:52:13.4909 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: e79GLX7bY0RNV15mPjfqoGTu4mk6kSuwk8qV8JEXxO5DV4J1WRxtUv0HB/iQ59vLrWIOTqqihnftPifSgSDasELlBpnsQ6+vOGmj+azGxXY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB3082 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210518_025215_448183_94AFB06A X-CRM114-Status: GOOD ( 15.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Quanyang Wang Add a new function is_layer_vid() to simplify the code that judges if a layer is the video layer. Acked-by: Paul Cercueil Signed-off-by: Quanyang Wang Reviewed-by: Laurent Pinchart --- drivers/gpu/drm/xlnx/zynqmp_disp.c | 39 +++++++++++++++++------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/xlnx/zynqmp_disp.c b/drivers/gpu/drm/xlnx/zynqmp_disp.c index 109d627968ac..eefb278e24c6 100644 --- a/drivers/gpu/drm/xlnx/zynqmp_disp.c +++ b/drivers/gpu/drm/xlnx/zynqmp_disp.c @@ -434,30 +434,35 @@ static void zynqmp_disp_avbuf_write(struct zynqmp_disp_avbuf *avbuf, writel(val, avbuf->base + reg); } +static bool is_layer_vid(const struct zynqmp_disp_layer *layer) +{ + return layer->id == ZYNQMP_DISP_LAYER_VID; +} + /** * zynqmp_disp_avbuf_set_format - Set the input format for a layer * @avbuf: Audio/video buffer manager - * @layer: The layer ID + * @layer: The layer * @fmt: The format information * * Set the video buffer manager format for @layer to @fmt. */ static void zynqmp_disp_avbuf_set_format(struct zynqmp_disp_avbuf *avbuf, - enum zynqmp_disp_layer_id layer, + struct zynqmp_disp_layer *layer, const struct zynqmp_disp_format *fmt) { unsigned int i; u32 val; val = zynqmp_disp_avbuf_read(avbuf, ZYNQMP_DISP_AV_BUF_FMT); - val &= layer == ZYNQMP_DISP_LAYER_VID + val &= is_layer_vid(layer) ? ~ZYNQMP_DISP_AV_BUF_FMT_NL_VID_MASK : ~ZYNQMP_DISP_AV_BUF_FMT_NL_GFX_MASK; val |= fmt->buf_fmt; zynqmp_disp_avbuf_write(avbuf, ZYNQMP_DISP_AV_BUF_FMT, val); for (i = 0; i < ZYNQMP_DISP_AV_BUF_NUM_SF; i++) { - unsigned int reg = layer == ZYNQMP_DISP_LAYER_VID + unsigned int reg = is_layer_vid(layer) ? ZYNQMP_DISP_AV_BUF_VID_COMP_SF(i) : ZYNQMP_DISP_AV_BUF_GFX_COMP_SF(i); @@ -573,19 +578,19 @@ static void zynqmp_disp_avbuf_disable_audio(struct zynqmp_disp_avbuf *avbuf) /** * zynqmp_disp_avbuf_enable_video - Enable a video layer * @avbuf: Audio/video buffer manager - * @layer: The layer ID + * @layer: The layer * @mode: Operating mode of layer * * Enable the video/graphics buffer for @layer. */ static void zynqmp_disp_avbuf_enable_video(struct zynqmp_disp_avbuf *avbuf, - enum zynqmp_disp_layer_id layer, + struct zynqmp_disp_layer *layer, enum zynqmp_disp_layer_mode mode) { u32 val; val = zynqmp_disp_avbuf_read(avbuf, ZYNQMP_DISP_AV_BUF_OUTPUT); - if (layer == ZYNQMP_DISP_LAYER_VID) { + if (is_layer_vid(layer)) { val &= ~ZYNQMP_DISP_AV_BUF_OUTPUT_VID1_MASK; if (mode == ZYNQMP_DISP_LAYER_NONLIVE) val |= ZYNQMP_DISP_AV_BUF_OUTPUT_VID1_MEM; @@ -605,17 +610,17 @@ static void zynqmp_disp_avbuf_enable_video(struct zynqmp_disp_avbuf *avbuf, /** * zynqmp_disp_avbuf_disable_video - Disable a video layer * @avbuf: Audio/video buffer manager - * @layer: The layer ID + * @layer: The layer * * Disable the video/graphics buffer for @layer. */ static void zynqmp_disp_avbuf_disable_video(struct zynqmp_disp_avbuf *avbuf, - enum zynqmp_disp_layer_id layer) + struct zynqmp_disp_layer *layer) { u32 val; val = zynqmp_disp_avbuf_read(avbuf, ZYNQMP_DISP_AV_BUF_OUTPUT); - if (layer == ZYNQMP_DISP_LAYER_VID) { + if (is_layer_vid(layer)) { val &= ~ZYNQMP_DISP_AV_BUF_OUTPUT_VID1_MASK; val |= ZYNQMP_DISP_AV_BUF_OUTPUT_VID1_NONE; } else { @@ -807,7 +812,7 @@ static void zynqmp_disp_blend_layer_set_csc(struct zynqmp_disp_blend *blend, } } - if (layer->id == ZYNQMP_DISP_LAYER_VID) + if (is_layer_vid(layer)) reg = ZYNQMP_DISP_V_BLEND_IN1CSC_COEFF(0); else reg = ZYNQMP_DISP_V_BLEND_IN2CSC_COEFF(0); @@ -818,7 +823,7 @@ static void zynqmp_disp_blend_layer_set_csc(struct zynqmp_disp_blend *blend, zynqmp_disp_blend_write(blend, reg + 8, coeffs[i + swap[2]]); } - if (layer->id == ZYNQMP_DISP_LAYER_VID) + if (is_layer_vid(layer)) reg = ZYNQMP_DISP_V_BLEND_IN1CSC_OFFSET(0); else reg = ZYNQMP_DISP_V_BLEND_IN2CSC_OFFSET(0); @@ -1025,7 +1030,7 @@ zynqmp_disp_layer_find_format(struct zynqmp_disp_layer *layer, */ static void zynqmp_disp_layer_enable(struct zynqmp_disp_layer *layer) { - zynqmp_disp_avbuf_enable_video(&layer->disp->avbuf, layer->id, + zynqmp_disp_avbuf_enable_video(&layer->disp->avbuf, layer, ZYNQMP_DISP_LAYER_NONLIVE); zynqmp_disp_blend_layer_enable(&layer->disp->blend, layer); @@ -1046,7 +1051,7 @@ static void zynqmp_disp_layer_disable(struct zynqmp_disp_layer *layer) for (i = 0; i < layer->drm_fmt->num_planes; i++) dmaengine_terminate_sync(layer->dmas[i].chan); - zynqmp_disp_avbuf_disable_video(&layer->disp->avbuf, layer->id); + zynqmp_disp_avbuf_disable_video(&layer->disp->avbuf, layer); zynqmp_disp_blend_layer_disable(&layer->disp->blend, layer); } @@ -1067,7 +1072,7 @@ static void zynqmp_disp_layer_set_format(struct zynqmp_disp_layer *layer, layer->disp_fmt = zynqmp_disp_layer_find_format(layer, info->format); layer->drm_fmt = info; - zynqmp_disp_avbuf_set_format(&layer->disp->avbuf, layer->id, + zynqmp_disp_avbuf_set_format(&layer->disp->avbuf, layer, layer->disp_fmt); /* @@ -1244,8 +1249,8 @@ static int zynqmp_disp_create_planes(struct zynqmp_disp *disp) drm_formats[j] = layer->info->formats[j].drm_fmt; /* Graphics layer is primary, and video layer is overlay. */ - type = i == ZYNQMP_DISP_LAYER_GFX - ? DRM_PLANE_TYPE_PRIMARY : DRM_PLANE_TYPE_OVERLAY; + type = is_layer_vid(layer) + ? DRM_PLANE_TYPE_OVERLAY : DRM_PLANE_TYPE_PRIMARY; ret = drm_universal_plane_init(disp->drm, &layer->plane, 0, &zynqmp_disp_plane_funcs, drm_formats, From patchwork Tue May 18 09:50:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quanyang Wang X-Patchwork-Id: 12264491 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F9C8C433ED for ; Tue, 18 May 2021 10:13:53 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6C27861185 for ; Tue, 18 May 2021 10:13:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6C27861185 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=windriver.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=1E6dvcVe+KDSM8Sh0QeYYo1ZXYcZxgn4IF3+bzSbtEs=; b=OH/sc0iYccgfG7yP2/buhwI4g VxQliV6ScAG/UGaE0SgW+kPx/fXKT/ioQvxED1j3PJd2TIMzQNeeyaFrKQg1dMDNyKVHFbOt76UWW z7PPdwlm5yXgtnNP/lBMhWFLdS9yJBYnFdEESXFqEaCkhNSjx9fmxP85gsLoEJRIWcY48VBteLedW NJVyVG7jfoqARfw/9l4TMm/YCgX+09mInoatezE6DSBojk77eEi8lyFBT5kj3QTk9iFUGvqIjrryv 7k9lm2q3uTsBcYz6NV/3DHPL3XJzrX+R7772peJ4cISmLDOYy0r/zUpHk7DTI5zeO62/stj+xJQX9 KmRZPJUlA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1liwhr-000IkO-ER; Tue, 18 May 2021 10:12:08 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1liwOn-000Et6-BS for linux-arm-kernel@desiato.infradead.org; Tue, 18 May 2021 09:52:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=OCpviyJ7FmA4C/LYkpOVdZOEr+eVvFT8aACG6+3b5vQ=; b=fJHKTI/4kWZUJS2a2u7+zz672s b+EBeBmOWFm9qyXcKO0QBR1TzOP4W8qmX1zw+JdNbG0lrGxBYvpGdWRZeYNP5HdvXrAaimNDP1at+ UKl//XPM1s2o8kjGCuPOheFbGXqwkoR7U59Q3y4RXiwCg8L0KSuYZnnyDZQrpqwR6r6e9yruvb3eE 9bM94ElV8gLZICcfDSbRcIZJfwCOhfXX/sviHPeKQw1aWYpjiz6BPeLpCFc8G2McvXCQsnfbeAQ/G 2XJyYdvcWIimUJu/pOeCZcec20lMfmQesGFj4fpHFCbhtluF2G0As7pckQiZaoiI/A9t/lsURPSh4 AAIqnU3A==; Received: from mail-dm6nam11on2077.outbound.protection.outlook.com ([40.107.223.77] helo=NAM11-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1liwOh-00EWza-HG for linux-arm-kernel@lists.infradead.org; Tue, 18 May 2021 09:52:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ldphnhndKuJiNUjPKRcetlWY9Hpx8ExrzNagR9DhcmsqNsspYcZPrqmDylnJx5iOsirdjYDJPRBABEmNcNsh+v3cJE0sxY5UW2IIYfojI/860R6iYxo/QzxL5E0kaxq0iJj4IhIjLo3J9eO8YslEYdl+Zr3ELWNZxzoKco/B/Br/GpZNAsB4kgvSfOXgg7p5uYnZvhdlCtrTzog3rEG26467O9ZSiTY5BNALQDA7dTpGDzwxV+MTYKLkeJpP4tE387eeUvITOcocdYbePsDp21y7xVZiPXzPojFhneUB+M3PRsF5PKEiOamYlbiDSwZGGuKDNVmGDR8JMmh/589Bzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OCpviyJ7FmA4C/LYkpOVdZOEr+eVvFT8aACG6+3b5vQ=; b=oMp+i6zxcwMAZ8zTg/ftef1XtB+E4sExbNt4noKvcfl2YA/RBqMUeDY7RjHAhxRdXgVp245Rpt8MKNgN2H+YAWLY8bnsf97CtANMTbf++sTa1/nTKlL4fMW8sfX3dKUKt2qx3OOKxS2HVqpDm7ydjdlXX3/n2Cr7r8BJUW/2XuzK3T/ZLxVEjUlx3bSfnhzzV4byVGOh470/xoXEYmHKKyszWCxZRdUB3Kdv0yhWw2wbGOpZjlz0wymoRvjSHgm20l+boR7BT9N8POp9y7QMjw75w9EVV7N+lP1SNV6FdEdFTjSzfZl5SVc4cNyAgDZ5pHlFuSuSKdyuc2J7G9FX5Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriversystems.onmicrosoft.com; s=selector2-windriversystems-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OCpviyJ7FmA4C/LYkpOVdZOEr+eVvFT8aACG6+3b5vQ=; b=A63I6HAd8dh6ZnIzflfdaX0eN/8AFp9w5noEjXjqoaAVAJWnkMy6RcyPS3eK2NLuVQfHS8VFi3/mIDBMx5D6+xxiCZnwRuhToIFaNU8TFXY3j5+7mBwS3n5A/AdYVqsF0kEpnqKty7fZrZWghLlAtOMw1HwYV0TEPlCazuEWP9s= Authentication-Results: crapouillou.net; dkim=none (message not signed) header.d=none;crapouillou.net; dmarc=none action=none header.from=windriver.com; Received: from DM5PR11MB0075.namprd11.prod.outlook.com (2603:10b6:4:6c::16) by DM6PR11MB3082.namprd11.prod.outlook.com (2603:10b6:5:6b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.26; Tue, 18 May 2021 09:52:17 +0000 Received: from DM5PR11MB0075.namprd11.prod.outlook.com ([fe80::7cf5:4b57:4804:20bf]) by DM5PR11MB0075.namprd11.prod.outlook.com ([fe80::7cf5:4b57:4804:20bf%5]) with mapi id 15.20.4129.031; Tue, 18 May 2021 09:52:17 +0000 From: quanyang.wang@windriver.com To: Paul Cercueil , Hyun Kwon , Laurent Pinchart , David Airlie , Daniel Vetter , Michal Simek Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Quanyang Wang Subject: [V2][PATCH 2/2] drm: xlnx: consolidate the functions which programming AUDIO_VIDEO_SELECT register Date: Tue, 18 May 2021 17:50:19 +0800 Message-Id: <20210518095019.3855369-3-quanyang.wang@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210518095019.3855369-1-quanyang.wang@windriver.com> References: <20210518095019.3855369-1-quanyang.wang@windriver.com> X-Originating-IP: [60.247.85.82] X-ClientProxiedBy: HK2PR04CA0090.apcprd04.prod.outlook.com (2603:1096:202:15::34) To DM5PR11MB0075.namprd11.prod.outlook.com (2603:10b6:4:6c::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pek-qwang2-d1.wrs.com (60.247.85.82) by HK2PR04CA0090.apcprd04.prod.outlook.com (2603:1096:202:15::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.35 via Frontend Transport; Tue, 18 May 2021 09:52:14 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cd723d3a-22ea-4c8c-be0a-08d919e29eff X-MS-TrafficTypeDiagnostic: DM6PR11MB3082: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jIz9HTzbtXZxEX8s/XWoE6q0NIKax2TdI8xa2d4MdkM/cp9XtrXx43jIrkBq13N+Zk9gN7abmY9m3JJoQbnZOOuaOG02QB3j5u4pMbywXrCX/1vKIKa7imEpyR+JrDT3IPy198n9bFU+asx6Ax7LmbRGkioDsmO2k2vXwLGwLZzlR/OPKBwnk6QFcnBMo/NJh+erExWXfLdzG8vD+VdRt0NlVNDLdwqhId5ss4Cy4qkXxe9hHFp1rYAzdjQLlBIof13SMdAU8Lhvv0vH3yDtPWTwYoIesRXJ6uEUOTrWT0TAWffUDqPu6oG/YkvSRcvojhNRcsxh3DkYjUgITFxEJ+terac1skhqDRyr/3rXcMm1gAu1gC/M5o7Y0lF/5X4F5Okxx7wRFwl34RDxGzH5oM6LGRE7tVrBYa+sK0L0X6Yw3Q+357RHZE63Vq7LdGsnoZQz9wCDLbcQzQonTb8rRxoepwrrdSaHRlwx4irlbzIKbPDP6BG6lygATb4h4LYYBdqFWgo1PA1+pJ5Bj+dZE8N3NP2IDDUx5lzAggToa9KAUf0+03el4gtAFUrJOzUFZbvSI3VRqdzJWwlL42SJIs+vR9K1EXq7gSL0N/UU9E/ve/S5kXYgtelT6lLrzSIz89MqRCk1x2J6JkW8sMxvVTgXHIMAj5FJUYUUMLUEOMg= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR11MB0075.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(346002)(136003)(396003)(366004)(39850400004)(66556008)(52116002)(83380400001)(66946007)(66476007)(110136005)(38350700002)(478600001)(8936002)(5660300002)(38100700002)(6486002)(316002)(2906002)(2616005)(6512007)(9686003)(186003)(956004)(4326008)(1076003)(16526019)(36756003)(107886003)(8676002)(26005)(86362001)(6506007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: XWJSYmaLmfq+nOfKvPhvhRNUO+gygDUS6JsBFf84P4w0NEju18ldS4EE1JJpt4AJCDoLJl+3xdPbEJMF5rCyl8/PIH8wn9kUeWo8+Oy1NrpzzUZsVR2IXdyJwhrLPCnmMlftS5s2SnL4QsEGqbQZeDSEsoXjOSeU96NUM9UcVh1GSS0kll0kfNDYZgKsMMoQFC0ArVfJd2oQdkDXEWQSCCrGHkBHKX9vkuLhqkduu3pTgpCt76XAYQ2TzuaoEhukl+gkjVJh+c846UgpkvIYKNAENCOAzgSecbTi6G/DBnS8kxifrfrzFALBzePOJ5WJcoJXPmsLoy8Km17/6wiFyrKIceXdBdpR515Y83ah35AKc5qZeSsDykMd+xIkqIG5SMfuVQIwZidczJlCt1KTgYePnhJt2aQyNC7d4cMg5e+yCdfVUgXVZA1rIgESVmdw+dClL14TR1h5ww1t+HpoSP1xuUVUgjBLG9uoAGv1+C0OJK39/9ouuHNJj3c6ouE7zPudMQDDbKgDVQc/zC/fygNDAY9QF+quLPOoruFHOkHlhbnJmV+mz5u25Q43BeAxUxKgFgjGmdBxyIbNykvLwApocQrW/G/gRffd5fCjHPnhCSun+3r19Uzf9uOTShGJJrDz4Ep40iIV487s8NNreEqCj+J1u/cNt7G3w0jaFH8R6Xjak+EGwta8DMQO4DsKilPax+7cXCaTKyQeFwxZIfp/vYBNlD/+kQKq86tR/uLJVS37G2X77Sb1y2lfhiCDjYS+P05dK7CkBdrKbxc1PnylshFoksntr0zyURfn2gPjvpQGMSupg4NidL09yHp+9pEGssfI8Qw2W8e2F26qazQimu5rYgmOeNtUgMq6o8uQd1tVEoA9b9lmOhwRhqoSpfZbR38jLTMbgA3AdE49w4TpLK5rjTc2KrssWgbOz5DnzMFCV7lz+ssR8I+T2cPq/refV/0jOZw2cWYNK4Kd/bGGmi7RFyQHOXSO/xKb4g+z26Mtr+0esCyErwQZzW6c8+ZEVfF4H5pRHeXK1gY6+Bz8n6NFWs92/op36IJVjsULWgnmp+geFQ1oVKXMLZ+pWfiqY2pMHsSk+7FofteCzr7biln68FoGaDTU5TW0nwd+fws+ijFfzLLI/n5FKB85ws2nP+4oykdP0JcCVgAumYRF4fuA7S5q1lP2VazIcr2tgrjQBONDreussOBWsupJN13nRB13YFZP4QDiS3Imy9FRMUQhP2BJXxKJAQTPk8zxyx7Mh+xD/eUkJGapiC312uq9vntojB5ccu8rHzjVMRGirltz3lS77r2CAll6bxQG44W11f34teHwMVKJE0kI X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: cd723d3a-22ea-4c8c-be0a-08d919e29eff X-MS-Exchange-CrossTenant-AuthSource: DM5PR11MB0075.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2021 09:52:17.1928 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: aAlld9FsdfDpHSCZdekPf/Y4pmHk6Ds1Y8VjhRE/26MGb1vxnLrxaewm/SdxsxmoNcFEpTJt3CbvI8nc/D0rLMPDtj244DzRzM7iFmqkQjI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB3082 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210518_025219_670461_4E2AEBC5 X-CRM114-Status: GOOD ( 16.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Quanyang Wang For now, the functions zynqmp_disp_avbuf_enable/disable_audio and zynqmp_disp_avbuf_enable/disable_video are all programming the register AV_BUF_OUTPUT_AUDIO_VIDEO_SELECT to select the output for audio or video. And in the future, many drm properties (like video_tpg, audio_tpg, audio_pl, etc) also need to access it. So let's introduce some variables of enum type and consolidate the code to unify handling this. Signed-off-by: Quanyang Wang Acked-by: Paul Cercueil --- drivers/gpu/drm/xlnx/zynqmp_disp.c | 168 ++++++++++++++---------- drivers/gpu/drm/xlnx/zynqmp_disp_regs.h | 23 +--- 2 files changed, 106 insertions(+), 85 deletions(-) diff --git a/drivers/gpu/drm/xlnx/zynqmp_disp.c b/drivers/gpu/drm/xlnx/zynqmp_disp.c index eefb278e24c6..3672d2f5665b 100644 --- a/drivers/gpu/drm/xlnx/zynqmp_disp.c +++ b/drivers/gpu/drm/xlnx/zynqmp_disp.c @@ -102,12 +102,39 @@ enum zynqmp_disp_layer_id { /** * enum zynqmp_disp_layer_mode - Layer mode - * @ZYNQMP_DISP_LAYER_NONLIVE: non-live (memory) mode + * @ZYNQMP_DISP_LAYER_MEM: memory mode * @ZYNQMP_DISP_LAYER_LIVE: live (stream) mode + * @ZYNQMP_DISP_LAYER_TPG: tpg mode (only for video layer) + * @ZYNQMP_DISP_LAYER_DISABLE: disable mode */ enum zynqmp_disp_layer_mode { - ZYNQMP_DISP_LAYER_NONLIVE, - ZYNQMP_DISP_LAYER_LIVE + ZYNQMP_DISP_LAYER_MEM, + ZYNQMP_DISP_LAYER_LIVE, + ZYNQMP_DISP_LAYER_TPG, + ZYNQMP_DISP_LAYER_DISABLE +}; + +enum avbuf_vid_mode { + VID_MODE_LIVE, + VID_MODE_MEM, + VID_MODE_TPG, + VID_MODE_NONE +}; + +enum avbuf_gfx_mode { + GFX_MODE_DISABLE, + GFX_MODE_MEM, + GFX_MODE_LIVE, + GFX_MODE_NONE +}; + +enum avbuf_aud_mode { + AUD1_MODE_LIVE, + AUD1_MODE_MEM, + AUD1_MODE_TPG, + AUD1_MODE_DISABLE, + AUD2_MODE_DISABLE, + AUD2_MODE_ENABLE }; /** @@ -542,92 +569,102 @@ static void zynqmp_disp_avbuf_disable_channels(struct zynqmp_disp_avbuf *avbuf) } /** - * zynqmp_disp_avbuf_enable_audio - Enable audio + * zynqmp_disp_avbuf_output_select - Select the buffer manager outputs * @avbuf: Audio/video buffer manager + * @layer: The layer + * @mode: The mode for this layer * - * Enable all audio buffers with a non-live (memory) source. + * Select the buffer manager outputs for @layer. */ -static void zynqmp_disp_avbuf_enable_audio(struct zynqmp_disp_avbuf *avbuf) +static void zynqmp_disp_avbuf_output_select(struct zynqmp_disp_avbuf *avbuf, + struct zynqmp_disp_layer *layer, + u32 mode) { - u32 val; + u32 reg; - val = zynqmp_disp_avbuf_read(avbuf, ZYNQMP_DISP_AV_BUF_OUTPUT); - val &= ~ZYNQMP_DISP_AV_BUF_OUTPUT_AUD1_MASK; - val |= ZYNQMP_DISP_AV_BUF_OUTPUT_AUD1_MEM; - val |= ZYNQMP_DISP_AV_BUF_OUTPUT_AUD2_EN; - zynqmp_disp_avbuf_write(avbuf, ZYNQMP_DISP_AV_BUF_OUTPUT, val); + reg = zynqmp_disp_avbuf_read(avbuf, ZYNQMP_DISP_AV_BUF_OUTPUT); + + /* Select audio mode when the layer is NULL */ + if (layer == NULL) { + if (mode >= AUD2_MODE_DISABLE) { + reg &= ~ZYNQMP_DISP_AV_BUF_OUTPUT_AUD2_MASK; + reg |= FIELD_PREP(ZYNQMP_DISP_AV_BUF_OUTPUT_AUD2_MASK, + (mode - AUD2_MODE_DISABLE)); + } else { + reg &= ~ZYNQMP_DISP_AV_BUF_OUTPUT_AUD1_MASK; + reg |= FIELD_PREP(ZYNQMP_DISP_AV_BUF_OUTPUT_AUD1_MASK, mode); + } + } else if (is_layer_vid(layer)) { + reg &= ~ZYNQMP_DISP_AV_BUF_OUTPUT_VID1_MASK; + reg |= FIELD_PREP(ZYNQMP_DISP_AV_BUF_OUTPUT_VID1_MASK, mode); + } else { + reg &= ~ZYNQMP_DISP_AV_BUF_OUTPUT_VID2_MASK; + reg |= FIELD_PREP(ZYNQMP_DISP_AV_BUF_OUTPUT_VID2_MASK, mode); + } + + zynqmp_disp_avbuf_write(avbuf, ZYNQMP_DISP_AV_BUF_OUTPUT, reg); } /** - * zynqmp_disp_avbuf_disable_audio - Disable audio + * zynqmp_disp_avbuf_enable_audio - Enable audio * @avbuf: Audio/video buffer manager * - * Disable all audio buffers. + * Enable all audio buffers. */ -static void zynqmp_disp_avbuf_disable_audio(struct zynqmp_disp_avbuf *avbuf) +static void zynqmp_disp_avbuf_enable_audio(struct zynqmp_disp_avbuf *avbuf) { - u32 val; - - val = zynqmp_disp_avbuf_read(avbuf, ZYNQMP_DISP_AV_BUF_OUTPUT); - val &= ~ZYNQMP_DISP_AV_BUF_OUTPUT_AUD1_MASK; - val |= ZYNQMP_DISP_AV_BUF_OUTPUT_AUD1_DISABLE; - val &= ~ZYNQMP_DISP_AV_BUF_OUTPUT_AUD2_EN; - zynqmp_disp_avbuf_write(avbuf, ZYNQMP_DISP_AV_BUF_OUTPUT, val); + zynqmp_disp_avbuf_output_select(avbuf, NULL, AUD1_MODE_MEM); + zynqmp_disp_avbuf_output_select(avbuf, NULL, AUD2_MODE_ENABLE); } /** - * zynqmp_disp_avbuf_enable_video - Enable a video layer + * zynqmp_disp_avbuf_disable_audio - Disable audio * @avbuf: Audio/video buffer manager - * @layer: The layer - * @mode: Operating mode of layer * - * Enable the video/graphics buffer for @layer. + * Disable all audio buffers. */ -static void zynqmp_disp_avbuf_enable_video(struct zynqmp_disp_avbuf *avbuf, - struct zynqmp_disp_layer *layer, - enum zynqmp_disp_layer_mode mode) +static void zynqmp_disp_avbuf_disable_audio(struct zynqmp_disp_avbuf *avbuf) { - u32 val; - - val = zynqmp_disp_avbuf_read(avbuf, ZYNQMP_DISP_AV_BUF_OUTPUT); - if (is_layer_vid(layer)) { - val &= ~ZYNQMP_DISP_AV_BUF_OUTPUT_VID1_MASK; - if (mode == ZYNQMP_DISP_LAYER_NONLIVE) - val |= ZYNQMP_DISP_AV_BUF_OUTPUT_VID1_MEM; - else - val |= ZYNQMP_DISP_AV_BUF_OUTPUT_VID1_LIVE; - } else { - val &= ~ZYNQMP_DISP_AV_BUF_OUTPUT_VID2_MASK; - val |= ZYNQMP_DISP_AV_BUF_OUTPUT_VID2_MEM; - if (mode == ZYNQMP_DISP_LAYER_NONLIVE) - val |= ZYNQMP_DISP_AV_BUF_OUTPUT_VID2_MEM; - else - val |= ZYNQMP_DISP_AV_BUF_OUTPUT_VID2_LIVE; - } - zynqmp_disp_avbuf_write(avbuf, ZYNQMP_DISP_AV_BUF_OUTPUT, val); + zynqmp_disp_avbuf_output_select(avbuf, NULL, AUD1_MODE_DISABLE); + zynqmp_disp_avbuf_output_select(avbuf, NULL, AUD2_MODE_DISABLE); } /** - * zynqmp_disp_avbuf_disable_video - Disable a video layer - * @avbuf: Audio/video buffer manager + * zynqmp_disp_avbuf_set_layer_output - Set layer output * @layer: The layer + * @mode: The layer mode * - * Disable the video/graphics buffer for @layer. + * Set output for @layer */ -static void zynqmp_disp_avbuf_disable_video(struct zynqmp_disp_avbuf *avbuf, - struct zynqmp_disp_layer *layer) +static void zynqmp_disp_avbuf_set_layer_output(struct zynqmp_disp_layer *layer, + enum zynqmp_disp_layer_mode mode) { - u32 val; - - val = zynqmp_disp_avbuf_read(avbuf, ZYNQMP_DISP_AV_BUF_OUTPUT); - if (is_layer_vid(layer)) { - val &= ~ZYNQMP_DISP_AV_BUF_OUTPUT_VID1_MASK; - val |= ZYNQMP_DISP_AV_BUF_OUTPUT_VID1_NONE; - } else { - val &= ~ZYNQMP_DISP_AV_BUF_OUTPUT_VID2_MASK; - val |= ZYNQMP_DISP_AV_BUF_OUTPUT_VID2_DISABLE; + struct zynqmp_disp *disp = layer->disp; + int val; + + switch (mode) { + case ZYNQMP_DISP_LAYER_LIVE: + val = is_layer_vid(layer) ? VID_MODE_LIVE : GFX_MODE_LIVE; + break; + case ZYNQMP_DISP_LAYER_MEM: + val = is_layer_vid(layer) ? VID_MODE_MEM : GFX_MODE_MEM; + break; + case ZYNQMP_DISP_LAYER_TPG: + if (!is_layer_vid(layer)) { + dev_err(disp->dev, "gfx layer has no tpg mode\n"); + return; + } + val = VID_MODE_TPG; + break; + case ZYNQMP_DISP_LAYER_DISABLE: + val = is_layer_vid(layer) ? VID_MODE_NONE : GFX_MODE_DISABLE; + break; + default: + dev_err(disp->dev, "invalid layer mode\n"); + return; } - zynqmp_disp_avbuf_write(avbuf, ZYNQMP_DISP_AV_BUF_OUTPUT, val); + + zynqmp_disp_avbuf_output_select(&disp->avbuf, layer, val); } /** @@ -1030,11 +1067,10 @@ zynqmp_disp_layer_find_format(struct zynqmp_disp_layer *layer, */ static void zynqmp_disp_layer_enable(struct zynqmp_disp_layer *layer) { - zynqmp_disp_avbuf_enable_video(&layer->disp->avbuf, layer, - ZYNQMP_DISP_LAYER_NONLIVE); + zynqmp_disp_avbuf_set_layer_output(layer, ZYNQMP_DISP_LAYER_MEM); zynqmp_disp_blend_layer_enable(&layer->disp->blend, layer); - layer->mode = ZYNQMP_DISP_LAYER_NONLIVE; + layer->mode = ZYNQMP_DISP_LAYER_MEM; } /** @@ -1051,7 +1087,7 @@ static void zynqmp_disp_layer_disable(struct zynqmp_disp_layer *layer) for (i = 0; i < layer->drm_fmt->num_planes; i++) dmaengine_terminate_sync(layer->dmas[i].chan); - zynqmp_disp_avbuf_disable_video(&layer->disp->avbuf, layer); + zynqmp_disp_avbuf_set_layer_output(layer, ZYNQMP_DISP_LAYER_DISABLE); zynqmp_disp_blend_layer_disable(&layer->disp->blend, layer); } diff --git a/drivers/gpu/drm/xlnx/zynqmp_disp_regs.h b/drivers/gpu/drm/xlnx/zynqmp_disp_regs.h index f92a006d5070..4316e324102d 100644 --- a/drivers/gpu/drm/xlnx/zynqmp_disp_regs.h +++ b/drivers/gpu/drm/xlnx/zynqmp_disp_regs.h @@ -118,25 +118,10 @@ #define ZYNQMP_DISP_AV_BUF_STC_SNAPSHOT0 0x60 #define ZYNQMP_DISP_AV_BUF_STC_SNAPSHOT1 0x64 #define ZYNQMP_DISP_AV_BUF_OUTPUT 0x70 -#define ZYNQMP_DISP_AV_BUF_OUTPUT_VID1_SHIFT 0 -#define ZYNQMP_DISP_AV_BUF_OUTPUT_VID1_MASK (0x3 << 0) -#define ZYNQMP_DISP_AV_BUF_OUTPUT_VID1_LIVE (0 << 0) -#define ZYNQMP_DISP_AV_BUF_OUTPUT_VID1_MEM (1 << 0) -#define ZYNQMP_DISP_AV_BUF_OUTPUT_VID1_PATTERN (2 << 0) -#define ZYNQMP_DISP_AV_BUF_OUTPUT_VID1_NONE (3 << 0) -#define ZYNQMP_DISP_AV_BUF_OUTPUT_VID2_SHIFT 2 -#define ZYNQMP_DISP_AV_BUF_OUTPUT_VID2_MASK (0x3 << 2) -#define ZYNQMP_DISP_AV_BUF_OUTPUT_VID2_DISABLE (0 << 2) -#define ZYNQMP_DISP_AV_BUF_OUTPUT_VID2_MEM (1 << 2) -#define ZYNQMP_DISP_AV_BUF_OUTPUT_VID2_LIVE (2 << 2) -#define ZYNQMP_DISP_AV_BUF_OUTPUT_VID2_NONE (3 << 2) -#define ZYNQMP_DISP_AV_BUF_OUTPUT_AUD1_SHIFT 4 -#define ZYNQMP_DISP_AV_BUF_OUTPUT_AUD1_MASK (0x3 << 4) -#define ZYNQMP_DISP_AV_BUF_OUTPUT_AUD1_PL (0 << 4) -#define ZYNQMP_DISP_AV_BUF_OUTPUT_AUD1_MEM (1 << 4) -#define ZYNQMP_DISP_AV_BUF_OUTPUT_AUD1_PATTERN (2 << 4) -#define ZYNQMP_DISP_AV_BUF_OUTPUT_AUD1_DISABLE (3 << 4) -#define ZYNQMP_DISP_AV_BUF_OUTPUT_AUD2_EN BIT(6) +#define ZYNQMP_DISP_AV_BUF_OUTPUT_VID1_MASK GENMASK(1, 0) +#define ZYNQMP_DISP_AV_BUF_OUTPUT_VID2_MASK GENMASK(3, 2) +#define ZYNQMP_DISP_AV_BUF_OUTPUT_AUD1_MASK GENMASK(5, 4) +#define ZYNQMP_DISP_AV_BUF_OUTPUT_AUD2_MASK BIT(6) #define ZYNQMP_DISP_AV_BUF_HCOUNT_VCOUNT_INT0 0x74 #define ZYNQMP_DISP_AV_BUF_HCOUNT_VCOUNT_INT1 0x78 #define ZYNQMP_DISP_AV_BUF_PATTERN_GEN_SELECT 0x100