From patchwork Wed Aug 19 11:45:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 247946 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:522:0:0:0:0 with SMTP id h2csp386160ils; Wed, 19 Aug 2020 04:46:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLY/9nRkvFYSsN1aNBv0qVNcbsY7opeqOiqKwxMYCRRF/sIHMVbZKFUS1RNwuK/tt2Gixr X-Received: by 2002:a17:90a:1347:: with SMTP id y7mr3635508pjf.183.1597837588929; Wed, 19 Aug 2020 04:46:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597837588; cv=none; d=google.com; s=arc-20160816; b=cYXaOorKwLm0rq0PTdsAj+UuC8C4wyqPl0A/TfkcEjCWg95d2n2NA8hV2sVHRXB+BK gHv7Y/iCyJDfasikPY9PI+ZRlQFkmbTiUiq61+clNdvYA+wL1iTDWto8ALFNamUScG56 GI4bex4x910IGDROwphQBLurz5fiMQB529GPUaj+31F9qfmGj3kA3kNIRojdm0VJNQXd 7POBV0SquF3C94INbVqFjlKVGZj9Hzrxh6py7HWW45LMWliF0RIFimKdvyJ515Q+jg12 gDyUTSv4TvQYXbPHDfM0QELdsrlXOpt8Gro9EvslrcqX1ydeguqFRk71wv5b1omO0H6v 23Hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:delivered-to; bh=XTXwB/5orx9a62qeztuNwUIx1u4mGMhZR9PplgWD4zA=; b=YJMZSFSRWClzmJqlxG031a9y6TsnK7D7s+OfIs4TUfbKXrQB9qt8SeQ4R1/fad3AFF WIV79Zq8PsxNtgXGYlwmFCdBlDLwEY4JCizhJEFVS3mg5cU1W5w/jHHZI40YyjtoEbAt bkhpMhpwg2ZxxvbXbXTpw02Orx7Z7z7SFO1iTGFK+ASu32KWxcysMDCr1GWYbAlFFhF5 z8ae7WJRpKZ7MN8xlDAnbb0hPWt7+jzEWncmnpak1PYn1CpgxqdlqXw81DIlfSpz4i02 KdWsZAvIyuekaQy7kzRNKnZEZFq4I1Wtg+OiCgSyI6/W9VNCfzrrP+2Swdv23fh3rHTa px6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=default header.b=UPn3TXjW; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id w27si9040618pgl.148.2020.08.19.04.46.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 04:46:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=default header.b=UPn3TXjW; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C005389C19; Wed, 19 Aug 2020 11:46:22 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8EC276E02C for ; Wed, 19 Aug 2020 11:46:21 +0000 (UTC) Received: from mail.kernel.org (ip5f5ad5a3.dynamic.kabel-deutschland.de [95.90.213.163]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 278CB2075E; Wed, 19 Aug 2020 11:46:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597837581; bh=zqNspMux401BCdm+pH7vmh4yZc0oA2hxinQ5YNZNPGQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UPn3TXjWYhmWE7KZaa/M5ggJjamyqh6koKVtwDL3upfa5dNsaquLtvtWIk1wul73h sd1JRUAylh+fA6MH1LMkVtCPUo0/HcakPLHXaT9YFq8l/c/so9qNdB1sxidL7k0/uS PgXfhLcv4uPGDjEN/GbPraxEDtKzztDNe5eRASBk= Received: from mchehab by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1k8MXr-00Eua0-59; Wed, 19 Aug 2020 13:46:19 +0200 From: Mauro Carvalho Chehab To: Greg Kroah-Hartman Subject: [PATCH 02/49] staging: hikey9xx/gpu: port it to work with Kernel v4.9 Date: Wed, 19 Aug 2020 13:45:30 +0200 Message-Id: X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devel@driverdev.osuosl.org, Liwei Cai , Manivannan Sadhasivam , Mauro Carvalho Chehab , Chen Feng , Wanchun Zheng , linuxarm@huawei.com, dri-devel , Xiubin Zhang , Liuyao An , mauro.chehab@huawei.com, linux-kernel@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: John Stultz Update the driver to work with v4.9 kernels Signed-off-by: John Stultz Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/hikey9xx/gpu/dw_drm_dsi.c | 4 +- drivers/staging/hikey9xx/gpu/kirin_dpe_reg.h | 1 + drivers/staging/hikey9xx/gpu/kirin_drm_drv.c | 3 +- drivers/staging/hikey9xx/gpu/kirin_drm_drv.h | 1 + drivers/staging/hikey9xx/gpu/kirin_drm_dss.c | 46 ++++++++----------- .../hikey9xx/gpu/kirin_drm_overlay_utils.c | 7 ++- 6 files changed, 30 insertions(+), 32 deletions(-) -- 2.26.2 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel diff --git a/drivers/staging/hikey9xx/gpu/dw_drm_dsi.c b/drivers/staging/hikey9xx/gpu/dw_drm_dsi.c index 1d1d4f49609c..9871b375416b 100644 --- a/drivers/staging/hikey9xx/gpu/dw_drm_dsi.c +++ b/drivers/staging/hikey9xx/gpu/dw_drm_dsi.c @@ -1079,7 +1079,7 @@ static int dw_drm_encoder_init(struct device *dev, encoder->possible_crtcs = crtc_mask; ret = drm_encoder_init(drm_dev, encoder, &dw_encoder_funcs, - DRM_MODE_ENCODER_DSI); + DRM_MODE_ENCODER_DSI, NULL); if (ret) { DRM_ERROR("failed to init dsi encoder\n"); return ret; @@ -1104,7 +1104,7 @@ static int dsi_host_attach(struct mipi_dsi_host *host, dsi->client[id].lanes = mdsi->lanes; dsi->client[id].format = mdsi->format; dsi->client[id].mode_flags = mdsi->mode_flags; - dsi->client[id].phy_clock = mdsi->phy_clock; + dsi->client[id].phy_clock = 0; DRM_INFO("host attach, client name=[%s], id=%d\n", mdsi->name, id); diff --git a/drivers/staging/hikey9xx/gpu/kirin_dpe_reg.h b/drivers/staging/hikey9xx/gpu/kirin_dpe_reg.h index 61af8ef81878..9fad9ef942bd 100644 --- a/drivers/staging/hikey9xx/gpu/kirin_dpe_reg.h +++ b/drivers/staging/hikey9xx/gpu/kirin_dpe_reg.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include diff --git a/drivers/staging/hikey9xx/gpu/kirin_drm_drv.c b/drivers/staging/hikey9xx/gpu/kirin_drm_drv.c index edb690062f64..ffa0cd792bf1 100644 --- a/drivers/staging/hikey9xx/gpu/kirin_drm_drv.c +++ b/drivers/staging/hikey9xx/gpu/kirin_drm_drv.c @@ -200,9 +200,8 @@ static int kirin_drm_connectors_register(struct drm_device *dev) static struct drm_driver kirin_drm_driver = { .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | - DRIVER_ATOMIC | DRIVER_HAVE_IRQ | DRIVER_RENDER, + DRIVER_ATOMIC | DRIVER_RENDER, .fops = &kirin_drm_fops, - .set_busid = drm_platform_set_busid, .gem_free_object = drm_gem_cma_free_object, .gem_vm_ops = &drm_gem_cma_vm_ops, diff --git a/drivers/staging/hikey9xx/gpu/kirin_drm_drv.h b/drivers/staging/hikey9xx/gpu/kirin_drm_drv.h index b361f5f69932..2f842ad36ae9 100644 --- a/drivers/staging/hikey9xx/gpu/kirin_drm_drv.h +++ b/drivers/staging/hikey9xx/gpu/kirin_drm_drv.h @@ -12,6 +12,7 @@ #define __KIRIN_DRM_DRV_H__ #include +#include #include #include #include diff --git a/drivers/staging/hikey9xx/gpu/kirin_drm_dss.c b/drivers/staging/hikey9xx/gpu/kirin_drm_dss.c index 2a92372d0c81..c47d860f4697 100644 --- a/drivers/staging/hikey9xx/gpu/kirin_drm_dss.c +++ b/drivers/staging/hikey9xx/gpu/kirin_drm_dss.c @@ -213,6 +213,7 @@ static void dss_disable_vblank(struct drm_device *dev, unsigned int pipe) static irqreturn_t dss_irq_handler(int irq, void *data) { struct dss_crtc *acrtc = data; + struct drm_crtc *crtc = &acrtc->base; struct dss_hw_ctx *ctx = acrtc->ctx; void __iomem *dss_base = ctx->base; @@ -241,8 +242,10 @@ static irqreturn_t dss_irq_handler(int irq, void *data) wake_up_interruptible_all(&ctx->vactive0_start_wq); } - if (isr_s2 & BIT_VSYNC) + if (isr_s2 & BIT_VSYNC) { ctx->vsync_timestamp = ktime_get(); + drm_crtc_handle_vblank(crtc); + } if (isr_s2 & BIT_LDI_UNFLOW) { mask = inp32(dss_base + DSS_LDI0_OFFSET + LDI_CPU_ITF_INT_MSK); @@ -271,6 +274,7 @@ static void dss_crtc_enable(struct drm_crtc *crtc) } acrtc->enable = true; + drm_crtc_vblank_on(crtc); } static void dss_crtc_disable(struct drm_crtc *crtc) @@ -282,13 +286,7 @@ static void dss_crtc_disable(struct drm_crtc *crtc) /*dss_power_down(acrtc);*/ acrtc->enable = false; -} - -static int dss_crtc_atomic_check(struct drm_crtc *crtc, - struct drm_crtc_state *state) -{ - /* do nothing */ - return 0; + drm_crtc_vblank_off(crtc); } static void dss_crtc_mode_set_nofb(struct drm_crtc *crtc) @@ -315,13 +313,24 @@ static void dss_crtc_atomic_flush(struct drm_crtc *crtc, struct drm_crtc_state *old_state) { + struct drm_pending_vblank_event *event = crtc->state->event; + + if (event) { + crtc->state->event = NULL; + + spin_lock_irq(&crtc->dev->event_lock); + if (drm_crtc_vblank_get(crtc) == 0) + drm_crtc_arm_vblank_event(crtc, event); + else + drm_crtc_send_vblank_event(crtc, event); + spin_unlock_irq(&crtc->dev->event_lock); + } } static const struct drm_crtc_helper_funcs dss_crtc_helper_funcs = { .enable = dss_crtc_enable, .disable = dss_crtc_disable, - .atomic_check = dss_crtc_atomic_check, .mode_set_nofb = dss_crtc_mode_set_nofb, .atomic_begin = dss_crtc_atomic_begin, .atomic_flush = dss_crtc_atomic_flush, @@ -357,7 +366,7 @@ static int dss_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, crtc->port = port; ret = drm_crtc_init_with_planes(dev, crtc, plane, NULL, - &dss_crtc_funcs); + &dss_crtc_funcs, NULL); if (ret) { DRM_ERROR("failed to init crtc.\n"); return ret; @@ -369,19 +378,6 @@ static int dss_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, return 0; } -static int dss_plane_prepare_fb(struct drm_plane *plane, - const struct drm_plane_state *new_state) -{ - /* do nothing */ - return 0; -} - -static void dss_plane_cleanup_fb(struct drm_plane *plane, - const struct drm_plane_state *old_state) -{ - /* do nothing */ -} - static int dss_plane_atomic_check(struct drm_plane *plane, struct drm_plane_state *state) { @@ -441,8 +437,6 @@ static void dss_plane_atomic_disable(struct drm_plane *plane, } static const struct drm_plane_helper_funcs dss_plane_helper_funcs = { - .prepare_fb = dss_plane_prepare_fb, - .cleanup_fb = dss_plane_cleanup_fb, .atomic_check = dss_plane_atomic_check, .atomic_update = dss_plane_atomic_update, .atomic_disable = dss_plane_atomic_disable, @@ -471,7 +465,7 @@ static int dss_plane_init(struct drm_device *dev, struct dss_plane *aplane, return ret; ret = drm_universal_plane_init(dev, &aplane->base, 1, &dss_plane_funcs, - fmts, fmts_cnt, type); + fmts, fmts_cnt, type, NULL); if (ret) { DRM_ERROR("fail to init plane, ch=%d\n", aplane->ch); return ret; diff --git a/drivers/staging/hikey9xx/gpu/kirin_drm_overlay_utils.c b/drivers/staging/hikey9xx/gpu/kirin_drm_overlay_utils.c index 98ab748b8d8e..095335eba16d 100644 --- a/drivers/staging/hikey9xx/gpu/kirin_drm_overlay_utils.c +++ b/drivers/staging/hikey9xx/gpu/kirin_drm_overlay_utils.c @@ -1117,7 +1117,7 @@ void hisi_fb_pan_display(struct drm_plane *plane) dss_rect_ltrb_t rect; u32 bpp; u32 stride; - u32 display_addr; + u32 display_addr = 0; u32 hal_fmt; int chn_idx = DSS_RCHN_D2; @@ -1138,7 +1138,10 @@ void hisi_fb_pan_display(struct drm_plane *plane) bpp = fb->bits_per_pixel / 8; stride = fb->pitches[0]; - display_addr = (u32)fbdev->smem_start + src_y * stride; + if (fbdev) + display_addr = (u32)fbdev->smem_start + src_y * stride; + else + printk("JDB: fbdev is null?\n"); rect.left = 0; rect.right = src_w - 1;