[PATCH] demos/intel_sprite_on : Adding Pixel Format Support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: meghanelogal <megha.i.nelogal@xxxxxxxxx>

Adding various pixel format support

Signed-off-by: meghanelogal <megha.i.nelogal@xxxxxxxxx>
---
 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] <output rect width>x<output rect height>\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 */
-- 
1.7.9.5

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx





[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux