From nobody Mon Sep 21 21:52:45 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1784192606; cv=none; d=zohomail.com; s=zohoarc; b=ifVqWRsYhxHeyCAt/DrxGJWMeOau9B8AUNoO8cjGnfZTKsxZg+ZkxR1b5hv2HY1rhj5dCBsTMn8+Q9VVxNYB6mV/72hoog7TSzO6Uc1Lp6wuFVMI/8S0ZmA8JJ6mTlo+ofvq3mRw8C1GwDZ4bBC6kmKsZHqI9+ZDAaEO2xwJfxA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784192606; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=K0bpK7inA55ypw9IyK4ZYF+yJtIn8h5ntrPY4x3zw2I=; b=KxAKvGVI2YzzOpeqkjLX9hZ8kY8PPMhlTgF2mh5uD+wKVHfXgTQ7h8cGdm1po1aCvjh1o5wfkIi40/r8W2Xe8OpLIMjw9+pJBjx1wX8V8pMABNI6bXyuqGLSU5ybZXAU4tS9IeLjOR+vDaddLeaD1nSeoSU9J3dOCAbkAe8Ilvs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1784192606299326.00704662043154; Thu, 16 Jul 2026 02:03:26 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1363563.1615146 (Exim 4.92) (envelope-from ) id 1wkHzg-0001So-PO; Thu, 16 Jul 2026 09:03:00 +0000 Received: by outflank-mailman (output) from mailman id 1363563.1615146; Thu, 16 Jul 2026 09:03:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wkHzg-0001Sh-IE; Thu, 16 Jul 2026 09:03:00 +0000 Received: by outflank-mailman (input) for mailman id 1363563; Thu, 16 Jul 2026 09:02:59 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wkHzf-0001Rv-CZ for xen-devel@lists.xenproject.org; Thu, 16 Jul 2026 09:02:59 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wkHze-005AXw-P6 for xen-devel@lists.xenproject.org; Thu, 16 Jul 2026 11:02:58 +0200 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a589e36-2eae-0a2a0a5409dd-0a2a4503be80-40 for ; Thu, 16 Jul 2026 11:02:58 +0200 Received: from [205.220.180.131] (helo=mx0b-0031df01.pphosted.com) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a589e40-fae8-0a2a45030019-cddcb48388c8-3 for ; Thu, 16 Jul 2026 11:02:58 +0200 Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66G838GX2123575 for ; Thu, 16 Jul 2026 09:02:56 GMT Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4feuex072t-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 16 Jul 2026 09:02:56 +0000 (GMT) Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-2c7f385887bso154816165ad.0 for ; Thu, 16 Jul 2026 02:02:56 -0700 (PDT) Received: from le-cd01-lnx.qualcomm.com ([114.94.8.21]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2cf106b271asm16592555ad.64.2026.07.16.02.02.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2026 02:02:54 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=qcppdkim1 header.d=qualcomm.com header.i="@qualcomm.com" header.h="Cc:Content-Transfer-Encoding:Content-Type:Date:From:In-Reply-To:Message-Id:MIME-Version:References:Subject:To"; dkim=pass header.s=google header.d=oss.qualcomm.com header.i="@oss.qualcomm.com" header.h="Cc:To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= K0bpK7inA55ypw9IyK4ZYF+yJtIn8h5ntrPY4x3zw2I=; b=jtsMH/CiIg+IYyIM UoWG17o1MwtLWopLoZO3sy24Al2Z9sOFbaENN4AOVJF4xU+bpPR+d9C9787h4TwO tSi9Ly3o/bxKWOdhB2fUU2i6GLhIiOeLqh+axAMMQ1eq/rr8R37KUew+2z2OQOHC nepZjqnosLkUboNLZlbyuXUjJEuUwJmPnkH2LVpO1iG4PXZJbOh8GFxD2BcKMFn7 41Czs3gRW49t6RwW8MVnxwacodggU7naT8AG19dTfVi+b1JqsixtDBt1+u2reMB+ XBxXv62GBdx6j/TuWz2kjm07GxtIOsh5Py6VZY4wdDPyPKa0u7dUY310ccoTFnlq 1cRjdA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1784192575; x=1784797375; darn=lists.xenproject.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=K0bpK7inA55ypw9IyK4ZYF+yJtIn8h5ntrPY4x3zw2I=; b=VIccdnXdof8AWkzdZJMFCsFmzzM/CgxoUDtrAZHuorSIim6x6pAoxJr6ArjlIeBx3n ZEZvbEW56RDDo2x86oFBCgG0lLeTBmOG4ZODj8Sdxi/1ne+03AGTSBw4AxuHv0qa2xI2 pY44IA5MXDihQ4YX24sP26WtfMq1+uV3uJ2nVemuCioFjKtzUBQm7jYlA8/VN85uRUE+ EcXS/hAQ13dEtqkkR/lBEU9qzoPrjD7XrOiAN6Jf98hVIhNeSh/U7SFV0aq2epJurPE+ SsO1SsQWldmj/hPUsaHCni8KbBxdIDOAc0+LkNUtjh6Xocb3ODzguO7TuVFIv/NO8n2F 8VYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784192575; x=1784797375; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=K0bpK7inA55ypw9IyK4ZYF+yJtIn8h5ntrPY4x3zw2I=; b=hdEFb4H2iBbyXUZZZrjJiqvm5YPnNQZmLVRrXnGwkPw+eexcE6eQF+0HB4xOD8YNhB Kd0GMs+rlRKcfm881VOMWCLmM8gTTy2+khH2lDBAvdm+WSXtb7tylQqfHmzBQA84x70K G898m4Gll0HIakR+CFFJZOAtX8EiGZemf8vxJrwNJvu9Yod8iypMKYL3uS5O4Ym2MCYy /zuKo3L+XwTmuCDMT3NaDHQWOB5lIfn8fm+l8ab2DLo65uMjiJTgoEofeSic+F+6uBxb CnirDLQGeMJhDAPLHrlow4TEG443HtWSanrKoUfHP4oCvSnLy4I6sy/jvtmFw4pV103K hXSA== X-Forwarded-Encrypted: i=1; AHgh+RorI4ANTVGAvOeiPWZkMNKAcRTCprTl7u+h/tm17gaT5tCirsOK4I9NCDpbjGwysEhJbehQaNMnEW0=@lists.xenproject.org X-Gm-Message-State: AOJu0YxSK2bFaucE06HOzeC/oCMmuZJ4r/NxLkAhYa4EzQ9xNjMv8cq9 5UMwluMvAV30PwEgtigVygDg9YsGcF76WUYuHvR9bjQymw8KvTagIeKIJ/keJCzuBgw74MrB9Gy ZA8s/TiZrZJ03dALcATIp2I6McABpiWHpRk795AW4TOjX2WX+fvQRHu7JHYHOL52uJdpOr0anAE GMrSoW X-Gm-Gg: AfdE7cm5tWCskceprnHf5D0sesPagY3BkAk/YRcThGpI43h176RMTgJZzVWrL5Zodfi +LPQiTCGpMUZ+mbrRMseutCwl43yaMYYKB1fWXALSFov5tp4rLmf/RKAkYQTI5HNb6323i8MS7T OqeaCSf1ZwhmmLZwDiwT/OmswkQ81hwsp1s9YOLhk3bIxAC9gMs6qQmaDkb2HIr/uPyStiJXiaH LN38Gz6pQ/QrjJ75BsTM1REJxCklrbnQ4JARYQd3iCjOlt3aTMQWt0yUOCEAokHyA/a4RI8aFIV sh90//28K4cuKVKhINhtWteOzZAI53p6SIOApGfMPa6hhpIRXViI77SQjsEzvPFlkbRPybJOM7k SIN2awLIpY2+vJv/eZJlS X-Received: by 2002:a17:902:e787:b0:2cc:7c36:2c23 with SMTP id d9443c01a7336-2cf03d6be8amr56675115ad.43.1784192575386; Thu, 16 Jul 2026 02:02:55 -0700 (PDT) X-Received: by 2002:a17:902:e787:b0:2cc:7c36:2c23 with SMTP id d9443c01a7336-2cf03d6be8amr56674695ad.43.1784192574779; Thu, 16 Jul 2026 02:02:54 -0700 (PDT) From: Ze Huang Date: Thu, 16 Jul 2026 17:01:53 +0800 Subject: [PATCH v2 1/8] drm/arcpgu: replace struct drm_simple_display_pipe with regular atomic helpers MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260716-drm-simple-kms-removal-v2-1-1133a8fc3785@oss.qualcomm.com> References: <20260716-drm-simple-kms-removal-v2-0-1133a8fc3785@oss.qualcomm.com> In-Reply-To: <20260716-drm-simple-kms-removal-v2-0-1133a8fc3785@oss.qualcomm.com> To: Alexey Brodkin , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Joel Stanley , Andrew Jeffery , Frank Li , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Linus Walleij , Hans de Goede , Alex Lanzano , Oleksandr Andrushchenko Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-aspeed@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev, xen-devel@lists.xenproject.org, Ze Huang X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1784192559; l=11611; i=ze.huang@oss.qualcomm.com; s=20260716; h=from:subject:message-id; bh=mhZuZpvxlw2add5yFJofNe/qRYemwKr9KZXWIRbaR4U=; b=bKGcIBRbY3DWlMj5Cf4cPqNMuGZMGDU6qKuQzX/N11LATYpXjJUNET/zATFlfhoW3+9trVitB aYnklaVV/K+BCQCTcDi+FqGjUSBjW456AT7fVFNvbJXR15fJ9ZpoOgM X-Developer-Key: i=ze.huang@oss.qualcomm.com; a=ed25519; pk=8uGhlZHInA8NXq7G6u/g59qEcwXwuMRI7nBSnT/ijtY= X-Authority-Analysis: v=2.4 cv=JeeMa0KV c=1 sm=1 tr=0 ts=6a589e40 cx=c_pps a=JL+w9abYAAE89/QcEU+0QA==:117 a=Uz3yg00KUFJ2y2WijEJ4bw==:17 a=IkcTkHD0fZMA:10 a=RAioF0-LDSMA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=ZpdpYltYx_vBUK5n70dp:22 a=EUspDBNiAAAA:8 a=dobV-df0kVLvunOko3gA:9 a=QEXdDO2ut3YA:10 a=324X-CrmTo6CU4MGRt3R:22 X-Proofpoint-ORIG-GUID: UVfDJ17aSi6kKC9iopJkOIgDL_Cat37y X-Proofpoint-GUID: UVfDJ17aSi6kKC9iopJkOIgDL_Cat37y X-Proofpoint-Spam-Info: AW1haW4tMjYwNzE2MDA5MSBTYWx0ZWRfXzO4mU/PZRlpN hCwWRuKeMGe0hL2X2ubnf493ASUtp9TIsngfrtoCG2OHI5WlfqF3uAOnfD3caHsg/iHsghxPi3c t3bMOhhaMPv9UZezZ34IcgSkhRAPTCU= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzE2MDA5MSBTYWx0ZWRfX1TD7Y633MImh G+1v4sbjflQ0DLuS3Z4dfHQB9+BPJLwLZTKDXAyuLA0PWnMFcWCyG5a/9K0Un3h6lZAg43J2/7+ qtfyCUgr2jjH3+z7SmZW34FfBrmBAqp77hdKVc7Sad04nFPYwsc90WMVhrywuCw2AtUAVQENDXN 3CosM4zcO+r7XVlPn5guSJpkyj128iwmAWL5Y0I7x+tf5KGIu0dTFt6yrl63CjM1KZj4eKiLCfb acu85Duf40Hb1o8LJRHKWLbYQZS252r86f/Lzf/gwfVRNuXIqP3WU5+oxo64oaAKPpo12OKc4mD ijjhmcxB41yOfgd1mwNa+MWkCUdb+0BCfN/qEMYJlQIanmktmiCEtFNBGdXsy+pA1FOM6ned3Tc 1cb2qyupVb+F7EpK7DDJmbq2lRR+ugFpYHYKeur+q5Hxl8aKE82MVrjsKRlBcI4EAlggTuSPCAW BylRsyxuS71AgQ5Pf8A== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-16_03,2026-07-15_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 adultscore=0 clxscore=1015 suspectscore=0 lowpriorityscore=0 priorityscore=1501 impostorscore=0 phishscore=0 malwarescore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607160091 X-purgate-ID: tlsNG-33051d/1784192578-762FD4E9-E18FBE81/0/0 X-purgate-type: clean X-purgate-size: 11613 X-ZohoMail-DKIM: pass (identity @qualcomm.com) X-ZM-MESSAGEID: 1784192607410158500 Instantiate plane, CRTC and encoder directly and wire them up with standard atomic helpers. This removes arcpgu's dependency on deprecated simple-KMS display pipe interface. Signed-off-by: Ze Huang --- drivers/gpu/drm/tiny/arcpgu.c | 179 +++++++++++++++++++++++++++++++-------= ---- 1 file changed, 133 insertions(+), 46 deletions(-) diff --git a/drivers/gpu/drm/tiny/arcpgu.c b/drivers/gpu/drm/tiny/arcpgu.c index c93d61ac0bb7..e0cce4798f3e 100644 --- a/drivers/gpu/drm/tiny/arcpgu.c +++ b/drivers/gpu/drm/tiny/arcpgu.c @@ -8,6 +8,7 @@ #include =20 #include +#include #include #include #include @@ -17,12 +18,13 @@ #include #include #include +#include #include #include #include #include +#include #include -#include #include #include #include @@ -52,13 +54,16 @@ struct arcpgu_drm_private { struct drm_device drm; void __iomem *regs; struct clk *clk; - struct drm_simple_display_pipe pipe; + struct drm_plane plane; + struct drm_crtc crtc; + struct drm_encoder encoder; struct drm_connector sim_conn; }; =20 -#define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm) - -#define pipe_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, = pipe) +static inline struct arcpgu_drm_private *dev_to_arcpgu(struct drm_device *= drm) +{ + return container_of(drm, struct arcpgu_drm_private, drm); +} =20 static inline void arc_pgu_write(struct arcpgu_drm_private *arcpgu, unsigned int reg, u32 value) @@ -117,7 +122,7 @@ static const u32 arc_pgu_supported_formats[] =3D { =20 static void arc_pgu_set_pxl_fmt(struct arcpgu_drm_private *arcpgu) { - const struct drm_framebuffer *fb =3D arcpgu->pipe.plane.state->fb; + const struct drm_framebuffer *fb =3D arcpgu->plane.state->fb; uint32_t pixel_format =3D fb->format->format; u32 format =3D DRM_FORMAT_INVALID; int i; @@ -139,10 +144,10 @@ static void arc_pgu_set_pxl_fmt(struct arcpgu_drm_pri= vate *arcpgu) arc_pgu_write(arcpgu, ARCPGU_REG_CTRL, reg_ctrl); } =20 -static enum drm_mode_status arc_pgu_mode_valid(struct drm_simple_display_p= ipe *pipe, - const struct drm_display_mode *mode) +static enum drm_mode_status arcpgu_crtc_helper_mode_valid(struct drm_crtc = *crtc, + const struct drm_display_mode *mode) { - struct arcpgu_drm_private *arcpgu =3D pipe_to_arcpgu_priv(pipe); + struct arcpgu_drm_private *arcpgu =3D dev_to_arcpgu(crtc->dev); long rate, clk_rate =3D mode->clock * 1000; long diff =3D clk_rate / 200; /* +-0.5% allowed by HDMI spec */ =20 @@ -155,7 +160,7 @@ static enum drm_mode_status arc_pgu_mode_valid(struct d= rm_simple_display_pipe *p =20 static void arc_pgu_mode_set(struct arcpgu_drm_private *arcpgu) { - struct drm_display_mode *m =3D &arcpgu->pipe.crtc.state->adjusted_mode; + struct drm_display_mode *m =3D &arcpgu->crtc.state->adjusted_mode; u32 val; =20 arc_pgu_write(arcpgu, ARCPGU_REG_FMT, @@ -194,11 +199,10 @@ static void arc_pgu_mode_set(struct arcpgu_drm_privat= e *arcpgu) clk_set_rate(arcpgu->clk, m->crtc_clock * 1000); } =20 -static void arc_pgu_enable(struct drm_simple_display_pipe *pipe, - struct drm_crtc_state *crtc_state, - struct drm_plane_state *plane_state) +static void arcpgu_crtc_helper_atomic_enable(struct drm_crtc *crtc, + struct drm_atomic_commit *commit) { - struct arcpgu_drm_private *arcpgu =3D pipe_to_arcpgu_priv(pipe); + struct arcpgu_drm_private *arcpgu =3D dev_to_arcpgu(crtc->dev); =20 arc_pgu_mode_set(arcpgu); =20 @@ -208,9 +212,10 @@ static void arc_pgu_enable(struct drm_simple_display_p= ipe *pipe, ARCPGU_CTRL_ENABLE_MASK); } =20 -static void arc_pgu_disable(struct drm_simple_display_pipe *pipe) +static void arcpgu_crtc_helper_atomic_disable(struct drm_crtc *crtc, + struct drm_atomic_commit *commit) { - struct arcpgu_drm_private *arcpgu =3D pipe_to_arcpgu_priv(pipe); + struct arcpgu_drm_private *arcpgu =3D dev_to_arcpgu(crtc->dev); =20 clk_disable_unprepare(arcpgu->clk); arc_pgu_write(arcpgu, ARCPGU_REG_CTRL, @@ -218,35 +223,95 @@ static void arc_pgu_disable(struct drm_simple_display= _pipe *pipe) ~ARCPGU_CTRL_ENABLE_MASK); } =20 -static void arc_pgu_update(struct drm_simple_display_pipe *pipe, - struct drm_plane_state *state) +static void arcpgu_plane_helper_atomic_update(struct drm_plane *plane, + struct drm_atomic_commit *commit) { + struct drm_plane_state *pstate =3D drm_atomic_get_new_plane_state(commit,= plane); struct arcpgu_drm_private *arcpgu; struct drm_gem_dma_object *gem; =20 - if (!pipe->plane.state->fb) + if (!pstate->fb) return; =20 - arcpgu =3D pipe_to_arcpgu_priv(pipe); - gem =3D drm_fb_dma_get_gem_obj(pipe->plane.state->fb, 0); + arcpgu =3D dev_to_arcpgu(plane->dev); + gem =3D drm_fb_dma_get_gem_obj(pstate->fb, 0); arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->dma_addr); } =20 -static const struct drm_simple_display_pipe_funcs arc_pgu_pipe_funcs =3D { - .update =3D arc_pgu_update, - .mode_valid =3D arc_pgu_mode_valid, - .enable =3D arc_pgu_enable, - .disable =3D arc_pgu_disable, -}; - static const struct drm_mode_config_funcs arcpgu_drm_modecfg_funcs =3D { - .fb_create =3D drm_gem_fb_create, + .fb_create =3D drm_gem_fb_create, .atomic_check =3D drm_atomic_helper_check, .atomic_commit =3D drm_atomic_helper_commit, }; =20 DEFINE_DRM_GEM_DMA_FOPS(arcpgu_drm_ops); =20 +static int arcpgu_plane_helper_atomic_check(struct drm_plane *plane, + struct drm_atomic_commit *commit) +{ + struct drm_plane_state *plane_state =3D drm_atomic_get_new_plane_state(co= mmit, plane); + struct drm_crtc *crtc =3D plane_state->crtc; + struct drm_crtc_state *crtc_state =3D NULL; + + if (crtc) + crtc_state =3D drm_atomic_get_new_crtc_state(commit, crtc); + + return drm_atomic_helper_check_plane_state(plane_state, crtc_state, + DRM_PLANE_NO_SCALING, + DRM_PLANE_NO_SCALING, + false, false); +} + +static const struct drm_plane_helper_funcs arcpgu_plane_helper_funcs =3D { + .prepare_fb =3D drm_gem_plane_helper_prepare_fb, + .atomic_check =3D arcpgu_plane_helper_atomic_check, + .atomic_update =3D arcpgu_plane_helper_atomic_update, +}; + +static const struct drm_plane_funcs arcpgu_plane_funcs =3D { + .update_plane =3D drm_atomic_helper_update_plane, + .disable_plane =3D drm_atomic_helper_disable_plane, + .destroy =3D drm_plane_cleanup, + .reset =3D drm_atomic_helper_plane_reset, + .atomic_duplicate_state =3D drm_atomic_helper_plane_duplicate_state, + .atomic_destroy_state =3D drm_atomic_helper_plane_destroy_state, +}; + +static int arcpgu_crtc_helper_atomic_check(struct drm_crtc *crtc, + struct drm_atomic_commit *commit) +{ + struct drm_crtc_state *crtc_state =3D drm_atomic_get_new_crtc_state(commi= t, crtc); + int ret; + + if (crtc_state->enable) { + ret =3D drm_atomic_helper_check_crtc_primary_plane(crtc_state); + if (ret) + return ret; + } + + return drm_atomic_add_affected_planes(commit, crtc); +} + +static const struct drm_crtc_helper_funcs arcpgu_crtc_helper_funcs =3D { + .mode_valid =3D arcpgu_crtc_helper_mode_valid, + .atomic_check =3D arcpgu_crtc_helper_atomic_check, + .atomic_enable =3D arcpgu_crtc_helper_atomic_enable, + .atomic_disable =3D arcpgu_crtc_helper_atomic_disable, +}; + +static const struct drm_crtc_funcs arcpgu_crtc_funcs =3D { + .reset =3D drm_atomic_helper_crtc_reset, + .destroy =3D drm_crtc_cleanup, + .set_config =3D drm_atomic_helper_set_config, + .page_flip =3D drm_atomic_helper_page_flip, + .atomic_duplicate_state =3D drm_atomic_helper_crtc_duplicate_state, + .atomic_destroy_state =3D drm_atomic_helper_crtc_destroy_state, +}; + +static const struct drm_encoder_funcs arcpgu_encoder_funcs =3D { + .destroy =3D drm_encoder_cleanup, +}; + static int arcpgu_load(struct arcpgu_drm_private *arcpgu) { struct platform_device *pdev =3D to_platform_device(arcpgu->drm.dev); @@ -254,6 +319,9 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpg= u) struct device_node *endpoint_node =3D NULL; struct drm_connector *connector =3D NULL; struct drm_device *drm =3D &arcpgu->drm; + struct drm_plane *plane; + struct drm_encoder *encoder; + struct drm_crtc *crtc; int ret; =20 arcpgu->clk =3D devm_clk_get(drm->dev, "pxlclk"); @@ -285,6 +353,30 @@ static int arcpgu_load(struct arcpgu_drm_private *arcp= gu) if (dma_set_mask_and_coherent(drm->dev, DMA_BIT_MASK(32))) return -ENODEV; =20 + plane =3D &arcpgu->plane; + ret =3D drm_universal_plane_init(drm, plane, 0, + &arcpgu_plane_funcs, + arc_pgu_supported_formats, + ARRAY_SIZE(arc_pgu_supported_formats), + NULL, + DRM_PLANE_TYPE_PRIMARY, NULL); + if (ret) + return ret; + drm_plane_helper_add(plane, &arcpgu_plane_helper_funcs); + + crtc =3D &arcpgu->crtc; + ret =3D drm_crtc_init_with_planes(drm, crtc, plane, NULL, + &arcpgu_crtc_funcs, NULL); + if (ret) + return ret; + drm_crtc_helper_add(crtc, &arcpgu_crtc_helper_funcs); + + encoder =3D &arcpgu->encoder; + ret =3D drm_encoder_init(drm, encoder, &arcpgu_encoder_funcs, DRM_MODE_EN= CODER_NONE, NULL); + if (ret) + return ret; + encoder->possible_crtcs =3D drm_crtc_mask(crtc); + /* * There is only one output port inside each device. It is linked with * encoder endpoint. @@ -293,29 +385,24 @@ static int arcpgu_load(struct arcpgu_drm_private *arc= pgu) if (endpoint_node) { encoder_node =3D of_graph_get_remote_port_parent(endpoint_node); of_node_put(endpoint_node); - } else { - connector =3D &arcpgu->sim_conn; - dev_info(drm->dev, "no encoder found. Assumed virtual LCD on simulation = platform\n"); - ret =3D arcpgu_drm_sim_init(drm, connector); - if (ret < 0) - return ret; - } =20 - ret =3D drm_simple_display_pipe_init(drm, &arcpgu->pipe, &arc_pgu_pipe_fu= ncs, - arc_pgu_supported_formats, - ARRAY_SIZE(arc_pgu_supported_formats), - NULL, connector); - if (ret) - return ret; - - if (encoder_node) { /* Locate drm bridge from the hdmi encoder DT node */ struct drm_bridge *bridge __free(drm_bridge_put) =3D of_drm_find_and_get_bridge(encoder_node); if (!bridge) return -EPROBE_DEFER; =20 - ret =3D drm_simple_display_pipe_attach_bridge(&arcpgu->pipe, bridge); + ret =3D drm_bridge_attach(encoder, bridge, NULL, 0); + if (ret) + return ret; + } else { + connector =3D &arcpgu->sim_conn; + dev_info(drm->dev, "no encoder found. Assumed virtual LCD on simulation = platform\n"); + ret =3D arcpgu_drm_sim_init(drm, connector); + if (ret < 0) + return ret; + + ret =3D drm_connector_attach_encoder(connector, encoder); if (ret) return ret; } @@ -342,7 +429,7 @@ static int arcpgu_show_pxlclock(struct seq_file *m, voi= d *arg) struct drm_device *drm =3D node->minor->dev; struct arcpgu_drm_private *arcpgu =3D dev_to_arcpgu(drm); unsigned long clkrate =3D clk_get_rate(arcpgu->clk); - unsigned long mode_clock =3D arcpgu->pipe.crtc.mode.crtc_clock * 1000; + unsigned long mode_clock =3D arcpgu->crtc.state->mode.crtc_clock * 1000; =20 seq_printf(m, "hw : %lu\n", clkrate); seq_printf(m, "mode: %lu\n", mode_clock); --=20 2.43.0