From patchwork Thu Apr 19 16:27:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Rosin X-Patchwork-Id: 10351925 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0317F602B7 for ; Fri, 20 Apr 2018 07:32:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2A27286A1 for ; Fri, 20 Apr 2018 07:32:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D73F3286A3; Fri, 20 Apr 2018 07:32:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4C37D286A1 for ; Fri, 20 Apr 2018 07:32:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 78D186E1A5; Fri, 20 Apr 2018 07:31:51 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0103.outbound.protection.outlook.com [104.47.1.103]) by gabe.freedesktop.org (Postfix) with ESMTPS id 196F76E64D for ; Thu, 19 Apr 2018 16:28:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axentia.se; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=njvb5j8U6TF8P2ur99zxiHqCQkRP5vAUFzk9gExnEPo=; b=s+wzGh3Dr6Tn9bspiR8TmruQeAeT1u/6App2GrXm+e3L6JqBGtYQpIGgFL3WSEYvtjoVZ9Y2zmgrwL3DQ6xnAJDxaQPEVCHbpGeWJXcx4tNSTj+2Vrm3ZWSiFAWe0uoUXbKE4XN7X+SOCDEfjNf1QgRHM7XMw22p4ML21pIqCEA= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=axentia.se; Received: from orc.pedanet (85.226.244.23) by VI1PR0202MB2784.eurprd02.prod.outlook.com (2603:10a6:800:db::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.696.13; Thu, 19 Apr 2018 16:28:23 +0000 From: Peter Rosin To: linux-kernel@vger.kernel.org Subject: [PATCH v3 3/7] drm: of: introduce drm_of_media_bus_fmt Date: Thu, 19 Apr 2018 18:27:47 +0200 Message-Id: <20180419162751.25223-4-peda@axentia.se> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180419162751.25223-1-peda@axentia.se> References: <20180419162751.25223-1-peda@axentia.se> MIME-Version: 1.0 X-Originating-IP: [85.226.244.23] X-ClientProxiedBy: HE1PR0102CA0072.eurprd01.prod.exchangelabs.com (2603:10a6:7:7d::49) To VI1PR0202MB2784.eurprd02.prod.outlook.com (2603:10a6:800:db::9) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(7021125)(5600026)(4534165)(7022125)(4603075)(4627221)(201702281549075)(7048125)(7024125)(7027125)(7028125)(7023125)(2017052603328)(7153060)(7193020); SRVR:VI1PR0202MB2784; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0202MB2784; 3:+2Bg+0piHtjg8gfmB6VtlLEuWd56LSQwQ0hG/LtEh8z3ODjw2reYFDS0+XISyOTqlDFLQSW26yWsIVTkfR5rkYflt503tvfNJc4/Q2mtddpkbrd2rOtUML4bDAC+ZzDf72ulfMk3Lbepkwb0GXDshNKX3faAUN5M1QmAXcYXN+DoPncNnSVyilrq3HNgSB/5tVD72Yme1zOFcjo7cDnQXCzgm0jv759bppENwH+yoM5sP5WKd5hi6rDA3RIEAoTa; 25:QYHKORxYDb3xylIWG54cuIulGd4aESIaofd0dMpTBZ9lqKGzAi65L2X6+GRSmmZ6bAwn66e6g7cIUICmH8JpLKMvLK+HzGlV46tWE9rxfJPSIejmq5Ly6MdceggRB6F6OefDj5KFZ0SZu4aMckB9rNJOKP05ByL8W82I1VJkl4RsBaEGTX/EDRsy0HqtsLiBQjvoQXGdbswDy7Qq+iZmsN35hJ0Lu511Lrx3WJVt3UPJeakBBOM+4SNT8VClP534NayVJLfyp2il3eVSfKKPuXRl5rDHZ3iR5zdaYRDWEsg/P1c9adHqGOA0Pxe5bADnLUNPqT1jLzkgf0QmtyaYKQ==; 31:FH5Sz2GJFu3V4luiqhbIQFQOfUmIk4qAKiD/+gx0gh+8iTmQ8Mb3T7zx8HQLJZpI1IRjUKlb8dcUB7Iq/yCCt+/ai7e4A2937vZKjTFOqp2xOMm0abpIaKWbFYwW8k7oGi1lg+eeMxzQjBVqtPyAwhhfggQdO/USV8Q/dqZPM81KE+yTbSG9XyqSVLhsRTdEB8ZwczTUS60zKOZgFRtv4hEHx05Pn1/Y9BAHDVwJ8G4= X-MS-TrafficTypeDiagnostic: VI1PR0202MB2784: X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231232)(944501327)(52105095)(10201501046)(3002001)(6041310)(20161123558120)(20161123562045)(2016111802025)(20161123564045)(20161123560045)(6072148)(6043046)(201708071742011); SRVR:VI1PR0202MB2784; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0202MB2784; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0202MB2784; 4:RSjtOKMBtuhpFBY/1gJbzOQHCYIj4gFWjXOe7LMvb4qMaJDp9+3q4VgQUoDFyGrnoH3Exp71DqTS5jwmc6wM/E2VrJUHSs+4ItEBSi2BpXqjsTbLNgxUZHYvRaSbTvAtafNsdAjKP6Qj2LtVPvriguuNvYs3cmxaspnzXn9YFfN5pEzEZLUGKRGVAKeJol8HWi+B8iMvoe2bDsi/BNGYPi2br0o7kgYt3/iXm7FOGFC8wqBDk3DAgFAD9pIWp6UYl9C8FMfD5XCpuDdrcJE57g== X-Forefront-PRVS: 0647963F84 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(396003)(346002)(366004)(376002)(39380400002)(26005)(86362001)(50466002)(50226002)(8936002)(6506007)(386003)(76176011)(47776003)(1076002)(2351001)(66066001)(6116002)(3846002)(2361001)(16526019)(305945005)(186003)(74482002)(11346002)(956004)(2906002)(446003)(6512007)(52116002)(53936002)(6916009)(6486002)(476003)(478600001)(316002)(8676002)(4326008)(2616005)(36756003)(7416002)(7736002)(6666003)(48376002)(16586007)(5660300001)(54906003)(25786009)(81166006)(42262002); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR0202MB2784; H:orc.pedanet; FPR:; SPF:None; LANG:en; MLV:sfv; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0202MB2784; 23:uvCOf/M3BFXop8MFyjQqmpAT7EvuGo/vkjmD+z8?= =?us-ascii?Q?1Knu4V5zp/WhPV2MD5c5AiYKLtAnqmpjrOaqHoFpcjTXueH2sR0CFeTxTypI?= =?us-ascii?Q?Wid1Xk2PFB3shg6FHF0eXTY1E4gmgiCEABBxI1/rmOkBsSa89kroSPYfECK0?= =?us-ascii?Q?xP0WGiSlQIUqU+vuhPmQn82YBhOHKKuZweHs0cMZjpVQe0VwLaJg7n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APn3lF935RAVk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR0202MB2784; 7:OCW5iI1FdRvztzZyD530lVTnMI5RTZ8WbX7VX+fgfE1lbLweglmAAA0P+vrfd/jYDI677gtFml5Mx7BqiJMi7MHmvkkx1SG+dV61tsnauLxdaoXBzgN+0nqqcKQ0JfN0w6llvKC1pvMB6SecYBD7lPHwhhc71+LILzLqsPXBu/v2eWozd/o8N0Z6quiMrH2UyPK9cbxi0E0afgqAEWE1O0TeogZDrPFicotmjUKjX9q/oUMQM7MuUk3/VJOEAhyU X-MS-Office365-Filtering-Correlation-Id: 28d08edc-4103-40ba-4b89-08d5a612931c X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2018 16:28:23.8801 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 28d08edc-4103-40ba-4b89-08d5a612931c X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4ee68585-03e1-4785-942a-df9c1871a234 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0202MB2784 X-Mailman-Approved-At: Fri, 20 Apr 2018 07:31:50 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Boris Brezillon , Alexandre Belloni , Jacopo Mondi , devicetree@vger.kernel.org, David Airlie , Nicolas Ferre , dri-devel@lists.freedesktop.org, Russell King , Rob Herring , Laurent Pinchart , Daniel Vetter , Peter Rosin , linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add a central function to parse a node according to the video interface binding and get a media bus format. Start with only supporting a very limited set of a few basic media bus formats. Signed-off-by: Peter Rosin --- drivers/gpu/drm/drm_of.c | 38 ++++++++++++++++++++++++++++++++++++++ include/drm/drm_of.h | 7 +++++++ 2 files changed, 45 insertions(+) diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c index 4c191c050e7d..f9473edb60a7 100644 --- a/drivers/gpu/drm/drm_of.c +++ b/drivers/gpu/drm/drm_of.c @@ -212,6 +212,44 @@ int drm_of_encoder_active_endpoint(struct device_node *node, EXPORT_SYMBOL_GPL(drm_of_encoder_active_endpoint); /* + * drm_of_media_bus_fmt - return the media bus format described in the node + * @node: device tree node containing the media bus format + * + * @node is presumably an of-graph endpoint node. + * + * Return the media bus format, or zero if none is described. Or one of the + * standard error codes. + */ +int drm_of_media_bus_fmt(struct device_node *node) +{ + s32 bus_type; + u32 bus_width = 0; + + if (!node) + return -EINVAL; + + if (of_property_read_u32(node, "bus-type", &bus_type)) + return 0; + if (bus_type != 0) + return -EINVAL; + + of_property_read_u32(node, "bus-width", &bus_width); + switch (bus_width) { + case 12: + return MEDIA_BUS_FMT_RGB444_1X12; + case 16: + return MEDIA_BUS_FMT_RGB565_1X16; + case 18: + return MEDIA_BUS_FMT_RGB666_1X18; + case 24: + return MEDIA_BUS_FMT_RGB888_1X24; + default: + return -EINVAL; + } +} +EXPORT_SYMBOL_GPL(drm_of_media_bus_fmt); + +/* * drm_of_find_panel_or_bridge - return connected panel or bridge device * @np: device tree node containing encoder output ports * @panel: pointer to hold returned drm_panel diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h index b93c239afb60..f86f0098b21e 100644 --- a/include/drm/drm_of.h +++ b/include/drm/drm_of.h @@ -29,6 +29,7 @@ int drm_of_component_probe(struct device *dev, int drm_of_encoder_active_endpoint(struct device_node *node, struct drm_encoder *encoder, struct of_endpoint *endpoint); +int drm_of_media_bus_fmt(struct device_node *node); int drm_of_find_panel_or_bridge(const struct device_node *np, int port, int endpoint, struct drm_panel **panel, @@ -62,6 +63,12 @@ static inline int drm_of_encoder_active_endpoint(struct device_node *node, { return -EINVAL; } + +static inline int drm_of_media_bus_fmt(struct device_node *node) +{ + return -EINVAL; +} + static inline int drm_of_find_panel_or_bridge(const struct device_node *np, int port, int endpoint, struct drm_panel **panel,