From patchwork Mon Nov 5 10:45:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Jourdan X-Patchwork-Id: 10667749 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C4D9017D4 for ; Mon, 5 Nov 2018 10:45:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2F6229546 for ; Mon, 5 Nov 2018 10:45:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A759B29637; Mon, 5 Nov 2018 10:45:57 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 100A329615 for ; Mon, 5 Nov 2018 10:45:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8gKhH+H2nn5UhCoN/G2MVgYbI3lkHbaoXe1UjFe8FAg=; b=hVIW4nVfxJpzTL /R9p7sqts9vpvZHiWtmQLFTsHQ0QW7NWNGT6tS8/rK9fjCQe5bFZ9VoHBXfpV5ROrXkEgHMkujYlL HOSrPNUobUU9QZ8P1MU5v4JVXaDn+MTL+FkhYIGCOQdKX4D6G/kzBcHZsiV8lmlTdHB9n7hTHEXWO m8PwZBIcqjAeFyRqDctFiMD+cJy0XDt8sTvFg4NZp214BlcNlVhM4e6cL9ySXbLntiFL1v4lMhzzt 3X41OCsDCJd69khj/46rKQilScKDDbGYhpoxQxf5JveRV+ux88PAwXnxuRJr9AKVEoquN13SZTpGZ XUrenLL8kxUmU8Qo/flg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gJcOK-0000Zp-Bv; Mon, 05 Nov 2018 10:45:56 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gJcNq-00089V-EO for linux-amlogic@lists.infradead.org; Mon, 05 Nov 2018 10:45:31 +0000 Received: by mail-wm1-x341.google.com with SMTP id u13-v6so7541692wmc.4 for ; Mon, 05 Nov 2018 02:45:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jHG3pEhuEYUagxkiAojd6GLQqBQ8g60ZmVS+lON+9AU=; b=GyUzBshYb82xkM3Omfd4J4I5SRquHgD03DuZmnVgKBuuiDX5CctabTG1Bm3jPYZiE5 +gCXPl3p7rYXw3FifcR8rQtRi4eNRxEYN1fQlOcg12TAAQM1vZa6Z8fkC+SFNzBUPC32 Z7CDhZc9TGn6qyHKtWaeBDFMfavB/O25pi2uAWrHWqxNw81CEQ9xtS+uXVfA5E3rzepl PaVROxm1A5wFetOUqsXN0eHSkqSJSw34u0DZ09l5118RlmIo8orYv+JvpsmeyLHIG7CH Lo/i9cY6oElX4Vem0GPgsX1+P60RAT4Xw8YPRDbZO4YOZ1CTMJpZb9HkzXT1GrqoZn4x Y5+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jHG3pEhuEYUagxkiAojd6GLQqBQ8g60ZmVS+lON+9AU=; b=SydH3ALnsWQF/anLKoyKgmhQH6FfpSw22yAkeNd7QxsVcX9PKXgV0hSxkOLDHHHFmH d/mAbVWjRZarO2m13EOKT0t2SkqUlK4tNZS3lTTRcFtZ+I9tJ/LubZ8hho1LaRxX654I cltcFgICi29om1q9xBD3t7T4tVQbhVjtjmnRVZXGWZZ1vg8lecFZc473GLQi3uCR3HLg qXh5Ro334M6TqsGkCfmJVGaYhIFcfmjLqPVrljKyU3s6OzFhzFml2E4BsHI+eORY9PoY zrVAlfDAK7IDwFBkWumqM+uzf/Zim+lyWzBTmsmUkC5v8Kkdlqo6Jv6FwWKSsBp1RxS0 tojg== X-Gm-Message-State: AGRZ1gKQCSTEOPv1l+uXsFhqKhYg1Y6RRi1CKybGfk6HjsLNdLDD2dLl WjjpIEkhojLrXZOJi+ao4Bcc0w== X-Google-Smtp-Source: AJdET5c3vMDFdsazXfk30zZXypAXRytdXY124vuVqH0Id0zsC++l56yH44uyWgzw9A3qdzSACEJ26Q== X-Received: by 2002:a1c:a757:: with SMTP id q84-v6mr4126035wme.61.1541414714743; Mon, 05 Nov 2018 02:45:14 -0800 (PST) Received: from localhost.localdomain (abo-99-183-68.mtp.modulonet.fr. [85.68.183.99]) by smtp.gmail.com with ESMTPSA id p125-v6sm8033114wmp.2.2018.11.05.02.45.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Nov 2018 02:45:13 -0800 (PST) From: Maxime Jourdan To: Neil Armstrong Subject: [PATCH 2/2] drm/meson: Use optional canvas provider Date: Mon, 5 Nov 2018 11:45:08 +0100 Message-Id: <20181105104508.23090-3-mjourdan@baylibre.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181105104508.23090-1-mjourdan@baylibre.com> References: <20181105104508.23090-1-mjourdan@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181105_024526_924142_EAF8EF26 X-CRM114-Status: GOOD ( 18.37 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Kevin Hilman , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Jerome Brunet Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This is the first step into converting the meson/drm driver to use the canvas module. If a canvas provider node is detected in DT, use it. Otherwise, fall back to what is currently being done. Signed-off-by: Maxime Jourdan Reviewed-by: Neil Armstrong --- drivers/gpu/drm/meson/Kconfig | 1 + drivers/gpu/drm/meson/meson_crtc.c | 14 ++++++--- drivers/gpu/drm/meson/meson_drv.c | 46 ++++++++++++++++++----------- drivers/gpu/drm/meson/meson_drv.h | 4 +++ drivers/gpu/drm/meson/meson_plane.c | 8 ++++- 5 files changed, 51 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/meson/Kconfig b/drivers/gpu/drm/meson/Kconfig index 3ce51d8dfe1c..c28b69f48555 100644 --- a/drivers/gpu/drm/meson/Kconfig +++ b/drivers/gpu/drm/meson/Kconfig @@ -7,6 +7,7 @@ config DRM_MESON select DRM_GEM_CMA_HELPER select VIDEOMODE_HELPERS select REGMAP_MMIO + select MESON_CANVAS config DRM_MESON_DW_HDMI tristate "HDMI Synopsys Controller support for Amlogic Meson Display" diff --git a/drivers/gpu/drm/meson/meson_crtc.c b/drivers/gpu/drm/meson/meson_crtc.c index 05520202c967..b3bc0b0ee07f 100644 --- a/drivers/gpu/drm/meson/meson_crtc.c +++ b/drivers/gpu/drm/meson/meson_crtc.c @@ -193,10 +193,16 @@ void meson_crtc_irq(struct meson_drm *priv) } else meson_vpp_disable_interlace_vscaler_osd1(priv); - meson_canvas_setup(priv, MESON_CANVAS_ID_OSD1, - priv->viu.osd1_addr, priv->viu.osd1_stride, - priv->viu.osd1_height, MESON_CANVAS_WRAP_NONE, - MESON_CANVAS_BLKMODE_LINEAR); + if (priv->canvas) + meson_canvas_config(priv->canvas, priv->canvas_id_osd1, + priv->viu.osd1_addr, priv->viu.osd1_stride, + priv->viu.osd1_height, MESON_CANVAS_WRAP_NONE, + MESON_CANVAS_BLKMODE_LINEAR, 0); + else + meson_canvas_setup(priv, MESON_CANVAS_ID_OSD1, + priv->viu.osd1_addr, priv->viu.osd1_stride, + priv->viu.osd1_height, MESON_CANVAS_WRAP_NONE, + MESON_CANVAS_BLKMODE_LINEAR); /* Enable OSD1 */ writel_bits_relaxed(VPP_OSD1_POSTBLEND, VPP_OSD1_POSTBLEND, diff --git a/drivers/gpu/drm/meson/meson_drv.c b/drivers/gpu/drm/meson/meson_drv.c index d3443125e661..b39c38c2350d 100644 --- a/drivers/gpu/drm/meson/meson_drv.c +++ b/drivers/gpu/drm/meson/meson_drv.c @@ -216,24 +216,33 @@ static int meson_drv_bind_master(struct device *dev, bool has_components) goto free_drm; } - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dmc"); - if (!res) { - ret = -EINVAL; - goto free_drm; - } - /* Simply ioremap since it may be a shared register zone */ - regs = devm_ioremap(dev, res->start, resource_size(res)); - if (!regs) { - ret = -EADDRNOTAVAIL; - goto free_drm; - } + priv->canvas = meson_canvas_get(dev); + if (!IS_ERR(priv->canvas)) { + ret = meson_canvas_alloc(priv->canvas, &priv->canvas_id_osd1); + if (ret) + goto free_drm; + } else { + priv->canvas = NULL; - priv->dmc = devm_regmap_init_mmio(dev, regs, - &meson_regmap_config); - if (IS_ERR(priv->dmc)) { - dev_err(&pdev->dev, "Couldn't create the DMC regmap\n"); - ret = PTR_ERR(priv->dmc); - goto free_drm; + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dmc"); + if (!res) { + ret = -EINVAL; + goto free_drm; + } + /* Simply ioremap since it may be a shared register zone */ + regs = devm_ioremap(dev, res->start, resource_size(res)); + if (!regs) { + ret = -EADDRNOTAVAIL; + goto free_drm; + } + + priv->dmc = devm_regmap_init_mmio(dev, regs, + &meson_regmap_config); + if (IS_ERR(priv->dmc)) { + dev_err(&pdev->dev, "Couldn't create the DMC regmap\n"); + ret = PTR_ERR(priv->dmc); + goto free_drm; + } } priv->vsync_irq = platform_get_irq(pdev, 0); @@ -315,6 +324,9 @@ static void meson_drv_unbind(struct device *dev) struct drm_device *drm = dev_get_drvdata(dev); struct meson_drm *priv = drm->dev_private; + if (priv->canvas) + meson_canvas_free(priv->canvas, priv->canvas_id_osd1); + drm_dev_unregister(drm); drm_kms_helper_poll_fini(drm); drm_fbdev_cma_fini(priv->fbdev); diff --git a/drivers/gpu/drm/meson/meson_drv.h b/drivers/gpu/drm/meson/meson_drv.h index 8450d6ac8c9b..728d0ca33732 100644 --- a/drivers/gpu/drm/meson/meson_drv.h +++ b/drivers/gpu/drm/meson/meson_drv.h @@ -22,6 +22,7 @@ #include #include #include +#include #include struct meson_drm { @@ -31,6 +32,9 @@ struct meson_drm { struct regmap *dmc; int vsync_irq; + struct meson_canvas *canvas; + u8 canvas_id_osd1; + struct drm_device *drm; struct drm_crtc *crtc; struct drm_fbdev_cma *fbdev; diff --git a/drivers/gpu/drm/meson/meson_plane.c b/drivers/gpu/drm/meson/meson_plane.c index 12c80dfcff59..51bec8e98a39 100644 --- a/drivers/gpu/drm/meson/meson_plane.c +++ b/drivers/gpu/drm/meson/meson_plane.c @@ -90,6 +90,7 @@ static void meson_plane_atomic_update(struct drm_plane *plane, .y2 = state->crtc_y + state->crtc_h, }; unsigned long flags; + u8 canvas_id_osd1; /* * Update Coordinates @@ -104,8 +105,13 @@ static void meson_plane_atomic_update(struct drm_plane *plane, (0xFF << OSD_GLOBAL_ALPHA_SHIFT) | OSD_BLK0_ENABLE; + if (priv->canvas) + canvas_id_osd1 = priv->canvas_id_osd1; + else + canvas_id_osd1 = MESON_CANVAS_ID_OSD1; + /* Set up BLK0 to point to the right canvas */ - priv->viu.osd1_blk0_cfg[0] = ((MESON_CANVAS_ID_OSD1 << OSD_CANVAS_SEL) | + priv->viu.osd1_blk0_cfg[0] = ((canvas_id_osd1 << OSD_CANVAS_SEL) | OSD_ENDIANNESS_LE); /* On GXBB, Use the old non-HDR RGB2YUV converter */