From patchwork Mon May 25 01:52:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1297069 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=H/XvKH30; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49VgBs3F2Hz9sPF for ; Mon, 25 May 2020 11:54:45 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E50C1808A1; Mon, 25 May 2020 03:54:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="H/XvKH30"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 43E2E813A5; Mon, 25 May 2020 03:54:11 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1868180675 for ; Mon, 25 May 2020 03:54:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd42.google.com with SMTP id r2so6946016ioo.4 for ; Sun, 24 May 2020 18:54:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=aQTFXS3FuSGFYQjNntgbB6c+rNwt5HUqAnDU7oWQGS4=; b=H/XvKH30L+mLZ92PMtr28admIJoVwn+3DpUMosvfV2dQLEDTn4/JbDqK9S6ndrSmV9 L6GOIOPGVX7gh5lo6IXyvaeQ8PKU5ZrB/Uk+iQvGC+DcIialnQyCKoD3MZjGPcdFkJ5H UbYK1nCSrCqWI3KR+spaev1kDea3dmthtM6UU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=aQTFXS3FuSGFYQjNntgbB6c+rNwt5HUqAnDU7oWQGS4=; b=b1XuFYv1LwxhxDaHz5e1cniOXvf7eakf/HY62keG3BARQI5lMS2hY3xm7QypgplHZn RcKSwhsanoTejrzLvp28cqkaIuP6rIUJQgHL68H6zftw+mW51bqu7Ur5SEgxs7BYReed RB94dfvNh7KsmabBHH3iEc5SbXJZe6sA8aNUoGoeUp7agAXu/2DzoydoOMCmJXBHP3sC CA3vSf/VqQv4/NlyqayBEiNlp+17gCjJdhkErS2BuYAc/qMK4vAtKu7PXS741TcfuFKm GzSkn+CvZ9mxsOkluMYOJUMVHC496CXVAADZxzXxGcjyJpggqNyoyPeNP+rxxEVp/Q5w YVzg== X-Gm-Message-State: AOAM533vxCZmOB14xehqnwN92xXq5+D54pS3lPFOCdNStDR2NbD0Ir84 HKxnjfRfwNkRNiI1B2eNsCF0erdH+OQqcg== X-Google-Smtp-Source: ABdhPJwKCupqXpcMPkNwCVg01G4ug5VTCMgHzzamAo1Dv+c0uTUNE15jZ+1bp4mlCj1yh8buHrI/iw== X-Received: by 2002:a6b:cac5:: with SMTP id a188mr11700547iog.145.1590371645803; Sun, 24 May 2020 18:54:05 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id b18sm8456856ilh.77.2020.05.24.18.54.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 May 2020 18:54:05 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass , Anatolij Gustschin Subject: [PATCH v3 12/26] video: Add helpers for vidconsole for the copy framebuffer Date: Sun, 24 May 2020 19:52:56 -0600 Message-Id: <20200524195300.v3.12.If5b172fd65f0d257381cc0f78cca1b506d5d0bcf@changeid> X-Mailer: git-send-email 2.27.0.rc0.183.gde8f92d652-goog MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean Add a convenience function to call video_sync_copy() for a vidconsole. Also add a memmove() helper, which does the memmove() as well as the sync. Signed-off-by: Simon Glass Reviewed-by: Anatolij Gustschin --- Changes in v3: - Drop unnecessary variable Changes in v2: - Simplify return sequence in vidconsole_memmove() since there is no logging drivers/video/vidconsole-uclass.c | 16 ++++++++++ include/video_console.h | 49 +++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index e06912cf36..5f982b7653 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -629,6 +629,22 @@ UCLASS_DRIVER(vidconsole) = { .per_device_auto_alloc_size = sizeof(struct vidconsole_priv), }; +#ifdef CONFIG_VIDEO_COPY +int vidconsole_sync_copy(struct udevice *dev, void *from, void *to) +{ + struct udevice *vid = dev_get_parent(dev); + + return video_sync_copy(vid, from, to); +} + +int vidconsole_memmove(struct udevice *dev, void *dst, const void *src, + int size) +{ + memmove(dst, src, size); + return vidconsole_sync_copy(dev, dst, dst + size); +} +#endif + void vidconsole_position_cursor(struct udevice *dev, unsigned col, unsigned row) { struct vidconsole_priv *priv = dev_get_uclass_priv(dev); diff --git a/include/video_console.h b/include/video_console.h index d3bc063165..06b798ef10 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -256,4 +256,53 @@ void vidconsole_position_cursor(struct udevice *dev, unsigned col, */ u32 vid_console_color(struct video_priv *priv, unsigned int idx); +#ifdef CONFIG_VIDEO_COPY +/** + * vidconsole_sync_copy() - Sync back to the copy framebuffer + * + * This ensures that the copy framebuffer has the same data as the framebuffer + * for a particular region. It should be called after the framebuffer is updated + * + * @from and @to can be in either order. The region between them is synced. + * + * @dev: Vidconsole device being updated + * @from: Start/end address within the framebuffer (->fb) + * @to: Other address within the frame buffer + * @return 0 if OK, -EFAULT if the start address is before the start of the + * frame buffer start + */ +int vidconsole_sync_copy(struct udevice *dev, void *from, void *to); + +/** + * vidconsole_memmove() - Perform a memmove() within the frame buffer + * + * This handles a memmove(), e.g. for scrolling. It also updates the copy + * framebuffer. + * + * @dev: Vidconsole device being updated + * @dst: Destination address within the framebuffer (->fb) + * @src: Source address within the framebuffer (->fb) + * @size: Number of bytes to transfer + * @return 0 if OK, -EFAULT if the start address is before the start of the + * frame buffer start + */ +int vidconsole_memmove(struct udevice *dev, void *dst, const void *src, + int size); +#else +static inline int vidconsole_sync_copy(struct udevice *dev, void *from, + void *to) +{ + return 0; +} + +static inline int vidconsole_memmove(struct udevice *dev, void *dst, + const void *src, int size) +{ + memmove(dst, src, size); + + return 0; +} + +#endif + #endif