From nobody Wed Nov 27 18:43:05 2024 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 07BE614EC59 for ; Tue, 8 Oct 2024 14:18:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728397115; cv=none; b=OMZvvWb9mmo8CkkscTgpU9mxWNDqmqpDiH1/dFguRfdALYPpg/bs33ojkE263mTnehVsOEFqeEDcRQXgy+yubjpxBBMfTvE0BShHJJ9B7/0v080g2ew4lBkpIQdECvmZCznd4Bb/+ycjjVsqmhw332WzQKjzeqDd5baT6rO5OZQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728397115; c=relaxed/simple; bh=cIyPW9Z2jzZyEh86fXqhUa+MuKu+8xjoPEs+7ONDo2c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=OAkcIh47wIcLQPtEISFlweJR9Tbr1/t+5ECAMcjSo5Zs2n4wLnHsLzcRQT9o0jW82TfZSTgkQJX0FDhYvoKesAOG7gY4Rxehud1rKgbQ7hLwYyZsG1kcoORQTjnMJJYHNMhahBU9z0mFkaoiYKLsullWSa1qInQx/R+FdBRq3xs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=YvMth1VV; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="YvMth1VV" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4985vcou021306; Tue, 8 Oct 2024 14:18:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= gKsmCYkhXMlDqpGR7T5GsjFzXiEzCV3nk0wvpW6MLM8=; b=YvMth1VVfFQJaxvh hb1C+Ud0qunMaUXf1tZfB+I326jf2OPnRcqD6kcK1Fd+2cML3z/nyB6xoA0G38fb TR6iSTp1ABAratoWVofiVndYPpEj7qkaGfk2HUPC0yGX6/iAHSJXB/3ys6uCV7yR QZxN/62bcuvJDsnzjeTRGNU/GGpkSJfw5ezXbFoBugnklMOy1phiiqUupaCnX2yX Js9zsZaxP9Ruvg6ekMD0j6iBit0+zrB4ZPnpFVrSbMMgBD0g+uNqED388G04D4PN juTlXkrRgf/Bqy5EbPdn9gJCcGjzFejm5FFc3YDv3UYvdA0KkUCANKk0FrX0BTKq fB9qdQ== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 422xr5qkba-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Oct 2024 14:18:12 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA03.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 498EIBH6021043 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 8 Oct 2024 14:18:11 GMT Received: from jesszhan-linux.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Tue, 8 Oct 2024 07:18:11 -0700 From: Jessica Zhang Date: Tue, 8 Oct 2024 07:17:40 -0700 Subject: [PATCH RFC v2 3/3] drm/panel: Introduce simulated panel bridge API Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20241008-jz-test-sim-panel-v2-3-d60046470e6c@quicinc.com> References: <20241008-jz-test-sim-panel-v2-0-d60046470e6c@quicinc.com> In-Reply-To: <20241008-jz-test-sim-panel-v2-0-d60046470e6c@quicinc.com> To: Neil Armstrong , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Jessica Zhang , Simona Vetter , Andrzej Hajda , Robert Foss , Laurent Pinchart , Jonas Karlman , "Jernej Skrabec" , Simona Vetter CC: , , X-Mailer: b4 0.15-dev-2a633 X-Developer-Signature: v=1; a=ed25519-sha256; t=1728397090; l=4528; i=quic_jesszhan@quicinc.com; s=20230329; h=from:subject:message-id; bh=cIyPW9Z2jzZyEh86fXqhUa+MuKu+8xjoPEs+7ONDo2c=; b=9tUmkgHjtKtmvNe7ODal7vwSpmLQH0saKzBK2c9oha69gDxYBzlN3/UOccd4vVRhqIJSwQm2R vK2kPXGbhOMDdRjRlBmrlSYGzZ93imkS1JXLtrBGqXkEzxiNmopDOJ/ X-Developer-Key: i=quic_jesszhan@quicinc.com; a=ed25519; pk=gAUCgHZ6wTJOzQa3U0GfeCDH7iZLlqIEPo4rrjfDpWE= X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: era3619I07jwGVG3p2MzGq8wZtp3rjW5 X-Proofpoint-ORIG-GUID: era3619I07jwGVG3p2MzGq8wZtp3rjW5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 clxscore=1015 mlxlogscore=999 priorityscore=1501 impostorscore=0 adultscore=0 mlxscore=0 phishscore=0 malwarescore=0 lowpriorityscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410080091 Add separate bridge and drm_panel API for getting the simulated panel. If the panel_simulation kernel module is enabled, the DRM framework will get the sim panel bridge instead of the physical panel or bridge. Signed-off-by: Jessica Zhang --- drivers/gpu/drm/bridge/panel.c | 28 ++++++++++++++++++++++++++++ drivers/gpu/drm/drm_panel.c | 33 +++++++++++++++++++++++++++++++++ include/drm/drm_bridge.h | 1 + include/drm/drm_panel.h | 1 + 4 files changed, 63 insertions(+) diff --git a/drivers/gpu/drm/bridge/panel.c b/drivers/gpu/drm/bridge/panel.c index 6e88339dec0f5faee690b7c53e8dcd0f1ee2281c..e703a770a86e60887ecb669011f= 311210fac695e 100644 --- a/drivers/gpu/drm/bridge/panel.c +++ b/drivers/gpu/drm/bridge/panel.c @@ -482,6 +482,30 @@ struct drm_connector *drm_panel_bridge_connector(struc= t drm_bridge *bridge) } EXPORT_SYMBOL(drm_panel_bridge_connector); =20 +/** + * drm_get_sim_panel_bridge - return the simulated panel bridge + * @dev: device to tie the bridge lifetime to + * + * This function will return a bridge for the simulated panel. + * + * Returns a pointer to the bridge if successful, or an error pointer + * otherwise. + */ +struct drm_bridge *drm_get_sim_panel_bridge(struct device *dev) +{ + struct drm_bridge *bridge; + struct drm_panel *panel; + + panel =3D drm_find_sim_panel(); + if (IS_ERR(panel)) + return ERR_PTR(-EPROBE_DEFER); + + bridge =3D devm_drm_panel_bridge_add(dev, panel); + + return bridge; +} +EXPORT_SYMBOL(drm_get_sim_panel_bridge); + #ifdef CONFIG_OF /** * devm_drm_of_get_bridge - Return next bridge in the chain @@ -505,6 +529,10 @@ struct drm_bridge *devm_drm_of_get_bridge(struct devic= e *dev, struct drm_panel *panel; int ret; =20 + bridge =3D drm_get_sim_panel_bridge(dev); + if (!IS_ERR(bridge)) + return bridge; + ret =3D drm_of_find_panel_or_bridge(np, port, endpoint, &panel, &bridge); if (ret) diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c index 19ab0a794add31f34275d53dfab0a7c0050476e3..1e532f8e5bff99467f058fe0a44= 1141c80ca95d6 100644 --- a/drivers/gpu/drm/drm_panel.c +++ b/drivers/gpu/drm/drm_panel.c @@ -313,6 +313,39 @@ int drm_panel_get_modes(struct drm_panel *panel, } EXPORT_SYMBOL(drm_panel_get_modes); =20 +/** + * drm_find_sim_panel - look up the simulated panel + * + * Searches for the simulated panel in the panel list. + * + * Return: A pointer to the simulated panel or an ERR_PTR() if the simulat= ed + * panel was not found in the panel list. + * + * Possible error codes returned by this function: + * - EPROBE_DEFER: the panel device has not been probed yet, and the caller + * should retry later + */ +struct drm_panel *drm_find_sim_panel(void) +{ + struct drm_panel *panel; + + mutex_lock(&panel_lock); + + list_for_each_entry(panel, &panel_list, list) { + bool is_sim_panel =3D !strncmp(panel->dev->driver->name, + "panel_simulation", + strlen("panel_simulation")); + if (is_sim_panel) { + mutex_unlock(&panel_lock); + return panel; + } + } + + mutex_unlock(&panel_lock); + return ERR_PTR(-EPROBE_DEFER); +} +EXPORT_SYMBOL(drm_find_sim_panel); + #ifdef CONFIG_OF /** * of_drm_find_panel - look up a panel using a device tree node diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h index 75019d16be643ae87f756e131a079feffd9b4d59..8c1ae06ecbcdb2e9d1fba6845bd= 85a54a9643502 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -1006,6 +1006,7 @@ static inline int drm_panel_bridge_set_orientation(st= ruct drm_connector *connect } #endif =20 +struct drm_bridge *drm_get_sim_panel_bridge(struct device *dev); #if defined(CONFIG_OF) && defined(CONFIG_DRM_PANEL_BRIDGE) struct drm_bridge *devm_drm_of_get_bridge(struct device *dev, struct devic= e_node *node, u32 port, u32 endpoint); diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h index 10015891b056f816c7a992a2052b36fd26943c5b..c3a5944c35a911b809a6567040c= ea7bc7da07ba6 100644 --- a/include/drm/drm_panel.h +++ b/include/drm/drm_panel.h @@ -283,6 +283,7 @@ int drm_panel_enable(struct drm_panel *panel); int drm_panel_disable(struct drm_panel *panel); =20 int drm_panel_get_modes(struct drm_panel *panel, struct drm_connector *con= nector); +struct drm_panel *drm_find_sim_panel(void); =20 #if defined(CONFIG_OF) && defined(CONFIG_DRM_PANEL) struct drm_panel *of_drm_find_panel(const struct device_node *np); --=20 2.34.1