From patchwork Mon Jul 4 07:40:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ying Liu X-Patchwork-Id: 9211863 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 DF73560571 for ; Mon, 4 Jul 2016 08:14:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF322284BC for ; Mon, 4 Jul 2016 08:14:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C305228522; Mon, 4 Jul 2016 08:14:46 +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]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 337DB284BC for ; Mon, 4 Jul 2016 08:14:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5BA516E3CD; Mon, 4 Jul 2016 08:14:44 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0055.outbound.protection.outlook.com [104.47.34.55]) by gabe.freedesktop.org (Postfix) with ESMTPS id 039856E3C9 for ; Mon, 4 Jul 2016 08:14:42 +0000 (UTC) Received: from BY2PR03CA045.namprd03.prod.outlook.com (10.141.249.18) by BLUPR03MB247.namprd03.prod.outlook.com (10.255.213.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.523.12; Mon, 4 Jul 2016 07:41:00 +0000 Received: from BN1AFFO11FD014.protection.gbl (2a01:111:f400:7c10::129) by BY2PR03CA045.outlook.office365.com (2a01:111:e400:2c5d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.528.16 via Frontend Transport; Mon, 4 Jul 2016 07:41:00 +0000 Authentication-Results: spf=softfail (sender IP is 192.88.158.2) smtp.mailfrom=gmail.com; ffwll.ch; dkim=none (message not signed) header.d=none; ffwll.ch; dmarc=fail action=none header.from=gmail.com; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning gmail.com discourages use of 192.88.158.2 as permitted sender) Received: from az84smr01.freescale.net (192.88.158.2) by BN1AFFO11FD014.mail.protection.outlook.com (10.58.52.74) with Microsoft SMTP Server (TLS) id 15.1.523.9 via Frontend Transport; Mon, 4 Jul 2016 07:40:59 +0000 Received: from victor.ap.freescale.net (victor.ap.freescale.net [10.192.241.62]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id u647ep0R026135; Mon, 4 Jul 2016 00:40:57 -0700 From: Liu Ying To: Subject: [PATCH v3 02/10] gpu: ipu-v3: ipu-dmfc: Use static DMFC FIFO allocation mechanism Date: Mon, 4 Jul 2016 15:40:31 +0800 Message-ID: <1467618039-7457-3-git-send-email-gnuiyl@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1467618039-7457-1-git-send-email-gnuiyl@gmail.com> References: <1467618039-7457-1-git-send-email-gnuiyl@gmail.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131120916599339588; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(979002)(6009001)(7916002)(2980300002)(189002)(199003)(76176999)(2906002)(81442002)(69596002)(48376002)(73392002)(104016004)(73972006)(106466001)(8936002)(50986999)(19580395003)(586003)(68736007)(11100500001)(19580405001)(33646002)(189998001)(5003940100001)(50226002)(50466002)(2351001)(7846002)(81166006)(305945005)(97736004)(61266001)(87936001)(83322999)(82202001)(87572001)(6260500002)(92566002)(55446002)(6806005)(105596002)(76482005)(8676002)(36756003)(229853001)(4326007)(2950100001)(86362001)(356003)(110136002)(77096005)(47776003)(81156014)(217873001)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR03MB247; H:az84smr01.freescale.net; FPR:; SPF:SoftFail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD014; 1:kwGNQdDuuwMhZnVRV79Z9mOXUsZV/WF73MyAZyzJN8j5DP58VMCYYJs3mnKAlZch6KV1lWDjWJ/G4bjASpUAb30hww7evPc7ThADOZEASu8LahBiF6Hs5XGNlxJMvVXk8PTeGu9tDuIa1WQqWKDQpuuL0PsRVbIqEgaEjmaCKiWbx3bfiKgtqhrLoBJ91CgphvHt/NH2RP3u0vXiMgalNLwfYos+VwIz6xc1kzmmvSriQTTIRFJ6h+O8yccwP4oEA0Tdx91L1s5O6aMLCaT23NIQBIh0kODWvE5sM4fwwOguFJjwI85dQVGoYEMkIhWSaRfsXNFKiR58eSI1T4trOtAX94FL3kbvXe81z69yPx4n1HyR/lyY0ZkKMGpMTpxZTzoVlQYPw/hsY8VyLZ7kySl2k5DaeKdDLcwpmADWpYtYGK9z7LfNvtyhSfXYArkuxd7tEE8LwY94AHrMuAyLPuPmjNSNFERI6wIat60HsmtKuc1onYLXP6mQUwA+TBci7jfJ3AUcVLe/W+lG2eh9+TOKrByhpF2SySOiJmsmbCUT4swdByxpHGq6qFipJseT684HrizA05vlO3VQClyHlA== MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: f8237f21-f152-4c5f-fa44-08d3a3de8afd X-Microsoft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HFoQC5g3+4tR3gTCvEQoONmR0WheXzZvr71t4bo+n0/Bp8M5wpYNd15TYCPjf0y5m0/TEOD2H5Phv0hgbUJuNYEUe+69Mw3CHr/fKAK/VqM5R86pqVw+dCQhv0AsbkuRxpAlmY9VVUhYP2ZPHWJhq/CRXEwRbaT3Bimmipc57Go85iGU1hjiCKvMxieXsnQAj8tebmZHCMBpTnNDOlOGjW6o5zCgQStrLf8adxS1ap2zoZkRAJO4egZVz+9fGeslUvXR X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(788757137089); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(13017025)(5005006)(13018025)(13024025)(13015025)(13023025)(3002001)(10201501046)(6055026); SRVR:BLUPR03MB247; BCL:0; PCL:0; RULEID:(400006); SRVR:BLUPR03MB247; X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB247; 4:5NCgxuRzzhH6IL7D27me3SuQGa03P1LjNjcTg1WDGshQawVnI/bFmtS+UrtSOTD2nzoYI9W+kpXC5+1LK4Eq3RI1BU0bdlMA2uzPNSpz51SM83U4Ec4SpzgJKmlJYIUhtc5J1q3MbhLern/fFbMZKZMeTWwn5XNSvsqodZwpVpD3elh0/3JZMVEUBjJtb0DhVCXWgbLBra2AcJKwGG4Tc+mZEn16iBGSkYt4fRPr4Yg/vvZywQgdNvoALwlGV+QUdPCch22ghcGtuf31rBEr5+SzpsV9qWJEMqeFH4R+S/W33yuOZAOrLcH+Le6cTspQQrS5Gj27l3ZZgblqxtcgL3wBlQ6JfZBER2qlhsvI6uxaWduoguT9uUfe/rGgy+4AsRF6Ratkrqmt/eu1L0rH9BrOGTRcNIgOpk63Qa0aYVZ9dGU6RuRBhTFdYzZE0wy69GQgjWdxSmiZTwJ87URlogkQTKHfmcEgeDvuadYsuMIG32C4CeJzWt4Gs/DzN9uNCqPH3e0ccK9nbebQ9b7Thw== X-Forefront-PRVS: 0993689CD1 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR03MB247; 23:LkB5ZUkYsnsCn983U5ROs7A34GWy8CnHXHrJaweCYt?= =?us-ascii?Q?K8p7a0IFu0M3I8a0Qy3DYGVzilAnbUNyU2r9pa9Nygb5fL281fWuOgmal5aL?= =?us-ascii?Q?X8pQri/iW+Ct0rF3mOq0S9LZsv8Ex4K6LsCAOsP9ISHMvKfcMKrGpBdy33ty?= =?us-ascii?Q?pNa7KRDjRz8JsFKQoenjg1sLJ+QdClh0BTcBTeiaCGC/RljEOnonhtxMp2qU?= =?us-ascii?Q?ZoSNR4acMUO0z4Ioirf1mq0adO7NWDv8plw7KcfVK9UwGEliG0XgVk0movHO?= =?us-ascii?Q?nPOmhACFxW2gQl9kB0FMStgc3V4IJhKZH1SnNvcB0C9rT8BNfCOJ6dYUW17F?= =?us-ascii?Q?EOs0CGE+Gp50GYA6uTNaavbs5kdzJYDnMTSL2MlySoGuafz7ojDztXC9gKAK?= =?us-ascii?Q?tTw+EH0eFyy2UlDs9lyxHAum0JViTcjMTQss6zji8tASIZs81lmBEsmbjATK?= =?us-ascii?Q?sgeOdqeSnVJUen3rD/1o4sjZdAMtrzwCpG4xNIij+gQaH/Lt9sQP5Ujyq8+m?= =?us-ascii?Q?Dx69xpSvPE5gF/Xlyoh9MBSUcZIaHOLOP/WgGlCsDE1J/4+vLVGKBGhi7P5O?= =?us-ascii?Q?g7QF/RklVuFo6Q6mwVQRLFVpXheylgGMaZazYhkpryqVBJT+z4W1Xc+TRveI?= =?us-ascii?Q?4WYNcs8KJPS6iaU8Of7MvITtR5MbG6CjRb3wGn3dfrHa6UewUpCUnQHyRAvv?= =?us-ascii?Q?aflbubrmUaKD9+cN4zpfOFYqV1Ms0kZpRnODOzeItJO+tf1MydZbTu44r8j7?= =?us-ascii?Q?/zgCzKDDW+0040PhQOiGF+N7J+MdZq69IRg7CDS4Tce/t9OtHoSue2bFXFOc?= =?us-ascii?Q?E79FU+OSo+WwKobOHBOG43S0NZ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1t//0jgZmV1k4gKjHvxKSxybXjG4bfOVUoeAwKGCt+NmSz9FdEJyDdM1SnrPNXvDxEYm8WXE3JPVhO4s/Kk015Nk90TrIMJdjQuLqle173H/aSgGKSoHZQInPr+R56LNDPhXc6cqHjTY/E=; 24:d/fjHeb9tOvkILM0zF7RJxnB9jeB7vQdNBwj7+mnMyEFQkVsqzzYoZ6w3tZ6jrPt8J0Yp8Fyvh92ouqA8V4V/KzrDlE1XJDfhqXO88DT038=; 7:I6te0lrebyrPQuaZIJ8KSCRETNslWzZCV0oABp68Pv0g8/13zygLepblJLow2HOrAwwucC0v0drq2C4h5iYULiLsWL33t0IutJUN31kMM8iXnz12OZTaT7+fHugTTvGamjZ6t8pJQCg+gyCf7+3pa0/USohVXDLN8uPTYZblOzOLh0VPhLe8iI4L3BCkJ0G3qnSPWyQzpR4ZkMONt/9AwzfESppmmMqNWPzvUriuEu+ltp3++4hnUuOQ4+o3YJrQZWBdr4edg9qo6k02soo8yQ== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jul 2016 07:40:59.7155 (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.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB247 Cc: Russell King , Daniel Vetter 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 For all video modes we support currently, we always get 2 slots for a plane by using the current existing dynamic DMFC FIFO allocation mechanism. So, let's change to use the static one to simplify the code. This also makes it easier to implement the atomic mode setting as we don't need to handle allocation failure cases then. Signed-off-by: Liu Ying --- v2->v3: * None. v1->v2: * Improve the commit message to better explain why the static allocation mechanism can replace the dynamic one. drivers/gpu/drm/imx/ipuv3-plane.c | 26 ----- drivers/gpu/ipu-v3/ipu-dmfc.c | 213 ++------------------------------------ include/video/imx-ipu-v3.h | 3 - 3 files changed, 7 insertions(+), 235 deletions(-) diff --git a/drivers/gpu/drm/imx/ipuv3-plane.c b/drivers/gpu/drm/imx/ipuv3-plane.c index cd7eb26..02701de 100644 --- a/drivers/gpu/drm/imx/ipuv3-plane.c +++ b/drivers/gpu/drm/imx/ipuv3-plane.c @@ -53,24 +53,6 @@ int ipu_plane_irq(struct ipu_plane *ipu_plane) IPU_IRQ_EOF); } -static int calc_vref(struct drm_display_mode *mode) -{ - unsigned long htotal, vtotal; - - htotal = mode->htotal; - vtotal = mode->vtotal; - - if (!htotal || !vtotal) - return 60; - - return DIV_ROUND_UP(mode->clock * 1000, vtotal * htotal); -} - -static inline int calc_bandwidth(int width, int height, unsigned int vref) -{ - return width * height * vref; -} - int ipu_plane_set_base(struct ipu_plane *ipu_plane, struct drm_framebuffer *fb, int x, int y) { @@ -291,14 +273,6 @@ int ipu_plane_mode_set(struct ipu_plane *ipu_plane, struct drm_crtc *crtc, } } - ret = ipu_dmfc_alloc_bandwidth(ipu_plane->dmfc, - calc_bandwidth(crtc_w, crtc_h, - calc_vref(mode)), 64); - if (ret) { - dev_err(dev, "allocating dmfc bandwidth failed with %d\n", ret); - return ret; - } - ipu_dmfc_config_wait4eot(ipu_plane->dmfc, crtc_w); ipu_cpmem_zero(ipu_plane->ipu_ch); diff --git a/drivers/gpu/ipu-v3/ipu-dmfc.c b/drivers/gpu/ipu-v3/ipu-dmfc.c index 837b1ec2..42705bb 100644 --- a/drivers/gpu/ipu-v3/ipu-dmfc.c +++ b/drivers/gpu/ipu-v3/ipu-dmfc.c @@ -45,17 +45,6 @@ #define DMFC_DP_CHAN_6B_24 16 #define DMFC_DP_CHAN_6F_29 24 -#define DMFC_FIFO_SIZE_64 (3 << 3) -#define DMFC_FIFO_SIZE_128 (2 << 3) -#define DMFC_FIFO_SIZE_256 (1 << 3) -#define DMFC_FIFO_SIZE_512 (0 << 3) - -#define DMFC_SEGMENT(x) ((x & 0x7) << 0) -#define DMFC_BURSTSIZE_128 (0 << 6) -#define DMFC_BURSTSIZE_64 (1 << 6) -#define DMFC_BURSTSIZE_32 (2 << 6) -#define DMFC_BURSTSIZE_16 (3 << 6) - struct dmfc_channel_data { int ipu_channel; unsigned long channel_reg; @@ -104,9 +93,6 @@ struct ipu_dmfc_priv; struct dmfc_channel { unsigned slots; - unsigned slotmask; - unsigned segment; - int burstsize; struct ipu_soc *ipu; struct ipu_dmfc_priv *priv; const struct dmfc_channel_data *data; @@ -117,7 +103,6 @@ struct ipu_dmfc_priv { struct device *dev; struct dmfc_channel channels[DMFC_NUM_CHANNELS]; struct mutex mutex; - unsigned long bandwidth_per_slot; void __iomem *base; int use_count; }; @@ -172,184 +157,6 @@ void ipu_dmfc_disable_channel(struct dmfc_channel *dmfc) } EXPORT_SYMBOL_GPL(ipu_dmfc_disable_channel); -static int ipu_dmfc_setup_channel(struct dmfc_channel *dmfc, int slots, - int segment, int burstsize) -{ - struct ipu_dmfc_priv *priv = dmfc->priv; - u32 val, field; - - dev_dbg(priv->dev, - "dmfc: using %d slots starting from segment %d for IPU channel %d\n", - slots, segment, dmfc->data->ipu_channel); - - switch (slots) { - case 1: - field = DMFC_FIFO_SIZE_64; - break; - case 2: - field = DMFC_FIFO_SIZE_128; - break; - case 4: - field = DMFC_FIFO_SIZE_256; - break; - case 8: - field = DMFC_FIFO_SIZE_512; - break; - default: - return -EINVAL; - } - - switch (burstsize) { - case 16: - field |= DMFC_BURSTSIZE_16; - break; - case 32: - field |= DMFC_BURSTSIZE_32; - break; - case 64: - field |= DMFC_BURSTSIZE_64; - break; - case 128: - field |= DMFC_BURSTSIZE_128; - break; - } - - field |= DMFC_SEGMENT(segment); - - val = readl(priv->base + dmfc->data->channel_reg); - - val &= ~(0xff << dmfc->data->shift); - val |= field << dmfc->data->shift; - - writel(val, priv->base + dmfc->data->channel_reg); - - dmfc->slots = slots; - dmfc->segment = segment; - dmfc->burstsize = burstsize; - dmfc->slotmask = ((1 << slots) - 1) << segment; - - return 0; -} - -static int dmfc_bandwidth_to_slots(struct ipu_dmfc_priv *priv, - unsigned long bandwidth) -{ - int slots = 1; - - while (slots * priv->bandwidth_per_slot < bandwidth) - slots *= 2; - - return slots; -} - -static int dmfc_find_slots(struct ipu_dmfc_priv *priv, int slots) -{ - unsigned slotmask_need, slotmask_used = 0; - int i, segment = 0; - - slotmask_need = (1 << slots) - 1; - - for (i = 0; i < DMFC_NUM_CHANNELS; i++) - slotmask_used |= priv->channels[i].slotmask; - - while (slotmask_need <= 0xff) { - if (!(slotmask_used & slotmask_need)) - return segment; - - slotmask_need <<= 1; - segment++; - } - - return -EBUSY; -} - -void ipu_dmfc_free_bandwidth(struct dmfc_channel *dmfc) -{ - struct ipu_dmfc_priv *priv = dmfc->priv; - int i; - - dev_dbg(priv->dev, "dmfc: freeing %d slots starting from segment %d\n", - dmfc->slots, dmfc->segment); - - mutex_lock(&priv->mutex); - - if (!dmfc->slots) - goto out; - - dmfc->slotmask = 0; - dmfc->slots = 0; - dmfc->segment = 0; - - for (i = 0; i < DMFC_NUM_CHANNELS; i++) - priv->channels[i].slotmask = 0; - - for (i = 0; i < DMFC_NUM_CHANNELS; i++) { - if (priv->channels[i].slots > 0) { - priv->channels[i].segment = - dmfc_find_slots(priv, priv->channels[i].slots); - priv->channels[i].slotmask = - ((1 << priv->channels[i].slots) - 1) << - priv->channels[i].segment; - } - } - - for (i = 0; i < DMFC_NUM_CHANNELS; i++) { - if (priv->channels[i].slots > 0) - ipu_dmfc_setup_channel(&priv->channels[i], - priv->channels[i].slots, - priv->channels[i].segment, - priv->channels[i].burstsize); - } -out: - mutex_unlock(&priv->mutex); -} -EXPORT_SYMBOL_GPL(ipu_dmfc_free_bandwidth); - -int ipu_dmfc_alloc_bandwidth(struct dmfc_channel *dmfc, - unsigned long bandwidth_pixel_per_second, int burstsize) -{ - struct ipu_dmfc_priv *priv = dmfc->priv; - int slots = dmfc_bandwidth_to_slots(priv, bandwidth_pixel_per_second); - int segment = -1, ret = 0; - - dev_dbg(priv->dev, "dmfc: trying to allocate %ldMpixel/s for IPU channel %d\n", - bandwidth_pixel_per_second / 1000000, - dmfc->data->ipu_channel); - - ipu_dmfc_free_bandwidth(dmfc); - - mutex_lock(&priv->mutex); - - if (slots > 8) { - ret = -EBUSY; - goto out; - } - - /* For the MEM_BG channel, first try to allocate twice the slots */ - if (dmfc->data->ipu_channel == IPUV3_CHANNEL_MEM_BG_SYNC) - segment = dmfc_find_slots(priv, slots * 2); - else if (slots < 2) - /* Always allocate at least 128*4 bytes (2 slots) */ - slots = 2; - - if (segment >= 0) - slots *= 2; - else - segment = dmfc_find_slots(priv, slots); - if (segment < 0) { - ret = -EBUSY; - goto out; - } - - ipu_dmfc_setup_channel(dmfc, slots, segment, burstsize); - -out: - mutex_unlock(&priv->mutex); - - return ret; -} -EXPORT_SYMBOL_GPL(ipu_dmfc_alloc_bandwidth); - void ipu_dmfc_config_wait4eot(struct dmfc_channel *dmfc, int width) { struct ipu_dmfc_priv *priv = dmfc->priv; @@ -384,7 +191,6 @@ EXPORT_SYMBOL_GPL(ipu_dmfc_get); void ipu_dmfc_put(struct dmfc_channel *dmfc) { - ipu_dmfc_free_bandwidth(dmfc); } EXPORT_SYMBOL_GPL(ipu_dmfc_put); @@ -412,20 +218,15 @@ int ipu_dmfc_init(struct ipu_soc *ipu, struct device *dev, unsigned long base, priv->channels[i].priv = priv; priv->channels[i].ipu = ipu; priv->channels[i].data = &dmfcdata[i]; - } - - writel(0x0, priv->base + DMFC_WR_CHAN); - writel(0x0, priv->base + DMFC_DP_CHAN); - /* - * We have a total bandwidth of clkrate * 4pixel divided - * into 8 slots. - */ - priv->bandwidth_per_slot = clk_get_rate(ipu_clk) * 4 / 8; - - dev_dbg(dev, "dmfc: 8 slots with %ldMpixel/s bandwidth each\n", - priv->bandwidth_per_slot / 1000000); + if (dmfcdata[i].ipu_channel == IPUV3_CHANNEL_MEM_BG_SYNC || + dmfcdata[i].ipu_channel == IPUV3_CHANNEL_MEM_FG_SYNC || + dmfcdata[i].ipu_channel == IPUV3_CHANNEL_MEM_DC_SYNC) + priv->channels[i].slots = 2; + } + writel(0x00000050, priv->base + DMFC_WR_CHAN); + writel(0x00005654, priv->base + DMFC_DP_CHAN); writel(0x202020f6, priv->base + DMFC_WR_CHAN_DEF); writel(0x2020f6f6, priv->base + DMFC_DP_CHAN_DEF); writel(0x00000003, priv->base + DMFC_GENERAL1); diff --git a/include/video/imx-ipu-v3.h b/include/video/imx-ipu-v3.h index 3a2a794..7adeaae 100644 --- a/include/video/imx-ipu-v3.h +++ b/include/video/imx-ipu-v3.h @@ -235,9 +235,6 @@ int ipu_di_init_sync_panel(struct ipu_di *, struct ipu_di_signal_cfg *sig); struct dmfc_channel; int ipu_dmfc_enable_channel(struct dmfc_channel *dmfc); void ipu_dmfc_disable_channel(struct dmfc_channel *dmfc); -int ipu_dmfc_alloc_bandwidth(struct dmfc_channel *dmfc, - unsigned long bandwidth_mbs, int burstsize); -void ipu_dmfc_free_bandwidth(struct dmfc_channel *dmfc); void ipu_dmfc_config_wait4eot(struct dmfc_channel *dmfc, int width); struct dmfc_channel *ipu_dmfc_get(struct ipu_soc *ipu, int ipuv3_channel); void ipu_dmfc_put(struct dmfc_channel *dmfc);