Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6502429rdb; Tue, 2 Jan 2024 04:22:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IFJOwhn+lh9SouQrfFEo5AWdNnbV77eo0kPQ2v2bL0s0X3cXytwKSojG1oCkfJaJnAiElS5 X-Received: by 2002:a17:902:9a06:b0:1d4:a327:f6af with SMTP id v6-20020a1709029a0600b001d4a327f6afmr5811059plp.38.1704198144453; Tue, 02 Jan 2024 04:22:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704198144; cv=none; d=google.com; s=arc-20160816; b=z8c5ABTId1IyX2arWFdiVg/Mq9y5W3qgujXmBms5zVRQbb+syMvviw7PSyD2TC45qN b2AdlQ2GqkHTsSqWD1n+kI7FyhvICMQPG4anra5jlxamm7gjDxX3HXnIEZs3apdCE1sF hCNfug1m9OpxRTWy0HeNG2HNLjPeSewN08spOusdegsOR6IYyuegUPbBPa5OEiefaPN/ p0QbsFzEKTUWkpsQ5bl+avpQ3IzT81VJmYJmqR8+fuC7/t742A+HU5WyNw/ZWnfnDT9O Fhw2VB62hJBJwL2lUGiVb5MuGCEk0PdNRivJn98jZAANq8YFPeSO9jvQTlw5s78y00C2 GzWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=5aXs8fUOsfgSo7g4FENf0GEgJl7/TE420KVs2VRDTFk=; fh=iZqD7tK6bXzmATvcK7jLFBfIu+uTpfMAKLoBfLuWtD0=; b=v1r8vnoOvSmxYdki8m0U8VA1iLIIz20c27WCALPf3/tEdDG1xdZ4VqGjuvMJ2ipWX7 +V02smSH9pV19GA75XRtvX9Qp/H/iOB6hepUst3FhhafzvUKgVcx1hmkM4s/M/Iiwlgw nolDtYRn79vzyYLUNTbnyDaxqPFTn9lSvRo9kuM0cH3F+1fA6FLwZLOcsYgKPhXgfCdD FbPIGUi5k7stVQOFYHXFWGY0LcMgacYJ6wubMX35kjSYmesfadpI7aKcD+ZnpbRb5JuY yrKHE5DKmw8M99w3PaGcVxb8D03Q2STEBCSIR6aZfmGl8ML3HvZ7QyG7X5YWY1Wnx2J8 b7ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZYgqSlEA; spf=pass (google.com: domain of linux-kernel+bounces-14334-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14334-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id w12-20020a170902e88c00b001d4c4bd4bc8si1374941plg.354.2024.01.02.04.22.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 04:22:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14334-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZYgqSlEA; spf=pass (google.com: domain of linux-kernel+bounces-14334-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14334-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 19C50283220 for ; Tue, 2 Jan 2024 12:22:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EAAEBFBF0; Tue, 2 Jan 2024 12:22:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZYgqSlEA" X-Original-To: linux-kernel@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0E18FBE7 for ; Tue, 2 Jan 2024 12:22:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704198137; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=5aXs8fUOsfgSo7g4FENf0GEgJl7/TE420KVs2VRDTFk=; b=ZYgqSlEAx91KUrF65ejZlCVF6MZozKckfYHiGvIouWpWzP0sEZAqkD6j+2Fkoulx6IWWHj rMQpIGpkhwmKkr47lp1y7e668BDr7BHYkMWXnw0nMbF+G9EYolmGTBaH0HO8WoaEv5MAjj 1AJC8hLOF+butRAZbqp+tcWYslg012o= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-439-Rg4wQkEKOSCpXSc9xsn4NQ-1; Tue, 02 Jan 2024 07:22:16 -0500 X-MC-Unique: Rg4wQkEKOSCpXSc9xsn4NQ-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-336937b3cf5so5917198f8f.3 for ; Tue, 02 Jan 2024 04:22:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704198134; x=1704802934; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5aXs8fUOsfgSo7g4FENf0GEgJl7/TE420KVs2VRDTFk=; b=soDxyFNbnw7fffGPPhRmxsCRdP6FeZVYLt0pEd4Nzfr4k/jcCc1PY76zRF8v6kq5jj aHT2FZ1xCSOx5RmJzS/oJ28GHVcGl6GE67OY5mdkZcmWm5Zg/3C4NE6mP2yMItdSUll/ 261gv00siCsqeH1q3/f0MKqU/SFEIAp4+dTXwLL7i/A3RIX33XSVcG2Ihx6evqt0YOxV bVVv8N9EhRO8WO+kEAE+b7FzRgzeet07JXVE0M0i6A+9A+ibEOTrjUjARVahkCVIH3AS aTRW27e++Trw0uHFoBnvXJkzIgDZQlFoDZ731LErOn8AOx0Syn82RblXUQjFTtxipRd2 y36w== X-Gm-Message-State: AOJu0YxRAu5vxSNrLQo/WbkVU0mmjht/k3N2HpeQBh7ryy4XO7od2Bzw xxLspg5hz9ka1fiG4Pp1kSh39DkbO/DtByL+zuYBuT2erklHV2vJ7Ppa2McO5ldzr49oeggLnkN 9KMKVX4Ix3HlCczSFvRz1xBU/D0zF8702Ht81tyIle6pJuYLk7kdcu28KK9WZO7NVdhd/DeCLxo xI3jWN0/lS9NAMuy/tCA== X-Received: by 2002:adf:f58d:0:b0:336:ded0:a21e with SMTP id f13-20020adff58d000000b00336ded0a21emr3259647wro.21.1704198134216; Tue, 02 Jan 2024 04:22:14 -0800 (PST) X-Received: by 2002:adf:f58d:0:b0:336:ded0:a21e with SMTP id f13-20020adff58d000000b00336ded0a21emr3259636wro.21.1704198133875; Tue, 02 Jan 2024 04:22:13 -0800 (PST) Received: from localhost (red-hat-inc.vlan560.asr1.mad1.gblx.net. [159.63.51.90]) by smtp.gmail.com with ESMTPSA id q5-20020a056000136500b003372c080acasm9421283wrz.2.2024.01.02.04.22.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 04:22:13 -0800 (PST) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Jani Nikula , Javier Martinez Canillas , Daniel Vetter , David Airlie , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , dri-devel@lists.freedesktop.org Subject: [PATCH v2] drm: Move drm_set_preferred_mode() helper from drm_edid to drm_modes Date: Tue, 2 Jan 2024 13:21:58 +0100 Message-ID: <20240102122208.3103597-1-javierm@redhat.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The helper is generic, it doesn't use the opaque EDID type struct drm_edid and is also used by drivers that only support non-probeable displays such as fixed panels. These drivers add a list of modes using drm_mode_probed_add() and then set a preferred mode using the drm_set_preferred_mode() helper. It seems more logical to have the helper definition in drm_modes.o instead of drm_edid.o, since the former contains modes helper while the latter has helpers to manage the EDID information. Since both drm_edid.o and drm_modes.o object files are built-in the drm.o object, there are no functional changes. But besides being a more logical place for this helper, it could also allow to eventually make drm_edid.o optional and not included in drm.o if only fixed panels must be supported in a given system. Signed-off-by: Javier Martinez Canillas Reviewed-by: Jani Nikula --- Changes in v2: - Drop unnecessary drm_modes.h header include in drm_edid.c (Jani Nikula). - Add Jani Nikula's Reviewed-by tag. drivers/gpu/drm/drm_edid.c | 22 ---------------------- drivers/gpu/drm/drm_modes.c | 22 ++++++++++++++++++++++ include/drm/drm_edid.h | 2 -- include/drm/drm_modes.h | 2 ++ 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index cb4031d5dcbb..e677dc8eb7a9 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -6989,28 +6989,6 @@ int drm_add_modes_noedid(struct drm_connector *connector, } EXPORT_SYMBOL(drm_add_modes_noedid); -/** - * drm_set_preferred_mode - Sets the preferred mode of a connector - * @connector: connector whose mode list should be processed - * @hpref: horizontal resolution of preferred mode - * @vpref: vertical resolution of preferred mode - * - * Marks a mode as preferred if it matches the resolution specified by @hpref - * and @vpref. - */ -void drm_set_preferred_mode(struct drm_connector *connector, - int hpref, int vpref) -{ - struct drm_display_mode *mode; - - list_for_each_entry(mode, &connector->probed_modes, head) { - if (mode->hdisplay == hpref && - mode->vdisplay == vpref) - mode->type |= DRM_MODE_TYPE_PREFERRED; - } -} -EXPORT_SYMBOL(drm_set_preferred_mode); - static bool is_hdmi2_sink(const struct drm_connector *connector) { /* diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index ac9a406250c5..01aa44e87534 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c @@ -2754,3 +2754,25 @@ bool drm_mode_is_420(const struct drm_display_info *display, drm_mode_is_420_also(display, mode); } EXPORT_SYMBOL(drm_mode_is_420); + +/** + * drm_set_preferred_mode - Sets the preferred mode of a connector + * @connector: connector whose mode list should be processed + * @hpref: horizontal resolution of preferred mode + * @vpref: vertical resolution of preferred mode + * + * Marks a mode as preferred if it matches the resolution specified by @hpref + * and @vpref. + */ +void drm_set_preferred_mode(struct drm_connector *connector, + int hpref, int vpref) +{ + struct drm_display_mode *mode; + + list_for_each_entry(mode, &connector->probed_modes, head) { + if (mode->hdisplay == hpref && + mode->vdisplay == vpref) + mode->type |= DRM_MODE_TYPE_PREFERRED; + } +} +EXPORT_SYMBOL(drm_set_preferred_mode); diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h index 54cc6f04a708..5bd6b6eb6c57 100644 --- a/include/drm/drm_edid.h +++ b/include/drm/drm_edid.h @@ -426,8 +426,6 @@ enum hdmi_quantization_range drm_default_rgb_quant_range(const struct drm_display_mode *mode); int drm_add_modes_noedid(struct drm_connector *connector, int hdisplay, int vdisplay); -void drm_set_preferred_mode(struct drm_connector *connector, - int hpref, int vpref); int drm_edid_header_is_valid(const void *edid); bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid, diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h index c613f0abe9dc..b9bb92e4b029 100644 --- a/include/drm/drm_modes.h +++ b/include/drm/drm_modes.h @@ -467,6 +467,8 @@ bool drm_mode_is_420_also(const struct drm_display_info *display, const struct drm_display_mode *mode); bool drm_mode_is_420(const struct drm_display_info *display, const struct drm_display_mode *mode); +void drm_set_preferred_mode(struct drm_connector *connector, + int hpref, int vpref); struct drm_display_mode *drm_analog_tv_mode(struct drm_device *dev, enum drm_connector_tv_mode mode, -- 2.43.0