From patchwork Tue Aug 20 23:06:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171860 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp179837ily; Tue, 20 Aug 2019 16:06:32 -0700 (PDT) X-Received: by 2002:a17:902:aa08:: with SMTP id be8mr31272272plb.144.1566342392178; Tue, 20 Aug 2019 16:06:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566342392; cv=none; d=google.com; s=arc-20160816; b=WMLM9Ag4RbYxbFAQE5kKjIrqf1Rq3P8veAiiy+EfiOXpUyRaotz6dED1y8aF5n2397 sdFbwjQHvm3rfWucL+wl1XdTpA/MsM4Ji/HVPb1yspG9sWqki8lwdiJVUk5ts6nRLPAB eDV9H15DAwG+hrW9R9UUwr/oD0lM6hyU4D+xBaSk3xZ7mDKLW7FYeV7wap778Po6mRfI r2hlfr5flMFrHeafYf6qdsxMIxbue7iqqFPl4ufUjL4r0qaPtxP3dAWF8Hc8r5QhnGAF 9FSUC9LkVB176PhQk1Uv9/m70sdwdot/ByclCPMbNWQDFxuavyXDT8we8qKOhbG1Pb4t 9hIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=q1UYVKf1UgYkHQbbceABIVFSdc5VY9rhqkw1qWPFE+g=; b=b16dmmBztXjNnwcQm/KySRxGnhSwC0P7IMoobJP1NtqaQML2Q5YtHT0ajX98QHtKca u8fnTrIZWp6Tn3XtAMBXjALyjJK+FofIvpD8r3qWVU5cFG+2wWMkQfVA6ftcvPGJcGIf W8mVy5V7ia7hvME2KD/FegosVqeXUyi3k2+CScX5M++ksYDaHY3EUYxkVo1BPZxsxHJ/ P2cpQM9Utg4tftYUeLIBUlOyQ0/pQ9rpeCnpvpCjj380S3ItJxUg/ZdPH3CZJ55zP8y6 ACTOL6IZQ/Pst/YmV/yFD2ivPSHs7S7CwmDlEQTcOIKemIPcmnongw0hCllBX5bChvXn kxyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RJ0xYmr+; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id cb8sor6815164plb.4.2019.08.20.16.06.32 for (Google Transport Security); Tue, 20 Aug 2019 16:06:32 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RJ0xYmr+; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=q1UYVKf1UgYkHQbbceABIVFSdc5VY9rhqkw1qWPFE+g=; b=RJ0xYmr+le6e0PlBTw1zfPraNay7cF0OyB+nOHMyagiieh4nJXKPXaQvS3aMZyvjTO Dmk6dfoWGfWJkSpVdRwNjNYFsKpUZv/XyhMjb5cR/jkPe1xfhvU5GQb/mYk98XWCrRC/ hPu6nj+BMp2Yp5fK72qMJzbYwo/+3+MvQ0/3QmbQb7UvOVNhCwuys+knWVVbUj/WGzrq 5t+Z0pcOS3tIeJzDbdFTrjDoTkODIjDU1gC9ZudISnCQ7kbGGkZrDEswpYDtE30wx3tb Sd3hLENL8vNNiIh5S1hSRAhpRF/ZlPpW72Vs+AgHzTX5T6wwgAg08by4npeNAxrO3ZDu i6Sg== 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; bh=q1UYVKf1UgYkHQbbceABIVFSdc5VY9rhqkw1qWPFE+g=; b=GXyNaIHnc8MXNBiYBc5pRFKd56ZZ/J5iVnIEMg/wWDeHsLhzJY6hVoP6o80UyOvPo/ RVbPrzb5wo91WX13GKBt4iTOOnZ+XjIUZUST5YceRdnYKgGbKBNWGT31uMB0avZPjtch 46NmroP8p0rsqJIFumnaF9X5nZoKPvGquJbcnfhdHhavO3fl+DC8/SbFlAkI8Ndpw05N d8EU+9PEja20IvQIatGtWeiOKEvHKPHW7z9ylswLH4yzUhUd7ngEOC5idSYpdxonJVIQ cWzln/fIz8Tz1qWlWSVVjJMKisv5jrPRAxD0ry/iqbqguY6XDaV3cn0gJEsSc1WG0gTI nCGw== X-Gm-Message-State: APjAAAV67YuvbRK/Fw9jIfW+eXMqSnfm5DGOTvhsynYTAjJ/dxF3fo66 KJXqta9RrCHa/ZiIzASEZMxRgJr+ X-Google-Smtp-Source: APXvYqw5D4BZDetSBcN2Jnla7obS49bgLF/nwN7GXXGmMfCHVZaEj82kGnEeoSYhj3aNYpuZGpkXRg== X-Received: by 2002:a17:902:9895:: with SMTP id s21mr16299078plp.255.1566342391778; Tue, 20 Aug 2019 16:06:31 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id q4sm27564747pff.183.2019.08.20.16.06.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 16:06:31 -0700 (PDT) From: John Stultz To: lkml Cc: Da Lv , Rongrong Zou , Xinliang Liu , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg , Yidong Lin , John Stultz Subject: [PATCH v5 01/25] drm: kirin: Fix for hikey620 display offset problem Date: Tue, 20 Aug 2019 23:06:02 +0000 Message-Id: <20190820230626.23253-2-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820230626.23253-1-john.stultz@linaro.org> References: <20190820230626.23253-1-john.stultz@linaro.org> From: Da Lv The original HiKey (620) board has had a long running issue where when using a 1080p montior, the display would occasionally blink and come come back with a horizontal offset (usually also shifting the colors, depending on the value of the offset%4). After lots of analysis by HiSi developers, they found the issue was due to when running at 1080p, it was possible to hit the device memory bandwidth limits, which could cause the DSI signal to get out of sync. Unfortunately the DSI logic doesn't have the ability to automatically recover from this situation, but we can get a an LDI underflow interrupt when it happens. To then correct the issue, when we get an LDI underflow irq, we we can simply suspend and resume the display, which resets the hardware. Thus, this patch enables the ldi underflow interrupt, and initializes a workqueue that is used to suspend/resume the display to recover. Then when the irq occurs we clear it and schedule the workqueue to reset display engine. Cc: Rongrong Zou Cc: Xinliang Liu Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Cc: Sam Ravnborg Acked-by: Xinliang Liu Reviewed-by: Sam Ravnborg Signed-off-by: Da Lv Signed-off-by: Yidong Lin [jstultz: Reworded the commit message, checkpatch cleanups] Signed-off-by: John Stultz --- v2: Minor cleanups v3: Rename workqueue entry for clarity (suggested by Sam) --- .../gpu/drm/hisilicon/kirin/kirin_ade_reg.h | 1 + .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_ade_reg.h b/drivers/gpu/drm/hisilicon/kirin/kirin_ade_reg.h index e2ac09894a6d..0da860200410 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_ade_reg.h +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_ade_reg.h @@ -83,6 +83,7 @@ #define VSIZE_OFST 20 #define LDI_INT_EN 0x741C #define FRAME_END_INT_EN_OFST 1 +#define UNDERFLOW_INT_EN_OFST 2 #define LDI_CTRL 0x7420 #define BPP_OFST 3 #define DATA_GATE_EN BIT(2) diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index 0df1afdf319d..d972342527b8 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -58,6 +58,7 @@ struct ade_hw_ctx { struct ade_crtc { struct drm_crtc base; struct ade_hw_ctx *ctx; + struct work_struct display_reset_wq; bool enable; u32 out_format; }; @@ -176,6 +177,7 @@ static void ade_init(struct ade_hw_ctx *ctx) */ ade_update_bits(base + ADE_CTRL, FRM_END_START_OFST, FRM_END_START_MASK, REG_EFFECTIVE_IN_ADEEN_FRMEND); + ade_update_bits(base + LDI_INT_EN, UNDERFLOW_INT_EN_OFST, MASK(1), 1); } static bool ade_crtc_mode_fixup(struct drm_crtc *crtc, @@ -345,6 +347,17 @@ static void ade_crtc_disable_vblank(struct drm_crtc *crtc) MASK(1), 0); } +static void drm_underflow_wq(struct work_struct *work) +{ + struct ade_crtc *acrtc = container_of(work, struct ade_crtc, + display_reset_wq); + struct drm_device *drm_dev = (&acrtc->base)->dev; + struct drm_atomic_state *state; + + state = drm_atomic_helper_suspend(drm_dev); + drm_atomic_helper_resume(drm_dev, state); +} + static irqreturn_t ade_irq_handler(int irq, void *data) { struct ade_crtc *acrtc = data; @@ -362,6 +375,12 @@ static irqreturn_t ade_irq_handler(int irq, void *data) MASK(1), 1); drm_crtc_handle_vblank(crtc); } + if (status & BIT(UNDERFLOW_INT_EN_OFST)) { + ade_update_bits(base + LDI_INT_CLR, UNDERFLOW_INT_EN_OFST, + MASK(1), 1); + DRM_ERROR("LDI underflow!"); + schedule_work(&acrtc->display_reset_wq); + } return IRQ_HANDLED; } @@ -1038,6 +1057,9 @@ static int ade_drm_init(struct platform_device *pdev) /* vblank irq init */ ret = devm_request_irq(dev->dev, ctx->irq, ade_irq_handler, IRQF_SHARED, dev->driver->name, acrtc); + + INIT_WORK(&acrtc->display_reset_wq, drm_underflow_wq); + if (ret) return ret; From patchwork Tue Aug 20 23:06:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171861 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp179861ily; Tue, 20 Aug 2019 16:06:33 -0700 (PDT) X-Received: by 2002:a65:5183:: with SMTP id h3mr26991166pgq.250.1566342393330; Tue, 20 Aug 2019 16:06:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566342393; cv=none; d=google.com; s=arc-20160816; b=h7a33I7h5xyyxverrakHgZ27GKUj2hBDd9qQjHpHy6aSI7eIA7tC9d3VX4ZQ27DFBQ q6HdaVlVIsWg8JGKrpWS6XiFwrlydobiRk72y8GDezlAl8ssiRSVjAJgEj7NEphpzv1i rpVsqOMEXh2eMWwAdMsGKjAbDCqeack7u1N973a0rzY+FltMZSCorp4NgnwHyNqEIwAk TCU/b31ZfYxiLE7UBPDX0A4U0Qrl3GK8q61bR7EyvZliihcc05COgQ5WbNYRUiunzM5d 2vVIuvxzD2LAe3MeOaPNnDPXiG862Xvn0H675Rpxm81PYi/VTXCqvmFbxf1ehrjmLeHR cmMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=a1GVwhYagMUqR4YrGTGm12es7UZSRELJ0+S6Uqb2xtg=; b=NNgQKmIXYAmaePRYFHGkOr3c/9Z1UXWmlzq5zfIYqUH7UfVZvfdGTqPWQdnqTmbbzj 7mR42YB8Kkhx0tZPFK/3+bV8xW9JU8KiY+jadyeaKFtu330iAUmvP6TKaBFsBywGqnZK W6X9s/pHhX9uiG2MJys2WuO8XBT39BYK+NOQ9ZiEjDbk0UphDzYVUtJr5oxaHfPabkcF Aqx3hW4lXJnvv4bjRX95FcDmJ2g3ZDQxPzKBL/LKP+mlzbEDp2lM6t+9xZ3D7cNMkKDs G8zQ/HoSJ+eQPrwvAAi5YzfOJgcNLMWl76hqd07z0dolMkAQT50Qt/mdHhs22az83XZz h+Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yFWWviao; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id j21sor5585998pfi.64.2019.08.20.16.06.33 for (Google Transport Security); Tue, 20 Aug 2019 16:06:33 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yFWWviao; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=a1GVwhYagMUqR4YrGTGm12es7UZSRELJ0+S6Uqb2xtg=; b=yFWWviaoJKvZh1gOUEEuvxQyXX8glgCMCwN+TIErGjfUlBngteyvmSPNhOofiL4Mii Zbop9rO9WeLspnC+iAyTRUzfQxjE0X7FR3LQ5A1amxtR1piWk0eyqPKNBvLkjhft2YgQ X0jPP1nB5GA03sEkSLeQwBSzMwgaNgn/joRlvd2tIjyt3cOwRVZk8+2tgd/HDUEH4wJ3 jue0x0mf0hH83Pi/S34CETHHke/BbfFjwoAfxSgh4OUtbGoO38fwqqCPgmvxQQDVgftO dM5+qSshsRvTfLN2y7XS1oZf1DVuar/RI+KH01AtphduE0GzPy0N2Y8o3LTivXll9sZS t7wg== 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; bh=a1GVwhYagMUqR4YrGTGm12es7UZSRELJ0+S6Uqb2xtg=; b=CJzDQMzhZzAgfNhDTMepHkciEeh8L6m2aLcLQtST26j9NQKbCXEElOdacaPOQsewAU RaMyKe0HNPLTlK2fZHnJbWQmWKTb8IVrIzkzk8FOI6N3oro3cJq3ifToIC7ik9JzB2L3 ItjiLBGsP919jyIbLhktTGC1hIqVdzoS2kbkjtwYUMZDpLJnIH3PPVv/A7itiH/OsP1V /1Qqxuh7Mtk/8Yd6cm2dc+sz+62ui03ecSD3OyytHk75aLM1XJ1948qEo5MkNuadoqDh WmzNu2m4VoL3VeFJG5eFsIeEL2ScMdW5dqqVskLiIV56cCxQ8Uy+eJBVQzdCaRzGvDB4 VEcg== X-Gm-Message-State: APjAAAV6116SbpnIZLft2VRcm3eOWOqZ+Vckm3ly07OBThDn83gdT3TH 2PQcmXmcj90VeyLxqyKlvJQ4fP/h X-Google-Smtp-Source: APXvYqxT0eCJKaQPFDkMyQyR74+WfkWox/lmoKEdkV85flDMF6esaDLd5hpaiKtRGi2yjMmv8A+vDQ== X-Received: by 2002:aa7:96dc:: with SMTP id h28mr32692331pfq.86.1566342392992; Tue, 20 Aug 2019 16:06:32 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id q4sm27564747pff.183.2019.08.20.16.06.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 16:06:32 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Rongrong Zou , Xinliang Liu , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg Subject: [PATCH v5 02/25] drm: kirin: Remove HISI_KIRIN_DW_DSI config option Date: Tue, 20 Aug 2019 23:06:03 +0000 Message-Id: <20190820230626.23253-3-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820230626.23253-1-john.stultz@linaro.org> References: <20190820230626.23253-1-john.stultz@linaro.org> The CONFIG_HISI_KIRIN_DW_DSI option is only used w/ kirin driver, so cut out the middleman and condense the config logic down. Cc: Rongrong Zou Cc: Xinliang Liu Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Cc: Sam Ravnborg Acked-by: Xinliang Liu Reviewed-by: Sam Ravnborg Signed-off-by: John Stultz --- v5: Build fixup for module config noticed by Sam --- drivers/gpu/drm/hisilicon/kirin/Kconfig | 10 +--------- drivers/gpu/drm/hisilicon/kirin/Makefile | 3 +-- 2 files changed, 2 insertions(+), 11 deletions(-) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/kirin/Kconfig b/drivers/gpu/drm/hisilicon/kirin/Kconfig index 0fa29af08ad0..290553e2f6b4 100644 --- a/drivers/gpu/drm/hisilicon/kirin/Kconfig +++ b/drivers/gpu/drm/hisilicon/kirin/Kconfig @@ -5,16 +5,8 @@ config DRM_HISI_KIRIN select DRM_KMS_HELPER select DRM_GEM_CMA_HELPER select DRM_KMS_CMA_HELPER - select HISI_KIRIN_DW_DSI + select DRM_MIPI_DSI help Choose this option if you have a hisilicon Kirin chipsets(hi6220). If M is selected the module will be called kirin-drm. -config HISI_KIRIN_DW_DSI - tristate "HiSilicon Kirin specific extensions for Synopsys DW MIPI DSI" - depends on DRM_HISI_KIRIN - select DRM_MIPI_DSI - help - This selects support for HiSilicon Kirin SoC specific extensions for - the Synopsys DesignWare DSI driver. If you want to enable MIPI DSI on - hi6220 based SoC, you should selet this option. diff --git a/drivers/gpu/drm/hisilicon/kirin/Makefile b/drivers/gpu/drm/hisilicon/kirin/Makefile index c0501fa3fe53..d9323f66a7d4 100644 --- a/drivers/gpu/drm/hisilicon/kirin/Makefile +++ b/drivers/gpu/drm/hisilicon/kirin/Makefile @@ -2,6 +2,5 @@ kirin-drm-y := kirin_drm_drv.o \ kirin_drm_ade.o -obj-$(CONFIG_DRM_HISI_KIRIN) += kirin-drm.o +obj-$(CONFIG_DRM_HISI_KIRIN) += kirin-drm.o dw_drm_dsi.o -obj-$(CONFIG_HISI_KIRIN_DW_DSI) += dw_drm_dsi.o From patchwork Tue Aug 20 23:06:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171862 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp179886ily; Tue, 20 Aug 2019 16:06:34 -0700 (PDT) X-Received: by 2002:aa7:8108:: with SMTP id b8mr33201427pfi.197.1566342394822; Tue, 20 Aug 2019 16:06:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566342394; cv=none; d=google.com; s=arc-20160816; b=fC3jp0cfJyVd44FMRcepw+bYQx5aQtDYVXRlNSvVgxifY/f9K/EJnyUvBTyphyqpj1 ZI71b1ws8azDRhDJdGUAF2C2gupYLgvFJtQV4oKuigsS4Vk4ZWdNHWmqn8yaW0fm0bX6 Ab8kYC4DAXifMQwjSIoyBeS40Dj87AIGdfoHkKrxhWGUNmZM38ZuphF9IOeL0AO+PZd/ kzXf5QKjUz4eQhaQYegXuFZmPtWxT5l6/fETDw54ljilIdxpx0W2S3/xrjEFXXs8Sp6T hO+qnYpH9Sem1RbXlJkJHCwDCqiA5cas26tDPoKuClTW8ROv2KFFgiaz2BZPxijZZ5kU zTow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=i6m141WDgWo2fEqKOTQPkh65ch/WaZ2zC8BGag2kGAk=; b=XWJr+xtycLSmRRaDtPxf5umeXZ+YaJNgIivep/g6Bhx8+Rk6avJuvY+P5JSBF/Oex6 huqpcCdYUdpx4M9TTm1Uq1tjRjJaADuYBs9hRLtVwWogBuA+B9k/JYGUDc9lXOxwz7uS tKHPAGmNCeK5dYh+OyJiHKXjIRqnwnur/xEUcnb/itp8rWAcrrFVaevWJdQg3RRu62CG KuG2kOwI4DOM0vwD9PxK6t7fsECmfOXQX7wBtVsCyIRwipPFoSVGtwJ78x1++J+xW3A5 qWphpbdeF+GXO1W7hYQ6X931SwNP5+vWqUf3rakmDIsWqDxju7w45HTY+Ec7Ul8z06wu eS/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xU3RqNBd; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id cp19sor6799589plb.63.2019.08.20.16.06.34 for (Google Transport Security); Tue, 20 Aug 2019 16:06:34 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xU3RqNBd; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=i6m141WDgWo2fEqKOTQPkh65ch/WaZ2zC8BGag2kGAk=; b=xU3RqNBdba+sjj16E8oEggAfQ3tfoyAiSrPQbTkSPPgvVvJd17JZENyO47OSnMtF/J arQsfrqPH6HE4qSgYaDIVVZ6NYgELBTOHWU/uyOzReRxybENDaylvj05Wldh9PDCSIq+ klWJKX6XnHYYBbQjNTWo7zETkfk8t+J8XCBHpHQo8hKOQ1S/r/9h/0fWizsnZfbbCjIo AnEX938ZPQIanIojy4XrVQtESf5XZhDnt1rTmD/UY/C6opfQvyxkOscJKzqEW4vhIZj8 nn9z024aVq6ZGP02cOJejzYba2lo48VNhCqvPSz+C1pNe1BTXFzJ+ttD2lu/QbK81nDn k2iw== 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; bh=i6m141WDgWo2fEqKOTQPkh65ch/WaZ2zC8BGag2kGAk=; b=lZKkRTW/r0vx2QUmez1VR5uRbxUfct2os6XZS02fVQpccTVuT8kPwXvAxJKsGZ3ydu xwkdbIwSh8VoN+MtJO+rkBWzh8WQXPe1H2V0xqMXVpmHzwd2bywkiliHG7gQQ5BHBCw/ jrNm9bGLBfiOiS/pnyD4olC+0DDPxuunQdkMF63M0gkyyRzZXMnCrAXDYK4N3e9hEsZD LQJpLTBtZSZ10kQ2C81EXIytAM8oKVxA7tiiHStS7aj+pITsh9U8Wt0FxYCsvRqnvXXJ JU2Vw8puQpYBAqJf04i9MfV6rjdKArBO1NL6G1GlZsx3dFm09PY9tuNKwnw7+ChtJZcR ayEw== X-Gm-Message-State: APjAAAUf19ASD++OvyAiO8YhM1om5KAXtrU1jJNzqD9HseZbi3HF7YJf yWG9mhWPDm2Y/CEgPHcAGCqHKYfJEs+WjQ== X-Google-Smtp-Source: APXvYqwSD86miSdIr5XIL6amQdd092Qu4cUoqGCUj8MABeZCa7rID5KZaxQ4HCPPF75msEeuaCPuMg== X-Received: by 2002:a17:902:9f8e:: with SMTP id g14mr31066446plq.67.1566342394450; Tue, 20 Aug 2019 16:06:34 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id q4sm27564747pff.183.2019.08.20.16.06.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 16:06:33 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Rongrong Zou , Xinliang Liu , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg Subject: [PATCH v5 03/25] drm: kirin: Remove unreachable return Date: Tue, 20 Aug 2019 23:06:04 +0000 Message-Id: <20190820230626.23253-4-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820230626.23253-1-john.stultz@linaro.org> References: <20190820230626.23253-1-john.stultz@linaro.org> The 'return 0' in kirin_drm_platform_probe() is unreachable code, so remove it. Cc: Rongrong Zou Cc: Xinliang Liu Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Cc: Sam Ravnborg Acked-by: Xinliang Liu Reviewed-by: Sam Ravnborg Suggested by: Xu YiPing Signed-off-by: John Stultz --- drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 2 -- 1 file changed, 2 deletions(-) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c index 204c94c01e3d..fcdd6b1e167d 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c @@ -208,8 +208,6 @@ static int kirin_drm_platform_probe(struct platform_device *pdev) of_node_put(remote); return component_master_add_with_match(dev, &kirin_drm_ops, match); - - return 0; } static int kirin_drm_platform_remove(struct platform_device *pdev) From patchwork Tue Aug 20 23:06:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171863 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp179916ily; Tue, 20 Aug 2019 16:06:36 -0700 (PDT) X-Received: by 2002:a17:902:76c7:: with SMTP id j7mr30042668plt.247.1566342395982; Tue, 20 Aug 2019 16:06:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566342395; cv=none; d=google.com; s=arc-20160816; b=wabto6b8snXT3PrleT0fjbcHKZr1WSrE9+hDB+qYW4rfn0FFRl74e23Sph0pRDO9a5 14+d0Ckk/a62OlZX/d3zvlWXndz77IA5aMXe3b8IaI8RpQhv6x+pJgkMh//dSzLYj5r6 GBdL5CFqM3P7Uxcp40d5K8DSnNYF0NH692OXTONGKCr4mmEoltPJ835yprZrs9Rd7O9O rR0DCGo7qVkyzUJRu6uaSGdajGyOzmqCskrAWASjzGdwtMFVIPQdO0B7My/LDLdsfxdu Myp61IPcuGidrZs4xCb5LYsK4dKW0BsT/dp2hzzBCo1NXWKDS49XFREJdWupMmt8pND1 kn1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sMMNrNPEyr5ojRnGMae00OuNvWMz/twMj42dMKt7nWI=; b=s9a/gpj8jSFRrdMkrZwfKEMKWHZFTXLS8bAbLRnm+DD+A9pxn/DFpgYiP60VEH/SSS mikFYImfFWFGy+hfkyMSI+dP/hSvoLAeR6XUunPQ7N/VZISKO04uEARgqhUp7iMENdfc fn/l+bg5qWrAHu7IiF8GKdEq376QRLTqMTl831J7WrvO8o0sVIHsM3Bj4MTO6EW6ZqG/ a3ZvUZxXtlK3iebdmdvGyyGTFNONdAbWhQSDOCkd3iJotvwG1eBZalGGOjWTdREo85Zt yLsMvwC2LH9V7cA6Fw8XuuMIs4freSe0KxV7mneriM3iAwzLZh2IE+PPXZQXA/oO3td4 YFRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IB7XgmYv; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id e93sor6834994plk.27.2019.08.20.16.06.35 for (Google Transport Security); Tue, 20 Aug 2019 16:06:35 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IB7XgmYv; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sMMNrNPEyr5ojRnGMae00OuNvWMz/twMj42dMKt7nWI=; b=IB7XgmYvkwQEJtHZlzt4hH6T5NopJkfBoayNv/GodStcZXxTvSt35M0eDDE9K3LV2X t34RV1DW6QSCYi7l5B5gjU/nC/lzfgqYLQUgPK/FHUm7Q90eU6Xs99OSlhMpSBUAFZu/ Yimi+ol1E2NCdt3K/+oziOzE6uaD+OHWte422JmbCriql6H9kOHQKD/tsCDvM56LPSqq xcAGaApq98JTw0Q04lqdwrHP703sVt3Vds/7vEiDMpD3keehlJIiDsFeg+/lMwH4ucqu 0nxmOsfgPHJW/SjDgWdvnebrKFcXAhGduTdxDSkzdCzBM1GIttYl8RXIDDS2rgs60whC iuUg== 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; bh=sMMNrNPEyr5ojRnGMae00OuNvWMz/twMj42dMKt7nWI=; b=twBwGLmcHgNfJFaai9mwcPPE1hFZDsmaFjfHWeRRMQS2M0Im/ZxKB9X9iFMP3TBJhz zoqup290Yimkl1lckVy2IoN2vsqezMDygU6b85ciqqJReFK93a15v8cuwrobHVBPI8rX 7jNalXyWRb9g6kGFs2HHoe0xQwncIN1vA+BROFl2ugGEdc1pFPfZputEtVSuyY5ClCg3 q8Er6KZ2NDUFfZ8RyzHhycoGjBeqC1DAFSzIZyql2SIQ2V2oOp1IgVnEB/0X+0oL/yVH OBZzXm9L2rY8JBAHJaX4OWzDkfxyzumX9ZI8Ld+EM+49kVp270rfApk6jNQHo4p7F39x YjTg== X-Gm-Message-State: APjAAAUX4pXNnSp3tqMG05egUljJsf3nh2UmNBH8nOuPxNhuYocoRLMX Bc8d4pLjQUftxrHuBg4RdnC1QMgJ X-Google-Smtp-Source: APXvYqxvBHkagafXH1CnZDG8/J2NJtGYyNSNZb9XstBXBy84ZynIq7jqLkNKO8FL/LW4w2k+JTFkdA== X-Received: by 2002:a17:902:1105:: with SMTP id d5mr31408400pla.197.1566342395612; Tue, 20 Aug 2019 16:06:35 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id q4sm27564747pff.183.2019.08.20.16.06.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 16:06:34 -0700 (PDT) From: John Stultz To: lkml Cc: Xu YiPing , Rongrong Zou , Xinliang Liu , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg , John Stultz Subject: [PATCH v5 04/25] drm: kirin: Remove uncessary parameter indirection Date: Tue, 20 Aug 2019 23:06:05 +0000 Message-Id: <20190820230626.23253-5-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820230626.23253-1-john.stultz@linaro.org> References: <20190820230626.23253-1-john.stultz@linaro.org> From: Xu YiPing In a few functions, we pass in a struct ade_crtc, which we only use to get to the underlying struct ade_hw_ctx. Thus this patch refactors the functions to just take the struct ade_hw_ctx directly. Cc: Rongrong Zou Cc: Xinliang Liu Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Cc: Sam Ravnborg Acked-by: Xinliang Liu Reviewed-by: Sam Ravnborg Signed-off-by: Xu YiPing [jstultz: reworded commit message] Signed-off-by: John Stultz --- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index d972342527b8..45351934d919 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -210,11 +210,10 @@ static void ade_set_pix_clk(struct ade_hw_ctx *ctx, adj_mode->clock = clk_get_rate(ctx->ade_pix_clk) / 1000; } -static void ade_ldi_set_mode(struct ade_crtc *acrtc, +static void ade_ldi_set_mode(struct ade_hw_ctx *ctx, struct drm_display_mode *mode, struct drm_display_mode *adj_mode) { - struct ade_hw_ctx *ctx = acrtc->ctx; void __iomem *base = ctx->base; u32 width = mode->hdisplay; u32 height = mode->vdisplay; @@ -301,9 +300,8 @@ static void ade_power_down(struct ade_hw_ctx *ctx) ctx->power_on = false; } -static void ade_set_medianoc_qos(struct ade_crtc *acrtc) +static void ade_set_medianoc_qos(struct ade_hw_ctx *ctx) { - struct ade_hw_ctx *ctx = acrtc->ctx; struct regmap *map = ctx->noc_regmap; regmap_update_bits(map, ADE0_QOSGENERATOR_MODE, @@ -515,7 +513,7 @@ static void ade_crtc_atomic_enable(struct drm_crtc *crtc, return; } - ade_set_medianoc_qos(acrtc); + ade_set_medianoc_qos(ctx); ade_display_enable(acrtc); ade_dump_regs(ctx->base); drm_crtc_vblank_on(crtc); @@ -545,7 +543,7 @@ static void ade_crtc_mode_set_nofb(struct drm_crtc *crtc) if (!ctx->power_on) (void)ade_power_up(ctx); - ade_ldi_set_mode(acrtc, mode, adj_mode); + ade_ldi_set_mode(ctx, mode, adj_mode); } static void ade_crtc_atomic_begin(struct drm_crtc *crtc, @@ -558,7 +556,7 @@ static void ade_crtc_atomic_begin(struct drm_crtc *crtc, if (!ctx->power_on) (void)ade_power_up(ctx); - ade_ldi_set_mode(acrtc, mode, adj_mode); + ade_ldi_set_mode(ctx, mode, adj_mode); } static void ade_crtc_atomic_flush(struct drm_crtc *crtc, From patchwork Tue Aug 20 23:06:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171864 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp179950ily; Tue, 20 Aug 2019 16:06:37 -0700 (PDT) X-Received: by 2002:a17:90a:4c:: with SMTP id 12mr2314588pjb.40.1566342397490; Tue, 20 Aug 2019 16:06:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566342397; cv=none; d=google.com; s=arc-20160816; b=Ud9piNqxbW5l90IYDmB75dwTo2qLEjroLv69iRFMys8BeendM7OS99v9/lok62xx8H N8wBOtFnzXBetUyBY/UMsRx3lvx7Hzg3cxTcMd4pk53T/WpoTbm6GwBgn9u8163O1RBb /o58MCpNrE7d+b7QLxBh4xebHIra+etsOch1OyPFwWIc6sMx1e19dbJ/ywvByShoaMCr hPZGkYIZbL6daKKEwtz8MQV3Gy5SJslwxUCx2CoW43o2YuYSNs7fPecghsymzqbrDz3r IXv6BH3/TU5RKuPHs5+DrFk2Zv9plFrCUff726kcpqVgYjLYHaaMu/X3NL8r4LUYjvB7 KTfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IcvzzFr1yUCqUm7igC+fhVBaiFn8HJOuskJ5pNSj2cg=; b=TQn0yL22D/O1NB6RHs/K6PotDgS7bF/4LqAnw0bxJ/LCWRtya6DHplTGewDDyaxP8W RFq1ga6Aa/LCswXUIwhPONH5F53FAp+VtmUhdi1pX3ozKkoPPvEFebB2yLXRk1KkIT7C 5XKJeEGEEqN/lQsh0ksbGdbqq59XKBOMSNXyUf6Ogt99n8bT+PtAfIHWONT/0nPoUacv FussabdYH8on3j8eZAU/lZdnls5okOX4LUl0wMdiUK2uwLsCDhYq1GRMxA2t168n2dxr wleTlvSr01sRZ4ucqpCyOxoVEkcXhfNpePN49HvjZ7hsRYiNDZ4Th/KWfkWNxHWOhV75 fy5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=s6WQ7sIS; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id 196sor4463572pgg.26.2019.08.20.16.06.37 for (Google Transport Security); Tue, 20 Aug 2019 16:06:37 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=s6WQ7sIS; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IcvzzFr1yUCqUm7igC+fhVBaiFn8HJOuskJ5pNSj2cg=; b=s6WQ7sISarwjn/LoXRuWTs7T9mI5glGbXZ8EsPI3bJI84uER1hU+D4STDBevGNYS3Z eOvv5irY6DvPeWzChsKAuakSVEFkiW8fIPj9iEVuzTxRkakHzBvVbJl0FlVpnSJenv9d oUJ9gN9hBHJudtKn5GBt22PjFXTs1PV+hJA8u6D32MuR5+IQjqNaFWUvr7EnYQyDfM4e gRcM1L8/KdxdVssB84zN+ICvvYZKBrcOQUwjy8cozJJY6u/J9LfaZoSSyXmW9cieqa08 AwWuH+bjNzMQG0fL+nLfeolv/+EHIUXxixtM7d/daNtzOmFYkW4AB5qLThiEB2YXp4Ay CTgg== 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; bh=IcvzzFr1yUCqUm7igC+fhVBaiFn8HJOuskJ5pNSj2cg=; b=Ry5m0tYGUiyfVCjQSZ2+UbQtTJWHxy/zjZiA6hj+HkKDx2wSOe2JbwvtcGGQBNSF5v PDVqKmjGmCHuVq5MiScM59hfdKiGagoUDXZ6aVBCFvcW2yQBsrROhMJfK7k+ZvsPBuav dvmeKckHDYXUgIOs5gviZTe3hcfXsA48LsUwRfZ9HNhYQ+4AOieS+9inlIutZHYVCv7e gCVeB9epBAvp9YYe5fk9DFrkRvCY/NTuKefSVyFQTMq4aljrhcTNQFwnfhZvSEmcyHvf ql5LdzohY1U2SEwvqN6MSSlUk3Xy0RPtPAWaQT2pL2BEbtqnWEZdpx4zKCWfki0SsECo cXZQ== X-Gm-Message-State: APjAAAUDGtEdjMoRmL/AEdSb0YlT4QNQwUTBk2UrqWF6qBAL4Sm0IOiQ o66B5lRbRmiS9mHXkX3EmW2VYhcv X-Google-Smtp-Source: APXvYqwhPnpN+NIoIIfhZvjoBsWXfZaXDVMAu7KdrUCnG//Qro9vlYsd9RANeyEKSV9ZPwGORsOy6w== X-Received: by 2002:a63:5b23:: with SMTP id p35mr26142289pgb.366.1566342397025; Tue, 20 Aug 2019 16:06:37 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id q4sm27564747pff.183.2019.08.20.16.06.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 16:06:36 -0700 (PDT) From: John Stultz To: lkml Cc: Xu YiPing , Rongrong Zou , Xinliang Liu , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg , John Stultz Subject: [PATCH v5 05/25] drm: kirin: Remove out_format from ade_crtc Date: Tue, 20 Aug 2019 23:06:06 +0000 Message-Id: <20190820230626.23253-6-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820230626.23253-1-john.stultz@linaro.org> References: <20190820230626.23253-1-john.stultz@linaro.org> From: Xu YiPing As part of refactoring the kirin driver to better support different hardware revisions, this patch removes the out_format field in the struct ade_crtc, which was only ever set to LDI_OUT_RGB_888. Thus this patch removes the field and instead directly uses LDI_OUT_RGB_888. Cc: Rongrong Zou Cc: Xinliang Liu Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Cc: Sam Ravnborg Acked-by: Xinliang Liu Reviewed-by: Sam Ravnborg Signed-off-by: Xu YiPing [jstultz: reworded commit message] Signed-off-by: John Stultz --- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index 45351934d919..65f1a57f7304 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -60,7 +60,6 @@ struct ade_crtc { struct ade_hw_ctx *ctx; struct work_struct display_reset_wq; bool enable; - u32 out_format; }; struct ade_plane { @@ -383,11 +382,10 @@ static irqreturn_t ade_irq_handler(int irq, void *data) return IRQ_HANDLED; } -static void ade_display_enable(struct ade_crtc *acrtc) +static void ade_display_enable(struct ade_hw_ctx *ctx) { - struct ade_hw_ctx *ctx = acrtc->ctx; void __iomem *base = ctx->base; - u32 out_fmt = acrtc->out_format; + u32 out_fmt = LDI_OUT_RGB_888; /* enable output overlay compositor */ writel(ADE_ENABLE, base + ADE_OVLYX_CTL(OUT_OVLY)); @@ -514,7 +512,7 @@ static void ade_crtc_atomic_enable(struct drm_crtc *crtc, } ade_set_medianoc_qos(ctx); - ade_display_enable(acrtc); + ade_display_enable(ctx); ade_dump_regs(ctx->base); drm_crtc_vblank_on(crtc); acrtc->enable = true; @@ -1024,7 +1022,6 @@ static int ade_drm_init(struct platform_device *pdev) ctx = &ade->ctx; acrtc = &ade->acrtc; acrtc->ctx = ctx; - acrtc->out_format = LDI_OUT_RGB_888; ret = ade_dts_parse(pdev, ctx); if (ret) From patchwork Tue Aug 20 23:06:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171865 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp179970ily; Tue, 20 Aug 2019 16:06:39 -0700 (PDT) X-Received: by 2002:aa7:8108:: with SMTP id b8mr33201854pfi.197.1566342398988; Tue, 20 Aug 2019 16:06:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566342398; cv=none; d=google.com; s=arc-20160816; b=x0Kl42iYBID4lkDbS8+pL09w9GgEyyFnahQUCCfvotRNGBYsXZRuXERTzUEqNOnAsF 5ILr/fW8gqP87ewJJFpnJ6zsnDVcWA3veeeU1wv41VJy3pj8k5E5szKZEjRdpm/h5n8o reyoIfsY4rad96A5tkeZU1wUxYQzvcEXLdzJd3GbeD2kGw0Qm7jdlGJiTohXdyGyvsHe zHJ7+Tal9dqwaZ968PY2B2sYzHhjesyyGpWJfGW8CAtBfOjWLruRgXW76vKYCQr6ONes o0eJKgJtaLgdGbdRdItOH9kKClnUrEdtSADxgqD7SINcfJlJuDkqUFBkaifKLaEr0yqp FP6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wDN5Qh2/00dJZLoF3M4SXeIuODTG/TUr5/kEaW32ueQ=; b=BjCYGoppej/+3HusF1n3xaj2WdrVWXQZPaMs+DxdlhVcXjeOGL2VhhOamWgmvMIdm8 NPG8/ddFA+ahOnkxeOlyB4VVNcfS74tj+PwzkeYpUaz5Rfsghd0i8icCX5HpqWVTyjEa uOzVSQPWTgtqbuyJBXBVdKpqWoC9UqSDFXGTkMxCaIyKuOZnq1lUn8dtc8Izt2wzxpE5 4wg484iFC/ap51w/98YEPbI1y22Z9J7AjO49gcoMI0lZe87F8IfrEmOWOOS9c7b0jkdJ wYnGMaUFbxIZbQNypbOBwcKsCmfiF5TfNCWyxiy1MeBq1W6P3wRMK04Y8xuRjfHwy9xh VLQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XwS7bbyh; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id d5sor1783299pjj.19.2019.08.20.16.06.38 for (Google Transport Security); Tue, 20 Aug 2019 16:06:38 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XwS7bbyh; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wDN5Qh2/00dJZLoF3M4SXeIuODTG/TUr5/kEaW32ueQ=; b=XwS7bbyhv7KSYpUhN3YWKe2XRXo+vCq0L5TwkScGsafW2XI8q92sn12VbS6PItgEx2 FkTxifJUE1vQH+Fxf2NSEYSbUATVLNbHoYld4u/5eNMysj+j7nBh66ceKU6b6oyuxyP3 V0fR33jPt7nT5YkxyVbYgLnfc9Qk7ECNP26C9xz4+he+Rg+3A+9wRaUx451L0Q2Hk3L0 xz9RaK+gWaKqem3DvZwpIsLnTRP6eEibU1B9I/0FHHa6tzRigPTVSII4x+5YwT7THOeo 5DBNIUq8xbeuSSMclzSGVnEuzIjokBxnFn96cwcHyq5Y6rMIE/ZJ+UQZTTZb34SOUS7J 0j+Q== 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; bh=wDN5Qh2/00dJZLoF3M4SXeIuODTG/TUr5/kEaW32ueQ=; b=VUr+HO3VxGmkCEEzZ/tzn7V/9xkoozyBR4SKAhc0QBVaMsN9sTh1j3zS4sNzyc5++3 buBGATvuMfL/hrMYkvkgG7VhWuMoJuTs+/aABL2WwaZqBNWXdX76CGiSXsa8TKFqeGUM u5zsROFCYa0lTKF9p2XD2dYrtltjkT0SNKeoflvuxfoRXcPfhOIsv7SuZUC+rTJcBDup K3a8VO+GdQpor1bhQVZl1Ks0nJk83Yf9nKnC38DfUxVEdBVaPbBHLiOn6ZgO+QrCBWoO ZV0rFm1bjo7czFRyzPfzJs8EqnUaPVsZYRxpTrWnNqPL6wmzbtOFcxDjn3DVTRY1/PLn VZ8w== X-Gm-Message-State: APjAAAXg6d7acoWkWxpi5Y5z2aoIshrtQEC8OvNSakZAgvaOhYFTkBy4 1s1dxMfECfmG5tnmq1GbQS7pvJHO X-Google-Smtp-Source: APXvYqyYDwB631aYgn8zmOVX0yCXduCJhxlIgFNp+RN88S2rqKNAysxqeVrW7xOQi3+kqu7fbF1Row== X-Received: by 2002:a17:90a:fa82:: with SMTP id cu2mr2404819pjb.85.1566342398556; Tue, 20 Aug 2019 16:06:38 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id q4sm27564747pff.183.2019.08.20.16.06.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 16:06:37 -0700 (PDT) From: John Stultz To: lkml Cc: Xu YiPing , Rongrong Zou , Xinliang Liu , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg , John Stultz Subject: [PATCH v5 06/25] drm: kirin: Rename ade_plane to kirin_plane Date: Tue, 20 Aug 2019 23:06:07 +0000 Message-Id: <20190820230626.23253-7-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820230626.23253-1-john.stultz@linaro.org> References: <20190820230626.23253-1-john.stultz@linaro.org> From: Xu YiPing As part of refactoring the kirin driver to better support different hardware revisions, this patch renames the struct ade_plane to kirin_plane. The struct kirin_plane will later used by both kirin620 and future kirin960 driver, and will be moved to a common kirin_drm_drv.h in a future patch Cc: Rongrong Zou Cc: Xinliang Liu Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Cc: Sam Ravnborg Acked-by: Xinliang Liu Reviewed-by: Sam Ravnborg Signed-off-by: Xu YiPing [jstultz: reworded commit message] Signed-off-by: John Stultz --- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 57 ++++++++++--------- 1 file changed, 29 insertions(+), 28 deletions(-) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index 65f1a57f7304..19d279167694 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -41,8 +41,9 @@ #define to_ade_crtc(crtc) \ container_of(crtc, struct ade_crtc, base) -#define to_ade_plane(plane) \ - container_of(plane, struct ade_plane, base) +#define to_kirin_plane(plane) \ + container_of(plane, struct kirin_plane, base) + struct ade_hw_ctx { void __iomem *base; @@ -62,15 +63,15 @@ struct ade_crtc { bool enable; }; -struct ade_plane { +struct kirin_plane { struct drm_plane base; - void *ctx; - u8 ch; /* channel */ + void *hw_ctx; + u32 ch; }; struct ade_data { struct ade_crtc acrtc; - struct ade_plane aplane[ADE_CH_NUM]; + struct kirin_plane planes[ADE_CH_NUM]; struct ade_hw_ctx ctx; }; @@ -795,16 +796,16 @@ static void ade_compositor_routing_disable(void __iomem *base, u32 ch) /* * Typicaly, a channel looks like: DMA-->clip-->scale-->ctrans-->compositor */ -static void ade_update_channel(struct ade_plane *aplane, +static void ade_update_channel(struct kirin_plane *kplane, struct drm_framebuffer *fb, int crtc_x, int crtc_y, unsigned int crtc_w, unsigned int crtc_h, u32 src_x, u32 src_y, u32 src_w, u32 src_h) { - struct ade_hw_ctx *ctx = aplane->ctx; + struct ade_hw_ctx *ctx = kplane->hw_ctx; void __iomem *base = ctx->base; u32 fmt = ade_get_format(fb->format->format); - u32 ch = aplane->ch; + u32 ch = kplane->ch; u32 in_w; u32 in_h; @@ -828,11 +829,11 @@ static void ade_update_channel(struct ade_plane *aplane, ade_compositor_routing_set(base, ch, crtc_x, crtc_y, in_w, in_h, fmt); } -static void ade_disable_channel(struct ade_plane *aplane) +static void ade_disable_channel(struct kirin_plane *kplane) { - struct ade_hw_ctx *ctx = aplane->ctx; + struct ade_hw_ctx *ctx = kplane->hw_ctx; void __iomem *base = ctx->base; - u32 ch = aplane->ch; + u32 ch = kplane->ch; DRM_DEBUG_DRIVER("disable channel%d\n", ch + 1); @@ -894,10 +895,10 @@ static int ade_plane_atomic_check(struct drm_plane *plane, static void ade_plane_atomic_update(struct drm_plane *plane, struct drm_plane_state *old_state) { - struct drm_plane_state *state = plane->state; - struct ade_plane *aplane = to_ade_plane(plane); + struct drm_plane_state *state = plane->state; + struct kirin_plane *kplane = to_kirin_plane(plane); - ade_update_channel(aplane, state->fb, state->crtc_x, state->crtc_y, + ade_update_channel(kplane, state->fb, state->crtc_x, state->crtc_y, state->crtc_w, state->crtc_h, state->src_x >> 16, state->src_y >> 16, state->src_w >> 16, state->src_h >> 16); @@ -906,9 +907,9 @@ static void ade_plane_atomic_update(struct drm_plane *plane, static void ade_plane_atomic_disable(struct drm_plane *plane, struct drm_plane_state *old_state) { - struct ade_plane *aplane = to_ade_plane(plane); + struct kirin_plane *kplane = to_kirin_plane(plane); - ade_disable_channel(aplane); + ade_disable_channel(kplane); } static const struct drm_plane_helper_funcs ade_plane_helper_funcs = { @@ -926,7 +927,7 @@ static struct drm_plane_funcs ade_plane_funcs = { .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, }; -static int ade_plane_init(struct drm_device *dev, struct ade_plane *aplane, +static int ade_plane_init(struct drm_device *dev, struct kirin_plane *kplane, enum drm_plane_type type) { const u32 *fmts; @@ -934,18 +935,18 @@ static int ade_plane_init(struct drm_device *dev, struct ade_plane *aplane, int ret = 0; /* get properties */ - fmts_cnt = ade_get_channel_formats(aplane->ch, &fmts); + fmts_cnt = ade_get_channel_formats(kplane->ch, &fmts); if (ret) return ret; - ret = drm_universal_plane_init(dev, &aplane->base, 1, &ade_plane_funcs, + ret = drm_universal_plane_init(dev, &kplane->base, 1, &ade_plane_funcs, fmts, fmts_cnt, NULL, type, NULL); if (ret) { - DRM_ERROR("fail to init plane, ch=%d\n", aplane->ch); + DRM_ERROR("fail to init plane, ch=%d\n", kplane->ch); return ret; } - drm_plane_helper_add(&aplane->base, &ade_plane_helper_funcs); + drm_plane_helper_add(&kplane->base, &ade_plane_helper_funcs); return 0; } @@ -1007,7 +1008,7 @@ static int ade_drm_init(struct platform_device *pdev) struct ade_data *ade; struct ade_hw_ctx *ctx; struct ade_crtc *acrtc; - struct ade_plane *aplane; + struct kirin_plane *kplane; enum drm_plane_type type; int ret; int i; @@ -1033,19 +1034,19 @@ static int ade_drm_init(struct platform_device *pdev) * need to do. */ for (i = 0; i < ADE_CH_NUM; i++) { - aplane = &ade->aplane[i]; - aplane->ch = i; - aplane->ctx = ctx; + kplane = &ade->planes[i]; + kplane->ch = i; + kplane->hw_ctx = ctx; type = i == PRIMARY_CH ? DRM_PLANE_TYPE_PRIMARY : DRM_PLANE_TYPE_OVERLAY; - ret = ade_plane_init(dev, aplane, type); + ret = ade_plane_init(dev, kplane, type); if (ret) return ret; } /* crtc init */ - ret = ade_crtc_init(dev, &acrtc->base, &ade->aplane[PRIMARY_CH].base); + ret = ade_crtc_init(dev, &acrtc->base, &ade->planes[PRIMARY_CH].base); if (ret) return ret; From patchwork Tue Aug 20 23:06:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171866 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp180001ily; Tue, 20 Aug 2019 16:06:40 -0700 (PDT) X-Received: by 2002:a17:902:82c4:: with SMTP id u4mr7069173plz.196.1566342400337; Tue, 20 Aug 2019 16:06:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566342400; cv=none; d=google.com; s=arc-20160816; b=IjrmYsGa6d0ek/yK6pso4XIgj1fud1f/q20nRd/7g9Q9EvrdhMakP4ozjqC02LPBy0 YxQd8/tFY6MzCGARAFe15tmU0IwmopWXjaOAgoQLqGq0EvLVI1uyXaRM+yNGnhEwqaaP 7yWrnlYXUkFdtl5eveLacGs6O5D+sHCZ4Zptffd52m6i38vreUThpv2LsGxfHQ4FFL6C D8VdXMJtja+EuTFo/TwCbVK/KvuRjmIDY850SMFn4/LzO5htMq0m0CLLxdVNGNojpHT0 +A5wFaer8IPwPOpWv0iajT8M9On2uMA+5ff9wOZBIjSJMJ+N7jmp4016Yz6Ggtxvsrfc A8ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/TlFFqIFbnuilFAvaZfscTqwSZVj/Gq+GQdJwcM1CA0=; b=MeFg+nO3hm+wmPZ3Svaa/g1xhpe5GJ7jPZlq4eM65FM21ZYFFvp+1qhaJfR73eM7fO 3mcbkhjsBhBT7F7BAQHpZ9Zi4OtuColrvyK3HXlAGUetbYXgYyt8SG4IRVJ/PkFAxpZl AhMtx3I9RCGxhlFq286YDchjcMywRaCzxMtbq9EsuI5sJ/4oMdERD+ZF2uZkKgVi1H/h ukPXBgYt4Kh1smTNQNmhKG8a28kvyzcUY9vTCB58Hi6B3VJWV7wTcXpY/ZVXkyXfkWQE 0Px3tIwFZZjzacjuatO4TcDIqX0jewl4NxAE8hmWNWvFkObfth6LcJQpM844uYESYqa7 3atQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="HviUdM/t"; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id b10sor6873957plz.15.2019.08.20.16.06.40 for (Google Transport Security); Tue, 20 Aug 2019 16:06:40 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="HviUdM/t"; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/TlFFqIFbnuilFAvaZfscTqwSZVj/Gq+GQdJwcM1CA0=; b=HviUdM/tv8eMmEpbKEVgJTYkgMSX+G7Qmv5SN/sgq1VI0DfXyqnjhmazyo0G13ipEx qVDozny5uy3plXW4sra5E0lvs7R+t0kHnM7O92xdkXFt/Myk8UQVcteiFH3jsgy4Sc0Q 6IXbArI868zpxf+pNFeM7IvgZrTZoLgoaAUqmIlVsI93IxpVtVKTQT15WDqFFvlhpt2e DO/xqixbe9/RHAknyrQsNIFG4h/PpgYSsktjLyf3s/mqEagpmTkD+E9D79elC5MhpFy0 7IL+dSW+S98gbywz2M6E2CgsiLdgT8vheTZvcbWFlnZTkGxwdnmyUtqFMjwID6j4i1JY vDtg== 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; bh=/TlFFqIFbnuilFAvaZfscTqwSZVj/Gq+GQdJwcM1CA0=; b=GYBxH8Dl+uBn3evT6k+QE3sg7ToZk1IRx0k9eVBN1fcHcFMoMJCpgFpzRWzBb/yjSj r/gd/EXCXG2Rvc3g17USCOuPKUwZsL47yQ+627rIK1ozGAHZnQl8pQvwl1mHddxd6ujW B8sObQUP6lprXkcIAzIM5XI35CcXLB/I0it/vKqsw/hoi+Q68+8D/tQduLw4zEh3SuMy Hq+znmEVKNMPawip5Ra6F0QGZN8P3BXncU51iNOkql5RD8bbBOIKMQRA3azht8nWHHXa 2szT7GOHMWI+V4buSZtm+QhzbIQLdDT67TvwyeFWTeQUrFOOw80Um0/2gKLZK6WUJobw X4BQ== X-Gm-Message-State: APjAAAVrkrZ/Al7ApN4zyhJmM5LFFgB0b9bILYBEKAffb7YFQQN6EyHP 4420UCmON7pZnXCqmOVHqZakhEKT X-Google-Smtp-Source: APXvYqzSIcHyS7cXOjM7sSGyRY4y7Ib0Cf70Y0g3Zt9ptLMwbmAp/rjfbMCd6l3tXSunnZGEA3BIrA== X-Received: by 2002:a17:902:29eb:: with SMTP id h98mr31565337plb.128.1566342399923; Tue, 20 Aug 2019 16:06:39 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id q4sm27564747pff.183.2019.08.20.16.06.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 16:06:39 -0700 (PDT) From: John Stultz To: lkml Cc: Xu YiPing , Rongrong Zou , Xinliang Liu , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg , John Stultz Subject: [PATCH v5 07/25] drm: kirin: Rename ade_crtc to kirin_crtc Date: Tue, 20 Aug 2019 23:06:08 +0000 Message-Id: <20190820230626.23253-8-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820230626.23253-1-john.stultz@linaro.org> References: <20190820230626.23253-1-john.stultz@linaro.org> From: Xu YiPing As part of refactoring the kirin driver to better support different hardware revisions, this patch renames the struct ade_crtc to kirin_crtc. The struct kirin_crtc will later used by both kirin620 and future kirin960 driver, and will be moved to a common kirin_drm_drv.h in a future patch Cc: Rongrong Zou Cc: Xinliang Liu Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Cc: Sam Ravnborg Acked-by: Xinliang Liu Reviewed-by: Sam Ravnborg Signed-off-by: Xu YiPing [jstultz: reworded commit message] Signed-off-by: John Stultz --- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 74 +++++++++---------- 1 file changed, 37 insertions(+), 37 deletions(-) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index 19d279167694..fce374ec69e8 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -38,8 +38,8 @@ #define OUT_OVLY ADE_OVLY2 /* output overlay compositor */ #define ADE_DEBUG 1 -#define to_ade_crtc(crtc) \ - container_of(crtc, struct ade_crtc, base) +#define to_kirin_crtc(crtc) \ + container_of(crtc, struct kirin_crtc, base) #define to_kirin_plane(plane) \ container_of(plane, struct kirin_plane, base) @@ -56,9 +56,9 @@ struct ade_hw_ctx { int irq; }; -struct ade_crtc { +struct kirin_crtc { struct drm_crtc base; - struct ade_hw_ctx *ctx; + void *hw_ctx; struct work_struct display_reset_wq; bool enable; }; @@ -70,7 +70,7 @@ struct kirin_plane { }; struct ade_data { - struct ade_crtc acrtc; + struct kirin_crtc crtc; struct kirin_plane planes[ADE_CH_NUM]; struct ade_hw_ctx ctx; }; @@ -184,8 +184,8 @@ static bool ade_crtc_mode_fixup(struct drm_crtc *crtc, const struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode) { - struct ade_crtc *acrtc = to_ade_crtc(crtc); - struct ade_hw_ctx *ctx = acrtc->ctx; + struct kirin_crtc *kcrtc = to_kirin_crtc(crtc); + struct ade_hw_ctx *ctx = kcrtc->hw_ctx; adjusted_mode->clock = clk_round_rate(ctx->ade_pix_clk, mode->clock * 1000) / 1000; @@ -317,8 +317,8 @@ static void ade_set_medianoc_qos(struct ade_hw_ctx *ctx) static int ade_crtc_enable_vblank(struct drm_crtc *crtc) { - struct ade_crtc *acrtc = to_ade_crtc(crtc); - struct ade_hw_ctx *ctx = acrtc->ctx; + struct kirin_crtc *kcrtc = to_kirin_crtc(crtc); + struct ade_hw_ctx *ctx = kcrtc->hw_ctx; void __iomem *base = ctx->base; if (!ctx->power_on) @@ -332,8 +332,8 @@ static int ade_crtc_enable_vblank(struct drm_crtc *crtc) static void ade_crtc_disable_vblank(struct drm_crtc *crtc) { - struct ade_crtc *acrtc = to_ade_crtc(crtc); - struct ade_hw_ctx *ctx = acrtc->ctx; + struct kirin_crtc *kcrtc = to_kirin_crtc(crtc); + struct ade_hw_ctx *ctx = kcrtc->hw_ctx; void __iomem *base = ctx->base; if (!ctx->power_on) { @@ -347,7 +347,7 @@ static void ade_crtc_disable_vblank(struct drm_crtc *crtc) static void drm_underflow_wq(struct work_struct *work) { - struct ade_crtc *acrtc = container_of(work, struct ade_crtc, + struct kirin_crtc *acrtc = container_of(work, struct kirin_crtc, display_reset_wq); struct drm_device *drm_dev = (&acrtc->base)->dev; struct drm_atomic_state *state; @@ -358,9 +358,9 @@ static void drm_underflow_wq(struct work_struct *work) static irqreturn_t ade_irq_handler(int irq, void *data) { - struct ade_crtc *acrtc = data; - struct ade_hw_ctx *ctx = acrtc->ctx; - struct drm_crtc *crtc = &acrtc->base; + struct kirin_crtc *kcrtc = data; + struct ade_hw_ctx *ctx = kcrtc->hw_ctx; + struct drm_crtc *crtc = &kcrtc->base; void __iomem *base = ctx->base; u32 status; @@ -377,7 +377,7 @@ static irqreturn_t ade_irq_handler(int irq, void *data) ade_update_bits(base + LDI_INT_CLR, UNDERFLOW_INT_EN_OFST, MASK(1), 1); DRM_ERROR("LDI underflow!"); - schedule_work(&acrtc->display_reset_wq); + schedule_work(&kcrtc->display_reset_wq); } return IRQ_HANDLED; @@ -499,11 +499,11 @@ static void ade_dump_regs(void __iomem *base) { } static void ade_crtc_atomic_enable(struct drm_crtc *crtc, struct drm_crtc_state *old_state) { - struct ade_crtc *acrtc = to_ade_crtc(crtc); - struct ade_hw_ctx *ctx = acrtc->ctx; + struct kirin_crtc *kcrtc = to_kirin_crtc(crtc); + struct ade_hw_ctx *ctx = kcrtc->hw_ctx; int ret; - if (acrtc->enable) + if (kcrtc->enable) return; if (!ctx->power_on) { @@ -516,27 +516,27 @@ static void ade_crtc_atomic_enable(struct drm_crtc *crtc, ade_display_enable(ctx); ade_dump_regs(ctx->base); drm_crtc_vblank_on(crtc); - acrtc->enable = true; + kcrtc->enable = true; } static void ade_crtc_atomic_disable(struct drm_crtc *crtc, struct drm_crtc_state *old_state) { - struct ade_crtc *acrtc = to_ade_crtc(crtc); - struct ade_hw_ctx *ctx = acrtc->ctx; + struct kirin_crtc *kcrtc = to_kirin_crtc(crtc); + struct ade_hw_ctx *ctx = kcrtc->hw_ctx; - if (!acrtc->enable) + if (!kcrtc->enable) return; drm_crtc_vblank_off(crtc); ade_power_down(ctx); - acrtc->enable = false; + kcrtc->enable = false; } static void ade_crtc_mode_set_nofb(struct drm_crtc *crtc) { - struct ade_crtc *acrtc = to_ade_crtc(crtc); - struct ade_hw_ctx *ctx = acrtc->ctx; + struct kirin_crtc *kcrtc = to_kirin_crtc(crtc); + struct ade_hw_ctx *ctx = kcrtc->hw_ctx; struct drm_display_mode *mode = &crtc->state->mode; struct drm_display_mode *adj_mode = &crtc->state->adjusted_mode; @@ -548,8 +548,8 @@ static void ade_crtc_mode_set_nofb(struct drm_crtc *crtc) static void ade_crtc_atomic_begin(struct drm_crtc *crtc, struct drm_crtc_state *old_state) { - struct ade_crtc *acrtc = to_ade_crtc(crtc); - struct ade_hw_ctx *ctx = acrtc->ctx; + struct kirin_crtc *kcrtc = to_kirin_crtc(crtc); + struct ade_hw_ctx *ctx = kcrtc->hw_ctx; struct drm_display_mode *mode = &crtc->state->mode; struct drm_display_mode *adj_mode = &crtc->state->adjusted_mode; @@ -562,13 +562,13 @@ static void ade_crtc_atomic_flush(struct drm_crtc *crtc, struct drm_crtc_state *old_state) { - struct ade_crtc *acrtc = to_ade_crtc(crtc); - struct ade_hw_ctx *ctx = acrtc->ctx; + struct kirin_crtc *kcrtc = to_kirin_crtc(crtc); + struct ade_hw_ctx *ctx = kcrtc->hw_ctx; struct drm_pending_vblank_event *event = crtc->state->event; void __iomem *base = ctx->base; /* only crtc is enabled regs take effect */ - if (acrtc->enable) { + if (kcrtc->enable) { ade_dump_regs(base); /* flush ade registers */ writel(ADE_ENABLE, base + ADE_EN); @@ -1007,7 +1007,7 @@ static int ade_drm_init(struct platform_device *pdev) struct drm_device *dev = platform_get_drvdata(pdev); struct ade_data *ade; struct ade_hw_ctx *ctx; - struct ade_crtc *acrtc; + struct kirin_crtc *kcrtc; struct kirin_plane *kplane; enum drm_plane_type type; int ret; @@ -1021,8 +1021,8 @@ static int ade_drm_init(struct platform_device *pdev) platform_set_drvdata(pdev, ade); ctx = &ade->ctx; - acrtc = &ade->acrtc; - acrtc->ctx = ctx; + kcrtc = &ade->crtc; + kcrtc->hw_ctx = ctx; ret = ade_dts_parse(pdev, ctx); if (ret) @@ -1046,15 +1046,15 @@ static int ade_drm_init(struct platform_device *pdev) } /* crtc init */ - ret = ade_crtc_init(dev, &acrtc->base, &ade->planes[PRIMARY_CH].base); + ret = ade_crtc_init(dev, &kcrtc->base, &ade->planes[PRIMARY_CH].base); if (ret) return ret; /* vblank irq init */ ret = devm_request_irq(dev->dev, ctx->irq, ade_irq_handler, - IRQF_SHARED, dev->driver->name, acrtc); + IRQF_SHARED, dev->driver->name, kcrtc); - INIT_WORK(&acrtc->display_reset_wq, drm_underflow_wq); + INIT_WORK(&kcrtc->display_reset_wq, drm_underflow_wq); if (ret) return ret; From patchwork Tue Aug 20 23:06:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171867 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp180028ily; Tue, 20 Aug 2019 16:06:41 -0700 (PDT) X-Received: by 2002:a63:188:: with SMTP id 130mr26469726pgb.231.1566342401642; Tue, 20 Aug 2019 16:06:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566342401; cv=none; d=google.com; s=arc-20160816; b=Tzpz110SCIjLGvsv8/uqk5NKD9k3ucuNUJtkZ5xdizr3bIGQcAj74GXX/48jV0yUPJ TRNwUBwb3U8uZt6XHBkjEoq80uxkUZd33PIzpMLfPQqEL2EIopMAi4ifLuU0+D6MtNSD JSL7PEQUgRBESIZmecDiMHkdEUvg5ho1v5FWLN+7oUKK6vhMPXXYajGn6vD+B389XaLj C1vB78DolVF/0r3JzLyff9Eu1T0SNIFnn7HLf1VJl02E5TOn6aY4NpmICVzHJQmJjAvX FgG1VEGMlfb2HPx7HHhCavUIzdhNJ0dojemjIl8RyayhHlZF1ky9gL8o3bdBlPisVrmw VGmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JD7m4tZwO+IDa1xgX/FwZAd/NdHORHjMi+i9qNb5uKs=; b=fXQQ1jpcjd+zmG13aIf9WMrhTKli8IecW1seXDlMmmTUOsCYLmgWwzlkZBfcDPEjGs ipuvw0A9/WodHnUtSAqYAfj01ofdaS4g4SSYga8cVloyqafGLiyTNTsYGtvSygZaej/K hmbtlk6eXd+EoJhnm6mrl3Fsp20xzBR11pL9cnQhCjx2S/jmWx7ADveqd+m3tK0Jv7lJ UeauUliuqKqKWfJIoM3q4uM7BI405/JzJVnNcULxTXtFGAMuEihZL3M4/sbAfSav7Ff6 1eVAmECX9s4tT1ppGoPO9LkKRa3HO4E4mXwcSX95BgVCWwEQ/W6n9BcP/CoP8tY2ot/u GaSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ultjCohi; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id q13sor5747990plr.43.2019.08.20.16.06.41 for (Google Transport Security); Tue, 20 Aug 2019 16:06:41 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ultjCohi; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JD7m4tZwO+IDa1xgX/FwZAd/NdHORHjMi+i9qNb5uKs=; b=ultjCohiF3aF5SKoBtMgvK3996QvDB4DB8LMN4ZJXzQ/IADuWxwM6RXS0aL1KWxhky f17ioMxRO2j+E5oyHoDncbYXqO0/p/6EdVY/+hlXpqUJvTKFAQ5imnrAr6qbwaLIbTXt JqijIJ7KAIMXd5/ir6UAwmV1WRSe3nm0N+Lbx1TS1rsEy3eAOKW6W7ooAnK1KJG3s6Bj XsKnzgBNlzhkM+dqHOFHXBVYDrRkqQJaJFR9JiJUVtwohJyi0I1YEDOEDGaaFwf1W6dS fBqwUySj7mnJbpGcZVapSGC6x2bu9M+D/iThbVPJ8PejNTx3fyX9iaxAXbf6VGxVzivY O9Kw== 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; bh=JD7m4tZwO+IDa1xgX/FwZAd/NdHORHjMi+i9qNb5uKs=; b=jBV2zICvxA9hKck8B91RiBSjgJgebfVRHrAFF7/BeWcRtA8hUyDuZio9ORinIeziFd DlZnyn2dneQEsoGoFW38w1tlWxS9/3VgvjUylmmnLxpSaJXpS3ooJtiU/OpAegmb5LQ7 E0ePyMsvpq73E9S9Qbr7fa6Sj3YwVzIdqLe5B2MPdI43jf8VwkcfLvvsFXhEKj4r/MaX 4TUUOSrnf3NNEZ30ZZgXILIfBvMOuucTdcE6X97woEBNxZrDoKeiQXmAgLxVuSTtiRJm bYq4PF81/0+FyJP+MuU5VJFFgXVwlSq/vezvjHpZPZjmbxg8Q13w3aB4+ddEFPvwB6uL u9Nw== X-Gm-Message-State: APjAAAVf0Yplgj+3o2l6WWC14PfBMy5K6Bt5LC+DIrgUfmn+dMIzszTf HcAH9vvBcdsDGtq7Xjm8Y8tvqU7r X-Google-Smtp-Source: APXvYqyjR3pev/6MPv1S4rx9Fw8zhNrO4paP3w4iaxvHJPNck874/OAEJfh9LV3ko11Ugqjy3Y3w0g== X-Received: by 2002:a17:902:5a46:: with SMTP id f6mr28717477plm.319.1566342401294; Tue, 20 Aug 2019 16:06:41 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id q4sm27564747pff.183.2019.08.20.16.06.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 16:06:40 -0700 (PDT) From: John Stultz To: lkml Cc: Xu YiPing , Rongrong Zou , Xinliang Liu , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg , John Stultz Subject: [PATCH v5 08/25] drm: kirin: Dynamically allocate the hw_ctx Date: Tue, 20 Aug 2019 23:06:09 +0000 Message-Id: <20190820230626.23253-9-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820230626.23253-1-john.stultz@linaro.org> References: <20190820230626.23253-1-john.stultz@linaro.org> From: Xu YiPing As part of refactoring the kirin driver to better support different hardware revisions, this patch modifies the initialization function to dynamically allocate the ade_hw_ctx structure previously kept as part of struct ade_data. This is done so that later we can have the hw_ctx point to hardware revision specific ctx structures. Cc: Rongrong Zou Cc: Xinliang Liu Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Cc: Sam Ravnborg Acked-by: Xinliang Liu Reviewed-by: Sam Ravnborg Signed-off-by: Xu YiPing [jstultz: reworded commit message] Signed-off-by: John Stultz --- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index fce374ec69e8..ecb507985fea 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -72,7 +72,7 @@ struct kirin_plane { struct ade_data { struct kirin_crtc crtc; struct kirin_plane planes[ADE_CH_NUM]; - struct ade_hw_ctx ctx; + struct ade_hw_ctx *hw_ctx; }; /* ade-format info: */ @@ -951,55 +951,62 @@ static int ade_plane_init(struct drm_device *dev, struct kirin_plane *kplane, return 0; } -static int ade_dts_parse(struct platform_device *pdev, struct ade_hw_ctx *ctx) +static void *ade_hw_ctx_alloc(struct platform_device *pdev) { struct resource *res; struct device *dev = &pdev->dev; struct device_node *np = pdev->dev.of_node; + struct ade_hw_ctx *ctx = NULL; + + ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); + if (!ctx) { + DRM_ERROR("failed to alloc ade_hw_ctx\n"); + return ERR_PTR(-ENOMEM); + } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); ctx->base = devm_ioremap_resource(dev, res); if (IS_ERR(ctx->base)) { DRM_ERROR("failed to remap ade io base\n"); - return PTR_ERR(ctx->base); + return ERR_PTR(-EIO); } ctx->reset = devm_reset_control_get(dev, NULL); if (IS_ERR(ctx->reset)) - return PTR_ERR(ctx->reset); + return ERR_PTR(-ENODEV); ctx->noc_regmap = syscon_regmap_lookup_by_phandle(np, "hisilicon,noc-syscon"); if (IS_ERR(ctx->noc_regmap)) { DRM_ERROR("failed to get noc regmap\n"); - return PTR_ERR(ctx->noc_regmap); + return ERR_PTR(-ENODEV); } ctx->irq = platform_get_irq(pdev, 0); if (ctx->irq < 0) { DRM_ERROR("failed to get irq\n"); - return -ENODEV; + return ERR_PTR(-ENODEV); } ctx->ade_core_clk = devm_clk_get(dev, "clk_ade_core"); if (IS_ERR(ctx->ade_core_clk)) { DRM_ERROR("failed to parse clk ADE_CORE\n"); - return PTR_ERR(ctx->ade_core_clk); + return ERR_PTR(-ENODEV); } ctx->media_noc_clk = devm_clk_get(dev, "clk_codec_jpeg"); if (IS_ERR(ctx->media_noc_clk)) { DRM_ERROR("failed to parse clk CODEC_JPEG\n"); - return PTR_ERR(ctx->media_noc_clk); + return ERR_PTR(-ENODEV); } ctx->ade_pix_clk = devm_clk_get(dev, "clk_ade_pix"); if (IS_ERR(ctx->ade_pix_clk)) { DRM_ERROR("failed to parse clk ADE_PIX\n"); - return PTR_ERR(ctx->ade_pix_clk); + return ERR_PTR(-ENODEV); } - return 0; + return ctx; } static int ade_drm_init(struct platform_device *pdev) @@ -1020,14 +1027,16 @@ static int ade_drm_init(struct platform_device *pdev) } platform_set_drvdata(pdev, ade); - ctx = &ade->ctx; + ctx = ade_hw_ctx_alloc(pdev); + if (IS_ERR(ctx)) { + DRM_ERROR("failed to initialize kirin_priv hw ctx\n"); + return -EINVAL; + } + ade->hw_ctx = ctx; + kcrtc = &ade->crtc; kcrtc->hw_ctx = ctx; - ret = ade_dts_parse(pdev, ctx); - if (ret) - return ret; - /* * plane init * TODO: Now only support primary plane, overlay planes From patchwork Tue Aug 20 23:06:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171868 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp180065ily; Tue, 20 Aug 2019 16:06:43 -0700 (PDT) X-Received: by 2002:aa7:9483:: with SMTP id z3mr32752769pfk.104.1566342403299; Tue, 20 Aug 2019 16:06:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566342403; cv=none; d=google.com; s=arc-20160816; b=TxWvh0oh9X/EV/vOjWuOFeNZNakFp0eXFx9C+d5ccZntF69SvPHf0Gez7IM7JQjNWS 7dWx2I/bhTyQlHcDPzK4CgI3+x838BWJI7E27ZtYcSFPdTddPcm8Xuc9HIgGHObgmmR9 YQH87ZC0zTSIV437YOHAES4xGueeiGeqyECKoPEbRW2JthItmCVu/9uPTat0qoP+nvrE mAroiStJK1gK3H0/+r0q38Ha4YAFoVFY+Zru4KqUV+srXMZN6nenpf1SkLuefbnLlQS7 wVefomR2DxRMxhJ1+MMGt91kfCy56/rI99jjuhRvyabvNpDbuPKYCm3c9/rGSNfLwPv2 hntA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IHOpC8CLMCy6vYTMkD3TApEoOIR8Z3RyhkmjOSjWV48=; b=aZUrGCYepH4sv5XI+9sLNxWuyLfFQigJSX5moIemxaUcmZsI3/ka2VHOmCdRhfJk6i /6/1iJ/p3ZxN9QB0UAAIAvAWqb9YfE1sAaYm7Rn+tm9UNCwu3osJMXaCazIjF0vHdjei vkGSkQu6BpeFvj0PiTkv+XlXQ4SAkIxY9K9z0CUTH4fSflTZaU1/4Imr6PS3z0DPUsDh kl5Tlc3ik4phSXqEfjdci9jYZBcsBymTU4ZlsVu5iIafEceO6Jt3z95SxscSVzk9wa5T CNQcSfmqjD7qKCJ1W3b9y1SAJsT3TqA/vAwjjU0Q4gQVNv0FVtEJFjxgRUM/GliW3UMn YUfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Lf3X1kiV; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id t9sor1818994pji.21.2019.08.20.16.06.43 for (Google Transport Security); Tue, 20 Aug 2019 16:06:43 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Lf3X1kiV; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IHOpC8CLMCy6vYTMkD3TApEoOIR8Z3RyhkmjOSjWV48=; b=Lf3X1kiV6Q+88ALsWCTXpUPKE3BXimIMLls1hjiLvA+69eGl5zRh7EytASAO1J72oH Opd16Ho9fTavo08W9QtWEH0ivz4UelAAjsLR1AWdxgi0arlaoSOnE216Hm2g67F/0+N3 umGrniElDd5TBOo82p/a1vzDMo4xb9eY15B94Esn6GLXZwTNlwBCnU0+m0W0DMzkcs1N h+W16udncU+Jx955N0uLwOwNJ83OLYC/1ssJL4qLKuJI+2WrclJIlr9qiLA+QvwK8Hbk gRrePxJrP6z6mHRedFi5bhbzujcM+2b7X8j8q0VzcJBskcODPiwvx06rQ6n/IOJoR5tw Bcig== 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; bh=IHOpC8CLMCy6vYTMkD3TApEoOIR8Z3RyhkmjOSjWV48=; b=WnG17EyW33NoF0vpcaXm+YKcGMvBPAU3wo9I1v2SarNSSJKVLFPZdB7C1dxco+NA6m H0k1QfkGkuiK9Oaad4l6vn1ZIPO0UkAyZT5mhDhApLDmaGAymIkncUuS9CbvjPJFsUo8 RimTPxOyZdIVKukiJafndkJfUTOwe9WAuXrbK6izyHfwAKebSG5+U19KYuZz2nK2Gt7K esP1SpyXuodHUEoOjVpMxv84tTQU5qil8Cccu5sYGa4sAGgBi7Z1UbSD6VwFsSao6lKP gMTLbAGxmG7Tfu7fz4Qrx1+uGxLQRQTm375zpdQhcnp19R+dS5dyvr1r0cKVYxIEEKDX 7KFA== X-Gm-Message-State: APjAAAUbPpRGLV63tn4bRDSOudp+IOtKVP9f0wSaNroTnc3q5EDHYQlS 3tO8eezyNG0s64aGD9JMOXAQq0MN X-Google-Smtp-Source: APXvYqwFyS1sAlRP8XG80pzzyhQTF9viVgJhczs8w38ldtloeV/kE7MMCAlmSY0+sBENvGQCc7gM0A== X-Received: by 2002:a17:90a:ae15:: with SMTP id t21mr2369044pjq.50.1566342402912; Tue, 20 Aug 2019 16:06:42 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id q4sm27564747pff.183.2019.08.20.16.06.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 16:06:42 -0700 (PDT) From: John Stultz To: lkml Cc: Xu YiPing , Rongrong Zou , Xinliang Liu , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg , John Stultz Subject: [PATCH v5 09/25] drm: kirin: Move request irq handle in ade hw ctx alloc Date: Tue, 20 Aug 2019 23:06:10 +0000 Message-Id: <20190820230626.23253-10-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820230626.23253-1-john.stultz@linaro.org> References: <20190820230626.23253-1-john.stultz@linaro.org> From: Xu YiPing As part of refactoring the kirin driver to better support different hardware revisions, this patch modifies the initialization routines so the devm_request_irq() function is called as part of the allocation function. This will be needed in the future when we will have different allocation functions to allocate hardware specific hw_ctx structures, which will setup the vblank irq differently. Cc: Rongrong Zou Cc: Xinliang Liu Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Cc: Sam Ravnborg Acked-by: Xinliang Liu Reviewed-by: Sam Ravnborg Signed-off-by: Xu YiPing [jstultz: reworded commit message] Signed-off-by: John Stultz --- v5: checkpatch --strict whitespace fixups noticed by Sam --- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index ecb507985fea..d0a7c1d0adbe 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -54,6 +54,8 @@ struct ade_hw_ctx { struct reset_control *reset; bool power_on; int irq; + + struct drm_crtc *crtc; }; struct kirin_crtc { @@ -358,9 +360,9 @@ static void drm_underflow_wq(struct work_struct *work) static irqreturn_t ade_irq_handler(int irq, void *data) { - struct kirin_crtc *kcrtc = data; - struct ade_hw_ctx *ctx = kcrtc->hw_ctx; - struct drm_crtc *crtc = &kcrtc->base; + struct ade_hw_ctx *ctx = data; + struct drm_crtc *crtc = ctx->crtc; + struct kirin_crtc *kcrtc = to_kirin_crtc(crtc); void __iomem *base = ctx->base; u32 status; @@ -951,12 +953,14 @@ static int ade_plane_init(struct drm_device *dev, struct kirin_plane *kplane, return 0; } -static void *ade_hw_ctx_alloc(struct platform_device *pdev) +static void *ade_hw_ctx_alloc(struct platform_device *pdev, + struct drm_crtc *crtc) { struct resource *res; struct device *dev = &pdev->dev; struct device_node *np = pdev->dev.of_node; struct ade_hw_ctx *ctx = NULL; + int ret; ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); if (!ctx) { @@ -1006,6 +1010,14 @@ static void *ade_hw_ctx_alloc(struct platform_device *pdev) return ERR_PTR(-ENODEV); } + /* vblank irq init */ + ret = devm_request_irq(dev, ctx->irq, ade_irq_handler, + IRQF_SHARED, dev->driver->name, ctx); + if (ret) + return ERR_PTR(-EIO); + + ctx->crtc = crtc; + return ctx; } @@ -1027,7 +1039,7 @@ static int ade_drm_init(struct platform_device *pdev) } platform_set_drvdata(pdev, ade); - ctx = ade_hw_ctx_alloc(pdev); + ctx = ade_hw_ctx_alloc(pdev, &ade->crtc.base); if (IS_ERR(ctx)) { DRM_ERROR("failed to initialize kirin_priv hw ctx\n"); return -EINVAL; @@ -1059,15 +1071,8 @@ static int ade_drm_init(struct platform_device *pdev) if (ret) return ret; - /* vblank irq init */ - ret = devm_request_irq(dev->dev, ctx->irq, ade_irq_handler, - IRQF_SHARED, dev->driver->name, kcrtc); - INIT_WORK(&kcrtc->display_reset_wq, drm_underflow_wq); - if (ret) - return ret; - return 0; } From patchwork Tue Aug 20 23:06:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171872 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp180214ily; Tue, 20 Aug 2019 16:06:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqyQJlwSOOf7zuaAF5hHQIgvh8fp81Sx419qRPF3ucJrNymyi0hyRE/eg1hFOactMUR9OmpI X-Received: by 2002:a17:90a:c20f:: with SMTP id e15mr2292207pjt.123.1566342409792; Tue, 20 Aug 2019 16:06:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566342409; cv=none; d=google.com; s=arc-20160816; b=In1HoMtCt3xqsw0mvvaIP7NIOew0eYyxEsh5tvW2fCxkQRkoZhGTr+HMzDnSGVRbZD mE2bsub/W/Q4j2Hcz3+i8EMOx/LHZgbVwjPw8H3kTMXGUXH2c2Nykm66aAwQHA2DdLUw ll5vYDTaocOVkj/KR9qVkUNOYNZzsuwlAlZKV464hHxYqlA99RoIX40V5u3bLlZxyCxN ZuaicSjKesfsiZ0Umo6G7vd9pV5TwDPlN0pagfIXy16efweIcSQmzfgLCIKW8N6uZNh5 2LNIeSxA90ox1j54lYV/LWOJ9xzhbiu5YxPSTKfbP9IW+UiiCJu0W80m8Ne4WKF+kDTH ekdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=UWiGXBfNJ86mDn5vZAb7KTs6jR4hl8/Ldv9PC03GxK8=; b=D8eru1zs71pquP4o3vP+0YuLpr8lJI1aqk2nOkfSP+o4LFwkbPbpwjsF8QcGt8m//z fQjtLFEwIHaQ+F6DSquN77VCmM81Ew996YbdpBCKOtrj9nJ/H+kysG39JTGISc+LKISw WAug26ZG/b+gUphbtF//kPI/mBiWzcjy3L7Z7dgzxWTy5UDWKa9oYi9d+QRfAQI2rWOi CMnxEQ7K/t95S5n3ozBrCjgZ+r09HCtFtC/MsrHhS1drm4vQQJtMNObViipEq5qnVmhi KaaMJTgq2U+b7llbSDnGv5YhRhG4xQgOvyWk8zJ6+5azSAOzzvrAgPc5TIyFCTRrfyOt ACyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=im5eLTod; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n6si13635300pgs.333.2019.08.20.16.06.49; Tue, 20 Aug 2019 16:06:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=im5eLTod; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726543AbfHTXGs (ORCPT + 28 others); Tue, 20 Aug 2019 19:06:48 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:37886 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726470AbfHTXGp (ORCPT ); Tue, 20 Aug 2019 19:06:45 -0400 Received: by mail-pf1-f195.google.com with SMTP id 129so95155pfa.4 for ; Tue, 20 Aug 2019 16:06:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UWiGXBfNJ86mDn5vZAb7KTs6jR4hl8/Ldv9PC03GxK8=; b=im5eLTodcpvNyYnvYfKclfPWmk5IUJ/g/C/c2m9NEVUHIuNQ2eHed4taHOze1kwaBw /k5jCxwp3/XS53RsLk0B+/s9PsXzJe0e8yPuOysMN2KjnMRvjRhKfGLDX1VQiUZAlEI7 TRJtpAwNUF1f94QjOU7ib737yMsqAJcLaC1kALQ/6RNW7ZZK6ezT0QikKFBhc9qzo0Yz LXEPg0he5RI7DAmFAkAzsMDnAU7mSbxjUctQ+S5tiZsx7tVs+LKORaMe0PTposQ+jkHI /HkmmQMM5WoBkTZMu906bIuDQjRD24C2/Rv2zLAM8RO1NAt832o5zjIL6Nk3y9TIk0fd kfwQ== 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; bh=UWiGXBfNJ86mDn5vZAb7KTs6jR4hl8/Ldv9PC03GxK8=; b=UXtgpz8ljCgVBJdlcnfi5i7uFi+t+P8JK7ur778FoPjSTg5+ZdRGiLM6CROv+mYH8o YyhNZWA5ZqxaUDIigGG/HBOhKrHpMPoTwZRDk6UtHVd9MeUdaplnjanZRpQe/3vh5UUe 2vi6IvL9YgvEXKNpmaRSLNWfhUoOO3DYU8zB4aZNtBlbeIeLEI9hK5bI/bDvB0gbAHbq UaU++wg9n5TrUw3McRm5lpH9Pd95b6GTMqsUw3ym4BEy/DEs79eHwkeYZw0NvFzgw2Ie Docs9vDkXPmWs/Bg5H0GWnH4d59dvHyCBi3XIZKpC2Y9fl38gM6Aik4wwa2zRlYThalm cmmQ== X-Gm-Message-State: APjAAAVgRX7a6S7vbbPFCUNOBFRyMGHOsGkstZ2u6chfA3aEmtHZGgS7 ebnE+EXecXCYqchyNROz/cQVDtA3Q0w= X-Received: by 2002:a17:90a:8d86:: with SMTP id d6mr2371628pjo.94.1566342404395; Tue, 20 Aug 2019 16:06:44 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id q4sm27564747pff.183.2019.08.20.16.06.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 16:06:43 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Rongrong Zou , Xinliang Liu , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg Subject: [PATCH v5 10/25] drm: kirin: Move workqueue to ade_hw_ctx structure Date: Tue, 20 Aug 2019 23:06:11 +0000 Message-Id: <20190820230626.23253-11-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820230626.23253-1-john.stultz@linaro.org> References: <20190820230626.23253-1-john.stultz@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The workqueue used to reset the display when we hit an LDI underflow error is ADE specific, so since this patch series works to make the kirin_crtc structure more generic, move the workqueue to the ade_hw_ctx structure instead. Cc: Rongrong Zou Cc: Xinliang Liu Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Cc: Sam Ravnborg Acked-by: Xinliang Liu Reviewed-by: Sam Ravnborg Signed-off-by: John Stultz --- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index d0a7c1d0adbe..da9f477679a3 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -52,6 +52,7 @@ struct ade_hw_ctx { struct clk *media_noc_clk; struct clk *ade_pix_clk; struct reset_control *reset; + struct work_struct display_reset_wq; bool power_on; int irq; @@ -61,7 +62,6 @@ struct ade_hw_ctx { struct kirin_crtc { struct drm_crtc base; void *hw_ctx; - struct work_struct display_reset_wq; bool enable; }; @@ -349,9 +349,9 @@ static void ade_crtc_disable_vblank(struct drm_crtc *crtc) static void drm_underflow_wq(struct work_struct *work) { - struct kirin_crtc *acrtc = container_of(work, struct kirin_crtc, + struct ade_hw_ctx *ctx = container_of(work, struct ade_hw_ctx, display_reset_wq); - struct drm_device *drm_dev = (&acrtc->base)->dev; + struct drm_device *drm_dev = ctx->crtc->dev; struct drm_atomic_state *state; state = drm_atomic_helper_suspend(drm_dev); @@ -362,7 +362,6 @@ static irqreturn_t ade_irq_handler(int irq, void *data) { struct ade_hw_ctx *ctx = data; struct drm_crtc *crtc = ctx->crtc; - struct kirin_crtc *kcrtc = to_kirin_crtc(crtc); void __iomem *base = ctx->base; u32 status; @@ -379,7 +378,7 @@ static irqreturn_t ade_irq_handler(int irq, void *data) ade_update_bits(base + LDI_INT_CLR, UNDERFLOW_INT_EN_OFST, MASK(1), 1); DRM_ERROR("LDI underflow!"); - schedule_work(&kcrtc->display_reset_wq); + schedule_work(&ctx->display_reset_wq); } return IRQ_HANDLED; @@ -1016,6 +1015,7 @@ static void *ade_hw_ctx_alloc(struct platform_device *pdev, if (ret) return ERR_PTR(-EIO); + INIT_WORK(&ctx->display_reset_wq, drm_underflow_wq); ctx->crtc = crtc; return ctx; @@ -1071,8 +1071,6 @@ static int ade_drm_init(struct platform_device *pdev) if (ret) return ret; - INIT_WORK(&kcrtc->display_reset_wq, drm_underflow_wq); - return 0; } From patchwork Tue Aug 20 23:06:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171869 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp180128ily; Tue, 20 Aug 2019 16:06:46 -0700 (PDT) X-Received: by 2002:a17:90a:a00d:: with SMTP id q13mr2396550pjp.114.1566342405958; Tue, 20 Aug 2019 16:06:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566342405; cv=none; d=google.com; s=arc-20160816; b=hihYfaYzEP8EjKLaawhWExoY2Ur+JPu/PXDM9JelHnGBkLrlVcajskWbLaMz6mQyo3 nww+Earazif+1iclTbJbwj9tx62SH4NZL8apXNQc1oISjAV1pQhX/OfcqgXTGENbZp5R CUxHrcjJH7goHEMFDuJQMw8RWJcWIaWFjE0wffsoS/klaGpuK1/eE6s7yQL/3ddrYurI g/x2PpdwFLYtFaLEGxjNDIw2HYrliIn6zd6Y5LcywO3xc5S6/H4JOFpzwYME09BvC5Bt d4RX3JdeRykcELCrWZdvqiDc3hVn8/Z9gj4EnLK0QdZTYTxKdHTsBUD1rQy0g1RpyKws JS/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=agbQoDDs1++FfyQHMzk0YO2MigtF6/kdBKLBogsUhss=; b=yostyDSrEepVPEIBlyunkTvMZJbjqVSY07pr2NK2k6fvEw9NaDkcy5cC1XRBGTPCC7 6Lxb+y8PduhDphJT4Yc6ByjEtvXKyaM6TX0ebpSlbkeJRMRPhIcp4i3qqc4aUSG9qv2x BIyLrh65SoPthhEcJbp2QNoirsKZN7cm2LjIVg3Q+lXdMaA4aMPZlTTbSfjmqq7SQiOA s0kdw3DXspaToJu4ANoME3z4cSBoRBF3iEu6LXzQvyev+uuBAFL0OUKtuzUeL4ZhmJ+2 /5NUG5eGl/v00czC8OVzRLhpOEvRBSqIISE8bMYUZwprK0RKg301RcXkiXW+nyNBR029 0FXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UnQiUTuc; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id gn19sor6860969plb.30.2019.08.20.16.06.45 for (Google Transport Security); Tue, 20 Aug 2019 16:06:45 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UnQiUTuc; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=agbQoDDs1++FfyQHMzk0YO2MigtF6/kdBKLBogsUhss=; b=UnQiUTuc0BE9+QzXshy4rNkJmm+9QdEpKNXjs0jrBBpCLpvQxr0OFf+uzTU1fKLZUd U+6XMHVbRLD7NLNXzUFvqoa6WG7ox/rxP7FTcDxcu9nvoJP53gEVrmotLD7oQiPvVHs7 sHDvVFRSVLUzhUEHU67hHUfA8b1H9nHD5419g5e+49YIxQfOKQmFnDZh/kMAWrfDvkpW Qhu2m8nO0MvlAEXhgt2GUUjaQ9vCVLfzaYvvRlMbw88pSK9WzW36mKRsPa27u4fW8st7 p0Sm0UBQf8Sj0KSuhUH9sDJZyjR13hsrijDwJZzqW+NjS6ojgmjwLkBDKZLNp499pKv/ Qs2g== 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; bh=agbQoDDs1++FfyQHMzk0YO2MigtF6/kdBKLBogsUhss=; b=p9NFSbTZStHFLwxtCnlnfBPhcn0Xz2888ITLzUOWD1SHlSOXuNUZ+HDG68KvGIQhAo 8w2x9k16W4/a8Cx7/YbQKaS3NjshELNIn4+aggjEBmYgCgR5t0La+F5+pU2SpQXeQ6YU iiz13pPWyFaYnn0rNOER4w2CBOnIulcMa3wWp2mhvUBNIV73dQH3kNxtfRpVR+aDxJAA JuLCmXMIG8VVVEhMdzTNCGrDpxCZ0apCoMWvxq6xf/xtkmvBUZgfxcdrnMcmYHogOYgq 8+vc0yXaYFWbIKlGs6W+ae+61Y55u/+Mdy88SbFsF4Hd3zugbHt293YHsVaAyuQaptjD +CcQ== X-Gm-Message-State: APjAAAX0AXjV5R1lw6mx3rUCNXR2gdggX6lFGPb/89RwqzhHEiAwannk eUHh89RDMfmITUQqnJR3EjaEKXMx X-Google-Smtp-Source: APXvYqw0XeS9psDk0ARBG6xEE0Yz76hurSEj3BK/Au7bic2CmkXtyBVc1sIbljqrdndw6/t3Ms7obQ== X-Received: by 2002:a17:902:bc4c:: with SMTP id t12mr31536024plz.1.1566342405586; Tue, 20 Aug 2019 16:06:45 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id q4sm27564747pff.183.2019.08.20.16.06.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 16:06:44 -0700 (PDT) From: John Stultz To: lkml Cc: Xu YiPing , Rongrong Zou , Xinliang Liu , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg , John Stultz Subject: [PATCH v5 11/25] drm: kirin: Move kirin_crtc, kirin_plane, kirin_format to kirin_drm_drv.h Date: Tue, 20 Aug 2019 23:06:12 +0000 Message-Id: <20190820230626.23253-12-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820230626.23253-1-john.stultz@linaro.org> References: <20190820230626.23253-1-john.stultz@linaro.org> From: Xu YiPing As part of refactoring the kirin driver to better support different hardware revisions, this patch moves some shared structures and helpers to the common kirin_drm_drv.h These structures will later used by both kirin620 and future kirin960 driver Cc: Rongrong Zou Cc: Xinliang Liu Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Cc: Sam Ravnborg Acked-by: Xinliang Liu Reviewed-by: Sam Ravnborg Signed-off-by: Xu YiPing [jstultz: reworded commit message] Signed-off-by: John Stultz --- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 27 ++----------------- .../gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 24 +++++++++++++++++ 2 files changed, 26 insertions(+), 25 deletions(-) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index da9f477679a3..3fbf099597c1 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -38,12 +38,6 @@ #define OUT_OVLY ADE_OVLY2 /* output overlay compositor */ #define ADE_DEBUG 1 -#define to_kirin_crtc(crtc) \ - container_of(crtc, struct kirin_crtc, base) - -#define to_kirin_plane(plane) \ - container_of(plane, struct kirin_plane, base) - struct ade_hw_ctx { void __iomem *base; @@ -59,18 +53,6 @@ struct ade_hw_ctx { struct drm_crtc *crtc; }; -struct kirin_crtc { - struct drm_crtc base; - void *hw_ctx; - bool enable; -}; - -struct kirin_plane { - struct drm_plane base; - void *hw_ctx; - u32 ch; -}; - struct ade_data { struct kirin_crtc crtc; struct kirin_plane planes[ADE_CH_NUM]; @@ -78,12 +60,7 @@ struct ade_data { }; /* ade-format info: */ -struct ade_format { - u32 pixel_format; - enum ade_fb_format ade_format; -}; - -static const struct ade_format ade_formats[] = { +static const struct kirin_format ade_formats[] = { /* 16bpp RGB: */ { DRM_FORMAT_RGB565, ADE_RGB_565 }, { DRM_FORMAT_BGR565, ADE_BGR_565 }, @@ -127,7 +104,7 @@ static u32 ade_get_format(u32 pixel_format) for (i = 0; i < ARRAY_SIZE(ade_formats); i++) if (ade_formats[i].pixel_format == pixel_format) - return ade_formats[i].ade_format; + return ade_formats[i].hw_format; /* not found */ DRM_ERROR("Not found pixel format!!fourcc_format= %d\n", diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h index 22d1291668cd..d47cbb427979 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h @@ -9,6 +9,30 @@ #define MAX_CRTC 2 +#define to_kirin_crtc(crtc) \ + container_of(crtc, struct kirin_crtc, base) + +#define to_kirin_plane(plane) \ + container_of(plane, struct kirin_plane, base) + +/* kirin-format translate table */ +struct kirin_format { + u32 pixel_format; + u32 hw_format; +}; + +struct kirin_crtc { + struct drm_crtc base; + void *hw_ctx; + bool enable; +}; + +struct kirin_plane { + struct drm_plane base; + void *hw_ctx; + u32 ch; +}; + /* display controller init/cleanup ops */ struct kirin_dc_ops { int (*init)(struct platform_device *pdev); From patchwork Tue Aug 20 23:06:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171870 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp180155ily; Tue, 20 Aug 2019 16:06:47 -0700 (PDT) X-Received: by 2002:aa7:991a:: with SMTP id z26mr28482954pff.43.1566342407498; Tue, 20 Aug 2019 16:06:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566342407; cv=none; d=google.com; s=arc-20160816; b=N2r9iZOhS1lS06p7+EvuZcuZuJiaKK3GIdfyObAF/0l/qjOZmvgyRo3y7fMdgoE0/u maVxJS8/THcf1mEh63MjN3PLvb2Qu6bBaJebKnStJktgwsvrOU+rpRlgok85gknEoUeK Y6wtEaZXxx5fjUd0Laq6B8QPcxwiX7eg0y06xTC2Pc1/I+rs28A4qVWbH5CWR4Uq27eb mxQ2+b8elWFktzeQAJkxjBB8FcDIdOQbCgfYm38z9pcnYkHd1hd+w9V9JCgU7st2MtfV G7XbDXfhCjbBrEuQtFl7InD9mAnoS/v5OXmtyiCpX4tiKA1WNRhXoC6t1v1U97WJkVAo WLvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jrafS1xNw8QuY6208vzcwdkt7ZoMFEpwTrneiMG+q3Y=; b=rWoImgCFojFoKhdBliWEeVCu67f/reCo/bCIT94JwjxjzY2JtFvB75yUQQl2g0Khx9 UuvvgieWbmmeBisvyQqKDtcVltBuaUjk5LL8tXGzcAfReFmONf+FKxyUOl4MUgwAWJE/ pasQpK1BPRuNehGKMFmrPUYFDuTLOJ4P1qN0R1uZ9omQiGhMybbkDSyo5EWGh3gfmfyj AQfHsLuKb6aZErDlH9SxPu7NoY7VUtg2drcD8a14hjugt/ayMOTTTSJ51oknRYZNnbey OIe7lY84shkiqlXi48ns21aNdcmFtFswuVP8ZNbm5iOYP05/DCM+h3Gd6azxm8pO0iaB dgRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=x3n3QKSm; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id t1sor1797311pjv.17.2019.08.20.16.06.47 for (Google Transport Security); Tue, 20 Aug 2019 16:06:47 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=x3n3QKSm; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jrafS1xNw8QuY6208vzcwdkt7ZoMFEpwTrneiMG+q3Y=; b=x3n3QKSmp9O/+aB+dueAM4VMGwlrka/AjLuZQIGhfTSRJL3h02hR4DaP89vrNglcLI aODrVQVO3nmXcjujtmB3WzPKUMa+WmElxF3+if7c1eZP01jl8XqgpnGczM6DmIkXpkQH ptOIvlb9Q1cpl3/EqkR7Pydd77uHQKpN5/2+Ik3+M6wm/RRUGhCYtfKI/RdDrCEbHNs8 +rNB2vyOBpyF33L/rs1vEeWPRRAsSdUsKuycuh+Y/uluizXm1IMZFFpwNAAZEYHnTEFy nqJihsNLgRZJ4mo3uEYtpqusja+UoX7Z2if/FpH2vg1OTMR7qiTnJJ03u/WdDYnr0FDW 8o+A== 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; bh=jrafS1xNw8QuY6208vzcwdkt7ZoMFEpwTrneiMG+q3Y=; b=TNKN/kkrDZZwMEUs80+U+8G1QIH9iu3Nwr3V0kQV+kwcrIABNxYJJHWv84R67OU6a1 md1k6Evedp4liSOJKTXAT0vChuI59W2R60IYxVtWe4XVd7ASSumi5DkjBZuhBNP+GBCq VWaaUZGKAsOcGhtqlUNXR/jF/Ootg8AHwK8jYcFzVVqa/sK5qCGsl6a8yd6vsOPYHhf9 rnIubS6QFWJhEDpDCsmoGW850Wx04uzxGyYcdtnSLQ6s8nBvkMpr7ExA4AzoCRVkZXua CmInsDrKg41gds40p69la13ON7Pp2gmZUAiWHDUHzROo4pzPvKdEZ9iG9SoIV5q7/pBW JjKQ== X-Gm-Message-State: APjAAAXTeJYbz1NxgxexOge/lAL9qJUglEtmNFw+hSykHdIDwfjNfyZM aqsqdvYYKj3J7mY7IcDy3N4xAvng X-Google-Smtp-Source: APXvYqyquopmDIvJN+OnfrRPasNzNke/5ztk9S/nht4GczZwiyytgvvzq6gNRK0k3RRvbAzdh+5hmA== X-Received: by 2002:a17:90a:f995:: with SMTP id cq21mr2408433pjb.27.1566342407060; Tue, 20 Aug 2019 16:06:47 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id q4sm27564747pff.183.2019.08.20.16.06.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 16:06:46 -0700 (PDT) From: John Stultz To: lkml Cc: Xu YiPing , Rongrong Zou , Xinliang Liu , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg , John Stultz Subject: [PATCH v5 12/25] drm: kirin: Reanme dc_ops to kirin_drm_data Date: Tue, 20 Aug 2019 23:06:13 +0000 Message-Id: <20190820230626.23253-13-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820230626.23253-1-john.stultz@linaro.org> References: <20190820230626.23253-1-john.stultz@linaro.org> From: Xu YiPing As part of refactoring the kirin driver to better support different hardware revisions, this patch renames the struct kirin_dc_ops to struct kirin_drm_data and cleans up the related variable names. Cc: Rongrong Zou Cc: Xinliang Liu Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Cc: Sam Ravnborg Acked-by: Xinliang Liu Reviewed-by: Sam Ravnborg Signed-off-by: Xu YiPing [jstultz: reworded commit message] Signed-off-by: John Stultz --- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 2 +- drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 16 ++++++++-------- drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index 3fbf099597c1..4c6646dfc465 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -1055,7 +1055,7 @@ static void ade_drm_cleanup(struct platform_device *pdev) { } -const struct kirin_dc_ops ade_dc_ops = { +struct kirin_drm_data ade_driver_data = { .init = ade_drm_init, .cleanup = ade_drm_cleanup }; diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c index fcdd6b1e167d..3d22f944a840 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c @@ -29,12 +29,12 @@ #include "kirin_drm_drv.h" -static struct kirin_dc_ops *dc_ops; +static struct kirin_drm_data *driver_data; static int kirin_drm_kms_cleanup(struct drm_device *dev) { drm_kms_helper_poll_fini(dev); - dc_ops->cleanup(to_platform_device(dev->dev)); + driver_data->cleanup(to_platform_device(dev->dev)); drm_mode_config_cleanup(dev); return 0; @@ -68,7 +68,7 @@ static int kirin_drm_kms_init(struct drm_device *dev) kirin_drm_mode_config_init(dev); /* display controller init */ - ret = dc_ops->init(to_platform_device(dev->dev)); + ret = driver_data->init(to_platform_device(dev->dev)); if (ret) goto err_mode_config_cleanup; @@ -99,7 +99,7 @@ static int kirin_drm_kms_init(struct drm_device *dev) err_unbind_all: component_unbind_all(dev->dev, dev); err_dc_cleanup: - dc_ops->cleanup(to_platform_device(dev->dev)); + driver_data->cleanup(to_platform_device(dev->dev)); err_mode_config_cleanup: drm_mode_config_cleanup(dev); @@ -194,8 +194,8 @@ static int kirin_drm_platform_probe(struct platform_device *pdev) struct component_match *match = NULL; struct device_node *remote; - dc_ops = (struct kirin_dc_ops *)of_device_get_match_data(dev); - if (!dc_ops) { + driver_data = (struct kirin_drm_data *)of_device_get_match_data(dev); + if (!driver_data) { DRM_ERROR("failed to get dt id data\n"); return -EINVAL; } @@ -213,13 +213,13 @@ static int kirin_drm_platform_probe(struct platform_device *pdev) static int kirin_drm_platform_remove(struct platform_device *pdev) { component_master_del(&pdev->dev, &kirin_drm_ops); - dc_ops = NULL; + driver_data = NULL; return 0; } static const struct of_device_id kirin_drm_dt_ids[] = { { .compatible = "hisilicon,hi6220-ade", - .data = &ade_dc_ops, + .data = &ade_driver_data, }, { /* end node */ }, }; diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h index d47cbb427979..cd2eaa653db7 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h @@ -34,11 +34,11 @@ struct kirin_plane { }; /* display controller init/cleanup ops */ -struct kirin_dc_ops { +struct kirin_drm_data { int (*init)(struct platform_device *pdev); void (*cleanup)(struct platform_device *pdev); }; -extern const struct kirin_dc_ops ade_dc_ops; +extern struct kirin_drm_data ade_driver_data; #endif /* __KIRIN_DRM_DRV_H__ */ From patchwork Tue Aug 20 23:06:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171871 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp180195ily; Tue, 20 Aug 2019 16:06:49 -0700 (PDT) X-Received: by 2002:a17:902:5a5:: with SMTP id f34mr30161068plf.178.1566342409020; Tue, 20 Aug 2019 16:06:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566342409; cv=none; d=google.com; s=arc-20160816; b=NxYmeReGqYB0aBS6N2wFDhloVVGfzG+oMJe3iHK2tQ0K5vSPc6gmpzwhyI6myMWI3r ZChyVeRsCGXgcC90zBZ0MIARLDdfIvJkCg+5C9EfhjL8lDyyg6srZKBggXtocaSi7sZx ZeW4BCVAhM9uYA+X0c+aMVj/Kfe0e2dd2Dl8BEupBlxWvESq3n3oURW/x/gpX6N0fR1l ftRcX/Fx6eWvx8UdfC89vNmpHNFkscqFdRQW5BSNOAQ5wcdsV4NxB9NRzwARmnnkYi8c Sf5kE1o3LJ26A1I+8uT+H7ldWnM8gLOvAmgy7qfrSA3GFIdhYeiqiUNXGGOg+hwFng9h TvfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=OE/knvVfD1cUvaltFYKP0JvLLCHD/efyGm+69Rc7xlw=; b=i5LtGqDwJEF2fWFwXLttksF4iGvoQfR+XEF19YoQuykGDyY4FthHSFE319t3LRtNPt s9SLe9w1LNDeVlydFUiEE1tu8OIwE+2Y3nIZ0dibz55t8B0lxiAJnDfrwa19xdfi+3Bf 8mnZNWyRyghmh8RwiRSJW5w8G38qQP7MQFAF9tjxKOKpHvzynP3vU65fy4IQ1F2z+hvd gAtUlAWyU6gJQv3Dyb9dN/0t+bFuMFfyXtcrquUwHIW7eECux5OmjmgSA6bTih9zybbi xORQQAqGaH2bDVjaletAJGnvg1FJZfaMYz7+We4iyGC6glYLtx7k5CHyCrr1wiyxP0Ni beOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="t/W5hPjc"; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id v11sor1847254pju.18.2019.08.20.16.06.48 for (Google Transport Security); Tue, 20 Aug 2019 16:06:49 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="t/W5hPjc"; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OE/knvVfD1cUvaltFYKP0JvLLCHD/efyGm+69Rc7xlw=; b=t/W5hPjchDYa6sGZVIGnHO6x84ep6oMs8OQM95dG6M/wiomHPHQuiTvqt+n3CZLObc O+QoVXcBg9FH5iWKGRWKWGKakOXamJ+A1YDSsmZ/eag5qxWoPNbpY0T/FrWTQM4fA4bA 7a1CU2ujUC1Hcu2DpQygzwwEUXYz4SMH1LjAz7Lb/0cvZJQLByjhD8cu7uD48j0rDG8w OZig/Hnis2947iEqf9wJicr4akz0qfd58VRw9QeXmO0++iIIMihvCQLa+rg4497A7OlH dzqJVhg3Y7TS+g635mQguEl93U9enx9o+UtlHWnQjbKEsdI1sMNWx53aFsDToV8F/taD Yvzg== 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; bh=OE/knvVfD1cUvaltFYKP0JvLLCHD/efyGm+69Rc7xlw=; b=Zpe+eCB624cQBXegjHup19KtAFShbHInVYb0gBpxx7cpshTcLHHUi6GGKefrPzArC7 ugb47KHHYKiblajijU7lYgxppf2eCHvYNg7I93gEzkgqTKO/AbXe0ksv/d8vSbwzEY4a KaXKiSzelt0bnaBDDbqPbSQGNlHX/ZKvPuEeVBBPhZPyklPV3Dr2l4H8hJei1AEmSnpR X8qEVXtnGAmFkOTQzgYqJ/+LRh5mzC1LDYjPQCu4FNo05/EdbPL/urfjVxTM7Os/yiUq 6PoqEasxJTHOi1fmafCoHy1f3GCdXDgpbR8CBgcpOY+g4KnhaB65gAJSxMiMyBRHTLjF uPKA== X-Gm-Message-State: APjAAAXNMarFbD7F1HdA42lHj6RxQ4Gr1mBL1TJ5XwFDJ9zcpHIPSTeM J8SFD+/ItsJt1qzS2Y9NDrOmZHYa4tWKuw== X-Google-Smtp-Source: APXvYqy8NWxr4UsxAfs4ZFu3Qa6r1PCDzR/mO6PksK93ygC0/2OPDBqgbMjUaZPdEPsuXPjL9mXzYw== X-Received: by 2002:a17:90a:9a90:: with SMTP id e16mr2401477pjp.71.1566342408627; Tue, 20 Aug 2019 16:06:48 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id q4sm27564747pff.183.2019.08.20.16.06.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 16:06:47 -0700 (PDT) From: John Stultz To: lkml Cc: Xu YiPing , Rongrong Zou , Xinliang Liu , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg , John Stultz Subject: [PATCH v5 13/25] drm: kirin: Move ade crtc/plane help functions to driver_data Date: Tue, 20 Aug 2019 23:06:14 +0000 Message-Id: <20190820230626.23253-14-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820230626.23253-1-john.stultz@linaro.org> References: <20190820230626.23253-1-john.stultz@linaro.org> From: Xu YiPing As part of refactoring the kirin driver to better support different hardware revisions, this patch moves the crtc and plane funcs/helper_funcs to the struct kirin_drm_data. This will make it easier to add support for new devices via a new kirin_drm_data structure. Cc: Rongrong Zou Cc: Xinliang Liu Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Cc: Sam Ravnborg Acked-by: Xinliang Liu Reviewed-by: Sam Ravnborg Signed-off-by: Xu YiPing [jstultz: reworded commit message] Signed-off-by: John Stultz --- v5: checkpatch --strict whitespace fixups noticed by Sam --- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 15 ++++++++++----- drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 5 +++++ 2 files changed, 15 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index 4c6646dfc465..a1a79f372bcd 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -602,13 +602,13 @@ static int ade_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, crtc->port = port; ret = drm_crtc_init_with_planes(dev, crtc, plane, NULL, - &ade_crtc_funcs, NULL); + ade_driver_data.crtc_funcs, NULL); if (ret) { DRM_ERROR("failed to init crtc.\n"); return ret; } - drm_crtc_helper_add(crtc, &ade_crtc_helper_funcs); + drm_crtc_helper_add(crtc, ade_driver_data.crtc_helper_funcs); return 0; } @@ -917,14 +917,15 @@ static int ade_plane_init(struct drm_device *dev, struct kirin_plane *kplane, if (ret) return ret; - ret = drm_universal_plane_init(dev, &kplane->base, 1, &ade_plane_funcs, - fmts, fmts_cnt, NULL, type, NULL); + ret = drm_universal_plane_init(dev, &kplane->base, 1, + ade_driver_data.plane_funcs, fmts, + fmts_cnt, NULL, type, NULL); if (ret) { DRM_ERROR("fail to init plane, ch=%d\n", kplane->ch); return ret; } - drm_plane_helper_add(&kplane->base, &ade_plane_helper_funcs); + drm_plane_helper_add(&kplane->base, ade_driver_data.plane_helper_funcs); return 0; } @@ -1056,6 +1057,10 @@ static void ade_drm_cleanup(struct platform_device *pdev) } struct kirin_drm_data ade_driver_data = { + .crtc_helper_funcs = &ade_crtc_helper_funcs, + .crtc_funcs = &ade_crtc_funcs, + .plane_helper_funcs = &ade_plane_helper_funcs, + .plane_funcs = &ade_plane_funcs, .init = ade_drm_init, .cleanup = ade_drm_cleanup }; diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h index cd2eaa653db7..70b04e65789c 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h @@ -35,6 +35,11 @@ struct kirin_plane { /* display controller init/cleanup ops */ struct kirin_drm_data { + const struct drm_crtc_helper_funcs *crtc_helper_funcs; + const struct drm_crtc_funcs *crtc_funcs; + const struct drm_plane_helper_funcs *plane_helper_funcs; + const struct drm_plane_funcs *plane_funcs; + int (*init)(struct platform_device *pdev); void (*cleanup)(struct platform_device *pdev); }; From patchwork Tue Aug 20 23:06:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171873 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp180228ily; Tue, 20 Aug 2019 16:06:50 -0700 (PDT) X-Received: by 2002:a17:90a:bc4b:: with SMTP id t11mr2398292pjv.87.1566342410322; Tue, 20 Aug 2019 16:06:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566342410; cv=none; d=google.com; s=arc-20160816; b=p5RDq0wsziolRw3Rc02/kh4w6BcuSqyJyg6uC9SIcIa87ok+AJqNgYup1HcCfRuqs2 gvPPkgGFO2/I930Vg7r6tFNSDusZwKDzs2xDlCERSdch44fOKPEFK+radEDoTfGhE7+w gv3s2YKbOtlO5M/4SDQP3wyTq9B03FkVAGwrwKDAieYi+6xQwSIlK2EUu+h+HNyACj2k aP9WYBHc04Q9TxEIFZut49SZvRIhDE8rxLUT3HNtkp/xRoVas94LdE74m1CJ19dozZHf Fbz3ziK+aL954KqLV5nnte4FGSSOLIe70iIuV655+cfEhXBPOsOWyg35FcWZZW7DPSED qFTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YJTcSCEwUYf2TN3oxKMWFSLC+lpczIvjHDBU/TsB0vU=; b=S6NclTjAsI9ojZHtUwxCh+dc8hobq2rzWYfLLAUA4f5aqgBRT2DeUnGdOD/ifi0ieQ yyjK5qz0AZzX2dsY14izeuf42F9lvVweNV9V4anOZK2cEjRRIvFKNl8Ha6ADH5rMzvAR yqnXSGiSeiH3SvvpeCTNKVj/s0ldfYTTp8sceXVlMosrwo0CY8kZ/GHsm/7rVHPDo+58 zGr3gD0Om0q3MlGq7b/MQMN1nYD3pvn8P8Dk3u8lq5xbUitOndjEs/dB+fhaUXpZPffO 4RQiOMpEAVYhHf8lpud2AEsNNEwvtVxSclO90wU1b2pm/a7TzRl/EqiXGke8kRAHMtoU QTkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UrhNpyBE; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id i3sor1816348pjt.5.2019.08.20.16.06.50 for (Google Transport Security); Tue, 20 Aug 2019 16:06:50 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UrhNpyBE; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YJTcSCEwUYf2TN3oxKMWFSLC+lpczIvjHDBU/TsB0vU=; b=UrhNpyBEvkRLJlD1lnBou+mHZTRhB/m1n9p81ZBPRjW2VIAdtZdw5G0LZ73UkYTk7i 8yb8acrI/FprbY7QYWmu7hrInIgXo6Q1U8sBIfwpWF6Jy+T4/aDjI79bJ85+QDN/sb/z ph8+8gU5w39ZCU6HCOMXwXJJrQLlN1jMDhQhLpbJI/SR0eJW+vRZUfrV6gHu2tQKgSut Hrrs0dG0CzItmrae/ljTZN8Up+KIoi65kBrgp/exBe0g7+nLaiN8C2hjX0TAHvVDTsOu LOyowmqfp9OsBg3NCxiOwij812jVpq+HVLhQ8CDdigZTZIBOwxSUySP4EobC2wg3MqFh p/vQ== 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; bh=YJTcSCEwUYf2TN3oxKMWFSLC+lpczIvjHDBU/TsB0vU=; b=ADB5O4YssYszB+U7YTatYlccwikWABT2D6pyllXyZB1Z7oHUVnnV9NWDYz7C9qkVWm 3qRkrv/MQAAjXp6q0Ekr0q4NLpJ7ipUyvbNSt2LKoQuHKl/qtrL+XNJJDBT29sRVd2mW UEoImPIdVhraoWjv3uitNoZ2ln6WRKkZiidVXam8wxWDWJIANtusjlUKdRL1XfifU8GJ FPtLX3jfipL0DYkUhUbv+nlSrQ4psazyol/sdx/OQyMuJBl4+Y2XMEAhHwj7BCudol6Y q8+OyMlecQbVjCpibtcqlbCoP6T8WBAcJGvjecChCaSM5Ude2ag4/M0HKyo2odnQ+zoa JVbg== X-Gm-Message-State: APjAAAWZMCo1ZjaaOVuT7NRRpGRVmtto1DBUrFaaLTz/aeL9XCQXxZGX mUqDeK5WGwNLU8TaahY0Dydlux0/ X-Google-Smtp-Source: APXvYqzWSCAXbwKwbbCD16y0knYnO0K/isFTQTyNGy5wU9rDTJP8Lzw67+HLeQDhCU/xG3ibZb6+cw== X-Received: by 2002:a17:90a:b016:: with SMTP id x22mr2454039pjq.116.1566342409877; Tue, 20 Aug 2019 16:06:49 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id q4sm27564747pff.183.2019.08.20.16.06.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 16:06:49 -0700 (PDT) From: John Stultz To: lkml Cc: Xu YiPing , Rongrong Zou , Xinliang Liu , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg , John Stultz Subject: [PATCH v5 14/25] drm: kirin: Move channel formats to driver data Date: Tue, 20 Aug 2019 23:06:15 +0000 Message-Id: <20190820230626.23253-15-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820230626.23253-1-john.stultz@linaro.org> References: <20190820230626.23253-1-john.stultz@linaro.org> From: Xu YiPing As part of refactoring the kirin driver to better support different hardware revisions, this patch moves the channel format arrays into the kirin_drm_data structure. This will make it easier to add support for new devices via a new kirin_drm_data structure. Cc: Rongrong Zou Cc: Xinliang Liu Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Cc: Sam Ravnborg Acked-by: Xinliang Liu Reviewed-by: Sam Ravnborg Signed-off-by: Xu YiPing [jstultz: reworded commit message] Signed-off-by: John Stultz --- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 30 +++++-------------- .../gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 3 ++ 2 files changed, 10 insertions(+), 23 deletions(-) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index a1a79f372bcd..0489b6378e01 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -76,7 +76,7 @@ static const struct kirin_format ade_formats[] = { { DRM_FORMAT_ABGR8888, ADE_ABGR_8888 }, }; -static const u32 channel_formats1[] = { +static const u32 channel_formats[] = { /* channel 1,2,3,4 */ DRM_FORMAT_RGB565, DRM_FORMAT_BGR565, DRM_FORMAT_RGB888, DRM_FORMAT_BGR888, DRM_FORMAT_XRGB8888, DRM_FORMAT_XBGR8888, @@ -84,19 +84,6 @@ static const u32 channel_formats1[] = { DRM_FORMAT_ABGR8888 }; -u32 ade_get_channel_formats(u8 ch, const u32 **formats) -{ - switch (ch) { - case ADE_CH1: - *formats = channel_formats1; - return ARRAY_SIZE(channel_formats1); - default: - DRM_ERROR("no this channel %d\n", ch); - *formats = NULL; - return 0; - } -} - /* convert from fourcc format to ade format */ static u32 ade_get_format(u32 pixel_format) { @@ -908,18 +895,13 @@ static struct drm_plane_funcs ade_plane_funcs = { static int ade_plane_init(struct drm_device *dev, struct kirin_plane *kplane, enum drm_plane_type type) { - const u32 *fmts; - u32 fmts_cnt; int ret = 0; - /* get properties */ - fmts_cnt = ade_get_channel_formats(kplane->ch, &fmts); - if (ret) - return ret; - ret = drm_universal_plane_init(dev, &kplane->base, 1, - ade_driver_data.plane_funcs, fmts, - fmts_cnt, NULL, type, NULL); + ade_driver_data.plane_funcs, + ade_driver_data.channel_formats, + ade_driver_data.channel_formats_cnt, + NULL, type, NULL); if (ret) { DRM_ERROR("fail to init plane, ch=%d\n", kplane->ch); return ret; @@ -1057,6 +1039,8 @@ static void ade_drm_cleanup(struct platform_device *pdev) } struct kirin_drm_data ade_driver_data = { + .channel_formats = channel_formats, + .channel_formats_cnt = ARRAY_SIZE(channel_formats), .crtc_helper_funcs = &ade_crtc_helper_funcs, .crtc_funcs = &ade_crtc_funcs, .plane_helper_funcs = &ade_plane_helper_funcs, diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h index 70b04e65789c..66916502a9e6 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h @@ -35,6 +35,9 @@ struct kirin_plane { /* display controller init/cleanup ops */ struct kirin_drm_data { + const u32 *channel_formats; + u32 channel_formats_cnt; + const struct drm_crtc_helper_funcs *crtc_helper_funcs; const struct drm_crtc_funcs *crtc_funcs; const struct drm_plane_helper_funcs *plane_helper_funcs; From patchwork Tue Aug 20 23:06:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171874 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp180262ily; Tue, 20 Aug 2019 16:06:51 -0700 (PDT) X-Received: by 2002:a63:24a:: with SMTP id 71mr26350432pgc.273.1566342411814; Tue, 20 Aug 2019 16:06:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566342411; cv=none; d=google.com; s=arc-20160816; b=NTmg/dEjbciQDchfVQq9lMFzSKkb2vPHpSmSE4u16bC6XOueGL3SdR6F5SXD242yYJ 5aWpZhmeOqo3Mi+uw/dsSrYEVZ+6xBKvhGvncx7IIN7DqaMAcq4zbSQi1pQglhuJBrfa MtHFSn/DSyN5JCkJ1rCRr2xoxx/nhmxWzRIGrf4BpG93IeZvIbCkgNWYEEOKdF92nNP7 bczhbtgjwtGl3FwGmZPnX+mTLCR/7EWpkEmnpCXEjkhYYP3VWDH7FwQhX25qauYX+v+w ig1omYQ27cVWHqN1HQMRPV30hKiWGtIvCc7AiU6I96V7zOU2W9TLlci8NB+lXhmgaQLh rIqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NvRBTkEpcrR5Rep8edui09Pbrs4gwjsFcJ1vUHe92C8=; b=i1W4CwxY1wQe4ej6KmLQZUV/1rV3Idm0cpYK+uPVqSQQI/B2mRwYJ+LpVaEaExsqNR lHYjKJLdLVy2EBw3Fnh3+MqdKl2w9vSGr8et4/2Lbw5zwSaSgFF6NrUiC3DSrxmt+mSz C59DwfErZHhXZ9U6xCWNnrIBagp91VkxLmRsbULATtiVOkUfR4bHoV6+OZhZhDE1gUUo bPs7Yb/FmzwNgm6VWYKg9GBeFoFMkpyB+9kFae2kB1zvA9YHtz425dbdGqpZMMKqSx2u 57iNOV8lGfgT7EKdzw5sKBJA6CoUG2ZahgHjk4D1hlCmGFffgPPLn3Q5BoRS1CFSA3Vn R7Hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SpmUoFqT; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id q1sor6781586pll.52.2019.08.20.16.06.51 for (Google Transport Security); Tue, 20 Aug 2019 16:06:51 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SpmUoFqT; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NvRBTkEpcrR5Rep8edui09Pbrs4gwjsFcJ1vUHe92C8=; b=SpmUoFqTQ+QJ0g9hL7qgwe495wxUfIF5aJWDRv8mSGtUIbWZzEoSG+rlz9UkFpecSy /0C7WUsQ44Y05xaq68bMfODCQWQ124ezsD9PsPxx8LQvOKarjb1trxJuayJiEJG4Ds8X eVCL3EiK8jPXMqsNg1hln1fi116iayO8WR21flpsPW9o9Dvb9h4kX6d1OMYPbxjt1Jb3 PvD30Eb2rT0BAkR2GNDkO7kuW7tdX2G3epYPLwPZ2+TY9gmuvxa8xO/VrzdyvOVN4Bxm 3LlBwM03+GBOB/X/kGUx4hvq/zCruqoIM3dTxfX+4MT9ka2Q3BjWShFP8pE4+WB5JGpv X47Q== 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; bh=NvRBTkEpcrR5Rep8edui09Pbrs4gwjsFcJ1vUHe92C8=; b=bcWWdj8DYPeysZWqBzzOSTOoTinGPvzASVZzOhKT7DW7D4wdAMTSXphc65wgiSeXm+ zePZBrpopfAv9SMDFkTSn2+k91reEjJl5TDr9qf/QJnHytMexNv2GRbzNfQo0h38P4Rq slD2rIa+Du58kI4CWh14w8odc9ND6Dua4cAGOCPFPpOtdmFFqG5gqC8PiAhL8ZYO1x/+ fGTIGCgmGYQgd/kR4Wp1MVVwB3XV3TuL1wZ/fLuJXvk1E/AD8hv01Cptk+rztPbYcTP2 9cgjIANrD2Jg1uAalx0hB7cKOM/UOZfEilPKLMK5VECbAWsGHigx+2jk/B7Ujsoabgq1 EobA== X-Gm-Message-State: APjAAAWosrm+8gTSiF2hUsEH9raq6jJLw+v8fTVZS+adpUHH1hhWJJIy pmXv9LlJ7PrzddatGfavOQrNPuX1 X-Google-Smtp-Source: APXvYqxk1+RpZrPxlzUTPywKtSA/GrnBztJYlBYhotscSB7kHX9LZWOXAZRnLh+wBMuGbZ8bR4CLNw== X-Received: by 2002:a17:902:41:: with SMTP id 59mr8508124pla.268.1566342411457; Tue, 20 Aug 2019 16:06:51 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id q4sm27564747pff.183.2019.08.20.16.06.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 16:06:50 -0700 (PDT) From: John Stultz To: lkml Cc: Xu YiPing , Rongrong Zou , Xinliang Liu , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg , John Stultz Subject: [PATCH v5 15/25] drm: kirin: Move mode config function to driver_data Date: Tue, 20 Aug 2019 23:06:16 +0000 Message-Id: <20190820230626.23253-16-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820230626.23253-1-john.stultz@linaro.org> References: <20190820230626.23253-1-john.stultz@linaro.org> From: Xu YiPing As part of refactoring the kirin driver to better support different hardware revisions, this patch moves the mode config initialization values into the kirin_drm_data structure. This will make it easier to add support for new devices via a new kirin_drm_data structure. Cc: Rongrong Zou Cc: Xinliang Liu Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Cc: Sam Ravnborg Acked-by: Xinliang Liu Reviewed-by: Sam Ravnborg Signed-off-by: Xu YiPing Signed-off-by: John Stultz --- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 10 ++++++++++ drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 8 +------- drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index 0489b6378e01..94d74c467a81 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "kirin_drm_drv.h" #include "kirin_ade_reg.h" @@ -1038,6 +1039,13 @@ static void ade_drm_cleanup(struct platform_device *pdev) { } +static const struct drm_mode_config_funcs ade_mode_config_funcs = { + .fb_create = drm_gem_fb_create, + .atomic_check = drm_atomic_helper_check, + .atomic_commit = drm_atomic_helper_commit, + +}; + struct kirin_drm_data ade_driver_data = { .channel_formats = channel_formats, .channel_formats_cnt = ARRAY_SIZE(channel_formats), @@ -1045,6 +1053,8 @@ struct kirin_drm_data ade_driver_data = { .crtc_funcs = &ade_crtc_funcs, .plane_helper_funcs = &ade_plane_helper_funcs, .plane_funcs = &ade_plane_funcs, + .mode_config_funcs = &ade_mode_config_funcs, + .init = ade_drm_init, .cleanup = ade_drm_cleanup }; diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c index 3d22f944a840..25191824b64e 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c @@ -40,12 +40,6 @@ static int kirin_drm_kms_cleanup(struct drm_device *dev) return 0; } -static const struct drm_mode_config_funcs kirin_drm_mode_config_funcs = { - .fb_create = drm_gem_fb_create, - .atomic_check = drm_atomic_helper_check, - .atomic_commit = drm_atomic_helper_commit, -}; - static void kirin_drm_mode_config_init(struct drm_device *dev) { dev->mode_config.min_width = 0; @@ -54,7 +48,7 @@ static void kirin_drm_mode_config_init(struct drm_device *dev) dev->mode_config.max_width = 2048; dev->mode_config.max_height = 2048; - dev->mode_config.funcs = &kirin_drm_mode_config_funcs; + dev->mode_config.funcs = driver_data->mode_config_funcs; } static int kirin_drm_kms_init(struct drm_device *dev) diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h index 66916502a9e6..ce9ddccc67a8 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h @@ -42,7 +42,7 @@ struct kirin_drm_data { const struct drm_crtc_funcs *crtc_funcs; const struct drm_plane_helper_funcs *plane_helper_funcs; const struct drm_plane_funcs *plane_funcs; - + const struct drm_mode_config_funcs *mode_config_funcs; int (*init)(struct platform_device *pdev); void (*cleanup)(struct platform_device *pdev); }; From patchwork Tue Aug 20 23:06:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171875 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp180297ily; Tue, 20 Aug 2019 16:06:53 -0700 (PDT) X-Received: by 2002:a17:902:28c9:: with SMTP id f67mr31112298plb.19.1566342413888; Tue, 20 Aug 2019 16:06:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566342413; cv=none; d=google.com; s=arc-20160816; b=iSfvorEts9SaD231Q6Dv84jeFsIxoXwoBgVfF+7UNjt+t/EBSR2jct6vJFwYHUrl/C VI15Ertkyn6h/Vom6dC6TGIxlcscjNqr+6vEW5DY0ikYF6NgFZMEN7vFJzXHbG3XIF5Q hr+A8QZ9iTTU/dkd1Nmtysn4DprVaZCXpVSylW0dpI9j9m8yGaddROBBEGF83sd/WCDz anVAF1lAEuqAqcuvU1R6Wsrj7wz9uISHsu8IWin1TAYZ6aD1nCEPxzFV5766BZqFsFNG Qs3wylsYPwwbMGwpxA21/6rZ9ru+9eZrHuphddQwj+HHr7LPCWqZhnQywmOLZrIucGzD oTqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9wPcbIoBPT/8L74pQuiXRIt1kMA2rrNdraftIyGCKRU=; b=O9Xx/LGb6uO+5hr6Wi4zgUosZCjK786vTLGopEYpGLezhouZc3GIH07BMfVBlo7xQy OE7xkqEiM+DQlx/GXqQNVqVlnnAz277K/CXkUa+72xnlN6D9cgAybEDVjVi2xOE3m1Np oCTHkhCmpciaiLRy3FZsfMY4yoPtJ2AFa72CGN4uVT+NB0wgrjlu61a6p+nhgXArnfrV CW32WSh8+Uc4/ZUp+zJDxk8EeFx8DttbwLzhzSqidnprhAsBuGKDMBt70nyqE1StXzFX a6GKvyLpio6fKMNsGw7sWSJfsYy9wIOPQsnTCBS+gT6dyrbcAkgLoaO5U3/y5GVUU8Y1 99wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YIPSVYup; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id bt15sor1777756pjb.26.2019.08.20.16.06.53 for (Google Transport Security); Tue, 20 Aug 2019 16:06:53 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YIPSVYup; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9wPcbIoBPT/8L74pQuiXRIt1kMA2rrNdraftIyGCKRU=; b=YIPSVYupeR5GBL+4iP8KgubrHAAyoTX6x00LkJOHx1jvD0oh7M/xQwqeVwTMOWIXSl dZcTZfD+t1RJWSjCmcaq32LJsCbNAz/AqoyzNmpk+vyQiRgfQkMZNLDg2cuk5CE06kYu gYaP/UrYI8prOQAmd6gyd4g9yr2xhR+zAdWTUb9nVzmOmDJ0LkolQ+a5a/HMfu2ZK4le LLbj8fT2Fqx18tTcdS7M6kKWkE0+PH7N5+7UP7ckP0124Fwr2yfo3HnUIcxcSbkCAxo0 /ZdKrXBTUkj5c01ATSf05PQAQ4u3sZbsirGuxw3zR8kDDFrChpxxLeJflZz9FcGzERAy yFrQ== 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; bh=9wPcbIoBPT/8L74pQuiXRIt1kMA2rrNdraftIyGCKRU=; b=Yu0g57jh1l8Kz35dCXbSeOwcFTdAfklcGM36QwrSJ5Suk3ELRbOGgdctjAi9Rzv7ZX RU/7Uk/HoqZzKXhW1cFGGqbzT/+IGUMvE1MyZInCofmiK9i23/cNBP41d10QxnhFHpYR N0hrmZnCx1NuIY9EUrHkcP764odP/F3ZBcG1TPF8sKQUrf8OpD41H2Pvjow+ViGGOkOu Wyo5gv5pwC9SFU32jFitWCCO1ffJF7OvWOB1vOdomwN3qiXntacRdCuXxHXykcmCrd+y QaJDmNMKRcfDMZWCjClgKKznBKXHtntaNTTIgbtUjBJYgwDLph6+Y7CPRS+4won4kq5X xRGQ== X-Gm-Message-State: APjAAAUWItiGE2loDR7hXgd3YWsA1N731eaJRcQB0OeemuceQZuBTll2 Bx3DOe42POMwDwvQtATUATrIEicm X-Google-Smtp-Source: APXvYqwA2vG86Xa3XTeAfvmUNiasYaGiBQjfDhnTGPdGcYyITx4aN+Pjv6qz3iMqskAQpDZRDQcpYQ== X-Received: by 2002:a17:90a:6581:: with SMTP id k1mr2350909pjj.47.1566342413486; Tue, 20 Aug 2019 16:06:53 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id q4sm27564747pff.183.2019.08.20.16.06.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 16:06:52 -0700 (PDT) From: John Stultz To: lkml Cc: Xu YiPing , Rongrong Zou , Xinliang Liu , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg , John Stultz Subject: [PATCH v5 16/25] drm: kirin: Move plane number and primay plane in driver data Date: Tue, 20 Aug 2019 23:06:17 +0000 Message-Id: <20190820230626.23253-17-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820230626.23253-1-john.stultz@linaro.org> References: <20190820230626.23253-1-john.stultz@linaro.org> From: Xu YiPing As part of refactoring the kirin driver to better support different hardware revisions, this patch moves the number of planes and the primary plane value to the kirin_drm_data structure This will make it easier to add support for new devices via a new kirin_drm_data structure. Cc: Rongrong Zou Cc: Xinliang Liu Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Cc: Sam Ravnborg Acked-by: Xinliang Liu Reviewed-by: Sam Ravnborg Signed-off-by: Xu YiPing Signed-off-by: John Stultz --- v5: checkpatch --strict whitespace fixups noticed by Sam --- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 21 ++++++++++++------- .../gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 2 ++ 2 files changed, 15 insertions(+), 8 deletions(-) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index 94d74c467a81..a74b2623dbbb 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -35,7 +35,6 @@ #include "kirin_drm_drv.h" #include "kirin_ade_reg.h" -#define PRIMARY_CH ADE_CH1 /* primary plane */ #define OUT_OVLY ADE_OVLY2 /* output overlay compositor */ #define ADE_DEBUG 1 @@ -991,7 +990,7 @@ static int ade_drm_init(struct platform_device *pdev) struct kirin_plane *kplane; enum drm_plane_type type; int ret; - int i; + u32 ch; ade = devm_kzalloc(dev->dev, sizeof(*ade), GFP_KERNEL); if (!ade) { @@ -1015,12 +1014,15 @@ static int ade_drm_init(struct platform_device *pdev) * TODO: Now only support primary plane, overlay planes * need to do. */ - for (i = 0; i < ADE_CH_NUM; i++) { - kplane = &ade->planes[i]; - kplane->ch = i; + for (ch = 0; ch < ade_driver_data.num_planes; ch++) { + kplane = &ade->planes[ch]; + kplane->ch = ch; kplane->hw_ctx = ctx; - type = i == PRIMARY_CH ? DRM_PLANE_TYPE_PRIMARY : - DRM_PLANE_TYPE_OVERLAY; + + if (ch == ade_driver_data.prim_plane) + type = DRM_PLANE_TYPE_PRIMARY; + else + type = DRM_PLANE_TYPE_OVERLAY; ret = ade_plane_init(dev, kplane, type); if (ret) @@ -1028,7 +1030,8 @@ static int ade_drm_init(struct platform_device *pdev) } /* crtc init */ - ret = ade_crtc_init(dev, &kcrtc->base, &ade->planes[PRIMARY_CH].base); + ret = ade_crtc_init(dev, &kcrtc->base, + &ade->planes[ade_driver_data.prim_plane].base); if (ret) return ret; @@ -1047,6 +1050,8 @@ static const struct drm_mode_config_funcs ade_mode_config_funcs = { }; struct kirin_drm_data ade_driver_data = { + .num_planes = ADE_CH_NUM, + .prim_plane = ADE_CH1, .channel_formats = channel_formats, .channel_formats_cnt = ARRAY_SIZE(channel_formats), .crtc_helper_funcs = &ade_crtc_helper_funcs, diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h index ce9ddccc67a8..2b660df60293 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h @@ -37,6 +37,8 @@ struct kirin_plane { struct kirin_drm_data { const u32 *channel_formats; u32 channel_formats_cnt; + u32 num_planes; + u32 prim_plane; const struct drm_crtc_helper_funcs *crtc_helper_funcs; const struct drm_crtc_funcs *crtc_funcs; From patchwork Tue Aug 20 23:06:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171876 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp180334ily; Tue, 20 Aug 2019 16:06:55 -0700 (PDT) X-Received: by 2002:a65:6281:: with SMTP id f1mr25234891pgv.400.1566342415663; Tue, 20 Aug 2019 16:06:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566342415; cv=none; d=google.com; s=arc-20160816; b=iM32+j6DMiPbegz44Fwj8LKgugRUENxXgA3aF3+q+JtpTzQ+ypK3iYnXypjqf5mWCa B3+juLCKDv9E51sL7Ld3MCd9U6/NUPZa3bQGa1CW0gNf6e5mZA/kcylHvLhzGKQsAbpd dXa2RMyFnNT0bBkKuTNRc1s0MJDtQJYnoUiHgPd2DFmy2sfl58+DFAl2C/ZsrdujHTgX qGo3zV7GlX9IdsdXs6LFPah3HXudU2JZk0BaSkyGMhITeVuxp3z8tM+0jtZ18Pw2uv3x OVOyFq7+eqCZwQ4YuPbmH0hnC9e2iOBBAbR5ac0jwkWFxVQboywCgrC1cHAWRNPsYcXI Evng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Nc0HKvLqdfxQ4XGBrfjKvfOMJNdfixijHmLsJLYaeJM=; b=I0YVXhRiKL/jJHyzT29PyEOVvjBARnvcF9UgTVLyPF1xPO/YmSr2cEwrCXZI+L761B hHuezstK3mDGZKaHvgZj4idF77tQX09E7FJIQ9J8r23EYUBkWqxGdZ0jkEOOZlXL98DB /uc08n5IJ1sXGf91YB6BBsbu8ru43KylozLUczzoLzqy9W8AxhPHX2tlrAUCfvATgJKS jjw2ujRMQM1qEykOQdiwSuj53M40kBG2wmqDFB3k9iDns7JZHO5InW4PcSrX2EIrjoSC LG8BrhKkHyg2pfe9v1rJIjA6RkQTsEZyf1oOKOMeZcPmxv5f7oLqf/Gc/mdiigWId36Z UPOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GJQNBGk5; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id 1sor5541186pfz.26.2019.08.20.16.06.55 for (Google Transport Security); Tue, 20 Aug 2019 16:06:55 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GJQNBGk5; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Nc0HKvLqdfxQ4XGBrfjKvfOMJNdfixijHmLsJLYaeJM=; b=GJQNBGk5r/2vcoEMF2xMvysOdEQINWPzyB68OUdnEgdsP+PFQgWLf5Gk+wnqCbVE3k MHW9uNhKC7xDRdBUuUzVDyuppOCKAyTs6CRisMkdUpzHFAuqEWKBVDHtGCQ8HUDezlrm 5jNCCeZINejwuo60CoS7OfL08l3Ip/8ixVny4TedC7prbf+I6rV2ycGv1kNC5akcGW/f zJUOz4A7khwYlnW4oHgw/iOjwONpuAcsAxi3clf0DSahsstYfsa+zMdU6XE9zKWSmv8g Rn6ljFFKO6eCX3Fh0fQZ//J1FNyRJaWvKVWfgYX2522ZXI197xHpgSjgFi/ZKJImjSOM H7fg== 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; bh=Nc0HKvLqdfxQ4XGBrfjKvfOMJNdfixijHmLsJLYaeJM=; b=n6lggXuEv2jYCEEAB5EV8rp07TiGQ5ajmPo3oZghN+VLKiLsEPbS/tPWaqszisSRyh /VUhXdwtfEHi4ZONiZVMWOuFo8jXDu8VGp9vS8EuNzc/b9arRuj3+zXPHqcASGk8AcMH K1ibqh7GMiBBpFXLx8w9VJll1Nc45dw9KiDX47ViOpEQMc0E0OZI3yzqROiiaqH1jZqE Fv/XmgGqDop+4EuHhItL7arIVSVHVY7LnMqdYYdKUXbmbduXyMeF3igYDP48xAzW0IyM AMTo2mgNuHZX5tDmf/BZByUdsBJwC2OGUbrembEiuMGMecr6nZWQ5cgMf6uG+7Ybs6M0 LUrw== X-Gm-Message-State: APjAAAVimmqG6ZwK1GZH1uIvaHAONEwUIAYhcgdZC8adZPPguQWX+F8R NQjIkAPSscT/yXEzanToxP4tkLMHZbCvjA== X-Google-Smtp-Source: APXvYqyycOrj5QO/qCGc2tAh0Oxqq8tIKtAZe2eG52cV3l89piP4mv+qYGEtbuNk91J/oP8Yz4OZrg== X-Received: by 2002:a63:121b:: with SMTP id h27mr451417pgl.335.1566342415194; Tue, 20 Aug 2019 16:06:55 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id q4sm27564747pff.183.2019.08.20.16.06.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 16:06:53 -0700 (PDT) From: John Stultz To: lkml Cc: Xu YiPing , Rongrong Zou , Xinliang Liu , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg , John Stultz Subject: [PATCH v5 17/25] drm: kirin: Move config max_width and max_height to driver data Date: Tue, 20 Aug 2019 23:06:18 +0000 Message-Id: <20190820230626.23253-18-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820230626.23253-1-john.stultz@linaro.org> References: <20190820230626.23253-1-john.stultz@linaro.org> From: Xu YiPing As part of refactoring the kirin driver to better support different hardware revisions, this patch moves the max_width and max_height values used in kirin_drm_mode_config_inita to hardware specific driver data. This will make it easier to add support for new devices via a new kirin_drm_data structure. Cc: Rongrong Zou Cc: Xinliang Liu Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Cc: Sam Ravnborg Acked-by: Xinliang Liu Reviewed-by: Sam Ravnborg Signed-off-by: Xu YiPing [jstultz: reworded commit message] Signed-off-by: John Stultz --- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 2 ++ drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 17 +++++------------ drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 2 ++ 3 files changed, 9 insertions(+), 12 deletions(-) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index a74b2623dbbb..a4cf122375ea 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -1054,6 +1054,8 @@ struct kirin_drm_data ade_driver_data = { .prim_plane = ADE_CH1, .channel_formats = channel_formats, .channel_formats_cnt = ARRAY_SIZE(channel_formats), + .config_max_width = 2048, + .config_max_height = 2048, .crtc_helper_funcs = &ade_crtc_helper_funcs, .crtc_funcs = &ade_crtc_funcs, .plane_helper_funcs = &ade_plane_helper_funcs, diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c index 25191824b64e..2ab32c2e3f95 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c @@ -40,17 +40,6 @@ static int kirin_drm_kms_cleanup(struct drm_device *dev) return 0; } -static void kirin_drm_mode_config_init(struct drm_device *dev) -{ - dev->mode_config.min_width = 0; - dev->mode_config.min_height = 0; - - dev->mode_config.max_width = 2048; - dev->mode_config.max_height = 2048; - - dev->mode_config.funcs = driver_data->mode_config_funcs; -} - static int kirin_drm_kms_init(struct drm_device *dev) { int ret; @@ -59,7 +48,11 @@ static int kirin_drm_kms_init(struct drm_device *dev) /* dev->mode_config initialization */ drm_mode_config_init(dev); - kirin_drm_mode_config_init(dev); + dev->mode_config.min_width = 0; + dev->mode_config.min_height = 0; + dev->mode_config.max_width = driver_data->config_max_width; + dev->mode_config.max_height = driver_data->config_max_width; + dev->mode_config.funcs = driver_data->mode_config_funcs; /* display controller init */ ret = driver_data->init(to_platform_device(dev->dev)); diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h index 2b660df60293..43be65f82a03 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h @@ -37,6 +37,8 @@ struct kirin_plane { struct kirin_drm_data { const u32 *channel_formats; u32 channel_formats_cnt; + int config_max_width; + int config_max_height; u32 num_planes; u32 prim_plane; From patchwork Tue Aug 20 23:06:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171884 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp181978ily; Tue, 20 Aug 2019 16:08:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqw8kvgfMvy+snS0P2865ZKr+qIC1azA+YoI3IkYRb0nClGpypcEw6CUefI3i2+4I54s/bYz X-Received: by 2002:a62:e901:: with SMTP id j1mr33137097pfh.189.1566342423264; Tue, 20 Aug 2019 16:07:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566342423; cv=none; d=google.com; s=arc-20160816; b=YBpCq7DTEGxWr5812OHvs4KsYrvK7APyTb45Y2iqf5RcTNiAxohHMQyYN9zfrTe/z8 wVRLQsrEXd1VsvmJgGT/pCPBMpghTCppx6gRVy9iNkrgd+3KCXgF2gSGiX5xIGuSNKhU smGVS64w/N8gUkzeys8+NkF6h5f4zwkziXrHEfENECNkmiFaeoE8hruRiKGJHd3E0r54 n+8yIws6vjhHAvmChPjU8Wn2SRrnE8C+plE87tokdb7GtvdVos0RTvlRBOZ7uoKJOi+j 1i9jtlasKupQYP8EcchtL9xJ7CGo/b6Y9wnmMNsefd+dotxefcsGMXvyGXFl48ZUcglX fPKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=wvJMWqAUNb5jXlSdlJ418hl6Ngg4JxX27ryR36PDJ9Y=; b=T3m9UWbWS/WbZyvqWvReMNT6gNSVdTKfPvDKK0hJAedHZWZzg7pkOWzYFbj9nRpF0o PYi1OaOciBT8bGeXJA+zJAITFPz2mPjRIwt1UKv7tF2CuuYyhHWy4xjRn8YqEhYyuwz9 vYltYLMpByClyz+16u/rpJsU4wta8qbUO3IeXtNel8VlEe7e17E7QsbXqKmUGtb5tqlF nUdwNiE3q92z4jzxTZlMOmbmSyH1gcfMe4us9eGh9ooHO3fjVkH+nWjLekGhvg2vXxDw njZblLaO6+KYlp9ycPWXLu1HgUFMXQ7u3n6jDC9VZgsbaCW5kA2ojRoEKan0rBNfxGhs A0YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H0v6vChM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r17si13108242pgg.155.2019.08.20.16.07.03; Tue, 20 Aug 2019 16:07:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H0v6vChM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726729AbfHTXHC (ORCPT + 28 others); Tue, 20 Aug 2019 19:07:02 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:45842 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726669AbfHTXG6 (ORCPT ); Tue, 20 Aug 2019 19:06:58 -0400 Received: by mail-pg1-f194.google.com with SMTP id o13so139457pgp.12 for ; Tue, 20 Aug 2019 16:06:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wvJMWqAUNb5jXlSdlJ418hl6Ngg4JxX27ryR36PDJ9Y=; b=H0v6vChMxN+/FQzorsOoz4YIWOLQ1cFQ7JP50K8oPSWmmhzG9FFy206mcOK0mlMk2w 3sydKbEEN3ma79faN7FtUyVuSdCXDCIgCoMVOy7ZOKdM1XtKvVVi+/mBvK7qqDIf6LuJ HgdyhD42cfDzWIWlUBBTSW79gVlwO9Uj2WGimde4H6ILbpTJTza3gMO9snInbsTEYa65 xz1tvmxD3dKuTzliZsxSXJPWOLa8I7qx/65zuUviK5nfO7Y+OSX46svH58e3IaJGlJyr qkyVzY8uQ/i10HR+M69rPmzi90jnUSx/s8toZfhfJw2Vbp9ooXFcXyswSbeZJTleQ5z7 PuQA== 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; bh=wvJMWqAUNb5jXlSdlJ418hl6Ngg4JxX27ryR36PDJ9Y=; b=S0BEKwyhA+OdiH6A/b8wRI1B94ATTIBCklFtYIxb7F3sRXzleMGxVhOUqh06PsEsy4 8Paoj9pmtKrskfgkhk1ZQ/XKSiRT1PFhU1reZZ2uNXmBgISrSdxXt6UJdi+WisH52X5Q H7cH1pAzx4K5BnSGZon4SMMwLmpFDEm6LNLhOrlY3syIpyJpDPiWBxlcAoKU1HgIimlT jbRzwwTri8tXnIvwRisQsAjRvaQw6s0ydMsOWFqHhlmvZqBcmorjUSQavLrqjqbHcMnT 6+pVwAhHFXPkTaFRm+p3RWxLpc6S+Q/g97CKh2r2HnT6cxQGuI5L6imLbi5Fp0uivSA+ ++eA== X-Gm-Message-State: APjAAAWvW1WqbwwaOLoZI7J7/rZ/n1ykn8YzRAqTwvOn0fW687iuEj19 EPMFilllZkKoyOXMMEr1OOzF0o3pb34= X-Received: by 2002:a63:fa11:: with SMTP id y17mr26971937pgh.267.1566342417078; Tue, 20 Aug 2019 16:06:57 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id q4sm27564747pff.183.2019.08.20.16.06.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 16:06:56 -0700 (PDT) From: John Stultz To: lkml Cc: Xu YiPing , Rongrong Zou , Xinliang Liu , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg , John Stultz Subject: [PATCH v5 18/25] drm: kirin: Move drm driver to driver data Date: Tue, 20 Aug 2019 23:06:19 +0000 Message-Id: <20190820230626.23253-19-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820230626.23253-1-john.stultz@linaro.org> References: <20190820230626.23253-1-john.stultz@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xu YiPing As part of refactoring the kirin driver to better support different hardware revisions, this patch moves the drm_driver structure to be under device specific driver data. This will allow us to more easily add support for kirin960 hardware with later patches. Cc: Rongrong Zou Cc: Xinliang Liu Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Cc: Sam Ravnborg Acked-by: Xinliang Liu Reviewed-by: Sam Ravnborg Signed-off-by: Xu YiPing [jstultz: Reworded commit message] Signed-off-by: John Stultz --- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 24 +++++++++++++ .../gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 35 +------------------ .../gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 1 + 3 files changed, 26 insertions(+), 34 deletions(-) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index a4cf122375ea..21c5d457a97d 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -1049,6 +1049,29 @@ static const struct drm_mode_config_funcs ade_mode_config_funcs = { }; +DEFINE_DRM_GEM_CMA_FOPS(ade_fops); + +static struct drm_driver ade_driver = { + .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC, + .fops = &ade_fops, + .gem_free_object_unlocked = drm_gem_cma_free_object, + .gem_vm_ops = &drm_gem_cma_vm_ops, + .dumb_create = drm_gem_cma_dumb_create_internal, + .prime_handle_to_fd = drm_gem_prime_handle_to_fd, + .prime_fd_to_handle = drm_gem_prime_fd_to_handle, + .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table, + .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table, + .gem_prime_vmap = drm_gem_cma_prime_vmap, + .gem_prime_vunmap = drm_gem_cma_prime_vunmap, + .gem_prime_mmap = drm_gem_cma_prime_mmap, + + .name = "kirin", + .desc = "Hisilicon Kirin620 SoC DRM Driver", + .date = "20150718", + .major = 1, + .minor = 0, +}; + struct kirin_drm_data ade_driver_data = { .num_planes = ADE_CH_NUM, .prim_plane = ADE_CH1, @@ -1056,6 +1079,7 @@ struct kirin_drm_data ade_driver_data = { .channel_formats_cnt = ARRAY_SIZE(channel_formats), .config_max_width = 2048, .config_max_height = 2048, + .driver = &ade_driver, .crtc_helper_funcs = &ade_crtc_helper_funcs, .crtc_funcs = &ade_crtc_funcs, .plane_helper_funcs = &ade_plane_helper_funcs, diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c index 2ab32c2e3f95..c9faaa848cc6 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c @@ -93,38 +93,6 @@ static int kirin_drm_kms_init(struct drm_device *dev) return ret; } -DEFINE_DRM_GEM_CMA_FOPS(kirin_drm_fops); - -static int kirin_gem_cma_dumb_create(struct drm_file *file, - struct drm_device *dev, - struct drm_mode_create_dumb *args) -{ - return drm_gem_cma_dumb_create_internal(file, dev, args); -} - -static struct drm_driver kirin_drm_driver = { - .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC, - .fops = &kirin_drm_fops, - - .gem_free_object_unlocked = drm_gem_cma_free_object, - .gem_vm_ops = &drm_gem_cma_vm_ops, - .dumb_create = kirin_gem_cma_dumb_create, - - .prime_handle_to_fd = drm_gem_prime_handle_to_fd, - .prime_fd_to_handle = drm_gem_prime_fd_to_handle, - .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table, - .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table, - .gem_prime_vmap = drm_gem_cma_prime_vmap, - .gem_prime_vunmap = drm_gem_cma_prime_vunmap, - .gem_prime_mmap = drm_gem_cma_prime_mmap, - - .name = "kirin", - .desc = "Hisilicon Kirin SoCs' DRM Driver", - .date = "20150718", - .major = 1, - .minor = 0, -}; - static int compare_of(struct device *dev, void *data) { return dev->of_node == data; @@ -132,11 +100,10 @@ static int compare_of(struct device *dev, void *data) static int kirin_drm_bind(struct device *dev) { - struct drm_driver *driver = &kirin_drm_driver; struct drm_device *drm_dev; int ret; - drm_dev = drm_dev_alloc(driver, dev); + drm_dev = drm_dev_alloc(driver_data->driver, dev); if (IS_ERR(drm_dev)) return PTR_ERR(drm_dev); diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h index 43be65f82a03..fdbfc4a90f22 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h @@ -42,6 +42,7 @@ struct kirin_drm_data { u32 num_planes; u32 prim_plane; + struct drm_driver *driver; const struct drm_crtc_helper_funcs *crtc_helper_funcs; const struct drm_crtc_funcs *crtc_funcs; const struct drm_plane_helper_funcs *plane_helper_funcs; From patchwork Tue Aug 20 23:06:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171877 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp180399ily; Tue, 20 Aug 2019 16:06:59 -0700 (PDT) X-Received: by 2002:aa7:83c7:: with SMTP id j7mr33470537pfn.59.1566342419222; Tue, 20 Aug 2019 16:06:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566342419; cv=none; d=google.com; s=arc-20160816; b=jfvY2+3QHeMZa18eSZn5VFvLz+gTbD7J8ynfacueb05M4bSOG0sJpmu5FKlB3CdsSh FW9SginldcIuxMX83nCkgr37JiZL3GSweRpYXX7KZ7OfIsubR6wn9qGrps/HCyWuVgIw E2OEt5yr5bwktXhTmKj+HeZW+W9sBYd8EjjISRPaUxiMKRSI+RQNpCcgg7M+j7h3wa2v 0gc2l7zOX+fuvkg5hMOGfjJaCmXVJdDCP8MFDnYaBllvaKPVjkVdpoKpMl1YftSm7Rqb IOCAuQfV9nK6TvT5ANmaVotYSlGdhK881vcquNYLZDhQmsyJ7S9PwxDwj7L0OpL6kQok NJ8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=snb+417mkIMijis5gqdevRgXi5CVEc/HJIJZWNwpKg4=; b=AR0cJYd+nqQT6K67IWerMxBE5xhDRh4Ce3cE09ouupywJfzKjY10/+GltfiraSUFzr zBd9TnJs83y/f5nqFupumXgpKGqm0C5Ygb29OaJ2PWA8bUgFPQJq01E6zXAUzemLZMPJ zYK3Ij+89PqgXfuPYSWMZfIMTtjWiz7pVtIdqgYtX5JqZF+CGce15QzITgbF3Z3fSX1C jjwZHZTJm/ahoTj23Nxdj5R55XFaHpSzpkuydcUJtnt+4A9y379Bxqp+nuk/LltMrEbp 3YQh0uk5CuDzk5oWpWJwPlQBRuPoB11WI7KCkMGOxFjJjAYTDo4Kiv8gPpp7uhAtSo8E cemQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ckmC6bHO; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id j65sor4538492pgc.28.2019.08.20.16.06.59 for (Google Transport Security); Tue, 20 Aug 2019 16:06:59 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ckmC6bHO; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=snb+417mkIMijis5gqdevRgXi5CVEc/HJIJZWNwpKg4=; b=ckmC6bHO8Kbn1CHlkCqw7uMa48JTuuzH2nyUAHB1uDRaO0HUittmeTKLjRL0mTNEcy lubKDnkDdpPxOQ/Ua9bx/0M77HH0xP0TbZxIGkOdUgKpk3/2VC3U/RlG9jrdMLe3HBPL /ufFGRVWEQb41zCT1YnIk41YzfHkCnZ5leAuMjMdjHxzeMAebw6HwxJ49mvpod07sywX t7UIxQDlrlNuS/DVY7IjsbG19IzhsJ+dwbzFx41/yrW9F3sOpS9pbHFo5q7ONbgurGj4 z56oCcreOzy1X0wR/2dZ2ERY0AfVh28rQRfwSsv4IHENeCN7W7hq7UAYt+z50QjE7sEp cLwQ== 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; bh=snb+417mkIMijis5gqdevRgXi5CVEc/HJIJZWNwpKg4=; b=rB+OhwfJgjZR+rjZ82vApMY94gRo7zpRoKJNcN2m9C+ptesKlsT+C2sm/CaDsGnl0q DDf6w2+OVW8PFpoEvewOENImOQpS0pacsf3XChGOKYv53Q19z+aqT0kx6WP/Xv094Tlv 0q4lEPlVUCguMlqmGYfAMyzBGHwTiVmWQKiPqQpDZ+T3sj/Af5pJ7oA9eqvXq0P7bTbn wGY4B2Ffrs9+TKtDHMgaV0TkKaFAuHxABxJCO5zRvP+n1AOwDZsMYxoyjVhpIrzMj/6r zDsN21XBClF1FwlnWrGD6RC2LNSn1ej6aVzxB38FIy92MYRlPcA0w9UjdjnFHlnOZKWP mpBw== X-Gm-Message-State: APjAAAUo9ZVLsJotZhCLwckRobAgsXMmfgvLsk8+IEqI0YoUAbT36hmE ZJN7x30jxE6ZZwaEMVUXutIhhoU7 X-Google-Smtp-Source: APXvYqwY4EfPryJEWWvkuEZzRawoYOjYmi1jU1CLX9i5qMq4MfYDgepzGUiPR7bgjFNv9hEGkySf8A== X-Received: by 2002:a63:3006:: with SMTP id w6mr27037577pgw.440.1566342418741; Tue, 20 Aug 2019 16:06:58 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id q4sm27564747pff.183.2019.08.20.16.06.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 16:06:58 -0700 (PDT) From: John Stultz To: lkml Cc: Xu YiPing , Rongrong Zou , Xinliang Liu , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg , John Stultz Subject: [PATCH v5 19/25] drm: kirin: Add register connect helper functions in drm init Date: Tue, 20 Aug 2019 23:06:20 +0000 Message-Id: <20190820230626.23253-20-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820230626.23253-1-john.stultz@linaro.org> References: <20190820230626.23253-1-john.stultz@linaro.org> From: Xu YiPing As part of refactoring the kirin driver to better support different hardware revisions, this patch adds a flag to the device specific driver data so that we can conditionally register the connectors at init. Cc: Rongrong Zou Cc: Xinliang Liu Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Cc: Sam Ravnborg Acked-by: Xinliang Liu Reviewed-by: Sam Ravnborg Signed-off-by: Xu YiPing [jstultz: reworded commit message] Signed-off-by: John Stultz --- v5: checkpatch --strict whitespace fixups noticed by Sam --- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 1 + .../gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 43 +++++++++++++++++++ .../gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 1 + 3 files changed, 45 insertions(+) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index 21c5d457a97d..89bdc0388138 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -1073,6 +1073,7 @@ static struct drm_driver ade_driver = { }; struct kirin_drm_data ade_driver_data = { + .register_connects = false, .num_planes = ADE_CH_NUM, .prim_plane = ADE_CH1, .channel_formats = channel_formats, diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c index c9faaa848cc6..68de8838da3c 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c @@ -98,6 +98,40 @@ static int compare_of(struct device *dev, void *data) return dev->of_node == data; } +static int kirin_drm_connectors_register(struct drm_device *dev) +{ + struct drm_connector *connector; + struct drm_connector *failed_connector; + struct drm_connector_list_iter conn_iter; + int ret; + + mutex_lock(&dev->mode_config.mutex); + drm_connector_list_iter_begin(dev, &conn_iter); + drm_for_each_connector_iter(connector, &conn_iter) { + ret = drm_connector_register(connector); + if (ret) { + failed_connector = connector; + goto err; + } + } + drm_connector_list_iter_end(&conn_iter); + mutex_unlock(&dev->mode_config.mutex); + + return 0; + +err: + drm_connector_list_iter_begin(dev, &conn_iter); + drm_for_each_connector_iter(connector, &conn_iter) { + if (failed_connector == connector) + break; + drm_connector_unregister(connector); + } + drm_connector_list_iter_end(&conn_iter); + mutex_unlock(&dev->mode_config.mutex); + + return ret; +} + static int kirin_drm_bind(struct device *dev) { struct drm_device *drm_dev; @@ -117,8 +151,17 @@ static int kirin_drm_bind(struct device *dev) drm_fbdev_generic_setup(drm_dev, 32); + /* connectors should be registered after drm device register */ + if (driver_data->register_connects) { + ret = kirin_drm_connectors_register(drm_dev); + if (ret) + goto err_drm_dev_unregister; + } + return 0; +err_drm_dev_unregister: + drm_dev_unregister(drm_dev); err_kms_cleanup: kirin_drm_kms_cleanup(drm_dev); err_drm_dev_put: diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h index fdbfc4a90f22..95f56c9960d5 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h @@ -39,6 +39,7 @@ struct kirin_drm_data { u32 channel_formats_cnt; int config_max_width; int config_max_height; + bool register_connects; u32 num_planes; u32 prim_plane; From patchwork Tue Aug 20 23:06:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171878 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp180484ily; Tue, 20 Aug 2019 16:07:02 -0700 (PDT) X-Received: by 2002:a62:e401:: with SMTP id r1mr33684363pfh.193.1566342422702; Tue, 20 Aug 2019 16:07:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566342422; cv=none; d=google.com; s=arc-20160816; b=In/IEn0IYTOXIswEkdJ4E7z9MNJvB+pr9GkVJXrZTpeYUocYXoneiUDmjZosQmzXFk G8hI9/yYjV2P2dUogpYkCXiUKpLYPNLeNU7MzEDcGbfvthjDfsNV/iWe5IrxJvnZO9Kf 9cvGzOm+vCMQ35Oejt1/Lf1zp1YRoj5aPZLgP98TGJnlqA7FwsAhF875RMpsMn1DYDrD TG4Rso7Jwu/3M5dbf1Ur1rrvivHv/xaIfTCx0L5GLX4zIsLshYEIW/TCQcyyoqyRVzBi jsBX5qLjnNKUIFji2FHLAZI2L39AwVnHa9ASsw3l2fhYQmVXIX9zO9eTpOLJCulaR68P pxOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JH6TFWi2jRebxYBXOLzwh9NRdxn767CmjdWSOdZnLUU=; b=u38L84Qz7TzK8EvHFd/01i6jVjnc3TFbSzCW5K8zxwz13l50LnROIeKrFWMFTiQJuQ mhAXcXM3ZlCfq9+3OEBf3TL7hsWwu95FgVzsWcrzUe9ilnKrSJrXgFguMSIx1qGamZQY 1QqM6AMA+gz1WpjH9YWJPUY5J6n1KXcGQVngvfPjy33dKXv5rpe2FmPgH5k1UZ8p5j3O VWSVyvOW2J99INHNVEtuHH284ESm4g5hOgU7/nMPm8prfaFii3ajsSvnGflkKC15CeR2 4243AVejeV8PPDDNBN0zIgwDkHKqWiuZZA/ninsd2b2L6/0iBeV5hPjnKohZRdZKk4uZ si6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GC2fVtAj; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id r16sor5602691pfc.73.2019.08.20.16.07.02 for (Google Transport Security); Tue, 20 Aug 2019 16:07:02 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GC2fVtAj; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JH6TFWi2jRebxYBXOLzwh9NRdxn767CmjdWSOdZnLUU=; b=GC2fVtAj+YBtwyiQU4cD88uREHFeALuT3jPKkf8NTz0iGw8Wn45nLFCbMqPGUz+2dR 0gYKQJqIdjnrUwKlDMh3JQNLyAQPfpQIJ0mbXhKdYCF34TcU4rL7NEwrJjlfkgvdxVeA JpzkBkNn2MGzGd6UFO9KJQ9vXawjOin0EzUFazRkDOP/RBzQrZx7ZVs9/WRzf/DlTV1M p+5dzeM3+dZMhN2NYANr/FFQrs2gEWumdlchLmteC2QYvcqcTG6CesD+zF+zSirYUhrK pMhrfC8OLgH1wTLcf3F6DdT9i27AVAOGptJ+gua88BWMmlylsC3d1ePlRZjH0F6viva5 N6Sg== 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; bh=JH6TFWi2jRebxYBXOLzwh9NRdxn767CmjdWSOdZnLUU=; b=peNBgp4KQ6mgqWm7r2okebaGrjJ/CAiYklh+n+E8ewhJIoG9hICphVsRqZmOsbVm/y +WauDiNv5H6tlGvnFPGv3jk9a31U35Y44tbi3+Wv5a8tAALkz0IjqVCimSMtLB+zJi5H BZX7qcBxeLrCazceYZ868A+0pDaSH231I+mDDhzdVmI2OF2Rju0y9wdgvKKvRqJ3A6BH t+ITaUmw3aaqAPYX/6Q90ZBwEA1/0ctdrTj2dSgc0ow6S5n2tWCdCAf/wHc92FjzM4n4 eVo5oVaTcFnw3aRQYDw+KdD86m4XPMmhw7dBDp/fuRy4dwL2nnI5zNGXlZp7ZpYDp53o foSA== X-Gm-Message-State: APjAAAXP/CXE574IX163ZavWwJD3Vl+0xy21Culf7sPxppvO3I6ZtevB OKWdeJ7cz9d2Yq59UGmYQ8PMa8JS X-Google-Smtp-Source: APXvYqxcb1Obks0yFE+u7vU6fyhH13cugDVkKCNHFU9sRO/6BWUGpIIRt3iT73604AGLIwuXrrmSpw== X-Received: by 2002:a62:ab0a:: with SMTP id p10mr32526186pff.144.1566342422333; Tue, 20 Aug 2019 16:07:02 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id q4sm27564747pff.183.2019.08.20.16.06.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 16:06:59 -0700 (PDT) From: John Stultz To: lkml Cc: Xu YiPing , Rongrong Zou , Xinliang Liu , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg , John Stultz Subject: [PATCH v5 20/25] drm: kirin: Rename plane_init and crtc_init Date: Tue, 20 Aug 2019 23:06:21 +0000 Message-Id: <20190820230626.23253-21-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820230626.23253-1-john.stultz@linaro.org> References: <20190820230626.23253-1-john.stultz@linaro.org> From: Xu YiPing As part of refactoring the kirin driver to better support different hardware revisions, this patch renames ade_crtc/plane_init kirin_plane/crtc_init, as they will later be moved to kirin drm drv and shared with the kirin960 hardware support. Cc: Rongrong Zou Cc: Xinliang Liu Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Cc: Sam Ravnborg Acked-by: Xinliang Liu Reviewed-by: Sam Ravnborg Signed-off-by: Xu YiPing [jstultz: reworded commit message] Signed-off-by: John Stultz --- v5: checkpatch --strict whitespace fixups noticed by Sam --- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index 89bdc0388138..e390b1b657b8 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -571,8 +571,8 @@ static const struct drm_crtc_funcs ade_crtc_funcs = { .disable_vblank = ade_crtc_disable_vblank, }; -static int ade_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, - struct drm_plane *plane) +static int kirin_drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, + struct drm_plane *plane) { struct device_node *port; int ret; @@ -892,8 +892,9 @@ static struct drm_plane_funcs ade_plane_funcs = { .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, }; -static int ade_plane_init(struct drm_device *dev, struct kirin_plane *kplane, - enum drm_plane_type type) +static int kirin_drm_plane_init(struct drm_device *dev, + struct kirin_plane *kplane, + enum drm_plane_type type) { int ret = 0; @@ -989,6 +990,7 @@ static int ade_drm_init(struct platform_device *pdev) struct kirin_crtc *kcrtc; struct kirin_plane *kplane; enum drm_plane_type type; + int prim_plane; int ret; u32 ch; @@ -1024,14 +1026,15 @@ static int ade_drm_init(struct platform_device *pdev) else type = DRM_PLANE_TYPE_OVERLAY; - ret = ade_plane_init(dev, kplane, type); + ret = kirin_drm_plane_init(dev, kplane, type); if (ret) return ret; } /* crtc init */ - ret = ade_crtc_init(dev, &kcrtc->base, - &ade->planes[ade_driver_data.prim_plane].base); + prim_plane = ade_driver_data.prim_plane; + ret = kirin_drm_crtc_init(dev, &kcrtc->base, + &ade->planes[prim_plane].base); if (ret) return ret; From patchwork Tue Aug 20 23:06:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171879 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp180520ily; Tue, 20 Aug 2019 16:07:04 -0700 (PDT) X-Received: by 2002:a63:b64:: with SMTP id a36mr27332298pgl.215.1566342424202; Tue, 20 Aug 2019 16:07:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566342424; cv=none; d=google.com; s=arc-20160816; b=F8artvGXroeT84+1cOA5z3OnQFfB5GonpJjNT1lUx+OiJXyb9mVN6NS62MBd9gfNXy xriEmdxAZ7DGL86pH3FQeDbdBTu5Nlip9b9mG3uHUaaP+hiDdlcngGb/jwJONJ5XfLE9 Pg2Hjf5mpuYSi+icFhDY6Iv71fXIxoQpmbBp9COGDtompa7Z4WG/p3u22xlZZqUIkTm9 /mGSExvuTXfokHne7+SF3Gro86GUz8y/ObuvOvZEB/gVJcDO5eBF1XKzJRgB6V+R48cs 8tQ7XAdp6NMVZuyVH0cOT7FsTwPWNW0hfQeUYTqS9EDDh2Oq0Wuiwe2gyS771f6/75fc oVbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kPTZRFMdlMvsVJLbNqEMp+KDg1p/2/PzTgB54sSjI/U=; b=bSrMiEjW8iG5uRX6HaHSF8CJCW5BhU0QGM5CUTWUSHBKeth2TMQGhtqrfggFpq4C8m FrPoxGkolNTRV0+y6YWib1v8djtPyOVMAHIn+vBTLJdzR8YWtqjOBffCeAGhFFXOXcI9 S0oGDCeFVGmCLU17HrKPqIsu3SCW36RMaI5UgvGYz9JYhZEYlam837Cp1xoo8qZtFo8M ob9TEoSKoYHktLev4LAJsyz/asmnnAoMY3FH2MlDWIkuXekvF7u/hKD8KVQbGPCCUO9B mTVAwLQanmbGqkNwMT8mpflwo9s1jeI2k4tbKCxWdRXC3TIJozzUb+SXm3XZzo5qYZmv SMYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zyuDY+Dz; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id f6sor5540820pfd.46.2019.08.20.16.07.04 for (Google Transport Security); Tue, 20 Aug 2019 16:07:04 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zyuDY+Dz; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kPTZRFMdlMvsVJLbNqEMp+KDg1p/2/PzTgB54sSjI/U=; b=zyuDY+Dz9GS/ATmdo/KHEQi19IecSLdC2e6bTsUgY8jsteM9oMqvfXbaXAc221LP31 yDMUOoUvjo/Bi9oOEz3JmkMbJIZIbvDJ9NOb6jy85smlKiLm+/XLeT245/yjrermAOY5 IJyQFysEf15/jxU+Cv4Idz8tX4x6CfhARclR4mJwN+/o4teAp1RCRWNuFLhU2HFq8L/t Lvdu//m4AfDM1ZNAvfH7KbtLSJKvmK/agBLsSJHP/82IzWM8RBUtf8i6T+OerKLYFRho R7ljI1474mWznSb+KYDK0/c9Y5HW1lvd6goCAFrlpf9zCKH0OPMwy5y9GB7i73I8Zk/g 9prQ== 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; bh=kPTZRFMdlMvsVJLbNqEMp+KDg1p/2/PzTgB54sSjI/U=; b=UN2IrKlxX7K0tuPeA8gQ6HHueDUnI73lhpA0dACVcDvD+4beQHGRMwV34mPjSLYnVn x8NrZONGMS8Ag1JIk1XMp3bPdcUIV/ckMkjxkuZhXKLrQmM+D1Q8OI/1HBFhfihBJlwr EpXw1sodqRdw/2cioUBdPSrEUMOoUajw6mdnIkFUN5HLLst5a7OTIL0ABp9H6AfxQHUT KMHVK2CRvhMfB1RlFkbLAReFJHanjCiSHmYMifggpVR/OWbFUZ6/H7sHyHSl84RejCP+ ed63VjHrOeSU9cjrm7cbjSjSRkRE+hB98mB6forXMKKGifeC2DM+KuEqzyiU2fhXHLwC HP2g== X-Gm-Message-State: APjAAAUXr4OAAe7Mk1nyD14ToKBpy8EU+aOzwqgpveM9lM40FLf5BR2u oylejXpYqqBYnuUnpJN8+7giVtUk X-Google-Smtp-Source: APXvYqwPWi3hV1aULI47BdH1J86xCw7uOXUE660dq+vqeuPuIugq7A8By+kPCr/L6d0RdR//xPBKqQ== X-Received: by 2002:aa7:8488:: with SMTP id u8mr33269995pfn.229.1566342423834; Tue, 20 Aug 2019 16:07:03 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id q4sm27564747pff.183.2019.08.20.16.07.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 16:07:03 -0700 (PDT) From: John Stultz To: lkml Cc: Xu YiPing , Rongrong Zou , Xinliang Liu , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg , John Stultz Subject: [PATCH v5 21/25] drm: kirin: Fix dev->driver_data setting Date: Tue, 20 Aug 2019 23:06:22 +0000 Message-Id: <20190820230626.23253-22-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820230626.23253-1-john.stultz@linaro.org> References: <20190820230626.23253-1-john.stultz@linaro.org> From: Xu YiPing As part of refactoring the kirin driver to better support different hardware revisions, this patch changes the dev->driver_data to point to a drm_device, not ade_data. Thus we set the driver data to drm device after alloc. Cc: Rongrong Zou Cc: Xinliang Liu Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Cc: Sam Ravnborg Acked-by: Xinliang Liu Reviewed-by: Sam Ravnborg Signed-off-by: Xu YiPing [jstultz: Reworded commit message] Signed-off-by: John Stultz --- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 1 - drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index e390b1b657b8..d8e40fcff386 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -999,7 +999,6 @@ static int ade_drm_init(struct platform_device *pdev) DRM_ERROR("failed to alloc ade_data\n"); return -ENOMEM; } - platform_set_drvdata(pdev, ade); ctx = ade_hw_ctx_alloc(pdev, &ade->crtc.base); if (IS_ERR(ctx)) { diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c index 68de8838da3c..7f8d4539b1a9 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c @@ -44,8 +44,6 @@ static int kirin_drm_kms_init(struct drm_device *dev) { int ret; - dev_set_drvdata(dev->dev, dev); - /* dev->mode_config initialization */ drm_mode_config_init(dev); dev->mode_config.min_width = 0; @@ -140,6 +138,7 @@ static int kirin_drm_bind(struct device *dev) drm_dev = drm_dev_alloc(driver_data->driver, dev); if (IS_ERR(drm_dev)) return PTR_ERR(drm_dev); + dev_set_drvdata(dev, drm_dev); ret = kirin_drm_kms_init(drm_dev); if (ret) From patchwork Tue Aug 20 23:06:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171880 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp180559ily; Tue, 20 Aug 2019 16:07:05 -0700 (PDT) X-Received: by 2002:a63:9d8a:: with SMTP id i132mr10886649pgd.410.1566342425759; Tue, 20 Aug 2019 16:07:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566342425; cv=none; d=google.com; s=arc-20160816; b=0iJvhwfIagcTbqITSaLZlTHLGgwZzhC/ezyxbxJD+vLXy09AO/v14Iu4pJ3XRytG7/ 2gqrnyOUFYpXNw2z9j8RCPsS40P+15ZeRaRaqQxg5FauMCRzekr7vsULYRsyLgSvlizc ODFw7LnaNFMwkdPjjyInhuBHfWGlQpQDOLMmdBLVW4NnqxPfGsT5RiJY4gRp+mLYyYqB vEjpmYb6+UkdsjONXRlkp1niAzItVVIWlBAKHltFhH4LvuyfV4ytQrOSz7GsuPcJcmoz QkwLxBwwDvQO5kSbPJMbRj1BrmEMYgV45s+yEa0KsjC4ZuAHNlNEUZ9ZKKC+XzuJnT/a Z25w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MVBS6s/BS2iml31wX2/Rhd0nBzLwsiOkYjbfOZWZ4tw=; b=LHkGqvOCV0G86IiyYM1Q9zGOKruOtCUNlOHzGi6Gn3CAS872bR10JEdIjY0jL41vx9 l3iLz7DYa0Vc6jz5287+jdKk/vVA62/yIVyWZm/BYTt8elbtAIllWcamABpfDf1dhaee aQCaEOsxt31KaK+jE18WKvycurk8TjLHewJfdWFIYWy0VVoNCrqOj1K98PvCONj6L73B HEv0M8gQnBkwnfHExNnzsP2d6FiebUgKb+0x0r1hT1nlkV7ZGnPc9Fkw2Z06ovVZhjGJ Sn4PQxzxD3xxW9Iig6asVgFXPTOWnFIg1pRiViEZ867DcYJIUmt+WajfSzsIJW36lN9a V6GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jeM2fPkb; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id c16sor5603479pfr.5.2019.08.20.16.07.05 for (Google Transport Security); Tue, 20 Aug 2019 16:07:05 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jeM2fPkb; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MVBS6s/BS2iml31wX2/Rhd0nBzLwsiOkYjbfOZWZ4tw=; b=jeM2fPkbWnWSTtEljReDIHFfsfeHVQ01JqHJ9u2ShkYBcp+/+8KYKxqhYw3vJRtfW7 QVPqk/3z38c4SPs8IzrPnm7uelkN5fbYcTCsyH17RHuZSVSNJXpYSnlPXTbgSEIDg3fz WI4Gu4RCVWN4uYRfzbWWXuHkT8DjXxSIKW/THCwmlSZIvU+aYIPe1yQ3f/BooYC1qeex Lgt5cV4PIgRLXnc7Xq4BkU2nuYMxZJ6yp0zDEMhyBn83wAsR6t5j9l8Cl+GBvNrG5kPV NPU0owlbQoPnSXK0TefSdAMsPcnLzi1X8CgwVKhtVh/K0uhgD62tZfDXhaW381uj/zNt upbA== 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; bh=MVBS6s/BS2iml31wX2/Rhd0nBzLwsiOkYjbfOZWZ4tw=; b=dOnNzNJ6aI1qrKaGj2OBD1w4JWcU4qvJ0DU/g3mCzkJOtXbZRi5jwUv43DzpjmkJ8D oOLtVAfSTkobqPJwXs/LZHgLjLYcgbMIDCEVoglrxDKETUMNKH0bxQSaDcilKEvWYr89 hswe+ufMFXOFkUScng+rrLO+uoEozjKkL4uztLTozw31jHnH6y0tGMqmbtpt1Ze8yZ2a CxyBa/4DEfSBdJH8tRtMivGJqBHxvSRbx8xNUphh6vNJzslkkDTDzRtxTQBQz4ZLXQIi I0u4+n5w8ipHZzZ27DugBXNwJBtgVpI0zIqr6dLFIm3FR/P2fwxxkUhDRQGpKLzea2V1 Q+lg== X-Gm-Message-State: APjAAAX9YjWXnJqjBYWpO2hJMkHo4Ldbj0dKmOgXY72DfFaVdFf7wlzC RLXVaf8SWcR1JTpHMsYlcpxCdT4F X-Google-Smtp-Source: APXvYqwG9+bnLD4/Mpplbe8yIuvH+GlW31O8nnLcR91y1DkSlFoAAJKR0LUsiNpcJoVraKcZf5ZvIg== X-Received: by 2002:a62:76d5:: with SMTP id r204mr32005336pfc.252.1566342425396; Tue, 20 Aug 2019 16:07:05 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id q4sm27564747pff.183.2019.08.20.16.07.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 16:07:04 -0700 (PDT) From: John Stultz To: lkml Cc: Xu YiPing , Rongrong Zou , Xinliang Liu , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg , John Stultz Subject: [PATCH v5 22/25] drm: kirin: Make driver_data variable non-global Date: Tue, 20 Aug 2019 23:06:23 +0000 Message-Id: <20190820230626.23253-23-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820230626.23253-1-john.stultz@linaro.org> References: <20190820230626.23253-1-john.stultz@linaro.org> From: Xu YiPing As part of refactoring the kirin driver to better support different hardware revisions, this patch changes the driver_data value to not be a global variable. Instead the driver_data value is accessed via the of_device_get_match_data() when needed. Cc: Rongrong Zou Cc: Xinliang Liu Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Cc: Sam Ravnborg Acked-by: Xinliang Liu Reviewed-by: Sam Ravnborg Signed-off-by: Xu YiPing [jstultz: Reworded commit message] Signed-off-by: John Stultz --- v5: checkpatch --strict whitespace fixups noticed by Sam --- .../gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 43 +++++++++++-------- 1 file changed, 24 insertions(+), 19 deletions(-) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c index 7f8d4539b1a9..f5df88378591 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c @@ -29,18 +29,9 @@ #include "kirin_drm_drv.h" -static struct kirin_drm_data *driver_data; -static int kirin_drm_kms_cleanup(struct drm_device *dev) -{ - drm_kms_helper_poll_fini(dev); - driver_data->cleanup(to_platform_device(dev->dev)); - drm_mode_config_cleanup(dev); - - return 0; -} - -static int kirin_drm_kms_init(struct drm_device *dev) +static int kirin_drm_kms_init(struct drm_device *dev, + const struct kirin_drm_data *driver_data) { int ret; @@ -96,6 +87,21 @@ static int compare_of(struct device *dev, void *data) return dev->of_node == data; } +static int kirin_drm_kms_cleanup(struct drm_device *dev) +{ + const struct kirin_drm_data *driver_data; + + drm_kms_helper_poll_fini(dev); + + driver_data = of_device_get_match_data(dev->dev); + if (driver_data->cleanup) + driver_data->cleanup(to_platform_device(dev->dev)); + + drm_mode_config_cleanup(dev); + + return 0; +} + static int kirin_drm_connectors_register(struct drm_device *dev) { struct drm_connector *connector; @@ -132,15 +138,21 @@ static int kirin_drm_connectors_register(struct drm_device *dev) static int kirin_drm_bind(struct device *dev) { + struct kirin_drm_data *driver_data; struct drm_device *drm_dev; int ret; + driver_data = (struct kirin_drm_data *)of_device_get_match_data(dev); + if (!driver_data) + return -EINVAL; + drm_dev = drm_dev_alloc(driver_data->driver, dev); if (IS_ERR(drm_dev)) return PTR_ERR(drm_dev); dev_set_drvdata(dev, drm_dev); - ret = kirin_drm_kms_init(drm_dev); + /* display controller init */ + ret = kirin_drm_kms_init(drm_dev, driver_data); if (ret) goto err_drm_dev_put; @@ -190,12 +202,6 @@ static int kirin_drm_platform_probe(struct platform_device *pdev) struct component_match *match = NULL; struct device_node *remote; - driver_data = (struct kirin_drm_data *)of_device_get_match_data(dev); - if (!driver_data) { - DRM_ERROR("failed to get dt id data\n"); - return -EINVAL; - } - remote = of_graph_get_remote_node(np, 0, 0); if (!remote) return -ENODEV; @@ -209,7 +215,6 @@ static int kirin_drm_platform_probe(struct platform_device *pdev) static int kirin_drm_platform_remove(struct platform_device *pdev) { component_master_del(&pdev->dev, &kirin_drm_ops); - driver_data = NULL; return 0; } From patchwork Tue Aug 20 23:06:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171881 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp180592ily; Tue, 20 Aug 2019 16:07:07 -0700 (PDT) X-Received: by 2002:a63:5b52:: with SMTP id l18mr26705063pgm.21.1566342427189; Tue, 20 Aug 2019 16:07:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566342427; cv=none; d=google.com; s=arc-20160816; b=HkgBTugik3RJ9LUeafPOG3B2MRi0zn7URgTkqUkFO2E7mImiifOGKxFxI48zxlE7HZ dvfyEUsq4/4A4cJsQexNDcYH3cZhfPRPAE6uvH+yIrepIsLyNRXZHCID8Q9iWYnPDtxO 7H2NLusbla+kbQGiulhMzzR/Vbv2ybSAbexnTqH0kN+tJM0E8+t8wb2KegwmXrtwsqUX m5saPHYYgLuqV5S1FDwNfrLZGSLk9A0xRWJ/ZGHhGhxxmv9dC6octnI2OzLu+Si/MyiG 4gQ+ilZ95zJsjKkT923qKJelLXiasgo7ITvji+Sdhhp5GoLCT8j7QPseN9Uh7dIg6Def f0Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kYV4kILdbKA8eyGmIfSZvQNIJi3JDyMCa7aHVJs5K24=; b=op6hxBb0bAMlvO5QuyrHY5zPSMazRetTcr86McDEJWuGBDeq48R2lA9021JpsuZNw8 gvCsJHChopzSI1kQn1dp37tTSS2As+XePafmCvc9r6luxv2+3v1NODEe4nU3ikuQgG69 sHWKwxyX0Jk5r5NkKCRfHv3XjrJlVUCbBKRNJ83peBbiy1oeuqa9gt5VaTSG2RqbT220 b3YtGGWycCOSFpPUUu/YHD8TMAhMubKrrgauOA1xoaCqzxGKLK9QtCjzJ+bBdd/FYwZY dcWSdMY7Ft30+QJ19bMxE/oQ46KVfEws88ELVyGgy+INa8Q6UZfjiLBYQ0i8AvlH+LV1 qmPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dSG1Ek3w; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id y13sor5524159pfq.30.2019.08.20.16.07.07 for (Google Transport Security); Tue, 20 Aug 2019 16:07:07 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dSG1Ek3w; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kYV4kILdbKA8eyGmIfSZvQNIJi3JDyMCa7aHVJs5K24=; b=dSG1Ek3wXoduCZ6bdSuQJ6zGn1REdKK3dH8Owh1BVf8Ldw3GKyoUXKYaXn2HjvWsG8 0MlCq97ext2U9uYXyV/org/3fYSxurxIps7pVnWIju7CTI40kNCZgjnfK+xgXP/3KceD YG5T4TWr78XkSbRdmtVXsdo6ODmzIGweCY6eclvmzUTmzIYugRMn3xIwL6/kLv9usAsJ EtvvPiZ7Rxryd4Y0jImrXwmpmsjFCAV0/ljtjkKlK0DeVe2IgpfJ0ZT+qQJOSKUfcYI1 +kb3OeO4iytf1/eFRCRYE6vc7RenGQ1wX1UcNLIW/+ziqlO1DOjcD/rnuwwTMLpzJyXR Lu2Q== 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; bh=kYV4kILdbKA8eyGmIfSZvQNIJi3JDyMCa7aHVJs5K24=; b=RojQquQajjU7fU72cCyaMonEHyL+YwB9EaFeNPfJISPBQsbnfKSyDIxI0YE/rbNDYD DbttH7lPFoGKuNv2OrrdsmjqkMxndYlpG/Cdcpo0RP1bLwaaHLzMp21OX1JN1zGSZQg2 vi4v5qyRkPY5BJ7zg9gzAR09iXnFEXbUD7KS0ZZhm4okeKz/V1Aof+kCwvHyi5+XyiiQ WKYjAbSd+yBSgzY7HKDQa4eEd1+6ZLW3FEEvIj5Lkk2q20K02BV17LGTi59IUUWHiYME FUfQaJyJ3F5bvEiNDpSAY552rzxYZidgMvEWAqns+LsEA3GbQbqnHfnOSRCKbuxXlYDd a/Jw== X-Gm-Message-State: APjAAAVbFj7fag/Wk8KOBdZgLScP6SyeIrYNnuVH97v+PTDgmkCGYSve ywg7I+5LjYPYG1R9UbVHuEryg5vZ X-Google-Smtp-Source: APXvYqzk7Q18L54XsSE8B+hQfBteWjyw6GXtAXHv5na/lhxe1AhTuuoaZsEygqXrPAPNJJJfBzq22A== X-Received: by 2002:aa7:93cc:: with SMTP id y12mr28989943pff.246.1566342426836; Tue, 20 Aug 2019 16:07:06 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id q4sm27564747pff.183.2019.08.20.16.07.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 16:07:06 -0700 (PDT) From: John Stultz To: lkml Cc: Xu YiPing , Rongrong Zou , Xinliang Liu , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg , John Stultz Subject: [PATCH v5 23/25] drm: kirin: Add alloc_hw_ctx/clean_hw_ctx ops in driver data Date: Tue, 20 Aug 2019 23:06:24 +0000 Message-Id: <20190820230626.23253-24-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820230626.23253-1-john.stultz@linaro.org> References: <20190820230626.23253-1-john.stultz@linaro.org> From: Xu YiPing As part of refactoring the kirin driver to better support different hardware revisions, this patch changes the alloc/clean_hw_ctx functions to be called via driver_data specific funciton pointers. This will allow the ade_drm_init to later be made generic and moved to kirin_drm_drv.c Cc: Rongrong Zou Cc: Xinliang Liu Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Cc: Sam Ravnborg Acked-by: Xinliang Liu Reviewed-by: Sam Ravnborg Signed-off-by: Xu YiPing [jstultz: Reworded commit message] Signed-off-by: John Stultz --- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 9 ++++++++- drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index d8e40fcff386..a2bb2b75be4b 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -1000,7 +1000,7 @@ static int ade_drm_init(struct platform_device *pdev) return -ENOMEM; } - ctx = ade_hw_ctx_alloc(pdev, &ade->crtc.base); + ctx = ade_driver_data.alloc_hw_ctx(pdev, &ade->crtc.base); if (IS_ERR(ctx)) { DRM_ERROR("failed to initialize kirin_priv hw ctx\n"); return -EINVAL; @@ -1040,6 +1040,10 @@ static int ade_drm_init(struct platform_device *pdev) return 0; } +static void ade_hw_ctx_cleanup(void *hw_ctx) +{ +} + static void ade_drm_cleanup(struct platform_device *pdev) { } @@ -1089,6 +1093,9 @@ struct kirin_drm_data ade_driver_data = { .plane_funcs = &ade_plane_funcs, .mode_config_funcs = &ade_mode_config_funcs, + .alloc_hw_ctx = ade_hw_ctx_alloc, + .cleanup_hw_ctx = ade_hw_ctx_cleanup, + .init = ade_drm_init, .cleanup = ade_drm_cleanup }; diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h index 95f56c9960d5..1663610d2cd8 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h @@ -49,6 +49,11 @@ struct kirin_drm_data { const struct drm_plane_helper_funcs *plane_helper_funcs; const struct drm_plane_funcs *plane_funcs; const struct drm_mode_config_funcs *mode_config_funcs; + + void *(*alloc_hw_ctx)(struct platform_device *pdev, + struct drm_crtc *crtc); + void (*cleanup_hw_ctx)(void *hw_ctx); + int (*init)(struct platform_device *pdev); void (*cleanup)(struct platform_device *pdev); }; From patchwork Tue Aug 20 23:06:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171882 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp180615ily; Tue, 20 Aug 2019 16:07:08 -0700 (PDT) X-Received: by 2002:a17:902:9a82:: with SMTP id w2mr30535898plp.291.1566342428584; Tue, 20 Aug 2019 16:07:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566342428; cv=none; d=google.com; s=arc-20160816; b=rA6i+LUToPY8aNWwa9pp1G5jfS87ArzgV4YzRtEKLHzEtT9oKzt0yqYE+fw7XefXX+ HlcUNzeFU/LGlMo2dp4tzGpLILxRMyhP0xPiPDFmG+9JgMnySBOuuL3ZqEYMO8B5cNRa aXbqOa0xVvBPai8nRFvWI+NN5Fskly5DEGMG9jo2N3Mxd0GGkslaqfKdzDJUc/CkPI25 DkPGTagC6nn7Y06IhCyqHo4TZXmWE1bXmgDJn6nhQ6t8gWfo/dF1e+wgFFNVLbdNJ4ab mJBhnhprd90FCUMLDRr9FaoupBJB3NTcq+0sjjlIB3SkxAM9hWvuxRcjcROgiX9PD6vb M1/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VMYo3cmyj5mjY37f6pl3U9ULsw2dRbJPHRfoYta4hK0=; b=NeqDkMkyET0bG7Lk6Xlrph+B98Ga/T26RXlso/67AuEKFXNxtc9fWIlqt5vyZgToyX prABlbk7wxTKKu9/4+7bsnfzU7XfZpumHBt3rwKIvrHub5/tgeHNmBukhlPrIu6su1qS N721nD3VaXU6iF2TjCmvBAxpdyDjfAqhuNlN/hrhsT4Wm4sxoW1fBX2qhfmUm0QdG7e+ E2XzIZeRuABj+HKPQwfgNMHoC7/W4zpRjWHS4A4aul9YElNHG4cqtSjDTut9dfzfCqv4 ZKZ9NrxoiTIWhZko3oaB5WbfLa+/jdpwBKDgiwmdjlCyy5K6NTGIBcCNQX5Wwxa3mTIN Keng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gU8ZcIiN; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id z123sor5506345pfc.6.2019.08.20.16.07.08 for (Google Transport Security); Tue, 20 Aug 2019 16:07:08 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gU8ZcIiN; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VMYo3cmyj5mjY37f6pl3U9ULsw2dRbJPHRfoYta4hK0=; b=gU8ZcIiNsbUNjEDU4QjWJ18XVrvz8lEmU3ppSLa8L3REyQwkogE286YOh/RV+SS7bK dzkEXC8NFkYiQu0pEDlrrWCFHsw3x6XTDQbfUSId/HntLnnMVaVmQAol0l9wYXFnAb5/ 8u4GoC+2Y0OeBIaOu55i7DAptqIs488dPDRMi8qvm+E992oefr+YMpKZ8A/KdT+XUK8q Tp3+q7eThBZbXJ0XimqCKowZsiM3PkZokQj39DtGWkGe9ohYAh7C/ztK4b3a+sYzp5e8 P2/GfsazWdbIG77RFAy3zoB68GVn24r0Zqu6lHJroKkdWlxS73tzCy+RKm+PFWoanfNU QB/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; bh=VMYo3cmyj5mjY37f6pl3U9ULsw2dRbJPHRfoYta4hK0=; b=FulGKlft7ErV0jg4/e5FsDWebFHLNwz1ZlY0W3PFIFI4IqIWDXpjxsnc6+GIdP7HiJ 2zyWGpY0j4RLBht3icTN5qc/oEeFVY9kLEKovP+jWJdsdLmJfd3NULBH0epQH4f6uPdH VKJBLY0HhK+bIeveaYx0rB3Hc6U6z3LJMBCJWSoLyG6Ozq5g0Zrbd/Ebre/P3oW99Ub1 qOkZnOJBmnkmLxUKAh8D2tceqVfZgI0rxZgwkLp6bZkWBoa2w5HiFdI583WDc8MN/FL2 hKDNwguiTnEbOvOPUi/l/fk8z5H8fCkvwddTmJ35/7dA9MlaIRHhSYsxlqMCodfap70f MsGw== X-Gm-Message-State: APjAAAXm/Ee4ELZ/y8aDYVKWQtMXX5/djakSyNl/wvSL59nRbnxDXmvV ibb7yF/BmPgPZpN7ujIdtTCt+x/y X-Google-Smtp-Source: APXvYqxz1oVW6l7QOBSV8Pa4RGmsgh08w6fiIaPxG+0QGrfNNncnOJsGH7SP4TJXtPquEw8GHTDdyw== X-Received: by 2002:a62:1d93:: with SMTP id d141mr13758767pfd.40.1566342428229; Tue, 20 Aug 2019 16:07:08 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id q4sm27564747pff.183.2019.08.20.16.07.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 16:07:07 -0700 (PDT) From: John Stultz To: lkml Cc: Xu YiPing , Rongrong Zou , Xinliang Liu , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg , John Stultz Subject: [PATCH v5 24/25] drm: kirin: Pass driver data to crtc init and plane init Date: Tue, 20 Aug 2019 23:06:25 +0000 Message-Id: <20190820230626.23253-25-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820230626.23253-1-john.stultz@linaro.org> References: <20190820230626.23253-1-john.stultz@linaro.org> From: Xu YiPing As part of refactoring the kirin driver to better support different hardware revisions, this patch changes the code via a passed in driver_data pointer, rather than hardcoding them via ade_driver_data variable. This will allow those funcitons to be later moved to the generic kirin_drm_drv.c using alternative driver_data structures that support other hardware. Cc: Rongrong Zou Cc: Xinliang Liu Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Cc: Sam Ravnborg Acked-by: Xinliang Liu Reviewed-by: Sam Ravnborg Signed-off-by: Xu YiPing [jstultz: Reworded commit message] Signed-off-by: John Stultz --- v2: Whitespace fixups, commit message tweaks suggested by Sam. v5: checkpatch --strict whitespace fixups noticed by Sam --- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index a2bb2b75be4b..bbdfeac946a7 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -572,7 +572,8 @@ static const struct drm_crtc_funcs ade_crtc_funcs = { }; static int kirin_drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, - struct drm_plane *plane) + struct drm_plane *plane, + const struct kirin_drm_data *driver_data) { struct device_node *port; int ret; @@ -589,13 +590,13 @@ static int kirin_drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, crtc->port = port; ret = drm_crtc_init_with_planes(dev, crtc, plane, NULL, - ade_driver_data.crtc_funcs, NULL); + driver_data->crtc_funcs, NULL); if (ret) { DRM_ERROR("failed to init crtc.\n"); return ret; } - drm_crtc_helper_add(crtc, ade_driver_data.crtc_helper_funcs); + drm_crtc_helper_add(crtc, driver_data->crtc_helper_funcs); return 0; } @@ -894,21 +895,22 @@ static struct drm_plane_funcs ade_plane_funcs = { static int kirin_drm_plane_init(struct drm_device *dev, struct kirin_plane *kplane, - enum drm_plane_type type) + enum drm_plane_type type, + const struct kirin_drm_data *driver_data) { int ret = 0; ret = drm_universal_plane_init(dev, &kplane->base, 1, - ade_driver_data.plane_funcs, - ade_driver_data.channel_formats, - ade_driver_data.channel_formats_cnt, + driver_data->plane_funcs, + driver_data->channel_formats, + driver_data->channel_formats_cnt, NULL, type, NULL); if (ret) { DRM_ERROR("fail to init plane, ch=%d\n", kplane->ch); return ret; } - drm_plane_helper_add(&kplane->base, ade_driver_data.plane_helper_funcs); + drm_plane_helper_add(&kplane->base, driver_data->plane_helper_funcs); return 0; } @@ -1025,7 +1027,7 @@ static int ade_drm_init(struct platform_device *pdev) else type = DRM_PLANE_TYPE_OVERLAY; - ret = kirin_drm_plane_init(dev, kplane, type); + ret = kirin_drm_plane_init(dev, kplane, type, &ade_driver_data); if (ret) return ret; } @@ -1033,7 +1035,8 @@ static int ade_drm_init(struct platform_device *pdev) /* crtc init */ prim_plane = ade_driver_data.prim_plane; ret = kirin_drm_crtc_init(dev, &kcrtc->base, - &ade->planes[prim_plane].base); + &ade->planes[prim_plane].base, + &ade_driver_data); if (ret) return ret; From patchwork Tue Aug 20 23:06:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171883 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp180653ily; Tue, 20 Aug 2019 16:07:10 -0700 (PDT) X-Received: by 2002:a17:902:8a81:: with SMTP id p1mr29876109plo.71.1566342430194; Tue, 20 Aug 2019 16:07:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566342430; cv=none; d=google.com; s=arc-20160816; b=Wm1iw1FBgJ1TvOhTSTjykauiz7I5+7PY+UMIcV9XdqW7F2DZ6FOOKY23XKD3BH1+6U R2If25iU3CHP48hIcXzlN8FK6z+9cmnLkl8baiCeEhbRhZzutmsSXiwGf6U2nDthqmC+ 1jhM2jMbjP6eZJyd3sHDEB0wevCxYc9TjJOBzjlvM0YutQm9mcgRfvo/Qyy1f9+DV224 ECKE5HQal3pccBrZmowMtbDcGLCK2jFU5YKRwcoC92kNi/vXkklEShWjvhdNi1qyI7dZ UJvnnxpsEJBnrm5q9QRsUUCdeyr1xiIpj2eVLcVVYDpmpXtcxGfS/vjqYY53U93FpIq6 OkZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KJXVIjjEjcS++SJh1XiEkct02jaX19GJ8MzEi/j2O6Y=; b=JLfP+Bzj6bzGSINcTtKuElzt5UhV4uvz7txcmEpLRKEKukT/An8nNLxO0u4NGKPbZS Ygc8bChtt5kOULxPKw4VEwYeBRh6P8f0kk1FpfWAJGOvtaWr7BnI4eUjyRQWNul8Dzq1 3S3ZwBtStg2wmvVW/QoU4qHBw16HIdZOFhkPyds9igDB1k46fOFMo4OP8GYLCK4sUDDS VHcL8BKcXGRViegpKJRE4HqIpZLhZFJ0TlTIjNilSc0Y4ocKKyiSGZur/8cBD84huVAQ R109v2eN4PmRCULBrQo3EIeSCFdZrrfiyTi64H18GlZTkLRjH6lrhFM3tDPS93aQuP12 xc8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="O86/E66U"; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id j4sor5615044pff.7.2019.08.20.16.07.10 for (Google Transport Security); Tue, 20 Aug 2019 16:07:10 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="O86/E66U"; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KJXVIjjEjcS++SJh1XiEkct02jaX19GJ8MzEi/j2O6Y=; b=O86/E66UeBeESApeniO67zDOQ7uSYz51tlNrdPllkA5Ebv8MR1OX+O2o2DbxHxFHr2 xjnC34UlJTendJgI0xPKBarRPKxLmQIlZ+OsKqYypVqyBA5xrw0kK9+3nSqTKoBFER+h KaYAt00cDh63+XQhMOB/dcUQM73+/WrvtEyGKKDJJR/Yqx3vXkrtQc8w8wIiRp0llmH+ N5zeWh7JjIrrmTRATxkptT0KAY12fDMfr8zrEpXQffCpUEKUvkOKW1XtiA2ihZnDTrpy SFZMzL7WjANmzlRT6DCaP8IvqKt5ZRR4SLHlyphlGbwM2F4MPgxTvyBDu5cLPak5+4Ak eIHw== 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; bh=KJXVIjjEjcS++SJh1XiEkct02jaX19GJ8MzEi/j2O6Y=; b=jQ4SFnN4j31ui8usduReoFJYwHTKQHXyVnEHGubevqLFiLAFd3dj1Peak+uhipJzj5 w9m1yuhYmh+KpHsozhWJuwMmMxDSzzheIohtgYYRCN5zGK0sotkr3bBVe4fAqivSGJzb /CXG+7ijF0MVTrxszlcbqs7oGJmADbM8XFZ+j/DxMMdRmd194ThDM7gUEYTDzTZCReev l3xoRI5PDmU2TqSeNHMV4QPdBqXWUag6Gw94V7p7osX+RGkOdw7qbMBs0ZxVWEFW5XOY xJYlVS9rfXDT9O7MJ2azz/ZifjfdzAjDC9q9+FfAayB0sQCk1IIuWU3fDAyaNAR7gIAX RBuw== X-Gm-Message-State: APjAAAUg/qCL5gOJcbDzLpPu9ZvPVnLy7pHMI7qt1V1XjUUxwaPME7p1 7ijm7KG+daT8nHqOR48D5pi9PvXU X-Google-Smtp-Source: APXvYqzkTPoH3ukxS5Wn0/KyT91dTrz5lXdrPCWUlIFdTnx3kYaikaoqgLJ9iXUI+R9eo95/dL4hRw== X-Received: by 2002:aa7:9e0a:: with SMTP id y10mr32219595pfq.93.1566342429744; Tue, 20 Aug 2019 16:07:09 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id q4sm27564747pff.183.2019.08.20.16.07.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 16:07:08 -0700 (PDT) From: John Stultz To: lkml Cc: Xu YiPing , Rongrong Zou , Xinliang Liu , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg , John Stultz Subject: [PATCH v5 25/25] drm: kirin: Move ade drm init to kirin drm drv Date: Tue, 20 Aug 2019 23:06:26 +0000 Message-Id: <20190820230626.23253-26-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820230626.23253-1-john.stultz@linaro.org> References: <20190820230626.23253-1-john.stultz@linaro.org> From: Xu YiPing As part of refactoring the kirin driver to better support different hardware revisions, this patch renames ade_data to kirin_drm_private, and moves crtc_init and plane_init to kirin drm drv too. Now that they are generic the functions can be shared between the kirin620 and (to be added later) kirin960 specific support code. Cc: Rongrong Zou Cc: Xinliang Liu Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Cc: Sam Ravnborg Acked-by: Xinliang Liu Reviewed-by: Sam Ravnborg Signed-off-by: Xu YiPing [jstultz: Reworded commit message] Signed-off-by: John Stultz --- v5: checkpatch --strict whitespace fixups noticed by Sam --- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 125 ---------------- .../gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 141 ++++++++++++++++-- .../gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 5 - 3 files changed, 129 insertions(+), 142 deletions(-) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index bbdfeac946a7..73cd28a6ea07 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -53,13 +53,6 @@ struct ade_hw_ctx { struct drm_crtc *crtc; }; -struct ade_data { - struct kirin_crtc crtc; - struct kirin_plane planes[ADE_CH_NUM]; - struct ade_hw_ctx *hw_ctx; -}; - -/* ade-format info: */ static const struct kirin_format ade_formats[] = { /* 16bpp RGB: */ { DRM_FORMAT_RGB565, ADE_RGB_565 }, @@ -571,36 +564,6 @@ static const struct drm_crtc_funcs ade_crtc_funcs = { .disable_vblank = ade_crtc_disable_vblank, }; -static int kirin_drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, - struct drm_plane *plane, - const struct kirin_drm_data *driver_data) -{ - struct device_node *port; - int ret; - - /* set crtc port so that - * drm_of_find_possible_crtcs call works - */ - port = of_get_child_by_name(dev->dev->of_node, "port"); - if (!port) { - DRM_ERROR("no port node found in %pOF\n", dev->dev->of_node); - return -EINVAL; - } - of_node_put(port); - crtc->port = port; - - ret = drm_crtc_init_with_planes(dev, crtc, plane, NULL, - driver_data->crtc_funcs, NULL); - if (ret) { - DRM_ERROR("failed to init crtc.\n"); - return ret; - } - - drm_crtc_helper_add(crtc, driver_data->crtc_helper_funcs); - - return 0; -} - static void ade_rdma_set(void __iomem *base, struct drm_framebuffer *fb, u32 ch, u32 y, u32 in_h, u32 fmt) { @@ -893,28 +856,6 @@ static struct drm_plane_funcs ade_plane_funcs = { .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, }; -static int kirin_drm_plane_init(struct drm_device *dev, - struct kirin_plane *kplane, - enum drm_plane_type type, - const struct kirin_drm_data *driver_data) -{ - int ret = 0; - - ret = drm_universal_plane_init(dev, &kplane->base, 1, - driver_data->plane_funcs, - driver_data->channel_formats, - driver_data->channel_formats_cnt, - NULL, type, NULL); - if (ret) { - DRM_ERROR("fail to init plane, ch=%d\n", kplane->ch); - return ret; - } - - drm_plane_helper_add(&kplane->base, driver_data->plane_helper_funcs); - - return 0; -} - static void *ade_hw_ctx_alloc(struct platform_device *pdev, struct drm_crtc *crtc) { @@ -984,73 +925,10 @@ static void *ade_hw_ctx_alloc(struct platform_device *pdev, return ctx; } -static int ade_drm_init(struct platform_device *pdev) -{ - struct drm_device *dev = platform_get_drvdata(pdev); - struct ade_data *ade; - struct ade_hw_ctx *ctx; - struct kirin_crtc *kcrtc; - struct kirin_plane *kplane; - enum drm_plane_type type; - int prim_plane; - int ret; - u32 ch; - - ade = devm_kzalloc(dev->dev, sizeof(*ade), GFP_KERNEL); - if (!ade) { - DRM_ERROR("failed to alloc ade_data\n"); - return -ENOMEM; - } - - ctx = ade_driver_data.alloc_hw_ctx(pdev, &ade->crtc.base); - if (IS_ERR(ctx)) { - DRM_ERROR("failed to initialize kirin_priv hw ctx\n"); - return -EINVAL; - } - ade->hw_ctx = ctx; - - kcrtc = &ade->crtc; - kcrtc->hw_ctx = ctx; - - /* - * plane init - * TODO: Now only support primary plane, overlay planes - * need to do. - */ - for (ch = 0; ch < ade_driver_data.num_planes; ch++) { - kplane = &ade->planes[ch]; - kplane->ch = ch; - kplane->hw_ctx = ctx; - - if (ch == ade_driver_data.prim_plane) - type = DRM_PLANE_TYPE_PRIMARY; - else - type = DRM_PLANE_TYPE_OVERLAY; - - ret = kirin_drm_plane_init(dev, kplane, type, &ade_driver_data); - if (ret) - return ret; - } - - /* crtc init */ - prim_plane = ade_driver_data.prim_plane; - ret = kirin_drm_crtc_init(dev, &kcrtc->base, - &ade->planes[prim_plane].base, - &ade_driver_data); - if (ret) - return ret; - - return 0; -} - static void ade_hw_ctx_cleanup(void *hw_ctx) { } -static void ade_drm_cleanup(struct platform_device *pdev) -{ -} - static const struct drm_mode_config_funcs ade_mode_config_funcs = { .fb_create = drm_gem_fb_create, .atomic_check = drm_atomic_helper_check, @@ -1098,7 +976,4 @@ struct kirin_drm_data ade_driver_data = { .alloc_hw_ctx = ade_hw_ctx_alloc, .cleanup_hw_ctx = ade_hw_ctx_cleanup, - - .init = ade_drm_init, - .cleanup = ade_drm_cleanup }; diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c index f5df88378591..d3145ae877d7 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c @@ -29,6 +29,130 @@ #include "kirin_drm_drv.h" +#define KIRIN_MAX_PLANE 2 + +struct kirin_drm_private { + struct kirin_crtc crtc; + struct kirin_plane planes[KIRIN_MAX_PLANE]; + void *hw_ctx; +}; + +static int kirin_drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, + struct drm_plane *plane, + const struct kirin_drm_data *driver_data) +{ + struct device_node *port; + int ret; + + /* set crtc port so that + * drm_of_find_possible_crtcs call works + */ + port = of_get_child_by_name(dev->dev->of_node, "port"); + if (!port) { + DRM_ERROR("no port node found in %pOF\n", dev->dev->of_node); + return -EINVAL; + } + of_node_put(port); + crtc->port = port; + + ret = drm_crtc_init_with_planes(dev, crtc, plane, NULL, + driver_data->crtc_funcs, NULL); + if (ret) { + DRM_ERROR("failed to init crtc.\n"); + return ret; + } + + drm_crtc_helper_add(crtc, driver_data->crtc_helper_funcs); + + return 0; +} + +static int kirin_drm_plane_init(struct drm_device *dev, struct drm_plane *plane, + enum drm_plane_type type, + const struct kirin_drm_data *data) +{ + int ret = 0; + + ret = drm_universal_plane_init(dev, plane, 1, data->plane_funcs, + data->channel_formats, + data->channel_formats_cnt, + NULL, type, NULL); + if (ret) { + DRM_ERROR("fail to init plane, ch=%d\n", 0); + return ret; + } + + drm_plane_helper_add(plane, data->plane_helper_funcs); + + return 0; +} + +static void kirin_drm_private_cleanup(struct drm_device *dev) +{ + struct kirin_drm_private *kirin_priv = dev->dev_private; + struct kirin_drm_data *data; + + data = (struct kirin_drm_data *)of_device_get_match_data(dev->dev); + if (data->cleanup_hw_ctx) + data->cleanup_hw_ctx(kirin_priv->hw_ctx); + + devm_kfree(dev->dev, kirin_priv); + dev->dev_private = NULL; +} + +static int kirin_drm_private_init(struct drm_device *dev, + const struct kirin_drm_data *driver_data) +{ + struct platform_device *pdev = to_platform_device(dev->dev); + struct kirin_drm_private *kirin_priv; + struct drm_plane *prim_plane; + enum drm_plane_type type; + void *ctx; + int ret; + u32 ch; + + kirin_priv = devm_kzalloc(dev->dev, sizeof(*kirin_priv), GFP_KERNEL); + if (!kirin_priv) { + DRM_ERROR("failed to alloc kirin_drm_private\n"); + return -ENOMEM; + } + + ctx = driver_data->alloc_hw_ctx(pdev, &kirin_priv->crtc.base); + if (IS_ERR(ctx)) { + DRM_ERROR("failed to initialize kirin_priv hw ctx\n"); + return -EINVAL; + } + kirin_priv->hw_ctx = ctx; + + /* + * plane init + * TODO: Now only support primary plane, overlay planes + * need to do. + */ + for (ch = 0; ch < driver_data->num_planes; ch++) { + if (ch == driver_data->prim_plane) + type = DRM_PLANE_TYPE_PRIMARY; + else + type = DRM_PLANE_TYPE_OVERLAY; + ret = kirin_drm_plane_init(dev, &kirin_priv->planes[ch].base, + type, driver_data); + if (ret) + return ret; + kirin_priv->planes[ch].ch = ch; + kirin_priv->planes[ch].hw_ctx = ctx; + } + + /* crtc init */ + prim_plane = &kirin_priv->planes[driver_data->prim_plane].base; + ret = kirin_drm_crtc_init(dev, &kirin_priv->crtc.base, + prim_plane, driver_data); + if (ret) + return ret; + kirin_priv->crtc.hw_ctx = ctx; + dev->dev_private = kirin_priv; + + return 0; +} static int kirin_drm_kms_init(struct drm_device *dev, const struct kirin_drm_data *driver_data) @@ -44,7 +168,7 @@ static int kirin_drm_kms_init(struct drm_device *dev, dev->mode_config.funcs = driver_data->mode_config_funcs; /* display controller init */ - ret = driver_data->init(to_platform_device(dev->dev)); + ret = kirin_drm_private_init(dev, driver_data); if (ret) goto err_mode_config_cleanup; @@ -52,7 +176,7 @@ static int kirin_drm_kms_init(struct drm_device *dev, ret = component_bind_all(dev->dev, dev); if (ret) { DRM_ERROR("failed to bind all component.\n"); - goto err_dc_cleanup; + goto err_private_cleanup; } /* vblank init */ @@ -74,11 +198,10 @@ static int kirin_drm_kms_init(struct drm_device *dev, err_unbind_all: component_unbind_all(dev->dev, dev); -err_dc_cleanup: - driver_data->cleanup(to_platform_device(dev->dev)); +err_private_cleanup: + kirin_drm_private_cleanup(dev); err_mode_config_cleanup: drm_mode_config_cleanup(dev); - return ret; } @@ -89,14 +212,8 @@ static int compare_of(struct device *dev, void *data) static int kirin_drm_kms_cleanup(struct drm_device *dev) { - const struct kirin_drm_data *driver_data; - drm_kms_helper_poll_fini(dev); - - driver_data = of_device_get_match_data(dev->dev); - if (driver_data->cleanup) - driver_data->cleanup(to_platform_device(dev->dev)); - + kirin_drm_private_cleanup(dev); drm_mode_config_cleanup(dev); return 0; diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h index 1663610d2cd8..4d5c05a24065 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h @@ -7,8 +7,6 @@ #ifndef __KIRIN_DRM_DRV_H__ #define __KIRIN_DRM_DRV_H__ -#define MAX_CRTC 2 - #define to_kirin_crtc(crtc) \ container_of(crtc, struct kirin_crtc, base) @@ -53,9 +51,6 @@ struct kirin_drm_data { void *(*alloc_hw_ctx)(struct platform_device *pdev, struct drm_crtc *crtc); void (*cleanup_hw_ctx)(void *hw_ctx); - - int (*init)(struct platform_device *pdev); - void (*cleanup)(struct platform_device *pdev); }; extern struct kirin_drm_data ade_driver_data;