From patchwork Thu May 14 02:21:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Ying X-Patchwork-Id: 6402471 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DC3629F374 for ; Thu, 14 May 2015 02:31:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EDA06203AA for ; Thu, 14 May 2015 02:31:24 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id F412420383 for ; Thu, 14 May 2015 02:31:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 327736E14A; Wed, 13 May 2015 19:31:22 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 922 seconds by postgrey-1.34 at gabe; Wed, 13 May 2015 19:31:20 PDT Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2on0136.outbound.protection.outlook.com [207.46.100.136]) by gabe.freedesktop.org (Postfix) with ESMTP id AC0336E14A for ; Wed, 13 May 2015 19:31:20 -0700 (PDT) Received: from CO2PR03CA0027.namprd03.prod.outlook.com (10.141.194.154) by BLUPR03MB487.namprd03.prod.outlook.com (10.141.79.27) with Microsoft SMTP Server (TLS) id 15.1.166.19; Thu, 14 May 2015 02:15:57 +0000 Received: from BN1BFFO11FD020.protection.gbl (2a01:111:f400:7c10::1:152) by CO2PR03CA0027.outlook.office365.com (2a01:111:e400:1414::26) with Microsoft SMTP Server (TLS) id 15.1.154.19 via Frontend Transport; Thu, 14 May 2015 02:15:56 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; vger.kernel.org; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BN1BFFO11FD020.mail.protection.outlook.com (10.58.144.83) with Microsoft SMTP Server (TLS) id 15.1.160.8 via Frontend Transport; Thu, 14 May 2015 02:15:55 +0000 Received: from victor.ap.freescale.net (victor.ap.freescale.net [10.192.241.62]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t4E2FhZD001212; Wed, 13 May 2015 19:15:46 -0700 From: Liu Ying To: Subject: [PATCH v9.5.1 09/20] drm/dsi: Add a helper to get bits per pixel of MIPI DSI pixel format Date: Thu, 14 May 2015 10:21:39 +0800 Message-ID: <1431570099-29216-1-git-send-email-Ying.Liu@freescale.com> X-Mailer: git-send-email 2.1.4 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD020; 1:UkescR5apRHl4CGueYqnpAbmPRkBpp7CbmdLEAY2xdT3vV8Fjlo0oaZioRxrdG/yCS9X4EUFy/65piOijGQmy/eOFczz973xZNW48cRDDvbc3RhmUhzXVp4bjJ4DR/XY0omCcoPOED9yaLiGVj7bjn7oxKfqXnRe0sEDjY/hT3bxnaKxXNjB4bOYEJSlAGnolKG5YtHtiValYDwm2etyfF5HU8T0+35tChzB+6sA5tih/vr3Sd8dQmxsUjaGAecAk4xK7AWaWvoNKAN9/hViM8B1pRc3RMrHuploWr+u1GxkNmuXGxIHzySH7ROcqUQQWmRAzdCeQmo9ob1NRXVpNQ== X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(339900001)(189002)(199003)(106466001)(77096005)(104016003)(62966003)(77156002)(48376002)(110136002)(50466002)(19580405001)(19580395003)(5001960100002)(36756003)(2351001)(92566002)(189998001)(229853001)(85426001)(87936001)(50226001)(5890100001)(50986999)(47776003)(575784001)(86362001)(46102003)(105606002)(6806004)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:BLUPR03MB487; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB487; 2:B31fkoilZzGnY9j297kUQ2l0evMrB10Uv2ZQ22fPEBBOvKI88zLoPi4yTZkGBXC+; 2:U3+LuRA4udBY25cu0tSABZc5VktYum+R7jXW3UwFf7Av6Q+1hCBRf5h7yU2H0xLzj61KtYf2mbY1Uttvd0XWfcjQ32Ejpn5v8rlY1HEApAKQB9ijXenaUA9ClPT4zz/3U9a0U6iANaYxxfqVJhazR+vDHpDdYSIU1b3ShuMy/Lyb3+g/wLp10ptgAZDuF4W4Osgvv6pTvWjLev3PFsiu3MD9HFyqmrObuZrqdYv6Pq4=; 6:H6zqrwRBKHc65za6othPh1OEkXBp4rrrOe5GicFuyjUxEnQpNHv3EiNgngTbuYJW9XBMwZqlJKgL85svS0y/cb+bFvC8F+7oXNZLKRjE7tNXzGEE7vx/yeLpw60k9OYb7DFVRRHAjRB9Z+kcn1Dr3yJec2XgfD/MS+xKWRXDlPTeib3xW/MDsODxOMezy01RVJdsNUtj82gVNZqHp2yVWR2utvN7GRHvPCKUyA1Tp6vLtGW63sdwtsYgPH5p4OgkjmEj+bxN0R/VokxYtZC83m4BQolf0tDP3gNcxC5iUc/nhoAswBQ+jsShJ3QzAho+qCgyQIq++RJT9tgCE7GvyQ==; 3:6Rd4QipOY4goxcEbpo6x+u1kRYZ4GpfBVAZQfdzxECq6bEdh9UWMRXVYI/aDPY5FJoLWim8W9mljd84kKS2IcCRfnhYlO6RJUg/6W/iTMdjHIHF4g6ZJA+958uNtrXwQKsqT6WpI4qxTcny5uVOgZ4sJrwT3nV2NeUBKj5h4cfpzzEUFh6pM8iBdZ05flP8QS85CP71E3VBNsq7JwaPUzd1tYgQf562PZ4asNuOKIq+vxKK2dmG6lskSyq1t9VxujBSBAjVh7qKYEsKHkMNqH3ibNc5Ex7Y3+VTyaTlvuVY= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB487; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(3002001); SRVR:BLUPR03MB487; BCL:0; PCL:0; RULEID:; SRVR:BLUPR03MB487; X-Forefront-PRVS: 0576145E86 X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB487; 9:x4f8vWLx6EqjHU5Eh+KZBdPuLcjP4aW92NgFzBK7SXfiQSheCEK1IJZc3NneSCJTVRL4IZscNL9n48gqud7quy9u1TMEpwteKZW/gHoVj8SWwtq1UmOnCBpalcmJhV5LOy91w2VPr3+nkTjcoKLQvM+oPRn3ZONZY9ttiQkt58LxUigqM7BEbAJZHi3sp25ZyE6t5vfPklOOdv8n0XGPJgYhubmo6jPLdLMjit18EHRBfmnCC9+nEnRdiGjAOCGJIvg7bKgk0XkOcQg1SumEYAAJzcvABuWFyCxRCWOtfXXC/D/k1g4+QIqSzyCtFuhfO5YjPrsn8VAZK0WA8OTJi62jWqkruEO2PLK03WAcfZusuia3PRUhSE4FdS9bT01krs2ZImA+oZRXynvwLhakVdwu74SE2W4s5mhkqO5YiFvOwj7BoFIXIuP2/OQ39ExGdZdusA6VZbEcAxvFCBiq7xZsn2xjpVefo+eUksVaDo+SMGaG/iC+TPQyODT8m2jMmmqTplJT0Wuk3OrKPgQ8vfPSRsj9SVhCtfw1edxnXGpLB5ya2B4CatsFsXEDStumAT0hYNYUOGSF7nIE6byqXxm7ErCLgWkt2wkci+sEoHZ+ufXpMmRTpK9tOjiRDRsMTnVARvtu9nfUoFs3tT2ivKf6mY3yqo3nHbWOxWgzRA4bqEdOKE2TnNQlpegSrq0hUO4ZmuZhqgvFhMdbh8J+zTsIMRVRlRGKZv6wA7btiHXHPLmtLHmRlzDgcEywlZSB4jIKUqc5JiaAe0+H0eBdHVBFMaHeybBfGgxsr8a8CKGPFHcSZi7L9gmostss4thTRlz3gcExIFW10CuHfaRHVmflcNZHPB9zJNUg6biMJTE= X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB487; 3:UorqS41KZpEXfzVksQtnlC+dh2tg1bubXOowAXD96crKHKM/M7xvSwU2mPmHZIk6N1gijzUre4DdXMrpnrWJbZ1RQ2q6kQZR5aWtEKOWAmnis377z1Z5xk8EEGqTORSFCHdBNlwp1R3HbNIHw9c8MQ==; 10:b7ydUO+1iKF9YY+zEtb9Fq8i1I+ACmaqrt9HgyRV30Tqp3ST5Rs8T/mgl0TScLSXhGiypzorHjyYUC5SKhdvfAzL2RvxUEXLbiVw7GxHgB4=; 6:rpPSYadBAq0ydhyAw00f+f1wPYjBWWFu2Itq1msa1MxUQ/aXZXGWbLYHRbPpLWiK X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 May 2015 02:15:55.5648 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB487 Cc: stefan.wahren@i2se.com, linux@arm.linux.org.uk, kernel@pengutronix.de, daniel.vetter@ffwll.ch, sboyd@codeaurora.org, linux-kernel@vger.kernel.org, a.hajda@samsung.com, linux-arm-kernel@lists.infradead.org, andyshrk@gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds a helper to get bits per pixel value of MIPI DSI pixel format. The helper takes a parameter in the type 'enum mipi_dsi_pixel_format' and returns it's bits per pixel value if the parameter is valid, otherwise, it returns -EINVAL. The helper makes users' life easier to do the conversion from a specific MIPI DSI pixel format to it's bits per pixel value. Signed-off-by: Liu Ying Reviewed-by: Jani Nikula --- v9.5->v9.5.1: * To address Thierry Reding's comments, add a commit message to describe why the helper is useful and when to use it and fix typo in kernel-doc from 'mipi dsi' to 'MIPI DSI'. v9->v9.5: * Add kernel-doc for the new helper function to address Daniel Vetter's comment. v8->v9: * Rebase onto the imx-drm/next branch of Philipp Zabel's open git repository. v7->v8: * None. v6->v7: * None. v5->v6: * Address the over 80 characters in one line warning reported by the checkpatch.pl script. v4->v5: * None. v3->v4: * None. v2->v3: * None. v1->v2: * Thierry Reding suggested that the mipi_dsi_pixel_format_to_bpp() function could be placed at the common DRM MIPI DSI driver. This patch is newly added. include/drm/drm_mipi_dsi.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h index f1d8d0d..186b15b 100644 --- a/include/drm/drm_mipi_dsi.h +++ b/include/drm/drm_mipi_dsi.h @@ -163,6 +163,28 @@ static inline struct mipi_dsi_device *to_mipi_dsi_device(struct device *dev) return container_of(dev, struct mipi_dsi_device, dev); } +/** + * mipi_dsi_pixel_format_to_bpp() - get bits per pixel for a MIPI DSI + * pixel format + * @fmt: MIPI DSI pixel format + * + * Return: The bits per pixel value for the MIPI DSI pixel format on success or + * a negative error code on failure. + */ +static inline int mipi_dsi_pixel_format_to_bpp(enum mipi_dsi_pixel_format fmt) +{ + switch (fmt) { + case MIPI_DSI_FMT_RGB888: + case MIPI_DSI_FMT_RGB666: + return 24; + case MIPI_DSI_FMT_RGB666_PACKED: + return 18; + case MIPI_DSI_FMT_RGB565: + return 16; + } + return -EINVAL; +} + struct mipi_dsi_device *of_find_mipi_dsi_device_by_node(struct device_node *np); int mipi_dsi_attach(struct mipi_dsi_device *dsi); int mipi_dsi_detach(struct mipi_dsi_device *dsi);