From patchwork Tue Nov 5 21:10:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 11228631 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8A33D1390 for ; Tue, 5 Nov 2019 21:10:53 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 7AAA921A49 for ; Tue, 5 Nov 2019 21:10:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7AAA921A49 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=poorly.run Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DADC36E9D8; Tue, 5 Nov 2019 21:10:52 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yb1-xb41.google.com (mail-yb1-xb41.google.com [IPv6:2607:f8b0:4864:20::b41]) by gabe.freedesktop.org (Postfix) with ESMTPS id AE18E6E9D8 for ; Tue, 5 Nov 2019 21:10:51 +0000 (UTC) Received: by mail-yb1-xb41.google.com with SMTP id g17so567984ybd.13 for ; Tue, 05 Nov 2019 13:10:51 -0800 (PST) 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=wV4eozP5loNQwYGwTBZjo7fjHegUFd2KeaLBGEk3hXA=; b=HR2wpKl1/phnNjkw5DhC/wvmCCUOZ5XzoGk8/ZNQ5PPRBLm0QrQSZ71eOhWbwWweCI It9KYB1tWlZyyEpxFVhzjNAv2dLAt4Y6ZvhZIJaVhxn4Y/OTkvxHNa7xs9o/gVAz3t3y JTUPRKStobRHXYi9OCQEHiSvrnvASzb6LcEL+rgZy6Pd7Rxr9M4NqAlqxS6sBdmCNieP iuetUrYJIYhuMWKneLroFBB/jwR+vlJVUgkiel/8vDYr4ldahk/wqJozyv0qvxDLlT2X o85FJelD3UO1ViuJiGxPmyEsvnJJ3V1MQ2W6goqZb5M6lB7czf7bGVTTFbaAsk+iVj/R Ou4w== X-Gm-Message-State: APjAAAVYwXZ8GPL+bS2AG6MmZf1K8sH/8ETKlluRA8LDiOfNBTwKQjKN 7RmEpIueJU43cMkJ4ya3qDq2oiTvDlc= X-Google-Smtp-Source: APXvYqzU0qqs+85NekuoYN3av0T/6sjs3A+/t1dcUDPS/GuqvBVMdxP+0PxcpfW0TVgNQIEIHKU3cw== X-Received: by 2002:a25:c281:: with SMTP id s123mr29226020ybf.92.1572988250491; Tue, 05 Nov 2019 13:10:50 -0800 (PST) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:89c6:2139:5435:371d]) by smtp.gmail.com with ESMTPSA id j66sm1815216ywb.101.2019.11.05.13.10.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Nov 2019 13:10:50 -0800 (PST) From: Sean Paul To: dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org Subject: [PATCH v2 1/7] drm/mediatek: Refactor plane init Date: Tue, 5 Nov 2019 16:10:18 -0500 Message-Id: <20191105211034.123937-2-sean@poorly.run> X-Mailer: git-send-email 2.24.0.rc1.363.gb1bccd3e3d-goog In-Reply-To: <20191105211034.123937-1-sean@poorly.run> References: <20191105211034.123937-1-sean@poorly.run> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poorly.run; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wV4eozP5loNQwYGwTBZjo7fjHegUFd2KeaLBGEk3hXA=; b=G7Z/3RjJH8MhJ9aRUpU58OK1kicWtOfm3WtQLcKX1elIQ+JQ/825WwFnfTx4QpN0R5 /qz307oDAZfzYxFCewWZ6HZAx5GKfnNPQPZJw852kLB84ojf24fkweH7Mql1ilO/efva 16no+9TaJtrLwAejmjAg168sSggFqN5IP5HAJLd1LDvbs7ICGLkHKbAEbx9Q+m/Hjbge wgDh+5WQN2fFFuG9iTJfXU2Oe8fE9gFFXyr7zSyuv8loygbB+7NHsZL1cKNzuKhhDaSE Yyj2G5EB6Ivy6uimax0FkY71FYWlYKILN1Mia76WZgswL4pnibiWzvwRC9K/gJRbn9kN zqVg== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dcastagna@chromium.org, matthias.bgg@gmail.com, mcasas@chromium.org, Sean Paul , frkoenig@chromium.org, linux-arm-kernel@lists.infradead.org, markyacoub@google.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Sean Paul Add a couple of functions which enumerate the number of planes for a component and initialize the planes for a component. No functional changes in this patch, but it will allow us to selectively support rotation if the component supports it. Signed-off-by: Sean Paul --- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 77 +++++++++++++++++++------ 1 file changed, 59 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c index b841d3706d8b..7d0f50da8e40 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c @@ -543,14 +543,63 @@ void mtk_crtc_ddp_irq(struct drm_crtc *crtc, struct mtk_ddp_comp *comp) mtk_drm_finish_page_flip(mtk_crtc); } +static int mtk_drm_crtc_num_comp_planes(struct mtk_drm_crtc *mtk_crtc, + int comp_idx) +{ + struct mtk_ddp_comp *comp; + + if (comp_idx > 1) + return 0; + + comp = mtk_crtc->ddp_comp[comp_idx]; + if (!comp->funcs) + return 0; + + if (comp_idx == 1 && !comp->funcs->bgclr_in_on) + return 0; + + return mtk_ddp_comp_layer_nr(comp); +} + +static inline +enum drm_plane_type mtk_drm_crtc_plane_type(unsigned int plane_idx) +{ + if (plane_idx == 0) + return DRM_PLANE_TYPE_PRIMARY; + else if (plane_idx == 1) + return DRM_PLANE_TYPE_CURSOR; + else + return DRM_PLANE_TYPE_OVERLAY; + +} + +static int mtk_drm_crtc_init_comp_planes(struct drm_device *drm_dev, + struct mtk_drm_crtc *mtk_crtc, + int comp_idx, int pipe) +{ + int num_planes = mtk_drm_crtc_num_comp_planes(mtk_crtc, comp_idx); + int i, ret; + + for (i = 0; i < num_planes; i++) { + ret = mtk_plane_init(drm_dev, + &mtk_crtc->planes[mtk_crtc->layer_nr], + BIT(pipe), + mtk_drm_crtc_plane_type(mtk_crtc->layer_nr)); + if (ret) + return ret; + + mtk_crtc->layer_nr++; + } + return 0; +} + int mtk_drm_crtc_create(struct drm_device *drm_dev, const enum mtk_ddp_comp_id *path, unsigned int path_len) { struct mtk_drm_private *priv = drm_dev->dev_private; struct device *dev = drm_dev->dev; struct mtk_drm_crtc *mtk_crtc; - enum drm_plane_type type; - unsigned int zpos; + unsigned int num_comp_planes = 0; int pipe = priv->num_pipes; int ret; int i; @@ -606,23 +655,15 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev, mtk_crtc->ddp_comp[i] = comp; } - mtk_crtc->layer_nr = mtk_ddp_comp_layer_nr(mtk_crtc->ddp_comp[0]); - if (mtk_crtc->ddp_comp_nr > 1) { - struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[1]; + for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) + num_comp_planes += mtk_drm_crtc_num_comp_planes(mtk_crtc, i); + + mtk_crtc->planes = devm_kcalloc(dev, num_comp_planes, + sizeof(struct drm_plane), GFP_KERNEL); - if (comp->funcs->bgclr_in_on) - mtk_crtc->layer_nr += mtk_ddp_comp_layer_nr(comp); - } - mtk_crtc->planes = devm_kcalloc(dev, mtk_crtc->layer_nr, - sizeof(struct drm_plane), - GFP_KERNEL); - - for (zpos = 0; zpos < mtk_crtc->layer_nr; zpos++) { - type = (zpos == 0) ? DRM_PLANE_TYPE_PRIMARY : - (zpos == 1) ? DRM_PLANE_TYPE_CURSOR : - DRM_PLANE_TYPE_OVERLAY; - ret = mtk_plane_init(drm_dev, &mtk_crtc->planes[zpos], - BIT(pipe), type); + for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) { + ret = mtk_drm_crtc_init_comp_planes(drm_dev, mtk_crtc, i, + pipe); if (ret) return ret; } From patchwork Tue Nov 5 21:10:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 11228633 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B7D0413A4 for ; Tue, 5 Nov 2019 21:10:56 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 A932B2087E for ; Tue, 5 Nov 2019 21:10:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A932B2087E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=poorly.run Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A13276E9D9; Tue, 5 Nov 2019 21:10:55 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yb1-xb42.google.com (mail-yb1-xb42.google.com [IPv6:2607:f8b0:4864:20::b42]) by gabe.freedesktop.org (Postfix) with ESMTPS id 474196E9D9 for ; Tue, 5 Nov 2019 21:10:53 +0000 (UTC) Received: by mail-yb1-xb42.google.com with SMTP id x14so4825052ybq.12 for ; Tue, 05 Nov 2019 13:10:53 -0800 (PST) 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=Ta1Xwfa+QeAgFSaukNPJQ5uJyx0Z9KTcb0vCHsmGyFQ=; b=ulHQ/ThhzE98kgWt7gK/Q6Wr5PDBePhGWHVUm1nIuMR37Zb0v4ZPxjwHmZeUNF064A Lm4HYfuw9qsI7GXpEh04hkjTTTDunMdFAnXYd8jCN5H7n/V2AJF8SMeg18vpfNzAp/BV ria6mxukaeoS+YWfLsipjgDdZH5noHObSyA6UcxlqzmVZAknPEs0er7hRM0KfjGY8zWI d8wuE8B+WsScV2AIevmexq3eWnZxszDRn/vy4qUzFyHdmsZXVuUNTyx7H6V3XuGFcDQt cFDqVeMLNr/Wc5JV/XJDt9h27lDouN2IzxyRoTfvo2PCMjR8oWMIWD93xrLlQzZTjPj5 dlag== X-Gm-Message-State: APjAAAVb9UrFAJDpcC/cGWoaAvrq2OJP2qvwH1wYhWGSYBcvhGnkKj5y TLuNHi6IlBek8uDbYlM+tbw3RJQ8ED8= X-Google-Smtp-Source: APXvYqylGH6ZNkY6K1tLbHFtvCxKxcHMgw9PDG6CbQLvQSvJUEARUn/PSgkolxKP8MpBrxfh0FKWzw== X-Received: by 2002:a25:cc84:: with SMTP id l126mr28076860ybf.249.1572988252193; Tue, 05 Nov 2019 13:10:52 -0800 (PST) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:89c6:2139:5435:371d]) by smtp.gmail.com with ESMTPSA id j66sm1815216ywb.101.2019.11.05.13.10.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Nov 2019 13:10:51 -0800 (PST) From: Sean Paul To: dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org Subject: [PATCH v2 2/7] drm/mediatek: Add helper to get component for a plane Date: Tue, 5 Nov 2019 16:10:19 -0500 Message-Id: <20191105211034.123937-3-sean@poorly.run> X-Mailer: git-send-email 2.24.0.rc1.363.gb1bccd3e3d-goog In-Reply-To: <20191105211034.123937-1-sean@poorly.run> References: <20191105211034.123937-1-sean@poorly.run> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poorly.run; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ta1Xwfa+QeAgFSaukNPJQ5uJyx0Z9KTcb0vCHsmGyFQ=; b=XA/fs7qgEdfJZML+yaAQj0RuclIsRF7Ra54ebOTOISjSJsvFenImCTBE6H+Tya5FKp YlAwTnFfG8ezZMDaqA0HJZikqdEHYac7VFwjzlzBpKZ4sG3lqdDZqtpWWJiMkD/T6x3X EFSD8vOEyexf+Odjr1tXCZa9CX35E54Jm5ooFUlPNOVyFOSa9IljuapxUFX2L2ySKvlw 8AZp/urnvC+xMC+E0XaBzF2do4tcNa1YV+RS2fyLicN1Biz6DJQ019Cj8AHzPAnMGFeS PGwJf4Rmu/viUbcl2eIoqpebK0yG/Xg5GgEryWs7INnvw46teyCbUNsZuZj8S1dKmTSD MCsQ== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dcastagna@chromium.org, matthias.bgg@gmail.com, mcasas@chromium.org, Sean Paul , frkoenig@chromium.org, linux-arm-kernel@lists.infradead.org, markyacoub@google.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Sean Paul Instead of hard-coding which components have planes, add a helper function to walk the components and map a plane index to a component layer. Signed-off-by: Sean Paul --- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 56 +++++++++++++++---------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c index 7d0f50da8e40..ccf395f17a99 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c @@ -207,6 +207,28 @@ static void mtk_crtc_ddp_clk_disable(struct mtk_drm_crtc *mtk_crtc) clk_disable_unprepare(mtk_crtc->ddp_comp[i]->clk); } +static +struct mtk_ddp_comp *mtk_drm_ddp_comp_for_plane(struct drm_crtc *crtc, + struct drm_plane *plane, + unsigned int *local_layer) +{ + struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); + struct mtk_ddp_comp *comp; + int i, count = 0; + + for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) { + comp = mtk_crtc->ddp_comp[i]; + if (plane->index < (count + mtk_ddp_comp_layer_nr(comp))) { + *local_layer = plane->index - count; + return comp; + } + count += mtk_ddp_comp_layer_nr(comp); + } + + WARN(1, "Failed to find component for plane %d\n", plane->index); + return NULL; +} + static int mtk_crtc_ddp_hw_init(struct mtk_drm_crtc *mtk_crtc) { struct drm_crtc *crtc = &mtk_crtc->base; @@ -283,19 +305,12 @@ static int mtk_crtc_ddp_hw_init(struct mtk_drm_crtc *mtk_crtc) for (i = 0; i < mtk_crtc->layer_nr; i++) { struct drm_plane *plane = &mtk_crtc->planes[i]; struct mtk_plane_state *plane_state; - struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[0]; - unsigned int comp_layer_nr = mtk_ddp_comp_layer_nr(comp); + struct mtk_ddp_comp *comp; unsigned int local_layer; plane_state = to_mtk_plane_state(plane->state); - - if (i >= comp_layer_nr) { - comp = mtk_crtc->ddp_comp[1]; - local_layer = i - comp_layer_nr; - } else - local_layer = i; - mtk_ddp_comp_layer_config(comp, local_layer, - plane_state); + comp = mtk_drm_ddp_comp_for_plane(crtc, plane, &local_layer); + mtk_ddp_comp_layer_config(comp, local_layer, plane_state); } return 0; @@ -343,7 +358,6 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc) struct mtk_crtc_state *state = to_mtk_crtc_state(mtk_crtc->base.state); struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[0]; unsigned int i; - unsigned int comp_layer_nr = mtk_ddp_comp_layer_nr(comp); unsigned int local_layer; /* @@ -366,17 +380,15 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc) plane_state = to_mtk_plane_state(plane->state); - if (plane_state->pending.config) { - if (i >= comp_layer_nr) { - comp = mtk_crtc->ddp_comp[1]; - local_layer = i - comp_layer_nr; - } else - local_layer = i; - - mtk_ddp_comp_layer_config(comp, local_layer, - plane_state); - plane_state->pending.config = false; - } + if (!plane_state->pending.config) + continue; + + comp = mtk_drm_ddp_comp_for_plane(crtc, plane, + &local_layer); + + mtk_ddp_comp_layer_config(comp, local_layer, + plane_state); + plane_state->pending.config = false; } mtk_crtc->pending_planes = false; } From patchwork Tue Nov 5 21:10:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 11228635 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 302E313A4 for ; Tue, 5 Nov 2019 21:10:59 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 2153E2087E for ; Tue, 5 Nov 2019 21:10:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2153E2087E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=poorly.run Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CF9DE6E9F7; Tue, 5 Nov 2019 21:10:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yw1-xc41.google.com (mail-yw1-xc41.google.com [IPv6:2607:f8b0:4864:20::c41]) by gabe.freedesktop.org (Postfix) with ESMTPS id 26BD76E9D9 for ; Tue, 5 Nov 2019 21:10:55 +0000 (UTC) Received: by mail-yw1-xc41.google.com with SMTP id i2so8820842ywg.13 for ; Tue, 05 Nov 2019 13:10:55 -0800 (PST) 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=47K5oOg7WLw5/3p9dwg+0DGsBD3xNcb5zwIbofYoaPA=; b=kNhFeXWtkrWpF3XPQU7U/xp2A9mq9OBuvRQj+U3RAUh7F65YTGC56/P3kaq87dvj2X Ft5XXU+TjuEJMqo3QC5S7m7eXzNtzRALGqi+Xh5QS4y/4G14Lf8GmeSN/vSGenBaIdtm 9zcm10i8jhGkzhUOjckJYbbL6WUUpwwktDEpJQd2fp0KNphgkm/t+lquAnS7HrDGFZMf KERoZOqSO4FgupOPQCnRPmbjWbZdX1b5C4bXYdZq/6Dc1vom1B5b++KQ+3BF6Vg0D7Dy 83AUZQq6sPlNsyrTklchD3PtKCAypOOalYvXjJbGg+ckmpQSMDsZ7wy0lM3PaUwJbpxG VKfQ== X-Gm-Message-State: APjAAAVpR5FMBcbtGXKp4KTX6mTmA9Oo84Ay+5YxBXb2ONsjfc0F363u tRj9VbO1GHt7YLpYB/KshCOtkSKKZJQ= X-Google-Smtp-Source: APXvYqwa5e6g0vw3L3tFhW0BtB4ETIxgip1pNsXJmRwcKlnn/4sNZ5kkBKbaTE9F2U4hGDttwHOBxg== X-Received: by 2002:a81:db07:: with SMTP id u7mr4709820ywm.126.1572988253967; Tue, 05 Nov 2019 13:10:53 -0800 (PST) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:89c6:2139:5435:371d]) by smtp.gmail.com with ESMTPSA id j66sm1815216ywb.101.2019.11.05.13.10.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Nov 2019 13:10:53 -0800 (PST) From: Sean Paul To: dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org Subject: [PATCH v2 3/7] drm/mediatek: Add plumbing for layer_check hook Date: Tue, 5 Nov 2019 16:10:20 -0500 Message-Id: <20191105211034.123937-4-sean@poorly.run> X-Mailer: git-send-email 2.24.0.rc1.363.gb1bccd3e3d-goog In-Reply-To: <20191105211034.123937-1-sean@poorly.run> References: <20191105211034.123937-1-sean@poorly.run> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poorly.run; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=47K5oOg7WLw5/3p9dwg+0DGsBD3xNcb5zwIbofYoaPA=; b=CWNIiMSHLVnAufWZgrmvlq1asdA7IwpWS/kZgw6NLjJTJTgeYxEfGOldA6SUYIn36/ /XlzTYjXGfnqwPIlshx5rIUyuA210kV1lo+8QucYHMdWnRSGIXYOvA0Knm0op+7zFD1s nb/3HMlqMnYKEn8KKAcVudt1XHSAyRl2fbpsIehgiznPgxQfgf8grLlQipXhSnACYR87 QmM1jNs5KHPflI2HM+s/W2tNhTjf0g2GltXN0UlTxDc9yyUYsgia56eXCwNEiTchzaA9 q8Ozr+sw2Ric7EQ3d/lulCZyQz8W/oWYyrtDtc8cgQhyIXSA5fmHYQjgalMlgZ5cPgIe qTFQ== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dcastagna@chromium.org, matthias.bgg@gmail.com, mcasas@chromium.org, Sean Paul , frkoenig@chromium.org, linux-arm-kernel@lists.infradead.org, markyacoub@google.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Sean Paul This allows components to implement a .layer_check callback for their layers which is called during atomic_check. Signed-off-by: Sean Paul --- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 10 ++++++++++ drivers/gpu/drm/mediatek/mtk_drm_crtc.h | 2 ++ drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 12 ++++++++++++ drivers/gpu/drm/mediatek/mtk_drm_plane.c | 6 ++++++ 4 files changed, 30 insertions(+) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c index ccf395f17a99..04e7e4bdbdb5 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c @@ -394,6 +394,16 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc) } } +int mtk_drm_crtc_plane_check(struct drm_crtc *crtc, struct drm_plane *plane, + struct mtk_plane_state *state) +{ + unsigned int local_layer; + struct mtk_ddp_comp *comp; + + comp = mtk_drm_ddp_comp_for_plane(crtc, plane, &local_layer); + return mtk_ddp_comp_layer_check(comp, local_layer, state); +} + static void mtk_drm_crtc_atomic_enable(struct drm_crtc *crtc, struct drm_crtc_state *old_state) { diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.h b/drivers/gpu/drm/mediatek/mtk_drm_crtc.h index fcc134eb00c9..6afe1c19557a 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.h +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.h @@ -19,5 +19,7 @@ void mtk_crtc_ddp_irq(struct drm_crtc *crtc, struct mtk_ddp_comp *comp); int mtk_drm_crtc_create(struct drm_device *drm_dev, const enum mtk_ddp_comp_id *path, unsigned int path_len); +int mtk_drm_crtc_plane_check(struct drm_crtc *crtc, struct drm_plane *plane, + struct mtk_plane_state *state); #endif /* MTK_DRM_CRTC_H */ diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h index 26441f4d1ad3..3de371e28bdf 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h @@ -80,6 +80,9 @@ struct mtk_ddp_comp_funcs { unsigned int (*layer_nr)(struct mtk_ddp_comp *comp); void (*layer_on)(struct mtk_ddp_comp *comp, unsigned int idx); void (*layer_off)(struct mtk_ddp_comp *comp, unsigned int idx); + int (*layer_check)(struct mtk_ddp_comp *comp, + unsigned int idx, + struct mtk_plane_state *state); void (*layer_config)(struct mtk_ddp_comp *comp, unsigned int idx, struct mtk_plane_state *state); void (*gamma_set)(struct mtk_ddp_comp *comp, @@ -152,6 +155,15 @@ static inline void mtk_ddp_comp_layer_off(struct mtk_ddp_comp *comp, comp->funcs->layer_off(comp, idx); } +static inline int mtk_ddp_comp_layer_check(struct mtk_ddp_comp *comp, + unsigned int idx, + struct mtk_plane_state *state) +{ + if (comp->funcs && comp->funcs->layer_check) + return comp->funcs->layer_check(comp, idx, state); + return 0; +} + static inline void mtk_ddp_comp_layer_config(struct mtk_ddp_comp *comp, unsigned int idx, struct mtk_plane_state *state) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c index 584a9ecadce6..58b02fffe321 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c @@ -84,6 +84,7 @@ static int mtk_plane_atomic_check(struct drm_plane *plane, { struct drm_framebuffer *fb = state->fb; struct drm_crtc_state *crtc_state; + int ret; if (!fb) return 0; @@ -91,6 +92,11 @@ static int mtk_plane_atomic_check(struct drm_plane *plane, if (!state->crtc) return 0; + ret = mtk_drm_crtc_plane_check(state->crtc, plane, + to_mtk_plane_state(state)); + if (ret) + return ret; + crtc_state = drm_atomic_get_crtc_state(state->state, state->crtc); if (IS_ERR(crtc_state)) return PTR_ERR(crtc_state); From patchwork Tue Nov 5 21:10:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 11228637 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6367F1390 for ; Tue, 5 Nov 2019 21:11:01 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 5061F2087E for ; Tue, 5 Nov 2019 21:11:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5061F2087E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=poorly.run Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 271B36E9FE; Tue, 5 Nov 2019 21:10:59 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yw1-xc44.google.com (mail-yw1-xc44.google.com [IPv6:2607:f8b0:4864:20::c44]) by gabe.freedesktop.org (Postfix) with ESMTPS id 23FDA6E9FE for ; Tue, 5 Nov 2019 21:10:57 +0000 (UTC) Received: by mail-yw1-xc44.google.com with SMTP id a83so7411996ywe.11 for ; Tue, 05 Nov 2019 13:10:57 -0800 (PST) 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=9rSYARhN3b2F7BmOpE2cXjpPtSaFQKmzVCGOumhcuwg=; b=gC4FZNs2tnNBOC3MaEx5dvHz6O7+xVifh9nuNJdawZz3N3Elt7eLGKDUBuP5RFF3+5 rTrocqvnzvDtck+konxAMbDstbg9dBrvUY7Sqz8ZG3L0BR3fkVp1YffQ3Qbgx1FPFudq FthfJ/XtQNNIjan6GuZ3FXOTJXjAR5sVxruSwWvwureVMAqP4wUH1VnsGvbO+D2WImoK wQijRPn/8Y4JwpzCwW1/f/8LmuPLsZmQnmM/y6F5S8+9OBMBWIftZ0KTlsfhlx8vO5HP /5VRG/QNHSykNhYhso9cl6BhRyYe8wzwpkCPGv7IAcP0nnNtoOLBXgvVK4TYCgGkKu7Q w0bg== X-Gm-Message-State: APjAAAUNCLyTBUjlcfeCYnZp8m5ZgLSCsY2ZD3zoUcacE7tl980ztWsS R9z8ICHm5OV25RJvTTmUKRgzgpJe7XY= X-Google-Smtp-Source: APXvYqwk0F8Xq86aLEEo6QvW5jscZPzVRTRYEBQOJjXehNuiMOKQ4SUnYGK0LLbYQDo3+77/8w4Jtw== X-Received: by 2002:a0d:f8c6:: with SMTP id i189mr24531710ywf.411.1572988255960; Tue, 05 Nov 2019 13:10:55 -0800 (PST) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:89c6:2139:5435:371d]) by smtp.gmail.com with ESMTPSA id j66sm1815216ywb.101.2019.11.05.13.10.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Nov 2019 13:10:55 -0800 (PST) From: Sean Paul To: dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org Subject: [PATCH v2 4/7] drm/mediatek: Plumb supported rotation values from components to plane init Date: Tue, 5 Nov 2019 16:10:21 -0500 Message-Id: <20191105211034.123937-5-sean@poorly.run> X-Mailer: git-send-email 2.24.0.rc1.363.gb1bccd3e3d-goog In-Reply-To: <20191105211034.123937-1-sean@poorly.run> References: <20191105211034.123937-1-sean@poorly.run> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poorly.run; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9rSYARhN3b2F7BmOpE2cXjpPtSaFQKmzVCGOumhcuwg=; b=SOht2ohCjqLrlZPq55rZ3anuMMKFp/QgaSmJhUWGEFjcZ3/AAFfFKH7iOkzM0vgcv3 W1J6H42pEnK3h94IuJb/CT9RHm5BVz3cAqXX97FID9YTw/D9vO6XoOKwNnFgNiRtdBrT ATE0IH8Ay+I9ekaK7yQVtxWDauagErUrCz7Qz5ZUCLhHxtEN8dls/5g4POuA+ug136/H MTabTceDtlw2hfiztNZM4KLFVDzh5/zGY4dWp4Owzf7Su0VcbzRxEoPmOlgbsXuy8FCO B8RGeds9Qd3QlnkdC7ACFgZPu7XOuk0KOeTmXx3lanPTLV1UrVKtS3PZu/O2wdJjM41B 6KOw== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dcastagna@chromium.org, matthias.bgg@gmail.com, mcasas@chromium.org, Sean Paul , frkoenig@chromium.org, linux-arm-kernel@lists.infradead.org, markyacoub@google.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Sean Paul This patch adds the ability for components to expose supported rotations which will be exposed to userspace via a plane rotation property. No functional changes in this patch. Signed-off-by: Sean Paul --- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 4 +++- drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 10 ++++++++++ drivers/gpu/drm/mediatek/mtk_drm_plane.c | 12 +++++++++++- drivers/gpu/drm/mediatek/mtk_drm_plane.h | 4 +++- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c index 04e7e4bdbdb5..f80a8ba75977 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c @@ -600,13 +600,15 @@ static int mtk_drm_crtc_init_comp_planes(struct drm_device *drm_dev, int comp_idx, int pipe) { int num_planes = mtk_drm_crtc_num_comp_planes(mtk_crtc, comp_idx); + struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[comp_idx]; int i, ret; for (i = 0; i < num_planes; i++) { ret = mtk_plane_init(drm_dev, &mtk_crtc->planes[mtk_crtc->layer_nr], BIT(pipe), - mtk_drm_crtc_plane_type(mtk_crtc->layer_nr)); + mtk_drm_crtc_plane_type(mtk_crtc->layer_nr), + mtk_ddp_comp_supported_rotations(comp)); if (ret) return ret; diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h index 3de371e28bdf..2f1e9e75b8da 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h @@ -77,6 +77,7 @@ struct mtk_ddp_comp_funcs { void (*stop)(struct mtk_ddp_comp *comp); void (*enable_vblank)(struct mtk_ddp_comp *comp, struct drm_crtc *crtc); void (*disable_vblank)(struct mtk_ddp_comp *comp); + unsigned int (*supported_rotations)(struct mtk_ddp_comp *comp); unsigned int (*layer_nr)(struct mtk_ddp_comp *comp); void (*layer_on)(struct mtk_ddp_comp *comp, unsigned int idx); void (*layer_off)(struct mtk_ddp_comp *comp, unsigned int idx); @@ -133,6 +134,15 @@ static inline void mtk_ddp_comp_disable_vblank(struct mtk_ddp_comp *comp) comp->funcs->disable_vblank(comp); } +static inline +unsigned int mtk_ddp_comp_supported_rotations(struct mtk_ddp_comp *comp) +{ + if (comp->funcs && comp->funcs->supported_rotations) + return comp->funcs->supported_rotations(comp); + + return 0; +} + static inline unsigned int mtk_ddp_comp_layer_nr(struct mtk_ddp_comp *comp) { if (comp->funcs && comp->funcs->layer_nr) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c index 58b02fffe321..cd7c97eb7ee6 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c @@ -138,6 +138,7 @@ static void mtk_plane_atomic_update(struct drm_plane *plane, state->pending.y = plane->state->dst.y1; state->pending.width = drm_rect_width(&plane->state->dst); state->pending.height = drm_rect_height(&plane->state->dst); + state->pending.rotation = plane->state->rotation; wmb(); /* Make sure the above parameters are set before update */ state->pending.dirty = true; } @@ -160,7 +161,8 @@ static const struct drm_plane_helper_funcs mtk_plane_helper_funcs = { }; int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane, - unsigned long possible_crtcs, enum drm_plane_type type) + unsigned long possible_crtcs, enum drm_plane_type type, + unsigned int supported_rotations) { int err; @@ -172,6 +174,14 @@ int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane, return err; } + if (supported_rotations & ~DRM_MODE_ROTATE_0) { + err = drm_plane_create_rotation_property(plane, + DRM_MODE_ROTATE_0, + supported_rotations); + if (err) + DRM_INFO("Create rotation property failed\n"); + } + drm_plane_helper_add(plane, &mtk_plane_helper_funcs); return 0; diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.h b/drivers/gpu/drm/mediatek/mtk_drm_plane.h index 6f842df722c7..760885e35b27 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_plane.h +++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.h @@ -20,6 +20,7 @@ struct mtk_plane_pending_state { unsigned int y; unsigned int width; unsigned int height; + unsigned int rotation; bool dirty; }; @@ -35,6 +36,7 @@ to_mtk_plane_state(struct drm_plane_state *state) } int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane, - unsigned long possible_crtcs, enum drm_plane_type type); + unsigned long possible_crtcs, enum drm_plane_type type, + unsigned int supported_rotations); #endif From patchwork Tue Nov 5 21:10:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 11228641 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0ED9413A4 for ; Tue, 5 Nov 2019 21:11:04 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 006162087E for ; Tue, 5 Nov 2019 21:11:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 006162087E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=poorly.run Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 56BBE6EA20; Tue, 5 Nov 2019 21:11:01 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yb1-xb41.google.com (mail-yb1-xb41.google.com [IPv6:2607:f8b0:4864:20::b41]) by gabe.freedesktop.org (Postfix) with ESMTPS id B88CC6EA20 for ; Tue, 5 Nov 2019 21:10:58 +0000 (UTC) Received: by mail-yb1-xb41.google.com with SMTP id i15so1085796ybq.0 for ; Tue, 05 Nov 2019 13:10:58 -0800 (PST) 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=zsWMYnPd4Aw1CcoU1mvThLbX9TGaEGFP0Ia7fKCg/po=; b=SmdMQrIpZUJElSGXKyL3B6L3Q2oB25zhpyK50iSKmO8udouN0HOMopVYBRJeAISDAt kRS6SuEZKV6SFq34qp5A3Xnnw5VY/yPrGxOjgtrOocmKA7MB09QwMY64LiYzswLH9/5j ndsZDwuPRD66ni1iuOtNDDyPiMSjfXHagJHEbg+fjP204ruVKejgAlmf6v0QRmwlR0VW oAQr5xTCcvlnzhLvQZ11F1lJr6S2VLDo7Y/dnH2AMvQrMneXQyNt7YobkW9Z5uLq2ax0 f84xhEqq/0+/RnhOA6rRkbyhnJyPIQ6vBn3CtKHPgeDVw28nBnbe4cmfGDlrJezdpmMq 1YnQ== X-Gm-Message-State: APjAAAUrBgTPm4r1F1jHWUogejVAZHUYAzKyBazlAW4PCpLgxvoz0ocN 4KIFF1YVSCzFrAlTd2vIukxW1kQ6+7k= X-Google-Smtp-Source: APXvYqzOzXSiMBon8QdPw00BMVJRl1tQsrr2noW3epgpCXkqmtMfVGaEK0hFffrZka1kAFUZhMO3RA== X-Received: by 2002:a25:bd88:: with SMTP id f8mr28380318ybh.135.1572988257623; Tue, 05 Nov 2019 13:10:57 -0800 (PST) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:89c6:2139:5435:371d]) by smtp.gmail.com with ESMTPSA id j66sm1815216ywb.101.2019.11.05.13.10.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Nov 2019 13:10:57 -0800 (PST) From: Sean Paul To: dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org Subject: [PATCH v2 5/7] drm/mediatek: Support reflect-y plane rotation Date: Tue, 5 Nov 2019 16:10:22 -0500 Message-Id: <20191105211034.123937-6-sean@poorly.run> X-Mailer: git-send-email 2.24.0.rc1.363.gb1bccd3e3d-goog In-Reply-To: <20191105211034.123937-1-sean@poorly.run> References: <20191105211034.123937-1-sean@poorly.run> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poorly.run; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zsWMYnPd4Aw1CcoU1mvThLbX9TGaEGFP0Ia7fKCg/po=; b=XLW1y6CQbRxMSOYcoi5wZSuKszC0GIywu0TVxMMjfwFK1PnNXWKRUIH6TK4/d5kMO1 /ww32khexerF4EmfttsPK6IEubjlkxvsbV1NZrgKzY4l5FzqonI+/eBp6TEZTCPzs00A iGztN2ZPkPUH115D6+aBVICxtW0khGZIU2sJZUOV8N8XRiodrapKWOk78mTGZA+v90p/ b9tPSxG9B9wJOzQO27Rq4m2HtAEoEfcxFb5MZ3rtqbe7YfLhS+cL9aan0PaflwhRfSnM dWXbhFH5Ia/KEA98zjYpIdoCmh+l55LuEdIoIAxUjARlKE626MTmrMQ2Uhdgb9RfG5Hw cXHw== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dcastagna@chromium.org, matthias.bgg@gmail.com, mcasas@chromium.org, Sean Paul , frkoenig@chromium.org, linux-arm-kernel@lists.infradead.org, markyacoub@google.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Sean Paul Expose the rotation property and handle REFLECT_Y rotations. Changes in v2: - Move the check logic into mtk_disp_ovl.c since it doesn't apply to rdma Link to v1: https://lists.freedesktop.org/archives/dri-devel/2019-November/242312.html Cc: Fritz Koenig Cc: Daniele Castagna Cc: Miguel Casas Cc: Mark Yacoub Signed-off-by: Sean Paul --- drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 42 +++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c index 14878ebf59d7..fae10aead3d5 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c @@ -3,6 +3,8 @@ * Copyright (c) 2015 MediaTek Inc. */ +#include + #include #include #include @@ -50,6 +52,7 @@ OVL_CON_CLRFMT_RGB : 0) #define OVL_CON_AEN BIT(8) #define OVL_CON_ALPHA 0xff +#define OVL_CON_VIRT_FLIP BIT(9) struct mtk_disp_ovl_data { unsigned int addr; @@ -137,6 +140,38 @@ static unsigned int mtk_ovl_layer_nr(struct mtk_ddp_comp *comp) return ovl->data->layer_nr; } +static unsigned int mtk_ovl_supported_rotations(struct mtk_ddp_comp *comp) +{ + return DRM_MODE_ROTATE_0 | DRM_MODE_REFLECT_Y; +} + +static int mtk_ovl_layer_check(struct mtk_ddp_comp *comp, unsigned int idx, + struct mtk_plane_state *mtk_state) +{ + struct drm_plane_state *state = &mtk_state->base; + unsigned int rotation = 0; + + rotation = drm_rotation_simplify(state->rotation, + DRM_MODE_ROTATE_0 | + DRM_MODE_REFLECT_Y); + rotation &= ~DRM_MODE_ROTATE_0; + + /* We can only do reflection, not rotation */ + if ((rotation & DRM_MODE_ROTATE_MASK) != 0) + return -EINVAL; + + /* + * TODO: Rotating/reflecting YUV buffers is not supported at this time. + * Only RGB[AX] variants are supported. + */ + if (state->fb->format->is_yuv && rotation != 0) + return -EINVAL; + + state->rotation = rotation; + + return 0; +} + static void mtk_ovl_layer_on(struct mtk_ddp_comp *comp, unsigned int idx) { unsigned int reg; @@ -229,6 +264,11 @@ static void mtk_ovl_layer_config(struct mtk_ddp_comp *comp, unsigned int idx, if (idx != 0) con |= OVL_CON_AEN | OVL_CON_ALPHA; + if (pending->rotation & DRM_MODE_REFLECT_Y) { + con |= OVL_CON_VIRT_FLIP; + addr += (pending->height - 1) * pending->pitch; + } + writel_relaxed(con, comp->regs + DISP_REG_OVL_CON(idx)); writel_relaxed(pitch, comp->regs + DISP_REG_OVL_PITCH(idx)); writel_relaxed(src_size, comp->regs + DISP_REG_OVL_SRC_SIZE(idx)); @@ -263,9 +303,11 @@ static const struct mtk_ddp_comp_funcs mtk_disp_ovl_funcs = { .stop = mtk_ovl_stop, .enable_vblank = mtk_ovl_enable_vblank, .disable_vblank = mtk_ovl_disable_vblank, + .supported_rotations = mtk_ovl_supported_rotations, .layer_nr = mtk_ovl_layer_nr, .layer_on = mtk_ovl_layer_on, .layer_off = mtk_ovl_layer_off, + .layer_check = mtk_ovl_layer_check, .layer_config = mtk_ovl_layer_config, .bgclr_in_on = mtk_ovl_bgclr_in_on, .bgclr_in_off = mtk_ovl_bgclr_in_off, From patchwork Tue Nov 5 21:10:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 11228643 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2E81D13A4 for ; Tue, 5 Nov 2019 21:11:06 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 1FE562087E for ; Tue, 5 Nov 2019 21:11:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1FE562087E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=poorly.run Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AED0F6EA33; Tue, 5 Nov 2019 21:11:01 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yw1-xc41.google.com (mail-yw1-xc41.google.com [IPv6:2607:f8b0:4864:20::c41]) by gabe.freedesktop.org (Postfix) with ESMTPS id 185F36EA20 for ; Tue, 5 Nov 2019 21:11:00 +0000 (UTC) Received: by mail-yw1-xc41.google.com with SMTP id d5so8825234ywk.9 for ; Tue, 05 Nov 2019 13:11:00 -0800 (PST) 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=wkKPVb6pP5aq3OLgQzfYcwJ5aNwtIA26btnxZ0mORbM=; b=XMFIMnbkRgsYVg2hPuubYZFb7kS7w7r8At7v+6MoDy2u3heatFb+J8hgjcdMAzKEgi S+yLx06RmDYtX0mBvtw3xxfXYS6VAEbkcDfjzA3vX+DLXFHVy+TPoL3NPxptVvZvEnOn YbIboUfoNCAtAALDw16HMWsrA5TjgQGsV8isSfNCtbSBzHebhI4a5W9xQ8PSevBF2amn xGcIRjiBdJ01aL2P8RCujhgVGpxMAxMc9eTXggn7oqxbf031z6X8EwaeudAif2VhjzjD syhGJbTwuRYhWljC1lT6QuF2VwWLv1jP+p0chjjA2fX0s1h+sdaIvEXMP0etIQ7tCajk MgWQ== X-Gm-Message-State: APjAAAWCSJPhM5DYdKFGpnJUG63R8lI+MtvaOxQoaUMxtL98WN7tLv8a 293f6jTjj3PvJo1Opdvx8uwpq9UudhI= X-Google-Smtp-Source: APXvYqyUCARybzwRjLGPnWuXk2JznQo9jeaLOMjuFbMyCaJBgQqqFWRHOQEwoBTwK7kELxzPui6Q+w== X-Received: by 2002:a0d:ca12:: with SMTP id m18mr25386699ywd.97.1572988259096; Tue, 05 Nov 2019 13:10:59 -0800 (PST) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:89c6:2139:5435:371d]) by smtp.gmail.com with ESMTPSA id j66sm1815216ywb.101.2019.11.05.13.10.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Nov 2019 13:10:58 -0800 (PST) From: Sean Paul To: dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org Subject: [PATCH v2 6/7] drm/mediatek: Support reflect-x plane rotation Date: Tue, 5 Nov 2019 16:10:23 -0500 Message-Id: <20191105211034.123937-7-sean@poorly.run> X-Mailer: git-send-email 2.24.0.rc1.363.gb1bccd3e3d-goog In-Reply-To: <20191105211034.123937-1-sean@poorly.run> References: <20191105211034.123937-1-sean@poorly.run> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poorly.run; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wkKPVb6pP5aq3OLgQzfYcwJ5aNwtIA26btnxZ0mORbM=; b=Mq6TglzNM33XbXY7U0CDyP267OuSAHrU9t/Sm6DqR/tMUQ61hFziZ0yRWSJeugur5+ rDiepGUZBx3TNu3ZVfa/ay14OgmV9ay+S0QbY+AeRHda6+7AaqpR3TlAtZloi5bE6HTT PAtXrU8G/YWwxUEcsW7XJ71obGHphVljhfNcT3Um/caOXlpaBQFOrfPvNYE9MbHWmGJS XhqSNf+g8ZLpnScwCo4xMTQN5Cfe3w5agoGjyvbkaPo0IPh7kGmc/q3TA8isg6KZyICV cECCGKePRvI6jpsOiDJKHdlsEHT40fovY2XPOeWib4+FkwXFr5Wqh3bpHtJ9E/VtUC8K vr+w== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dcastagna@chromium.org, matthias.bgg@gmail.com, mcasas@chromium.org, Sean Paul , frkoenig@chromium.org, linux-arm-kernel@lists.infradead.org, markyacoub@google.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Sean Paul Add support for REFLECT_X rotations. Cc: Fritz Koenig Cc: Daniele Castagna Cc: Miguel Casas Cc: Mark Yacoub Signed-off-by: Sean Paul --- drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c index fae10aead3d5..f4c4d3fedc5f 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c @@ -53,6 +53,7 @@ #define OVL_CON_AEN BIT(8) #define OVL_CON_ALPHA 0xff #define OVL_CON_VIRT_FLIP BIT(9) +#define OVL_CON_HORZ_FLIP BIT(10) struct mtk_disp_ovl_data { unsigned int addr; @@ -142,7 +143,8 @@ static unsigned int mtk_ovl_layer_nr(struct mtk_ddp_comp *comp) static unsigned int mtk_ovl_supported_rotations(struct mtk_ddp_comp *comp) { - return DRM_MODE_ROTATE_0 | DRM_MODE_REFLECT_Y; + return DRM_MODE_ROTATE_0 | DRM_MODE_REFLECT_Y | + DRM_MODE_REFLECT_X; } static int mtk_ovl_layer_check(struct mtk_ddp_comp *comp, unsigned int idx, @@ -153,6 +155,7 @@ static int mtk_ovl_layer_check(struct mtk_ddp_comp *comp, unsigned int idx, rotation = drm_rotation_simplify(state->rotation, DRM_MODE_ROTATE_0 | + DRM_MODE_REFLECT_X | DRM_MODE_REFLECT_Y); rotation &= ~DRM_MODE_ROTATE_0; @@ -269,6 +272,11 @@ static void mtk_ovl_layer_config(struct mtk_ddp_comp *comp, unsigned int idx, addr += (pending->height - 1) * pending->pitch; } + if (pending->rotation & DRM_MODE_REFLECT_X) { + con |= OVL_CON_HORZ_FLIP; + addr += pending->pitch - 1; + } + writel_relaxed(con, comp->regs + DISP_REG_OVL_CON(idx)); writel_relaxed(pitch, comp->regs + DISP_REG_OVL_PITCH(idx)); writel_relaxed(src_size, comp->regs + DISP_REG_OVL_SRC_SIZE(idx)); From patchwork Tue Nov 5 21:10:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 11228645 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DF1281390 for ; Tue, 5 Nov 2019 21:11:07 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 D099F2087E for ; Tue, 5 Nov 2019 21:11:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D099F2087E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=poorly.run Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 82DCF6EA72; Tue, 5 Nov 2019 21:11:03 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yw1-xc42.google.com (mail-yw1-xc42.google.com [IPv6:2607:f8b0:4864:20::c42]) by gabe.freedesktop.org (Postfix) with ESMTPS id D83936EA3D for ; Tue, 5 Nov 2019 21:11:01 +0000 (UTC) Received: by mail-yw1-xc42.google.com with SMTP id y64so5981407ywe.3 for ; Tue, 05 Nov 2019 13:11:01 -0800 (PST) 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=+WiVxRRU/BsDC4YALJAt3eFqvdwKtmFyjMHuXXIhN00=; b=qYVUkB1rbHOuIID8u8jESt0BPk0X/VxjmEDS+j38jiIjqLYBMyrry6lANCiv0/vjxf r/jDwObsKcnpzRqmKJ+DWwppOuzV65jjFPi41/XRqg+B72kLOx6k8SJUALwQeIiHA1vc QEa/HwJ+3cr619AITuNO8L8toFIHtMPb+nUWuMzSQhf2ChqpZXDoScUDaTgpmbe7HKCq SvB2xFwS0lyyPlxa/NggC5YLs/PMI71aj+3UXmdRAqiOY50kaPlsJV1bsBDFSSScjCsK 1vPe+vkkihlHDU0+7ENBuQmIMQ+ZTJnAPvYEny7zkg7kGKdFZUeTo3pk0XOpOLBJgQEU acpQ== X-Gm-Message-State: APjAAAUkrblUWbZgX0oeN7LfilxGN1JrCv8ih7LsUYDw/BMsPkRIWu7m dsUjHA/UAAt8yuBvIFTRgc0RcbLfg6E= X-Google-Smtp-Source: APXvYqzqhKbfG6uj0C9QtCsk5hTcg0qnCB5SoNKDWw01NkumaG0mVUCnnbjJ/lO9GqEJnRlx8UxkVA== X-Received: by 2002:a81:7053:: with SMTP id l80mr23239678ywc.377.1572988260799; Tue, 05 Nov 2019 13:11:00 -0800 (PST) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:89c6:2139:5435:371d]) by smtp.gmail.com with ESMTPSA id j66sm1815216ywb.101.2019.11.05.13.11.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Nov 2019 13:11:00 -0800 (PST) From: Sean Paul To: dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org Subject: [PATCH v2 7/7] drm/mediatek: Support 180 degree rotation Date: Tue, 5 Nov 2019 16:10:24 -0500 Message-Id: <20191105211034.123937-8-sean@poorly.run> X-Mailer: git-send-email 2.24.0.rc1.363.gb1bccd3e3d-goog In-Reply-To: <20191105211034.123937-1-sean@poorly.run> References: <20191105211034.123937-1-sean@poorly.run> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poorly.run; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+WiVxRRU/BsDC4YALJAt3eFqvdwKtmFyjMHuXXIhN00=; b=b7BvNVaq55rSQstmyVb7FVPxaDzfpQvfg2LWzAsNLXIw4Zgl5nKJ8oQMM9S+74IlZf 6evcHrczQNvXo4hfr/qCgBgUU1QXMEibjDd9StKHdtKFZ8/2d2HqLAUO9A0UGR3lsrpn HUzkGW8k5Dvge9poGrqF0sURTtUNKfmb4kwUAnaOXEdwRJJVKqRDDS3P8DeScfku51AJ xBYemInVm9isbevgdMHl1h6n0R4KLDQ6m+CMiC1pHpmibukZ66lHryHliW1ga6HcwnVx mC2RhQ1///qyMnhFQh6+pp/VxcsN1UPACfXKltS0IxDOD9OPpCxKfbtpVGrKHi0jUkDc yxmg== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dcastagna@chromium.org, matthias.bgg@gmail.com, mcasas@chromium.org, Sean Paul , frkoenig@chromium.org, linux-arm-kernel@lists.infradead.org, markyacoub@google.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Sean Paul Now that we support both reflections, we can expose 180 degree rotation and rely on the simplify routine to convert that into REFLECT_X | REFLECT_Y Signed-off-by: Sean Paul --- drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c index f4c4d3fedc5f..4a55bb6e2213 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c @@ -143,8 +143,8 @@ static unsigned int mtk_ovl_layer_nr(struct mtk_ddp_comp *comp) static unsigned int mtk_ovl_supported_rotations(struct mtk_ddp_comp *comp) { - return DRM_MODE_ROTATE_0 | DRM_MODE_REFLECT_Y | - DRM_MODE_REFLECT_X; + return DRM_MODE_ROTATE_0 | DRM_MODE_ROTATE_180 | + DRM_MODE_REFLECT_X | DRM_MODE_REFLECT_Y; } static int mtk_ovl_layer_check(struct mtk_ddp_comp *comp, unsigned int idx,