From patchwork Mon Oct 25 19:34:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Matheus Andrade Torrente X-Patchwork-Id: 12582709 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6990C433EF for ; Mon, 25 Oct 2021 19:37:00 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 70245611AE for ; Mon, 25 Oct 2021 19:37:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 70245611AE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C916389CF4; Mon, 25 Oct 2021 19:36:59 +0000 (UTC) Received: from mail-ua1-x936.google.com (mail-ua1-x936.google.com [IPv6:2607:f8b0:4864:20::936]) by gabe.freedesktop.org (Postfix) with ESMTPS id A9ACF89CF4 for ; Mon, 25 Oct 2021 19:36:58 +0000 (UTC) Received: by mail-ua1-x936.google.com with SMTP id f4so24459886uad.4 for ; Mon, 25 Oct 2021 12:36:58 -0700 (PDT) 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=g8AjUosguFFwtSTTUN5QcdLFCu3iDK1fKV4GOcMHHcY=; b=PcFs/wEZ8VbxCwliv/507Hskt3Tv4UKYeemuI4UqTdrbbsNSUr77o2qmmmm8veIpOU L7BTaLKeNRglTJlWBkS+BcovqQzHdCPqnjRqaYDv16pZeVLDzTYEmsZ9nacC4111Zcfn JyaN+U+y9SpQeut3Sd+edrj0KkOGxA+SdurMwcAinP3rPQ/aoO81o41mouHeVEDzDGIW nkiI79WpaXten0IEE+fhz8xPprhNA74wfQfVG5RyOedDQ+OpkqWDEqj+9x5yggc1Anib IL2WhHGrwuq3akF2auf2gNUKxa1mLGdm/pAdN29QPFJY1qRPRF5knJE10cL0GmkGet8Y q8MQ== 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=g8AjUosguFFwtSTTUN5QcdLFCu3iDK1fKV4GOcMHHcY=; b=s+vJTHAkPMD6AY0yz+Hj38QujwXbMzSMsGNkDl2DUqPtntuuDV2r3djiwaie1qIDpa auXNzRou6FCP82D6MWKlAdEl1j/fXKiLSTmGazNyfZv7+VveAFtop5zMMFxZMZHM65kn s1phPr5cToRgAXWgNPT2LvmiKq594IeggC4lrZ1HQYVFYcDyJiPXhaVXALFHEAiAVIRn rpV9UhBAwcuCzW29mu263hyqWqRMcVbQAQF/cJEqpFVGRffPU6dSBfX0U2jMi3YnDYFE eMNO0OVHoedEjzsSKTK8mJ27vT3vOAkxbljbVU6SMvkV7gRjU8VYDlOCTiPFdfbCZ+Cm oTsA== X-Gm-Message-State: AOAM533eTFpA1beIER7JdzINcf0q8+tPHczvKa28TgnCywj3jYe2ZPcn txqaBNUfXsyf3UAY80EG6nA= X-Google-Smtp-Source: ABdhPJxbIFVEYUhGCmCqLkmeJIKfqKSxp4Bt9YHB2j6AjqyrxO8wYtK4xzn/gHvg9xXj6E+uc6prZw== X-Received: by 2002:ab0:344e:: with SMTP id a14mr17215149uaq.63.1635190617719; Mon, 25 Oct 2021 12:36:57 -0700 (PDT) Received: from localhost.localdomain ([2804:431:c7f4:5469:b11e:67b8:49d2:1744]) by smtp.googlemail.com with ESMTPSA id k1sm10722013uaq.0.2021.10.25.12.36.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Oct 2021 12:36:57 -0700 (PDT) From: Igor Torrente To: rodrigosiqueiramelo@gmail.com, melissa.srw@gmail.com, ppaalanen@gmail.com, tzimmermann@suse.de Cc: Igor Torrente , hamohammed.sa@gmail.com, daniel@ffwll.ch, airlied@linux.ie, contact@emersion.fr, leandro.ribeiro@collabora.com, dri-devel@lists.freedesktop.org Subject: [PATCH v2 1/8] drm: vkms: Replace the deprecated drm_mode_config_init Date: Mon, 25 Oct 2021 16:34:37 -0300 Message-Id: <20211025193444.131207-2-igormtorrente@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211025193444.131207-1-igormtorrente@gmail.com> References: <20211025193444.131207-1-igormtorrente@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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The `drm_mode_config_init` was deprecated since c3b790e commit, and it's being replaced by the `drmm_mode_config_init`. Signed-off-by: Igor Torrente --- V2: Change the code style(Thomas Zimmermann). --- drivers/gpu/drm/vkms/vkms_drv.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index 0ffe5f0e33f7..ee4d96dabe19 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -140,8 +140,12 @@ static const struct drm_mode_config_helper_funcs vkms_mode_config_helpers = { static int vkms_modeset_init(struct vkms_device *vkmsdev) { struct drm_device *dev = &vkmsdev->drm; + int ret; + + ret = drmm_mode_config_init(dev); + if (ret < 0) + return ret; - drm_mode_config_init(dev); dev->mode_config.funcs = &vkms_mode_funcs; dev->mode_config.min_width = XRES_MIN; dev->mode_config.min_height = YRES_MIN; From patchwork Mon Oct 25 19:34:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Matheus Andrade Torrente X-Patchwork-Id: 12582711 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C9BCC433F5 for ; Mon, 25 Oct 2021 19:37:05 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id D555F60238 for ; Mon, 25 Oct 2021 19:37:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D555F60238 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6733189CF9; Mon, 25 Oct 2021 19:37:03 +0000 (UTC) Received: from mail-ua1-x92e.google.com (mail-ua1-x92e.google.com [IPv6:2607:f8b0:4864:20::92e]) by gabe.freedesktop.org (Postfix) with ESMTPS id A0F8F89CF9 for ; Mon, 25 Oct 2021 19:37:01 +0000 (UTC) Received: by mail-ua1-x92e.google.com with SMTP id e10so24505534uab.3 for ; Mon, 25 Oct 2021 12:37:01 -0700 (PDT) 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=wqMc7i1j40Y6DJkM28XSTOEIlGNuQurfBNScJR7ESu8=; b=PlANtSRA1rym/yuHpq5hDpfqE0nbRxtUgqstn07en9N2u+IBo2RDOCdJNfDOh6TOKM 8bOF82QUuGTOzoxBzxGAn0U/tK4gJ576Zte559slH9xmBOwN/RlfpHBUkVdpbMYyEQ8R Iz3q2QRjXkxOXyDsMGFrML+SlDZndKYOO3nyzZaAEHLTZtmEbAa07FqNuEtmM38I/GZg G8QaWqs9L8baxICcHqUka/nybMWW20FkRY+2qk8RnCsHt/jh7pjY7IAXQ5vcelHigBDH mc9smzirpaMsHlUMkBwWj/J3IujWYS2GC/PvB94odduKYXCGD3V6NnvTN3fp9VI7/c+W H/8A== 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=wqMc7i1j40Y6DJkM28XSTOEIlGNuQurfBNScJR7ESu8=; b=0jkARcOTBgLFWy86ZHg+r+1pXtEMY2OUQToT9bl2DFUSkhdWKXqxjMtC8vrq/4K1ng WwWBIRspMypFfT7any1DPS14OD0t1NzQRPytyGWRpethOX0Nkz28UV9A+RGVJS9P9O/V xDsY9N6QIVQkQz+19azN/s890KD1eUu9+rbz/J5o7LX9cikk2KQPibsRAn/PzhK4/avz vfDovjyAadmXvfpHSMR8qBI8y2lTx+WbqvVA7+Ywi5VVFkL2Tgd6NVFFu9Eu2vKPfpI+ GdYD0XBPzzbF9bV8ewkHsDrO/96A8nFNZBHMQ3FzaPKCwkqvxpYo+Z7DnQA1HfYbYqHN QwAQ== X-Gm-Message-State: AOAM530nSBnh353FbwSJAIM8K0bpaMMejZBQ6nbDplD4X2dtBXLOMLfy cFP58B1H/fbnVgOeaeK2PiE= X-Google-Smtp-Source: ABdhPJwUeUo+LUjdIx9jpeOaVyyPLhf0p9KTe4AmSuYDGNxs2POuCwgzLAE435Umc8FfwqhfGYQb8w== X-Received: by 2002:a67:d810:: with SMTP id e16mr17018450vsj.42.1635190620656; Mon, 25 Oct 2021 12:37:00 -0700 (PDT) Received: from localhost.localdomain ([2804:431:c7f4:5469:b11e:67b8:49d2:1744]) by smtp.googlemail.com with ESMTPSA id k1sm10722013uaq.0.2021.10.25.12.36.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Oct 2021 12:37:00 -0700 (PDT) From: Igor Torrente To: rodrigosiqueiramelo@gmail.com, melissa.srw@gmail.com, ppaalanen@gmail.com, tzimmermann@suse.de Cc: Igor Torrente , hamohammed.sa@gmail.com, daniel@ffwll.ch, airlied@linux.ie, contact@emersion.fr, leandro.ribeiro@collabora.com, dri-devel@lists.freedesktop.org Subject: [PATCH v2 2/8] drm: vkms: Alloc the compose frame using vzalloc Date: Mon, 25 Oct 2021 16:34:38 -0300 Message-Id: <20211025193444.131207-3-igormtorrente@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211025193444.131207-1-igormtorrente@gmail.com> References: <20211025193444.131207-1-igormtorrente@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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Currently, the memory to the composition frame is being allocated using the kzmalloc. This comes with the limitation of maximum size of one page size(which in the x86_64 is 4Kb and 4MB for default and hugepage respectively). Somes test of igt (e.g. kms_plane@pixel-format) uses more than 4MB when testing some pixel formats like ARGB16161616. This problem is addessed by allocating the memory using kvzalloc that circunvents this limitation. Signed-off-by: Igor Torrente --- drivers/gpu/drm/vkms/vkms_composer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index 9e8204be9a14..82f79e508f81 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -180,7 +180,7 @@ static int compose_active_planes(void **vaddr_out, int i; if (!*vaddr_out) { - *vaddr_out = kzalloc(gem_obj->size, GFP_KERNEL); + *vaddr_out = kvzalloc(gem_obj->size, GFP_KERNEL); if (!*vaddr_out) { DRM_ERROR("Cannot allocate memory for output frame."); return -ENOMEM; @@ -263,7 +263,7 @@ void vkms_composer_worker(struct work_struct *work) crtc_state); if (ret) { if (ret == -EINVAL && !wb_pending) - kfree(vaddr_out); + kvfree(vaddr_out); return; } @@ -275,7 +275,7 @@ void vkms_composer_worker(struct work_struct *work) crtc_state->wb_pending = false; spin_unlock_irq(&out->composer_lock); } else { - kfree(vaddr_out); + kvfree(vaddr_out); } /* From patchwork Mon Oct 25 19:34:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Matheus Andrade Torrente X-Patchwork-Id: 12582713 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A10DC433F5 for ; Mon, 25 Oct 2021 19:37:09 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 3688E60F46 for ; Mon, 25 Oct 2021 19:37:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3688E60F46 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F01476E202; Mon, 25 Oct 2021 19:37:07 +0000 (UTC) Received: from mail-ua1-x930.google.com (mail-ua1-x930.google.com [IPv6:2607:f8b0:4864:20::930]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9A9AC6E207 for ; Mon, 25 Oct 2021 19:37:04 +0000 (UTC) Received: by mail-ua1-x930.google.com with SMTP id f24so5307477uav.12 for ; Mon, 25 Oct 2021 12:37:04 -0700 (PDT) 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=4h5zssoprQVwUD/a+0iu7NgShrwtvdhuvMV0VoWpIVI=; b=AfFIH3PNBuyuiRd7wt9SbKOfVrU39AWSS0wMW64L31R7mkj/gIdjKFd7yyNB1xQtX8 UMvVanm23vGqCakOy/fdazF/bUTiJPXI3HOQ9f9NCz+j1sZ1n41aYY6vwGkBVfaZc3CR vf1moKvOUoUedAMtwFZXhIVhBSi/1W1ycgwWBopc8sXWPxvLR+qgx8FeUpuMkGmDdpfF A5zW1TuG4JMDFw8PZhmPPJt96ZH3Nl2fqTquSTL/nsajjxB+j38DNNErkE1MG/xRdXyD 9pxP9q57JFqc1ZQ6S9OfxhFvtFUC37JvIP3WPs9Vu69gJbumrqTR/1dOXwrHNah3teCc L5uQ== 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=4h5zssoprQVwUD/a+0iu7NgShrwtvdhuvMV0VoWpIVI=; b=J0k94xmq/T4v1tRQKH5aW55t8isEXJvSy9NNeTN3wIpXkq4A+pDTdhFJmT5M/5kNjj ZR3oPwvsnJZ6mmMXN/rIxJrdTU5sSw1SCAYaCFLvOOQbEV5uFUv1vdS61LVNTvCMcYS4 b/Gwtv49UKNqzvbuEeLcjC2y9JKF61fxCQmUXbPoWo5sKDIawnMwLYSlmxT6Ug/1V0ps lxf/aWNYllaX7kVHLtjN0huJ/EtFfcSf1g9Pah4Hm9oD4YyXbl13I0MyY1b65klzYaGs UstX5qnQ+gSwi+yN65DlOAvZaQX2bTeE+XbsvL61sNfQw6qzjz/zoPkZz9ntCKtf9uLA eeUw== X-Gm-Message-State: AOAM531STu295pjYOtq72ArAU6UB2FVvfcIm+39oMiRBadM4kfHM7EVf MBovpm5CUrjpGS3kQgX0aCI= X-Google-Smtp-Source: ABdhPJwKa8WuN24vWFE+ZjfJvyn0cipMm9CoKlqLtaZwmLUbo7Rzu+Wpx4BcJOY5MG+PtJbIcBYp1A== X-Received: by 2002:a67:ed5a:: with SMTP id m26mr17102156vsp.35.1635190623644; Mon, 25 Oct 2021 12:37:03 -0700 (PDT) Received: from localhost.localdomain ([2804:431:c7f4:5469:b11e:67b8:49d2:1744]) by smtp.googlemail.com with ESMTPSA id k1sm10722013uaq.0.2021.10.25.12.37.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Oct 2021 12:37:03 -0700 (PDT) From: Igor Torrente To: rodrigosiqueiramelo@gmail.com, melissa.srw@gmail.com, ppaalanen@gmail.com, tzimmermann@suse.de Cc: Igor Torrente , hamohammed.sa@gmail.com, daniel@ffwll.ch, airlied@linux.ie, contact@emersion.fr, leandro.ribeiro@collabora.com, dri-devel@lists.freedesktop.org Subject: [PATCH v2 3/8] drm: vkms: Replace hardcoded value of `vkms_composer.map` to DRM_FORMAT_MAX_PLANES Date: Mon, 25 Oct 2021 16:34:39 -0300 Message-Id: <20211025193444.131207-4-igormtorrente@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211025193444.131207-1-igormtorrente@gmail.com> References: <20211025193444.131207-1-igormtorrente@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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The `map` vector at `vkms_composer` uses a hardcoded value to define its size. If someday the maximum number of planes increases, this hardcoded value can be a problem. This value is being replaced with the DRM_FORMAT_MAX_PLANES macro. Signed-off-by: Igor Torrente --- drivers/gpu/drm/vkms/vkms_drv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index d48c23d40ce5..64e62993b06f 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -28,7 +28,7 @@ struct vkms_writeback_job { struct vkms_composer { struct drm_framebuffer fb; struct drm_rect src, dst; - struct dma_buf_map map[4]; + struct dma_buf_map map[DRM_FORMAT_MAX_PLANES]; unsigned int offset; unsigned int pitch; unsigned int cpp; From patchwork Mon Oct 25 19:34:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Matheus Andrade Torrente X-Patchwork-Id: 12582715 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A2DBC433FE for ; Mon, 25 Oct 2021 19:37:19 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 2055360F9B for ; Mon, 25 Oct 2021 19:37:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2055360F9B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 486A16E207; Mon, 25 Oct 2021 19:37:18 +0000 (UTC) Received: from mail-ua1-x92c.google.com (mail-ua1-x92c.google.com [IPv6:2607:f8b0:4864:20::92c]) by gabe.freedesktop.org (Postfix) with ESMTPS id B5D4D6E207 for ; Mon, 25 Oct 2021 19:37:16 +0000 (UTC) Received: by mail-ua1-x92c.google.com with SMTP id k28so20183692uaa.10 for ; Mon, 25 Oct 2021 12:37:16 -0700 (PDT) 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=vTJgeD6lPy222typZ3Q5onBN26bymP3kzPrhRNt/7Mo=; b=UhdUzw7RZQG5A2XwZjEsGAPXXWws8ksxEHvolJG/p4VAQhZa4f7PcQ7P0mj6j73SOh 3nSbVm1IPtKeEX/gjJ7kns2hs6F37Tc7FkX1noWLWhBWwm39YqqLyyLj7JEmgjd4he+t zYk2ErMvC4vdaA51nFwEeM/dacIhjEi5tewQ5BvFUtDCord/gMTO68hbRUwUsGapKpn7 vF3wEvQCjTf/imB5rSA+lf4boTHikPwyiPHr2BPfbw90UF/rREsKsbPUYeno1oSMdefu rf0zHvoJI4+Tf0zQ60bPYuZe7IDuiVuPHJnD2PFdgLHbY34t+8a/Aa+zXYbpX6Ytyeq0 vSHA== 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=vTJgeD6lPy222typZ3Q5onBN26bymP3kzPrhRNt/7Mo=; b=Ho/UVKcz6N+z0d4bPwpmm0bHPvVfWSlpgJjpw3dTlspS1YeYHcqPWA9GmTlkSr+GW+ uDKmzja2l1DSxxhU1LDMu8MPeZo0AKpYlXtTFduuy2DATqbGZtnanQrCiUTdZKLm/RQi TD3Krfh3YYj+arkeDjNHb0mux7paFUKfxe5iOiUWGaQz37iBt5hDqJ9Acy6fBXKepJlr KvFe9e1ZWYjrB2iJV/MM4oIUrLJzbY0eXRzDYYygusZ2AG2QTp0A/PKshgH6/tyYiXAK vt8gZWy+R407+iGlG9WTTv6aTXYBt15IgfWWmtuKHMgWnZHxh5r0zitMZYFnxtcwxXkz M4Nw== X-Gm-Message-State: AOAM530M2I2/qWNjKG/7CeOUgELYmz2tP+DQstc95HiUV4cizRJyJy8m MmUUFHuCEdIixFGOLJbH+ek= X-Google-Smtp-Source: ABdhPJxlv+3Fl/EI2C9ZKJbhHrTP92hgZ7yIviZFixOx4+b1z+2+car1+0+u6nf9a5TngNljcuv3BA== X-Received: by 2002:a67:ed5a:: with SMTP id m26mr17103662vsp.35.1635190635918; Mon, 25 Oct 2021 12:37:15 -0700 (PDT) Received: from localhost.localdomain ([2804:431:c7f4:5469:b11e:67b8:49d2:1744]) by smtp.googlemail.com with ESMTPSA id k1sm10722013uaq.0.2021.10.25.12.37.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Oct 2021 12:37:15 -0700 (PDT) From: Igor Torrente To: rodrigosiqueiramelo@gmail.com, melissa.srw@gmail.com, ppaalanen@gmail.com, tzimmermann@suse.de Cc: Igor Torrente , hamohammed.sa@gmail.com, daniel@ffwll.ch, airlied@linux.ie, contact@emersion.fr, leandro.ribeiro@collabora.com, dri-devel@lists.freedesktop.org Subject: [PATCH v2 7/8] drm: vkms: Exposes ARGB_1616161616 and adds XRGB_16161616 formats Date: Mon, 25 Oct 2021 16:34:43 -0300 Message-Id: <20211025193444.131207-8-igormtorrente@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211025193444.131207-1-igormtorrente@gmail.com> References: <20211025193444.131207-1-igormtorrente@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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This will be useful to write tests that depends on these formats. ARGB format is already used as the universal format for internal uses. Here we are just exposing it to the user space. XRGB follows the a similar implementation of the former format. Just overwriting the alpha channel. Signed-off-by: Igor Torrente --- drivers/gpu/drm/vkms/vkms_composer.c | 4 ++++ drivers/gpu/drm/vkms/vkms_formats.h | 25 +++++++++++++++++++++++++ drivers/gpu/drm/vkms/vkms_plane.c | 5 ++++- drivers/gpu/drm/vkms/vkms_writeback.c | 2 ++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index 69fe3a89bdc9..f16fcfc88cea 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -164,6 +164,8 @@ static void ((*get_line_fmt_transform_function(u32 format)) return &ARGB8888_to_ARGB16161616; else if (format == DRM_FORMAT_ARGB16161616) return &get_ARGB16161616; + else if (format == DRM_FORMAT_XRGB16161616) + return &XRGB16161616_to_ARGB16161616; else return &XRGB8888_to_ARGB16161616; } @@ -175,6 +177,8 @@ static void ((*get_output_line_function(u32 format)) return &convert_to_ARGB8888; else if (format == DRM_FORMAT_ARGB16161616) return &convert_to_ARGB16161616; + else if (format == DRM_FORMAT_XRGB16161616) + return &convert_to_XRGB16161616; else return &convert_to_XRGB8888; } diff --git a/drivers/gpu/drm/vkms/vkms_formats.h b/drivers/gpu/drm/vkms/vkms_formats.h index 5b850fce69f3..aa433edd00bd 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.h +++ b/drivers/gpu/drm/vkms/vkms_formats.h @@ -89,6 +89,19 @@ static void get_ARGB16161616(void *pixels_addr, int length, u64 *line_buffer) } } +static void XRGB16161616_to_ARGB16161616(void *pixels_addr, int length, + u64 *line_buffer) +{ + __le64 *src_pixels = pixels_addr; + int i; + + for (i = 0; i < length; i++) { + line_buffer[i] = le64_to_cpu(*src_pixels) | (0xffffllu << 48); + + src_pixels++; + } +} + /* * The following functions are used as blend operations. But unlike the * `alpha_blend`, these functions take an ARGB16161616 pixel from the @@ -152,4 +165,16 @@ static void convert_to_ARGB16161616(void *pixels_addr, int length, } } +static void convert_to_XRGB16161616(void *pixels_addr, int length, + u64 *line_buffer) +{ + __le64 *dst_pixels = pixels_addr; + int i; + + for (i = 0; i < length; i++) { + *dst_pixels = cpu_to_le64(line_buffer[i] | (0xffffllu << 48)); + dst_pixels++; + } +} + #endif /* _VKMS_FORMATS_H_ */ diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 0a28cb7a85e2..516e48b38806 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -13,11 +13,14 @@ static const u32 vkms_formats[] = { DRM_FORMAT_XRGB8888, + DRM_FORMAT_XRGB16161616 }; static const u32 vkms_plane_formats[] = { DRM_FORMAT_ARGB8888, - DRM_FORMAT_XRGB8888 + DRM_FORMAT_XRGB8888, + DRM_FORMAT_XRGB16161616, + DRM_FORMAT_ARGB16161616 }; static struct drm_plane_state * diff --git a/drivers/gpu/drm/vkms/vkms_writeback.c b/drivers/gpu/drm/vkms/vkms_writeback.c index 42f3396c523a..0f7bb77f981e 100644 --- a/drivers/gpu/drm/vkms/vkms_writeback.c +++ b/drivers/gpu/drm/vkms/vkms_writeback.c @@ -14,6 +14,8 @@ static const u32 vkms_wb_formats[] = { DRM_FORMAT_XRGB8888, + DRM_FORMAT_XRGB16161616, + DRM_FORMAT_ARGB16161616 }; static const struct drm_connector_funcs vkms_wb_connector_funcs = { From patchwork Mon Oct 25 19:34:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Matheus Andrade Torrente X-Patchwork-Id: 12582717 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CC22C4332F for ; Mon, 25 Oct 2021 19:37:24 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 018D4610D2 for ; Mon, 25 Oct 2021 19:37:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 018D4610D2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 31EBF89700; Mon, 25 Oct 2021 19:37:23 +0000 (UTC) Received: from mail-ua1-x92d.google.com (mail-ua1-x92d.google.com [IPv6:2607:f8b0:4864:20::92d]) by gabe.freedesktop.org (Postfix) with ESMTPS id DDC3D6E20B for ; Mon, 25 Oct 2021 19:37:19 +0000 (UTC) Received: by mail-ua1-x92d.google.com with SMTP id x3so5195341uar.13 for ; Mon, 25 Oct 2021 12:37:19 -0700 (PDT) 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=BpzB9psURBvhNvmXpPEQXb13hz7OsGQ74tdDzFCqOD4=; b=TlSD85XJaIoNMI754/tPjxLA+O0N3S/VCODwSchKarLwtiTo03kW4AmLhnk5iD2zNK zmCvzZ1gF/oLaXSDx6vDGu9ee/xWp+7RpUFHQ1K/F0NiXHs2M8H8ND+qAZVVG8jg905U uzgMdI34JcJebE+Uawo+i6Digl7lAwkSI9yj99lCWP8k1vtDx4VMyExQlrosvtttJfV6 4rzcMQsteB8VmzVwvsEQv+2Jsy22xAHd7/t8cmcHoUmcxlKkj22hv8DCgzpBcevol+oM Tyx5pVZUG9soOmIe9ZJhWda0UJLPRGz2lFcguEOYaNRLzD0GKnLIiXWeRAAAo4KIAntz o8Ig== 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=BpzB9psURBvhNvmXpPEQXb13hz7OsGQ74tdDzFCqOD4=; b=lGvuBgJjsZqtHxqVy4OoPTeFZABhvwWGgS/7FH9akVnb+jMjyhIrMkPSoCttilyUgr QaoDfjzNPx3vN5Hp97MG30ITgGthICo29cgvY0tjkVFfRwqMDhdnGcBBnLldykN12Xh6 QDSwSiGLKyI/pb/5tMNhrITOSjpZfmvspi85ZAT6srjtMjVdpbImqvjSOh22JqzDUHRI tviOgMf6dV4b8ZUEOFRKCc142eeKcNt1SxCBdvwFsd+Pi2L2AEJM7lQVJ4tFv9mawTLY XMYGsf3Lp3FZS8BHMUzTUK1rKpR7iVTVwg/g0qKhN7TenUzpvxhjUvaISWYOQwvIYJdZ sH+g== X-Gm-Message-State: AOAM530AmPnQA87UkaRPtlfEmrKuUpmgAj5k19ZCP/y99Ca3RcN1ssm5 CAm2hMNLQumJayPDUSwkpxfFmrsfkG8= X-Google-Smtp-Source: ABdhPJwguy3hP8tfm46E5ZJSruQN0IVWoHzihcDSez+Oi1xVPR3EKy00uVHhy/C7m5Uz+q6nyuKDow== X-Received: by 2002:a67:d996:: with SMTP id u22mr17493928vsj.12.1635190638954; Mon, 25 Oct 2021 12:37:18 -0700 (PDT) Received: from localhost.localdomain ([2804:431:c7f4:5469:b11e:67b8:49d2:1744]) by smtp.googlemail.com with ESMTPSA id k1sm10722013uaq.0.2021.10.25.12.37.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Oct 2021 12:37:18 -0700 (PDT) From: Igor Torrente To: rodrigosiqueiramelo@gmail.com, melissa.srw@gmail.com, ppaalanen@gmail.com, tzimmermann@suse.de Cc: Igor Torrente , hamohammed.sa@gmail.com, daniel@ffwll.ch, airlied@linux.ie, contact@emersion.fr, leandro.ribeiro@collabora.com, dri-devel@lists.freedesktop.org Subject: [PATCH v2 8/8] drm: vkms: Add support the RGB565 format Date: Mon, 25 Oct 2021 16:34:44 -0300 Message-Id: <20211025193444.131207-9-igormtorrente@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211025193444.131207-1-igormtorrente@gmail.com> References: <20211025193444.131207-1-igormtorrente@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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Adds this common format to vkms. This commit also adds new helper macros to deal with fixed-point arithmetic. It was done to improve the precision of the conversion to ARGB16161616 since the "conversion ratio" is not an integer. Signed-off-by: Igor Torrente --- drivers/gpu/drm/vkms/vkms_composer.c | 4 ++ drivers/gpu/drm/vkms/vkms_formats.h | 72 +++++++++++++++++++++++++++ drivers/gpu/drm/vkms/vkms_plane.c | 6 ++- drivers/gpu/drm/vkms/vkms_writeback.c | 3 +- 4 files changed, 82 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index f16fcfc88cea..57ec82839a89 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -166,6 +166,8 @@ static void ((*get_line_fmt_transform_function(u32 format)) return &get_ARGB16161616; else if (format == DRM_FORMAT_XRGB16161616) return &XRGB16161616_to_ARGB16161616; + else if (format == DRM_FORMAT_RGB565) + return &RGB565_to_ARGB16161616; else return &XRGB8888_to_ARGB16161616; } @@ -179,6 +181,8 @@ static void ((*get_output_line_function(u32 format)) return &convert_to_ARGB16161616; else if (format == DRM_FORMAT_XRGB16161616) return &convert_to_XRGB16161616; + else if (format == DRM_FORMAT_RGB565) + return &convert_to_RGB565; else return &convert_to_XRGB8888; } diff --git a/drivers/gpu/drm/vkms/vkms_formats.h b/drivers/gpu/drm/vkms/vkms_formats.h index aa433edd00bd..1e2db1a844aa 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.h +++ b/drivers/gpu/drm/vkms/vkms_formats.h @@ -8,6 +8,26 @@ #define pixel_offset(composer, x, y) \ ((composer)->offset + ((y) * (composer)->pitch) + ((x) * (composer)->cpp)) +/* + * FP stands for _Fixed Point_ and **not** _Float Point_ + * LF stands for Long Float (i.e. double) + * The following macros help doing fixed point arithmetic. + */ +/* + * With FP scale 15 we have 17 and 15 bits of integer and fractional parts + * respectively. + * | 0000 0000 0000 0000 0.000 0000 0000 0000 | + * 31 0 + */ +#define FP_SCALE 15 + +#define LF_TO_FP(a) ((a) * (u64)(1 << FP_SCALE)) +#define INT_TO_FP(a) ((a) << FP_SCALE) +#define FP_MUL(a, b) ((s32)(((s64)(a) * (b)) >> FP_SCALE)) +#define FP_DIV(a, b) ((s32)(((s64)(a) << FP_SCALE) / (b))) +/* This macro converts a fixed point number to int, and round half up it */ +#define FP_TO_INT_ROUND_UP(a) (((a) + (1 << (FP_SCALE - 1))) >> FP_SCALE) + /* * packed_pixels_addr - Get the pointer to pixel of a given pair of coordinates * @@ -102,6 +122,35 @@ static void XRGB16161616_to_ARGB16161616(void *pixels_addr, int length, } } +static void RGB565_to_ARGB16161616(void *pixels_addr, int length, + u64 *line_buffer) +{ + __le16 *src_pixels = pixels_addr; + int i; + + for (i = 0; i < length; i++) { + u16 rgb_565 = le16_to_cpu(*src_pixels); + int fp_r = INT_TO_FP((rgb_565 >> 11) & 0x1f); + int fp_g = INT_TO_FP((rgb_565 >> 5) & 0x3f); + int fp_b = INT_TO_FP(rgb_565 & 0x1f); + + /* + * The magic constants is the "conversion ratio" and is calculated + * dividing 65535(2^16 - 1) by 31(2^5 -1) and 63(2^6 - 1) respectively. + */ + int fp_rb_ratio = LF_TO_FP(2114.032258065); + int fp_g_ratio = LF_TO_FP(1040.238095238); + + u64 r = FP_TO_INT_ROUND_UP(FP_MUL(fp_r, fp_rb_ratio)); + u64 g = FP_TO_INT_ROUND_UP(FP_MUL(fp_g, fp_g_ratio)); + u64 b = FP_TO_INT_ROUND_UP(FP_MUL(fp_b, fp_rb_ratio)); + + line_buffer[i] = 0xffffllu << 48 | r << 32 | g << 16 | b; + + src_pixels++; + } +} + /* * The following functions are used as blend operations. But unlike the * `alpha_blend`, these functions take an ARGB16161616 pixel from the @@ -177,4 +226,27 @@ static void convert_to_XRGB16161616(void *pixels_addr, int length, } } +static void convert_to_RGB565(void *pixels_addr, int length, + u64 *line_buffer) +{ + __le16 *dst_pixels = pixels_addr; + int i; + + for (i = 0; i < length; i++) { + int fp_r = INT_TO_FP((line_buffer[i] >> 32) & 0xffff); + int fp_g = INT_TO_FP((line_buffer[i] >> 16) & 0xffff); + int fp_b = INT_TO_FP(line_buffer[i] & 0xffffllu); + + int fp_rb_ratio = LF_TO_FP(2114.032258065); + int fp_g_ratio = LF_TO_FP(1040.238095238); + + u16 r = FP_TO_INT_ROUND_UP(FP_DIV(fp_r, fp_rb_ratio)); + u16 g = FP_TO_INT_ROUND_UP(FP_DIV(fp_g, fp_g_ratio)); + u16 b = FP_TO_INT_ROUND_UP(FP_DIV(fp_b, fp_rb_ratio)); + + *dst_pixels = cpu_to_le16(r << 11 | g << 5 | b); + dst_pixels++; + } +} + #endif /* _VKMS_FORMATS_H_ */ diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 516e48b38806..de250808aa39 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -13,14 +13,16 @@ static const u32 vkms_formats[] = { DRM_FORMAT_XRGB8888, - DRM_FORMAT_XRGB16161616 + DRM_FORMAT_XRGB16161616, + DRM_FORMAT_RGB565 }; static const u32 vkms_plane_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB8888, DRM_FORMAT_XRGB16161616, - DRM_FORMAT_ARGB16161616 + DRM_FORMAT_ARGB16161616, + DRM_FORMAT_RGB565 }; static struct drm_plane_state * diff --git a/drivers/gpu/drm/vkms/vkms_writeback.c b/drivers/gpu/drm/vkms/vkms_writeback.c index 0f7bb77f981e..11eb1be5a0fc 100644 --- a/drivers/gpu/drm/vkms/vkms_writeback.c +++ b/drivers/gpu/drm/vkms/vkms_writeback.c @@ -15,7 +15,8 @@ static const u32 vkms_wb_formats[] = { DRM_FORMAT_XRGB8888, DRM_FORMAT_XRGB16161616, - DRM_FORMAT_ARGB16161616 + DRM_FORMAT_ARGB16161616, + DRM_FORMAT_RGB565 }; static const struct drm_connector_funcs vkms_wb_connector_funcs = {