From 22201f3b0a1ee957b41a93867b5d6bb46c6851fe Mon Sep 17 00:00:00 2001 From: glevand Date: Thu, 29 Nov 2012 20:03:18 +0000 Subject: [PATCH] implement get_tiled_pitch_size --- util.c | 25 +++++++++++++++++++++++++ util.h | 2 ++ 2 files changed, 27 insertions(+) diff --git a/util.c b/util.c index 5f06ebd..a3d7e00 100644 --- a/util.c +++ b/util.c @@ -145,6 +145,31 @@ flip(int fd, int context_id, int head, unsigned long offset) return (ioctl(fd, PS3GPU_CTL_FLIP, &flip)); } +uint32_t +get_tiled_pitch_size(uint32_t pitch) +{ + static const uint32_t tile_pitches[] = { + 0x00000000, 0x00000200, 0x00000300, 0x00000400, + 0x00000500, 0x00000600, 0x00000700, 0x00000800, + 0x00000a00, 0x00000c00, 0x00000d00, 0x00000e00, + 0x00001000, 0x00001400, 0x00001800, 0x00001a00, + 0x00001c00, 0x00002000, 0x00002800, 0x00003000, + 0x00003400, 0x00003800, 0x00004000, 0x00005000, + 0x00006000, 0x00006800, 0x00007000, 0x00008000, + 0x0000a000, 0x0000c000, 0x0000d000, 0x0000e000, + 0x00010000, + + }; + int i; + + for (i = 0; i < ARRAY_SIZE(tile_pitches) - 1; i++) { + if ((tile_pitches[i] < pitch) && (pitch <= tile_pitches[i + 1])) + return (tile_pitches[i + 1]); + } + + return (0); +} + int save_image(const char *filename, const char *buf, int len) { diff --git a/util.h b/util.h index cad1fa3..413ff33 100644 --- a/util.h +++ b/util.h @@ -171,6 +171,8 @@ int reset_flip_status(int fd, int context_id, int head); int flip(int fd, int context_id, int head, unsigned long offset); +uint32_t get_tiled_pitch_size(uint32_t pitch); + /* * How to convert image to JPG format: * -- 2.11.4.GIT