Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp21525515rwd; Thu, 29 Jun 2023 18:02:03 -0700 (PDT) X-Google-Smtp-Source: APBJJlGFDpNlAff1lSqIYNXPjNVBlB65lhelcVRbNC9j7DSl4ADsVmr+txzt8gB3alUZ2Wn4YjY/ X-Received: by 2002:a17:902:f545:b0:1b1:1168:656b with SMTP id h5-20020a170902f54500b001b11168656bmr1959609plf.26.1688086923302; Thu, 29 Jun 2023 18:02:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688086923; cv=none; d=google.com; s=arc-20160816; b=Jqn9aigkkwCvtFfS1vqLtQVFmZ+LCuHZRHxrN9nck0LST99bcnWrms0FFFD0SdoYP1 p2XOGWFC9eWSUti+lqKI7c4meUhwiWdxO4q2h+f60mR434UlBFdO+7BmXjv4AD4vTApL KvR2Kjr3Zcn2ZIwFvYPv1orb5A8Aosle7uI6m/LQIjD7kqaDyAWx7z5uKk/n8or9pBfk 81uZLFsqlzbZyHHMQrVHkqakB2Jp4O725lkCshJ2b0iFewt19SbdokSX8+OM7rTH5/TD sFLRdXeMYLqOf9qlUky8mvSEA/br+iNDSfD28THKO2ZW4KyyNoCGtfTinxaTX6LEDXwk G8WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=lAPlTdabfsz0jCPgQDKI7aPq9KfhvilxRGdFIKwbr8M=; fh=qzVtq+12QmJlLfSHX+cvjm5Xaxt5CHNwQYxNwaCG4V8=; b=aamKQ2xScJ1JeWvb8UwnkyT8GXDBP8fNyHo/nY6RGBYro8+RKjcjsKx+5Tp7oMpzDJ BbzqL6DaBRUlhUNJKv7N5fzZzDp5aMpwCJQO5PgEV/b3HwFS+nKn/u34NvlML3KxnOJ/ 0E0KRMh2X9+zBtGIu6iAqzVNrBrd95vD5aNn8qUaJzsk4EyC9fuQPXgdN0/TQYrfCyV1 v5wB8Rd2Bry5BOe6SFVMlVN3SCC+2sOV1sj97HtwotYh1wGigCFqFet7YimOi0MMReGj cJUuG1n7VJfP3DW+KOVquFRMeoPZRnc44M173Vbz8DliEyn9zIcaEtJ6OZa0nsDfV6ea KQxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=j1YRaA7H; 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=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kg14-20020a170903060e00b001b3e073e157si1819501plb.125.2023.06.29.18.01.50; Thu, 29 Jun 2023 18:02:03 -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=@quicinc.com header.s=qcppdkim1 header.b=j1YRaA7H; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232103AbjF3A0j (ORCPT + 99 others); Thu, 29 Jun 2023 20:26:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232180AbjF3A0L (ORCPT ); Thu, 29 Jun 2023 20:26:11 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3089630DF; Thu, 29 Jun 2023 17:26:06 -0700 (PDT) Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35U0LFYN027249; Fri, 30 Jun 2023 00:25:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : date : subject : mime-version : content-type : content-transfer-encoding : message-id : references : in-reply-to : to : cc; s=qcppdkim1; bh=lAPlTdabfsz0jCPgQDKI7aPq9KfhvilxRGdFIKwbr8M=; b=j1YRaA7HkX92gSqSAUOibCJYm2Y5k3TPhPP2JOvDf3rWXHY2OzV2IFSaxrPYjBGzMFgm 3xKY/jSzuY07THHiXCRvVoGR2pkyFKDkDq0mttl39w6dTb7X7rcxUcCDgafnEpm3yTNC QKfbSHChcFv8n15pNKTxZ68nqAPvOW5J1PPWgAqbVhAEgmhUN7mvXywgzaxPUlhwEXw3 pF3u8u+1nodqGon5AJSe5K8VMyRT2SoY8uvU4RYKTrin92td5lCXoWleRhs+26UNmN+N 1Wev87Tl8D/5a/4nO3grrHgz/TVdF7qDT36QsrU+o2YvlPvnkm2NLwsNwPo+FIzm/bZb /w== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rgy1tjfph-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 30 Jun 2023 00:25:37 +0000 Received: from nasanex01a.na.qualcomm.com (nasanex01a.na.qualcomm.com [10.52.223.231]) by NASANPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 35U0Parj010710 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 30 Jun 2023 00:25:36 GMT Received: from jesszhan-linux.qualcomm.com (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Thu, 29 Jun 2023 17:25:36 -0700 From: Jessica Zhang Date: Thu, 29 Jun 2023 17:25:01 -0700 Subject: [PATCH RFC v4 2/7] drm: Introduce pixel_source DRM plane property MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-ID: <20230404-solid-fill-v4-2-f4ec0caa742d@quicinc.com> References: <20230404-solid-fill-v4-0-f4ec0caa742d@quicinc.com> In-Reply-To: <20230404-solid-fill-v4-0-f4ec0caa742d@quicinc.com> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Clark , Dmitry Baryshkov , "Sean Paul" , Marijn Suijten CC: , , , , , , , , , , , Jessica Zhang X-Mailer: b4 0.13-dev-c6835 X-Developer-Signature: v=1; a=ed25519-sha256; t=1688084735; l=7128; i=quic_jesszhan@quicinc.com; s=20230329; h=from:subject:message-id; bh=JbsB75ScnJGdrFoWV3iEEmzBuoWRmdXBk1yeClXqevI=; b=nq0gG7V6jz+Z2cHWkgALPjhI4KxTMIHg6zsxemlJpwamS/l5gPbdc5ubxMzt0CZrkSdq+0/+B 1K7vvaxae+wBOabqKDoDpykGYE4Iy7/of9LppJ2XJO50U0AO2obkgYg X-Developer-Key: i=quic_jesszhan@quicinc.com; a=ed25519; pk=gAUCgHZ6wTJOzQa3U0GfeCDH7iZLlqIEPo4rrjfDpWE= X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: jnQtjANyIqhFLqtKwA24WrYE5rJd1rCU X-Proofpoint-GUID: jnQtjANyIqhFLqtKwA24WrYE5rJd1rCU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-29_10,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 impostorscore=0 mlxlogscore=679 mlxscore=0 malwarescore=0 lowpriorityscore=0 clxscore=1015 adultscore=0 priorityscore=1501 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306300002 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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 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/drm/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 = DRM_BLEND_ALPHA_OPAQUE; plane_state->pixel_blend_mode = DRM_MODE_BLEND_PREMULTI; + plane_state->pixel_source = 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_atomic_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 drm_plane *plane, drm_property_blob_put(solid_fill); return ret; + } else if (property == plane->pixel_source_property) { + state->pixel_source = val; } else if (property == plane->alpha_property) { state->alpha = val; } else if (property == plane->blend_mode_property) { @@ -671,6 +673,8 @@ drm_atomic_plane_get_property(struct drm_plane *plane, } else if (property == plane->solid_fill_property) { *val = state->solid_fill_blob ? state->solid_fill_blob->base.id : 0; + } else if (property == plane->pixel_source_property) { + *val = state->pixel_source; } else if (property == plane->alpha_property) { *val = state->alpha; } else if (property == 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_property(). 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_property(). + * 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 drm_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 driver (NOT + * including DRM_PLANE_PIXEL_SOURCE_FB, as it will 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 called + * "pixel_source" and has the following enumeration values: + * + * "FB": + * Framebuffer pixel source + * + * "COLOR": + * Solid fill color pixel source + * + * Returns: + * Zero on success, negative errno on failure. + */ +int drm_plane_create_pixel_source_property(struct drm_plane *plane, + unsigned int supported_sources) +{ + struct drm_device *dev = plane->dev; + struct drm_property *prop; + const struct drm_prop_enum_list enum_list[] = { + { DRM_PLANE_PIXEL_SOURCE_FB, "FB" }, + { DRM_PLANE_PIXEL_SOURCE_COLOR, "COLOR" }, + }; + unsigned int valid_source_mask = BIT(DRM_PLANE_PIXEL_SOURCE_FB) | + BIT(DRM_PLANE_PIXEL_SOURCE_COLOR); + int i; + + /* FB is supported by default */ + supported_sources |= BIT(DRM_PLANE_PIXEL_SOURCE_FB); + + if (WARN_ON(supported_sources & ~valid_source_mask)) + return -EINVAL; + + prop = drm_property_create(dev, DRM_MODE_PROP_ENUM, "pixel_source", + hweight32(supported_sources)); + + if (!prop) + return -ENOMEM; + + for (i = 0; i < ARRAY_SIZE(enum_list); i++) { + int ret; + + if (!(BIT(enum_list[i].type) & supported_sources)) + continue; + + ret = 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 = 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_sources); #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