From patchwork Tue Jan 12 08:43:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 12012767 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C59DC433E0 for ; Tue, 12 Jan 2021 08:44:32 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CD07A22E01 for ; Tue, 12 Jan 2021 08:44:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD07A22E01 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 53E5B6E14C; Tue, 12 Jan 2021 08:44:24 +0000 (UTC) Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by gabe.freedesktop.org (Postfix) with ESMTPS id EAF296E140 for ; Tue, 12 Jan 2021 08:44:21 +0000 (UTC) Received: by mail-wr1-x42c.google.com with SMTP id m4so183879wrx.9 for ; Tue, 12 Jan 2021 00:44:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yONOghH9XKfLdBbsmYmcUxNvyur91GJ2/vGJcIXVS2A=; b=PoT046FNG5xSUSGcsjxzXSKX86PLBicvfz/PdwsHrKAAHmV2mWX3fiiDT6m9fekijO fYANU07h2xJ1T6VnkXxqbwsIHQI+Qg9EJFA0MHLIRb5QvVvSdEIkJzS5XgBoBgaVuLaN LX58DtuxULaja5T03oTNd5u/uG+SJVdH2GIMA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yONOghH9XKfLdBbsmYmcUxNvyur91GJ2/vGJcIXVS2A=; b=bjAaeLgAHHmo9LiZMQtzPvHqY2RJDdsdNQP9DD/52gNX2VCt9nyaAQ4K/rYh2KaE+D hsx++uD1aM+umY5kUlyId/VceEwOVvkHufgLv21IRGAAPumEoMQ1fQybLGgk/ZBicPoy cIWr/Ta1ZwhIITD+NWjF74me5HfW3pG7sU7s5If8r4njbY/dhgxguvK1uiW3G/F8oRbT 8GPBT3uRPnYGE75POGeYS+ZUu/ohvtH/2jiLHjb37rhauZgL1dMgDHOdmLyZu2PFn9/y fuhUFj8amKU3ALPg884ZPbzclLVjorjbAC1sgnL7JYh2NXY1wSQyqQVvlPvVEXyoXg1P naow== X-Gm-Message-State: AOAM530AcyDvFTqvu06qqbM+uCrwmJytxHT26eorZuHdo/1vbeSFWFwK QRshbw26cnHNabJW8e4bLtoK86vyQX5FrV4N X-Google-Smtp-Source: ABdhPJzZ+LgZLVjC1A3IxUWd2nWIx8u4UqJGEGBTN42o1LDzib0ZlDqMc6IPNiDuDJ1eHbgG77LgbQ== X-Received: by 2002:adf:e552:: with SMTP id z18mr3181887wrm.29.1610441060416; Tue, 12 Jan 2021 00:44:20 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id j15sm3707017wrr.85.2021.01.12.00.44.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jan 2021 00:44:19 -0800 (PST) From: Daniel Vetter To: DRI Development Subject: [PATCH 14/15] drm/arc: Initialize sim connector before display pipe Date: Tue, 12 Jan 2021 09:43:57 +0100 Message-Id: <20210112084358.2771527-14-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210112084358.2771527-1-daniel.vetter@ffwll.ch> References: <20210112084358.2771527-1-daniel.vetter@ffwll.ch> 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: Sam Ravnborg , Alexey Brodkin , Daniel Vetter , Daniel Vetter , tiantao6@hisilicon.com, Eugeniy Paltsev Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" That way we can get rid of this final piece of init code, and use the simple pipe helpers as intended. v2: Fix indent (Sam) Acked-by: Sam Ravnborg Cc: Eugeniy Paltsev Signed-off-by: Daniel Vetter Cc: Alexey Brodkin --- drivers/gpu/drm/arc/arcpgu_drv.c | 53 ++++++++++---------------------- 1 file changed, 17 insertions(+), 36 deletions(-) diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c index 0a0b54993773..8edfe6601151 100644 --- a/drivers/gpu/drm/arc/arcpgu_drv.c +++ b/drivers/gpu/drm/arc/arcpgu_drv.c @@ -95,32 +95,11 @@ static const struct drm_connector_funcs arcpgu_drm_connector_funcs = { .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, }; -static int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np) +static int arcpgu_drm_sim_init(struct drm_device *drm, struct drm_connector *connector) { - struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm); - struct drm_encoder *encoder; - struct drm_connector *connector; - int ret; - - encoder = &arcpgu->pipe.encoder; - - connector = &arcpgu->sim_conn; drm_connector_helper_add(connector, &arcpgu_drm_connector_helper_funcs); - - ret = drm_connector_init(drm, connector, &arcpgu_drm_connector_funcs, - DRM_MODE_CONNECTOR_VIRTUAL); - if (ret < 0) { - dev_err(drm->dev, "failed to initialize drm connector\n"); - return ret; - } - - ret = drm_connector_attach_encoder(connector, encoder); - if (ret < 0) { - dev_err(drm->dev, "could not attach connector to encoder\n"); - return ret; - } - - return 0; + return drm_connector_init(drm, connector, &arcpgu_drm_connector_funcs, + DRM_MODE_CONNECTOR_VIRTUAL); } #define ENCODE_PGU_XY(x, y) ((((x) - 1) << 16) | ((y) - 1)) @@ -267,6 +246,7 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu) { struct platform_device *pdev = to_platform_device(arcpgu->drm.dev); struct device_node *encoder_node = NULL, *endpoint_node = NULL; + struct drm_connector *connector = NULL; struct drm_device *drm = &arcpgu->drm; struct resource *res; int ret; @@ -301,13 +281,6 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu) if (dma_set_mask_and_coherent(drm->dev, DMA_BIT_MASK(32))) return -ENODEV; - ret = drm_simple_display_pipe_init(drm, &arcpgu->pipe, &arc_pgu_pipe_funcs, - arc_pgu_supported_formats, - ARRAY_SIZE(arc_pgu_supported_formats), - NULL, NULL); - if (ret) - return ret; - /* * There is only one output port inside each device. It is linked with * encoder endpoint. @@ -316,8 +289,21 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu) if (endpoint_node) { encoder_node = of_graph_get_remote_port_parent(endpoint_node); of_node_put(endpoint_node); + } else { + connector = &arcpgu->sim_conn; + dev_info(drm->dev, "no encoder found. Assumed virtual LCD on simulation platform\n"); + ret = arcpgu_drm_sim_init(drm, connector); + if (ret < 0) + return ret; } + ret = drm_simple_display_pipe_init(drm, &arcpgu->pipe, &arc_pgu_pipe_funcs, + arc_pgu_supported_formats, + ARRAY_SIZE(arc_pgu_supported_formats), + NULL, connector); + if (ret) + return ret; + if (encoder_node) { struct drm_bridge *bridge; @@ -329,11 +315,6 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu) ret = drm_simple_display_pipe_attach_bridge(&arcpgu->pipe, bridge); if (ret) return ret; - } else { - dev_info(drm->dev, "no encoder found. Assumed virtual LCD on simulation platform\n"); - ret = arcpgu_drm_sim_init(drm, NULL); - if (ret < 0) - return ret; } drm_mode_config_reset(drm);