From patchwork Mon Sep 16 17:48:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lespiau, Damien" X-Patchwork-Id: 2899031 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 81C399F1C0 for ; Mon, 16 Sep 2013 18:08:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B00DD2025B for ; Mon, 16 Sep 2013 18:08:40 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 06C4620201 for ; Mon, 16 Sep 2013 18:08:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CA23BE5D4A for ; Mon, 16 Sep 2013 11:08:35 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTP id 522D8E6C47; Mon, 16 Sep 2013 10:49:08 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 16 Sep 2013 10:49:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.90,917,1371106800"; d="scan'208";a="396522561" Received: from unknown (HELO strange.amr.corp.intel.com) ([10.255.15.2]) by fmsmga001.fm.intel.com with ESMTP; 16 Sep 2013 10:49:07 -0700 From: Damien Lespiau To: dri-devel@lists.freedesktop.org Subject: [PATCH 09/12] drm: Track the number of buffers that compose a framebuffer Date: Mon, 16 Sep 2013 18:48:52 +0100 Message-Id: <1379353735-4472-10-git-send-email-damien.lespiau@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1379353735-4472-1-git-send-email-damien.lespiau@intel.com> References: <1379353735-4472-1-git-send-email-damien.lespiau@intel.com> Cc: intel-gfx@lists.freedesktop.org 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+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 DRM has supported multiple-buffers fbs since the introduction of ADDFB2. Let's track the number of buffers in a drm_framebuffer in the common structure so we can use it in the DRM core. Signed-off-by: Damien Lespiau --- drivers/gpu/drm/drm_crtc_helper.c | 20 ++++++++++++++++++++ include/drm/drm_crtc.h | 9 +++++++++ 2 files changed, 29 insertions(+) diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c index 6a64749..32985c0 100644 --- a/drivers/gpu/drm/drm_crtc_helper.c +++ b/drivers/gpu/drm/drm_crtc_helper.c @@ -901,6 +901,25 @@ void drm_helper_connector_dpms(struct drm_connector *connector, int mode) } EXPORT_SYMBOL(drm_helper_connector_dpms); +static int drm_helper_mode_fb_num_buffers(struct drm_mode_fb_cmd2 *mode_cmd) +{ + int count = 0, i, j; + + for (i = 0; i < 4; i++) { + if (!mode_cmd->handles[i]) + continue; + + for (j = 0; j < i; j++) + if (mode_cmd->handles[i] == mode_cmd->handles[j]) + break; + + if (j == i) + count++; + } + + return count; +} + int drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb, struct drm_mode_fb_cmd2 *mode_cmd) { @@ -915,6 +934,7 @@ int drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb, drm_fb_get_bpp_depth(mode_cmd->pixel_format, &fb->depth, &fb->bits_per_pixel); fb->pixel_format = mode_cmd->pixel_format; + fb->num_buffers = drm_helper_mode_fb_num_buffers(mode_cmd); return 0; } diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index bf242ac..e685baf 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -286,6 +286,15 @@ struct drm_framebuffer { int flags; uint32_t pixel_format; /* fourcc format */ struct list_head filp_head; + /* + * A framebuffer can be made of several planes (eg. planar YUV + * formats). These planes can either share the same buffer (in which + * case 'offsets' will tell us where they are within that buffer) or + * be in separate buffers (in which case offsets[i] will generally be + * 0). We track in the common DRM code how many different buffers the + * framebuffer consists of. + */ + int num_buffers; /* if you are using the helper */ void *helper_private; };