From patchwork Tue May 29 18:33:12 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: 10436737 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 3E573601E9 for ; Tue, 29 May 2018 18:33:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EB5A27DCD for ; Tue, 29 May 2018 18:33:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 23A182832D; Tue, 29 May 2018 18:33:33 +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 857BA27DCD for ; Tue, 29 May 2018 18:33:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B70246E50D; Tue, 29 May 2018 18:33:31 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 09BD26E50D for ; Tue, 29 May 2018 18:33:30 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 May 2018 11:33:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,457,1520924400"; d="scan'208";a="44862188" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.174]) by orsmga007.jf.intel.com with SMTP; 29 May 2018 11:33:28 -0700 Received: by stinkbox (sSMTP sendmail emulation); Tue, 29 May 2018 21:33:27 +0300 From: Ville Syrjala To: intel-gfx@lists.freedesktop.org Date: Tue, 29 May 2018 21:33:12 +0300 Message-Id: <20180529183315.9823-5-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 5/8] sna/video/sprite: Query planes for RGB565 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ä Not all sprite planes support RGB565. Insrtead of hardcoding which platforms have it let's ask the kernel instead. Signed-off-by: Ville Syrjälä --- src/sna/sna.h | 1 + src/sna/sna_display.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++ src/sna/sna_video_sprite.c | 2 +- 3 files changed, 78 insertions(+), 1 deletion(-) diff --git a/src/sna/sna.h b/src/sna/sna.h index 6fe1f0d252e6..496460ca6a84 100644 --- a/src/sna/sna.h +++ b/src/sna/sna.h @@ -636,6 +636,7 @@ extern bool sna_crtc_set_sprite_rotation(xf86CrtcPtr crtc, unsigned idx, uint32_ extern void sna_crtc_set_sprite_colorspace(xf86CrtcPtr crtc, unsigned idx, int colorspace); extern uint32_t sna_crtc_to_sprite(xf86CrtcPtr crtc, unsigned idx); extern bool sna_crtc_is_transformed(xf86CrtcPtr crtc); +bool sna_has_sprite_format(struct sna *sna, uint32_t format); #define CRTC_VBLANK 0x7 #define CRTC_ON 0x80000000 diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c index 66a941ae7301..96e7b1bc50d3 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -3560,6 +3560,82 @@ sna_crtc_find_planes(struct sna *sna, struct sna_crtc *crtc) free(planes); } +static bool plane_has_format(const uint32_t formats[], + int count_formats, + uint32_t format) +{ + int i; + + for (i = 0; i < count_formats; i++) { + if (formats[i] == format) + return true; + } + + return false; +} + +bool sna_has_sprite_format(struct sna *sna, uint32_t format) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(sna->scrn); + int i; + + if (sna->mode.num_real_crtc == 0) + return false; + + for (i = 0; i < sna->mode.num_real_crtc; i++) { + struct sna_crtc *sna_crtc = to_sna_crtc(config->crtc[i]); + struct plane *plane; + + list_for_each_entry(plane, &sna_crtc->sprites, link) { + struct local_mode_get_plane p; + uint32_t *formats; + int count_formats; + bool has_format; + + VG_CLEAR(p); + p.plane_id = plane->id; + p.count_format_types = 0; + if (drmIoctl(sna->kgem.fd, + LOCAL_IOCTL_MODE_GETPLANE, + &p)) + continue; + count_formats = p.count_format_types; + + formats = calloc(count_formats, sizeof(formats[0])); + if (!formats) + continue; + + p.count_format_types = count_formats; + p.format_type_ptr = (uintptr_t)formats; + if (drmIoctl(sna->kgem.fd, + LOCAL_IOCTL_MODE_GETPLANE, + &p)) { + free(formats); + continue; + } + + assert(p.count_format_types == count_formats); + + has_format = plane_has_format(formats, + count_formats, + format); + + free(formats); + + /* + * As long as one plane supports the + * format we declare it as supported. + * Not all planes may support it, but + * then the GPU fallback will kick in. + */ + if (has_format) + return true; + } + } + + return false; +} + static void sna_crtc_init__rotation(struct sna *sna, struct sna_crtc *crtc) { diff --git a/src/sna/sna_video_sprite.c b/src/sna/sna_video_sprite.c index 56391aa6f581..a4f3205b6fc9 100644 --- a/src/sna/sna_video_sprite.c +++ b/src/sna/sna_video_sprite.c @@ -754,7 +754,7 @@ void sna_video_sprite_setup(struct sna *sna, ScreenPtr screen) adaptor->pAttributes = (XvAttributeRec *)attribs; adaptor->pImages = (XvImageRec *)images; adaptor->nImages = 3; - if (sna->kgem.gen == 071) + if (sna_has_sprite_format(sna, DRM_FORMAT_RGB565)) adaptor->nImages = 4; #if XORG_XV_VERSION < 2