From patchwork Tue May 24 10:39:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12859966 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 49646C433F5 for ; Tue, 24 May 2022 10:40:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A64FC10F4DF; Tue, 24 May 2022 10:40:34 +0000 (UTC) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2E04610F4DF; Tue, 24 May 2022 10:40:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1653388833; x=1684924833; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CLMMGfqQw+LqplHZ+nvlRtkLb7Vb1hLYrmsom04awX4=; b=oEhUThLvCf63hjFp6bXwCJwC4V44j3MfOdJu0BmL/wg3Bd/ZCK0xxJ1x rTUsH5rOA4V/evtsJdB4CvAsSQhCRg/w666YFSAHt9sA9aCSKZTe/0jtc f8WfW2BC3FohJeWzE8IJOJHuNBW9MkKxiPFH1qHZsyumbRAMenVCh7uf/ NNrkUlPFiYhuLRuXQuyYxdL0wXIqA9idRkAFZJTDRNMJkfMrxa4TqZG68 8aLweMbKTtywTCgbIzWPFPxUcbDPfzYue3pVR/PA48ouHWtdj1MPcy338 p9iZ2HM9atXTqM7tb3YpQwYuq8KVCSOrsRAiQdJnXVrrY6ogAQCco8kKK A==; X-IronPort-AV: E=McAfee;i="6400,9594,10356"; a="261101200" X-IronPort-AV: E=Sophos;i="5.91,248,1647327600"; d="scan'208";a="261101200" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2022 03:40:32 -0700 X-IronPort-AV: E=Sophos;i="5.91,248,1647327600"; d="scan'208";a="548412038" Received: from zychseba-mobl.ger.corp.intel.com (HELO localhost) ([10.249.136.104]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2022 03:40:29 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Date: Tue, 24 May 2022 13:39:28 +0300 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v1 06/13] drm/probe-helper: make .get_modes() optional, add default action X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jani.nikula@intel.com, David Airlie Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Add default action when .get_modes() not set. This also defines what a .get_modes() hook should do. Cc: David Airlie Cc: Daniel Vetter Signed-off-by: Jani Nikula --- drivers/gpu/drm/drm_probe_helper.c | 14 +++++++++++++- include/drm/drm_modeset_helper_vtables.h | 4 ++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c index 836bcd5b4cb6..9df17f0ae225 100644 --- a/drivers/gpu/drm/drm_probe_helper.c +++ b/drivers/gpu/drm/drm_probe_helper.c @@ -360,7 +360,19 @@ static int drm_helper_probe_get_modes(struct drm_connector *connector) connector->helper_private; int count; - count = connector_funcs->get_modes(connector); + if (connector_funcs->get_modes) { + count = connector_funcs->get_modes(connector); + } else { + const struct drm_edid *drm_edid; + + /* Note: This requires connector->ddc is set */ + drm_edid = drm_edid_read(connector); + + /* Update modes etc. from the EDID */ + count = drm_edid_connector_update(connector, drm_edid); + + drm_edid_free(drm_edid); + } /* * Fallback for when DDC probe failed in drm_get_edid() and thus skipped diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h index fafa70ac1337..b4402bc64e57 100644 --- a/include/drm/drm_modeset_helper_vtables.h +++ b/include/drm/drm_modeset_helper_vtables.h @@ -894,6 +894,10 @@ struct drm_connector_helper_funcs { * libraries always call this with the &drm_mode_config.connection_mutex * held. Because of this it's safe to inspect &drm_connector->state. * + * This callback is optional. By default, it reads the EDID using + * drm_edid_read() and updates the connector display info, modes, and + * properties using drm_edid_connector_update(). + * * RETURNS: * * The number of modes added by calling drm_mode_probed_add().