From patchwork Tue May 29 18:33:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 10436739 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2311E601C7 for ; Tue, 29 May 2018 18:33:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 130BD27DCD for ; Tue, 29 May 2018 18:33:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07F382832D; Tue, 29 May 2018 18:33:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 93C0327DCD for ; Tue, 29 May 2018 18:33:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 08A396E529; Tue, 29 May 2018 18:33:35 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 08ACD6E526 for ; Tue, 29 May 2018 18:33:33 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 May 2018 11:33:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,457,1520924400"; d="scan'208";a="59551640" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.174]) by fmsmga001.fm.intel.com with SMTP; 29 May 2018 11:33:31 -0700 Received: by stinkbox (sSMTP sendmail emulation); Tue, 29 May 2018 21:33:30 +0300 From: Ville Syrjala To: intel-gfx@lists.freedesktop.org Date: Tue, 29 May 2018 21:33:13 +0300 Message-Id: <20180529183315.9823-6-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180529183315.9823-1-ville.syrjala@linux.intel.com> References: <20180529183315.9823-1-ville.syrjala@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH xf86-video-intel 6/8] sna/video/sprite: Add NV12 support X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Ville Syrjälä Starting from ~KBL planes can do NV12. Let's make use that capability in the sprite Xv adaptor. Signed-off-by: Ville Syrjälä --- src/sna/sna_video_sprite.c | 57 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/src/sna/sna_video_sprite.c b/src/sna/sna_video_sprite.c index a4f3205b6fc9..f6d6f0b45b6c 100644 --- a/src/sna/sna_video_sprite.c +++ b/src/sna/sna_video_sprite.c @@ -46,6 +46,7 @@ #define DRM_FORMAT_XRGB8888 fourcc_code('X', 'R', '2', '4') /* [31:0] x:R:G:B 8:8:8:8 little endian */ #define DRM_FORMAT_YUYV fourcc_code('Y', 'U', 'Y', 'V') /* [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian */ #define DRM_FORMAT_UYVY fourcc_code('U', 'Y', 'V', 'Y') /* [31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian */ +#define DRM_FORMAT_NV12 fourcc_code('N', 'V', '1', '2') /* 2x2 subsampled Cr:Cb plane */ #define has_hw_scaling(sna, video) ((sna)->kgem.gen < 071 || \ ((sna)->kgem.gen >= 0110 && (video)->AlwaysOnTop)) @@ -72,7 +73,12 @@ struct local_mode_set_plane { static Atom xvColorKey, xvAlwaysOnTop, xvSyncToVblank, xvColorspace; static XvFormatRec formats[] = { {15}, {16}, {24} }; -static const XvImageRec images[] = { XVIMAGE_YUY2, XVIMAGE_UYVY, XVMC_RGB888, XVMC_RGB565 }; +static const XvImageRec images[] = { XVIMAGE_YUY2, XVIMAGE_UYVY, + XVMC_RGB888 }; +static const XvImageRec images_rgb565[] = { XVIMAGE_YUY2, XVIMAGE_UYVY, + XVMC_RGB888, XVMC_RGB565 }; +static const XvImageRec images_nv12[] = { XVIMAGE_YUY2, XVIMAGE_UYVY, + XVIMAGE_NV12, XVMC_RGB888, XVMC_RGB565 }; static const XvAttributeRec attribs[] = { { XvSettable | XvGettable, 0, 1, (char *)"XV_COLORSPACE" }, /* BT.601, BT.709 */ { XvSettable | XvGettable, 0, 0xffffff, (char *)"XV_COLORKEY" }, @@ -307,8 +313,6 @@ sna_video_sprite_show(struct sna *sna, f.width = frame->width; f.height = frame->height; f.flags = 1 << 1; /* +modifiers */ - f.handles[0] = frame->bo->handle; - f.pitches[0] = frame->pitch[0]; switch (frame->bo->tiling) { case I915_TILING_NONE: @@ -323,6 +327,18 @@ sna_video_sprite_show(struct sna *sna, break; } + if (is_nv12_fourcc(frame->id)) { + f.handles[0] = frame->bo->handle; + f.handles[1] = frame->bo->handle; + f.pitches[0] = frame->pitch[1]; + f.pitches[1] = frame->pitch[0]; + f.offsets[0] = 0; + f.offsets[1] = frame->UBufOffset; + } else { + f.handles[0] = frame->bo->handle; + f.pitches[0] = frame->pitch[0]; + } + switch (frame->id) { case FOURCC_RGB565: f.pixel_format = DRM_FORMAT_RGB565; @@ -332,6 +348,9 @@ sna_video_sprite_show(struct sna *sna, f.pixel_format = DRM_FORMAT_XRGB8888; purged = sna->scrn->depth != 24; break; + case FOURCC_NV12: + f.pixel_format = DRM_FORMAT_NV12; + break; case FOURCC_UYVY: f.pixel_format = DRM_FORMAT_UYVY; break; @@ -633,7 +652,7 @@ static int sna_video_sprite_query(ddQueryImageAttributes_ARGS) { struct sna_video *video = port->devPriv.ptr; struct sna_video_frame frame; - int size; + int size, tmp; if (*w > video->sna->mode.max_crtc_width) *w = video->sna->mode.max_crtc_width; @@ -654,6 +673,21 @@ static int sna_video_sprite_query(ddQueryImageAttributes_ARGS) size = 4; break; + case FOURCC_NV12: + *h = (*h + 1) & ~1; + size = (*w + 3) & ~3; + if (pitches) + pitches[0] = size; + size *= *h; + if (offsets) + offsets[1] = size; + tmp = (*w + 3) & ~3; + if (pitches) + pitches[1] = tmp; + tmp *= (*h >> 1); + size += tmp; + break; + default: *w = (*w + 1) & ~1; *h = (*h + 1) & ~1; @@ -752,10 +786,17 @@ void sna_video_sprite_setup(struct sna *sna, ScreenPtr screen) ARRAY_SIZE(formats)); adaptor->nAttributes = ARRAY_SIZE(attribs); adaptor->pAttributes = (XvAttributeRec *)attribs; - adaptor->pImages = (XvImageRec *)images; - adaptor->nImages = 3; - if (sna_has_sprite_format(sna, DRM_FORMAT_RGB565)) - adaptor->nImages = 4; + + if (sna_has_sprite_format(sna, DRM_FORMAT_NV12)) { + adaptor->pImages = (XvImageRec *)images_nv12; + adaptor->nImages = ARRAY_SIZE(images_nv12); + } else if (sna_has_sprite_format(sna, DRM_FORMAT_RGB565)) { + adaptor->pImages = (XvImageRec *)images_rgb565; + adaptor->nImages = ARRAY_SIZE(images_rgb565); + } else { + adaptor->pImages = (XvImageRec *)images; + adaptor->nImages = ARRAY_SIZE(images); + } #if XORG_XV_VERSION < 2 adaptor->ddAllocatePort = sna_xv_alloc_port;