From: Rob Clark Subject: [PATCH libdrm 3/3] modetest: add AR15/XR15 (RGB-1555) formats Date: Wed, 21 Mar 2012 13:01:04 -0500 Message-ID: <1332352864-18723-3-git-send-email-rob.clark@linaro.org> References: <1332352864-18723-1-git-send-email-rob.clark@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-ob0-f177.google.com (mail-ob0-f177.google.com [209.85.214.177]) by gabe.freedesktop.org (Postfix) with ESMTP id D365FA0BD0 for ; Wed, 21 Mar 2012 11:01:15 -0700 (PDT) Received: by obbup16 with SMTP id up16so1036194obb.36 for ; Wed, 21 Mar 2012 11:01:15 -0700 (PDT) In-Reply-To: <1332352864-18723-1-git-send-email-rob.clark@linaro.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: dri-devel@lists.freedesktop.org Cc: Rob Clark , patches@linaro.org List-Id: dri-devel@lists.freedesktop.org From: Rob Clark Signed-off-by: Rob Clark --- tests/modetest/modetest.c | 36 ++++++++++++++++++++++++++++++++++++ 1 files changed, 36 insertions(+), 0 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index 36bdfff..819724a 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -652,6 +652,26 @@ fill422(unsigned char *virtual, int n, int width, int height, int stride) } } +static void +fill1555(unsigned char *virtual, int n, int width, int height, int stride) +{ + int i, j; + /* paint the buffer with colored tiles */ + for (j = 0; j < height; j++) { + uint16_t *ptr = (uint16_t*)((char*)virtual + j * stride); + for (i = 0; i < width; i++) { + div_t d = div(n+i+j, width); + uint32_t rgb = 0x00130502 * (d.quot >> 6) + 0x000a1120 * (d.rem >> 6); + unsigned char *rgbp = (unsigned char *)&rgb; + + *(ptr++) = 0x8000 | + (rgbp[RED] >> 3) << 10 | + (rgbp[GREEN] >> 3) << 5 | + (rgbp[BLUE] >> 3); + } + } +} + static int set_plane(struct kms_driver *kms, struct connector *c, struct plane *p) { @@ -756,6 +776,22 @@ set_plane(struct kms_driver *kms, struct connector *c, struct plane *p) 1, 0, p->w, p->h, pitches[0]); format = DRM_FORMAT_YVU420; + } else if (!strcmp(p->format_str, "XR15")) { + pitches[0] = p->w * 2; + offsets[0] = 0; + kms_bo_get_prop(plane_bo, KMS_HANDLE, &handles[0]); + + fill1555(virtual, 0, p->w, p->h, pitches[0]); + + format = DRM_FORMAT_XRGB1555; + } else if (!strcmp(p->format_str, "AR15")) { + pitches[0] = p->w * 2; + offsets[0] = 0; + kms_bo_get_prop(plane_bo, KMS_HANDLE, &handles[0]); + + fill1555(virtual, 0, p->w, p->h, pitches[0]); + + format = DRM_FORMAT_ARGB1555; } else { fprintf(stderr, "Unknown format: %s\n", p->format_str); return -1; -- 1.7.5.4