From patchwork Fri Jul 3 03:12:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1322048 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=85.214.62.61; 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=aBYKc+n1; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 49yg7q3lWkz9sRf for ; Fri, 3 Jul 2020 13:15:19 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D013081BEC; Fri, 3 Jul 2020 05:13:42 +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="aBYKc+n1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C3EBE81BD1; Fri, 3 Jul 2020 05:13:07 +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-il1-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) (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 A043B81B97 for ; Fri, 3 Jul 2020 05:12:54 +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-il1-x143.google.com with SMTP id o3so8704765ilo.12 for ; Thu, 02 Jul 2020 20:12:54 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=oNhWBl/MFFOvrsjyyp4uSmq0600ubclFehsl6q7X/FQ=; b=aBYKc+n1MA8Fj0mzTSg/uUykRhB9oH5TlxdqRh/EIQmoW61wxKlW060IL7tV+UAYc2 AM09VYvwvFlb3phrgFIZuvoHBwernCRcCfmVAocahLK7UvrAwvn7x/Ts0JCXHJpjKmkB DqZLTKcGGRyU9Lbno8aU1rwjJYQyMGhvPAezU= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=oNhWBl/MFFOvrsjyyp4uSmq0600ubclFehsl6q7X/FQ=; b=bfvUinvdvaBJJIiXtTk00374leP3rd/KwvPJG+9toZWQwMuN5W1CgWMFSw7yMv9Am0 qVS9Ops/xUkRdleQ8yx8G9DAPwt7Khe2PbMCdPBYUJ76WY5ApLejM1hhKs1yuZGTe2+o qXTfSoV49GEd4NJipGguBrKPvhYDYbMZ/4wZOb6hr1MfjZsfbB0d7RWVmBwX2xrbdEwf OTz2ZGZTXlB1kipR09jHOEMwl8WUn76afqrPOJK7KVUSRS4AL39AsPWXrH8AVCx741ik CiT8G2EaEXZxr2J14+zbJmrX5KAipt025xVbC++bvZt4KS4K8a7JhbZqyt14oN9px+9Z oFgw== X-Gm-Message-State: AOAM533JoYEvXubAckH9h86cp+bHgsvT2ens5DiNghxxEga/PT7r2VHr 0LlpPJNlSjbi1YEpBAvjQvLRgg== X-Google-Smtp-Source: ABdhPJyWe6pxYv9YaNyVJx/ioZj7Ph5v4gouHgzvmNJ/yMMMvzdpdbngLyxC44+EW0zi7XAfveeO2g== X-Received: by 2002:a05:6e02:106a:: with SMTP id q10mr15350638ilj.30.1593745973408; Thu, 02 Jul 2020 20:12:53 -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 c16sm5859654ilh.54.2020.07.02.20.12.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jul 2020 20:12:53 -0700 (PDT) From: Simon Glass To: Bin Meng Cc: Simon Glass , Anatolij Gustschin , u-boot@lists.denx.de Subject: [RESEND PATCH v3 12/26] video: Add helpers for vidconsole for the copy framebuffer Date: Thu, 2 Jul 2020 21:12:23 -0600 Message-Id: <20200702211204.RESEND.v3.12.If5b172fd65f0d257381cc0f78cca1b506d5d0bcf@changeid> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog In-Reply-To: <20200703031237.1546362-1-sjg@chromium.org> References: <20200703031237.1546362-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.3 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 841cfdaf93..3a07f36ce2 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 + #if CONFIG_IS_ENABLED(CMD_VIDCONSOLE) void vidconsole_position_cursor(struct udevice *dev, unsigned col, unsigned row) { 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