From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D35DC35247 for ; Wed, 5 Feb 2020 22:25:58 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 065F5214AF for ; Wed, 5 Feb 2020 22:25:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 065F5214AF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8E6946EA06; Wed, 5 Feb 2020 22:25:57 +0000 (UTC) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 761C56EA06 for ; Wed, 5 Feb 2020 22:25:56 +0000 (UTC) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Feb 2020 14:25:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,407,1574150400"; d="scan'208";a="430308094" Received: from cmoore1-mobl1.ger.corp.intel.com (HELO intel.com) ([10.252.20.158]) by fmsmga005.fm.intel.com with ESMTP; 05 Feb 2020 14:25:54 -0800 Date: Wed, 5 Feb 2020 22:25:53 +0000 From: Eric Engestrom To: Juston Li Subject: Re: [PATCH v4 libdrm 2/2] Add drmModeGetFB2 Message-ID: <20200205222553.xi6uv43a4hfgleqi@intel.com> Organization: Intel Corporation (UK) Ltd. - Co. Reg. 1134945 - Pipers Way, Swindon SN3 1RJ References: <20200131214109.6323-1-juston.li@intel.com> <20200131214109.6323-2-juston.li@intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200131214109.6323-2-juston.li@intel.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: daniels@collabora.com, dri-devel@lists.freedesktop.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Friday, 2020-01-31 13:41:09 -0800, Juston Li wrote: > From: Daniel Stone > > Add a wrapper around the getfb2 ioctl, which returns extended > framebuffer information mirroring addfb2, including multiple planes and > modifiers. > > Changes since v3: > - remove unnecessary null check in drmModeFreeFB2 (Daniel Stone) > > Changes since v2: > - getfb2 ioctl has been merged upstream > - sync include/drm/drm.h in a seperate patch > > Changes since v1: > - functions should be drm_public > - modifier should be 64 bits > - update ioctl number > > Signed-off-by: Juston Li > Signed-off-by: Daniel Stone > --- > xf86drmMode.c | 36 ++++++++++++++++++++++++++++++++++++ > xf86drmMode.h | 15 +++++++++++++++ > 2 files changed, 51 insertions(+) > > diff --git a/xf86drmMode.c b/xf86drmMode.c > index 0cf7992c6e9a..94dc8ce38a5e 100644 > --- a/xf86drmMode.c > +++ b/xf86drmMode.c > @@ -1594,3 +1594,39 @@ drmModeRevokeLease(int fd, uint32_t lessee_id) > return 0; > return -errno; > } > + > +drm_public drmModeFB2Ptr > +drmModeGetFB2(int fd, uint32_t fb_id) > +{ > + struct drm_mode_fb_cmd2 get; > + drmModeFB2Ptr ret; > + int err; > + > + memclear(get); > + get.fb_id = fb_id; As mentioned on IRC, could you write it like this instead? struct drm_mode_fb_cmd2 get = { .fb_id = fb_id, }; With that, consider this patch Reviewed-by: Eric Engestrom > + > + err = DRM_IOCTL(fd, DRM_IOCTL_MODE_GETFB2, &get); > + if (err != 0) > + return NULL; > + > + ret = drmMalloc(sizeof(drmModeFB2)); > + if (!ret) > + return NULL; > + > + ret->fb_id = fb_id; > + ret->width = get.width; > + ret->height = get.height; > + ret->pixel_format = get.pixel_format; > + ret->flags = get.flags; > + ret->modifier = get.modifier[0]; > + memcpy(ret->handles, get.handles, sizeof(uint32_t) * 4); > + memcpy(ret->pitches, get.pitches, sizeof(uint32_t) * 4); > + memcpy(ret->offsets, get.offsets, sizeof(uint32_t) * 4); > + > + return ret; > +} > + > +drm_public void drmModeFreeFB2(drmModeFB2Ptr ptr) > +{ > + drmFree(ptr); > +} > diff --git a/xf86drmMode.h b/xf86drmMode.h > index 159a39937240..fc0bbd8dcb67 100644 > --- a/xf86drmMode.h > +++ b/xf86drmMode.h > @@ -225,6 +225,19 @@ typedef struct _drmModeFB { > uint32_t handle; > } drmModeFB, *drmModeFBPtr; > > +typedef struct _drmModeFB2 { > + uint32_t fb_id; > + uint32_t width, height; > + uint32_t pixel_format; /* fourcc code from drm_fourcc.h */ > + uint64_t modifier; /* applies to all buffers */ > + uint32_t flags; > + > + /* per-plane GEM handle; may be duplicate entries for multiple planes */ > + uint32_t handles[4]; > + uint32_t pitches[4]; /* bytes */ > + uint32_t offsets[4]; /* bytes */ > +} drmModeFB2, *drmModeFB2Ptr; > + > typedef struct drm_clip_rect drmModeClip, *drmModeClipPtr; > > typedef struct _drmModePropertyBlob { > @@ -343,6 +356,7 @@ typedef struct _drmModePlaneRes { > extern void drmModeFreeModeInfo( drmModeModeInfoPtr ptr ); > extern void drmModeFreeResources( drmModeResPtr ptr ); > extern void drmModeFreeFB( drmModeFBPtr ptr ); > +extern void drmModeFreeFB2( drmModeFB2Ptr ptr ); > extern void drmModeFreeCrtc( drmModeCrtcPtr ptr ); > extern void drmModeFreeConnector( drmModeConnectorPtr ptr ); > extern void drmModeFreeEncoder( drmModeEncoderPtr ptr ); > @@ -362,6 +376,7 @@ extern drmModeResPtr drmModeGetResources(int fd); > * Retrieve information about framebuffer bufferId > */ > extern drmModeFBPtr drmModeGetFB(int fd, uint32_t bufferId); > +extern drmModeFB2Ptr drmModeGetFB2(int fd, uint32_t bufferId); > > /** > * Creates a new framebuffer with an buffer object as its scanout buffer. > -- > 2.21.1 > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel