From patchwork Mon Mar 2 05:52:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: meghanelogal X-Patchwork-Id: 5910221 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0DF799F318 for ; Mon, 2 Mar 2015 05:56:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1B19B20211 for ; Mon, 2 Mar 2015 05:56:22 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id EB12F201FE for ; Mon, 2 Mar 2015 05:56:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E16A56E36B; Sun, 1 Mar 2015 21:56:18 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id A06626E36B for ; Sun, 1 Mar 2015 21:56:17 -0800 (PST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 01 Mar 2015 21:54:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,674,1418112000"; d="scan'208";a="692524156" Received: from meghanelogal-2012-client-platform.iind.intel.com ([10.223.161.112]) by orsmga002.jf.intel.com with ESMTP; 01 Mar 2015 21:56:16 -0800 From: meghanelogal To: intel-gfx@lists.freedesktop.org Date: Mon, 2 Mar 2015 11:22:19 +0530 Message-Id: <1425275539-24308-1-git-send-email-megha.i.nelogal@intel.com> X-Mailer: git-send-email 1.7.9.5 Cc: megha.i.nelogal@intel.com Subject: [Intel-gfx] [PATCH] demos/intel_sprite_on : Adding Pixel Format Support X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 From: meghanelogal Adding various pixel format support Signed-off-by: meghanelogal --- demos/intel_sprite_on.c | 81 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 75 insertions(+), 6 deletions(-) diff --git a/demos/intel_sprite_on.c b/demos/intel_sprite_on.c index 23fc56c..614a860 100644 --- a/demos/intel_sprite_on.c +++ b/demos/intel_sprite_on.c @@ -49,6 +49,19 @@ #include "ioctl_wrappers.h" +/* Pixel Formats */ +#define SPRITE_DRM_FORMAT_RGB565 1 +#define SPRITE_DRM_FORMAT_XRGB8888 2 +#define SPRITE_DRM_FORMAT_ARGB8888 3 +#define SPRITE_DRM_FORMAT_XRGB2101010 4 +#define SPRITE_DRM_FORMAT_ARGB2101010 5 +#define SPRITE_DRM_FORMAT_XBGR8888 6 +#define SPRITE_DRM_FORMAT_ABGR8888 7 +#define SPRITE_DRM_FORMAT_YUYV 8 +#define SPRITE_DRM_FORMAT_C8 9 + +/* Default Pixel Format */ +static uint32_t pixel_format = DRM_FORMAT_XBGR8888; /* * Mode setting with the kernel interfaces is a bit of a chore. * First you have to find the connector in question and make sure the @@ -631,9 +644,9 @@ static void ricochet(int tiled, int sprite_w, int sprite_h, memset(offsets, 0, sizeof(offsets)); ret = drmModeAddFB2(gfx_fd, sprite_w, sprite_h, - DRM_FORMAT_XRGB8888, - handles, pitches, offsets, - &sprite_fb_id[sprite_index], plane_flags); + pixel_format, + handles, pitches, offsets, + &sprite_fb_id[sprite_index], plane_flags); gem_close(gfx_fd, sprite_handles[sprite_index]); if (ret) { @@ -777,9 +790,12 @@ static void ricochet(int tiled, int sprite_w, int sprite_h, sprite_x[i], sprite_y[i], out_w, out_h, 0, 0, - sprite_w << 16, sprite_h << 16)) + sprite_w << 16, sprite_h << 16)) { printf("Failed to enable sprite plane: %s\n", strerror(errno)); + printf("Given Pixel format is not supported\n"); + exit(0); + } } // Check if it's time to move the sprite surface @@ -886,6 +902,16 @@ static void usage(char *name) "\t-h\t[optional] output help message\n" "\t-t\t[optional] enable tiling\n" "\t-o\t[optional] x\n\n" + "\t-p\t - Pixel Format\n\ + [1] - DRM_FORMAT_RGB565 \n \ + [2] - DRM_FORMAT_XRGB8888 \n \ + [3] - DRM_FORMAT_ARGB8888 \n \ + [4] - DRM_FORMAT_XRGB2101010 \n \ + [5] - DRM_FORMAT_ARGB2101010 \n \ + [6] - DRM_FORMAT_XBGR8888 \n \ + [7] - DRM_FORMAT_ABGR8888 \n \ + [8] - DRM_FORMAT_YUYV \n \ + [9] - DRM_FORMAT_C8 \n \n" "Keyboard control for sprite movement and flip rate ...\n" "\t'q' or 'Q' - Quit the program\n" "\t'n' or 'N' - Switch to next display\n" @@ -905,8 +931,10 @@ int main(int argc, char **argv) int plane_width = 0, plane_height = 0, out_width = 0, - out_height = 0; - static char optstr[] = "ds:o:th"; + out_height = 0, + input_format = 0; + static char optstr[] = "ds:o:th:p:"; + opterr = 0; while ((c = getopt(argc, argv, optstr)) != -1) { @@ -926,6 +954,47 @@ int main(int argc, char **argv) if (sscanf(optarg, "%dx%d", &out_width, &out_height) != 2) usage(argv[0]); break; + case 'p': /* Pixel Format Support */ + if (sscanf(optarg, "%d", &input_format) != 1) + usage(argv[0]); + if ((input_format < SPRITE_DRM_FORMAT_RGB565) || (input_format > SPRITE_DRM_FORMAT_C8)) { + printf("\nError: Invalid pixel format entered : %d\n", input_format); + printf("Displaying the default pixel format : XBGR8888\n"); + usage(argv[0]); + } + switch (input_format) { + case SPRITE_DRM_FORMAT_RGB565: + pixel_format = DRM_FORMAT_RGB565; + break; + case SPRITE_DRM_FORMAT_XRGB8888: + pixel_format = DRM_FORMAT_XRGB8888; + break; + case SPRITE_DRM_FORMAT_ARGB8888: + pixel_format = DRM_FORMAT_ARGB8888; + break; + case SPRITE_DRM_FORMAT_XRGB2101010: + pixel_format = DRM_FORMAT_XRGB2101010; + break; + case SPRITE_DRM_FORMAT_ARGB2101010: + pixel_format = DRM_FORMAT_ARGB2101010; + break; + case SPRITE_DRM_FORMAT_XBGR8888: + pixel_format = DRM_FORMAT_XBGR8888; + break; + case SPRITE_DRM_FORMAT_ABGR8888: + pixel_format = DRM_FORMAT_ABGR8888; + break; + case SPRITE_DRM_FORMAT_YUYV: + pixel_format = DRM_FORMAT_YUYV; + break; + case SPRITE_DRM_FORMAT_C8: + pixel_format = DRM_FORMAT_C8; + break; + default: + pixel_format = DRM_FORMAT_XBGR8888; + break; + } + break; default: printf("unknown option %c\n", c); /* fall through */