From patchwork Wed Dec 10 17:17:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 5471031 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8DC58BEEA8 for ; Wed, 10 Dec 2014 17:18:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6E8822015A for ; Wed, 10 Dec 2014 17:18:00 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 8C49220125 for ; Wed, 10 Dec 2014 17:17:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BED846E2C2; Wed, 10 Dec 2014 09:17:58 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qa0-f44.google.com (mail-qa0-f44.google.com [209.85.216.44]) by gabe.freedesktop.org (Postfix) with ESMTP id 2979E6E2C2 for ; Wed, 10 Dec 2014 09:17:57 -0800 (PST) Received: by mail-qa0-f44.google.com with SMTP id i13so2275337qae.17 for ; Wed, 10 Dec 2014 09:17:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=8Y7roBuGZPYY6e3gTvITZp6wauZ9dSxmnMtcUF7f5VU=; b=I0zHmqV+8K7/IuBWqPhg3XC0CrgWesHAKgqOP81R44iQSXis1Kkk9NagI4pqNmCH2H TTUScNbZNVsLRgSTGUwqYvxHE7YUROPVXLzx7oilFGFs6nXDgWeeDRoIckvBzbLxnWaZ w486G0cahdxeuB8/EeaAAwrusT6zKJL++fJU3gPH+owNs8tBOacqFrNbaIbuZdNypjVd iZvU2yqUgHp9YUrrNQt/Y8PxzK65IaZLLXWp42cfdSscKlqr+wvogBGcnQ5odHgn59Rc QBxi3SWGseFRvHnvlFtCX013XAZgKbrVQMajDh1kuYw2J5xA23B5YZbtUmrKVrez+KTX xv0A== X-Received: by 10.140.16.194 with SMTP id 60mr9830644qgb.69.1418231876791; Wed, 10 Dec 2014 09:17:56 -0800 (PST) Received: from localhost ([2601:6:2c00:943:eab1:fcff:fe75:3f91]) by mx.google.com with ESMTPSA id s3sm4770282qat.4.2014.12.10.09.17.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Dec 2014 09:17:56 -0800 (PST) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [RFC] drm: add support for tiled/compressed/etc modifier in addfb2 Date: Wed, 10 Dec 2014 12:17:51 -0500 Message-Id: <1418231871-31088-1-git-send-email-robdclark@gmail.com> X-Mailer: git-send-email 2.1.0 Cc: Laurent Pinchart 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: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 In DRM/KMS we are lacking a good way to deal with tiled/compressed formats. Especially in the case of dmabuf/prime buffer sharing, where we cannot always rely on under-the-hood flags passed to driver specific gem-create ioctl to pass around these extra flags. The proposal is to add a per-plane format modifier. This allows to, if necessary, use different tiling patters for sub-sampled planes, etc. The format modifiers are added at the end of the ioctl struct, so for legacy userspace it will be zero padded. TODO how best to deal with assignment of modifier token values? The rough idea was to namespace things with an 8bit vendor-id, and then beyond that it is treated as an opaque value. But that was a relatively arbitrary choice. There are cases where same tiling pattern and/or compression is supported by various different vendors. So we should standardize to use the vendor-id and value of the first one who documents the format? TODO move definition of tokens to drm_fourcc.h? Signed-off-by: Rob Clark --- include/uapi/drm/drm_mode.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index aae71cb..c43648c 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -330,6 +330,28 @@ struct drm_mode_fb_cmd { #define DRM_MODE_FB_INTERLACED (1<<0) /* for interlaced framebuffers */ +/* + * Format Modifiers: + * + * Format modifiers describe, typically, a re-ordering or modification + * of the data in a plane of an FB. This can be used to express tiled/ + * swizzled formats, or compression, or a combination of the two. + * + * The upper 8 bits of the format modifier are a vendor-id as assigned + * below. The lower 24 bits are assigned as vendor sees fit. + */ + +/* Vendor Ids: */ +#define DRM_FOURCC_MOD_VENDOR_SAMSUNG 0x03 +/* ... more */ + +#define DRM_FOURCC_MOD(vendor, name) (((DRM_FOURCC_MOD_VENDOR_## vendor) << 24) | val) + +/* Modifier values: */ +/* 64x32 macroblock, ie NV12MT: */ +#define DRM_FOURCC_MOD_SAMSUNG_64_32_TILE DRM_FOURCC_MOD(SAMSUNG, 123) +/* ... more */ + struct drm_mode_fb_cmd2 { __u32 fb_id; __u32 width, height; @@ -349,10 +371,18 @@ struct drm_mode_fb_cmd2 { * So it would consist of Y as offsets[0] and UV as * offsets[1]. Note that offsets[0] will generally * be 0 (but this is not required). + * + * To accommodate tiled, compressed, etc formats, a per-plane + * modifier can be specified. The default value of zero + * indicates "native" format as specified by the fourcc. + * Vendor specific modifier token. This allows, for example, + * different tiling/swizzling pattern on different planes. + * See discussion above of DRM_FOURCC_MOD_xxx. */ __u32 handles[4]; __u32 pitches[4]; /* pitch for each plane */ __u32 offsets[4]; /* offset of each plane */ + __u32 modifier[4]; /* ie, tiling, compressed (per plane) */ }; #define DRM_MODE_FB_DIRTY_ANNOTATE_COPY 0x01