From patchwork Mon Oct 19 21:49:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatolij Gustschin X-Patchwork-Id: 1384516 X-Patchwork-Delegate: trini@ti.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=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=O3fNT+SR; 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 4CFVmF5Dgvz9sTc for ; Tue, 20 Oct 2020 08:49:56 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C2CF3822CD; Mon, 19 Oct 2020 23:49:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1603144185; bh=vzJpV1egTx0B0pET7vpDIeN0VfnaTeqUiymB9WiCv3A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=O3fNT+SRnGj6MnsvSc2PQ25X6vSND7pEWf5WAwwlW6X6zY328f/azMp7HDYtu9PdR Gm38O8BlhHz/PK04iq2F85w8ZYnbITVHK6hty6xU+2DJqvLkI7iBhm7xCAlRuIFTuW d8oGG9GFobMNZBzWpXJuMQ1lU4s3mo2uye+AYmrRJjuwHsTzYFDTsFLzT4C4nWuSUj UBZiaE5tIUv6Pg5uRKftC50KS0EKHW3ulEleLcWNc3AOgQzilKLig+SQeZBjFAN9e4 O625DPSe2CdUgPpuTozLcI7SuwmTTRHOi3npRON6jpiJF9p950+33O9bPEnhwyJ7Ew JovkddfN862HQ== Received: by phobos.denx.de (Postfix, from userid 109) id 2124081B79; Mon, 19 Oct 2020 23:49:44 +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=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A8CE581B79 for ; Mon, 19 Oct 2020 23:49:41 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=agust@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4CFVln1vQ5z1qs0p; Mon, 19 Oct 2020 23:49:41 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CFVln1cKXz1qrgQ; Mon, 19 Oct 2020 23:49:41 +0200 (CEST) Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id 8bLJiWFlLAsS; Mon, 19 Oct 2020 23:49:40 +0200 (CEST) X-Auth-Info: Y1xZJ1/FN5/jHnEHUSOl3zkgLZ6UlNt2foGqCtCp2Xc= Received: from crub.agik.hopto.org (p508b685f.dip0.t-ipconnect.de [80.139.104.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Mon, 19 Oct 2020 23:49:40 +0200 (CEST) From: Anatolij Gustschin To: u-boot@lists.denx.de Cc: Simon Glass , Frederik Aalund Subject: [PATCH v2] video: Add copy_fb_to_hw op Date: Mon, 19 Oct 2020 23:49:39 +0200 Message-Id: <20201019214939.11295-1-agust@denx.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200820153149.1732198-1-fpa@sbtinstruments.com> References: <20200820153149.1732198-1-fpa@sbtinstruments.com> 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 From: Frederik Aalund Some devices have their own framebuffer memory that is not shared directly with the CPU. For said devices, we need to copy U-boot's framebuffer (priv->fb) to the device's own framebuffer memory. E.g., via SPI. To support these devices, I've added the copy_fb_to_hw op. It's optional, so existing drivers do not need to define this op. I've used this new op to add support for the SSD2119 display panel driver over 4-wire SPI. I'll add this video driver in a subsequent patch. Signed-off-by: Frederik Aalund [agust: add Kconfig option] Signed-off-by: Anatolij Gustschin --- Changes in v2: - make this copy op optional and add Kconfig entry - check 'ops' pointer before dereferencing drivers/video/Kconfig | 10 ++++++++++ drivers/video/video-uclass.c | 18 ++++++++++++++++++ include/video.h | 8 +++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index e2e1f9c476..bb8c033d3d 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -53,6 +53,16 @@ config VIDEO_COPY To use this, your video driver must set @copy_base in struct video_uc_platdata. +config VIDEO_COPY_TO_HW + bool "Enable copying the frame buffer to external display hardware" + depends on DM_VIDEO + help + Some devices have their own framebuffer memory that is not + shared directly with the CPU. For such devices, the framebuffer + must be copied to the device's own framebuffer memory, e.g. via SPI. + Enable this option and implement video_ops copy_fb_to_hw() to + support this feature. + config BACKLIGHT_PWM bool "Generic PWM based Backlight Driver" depends on BACKLIGHT && DM_PWM diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c index 650891e49d..00e861bd55 100644 --- a/drivers/video/video-uclass.c +++ b/drivers/video/video-uclass.c @@ -196,6 +196,24 @@ void video_sync(struct udevice *vid, bool force) last_sync = get_timer(0); } #endif + /* + * Some devices have their own framebuffer memory that is not + * shared directly with the CPU. For said devices, we need to + * copy U-Boot's framebuffer (priv->fb) to the device's own + * framebuffer memory. E.g., via SPI. + */ + if (IS_ENABLED(CONFIG_VIDEO_COPY_TO_HW)) { + struct video_ops *ops = video_get_ops(vid); + int ret; + + if (ops && ops->copy_fb_to_hw) { + ret = ops->copy_fb_to_hw(vid); + if (ret) { + dev_err(vid, "Could not copy frame buffer to hardware: %d\n", + ret); + } + } + } } void video_sync_all(void) diff --git a/include/video.h b/include/video.h index 9d09d2409a..91ade65a73 100644 --- a/include/video.h +++ b/include/video.h @@ -114,8 +114,14 @@ struct video_priv { u8 bg_col_idx; }; -/* Placeholder - there are no video operations at present */ struct video_ops { + /** + * copy_fb_to_hw() - Copy the current frame buffer to the hardware + * + * @dev: Video device + * @return 0 if OK, -ve on error + */ + int (*copy_fb_to_hw)(struct udevice *dev); }; #define video_get_ops(dev) ((struct video_ops *)(dev)->driver->ops)