Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp26069193rwd; Mon, 3 Jul 2023 05:11:06 -0700 (PDT) X-Google-Smtp-Source: APBJJlEfA1bHVD8slFKgObEBQUA6ekAMGVcnt4KobCjbvxrXrC5VCFuissReLsAgmeUmckPc+thw X-Received: by 2002:a92:c608:0:b0:345:b536:61f with SMTP id p8-20020a92c608000000b00345b536061fmr10464191ilm.31.1688386265304; Mon, 03 Jul 2023 05:11:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688386265; cv=none; d=google.com; s=arc-20160816; b=Lj3y9bgcLz0LsqT612ULfvPc/ldRhXxtAsRAiAb40w05gjdxgSc9M8A1o5ub5k9c/3 cwmBvM6fNgY4piDJE6xJTAMsYT8bRdBykOtTH8iO0NCEzTd0EARuoUYLD32qTJSzl0IK Oa7yvIwP7M45sGVQibanp68CvuCdhoZjZC2OzBN+d544ySOc8B0w0SN1K0szEeZAImyP 2MiGNUfxlqJxm8H2QYsdCy9/02jcFJruuJJ5zIIduyEQElmseehrmBNOBWKjOI67SSka U2uopxHfplC78vXMEM740XjR3DQtgDuKNnhWK9AWcXNYhA0t7SY1NJ1XKEMUiqPM3S8i /HfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=46Sracu/D/0a4Yd4cBQRbtvN6kMcQIjjw3Sb/7ByX0U=; fh=rsTV9C1BSDwWlj+vWrLsV7I31uoaBHs4BtS5uLU3bok=; b=WB98VyjAeYntep0gVt16waF1tZv2Me7eKhoE1BRMLmS6bQDvzDmvRlwjUef+Ar7qkp j4USZDkwmXegy6TkbgBqWzTi24eI/Z4Q/ZqvQjINKFApT1gIkl8ZMl/pha957p2WXH8B 1L858wm0Hw2c9HpybCkjcj/HZInLLxzjIIHonYAls0KW2L7j6Yj7YNUZqccT/6rZ1SJx AzjuGzAwlqEDC2h7avohHh6SvQyiiaWYdVq3Ymf7vsVsi3NefXCS1HwVMpRnWnPhCzw3 K3s3b2oOdewedVJkOTFewUX/6utOjtIUCShxaXoq5xiCKUOiaj4jCElZRhvjUckYynDi pS5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Pe70J71E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n3-20020a634d43000000b0054fe372aa7bsi18010297pgl.609.2023.07.03.05.10.45; Mon, 03 Jul 2023 05:11:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Pe70J71E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230149AbjGCLvA (ORCPT + 99 others); Mon, 3 Jul 2023 07:51:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229844AbjGCLu7 (ORCPT ); Mon, 3 Jul 2023 07:50:59 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B816610E for ; Mon, 3 Jul 2023 04:50:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688385012; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=46Sracu/D/0a4Yd4cBQRbtvN6kMcQIjjw3Sb/7ByX0U=; b=Pe70J71EvFBIO2RSr5J1lXiam28RqVxuzuQwKQXiFDdXl1VS6Qiapn2wf4hIrbGGkQY2nV 0XxfUi8fj0XzwT6E4At8vfj2s1X2L5w9L5t1JTmLchDDQfFWXrfd6dFhocT8WZZolFEuKY y5aTOHWcbC2Dghj0CVksbSbIR6Yitmg= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-455-kxuh3lALOmyOk2lucpqIIA-1; Mon, 03 Jul 2023 07:50:11 -0400 X-MC-Unique: kxuh3lALOmyOk2lucpqIIA-1 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-4fb774de2d4so4017404e87.1 for ; Mon, 03 Jul 2023 04:50:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688385010; x=1690977010; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=46Sracu/D/0a4Yd4cBQRbtvN6kMcQIjjw3Sb/7ByX0U=; b=OAX8B+WUs7CwmkIovumfPm/0bv0wMLPgQJhMPhrTND4QSMSGWCq0F8ArjzXAm5B1a1 ewvgr7fp7S7CkNrp5YynkQfn9Fqgxg2nEyjATXu6leiKPAWJr72wvJA14cB4fNrq7KNx F4Plnm5wCCCNVve3FvCJgE9hj3WkydB3YgMUJ7MycRS76/3reTt6vJnUdHe16+zFvXni wM9GdDNeeRdxn8eWT1oRBWf2JppxqsfUteydw+jSyaxUykmSMixSgh325dyC43sK1qNv cHaacl9ssO7x8TQppwjnFxWLdTk1n2RtTb1wDiRKHv3mWpsxRzNnvZFX0PcMzxyJwTff fzgg== X-Gm-Message-State: ABy/qLZX5eeDyRXjf0887Q5Rj0UF9LoMXBgsqUnrpRk1ujN4oRFYZG92 8/4ywGtkJOVM/T87EqQMcxhcH6F6N8KBi+dQIxCV3nFiFEurmyF0bduN4HsJSqhhPNo3Jf8KtN2 IzKxS4NT/Byl0zMMyZ5cvpK1PmcPXC/cal+6itFdy X-Received: by 2002:a05:6512:4013:b0:4fb:8939:d962 with SMTP id br19-20020a056512401300b004fb8939d962mr7931358lfb.19.1688385010208; Mon, 03 Jul 2023 04:50:10 -0700 (PDT) X-Received: by 2002:a05:6512:4013:b0:4fb:8939:d962 with SMTP id br19-20020a056512401300b004fb8939d962mr7931319lfb.19.1688385009760; Mon, 03 Jul 2023 04:50:09 -0700 (PDT) MIME-Version: 1.0 References: <20230404-solid-fill-v4-0-f4ec0caa742d@quicinc.com> <20230404-solid-fill-v4-2-f4ec0caa742d@quicinc.com> <68629132-b77a-bfbc-20f7-92a76cf24953@quicinc.com> In-Reply-To: <68629132-b77a-bfbc-20f7-92a76cf24953@quicinc.com> From: Sebastian Wick Date: Mon, 3 Jul 2023 13:49:58 +0200 Message-ID: Subject: Re: [PATCH RFC v4 2/7] drm: Introduce pixel_source DRM plane property To: Jessica Zhang Cc: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Clark , Dmitry Baryshkov , Sean Paul , Marijn Suijten , quic_abhinavk@quicinc.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, ppaalanen@gmail.com, laurent.pinchart@ideasonboard.com, linux-arm-msm@vger.kernel.org, wayland-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 30, 2023 at 11:27=E2=80=AFPM Jessica Zhang wrote: > > > > On 6/30/2023 7:43 AM, Sebastian Wick wrote: > > On Fri, Jun 30, 2023 at 2:26=E2=80=AFAM Jessica Zhang wrote: > >> > >> Add support for pixel_source property to drm_plane and related > >> documentation. > >> > >> This enum property will allow user to specify a pixel source for the > >> plane. Possible pixel sources will be defined in the > >> drm_plane_pixel_source enum. > >> > >> The current possible pixel sources are DRM_PLANE_PIXEL_SOURCE_FB and > >> DRM_PLANE_PIXEL_SOURCE_COLOR. The default value is *_SOURCE_FB. > >> > >> Signed-off-by: Jessica Zhang > >> --- > >> drivers/gpu/drm/drm_atomic_state_helper.c | 1 + > >> drivers/gpu/drm/drm_atomic_uapi.c | 4 ++ > >> drivers/gpu/drm/drm_blend.c | 81 +++++++++++++++++++++= ++++++++++ > >> include/drm/drm_blend.h | 2 + > >> include/drm/drm_plane.h | 21 ++++++++ > >> 5 files changed, 109 insertions(+) > >> > >> diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/d= rm/drm_atomic_state_helper.c > >> index fe14be2bd2b2..86fb876efbe6 100644 > >> --- a/drivers/gpu/drm/drm_atomic_state_helper.c > >> +++ b/drivers/gpu/drm/drm_atomic_state_helper.c > >> @@ -252,6 +252,7 @@ void __drm_atomic_helper_plane_state_reset(struct = drm_plane_state *plane_state, > >> > >> plane_state->alpha =3D DRM_BLEND_ALPHA_OPAQUE; > >> plane_state->pixel_blend_mode =3D DRM_MODE_BLEND_PREMULTI; > >> + plane_state->pixel_source =3D DRM_PLANE_PIXEL_SOURCE_FB; > >> > >> if (plane_state->solid_fill_blob) { > >> drm_property_blob_put(plane_state->solid_fill_blob); > >> diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_a= tomic_uapi.c > >> index a28b4ee79444..6e59c21af66b 100644 > >> --- a/drivers/gpu/drm/drm_atomic_uapi.c > >> +++ b/drivers/gpu/drm/drm_atomic_uapi.c > >> @@ -596,6 +596,8 @@ static int drm_atomic_plane_set_property(struct dr= m_plane *plane, > >> drm_property_blob_put(solid_fill); > >> > >> return ret; > >> + } else if (property =3D=3D plane->pixel_source_property) { > >> + state->pixel_source =3D val; > >> } else if (property =3D=3D plane->alpha_property) { > >> state->alpha =3D val; > >> } else if (property =3D=3D plane->blend_mode_property) { > >> @@ -671,6 +673,8 @@ drm_atomic_plane_get_property(struct drm_plane *pl= ane, > >> } else if (property =3D=3D plane->solid_fill_property) { > >> *val =3D state->solid_fill_blob ? > >> state->solid_fill_blob->base.id : 0; > >> + } else if (property =3D=3D plane->pixel_source_property) { > >> + *val =3D state->pixel_source; > >> } else if (property =3D=3D plane->alpha_property) { > >> *val =3D state->alpha; > >> } else if (property =3D=3D plane->blend_mode_property) { > >> diff --git a/drivers/gpu/drm/drm_blend.c b/drivers/gpu/drm/drm_blend.c > >> index 38c3c5d6453a..8c100a957ee2 100644 > >> --- a/drivers/gpu/drm/drm_blend.c > >> +++ b/drivers/gpu/drm/drm_blend.c > >> @@ -189,6 +189,18 @@ > >> * solid_fill is set up with drm_plane_create_solid_fill_propert= y(). It > >> * contains pixel data that drivers can use to fill a plane. > >> * > >> + * pixel_source: > >> + * pixel_source is set up with drm_plane_create_pixel_source_prop= erty(). > >> + * It is used to toggle the source of pixel data for the plane. > >> + * > >> + * Possible values: > >> + * > >> + * "FB": > >> + * Framebuffer source > >> + * > >> + * "COLOR": > >> + * solid_fill source > >> + * > >> * Note that all the property extensions described here apply either= to the > >> * plane or the CRTC (e.g. for the background color, which currently= is not > >> * exposed and assumed to be black). > >> @@ -648,3 +660,72 @@ int drm_plane_create_solid_fill_property(struct d= rm_plane *plane) > >> return 0; > >> } > >> EXPORT_SYMBOL(drm_plane_create_solid_fill_property); > >> + > >> +/** > >> + * drm_plane_create_pixel_source_property - create a new pixel source= property > >> + * @plane: drm plane > >> + * @supported_sources: bitmask of supported pixel_sources for the dri= ver (NOT > >> + * including DRM_PLANE_PIXEL_SOURCE_FB, as it wil= l be supported > >> + * by default). > >> + * > >> + * This creates a new property describing the current source of pixel= data for the > >> + * plane. > >> + * > >> + * The property is exposed to userspace as an enumeration property ca= lled > >> + * "pixel_source" and has the following enumeration values: > >> + * > >> + * "FB": > >> + * Framebuffer pixel source > >> + * > >> + * "COLOR": > >> + * Solid fill color pixel source > > > > Can we add a "NONE" value? > > > > I know it has been discussed earlier if we *need* this and I don't > > think we do. I just think it would be better API design to disable > > planes this way than having to know that a framebuffer pixel source > > with a NULL framebuffer disables the plane. Obviously also keep the > > old behavior for backwards compatibility. > > Hi Sebastian, > > Sounds good. > > So if pixel_source =3D=3D NONE disables the planes, would that mean cases > where pixel_source =3D=3D COLOR && solid_fill_blob =3D=3D NULL, the atomi= c > commit should throw an error? I would say so, yes. > Thanks, > > Jessica Zhang > > > > >> + * > >> + * Returns: > >> + * Zero on success, negative errno on failure. > >> + */ > >> +int drm_plane_create_pixel_source_property(struct drm_plane *plane, > >> + unsigned int supported_sour= ces) > >> +{ > >> + struct drm_device *dev =3D plane->dev; > >> + struct drm_property *prop; > >> + const struct drm_prop_enum_list enum_list[] =3D { > >> + { DRM_PLANE_PIXEL_SOURCE_FB, "FB" }, > >> + { DRM_PLANE_PIXEL_SOURCE_COLOR, "COLOR" }, > >> + }; > >> + unsigned int valid_source_mask =3D BIT(DRM_PLANE_PIXEL_SOURCE_= FB) | > >> + BIT(DRM_PLANE_PIXEL_SOURCE_COLO= R); > >> + int i; > >> + > >> + /* FB is supported by default */ > >> + supported_sources |=3D BIT(DRM_PLANE_PIXEL_SOURCE_FB); > >> + > >> + if (WARN_ON(supported_sources & ~valid_source_mask)) > >> + return -EINVAL; > >> + > >> + prop =3D drm_property_create(dev, DRM_MODE_PROP_ENUM, "pixel_s= ource", > >> + hweight32(supported_sources)); > >> + > >> + if (!prop) > >> + return -ENOMEM; > >> + > >> + for (i =3D 0; i < ARRAY_SIZE(enum_list); i++) { > >> + int ret; > >> + > >> + if (!(BIT(enum_list[i].type) & supported_sources)) > >> + continue; > >> + > >> + ret =3D drm_property_add_enum(prop, enum_list[i].type,= enum_list[i].name); > >> + > >> + if (ret) { > >> + drm_property_destroy(dev, prop); > >> + > >> + return ret; > >> + } > >> + } > >> + > >> + drm_object_attach_property(&plane->base, prop, DRM_PLANE_PIXEL= _SOURCE_FB); > >> + plane->pixel_source_property =3D prop; > >> + > >> + return 0; > >> +} > >> +EXPORT_SYMBOL(drm_plane_create_pixel_source_property); > >> diff --git a/include/drm/drm_blend.h b/include/drm/drm_blend.h > >> index 0338a860b9c8..31af7cfa5b1b 100644 > >> --- a/include/drm/drm_blend.h > >> +++ b/include/drm/drm_blend.h > >> @@ -59,4 +59,6 @@ int drm_atomic_normalize_zpos(struct drm_device *dev= , > >> int drm_plane_create_blend_mode_property(struct drm_plane *plane, > >> unsigned int supported_modes= ); > >> int drm_plane_create_solid_fill_property(struct drm_plane *plane); > >> +int drm_plane_create_pixel_source_property(struct drm_plane *plane, > >> + unsigned int supported_sour= ces); > >> #endif > >> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h > >> index f6ab313cb83e..73fb6cf8a5d9 100644 > >> --- a/include/drm/drm_plane.h > >> +++ b/include/drm/drm_plane.h > >> @@ -59,6 +59,12 @@ struct drm_solid_fill { > >> uint32_t b; > >> }; > >> > >> +enum drm_plane_pixel_source { > >> + DRM_PLANE_PIXEL_SOURCE_FB, > >> + DRM_PLANE_PIXEL_SOURCE_COLOR, > >> + DRM_PLANE_PIXEL_SOURCE_MAX > >> +}; > >> + > >> /** > >> * struct drm_plane_state - mutable plane state > >> * > >> @@ -152,6 +158,14 @@ struct drm_plane_state { > >> */ > >> struct drm_solid_fill solid_fill; > >> > >> + /* > >> + * @pixel_source: > >> + * > >> + * Source of pixel information for the plane. See > >> + * drm_plane_create_pixel_source_property() for more details. > >> + */ > >> + enum drm_plane_pixel_source pixel_source; > >> + > >> /** > >> * @alpha: > >> * Opacity of the plane with 0 as completely transparent and = 0xffff as > >> @@ -742,6 +756,13 @@ struct drm_plane { > >> */ > >> struct drm_property *solid_fill_property; > >> > >> + /* > >> + * @pixel_source_property: > >> + * Optional pixel_source property for this plane. See > >> + * drm_plane_create_pixel_source_property(). > >> + */ > >> + struct drm_property *pixel_source_property; > >> + > >> /** > >> * @alpha_property: > >> * Optional alpha property for this plane. See > >> > >> -- > >> 2.41.0 > >> > > >