From patchwork Thu Dec 16 17:01:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 12682179 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2EEF8C433EF for ; Thu, 16 Dec 2021 17:02:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5D43110E260; Thu, 16 Dec 2021 17:02:04 +0000 (UTC) Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by gabe.freedesktop.org (Postfix) with ESMTPS id 459DC10E31E for ; Thu, 16 Dec 2021 17:02:03 +0000 (UTC) Received: by mail-wm1-x333.google.com with SMTP id o29so19369117wms.2 for ; Thu, 16 Dec 2021 09:02:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Axe4Q9VXvpGCP1w03oKYpmEgDNQia2jUa2INQifyMYg=; b=JnUskR6BQSx107PSNjQbFwC/egoZKWvzdtEKNpoEOvAysW1fM+UaksTnVw1zAJv45Q blVtyxzcM+gIQEv0XcennrIDlLGZ3x0h1D325REsRQCK2P+5UoLgMLuDHx7gxvnV2zt6 YECEfteZqW+PXKPurXESEjbHSSjeA9ZS7CxlDARUK8T9F1dfcLAnib/Uh3WBhu6tgU+K na0ZZhrjI3TfsiFHOmm0HrWY9ZTMk+zncmkrr7Kc2TLs24yVUaMvEJa+X7cEkopuMbBN 7f9tBr9qIELlIsKX7yR+QMwW8tIJ/mC1/cboxPH60la/L3MWL1WypHthAgDMe6I7GUIu sEfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Axe4Q9VXvpGCP1w03oKYpmEgDNQia2jUa2INQifyMYg=; b=sH4FYUT39h9UTpK3ZPmfi21QJjqr1uF+tYLwpxSiaccYy7Jadc9OblxuIJoP+luu6U 2Rm0qufQcRCICMWtg+Fga7nQbqd61tTtirM7kwKmAI4aq513Nn6sqmUFbBsR08vzDQro iURtkfIOGLsgkdfqcI1tQ7igzuuZruJU5eLdbUMhX7/8tRH7w4xJlWhQpVQorDzSh41a nIGEODBTNnyiKXbFsZJE7Dfi/S8W4G5XWhYARfV/N8XPNdM6CXw8+XWkThGEUyeW7Y3n Coz9yd6ZETLJTzwFLZequUNaUf+9WU8/gDpLO5Ab+oLB5zD51y8jSpPh9JfGnTtSccaE 6I+A== X-Gm-Message-State: AOAM532D8KqNQL7s8/n41j1DTZDi8S6TfUkQUexUKWi9jppZtffmKtEv s+E18hUvbSXu3zrNRcGi1lSghLG9MjWdgw== X-Google-Smtp-Source: ABdhPJyZR9qKxhXWhLSPZaa52rhCTCx7Oj3ZEeDXV7onBiivQ4yQXVK574JzTm6Dy+Uqi8ND6aP6nA== X-Received: by 2002:a05:600c:350a:: with SMTP id h10mr5786912wmq.62.1639674121776; Thu, 16 Dec 2021 09:02:01 -0800 (PST) Received: from localhost.localdomain ([217.113.240.86]) by smtp.gmail.com with ESMTPSA id n10sm5452472wri.67.2021.12.16.09.02.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 09:02:01 -0800 (PST) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: rodrigosiqueiramelo@gmail.com Subject: [PATCH v2 1/2] drm/vkms: add function to get plane formats Date: Thu, 16 Dec 2021 18:01:39 +0100 Message-Id: <20211216170140.15803-1-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: hamohammed.sa@gmail.com, airlied@linux.ie, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, melissa.srw@gmail.com, =?utf-8?b?Sm9zw6kg?= =?utf-8?b?RXhww7NzaXRv?= , cphealy@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Move the logic to get the plane formats depending on the plane type to its own function. Refactor, no functional changes. Signed-off-by: José Expósito --- drivers/gpu/drm/vkms/vkms_plane.c | 37 ++++++++++++++++--------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 32409e15244b..76a06dd92ac1 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -83,6 +83,23 @@ static void vkms_plane_reset(struct drm_plane *plane) __drm_gem_reset_shadow_plane(plane, &vkms_state->base); } +static void vkms_formats_for_plane_type(enum drm_plane_type type, + const u32 **formats, int *nformats) +{ + switch (type) { + case DRM_PLANE_TYPE_CURSOR: + case DRM_PLANE_TYPE_OVERLAY: + *formats = vkms_plane_formats; + *nformats = ARRAY_SIZE(vkms_plane_formats); + break; + case DRM_PLANE_TYPE_PRIMARY: + default: + *formats = vkms_formats; + *nformats = ARRAY_SIZE(vkms_formats); + break; + } +} + static const struct drm_plane_funcs vkms_plane_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, @@ -167,24 +184,8 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, const u32 *formats; int nformats; - switch (type) { - case DRM_PLANE_TYPE_PRIMARY: - formats = vkms_formats; - nformats = ARRAY_SIZE(vkms_formats); - funcs = &vkms_primary_helper_funcs; - break; - case DRM_PLANE_TYPE_CURSOR: - case DRM_PLANE_TYPE_OVERLAY: - formats = vkms_plane_formats; - nformats = ARRAY_SIZE(vkms_plane_formats); - funcs = &vkms_primary_helper_funcs; - break; - default: - formats = vkms_formats; - nformats = ARRAY_SIZE(vkms_formats); - funcs = &vkms_primary_helper_funcs; - break; - } + funcs = &vkms_primary_helper_funcs; + vkms_formats_for_plane_type(type, &formats, &nformats); plane = drmm_universal_plane_alloc(dev, struct vkms_plane, base, 1 << index, &vkms_plane_funcs, From patchwork Thu Dec 16 17:01:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 12682181 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5DB12C433EF for ; Thu, 16 Dec 2021 17:02:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2DC2510E4EC; Thu, 16 Dec 2021 17:02:08 +0000 (UTC) Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by gabe.freedesktop.org (Postfix) with ESMTPS id 356D610E4FE for ; Thu, 16 Dec 2021 17:02:05 +0000 (UTC) Received: by mail-wm1-x336.google.com with SMTP id g191-20020a1c9dc8000000b0032fbf912885so18539928wme.4 for ; Thu, 16 Dec 2021 09:02:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RHIbexvgyxYJ1k2n4EF0wOhYX1hcCGRht3QxBaZ21nc=; b=Mny18kM8HNgLVeESO+lTUDXQlg6tWo66tNrwSssq4emBapLqAgY6GbjofxwTEWF/0T drkxtwQxoY/QQA42ZSI1HoqU1WjjZDk10dUOLwh0awplFkCP8nHeFkGAQiRNqnWOtxOH LiB77mhaLbJl9V4R2kvPDVnQ+VR1sm8vUuJQEqXAFNwJH5wl81LyXWlmvxb42kjT1hdT IYWTEEf17o3L/Yhc6849lQ+Cq+LV80YOyzA60QJUuVm5vuNYfv5/tyVJhzYza39HuXYf NGCqLScJYQKE2fL/7kevudbUli3VFoNjdjumVZAp1C3bfitQO8ZeRdpinhAz5ONMcjhR jotg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RHIbexvgyxYJ1k2n4EF0wOhYX1hcCGRht3QxBaZ21nc=; b=tadlZfx3J5jmFuWguk/Z7SUHm66TUn+8huGv3EAVEL9qDwFw4ucQkyf4pqbO/pBRfr Uk0bMjL+85mjNGm7uWkJB7U5tL1GENdppsGq9a4GRqFB/DJgo37H2okNifGPkM8EtFMm RdQ9aHzqEhmLBoFouBK8idkOlZ+a1aZ2aOHajlaArKFlfMkUK30FbbLo3yqsDokSu87y tP8QSLOgbCdqlHrnkFlotcDK0hArYB8+oATIHIiakCc2VpqXMual5uaPbRGW8lkzDFZx Bks3uuDUhFNDBNqnC9jTexm2iKJqiMI7nOmaX+HxrKEm7UMTk0EoG4RNimUDvCplrEDC dI8Q== X-Gm-Message-State: AOAM532JitzkYoW0CEj3U//3/Gp9zftd4ee4/+56zEzJocvCBe5eOddu Q+K5rOfNex947kMeq3v7knY= X-Google-Smtp-Source: ABdhPJytLEeaQza+C4ISdN62zhwLhTua7exk5e1Pc1JpDVRvTsi2wpmFBiglcvYzGnBhS1qFlcckEQ== X-Received: by 2002:a05:600c:4e56:: with SMTP id e22mr5615636wmq.39.1639674123673; Thu, 16 Dec 2021 09:02:03 -0800 (PST) Received: from localhost.localdomain ([217.113.240.86]) by smtp.gmail.com with ESMTPSA id n10sm5452472wri.67.2021.12.16.09.02.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 09:02:03 -0800 (PST) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: rodrigosiqueiramelo@gmail.com Subject: [PATCH v2 2/2] drm/vkms: set plane modifiers Date: Thu, 16 Dec 2021 18:01:40 +0100 Message-Id: <20211216170140.15803-2-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211216170140.15803-1-jose.exposito89@gmail.com> References: <20211216170140.15803-1-jose.exposito89@gmail.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: hamohammed.sa@gmail.com, airlied@linux.ie, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, melissa.srw@gmail.com, =?utf-8?b?Sm9zw6kg?= =?utf-8?b?RXhww7NzaXRv?= , cphealy@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Where no modifiers are exposed, usually linear modifier is assumed. However, userspace code is starting to expect IN_FORMATS even when the only supported modifiers are linear [1]. To avoid possible issues, explicitly set the DRM_FORMAT_MOD_LINEAR modifier. [1] https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/599/diffs?commit_id=5aea1bc522f0874e6cc07f5120fbcf1736706536 Suggested-by: Chris Healy Signed-off-by: José Expósito --- v2: Implement format_mod_supported (Simon Ser) --- drivers/gpu/drm/vkms/vkms_plane.c | 34 ++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 76a06dd92ac1..7e0d021494c3 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -20,6 +20,11 @@ static const u32 vkms_plane_formats[] = { DRM_FORMAT_XRGB8888 }; +static const u64 vkms_plane_modifiers[] = { + DRM_FORMAT_MOD_LINEAR, + DRM_FORMAT_MOD_INVALID +}; + static struct drm_plane_state * vkms_plane_duplicate_state(struct drm_plane *plane) { @@ -100,12 +105,39 @@ static void vkms_formats_for_plane_type(enum drm_plane_type type, } } +static bool vkms_format_mod_supported(struct drm_plane *plane, u32 format, + u64 modifier) +{ + bool modifier_found = false; + unsigned int i; + const u32 *formats; + int nformats; + + for (i = 0; i < ARRAY_SIZE(vkms_plane_modifiers) - 1; i++) { + if (vkms_plane_modifiers[i] == modifier) + modifier_found = true; + } + + if (!modifier_found) + return false; + + vkms_formats_for_plane_type(plane->type, &formats, &nformats); + + for (i = 0; i < nformats; i++) { + if (formats[i] == format) + return true; + } + + return false; +} + static const struct drm_plane_funcs vkms_plane_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, .reset = vkms_plane_reset, .atomic_duplicate_state = vkms_plane_duplicate_state, .atomic_destroy_state = vkms_plane_destroy_state, + .format_mod_supported = vkms_format_mod_supported, }; static void vkms_plane_atomic_update(struct drm_plane *plane, @@ -190,7 +222,7 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, plane = drmm_universal_plane_alloc(dev, struct vkms_plane, base, 1 << index, &vkms_plane_funcs, formats, nformats, - NULL, type, NULL); + vkms_plane_modifiers, type, NULL); if (IS_ERR(plane)) return plane;