Received: by 2002:a05:7208:c250:b0:86:f851:443 with SMTP id w16csp936356rbd; Thu, 13 Jun 2024 01:40:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWeEBQzvtKledWp3dp8sXohjboLmbzgrR91ogCz1g1PtcTcCdglCVfmneROcIAxutBBq+DJL5tvjYWE05iyT+1fbh9fPNkxz+2rtFQSZA== X-Google-Smtp-Source: AGHT+IHnR6hvT9rQTKFPby1YFSKyhY+BKhdozD9yiWIEQOE+whlBF2mV/iEOLyaHXwoMkQfNLOkH X-Received: by 2002:a05:6830:4a3:b0:6fa:2b34:e14d with SMTP id 46e09a7af769-6fa2b34e273mr3859868a34.38.1718268042328; Thu, 13 Jun 2024 01:40:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718268042; cv=pass; d=google.com; s=arc-20160816; b=Kmbq4dcTRS82DcOP3Q28L4VySrBzVrQMv7gWbARyXHBIVEXZ4W7WxN4PhGqkQ7nP68 ygv8qD7zLj2EOytSTecaeDqnIX+MFSD8vBukKVVCbaV+OinQTbw2Q8gRqUW4AbRN8Fnt HZTP6NlJS5Mk1UL1MRg3cx5Rr4pTZwfiRWOzzOijJ4kD7GEWiZ0nnWgPDfWgj1Sv8Ao+ h3EdJgI3oHWMv30xBafOy9fUFTD3cGYVY3IxaTNctMFeCmkoGJx0NgIA4j0zH8sYaHrs HGm1IFeEWj0PvWgR9Lwah/AnYQRPaTWyq9vzXACu8VQKmws+RNlGVTrDiw2Xl9hYAUP/ Q/vQ== 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=BY7OHhQbmNI82hBMi2BWuhYz45KvvtmVf4whs4ZENdk=; fh=t0QNipbJl+LjstaJYccTR8asN890wrUDDAYih3UUEBQ=; b=xAWnFxRl70/i7DvXV02s5ElSYfJg2+ZuXxrUmAxB1Oa+vRW2heelh8vCNp1uAHGRrt iReHlel06Xrej0EO+fGUO42ua2+2NJ1gFc88houJ1xMCvBb7Q1quvbls6ot6pZF972fs OkG7d9YEBVhjqdHGCJMMDMc4OYxvWFsz6hccTyoZkKNGeBaTmVDSdswN8foBZU7fknux N8cX7CpUTrhzMYlqWZujg93Jpo0WumHjGFuOoxQlB67X+mWTGvoK9FFBzlvqehHn5Bf4 Br+bwJjtpou2oseA6DjpynOVkSN5zRF68ZHIvCTvbuX964K7xaXhfTq6f0Ph3uQ9h4Aa MdOA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=qvf10RLS; 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-212843-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212843-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-798aac9d625si89243985a.74.2024.06.13.01.40.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 01:40:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-212843-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=qvf10RLS; 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-212843-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212843-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 018EC1C2249C for ; Thu, 13 Jun 2024 08:40:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B0321411C1; Thu, 13 Jun 2024 08:38:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="qvf10RLS" Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (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 741D613D608 for ; Thu, 13 Jun 2024 08:38:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718267932; cv=none; b=ZvHQWhwRw/A5W7fMlBoaU4ftiwwycsCXP9P0D1RLiA4lSLko45R9wIuYTRvFbDBs8nrMpIjn4a5B3CEsaL+Szrsmo/4efythSrJobpZkL9Qev9kwIvn7ynwmDLS7rut+faFbwjgkjje5i6B3fR2P5FNHFRTHhJYNa5DtMP+jTes= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718267932; c=relaxed/simple; bh=Yt1zy1XfRzHpQQLlgxa42nzh9qUkh5kQNqod7piTvQQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=m2oi4cgQQMz67hS1SN8LeCZnknbzCnvYHTjSOLnkkFZfaGOAzFBgJ1tpmKEKCeDK/6k7U9h/n9MBIz9s4rOw1OLwE64ukBkr+9qZCGjxNXv0tbPTRgYXak2bNsEl+AonbPrQSZ9bWjgUqug0iOClaIrKS52EY5DfBjjLRrzbbHE= 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=qvf10RLS; arc=none smtp.client-ip=198.47.19.141 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 fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 45D8c8QB023308; Thu, 13 Jun 2024 03:38:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1718267888; bh=BY7OHhQbmNI82hBMi2BWuhYz45KvvtmVf4whs4ZENdk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=qvf10RLSnFcdwKeYKVzZRExDu9dUzzQ3KYQJpYFBTpQoYt6xpMo2K2jQrbf/38Hv4 byAQXvufKZwco6v39JUkP4DBhaBBgWNpwz44xtjbE4zgfFm1YpZFZuhKqe0CkfpN3T 4bdRVuKjL5k3pOE+JJ2bjAqBcyeumsEsvbQmgdpY= Received: from DFLE100.ent.ti.com (dfle100.ent.ti.com [10.64.6.21]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 45D8c8N6068476 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 13 Jun 2024 03:38:08 -0500 Received: from DFLE107.ent.ti.com (10.64.6.28) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Thu, 13 Jun 2024 03:38:07 -0500 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE107.ent.ti.com (10.64.6.28) 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; Thu, 13 Jun 2024 03:38:07 -0500 Received: from localhost (jayesh-hp-probook-440-g8-notebook-pc.dhcp.ti.com [172.24.227.55]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 45D8c7f9070256; Thu, 13 Jun 2024 03:38:07 -0500 From: Jayesh Choudhary To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v5 1/3] drm/bridge: sii902x: Fix mode_valid hook Date: Thu, 13 Jun 2024 14:08:03 +0530 Message-ID: <20240613083805.439337-2-j-choudhary@ti.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240613083805.439337-1-j-choudhary@ti.com> References: <20240613083805.439337-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 is defined only in drm_connector_helper_funcs. When the bridge is attached with the 'DRM_BRIDGE_ATTACH_NO_CONNECTOR' flag, the connector is not initialized, and so is the mode_valid hook under connector helper funcs. It also returns MODE_OK for all modes without actually checking the modes. So move the mode_valid hook to drm_bridge_funcs with proper clock checks for maximum and minimum pixel clock supported by the bridge. Signed-off-by: Jayesh Choudhary Reviewed-by: Dmitry Baryshkov Acked-by: Sui Jingfeng --- drivers/gpu/drm/bridge/sii902x.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c index 2fbeda9025bf..6a6055a4ccf9 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,17 +318,8 @@ static int sii902x_get_modes(struct drm_connector *connector) return num; } -static enum drm_mode_status sii902x_mode_valid(struct drm_connector *connector, - struct drm_display_mode *mode) -{ - /* TODO: check mode */ - - return MODE_OK; -} - static const struct drm_connector_helper_funcs sii902x_connector_helper_funcs = { .get_modes = sii902x_get_modes, - .mode_valid = sii902x_mode_valid, }; static void sii902x_bridge_disable(struct drm_bridge *bridge) @@ -504,6 +503,20 @@ 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) +{ + 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 const struct drm_bridge_funcs sii902x_bridge_funcs = { .attach = sii902x_bridge_attach, .mode_set = sii902x_bridge_mode_set, @@ -516,6 +529,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