Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp422970lqb; Fri, 24 May 2024 02:35:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXrus2dfdOSJsoYxbTzPKkqDqCiYWwdCnsvemRn6N4m+31ftl+lxZ9LqZXq97qL4s2Lz64yiLccrdm/C8gUlGd0CSnlPdLms61VkcCMBg== X-Google-Smtp-Source: AGHT+IFrf0HRsDMwJpuFNW7HiYUsHpWUqAdM+iEVSvNEWKCBhoaoI/4QBZxU+tiBXlKLH6Aqa0mP X-Received: by 2002:a17:906:339b:b0:a62:28ce:4e98 with SMTP id a640c23a62f3a-a62642e96camr106529166b.23.1716543342104; Fri, 24 May 2024 02:35:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716543342; cv=pass; d=google.com; s=arc-20160816; b=IjZHnoaUAd2x3HqmUgp/byNm+XTN+CE+XqBWJ6bvbDqFkJ+yc8GYyf8QCGmj/zGzyH xgzsEvQhPqMGpOykn8P3AWUl3dmWgZf4ZuHcny7E6AKPRhZ8Ve1J4aWcz9v4ZwdmQuui x/KYPArlGLNaOUWSf91CGaecp9r/Go9xW1OjcoRhkIpvqt/2mhgwbV5R/vLxiUE8ydl0 jOt9aCBd+x0PciF5DXbx1I2itl0Aoo1uE4IsmzyH278AjPiYwWDPYjsdS0dcb30D2fwN CIx2TjxkBXmsoinW4lyTRhIS6BYAhdHkEuFIksWz6Po1iUDrsxP0OeqHhwiVLUBrKOnZ IbJA== ARC-Message-Signature: i=2; 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=xGzgAbqslB1rt11Bkclq9cD769C5sYNmcnBRwDPmOQg=; fh=Uq66CT/HgOh+vaL5Ml5wdwssk2XkMfmyTbY+C42W2Fg=; b=V3Y3+naltuGKRNocmvFMRo6V2MsXS8/P46pW4VcsnAiVRloUaK2aD8BjaW+8tchTwP fAZ0GDy+9E+J5umKYGhm1DDqfUbwDJwjJvLE9q/jVakOSRVtE6Esrd6MrwVXvsftAfyF UKLqXya20lorKBWEMdTWyfJ78YCWu4nZNyCklzkj8zgBsQTXuwyyfe2+dLflzzKQ1Y25 Ala/1kwo6XALVVGXJB8JGU+nhHIjqCYQG5szz66Z1heNlP25xJ136KGhOkCfLDLifV6a uVd8znTitAeS7gkQ39WiTrpeftad331k2K2oltV+4Mf1Pz6odzumueM3vgj9dMGhJ3w5 8dGA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="sU/8zD5i"; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-188559-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-188559-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a626cc371f7si62219666b.386.2024.05.24.02.35.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 02:35:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-188559-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="sU/8zD5i"; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-188559-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-188559-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.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 am.mirrors.kernel.org (Postfix) with ESMTPS id CFA1C1F21F55 for ; Fri, 24 May 2024 09:35:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6C23F8562A; Fri, 24 May 2024 09:35:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="sU/8zD5i" Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) (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 DB5C084DEB for ; Fri, 24 May 2024 09:35:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.248 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716543332; cv=none; b=Yy67jEZBUcl8UE6HEdGyd1NJbg0QZh6HH+UU7oWZKmJnuJT6wtlULe42XvHVVTDLWBIeegn2jeVL3XySPRi9dHJSdLgVTmZwdccXcHkc06qldymzv2O4ropSKi3ig4gSvNPOEPojjuj9+DDc8D3nlabUr7iM2E318TTr72v5f8E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716543332; c=relaxed/simple; bh=xou/nOnXg0A3IRSSC6/T3yakPoTkz54RXu29mdoRMug=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SrGDQ63JSmeNjJbLk9AA5m+pO9WVUZgF+fmF7X6uvtob330GTt1bl0GnYG6MOTlGNv2QIYMpPcChUa+aYekktjvbGWaNTXZrQ2R3kA7HJvD4x9Ie8Pqu90jun3KF3bKy6Gyfd4WmZy1+t1es262PmYQMCKGKgEWmLIWUJEXaaKM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=sU/8zD5i; arc=none smtp.client-ip=198.47.23.248 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 44O9ZDEn038389; Fri, 24 May 2024 04:35:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1716543313; bh=xGzgAbqslB1rt11Bkclq9cD769C5sYNmcnBRwDPmOQg=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=sU/8zD5ieCISKoGlXHigATk6t5vD3/6/ZSQZ7Vj8Flp2dzJJP7raBsjIBQQNOjjxd ieQzLe84t/5O4jUSfoYVkfN9yP3mNj5HPBuCHOY8RNflTR/gbHSLa+D5esmZ1YXA8O gbT1xJncXllNMHIEseYmIv1dPsx9zgsMClEzqzEM= Received: from DFLE103.ent.ti.com (dfle103.ent.ti.com [10.64.6.24]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 44O9ZDkL023841 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 24 May 2024 04:35:13 -0500 Received: from DFLE105.ent.ti.com (10.64.6.26) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 24 May 2024 04:35:12 -0500 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 24 May 2024 04:35:12 -0500 Received: from localhost (jayesh-hp-probook-440-g8-notebook-pc.dhcp.ti.com [172.24.227.102] (may be forged)) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 44O9ZBjt060484; Fri, 24 May 2024 04:35:12 -0500 From: Jayesh Choudhary To: , , , , , , , , CC: , , , , , , Subject: [PATCH v3 1/2] drm/bridge: sii902x: Fix mode_valid hook Date: Fri, 24 May 2024 15:05:08 +0530 Message-ID: <20240524093509.127189-2-j-choudhary@ti.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240524093509.127189-1-j-choudhary@ti.com> References: <20240524093509.127189-1-j-choudhary@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Currently, mode_valid hook returns all mode as valid and it is defined only in drm_connector_helper_funcs. With the introduction of 'DRM_BRIDGE_ATTACH_NO_CONNECTOR', connector is not initialized in bridge_attach call for cases when the encoder has this flag enabled. So add the mode_valid hook in drm_bridge_funcs as well with proper clock checks for maximum and minimum pixel clock supported by the bridge. Signed-off-by: Jayesh Choudhary --- drivers/gpu/drm/bridge/sii902x.c | 37 ++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c index 2fbeda9025bf..bae551e107f9 100644 --- a/drivers/gpu/drm/bridge/sii902x.c +++ b/drivers/gpu/drm/bridge/sii902x.c @@ -163,6 +163,14 @@ #define SII902X_AUDIO_PORT_INDEX 3 +/* + * The maximum resolution supported by the HDMI bridge is 1080p@60Hz + * and 1920x1200 requiring a pixel clock of 165MHz and the minimum + * resolution supported is 480p@60Hz requiring a pixel clock of 25MHz + */ +#define SII902X_MIN_PIXEL_CLOCK_KHZ 25000 +#define SII902X_MAX_PIXEL_CLOCK_KHZ 165000 + struct sii902x { struct i2c_client *i2c; struct regmap *regmap; @@ -310,12 +318,26 @@ static int sii902x_get_modes(struct drm_connector *connector) return num; } +static enum +drm_mode_status sii902x_validate(struct sii902x *sii902x, + const struct drm_display_mode *mode) +{ + if (mode->clock < SII902X_MIN_PIXEL_CLOCK_KHZ) + return MODE_CLOCK_LOW; + + if (mode->clock > SII902X_MAX_PIXEL_CLOCK_KHZ) + return MODE_CLOCK_HIGH; + + return MODE_OK; +} + static enum drm_mode_status sii902x_mode_valid(struct drm_connector *connector, struct drm_display_mode *mode) { - /* TODO: check mode */ + struct sii902x *sii902x = connector_to_sii902x(connector); + const struct drm_display_mode *mod = mode; - return MODE_OK; + return sii902x_validate(sii902x, mod); } static const struct drm_connector_helper_funcs sii902x_connector_helper_funcs = { @@ -504,6 +526,16 @@ static int sii902x_bridge_atomic_check(struct drm_bridge *bridge, return 0; } +static enum drm_mode_status +sii902x_bridge_mode_valid(struct drm_bridge *bridge, + const struct drm_display_info *info, + const struct drm_display_mode *mode) +{ + struct sii902x *sii902x = bridge_to_sii902x(bridge); + + return sii902x_validate(sii902x, mode); +} + static const struct drm_bridge_funcs sii902x_bridge_funcs = { .attach = sii902x_bridge_attach, .mode_set = sii902x_bridge_mode_set, @@ -516,6 +548,7 @@ static const struct drm_bridge_funcs sii902x_bridge_funcs = { .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state, .atomic_get_input_bus_fmts = sii902x_bridge_atomic_get_input_bus_fmts, .atomic_check = sii902x_bridge_atomic_check, + .mode_valid = sii902x_bridge_mode_valid, }; static int sii902x_mute(struct sii902x *sii902x, bool mute) -- 2.25.1