From patchwork Thu Oct 26 03:14:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Icenowy Zheng X-Patchwork-Id: 830436 X-Patchwork-Delegate: agust@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3yMscH2bBSz9sCZ for ; Thu, 26 Oct 2017 14:16:47 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 14DE4C21DC8; Thu, 26 Oct 2017 03:16:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 7C91AC21DE5; Thu, 26 Oct 2017 03:16:01 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 95DA3C21DEF; Thu, 26 Oct 2017 03:15:45 +0000 (UTC) Received: from cadetblue.maple.relay.mailchannels.net (cadetblue.maple.relay.mailchannels.net [23.83.214.28]) by lists.denx.de (Postfix) with ESMTPS id E52D5C21DE9 for ; Thu, 26 Oct 2017 03:15:38 +0000 (UTC) X-Sender-Id: lmn-tzduiowcrqmw|x-authsender|icenowy@aosc.io Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 37579367EC9; Thu, 26 Oct 2017 03:15:37 +0000 (UTC) Received: from hermes.aosc.io (unknown [100.96.149.26]) (Authenticated sender: lmn-TZDUIOWCRQMW) by relay.mailchannels.net (Postfix) with ESMTPA id 3C838367A12; Thu, 26 Oct 2017 03:15:36 +0000 (UTC) X-Sender-Id: lmn-tzduiowcrqmw|x-authsender|icenowy@aosc.io Received: from hermes.aosc.io (hermes.aosc.io [172.20.63.30]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.9.14); Thu, 26 Oct 2017 03:15:37 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: lmn-tzduiowcrqmw|x-authsender|icenowy@aosc.io X-MailChannels-Auth-Id: lmn-TZDUIOWCRQMW X-Thoughtful-Chemical: 6b45158677d8735d_1508987737062_3939977084 X-MC-Loop-Signature: 1508987737062:938979650 X-MC-Ingress-Time: 1508987737062 Received: from localhost (localhost [127.0.0.1]) (Authenticated sender: icenowy@aosc.io) by hermes.aosc.io (Postfix) with ESMTPSA id 98D404BFBF; Thu, 26 Oct 2017 03:15:31 +0000 (UTC) From: Icenowy Zheng To: Jagan Teki , Maxime Ripard , Anatolij Gustschin , Jernej Skrabec , Simon Glass Date: Thu, 26 Oct 2017 11:14:45 +0800 Message-Id: <20171026031447.13043-3-icenowy@aosc.io> In-Reply-To: <20171026031447.13043-1-icenowy@aosc.io> References: <20171026031447.13043-1-icenowy@aosc.io> Cc: u-boot@lists.denx.de, linux-sunxi@googlegroups.com, Icenowy Zheng Subject: [U-Boot] [PATCH RESEND v5 2/4] video: sunxi: extract simplefb match code to a new file X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" As the DE2 simplefb setup code can also benefit from the simplefb match code, extract it to a new source file. Signed-off-by: Icenowy Zheng Reviewed-by: Andre Przywara Acked-by: Maxime Ripard --- Changes in v4: - Add missing copyright for Luc. Changes in v3: - Use /** to start kerndoc. drivers/video/sunxi/Makefile | 2 +- drivers/video/sunxi/simplefb_common.c | 30 ++++++++++++++++++++++++++++++ drivers/video/sunxi/simplefb_common.h | 22 ++++++++++++++++++++++ drivers/video/sunxi/sunxi_display.c | 13 ++----------- 4 files changed, 55 insertions(+), 12 deletions(-) create mode 100644 drivers/video/sunxi/simplefb_common.c create mode 100644 drivers/video/sunxi/simplefb_common.h diff --git a/drivers/video/sunxi/Makefile b/drivers/video/sunxi/Makefile index 0d64c2021f..10862edaca 100644 --- a/drivers/video/sunxi/Makefile +++ b/drivers/video/sunxi/Makefile @@ -5,5 +5,5 @@ # SPDX-License-Identifier: GPL-2.0+ # -obj-$(CONFIG_VIDEO_SUNXI) += sunxi_display.o lcdc.o tve_common.o ../videomodes.o +obj-$(CONFIG_VIDEO_SUNXI) += sunxi_display.o simplefb_common.o lcdc.o tve_common.o ../videomodes.o obj-$(CONFIG_VIDEO_DE2) += sunxi_de2.o sunxi_dw_hdmi.o lcdc.o ../dw_hdmi.o diff --git a/drivers/video/sunxi/simplefb_common.c b/drivers/video/sunxi/simplefb_common.c new file mode 100644 index 0000000000..7befb736da --- /dev/null +++ b/drivers/video/sunxi/simplefb_common.c @@ -0,0 +1,30 @@ +/* + * Common code for Allwinner SimpleFB with pipeline. + * + * (C) Copyright 2013-2014 Luc Verhaegen + * (C) Copyright 2014-2015 Hans de Goede + * (C) Copyright 2017 Icenowy Zheng + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include + +int sunxi_simplefb_fdt_match(void *blob, const char *pipeline) +{ + int offset, ret; + + /* Find a prefilled simpefb node, matching out pipeline config */ + offset = fdt_node_offset_by_compatible(blob, -1, + "allwinner,simple-framebuffer"); + while (offset >= 0) { + ret = fdt_stringlist_search(blob, offset, "allwinner,pipeline", + pipeline); + if (ret == 0) + break; + offset = fdt_node_offset_by_compatible(blob, offset, + "allwinner,simple-framebuffer"); + } + + return offset; +} diff --git a/drivers/video/sunxi/simplefb_common.h b/drivers/video/sunxi/simplefb_common.h new file mode 100644 index 0000000000..1a2bfabf00 --- /dev/null +++ b/drivers/video/sunxi/simplefb_common.h @@ -0,0 +1,22 @@ +/* + * (C) Copyright 2017 Icenowy Zheng + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef __SIMPLEFB_COMMON_H +#define __SIMPLEFB_COMMON_H + +/** + * sunxi_simplefb_fdt_match() - match a sunxi simplefb node + * + * Match a sunxi simplefb device node with a specified pipeline, and + * return its offset. + * + * @blob: device tree blob + * @pipeline: display pipeline + * @return device node offset in blob, or negative values if failed + */ +int sunxi_simplefb_fdt_match(void *blob, const char *pipeline); + +#endif diff --git a/drivers/video/sunxi/sunxi_display.c b/drivers/video/sunxi/sunxi_display.c index de768ba94a..7f25ed5f26 100644 --- a/drivers/video/sunxi/sunxi_display.c +++ b/drivers/video/sunxi/sunxi_display.c @@ -29,6 +29,7 @@ #include "../anx9804.h" #include "../hitachi_tx18d42vm_lcd.h" #include "../ssd2828.h" +#include "simplefb_common.h" #ifdef CONFIG_VIDEO_LCD_BL_PWM_ACTIVE_LOW #define PWM_ON 0 @@ -1377,17 +1378,7 @@ int sunxi_simplefb_setup(void *blob) break; } - /* Find a prefilled simpefb node, matching out pipeline config */ - offset = fdt_node_offset_by_compatible(blob, -1, - "allwinner,simple-framebuffer"); - while (offset >= 0) { - ret = fdt_stringlist_search(blob, offset, "allwinner,pipeline", - pipeline); - if (ret == 0) - break; - offset = fdt_node_offset_by_compatible(blob, offset, - "allwinner,simple-framebuffer"); - } + offset = sunxi_simplefb_fdt_match(blob, pipeline); if (offset < 0) { eprintf("Cannot setup simplefb: node not found\n"); return 0; /* Keep older kernels working */