From patchwork Mon Aug 19 23:03: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: 171754 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp3596658ily; Mon, 19 Aug 2019 16:04:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqx6Ub8CmXDKPedVIXPvpbXhC593GmvfKsSxD4LhbisjKj/x34PHQfTwITElk1G+XpZDfJC5 X-Received: by 2002:a63:5f01:: with SMTP id t1mr20161851pgb.200.1566255862736; Mon, 19 Aug 2019 16:04:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566255862; cv=none; d=google.com; s=arc-20160816; b=ivK0LqDAHna8YOxyxxLiJ6GYcR8f9PYE003kKROkgoS/Wg409Wbh9gaF9WEJXtSYj5 sUVr2bCHzikLoynGN74+j0W94be9DGLQ3nXttFax1EXiHCBV3T2nG+EqV3cFXITDiJlD u4/MxOaKBgJX7kklQ6xVDmVFV0Jq8MVPDDikX4v65mNGcV5/ap53jbd31drEejekRyno bTMyWKszT1CfGxYG3hsCsCDVTTQNvzbN7GibmGPvu62wBEM5aJYC8LUZVXFB/vu1963s 65z1mc+t5rTEzbim+6YaaeeFa3SwBghexwgozeDpYO9ozIni+kGJlcCZ9sj9XCvSjxWb 38YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:delivered-to; bh=86YSkkrXZjVBiZLLkGdeiz0GaKj2K4J7xs3y9YU7LBQ=; b=T+hznNbmGXm6OsQPFFhn8byiLCDBUwowKSsLvxd/XhSEMkHiXndfvgFr0jogubG2GH sSj6m3XsmBPQ9K3e61cCJOWeBGPvJ9ssC8NvPhh/nV68SYeS3vSAWVHa9ddkBhmbiPsp iDhdXrxqH7UhE0IKXY/6GRXJTV+rjvvSoPKL23LG425+BdrUI63afCTKjCS7exrDuR/f yyAEpnsZvdisAVBvBEbcQIen54aoAPje2sjerBv9f+UDn8f3tbyTHYEddXa8QQT1sbbm v+sChhOSFHcDSQzkZeeYD0wZ32K9n9eRVPclGVk4nCs/fCr8gdMpGVjNhspmxH8HgB4U 1bmw== ARC-Authentication-Results: i=1; mx.google.com; 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=linaro.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 205si10701944pge.295.2019.08.19.16.04.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 19 Aug 2019 16:04:22 -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; 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=linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8D8306E48C; Mon, 19 Aug 2019 23:04:18 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7788F6E47C for ; Mon, 19 Aug 2019 23:03:55 +0000 (UTC) Received: by mail-pf1-x444.google.com with SMTP id w2so2084507pfi.3 for ; Mon, 19 Aug 2019 16:03:55 -0700 (PDT) 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=RlVlGQamgcAhiognZlubIHGBBs3LgzzJ7vr3338hUrk=; b=tcNb8R9IRkRgZP7U9HG6TfZC+hkS4V2epveQAwE0EySOyYm/YwjQNYf8MclJbPmc+f d+7e09lTggOKFbxlWuC0zBq3VNgQDt2t273dUAK6iW7blB062qzB8KPoRbWrc7CZ+QBR XZvHA33fTGnjV9aVWkFFYDmAD0sb1CMTVcGuvsK/vrTyLI9rCJAuomFdfa7d8pzY8QCW FKcZqpFKJiR9Ol9gXKVsxVcnvOu+kYwKyft1QeQi1S5HhykIgd/e4YbeP9fAkISnPrLi nqUCAw6LzYhY331F5NH7z2EjbDa6HkbJJMQIGAvy/yibHkYR+m+hPDpzsYVAfHAq1mQ9 qDTA== X-Gm-Message-State: APjAAAU3ZqJaYuctwjULfBLx9SVw26V3/1k/jqZU76DfNdzMjpzQ59Ps 5QeN+yKezlWJfp4vyrAqjhKOsQ== X-Received: by 2002:a65:68c9:: with SMTP id k9mr21640940pgt.17.1566255834582; Mon, 19 Aug 2019 16:03:54 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id j15sm17256509pfr.146.2019.08.19.16.03.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2019 16:03:53 -0700 (PDT) From: John Stultz To: lkml Subject: [PATCH v4 19/25] drm: kirin: Add register connect helper functions in drm init Date: Mon, 19 Aug 2019 23:03:15 +0000 Message-Id: <20190819230321.56480-20-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190819230321.56480-1-john.stultz@linaro.org> References: <20190819230321.56480-1-john.stultz@linaro.org> X-Mailman-Original-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=RlVlGQamgcAhiognZlubIHGBBs3LgzzJ7vr3338hUrk=; b=zdBI9UDVng410qTgKzO177OK6M21SecuCMx5uW9MNvjhW524TFUeB9k9c5w0mZVy5U zLP0V/VnGsYqFONggfKgNzdVZxAxkd/KeOgKUGNaPZPYUCKaqTjCch9AUcoRpasoh7rW fpm7qeGXfif9V3pT/mK1bncOkPBlBjvmNypsIub3KZLHRDum8pO4lkRT0boZsgu+892S s3c936HBiT31uDogoYO+7N106UbmGnM+OtLriLAoWGPcUTHkvGKlfKjqSrIgyA0gSgto bSyo+rJFJNC8lj1L8HTFRqjL5uQ1IRdqoljPPCI7T57ph2sby0L4ufwZn5YDetRzjeHN i5Vw== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Xu YiPing , David Airlie , dri-devel , Xinliang Liu , Rongrong Zou , Sam Ravnborg MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 --- .../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(+) diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index 7db2cf93a245..5f39249fd83e 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..f92b3f7de5c0 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 == true) { + 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;