From patchwork Wed Aug 14 18:46:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171349 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1203408ily; Wed, 14 Aug 2019 11:47:38 -0700 (PDT) X-Received: by 2002:a17:90a:a013:: with SMTP id q19mr1090915pjp.64.1565808458342; Wed, 14 Aug 2019 11:47:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565808458; cv=none; d=google.com; s=arc-20160816; b=GD1+fGwdlEsuYp9Q42+XXB5CSsfi17C6x8uQwvgQn+BJhhTqWbz73Zkyn0s4Folb8N Q5Bay6860Cc1oxKHygZ3nxBRyGbfDDNR/CzwaETgLjEjkSxDutgWyGsENG985QWRayi5 PGreX6Y6zTYiBeffVtyLF/iQIdEHnycI4ivY/bI6gpWziYpne9Ijy+2+SZvr1HmKGiDd ybRIFpRvK7rTVRsQxA69tuA1uCA1EOg5sf3kgVgyz4n8va14aTiK+/18MIatuuiCKxOk AmnTTAdH/d2XWQITDyO4iYmzFxk5fU25C0A8bfILoQK5tvDDU4hgSs3/++eUKduoHz/B H/0g== 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=IPzeQ2CUMdGC3xubSflSEVQzVTUBARkxSdnQGwtck+A=; b=fgoiNEipcsg1Fxb960IJLZnqXLbKfJzLiGBkn6An5LsS4WLKjDawtE/vcb5JPsG5Zh 5mOdiJfvIz35ppGsz9xb1Kk1Y4hb3gwI5ltaUkGaYm5mJfIo8g/89tEODjjEtZrl3/ZY 8FeWbhkFtl/YcLWi61L73XtsIcTl23t61/lSwmtUDwkIuYMO3ZXxioC94UeyktN7Jbuz Bwl8UWaigrQgbYf64L7REDiuTgli3RfcuLcloFwAr9d1TBgiAlXPKzs5lniYGULEzITm 3UoFDGEu2x+qX3Q62O6K3iYDRyzTOGj4SOokqRUDr9RO4AqS29pcaBexKNsGHvHE60Cu /s3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JhJS6h06; 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 f1sor741430plt.64.2019.08.14.11.47.38 for (Google Transport Security); Wed, 14 Aug 2019 11:47: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=JhJS6h06; 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=IPzeQ2CUMdGC3xubSflSEVQzVTUBARkxSdnQGwtck+A=; b=JhJS6h06u1B9jqFTOn+CwQRoRUhrXNN3KxxzVeQC7MMbPEdCS3hf1OVLyf50PTvtjX Eavd8K17SGQWSqK/F6ko5GtkXtkbqdtRPqFJD2SRDSr6nHwiE7/t066G51Pep8u22D/8 KEL/25qrR/NG9tHTc8YmDvdM1JHd5w5asBezd/WNJwXB5uL0JldYKePpWjHmBU++U2UU Yp1Ki2xdTwnLaWHKWLuBvTKq3/D6Iy+vq1kBeg2GuuKIZ9TRC1VbLffKG6PFz66LVrDZ aoe6oWl54tOmU380QHfX/wb/WRGhESj0FRQJUGyOLWXM6GDHPNvMhgU/npBdk9uQbJHT ZLug== 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=IPzeQ2CUMdGC3xubSflSEVQzVTUBARkxSdnQGwtck+A=; b=mGfJ402C8ys2lMdcH6HiGzWeGvWGH03wtocHJ8mvb5QpEb/i8FLlGOmn0RzXq1QenD pCquBvmK/BVZWWUe5hpj3ZbOJBZhEJ56z6O6MD+bWttjPRFY5BdITYrm+Iuep0BMKqbp tWuQWF/PhzFQcC5DDhKGgbcBoEsNp4OV1UUXYdVkjCBprvjWw9XcY3fCiSvkvcU1HcpR rEYWC4r/7qGk60ltl/YolKwvPjIqAg2aLchuGJ97cz02Bb3pfqj9OvhC7ZTAEM0DV1qi mWDpToSgKYhmjeJZTK/PFCYlJi1uwcG/I2ibjWBT8QqDe/l5X+VSvWn2Qv9mpy8wbDy9 i41w== X-Gm-Message-State: APjAAAXz/GuqhF8U7IkWSrn8zyzk2Qh6NUnsK/G1hNiYsLF0x08FYRQO 7GBVZnHGJXZ2J+rfQVcunPfAdRTyd7+ORg== X-Google-Smtp-Source: APXvYqyUK1+R0//fvavu46QlOZxKHVtICulhldBFx7PuI83uF7+77CJwZapDfZcjU0OKXdcrz1x87g== X-Received: by 2002:a17:902:1107:: with SMTP id d7mr778830pla.184.1565808457932; Wed, 14 Aug 2019 11:47:37 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id y16sm610855pfc.36.2019.08.14.11.47.36 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 14 Aug 2019 11:47: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: [RESEND][PATCH v3 20/26] drm: kirin: Add register connect helper functions in drm init Date: Wed, 14 Aug 2019 18:46:56 +0000 Message-Id: <20190814184702.54275-21-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190814184702.54275-1-john.stultz@linaro.org> References: <20190814184702.54275-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 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(+) -- 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 0bc2e538913b..66434c0cce6e 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -1076,6 +1076,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 296661ba300f..1c9658e9565e 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c @@ -97,6 +97,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; @@ -116,8 +150,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;