From patchwork Fri Mar 14 17:59:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gwenole Beauchesne X-Patchwork-Id: 3834461 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EEDA49F1CD for ; Fri, 14 Mar 2014 17:59:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C225F201F9 for ; Fri, 14 Mar 2014 17:59:49 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 3296320340 for ; Fri, 14 Mar 2014 17:59:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D75A7FB287; Fri, 14 Mar 2014 10:59:43 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com [209.85.212.169]) by gabe.freedesktop.org (Postfix) with ESMTP id A1CD6FB409; Fri, 14 Mar 2014 10:59:41 -0700 (PDT) Received: by mail-wi0-f169.google.com with SMTP id hm4so32850wib.4 for ; Fri, 14 Mar 2014 10:59:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=xNFnY1MBZ3r9wzO+w49iPEScI2YrCCt1UhBii2L2OdI=; b=s9QM1hj2C6GbwSxeHw4XtB+FOhFh6ylhtIqH+DwabG/Uo0xNgrgwF7P8PWQMhfq4Ty wJPJ537QAMtMdEbPmxNw59zJPH9k5kqcPhL7BOJw7eKczLjwB9oB3W+mX8k2JmSXHJ6l 5nETkXuOwjmQHuQqKmuAlIq5TK1OdZk2/v84tKHLz7qNDjiLWfeD7earjw5NqkFGn5AV dGxm0j/UZ4wgClE+Pd+klXMACTFvqqU+1zoEji1FfAcDnTZgJA10HbGumUD9VBIQbCTy 3FOjs+IfGuqTLUwEmVtvcTimAcqeVMLDOFFLdokObZv5hn6NBecU5cmSsGfWF592m5nP 3ASQ== X-Received: by 10.194.58.79 with SMTP id o15mr2998950wjq.62.1394819981066; Fri, 14 Mar 2014 10:59:41 -0700 (PDT) Received: from localhost.localdomain (obs92-1-82-225-152-198.fbx.proxad.net. [82.225.152.198]) by mx.google.com with ESMTPSA id em1sm11287582wid.5.2014.03.14.10.59.40 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 14 Mar 2014 10:59:40 -0700 (PDT) From: Gwenole Beauchesne To: mesa-dev@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH] drm: add FOURCC formats for compute dma_buf interop. Date: Fri, 14 Mar 2014 18:59:21 +0100 Message-Id: <1394819961-21537-1-git-send-email-gwenole.beauchesne@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, 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 is a follow-up to: http://lists.freedesktop.org/archives/mesa-dev/2014-March/055742.html Add formats meant to convey a "compute" dimension when a DRM fourcc format is needed for dma_buf interop (EGL, OpenCL). Intended FOURCC format: ('T',,,). - : number of elements in the tuple. Range: [0..3]. - : type of each element. Values: {'_','I','U','F'}, respectively for normalized to [0..1] range, signed integers, unsigned integers, floating-point. - : size of the element. Values: {1, 2, 4, 8}. All entities are represented in native-endian byte-order in memory. For example, 'T2F4' format would represent the (float, float) tuple where elements are stored in little-endian byte-order on x86. Signed-off-by: Gwenole Beauchesne --- include/drm/drm_fourcc.h | 78 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h index 85facb0..26a2ca8 100644 --- a/include/drm/drm_fourcc.h +++ b/include/drm/drm_fourcc.h @@ -127,4 +127,82 @@ #define DRM_FORMAT_YUV444 fourcc_code('Y', 'U', '2', '4') /* non-subsampled Cb (1) and Cr (2) planes */ #define DRM_FORMAT_YVU444 fourcc_code('Y', 'V', '2', '4') /* non-subsampled Cr (1) and Cb (2) planes */ +/** + * \defgroup api_drm_tuples Compute formats (tuples) + * + * The following formats are not meant for display. Rather, they are + * meant to convey a "compute" dimension when a DRM fourcc format is + * needed for dma_buf interop (EGL, OpenCL). + * + * Intended FOURCC format: ('T',,,). + * - : number of elements in the tuple. Range: [0..3]. + * - : type of each element. Values: {'_','I','U','F'}, + * respectively for normalized to [0..1] range, signed integers, + * unsigned integers, floating-point. + * - : size of the element. Values: {1, 2, 4, 8}. + * + * All entities are represented in native-endian byte-order in memory. + * For example, 'T2F4' format would represent the (float, float) tuple + * where elements are stored in little-endian byte-order on x86. + * + * @{ + */ + +/** Type of a tuple element */ +enum { + DRM_FORMAT_TUPLE_TYPE_UNORM = '_', /**< Unsigned integer value normalized to [0..1] range */ + DRM_FORMAT_TUPLE_TYPE_SINT = 'I', /**< Signed integer value */ + DRM_FORMAT_TUPLE_TYPE_UINT = 'U', /**< Unsigned integer value */ + DRM_FORMAT_TUPLE_TYPE_FLOAT = 'F', /**< Floating-point value */ +}; + +/** Generates a FOURCC value for a tuple */ +#define DRM_FORMAT_TUPLE(num_elements, type, size) \ + fourcc_code('T', '0'+(num_elements), DRM_FORMAT_TUPLE_TYPE_##type, '0'+(size)) + +/** @name Unsigned integers normalized to [0..1] range */ +/**@{*/ +#define DRM_FORMAT_T1_1 DRM_FORMAT_TUPLE(1, UNORM, 1) /** (X), 8-bit integers normalized to [0..1] range */ +#define DRM_FORMAT_T2_1 DRM_FORMAT_TUPLE(2, UNORM, 1) /** (X, Y), 8-bit integers normalized to [0..1] range */ +#define DRM_FORMAT_T4_1 DRM_FORMAT_TUPLE(4, UNORM, 1) /** (X, Y, Z, W), 8-bit integers normalized to [0..1] range */ +#define DRM_FORMAT_T1_2 DRM_FORMAT_TUPLE(1, UNORM, 2) /** (X), 16-bit integers normalized to [0..1] range */ +#define DRM_FORMAT_T2_2 DRM_FORMAT_TUPLE(2, UNORM, 2) /** (X, Y), 16-bit integers normalized to [0..1] range */ +#define DRM_FORMAT_T4_2 DRM_FORMAT_TUPLE(4, UNORM, 2) /** (X, Y, Z, W), 16-bit integers normalized to [0..1] range */ +/**@}*/ + +/** @name Signed integer values */ +/**@{*/ +#define DRM_FORMAT_T1I1 DRM_FORMAT_TUPLE(1, SINT, 1) /** (X), 8-bit signed integer */ +#define DRM_FORMAT_T2I1 DRM_FORMAT_TUPLE(2, SINT, 1) /** (X, Y), 8-bit signed integer */ +#define DRM_FORMAT_T4I1 DRM_FORMAT_TUPLE(4, SINT, 1) /** (X, Y, Z, W), 8-bit signed integer */ +#define DRM_FORMAT_T1I2 DRM_FORMAT_TUPLE(1, SINT, 2) /** (X), 16-bit signed integer */ +#define DRM_FORMAT_T2I2 DRM_FORMAT_TUPLE(2, SINT, 2) /** (X, Y), 16-bit signed integer */ +#define DRM_FORMAT_T4I2 DRM_FORMAT_TUPLE(4, SINT, 2) /** (X, Y, Z, W), 16-bit signed integer */ +#define DRM_FORMAT_T1I4 DRM_FORMAT_TUPLE(1, SINT, 4) /** (X), 32-bit signed integer */ +#define DRM_FORMAT_T2I4 DRM_FORMAT_TUPLE(2, SINT, 4) /** (X, Y), 32-bit signed integer */ +#define DRM_FORMAT_T4I4 DRM_FORMAT_TUPLE(4, SINT, 4) /** (X, Y, Z, W), 32-bit signed integer */ +/**@}*/ + +/** @name Unsigned integer values */ +/**@{*/ +#define DRM_FORMAT_T1U1 DRM_FORMAT_TUPLE(1, UINT, 1) /** (X), 8-bit unsigned integer */ +#define DRM_FORMAT_T2U1 DRM_FORMAT_TUPLE(2, UINT, 1) /** (X, Y), 8-bit unsigned integer */ +#define DRM_FORMAT_T4U1 DRM_FORMAT_TUPLE(4, UINT, 1) /** (X, Y, Z, W), 8-bit unsigned integer */ +#define DRM_FORMAT_T1U2 DRM_FORMAT_TUPLE(1, UINT, 2) /** (X), 16-bit unsigned integer */ +#define DRM_FORMAT_T2U2 DRM_FORMAT_TUPLE(2, UINT, 2) /** (X, Y), 16-bit unsigned integer */ +#define DRM_FORMAT_T4U2 DRM_FORMAT_TUPLE(4, UINT, 2) /** (X, Y, Z, W), 16-bit unsigned integer */ +#define DRM_FORMAT_T1U4 DRM_FORMAT_TUPLE(1, UINT, 4) /** (X), 32-bit unsigned integer */ +#define DRM_FORMAT_T2U4 DRM_FORMAT_TUPLE(2, UINT, 4) /** (X, Y), 32-bit unsigned integer */ +#define DRM_FORMAT_T4U4 DRM_FORMAT_TUPLE(4, UINT, 4) /** (X, Y, Z, W), 32-bit unsigned integer */ +/**@}*/ + +/** @name Floating-point values */ +/**@{*/ +#define DRM_FORMAT_T1F4 DRM_FORMAT_TUPLE(1, FLOAT, 4) /** (X), 32-bit floating-point */ +#define DRM_FORMAT_T2F4 DRM_FORMAT_TUPLE(2, FLOAT, 4) /** (X, Y), 32-bit floating-point */ +#define DRM_FORMAT_T4F4 DRM_FORMAT_TUPLE(4, FLOAT, 4) /** (X, Y, Z, W), 32-bit floating-point */ +/**@}*/ + +/**@}*/ + #endif /* DRM_FOURCC_H */