diff options
author | Alexei Shlychkov <x0177296@ti.com> | 2012-09-13 03:46:57 -0700 |
---|---|---|
committer | Ziyann <jaraidaniel@gmail.com> | 2014-10-01 13:00:59 +0200 |
commit | 5773ee55071f2a531bc4b0fdb7fe94adb6fb6214 (patch) | |
tree | e5e0448514dda50c57e8b55f56ff80d353e5ad2b /drivers/misc/gcx | |
parent | 5026b8702d607e0ced4e080ff9e0c2489560fdfd (diff) | |
download | kernel_samsung_tuna-5773ee55071f2a531bc4b0fdb7fe94adb6fb6214.zip kernel_samsung_tuna-5773ee55071f2a531bc4b0fdb7fe94adb6fb6214.tar.gz kernel_samsung_tuna-5773ee55071f2a531bc4b0fdb7fe94adb6fb6214.tar.bz2 |
gcx: added generic format parser.
RGB and YUV formats are now generically supported.
Change-Id: I9911119c6323ac91a63e1fb7d0a3012038985d8e
Signed-off-by: Alexei Shlychkov <x0177296@ti.com>
Diffstat (limited to 'drivers/misc/gcx')
-rw-r--r-- | drivers/misc/gcx/gcbv/gcblit.c | 42 | ||||
-rw-r--r-- | drivers/misc/gcx/gcbv/gcbv.h | 37 | ||||
-rw-r--r-- | drivers/misc/gcx/gcbv/gcfill.c | 18 | ||||
-rw-r--r-- | drivers/misc/gcx/gcbv/gcfilter.c | 23 | ||||
-rw-r--r-- | drivers/misc/gcx/gcbv/gcparser.c | 666 |
5 files changed, 408 insertions, 378 deletions
diff --git a/drivers/misc/gcx/gcbv/gcblit.c b/drivers/misc/gcx/gcbv/gcblit.c index 4ff6ba1..030a329 100644 --- a/drivers/misc/gcx/gcbv/gcblit.c +++ b/drivers/misc/gcx/gcbv/gcblit.c @@ -116,17 +116,15 @@ static enum bverror do_blit_end(struct bvbltparams *bvbltparams, } /* Set destination configuration. */ - GCDBG(GCZONE_BLIT, "format entry = 0x%08X\n", - (unsigned int) dstinfo->format); GCDBG(GCZONE_BLIT, " swizzle code = %d\n", - dstinfo->format->swizzle); + dstinfo->format.swizzle); GCDBG(GCZONE_BLIT, " format code = %d\n", - dstinfo->format->format); + dstinfo->format.format); gcmobltconfig->dstconfig_ldst = gcmobltconfig_dstconfig_ldst; gcmobltconfig->dstconfig.raw = 0; - gcmobltconfig->dstconfig.reg.swizzle = dstinfo->format->swizzle; - gcmobltconfig->dstconfig.reg.format = dstinfo->format->format; + gcmobltconfig->dstconfig.reg.swizzle = dstinfo->format.swizzle; + gcmobltconfig->dstconfig.reg.format = dstinfo->format.format; gcmobltconfig->dstconfig.reg.command = gcblit->multisrc ? GCREG_DEST_CONFIG_COMMAND_MULTI_SOURCE_BLT : GCREG_DEST_CONFIG_COMMAND_BIT_BLT; @@ -264,7 +262,7 @@ enum bverror do_blit(struct bvbltparams *bvbltparams, /* Compute the source surface offset in bytes. */ srcbyteshift = srcshiftY * (int) srcinfo->geom->virtstride - + srcshiftX * (int) srcinfo->format->bitspp / 8; + + srcshiftX * (int) srcinfo->format.bitspp / 8; /* Compute the source offset in pixels needed to compensate * for the surface base address misalignment if any. */ @@ -279,7 +277,7 @@ enum bverror do_blit(struct bvbltparams *bvbltparams, srcalign); /* Apply the source alignment. */ - srcbyteshift += srcalign * (int) srcinfo->format->bitspp / 8; + srcbyteshift += srcalign * (int) srcinfo->format.bitspp / 8; srcshiftX += srcalign; GCDBG(GCZONE_SURF, " adjusted surface offset (pixels) = %d,%d\n", @@ -294,7 +292,7 @@ enum bverror do_blit(struct bvbltparams *bvbltparams, /* Compute the destination surface offset in bytes. */ dstbyteshift = dstshiftY * (int) dstinfo->geom->virtstride - + dstshiftX * (int) dstinfo->format->bitspp / 8; + + dstshiftX * (int) dstinfo->format.bitspp / 8; /* Compute the destination offset in pixels needed to compensate * for the surface base address misalignment if any. */ @@ -308,7 +306,7 @@ enum bverror do_blit(struct bvbltparams *bvbltparams, GCDBG(GCZONE_SURF, " realignment = %d\n", dstalign); - if ((srcinfo->format->format == GCREG_DE_FORMAT_NV12) || + if ((srcinfo->format.format == GCREG_DE_FORMAT_NV12) || (dstalign != 0) || ((srcalign != 0) && (srcinfo->angle == dstinfo->angle))) { /* Compute the source offset in pixels needed to compensate @@ -316,7 +314,7 @@ enum bverror do_blit(struct bvbltparams *bvbltparams, srcalign = get_pixel_offset(srcinfo, 0); /* Compute the surface offsets in bytes. */ - srcbyteshift = srcalign * (int) srcinfo->format->bitspp / 8; + srcbyteshift = srcalign * (int) srcinfo->format.bitspp / 8; GCDBG(GCZONE_SURF, "recomputed for single-source setup:\n"); GCDBG(GCZONE_SURF, " srcalign = %d\n", @@ -549,8 +547,8 @@ enum bverror do_blit(struct bvbltparams *bvbltparams, gcmosrc->config_ldst = gcmosrc_config_ldst[index]; gcmosrc->config.raw = 0; - gcmosrc->config.reg.swizzle = srcinfo->format->swizzle; - gcmosrc->config.reg.format = srcinfo->format->format; + gcmosrc->config.reg.swizzle = srcinfo->format.swizzle; + gcmosrc->config.reg.format = srcinfo->format.format; gcmosrc->origin_ldst = gcmosrc_origin_ldst[index]; gcmosrc->origin.reg.x = srcleft; @@ -581,25 +579,25 @@ enum bverror do_blit(struct bvbltparams *bvbltparams, gcmosrc->mult.reg.srcglobalpremul = GCREG_COLOR_MULTIPLY_MODES_SRC_GLOBAL_PREMULTIPLY_DISABLE; - if ((srcinfo->geom->format & OCDFMTDEF_NON_PREMULT) != 0) + if (srcinfo->format.premultiplied) gcmosrc->mult.reg.srcpremul - = GCREG_COLOR_MULTIPLY_MODES_SRC_PREMULTIPLY_ENABLE; + = GCREG_COLOR_MULTIPLY_MODES_SRC_PREMULTIPLY_DISABLE; else gcmosrc->mult.reg.srcpremul - = GCREG_COLOR_MULTIPLY_MODES_SRC_PREMULTIPLY_DISABLE; + = GCREG_COLOR_MULTIPLY_MODES_SRC_PREMULTIPLY_ENABLE; - if ((dstinfo->geom->format & OCDFMTDEF_NON_PREMULT) != 0) { + if (dstinfo->format.premultiplied) { gcmosrc->mult.reg.dstpremul - = GCREG_COLOR_MULTIPLY_MODES_SRC_PREMULTIPLY_ENABLE; + = GCREG_COLOR_MULTIPLY_MODES_SRC_PREMULTIPLY_DISABLE; gcmosrc->mult.reg.dstdemul - = GCREG_COLOR_MULTIPLY_MODES_DST_DEMULTIPLY_ENABLE; + = GCREG_COLOR_MULTIPLY_MODES_DST_DEMULTIPLY_DISABLE; } else { gcmosrc->mult.reg.dstpremul - = GCREG_COLOR_MULTIPLY_MODES_SRC_PREMULTIPLY_DISABLE; + = GCREG_COLOR_MULTIPLY_MODES_SRC_PREMULTIPLY_ENABLE; gcmosrc->mult.reg.dstdemul - = GCREG_COLOR_MULTIPLY_MODES_DST_DEMULTIPLY_DISABLE; + = GCREG_COLOR_MULTIPLY_MODES_DST_DEMULTIPLY_ENABLE; } if (srcinfo->gca == NULL) { @@ -658,7 +656,7 @@ enum bverror do_blit(struct bvbltparams *bvbltparams, gcmoxsrcalpha->dstglobal.raw = srcinfo->gca->dst_global_color; } - if (srcinfo->format->format == GCREG_DE_FORMAT_NV12) { + if (srcinfo->format.format == GCREG_DE_FORMAT_NV12) { struct gcmoxsrcyuv *gcmoxsrcyuv; int uvshift = srcbyteshift; diff --git a/drivers/misc/gcx/gcbv/gcbv.h b/drivers/misc/gcx/gcbv/gcbv.h index d54ad84..48f23d6 100644 --- a/drivers/misc/gcx/gcbv/gcbv.h +++ b/drivers/misc/gcx/gcbv/gcbv.h @@ -113,6 +113,16 @@ do { \ bverror = error; \ } while (0) +#define GCPRINT_RECT(zone, name, rect) \ +{ \ + GCDBG(zone, \ + name " = (%d,%d)-(%d,%d), %dx%d\n", \ + (rect)->left, (rect)->top, \ + (rect)->right, (rect)->bottom, \ + (rect)->right - (rect)->left, \ + (rect)->bottom - (rect)->top); \ +} + /******************************************************************************* * Kernel table definitions. @@ -217,13 +227,8 @@ struct bvbuffmapinfo { * Color format. */ -#define BVFMT_PLANAR 0x100 -#define BVFMT_MASK 0xFF - -#define BVFMT_RGB 1 -#define BVFMT_YUV 2 -#define BVFMT_PACKED_YUV (BVFMT_YUV) -#define BVFMT_PLANAR_YUV (BVFMT_YUV | BVFMT_PLANAR) +#define BVFMT_RGB 1 +#define BVFMT_YUV 2 struct bvcomponent { unsigned int shift; @@ -241,9 +246,21 @@ struct bvcsrgb { struct bvformatxlate { unsigned int type; unsigned int bitspp; + unsigned int allocbitspp; unsigned int format; unsigned int swizzle; - struct bvcsrgb rgba; + bool premultiplied; + + union { + struct { + const struct bvcsrgb *comp; + } rgb; + + struct { + unsigned int std; + unsigned int planecount; + } yuv; + } cs; }; @@ -320,7 +337,7 @@ struct surfaceinfo { struct gcrect rect; /* Surface format. */ - struct bvformatxlate *format; + struct bvformatxlate format; /* Physical size of the surface (accounted for rotation). */ unsigned int physwidth; @@ -460,6 +477,8 @@ struct gcbatch { struct gccontext *get_context(void); /* Parsers. */ +enum bverror parse_format(struct bvbltparams *bvbltparams, + struct surfaceinfo *surfaceinfo); enum bverror parse_blend(struct bvbltparams *bvbltparams, enum bvblend blend, struct gcalpha *gca); diff --git a/drivers/misc/gcx/gcbv/gcfill.c b/drivers/misc/gcx/gcbv/gcfill.c index a43bb63..252713b 100644 --- a/drivers/misc/gcx/gcbv/gcfill.c +++ b/drivers/misc/gcx/gcbv/gcfill.c @@ -65,7 +65,7 @@ GCDBG_FILTERDEF(gcfill, GCZONE_NONE, static inline unsigned int extract_component(unsigned int pixel, - struct bvcomponent *desc) + const struct bvcomponent *desc) { unsigned int component; unsigned int component8; @@ -129,10 +129,10 @@ static unsigned int getinternalcolor(void *ptr, struct bvformatxlate *format) GCDBG(GCZONE_COLOR, "srcpixel=0x%08X\n", srcpixel); } - r = extract_component(srcpixel, &format->rgba.r); - g = extract_component(srcpixel, &format->rgba.g); - b = extract_component(srcpixel, &format->rgba.b); - a = extract_component(srcpixel, &format->rgba.a); + r = extract_component(srcpixel, &format->cs.rgb.comp->r); + g = extract_component(srcpixel, &format->cs.rgb.comp->g); + b = extract_component(srcpixel, &format->cs.rgb.comp->b); + a = extract_component(srcpixel, &format->cs.rgb.comp->a); GCDBG(GCZONE_COLOR, "(r,g,b,a)=0x%02X,0x%02X,0x%02X,0x%02X\n", r, g, b, a); @@ -233,11 +233,11 @@ enum bverror do_fill(struct bvbltparams *bvbltparams, fillcolorptr = (unsigned char *) srcinfo->buf.desc->virtaddr + srcinfo->rect.top * srcinfo->geom->virtstride - + srcinfo->rect.left * srcinfo->format->bitspp / 8; + + srcinfo->rect.left * srcinfo->format.bitspp / 8; gcmofill->clearcolor_ldst = gcmofill_clearcolor_ldst; gcmofill->clearcolor.raw = getinternalcolor(fillcolorptr, - srcinfo->format); + &srcinfo->format); /*********************************************************************** ** Configure and start fill. @@ -246,8 +246,8 @@ enum bverror do_fill(struct bvbltparams *bvbltparams, /* Set destination configuration. */ gcmofill->dstconfig_ldst = gcmofill_dstconfig_ldst; gcmofill->dstconfig.raw = 0; - gcmofill->dstconfig.reg.swizzle = dstinfo->format->swizzle; - gcmofill->dstconfig.reg.format = dstinfo->format->format; + gcmofill->dstconfig.reg.swizzle = dstinfo->format.swizzle; + gcmofill->dstconfig.reg.format = dstinfo->format.format; gcmofill->dstconfig.reg.command = GCREG_DEST_CONFIG_COMMAND_CLEAR; /* Set ROP3. */ diff --git a/drivers/misc/gcx/gcbv/gcfilter.c b/drivers/misc/gcx/gcbv/gcfilter.c index d2dc438..a436186 100644 --- a/drivers/misc/gcx/gcbv/gcfilter.c +++ b/drivers/misc/gcx/gcbv/gcfilter.c @@ -647,8 +647,8 @@ static enum bverror startvr(struct bvbltparams *bvbltparams, gcmovrdst->address = GET_MAP_HANDLE(dstmap); gcmovrdst->stride = dstinfo->geom->virtstride; gcmovrdst->config.raw = 0; - gcmovrdst->config.reg.swizzle = dstinfo->format->swizzle; - gcmovrdst->config.reg.format = dstinfo->format->format; + gcmovrdst->config.reg.swizzle = dstinfo->format.swizzle; + gcmovrdst->config.reg.format = dstinfo->format.format; /* Set surface width and height. */ gcmovrdst->rotation.raw = 0; @@ -670,7 +670,7 @@ static enum bverror startvr(struct bvbltparams *bvbltparams, /* Compute the source alignments needed to compensate * for the surface base address misalignment if any. */ srcpixalign = get_pixel_offset(srcinfo, 0); - srcbytealign = (srcpixalign * (int) srcinfo->format->bitspp) / 8; + srcbytealign = (srcpixalign * (int) srcinfo->format.bitspp) / 8; switch (srcinfo->angle) { case ROT_ANGLE_0: @@ -730,11 +730,12 @@ static enum bverror startvr(struct bvbltparams *bvbltparams, gcmovrsrc->rotation.reg.surf_width = srcsurfwidth; gcmovrsrc->config.raw = 0; - gcmovrsrc->config.reg.swizzle = srcinfo->format->swizzle; - gcmovrsrc->config.reg.format = srcinfo->format->format; + gcmovrsrc->config.reg.swizzle = srcinfo->format.swizzle; + gcmovrsrc->config.reg.format = srcinfo->format.format; if (gccontext->gcfeatures2.reg.l2cachefor420 && - ((srcinfo->format->type & BVFMT_PLANAR) != 0) && + (srcinfo->format.type == BVFMT_YUV) && + (srcinfo->format.cs.yuv.planecount > 1) && ((srcinfo->angle & 1) != 0)) gcmovrsrc->config.reg.disable420L2cache = GCREG_SRC_CONFIG_DISABLE420_L2_CACHE_DISABLED; @@ -798,7 +799,7 @@ static enum bverror startvr(struct bvbltparams *bvbltparams, = GCREG_COLOR_MULTIPLY_MODES_DST_DEMULTIPLY_DISABLE; } - if (srcinfo->format->format == GCREG_DE_FORMAT_NV12) { + if (srcinfo->format.format == GCREG_DE_FORMAT_NV12) { struct gcmoxsrcyuv *gcmoxsrcyuv; int index = 0; int uvshift; @@ -974,7 +975,7 @@ enum bverror do_filter(struct bvbltparams *bvbltparams, GCENTER(GCZONE_FILTER); /* Additional stride requirements. */ - if (srcinfo->format->format == GCREG_DE_FORMAT_NV12) { + if (srcinfo->format.format == GCREG_DE_FORMAT_NV12) { /* Nv12 may be shifted up to 32 bytes for alignment. * In the worst case stride must be 32 bytes greater. */ @@ -1155,7 +1156,7 @@ enum bverror do_filter(struct bvbltparams *bvbltparams, tmpinfo.gca = srcinfo->gca; /* Determine temporary surface format. */ - if (srcinfo->format->type == BVFMT_YUV) { + if (srcinfo->format.type == BVFMT_YUV) { tmpinfo.format = dstinfo->format; tmpgeom.format = dstinfo->geom->format; } else { @@ -1165,7 +1166,7 @@ enum bverror do_filter(struct bvbltparams *bvbltparams, /* Determine pixel alignment. */ tmpalignmask = GC_BITS_PER_CACHELINE - / tmpinfo.format->bitspp - 1; + / tmpinfo.format.bitspp - 1; /* In partial filter blit cases, the vertical pass has to render * more pixel information to the left and to the right of the @@ -1202,7 +1203,7 @@ enum bverror do_filter(struct bvbltparams *bvbltparams, & ~tmpalignmask; tmpgeom.height = tmpinfo.rect.bottom; tmpgeom.virtstride = (tmpgeom.width - * tmpinfo.format->bitspp) / 8; + * tmpinfo.format.bitspp) / 8; tmpsize = tmpgeom.virtstride * tmpgeom.height; /* Allocate the temporary buffer. */ diff --git a/drivers/misc/gcx/gcbv/gcparser.c b/drivers/misc/gcx/gcbv/gcparser.c index bf0fc55..8ef92ca 100644 --- a/drivers/misc/gcx/gcbv/gcparser.c +++ b/drivers/misc/gcx/gcbv/gcparser.c @@ -83,12 +83,7 @@ GCDBG_FILTERDEF(gcparser, GCZONE_NONE, (gcrect)->right = (bvrect)->left + (bvrect)->width; \ (gcrect)->bottom = (bvrect)->top + (bvrect)->height; \ \ - GCDBG(zone, \ - name " = (%d,%d)-(%d,%d), %dx%d\n", \ - (gcrect)->left, (gcrect)->top, \ - (gcrect)->right, (gcrect)->bottom, \ - (gcrect)->right - (gcrect)->left, \ - (gcrect)->bottom - (gcrect)->top); \ + GCPRINT_RECT(zone, name, gcrect); \ } @@ -96,39 +91,9 @@ GCDBG_FILTERDEF(gcparser, GCZONE_NONE, * Pixel format parser. */ -/* FIXME/TODO: change to use BLTsvile defines. */ - -#if defined(OCDFMTDEF_ALPHA_SHIFT) -# undef OCDFMTDEF_ALPHA_SHIFT -#endif - -#if defined(OCDFMTDEF_ALPHA_MASK) -# undef OCDFMTDEF_ALPHA_MASK -#endif - -#define OCDFMTDEF_ALPHA_SHIFT 18 -#define OCDFMTDEF_ALPHA_MASK (1 << OCDFMTDEF_ALPHA_SHIFT) - #define OCDFMTDEF_PLACEMENT_SHIFT 9 #define OCDFMTDEF_PLACEMENT_MASK (3 << OCDFMTDEF_PLACEMENT_SHIFT) -#define OCDFMTDEF_BITS_SHIFT 3 -#define OCDFMTDEF_BITS_MASK (3 << OCDFMTDEF_BITS_SHIFT) - -#define OCDFMTDEF_BITS12 (0 << OCDFMTDEF_BITS_SHIFT) -#define OCDFMTDEF_BITS15 (1 << OCDFMTDEF_BITS_SHIFT) -#define OCDFMTDEF_BITS16 (2 << OCDFMTDEF_BITS_SHIFT) -#define OCDFMTDEF_BITS24 (3 << OCDFMTDEF_BITS_SHIFT) - -#define BVFORMATRGBA(BPP, Format, Swizzle, R, G, B, A) \ -{ \ - BVFMT_RGB, \ - BPP, \ - GCREG_DE_FORMAT_ ## Format, \ - GCREG_DE_SWIZZLE_ ## Swizzle, \ - { R, G, B, A } \ -} - #define BVCOMP(Shift, Size) \ { Shift, Size, ((1 << Size) - 1) << Shift } @@ -144,255 +109,230 @@ GCDBG_FILTERDEF(gcparser, GCZONE_NONE, #define BVALPHA(Shift, Size) \ BVCOMP(Shift, Size) -#define BVFORMATINVALID \ - { 0, 0, 0, 0, { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } } } +static const unsigned int rgba16swizzle[] = { + GCREG_DE_SWIZZLE_ARGB, + GCREG_DE_SWIZZLE_RGBA, + GCREG_DE_SWIZZLE_ABGR, + GCREG_DE_SWIZZLE_BGRA +}; -static struct bvformatxlate g_format_nv12 = { - .type = BVFMT_PLANAR_YUV, - .bitspp = 8, - .format = GCREG_DE_FORMAT_NV12, +static const unsigned int rgb16swizzle[] = { + GCREG_DE_SWIZZLE_ARGB, + GCREG_DE_SWIZZLE_ARGB, + GCREG_DE_SWIZZLE_ABGR, + GCREG_DE_SWIZZLE_ABGR }; -static struct bvformatxlate g_format_uyvy = { - .type = BVFMT_PACKED_YUV, - .bitspp = 16, - .format = GCREG_DE_FORMAT_UYVY + +static const unsigned int rgba32swizzle[] = { + GCREG_DE_SWIZZLE_BGRA, + GCREG_DE_SWIZZLE_ABGR, + GCREG_DE_SWIZZLE_RGBA, + GCREG_DE_SWIZZLE_ARGB }; -static struct bvformatxlate g_format_yuy2 = { - .type = BVFMT_PACKED_YUV, - .bitspp = 16, - .format = GCREG_DE_FORMAT_YUY2 + +static const struct bvcsrgb xrgb4444_bits[] = { + { BVRED(8, 4), BVGREEN(4, 4), BVBLUE(0, 4), BVALPHA(12, 0) }, + { BVRED(12, 4), BVGREEN(8, 4), BVBLUE(4, 4), BVALPHA(0, 0) }, + { BVRED(0, 4), BVGREEN(4, 4), BVBLUE(8, 4), BVALPHA(12, 0) }, + { BVRED(4, 4), BVGREEN(8, 4), BVBLUE(12, 4), BVALPHA(0, 0) } }; -static struct bvformatxlate formatxlate[] = { - /* #0: OCDFMT_xRGB12 - BITS=12 ALPHA=0 REVERSED=0 LEFT_JUSTIFIED=0 */ - BVFORMATRGBA(16, X4R4G4B4, ARGB, - BVRED(8, 4), BVGREEN(4, 4), BVBLUE(0, 4), BVALPHA(12, 0)), - - /* #1: OCDFMT_RGBx12 - BITS=12 ALPHA=0 REVERSED=0 LEFT_JUSTIFIED=1 */ - BVFORMATRGBA(16, X4R4G4B4, RGBA, - BVRED(12, 4), BVGREEN(8, 4), BVBLUE(4, 4), BVALPHA(0, 0)), - - /* #2: OCDFMT_xBGR12 - BITS=12 ALPHA=0 REVERSED=1 LEFT_JUSTIFIED=0 */ - BVFORMATRGBA(16, X4R4G4B4, ABGR, - BVRED(0, 4), BVGREEN(4, 4), BVBLUE(8, 4), BVALPHA(12, 0)), - - /* #3: OCDFMT_BGRx12 - BITS=12 ALPHA=0 REVERSED=1 LEFT_JUSTIFIED=1 */ - BVFORMATRGBA(16, X4R4G4B4, BGRA, - BVRED(4, 4), BVGREEN(8, 4), BVBLUE(12, 4), BVALPHA(0, 0)), - - /* #4: OCDFMT_ARGB12 - BITS=12 ALPHA=1 REVERSED=0 LEFT_JUSTIFIED=0 */ - BVFORMATRGBA(16, A4R4G4B4, ARGB, - BVRED(8, 4), BVGREEN(4, 4), BVBLUE(0, 4), BVALPHA(12, 4)), - - /* #5: OCDFMT_RGBA12 - BITS=12 ALPHA=1 REVERSED=0 LEFT_JUSTIFIED=1 */ - BVFORMATRGBA(16, A4R4G4B4, RGBA, - BVRED(12, 4), BVGREEN(8, 4), BVBLUE(4, 4), BVALPHA(0, 4)), - - /* #6: OCDFMT_ABGR12 - BITS=12 ALPHA=1 REVERSED=1 LEFT_JUSTIFIED=0 */ - BVFORMATRGBA(16, A4R4G4B4, ABGR, - BVRED(0, 4), BVGREEN(4, 4), BVBLUE(8, 4), BVALPHA(12, 4)), - - /* #7: OCDFMT_BGRA12 - BITS=12 ALPHA=1 REVERSED=1 LEFT_JUSTIFIED=1 */ - BVFORMATRGBA(16, A4R4G4B4, BGRA, - BVRED(4, 4), BVGREEN(8, 4), BVBLUE(12, 4), BVALPHA(0, 4)), - - /***********************************************/ - - /* #8: OCDFMT_xRGB15 - BITS=15 ALPHA=0 REVERSED=0 LEFT_JUSTIFIED=0 */ - BVFORMATRGBA(16, X1R5G5B5, ARGB, - BVRED(10, 5), BVGREEN(5, 5), BVBLUE(0, 5), BVALPHA(15, 0)), - - /* #9: OCDFMT_RGBx15 - BITS=15 ALPHA=0 REVERSED=0 LEFT_JUSTIFIED=1 */ - BVFORMATRGBA(16, X1R5G5B5, RGBA, - BVRED(11, 5), BVGREEN(6, 5), BVBLUE(1, 5), BVALPHA(0, 0)), - - /* #10: OCDFMT_xBGR15 - BITS=15 ALPHA=0 REVERSED=1 LEFT_JUSTIFIED=0 */ - BVFORMATRGBA(16, X1R5G5B5, ABGR, - BVRED(0, 5), BVGREEN(5, 5), BVBLUE(10, 5), BVALPHA(15, 0)), - - /* #11: OCDFMT_BGRx15 - BITS=15 ALPHA=0 REVERSED=1 LEFT_JUSTIFIED=1 */ - BVFORMATRGBA(16, X1R5G5B5, BGRA, - BVRED(1, 5), BVGREEN(6, 5), BVBLUE(11, 5), BVALPHA(0, 0)), - - /* #12: OCDFMT_ARGB15 - BITS=15 ALPHA=1 REVERSED=0 LEFT_JUSTIFIED=0 */ - BVFORMATRGBA(16, A1R5G5B5, ARGB, - BVRED(10, 5), BVGREEN(5, 5), BVBLUE(0, 5), BVALPHA(15, 1)), - - /* #13: OCDFMT_RGBA15 - BITS=15 ALPHA=1 REVERSED=0 LEFT_JUSTIFIED=1 */ - BVFORMATRGBA(16, A1R5G5B5, RGBA, - BVRED(11, 5), BVGREEN(6, 5), BVBLUE(1, 5), BVALPHA(0, 1)), - - /* #14: OCDFMT_ABGR15 - BITS=15 ALPHA=1 REVERSED=1 LEFT_JUSTIFIED=0 */ - BVFORMATRGBA(16, A1R5G5B5, ABGR, - BVRED(0, 5), BVGREEN(5, 5), BVBLUE(10, 5), BVALPHA(15, 1)), - - /* #15: OCDFMT_BGRA15 - BITS=15 ALPHA=1 REVERSED=1 LEFT_JUSTIFIED=1 */ - BVFORMATRGBA(16, A1R5G5B5, BGRA, - BVRED(1, 5), BVGREEN(6, 5), BVBLUE(11, 5), BVALPHA(0, 1)), - - /***********************************************/ - - /* #16: OCDFMT_RGB16 - BITS=16 ALPHA=0 REVERSED=0 LEFT_JUSTIFIED=0 */ - BVFORMATRGBA(16, R5G6B5, ARGB, - BVRED(11, 5), BVGREEN(5, 6), BVBLUE(0, 5), BVALPHA(0, 0)), - - /* #17: OCDFMT_RGB16 - BITS=16 ALPHA=0 REVERSED=0 LEFT_JUSTIFIED=1 */ - BVFORMATRGBA(16, R5G6B5, ARGB, - BVRED(11, 5), BVGREEN(5, 6), BVBLUE(0, 5), BVALPHA(0, 0)), - - /* #18: OCDFMT_BGR16 - BITS=16 ALPHA=0 REVERSED=1 LEFT_JUSTIFIED=0 */ - BVFORMATRGBA(16, R5G6B5, ABGR, - BVRED(0, 5), BVGREEN(5, 6), BVBLUE(11, 5), BVALPHA(0, 0)), - - /* #19: OCDFMT_BGR16 - BITS=16 ALPHA=0 REVERSED=1 LEFT_JUSTIFIED=1 */ - BVFORMATRGBA(16, R5G6B5, ABGR, - BVRED(0, 5), BVGREEN(5, 6), BVBLUE(11, 5), BVALPHA(0, 0)), - - /* #20 */ - BVFORMATINVALID, - - /* #21 */ - BVFORMATINVALID, - - /* #22 */ - BVFORMATINVALID, - - /* #23 */ - BVFORMATINVALID, - - /***********************************************/ - - /* #24: OCDFMT_xRGB24 - BITS=24 ALPHA=0 REVERSED=0 LEFT_JUSTIFIED=0 */ - BVFORMATRGBA(32, X8R8G8B8, BGRA, - BVRED(8, 8), BVGREEN(16, 8), BVBLUE(24, 8), BVALPHA(0, 0)), - - /* #25: OCDFMT_RGBx24 - BITS=24 ALPHA=0 REVERSED=0 LEFT_JUSTIFIED=1 */ - BVFORMATRGBA(32, X8R8G8B8, ABGR, - BVRED(0, 8), BVGREEN(8, 8), BVBLUE(16, 8), BVALPHA(24, 0)), - - /* #26: OCDFMT_xBGR24 - BITS=24 ALPHA=0 REVERSED=1 LEFT_JUSTIFIED=0 */ - BVFORMATRGBA(32, X8R8G8B8, RGBA, - BVRED(24, 8), BVGREEN(16, 8), BVBLUE(8, 8), BVALPHA(0, 0)), - - /* #27: OCDFMT_BGRx24 - BITS=24 ALPHA=0 REVERSED=1 LEFT_JUSTIFIED=1 */ - BVFORMATRGBA(32, X8R8G8B8, ARGB, - BVRED(16, 8), BVGREEN(8, 8), BVBLUE(0, 8), BVALPHA(24, 0)), - - /* #28: OCDFMT_ARGB24 - BITS=24 ALPHA=1 REVERSED=0 LEFT_JUSTIFIED=0 */ - BVFORMATRGBA(32, A8R8G8B8, BGRA, - BVRED(8, 8), BVGREEN(16, 8), BVBLUE(24, 8), BVALPHA(0, 8)), - - /* #29: OCDFMT_RGBA24 - BITS=24 ALPHA=1 REVERSED=0 LEFT_JUSTIFIED=1 */ - BVFORMATRGBA(32, A8R8G8B8, ABGR, - BVRED(0, 8), BVGREEN(8, 8), BVBLUE(16, 8), BVALPHA(24, 8)), - - /* #30: OCDFMT_ABGR24 - BITS=24 ALPHA=1 REVERSED=1 LEFT_JUSTIFIED=0 */ - BVFORMATRGBA(32, A8R8G8B8, RGBA, - BVRED(24, 8), BVGREEN(16, 8), BVBLUE(8, 8), BVALPHA(0, 8)), - - /* #31: OCDFMT_BGRA24 - BITS=24 ALPHA=1 REVERSED=1 LEFT_JUSTIFIED=1 */ - BVFORMATRGBA(32, A8R8G8B8, ARGB, - BVRED(16, 8), BVGREEN(8, 8), BVBLUE(0, 8), BVALPHA(24, 8)), +static const struct bvcsrgb argb4444_bits[] = { + { BVRED(8, 4), BVGREEN(4, 4), BVBLUE(0, 4), BVALPHA(12, 4) }, + { BVRED(12, 4), BVGREEN(8, 4), BVBLUE(4, 4), BVALPHA(0, 4) }, + { BVRED(0, 4), BVGREEN(4, 4), BVBLUE(8, 4), BVALPHA(12, 4) }, + { BVRED(4, 4), BVGREEN(8, 4), BVBLUE(12, 4), BVALPHA(0, 4) } }; -static enum bverror parse_format(struct bvbltparams *bvbltparams, - struct surfaceinfo *surfaceinfo) -{ - static unsigned int containers[] = { - 8, /* OCDFMTDEF_CONTAINER_8BIT */ - 16, /* OCDFMTDEF_CONTAINER_16BIT */ - 24, /* OCDFMTDEF_CONTAINER_24BIT */ - 32, /* OCDFMTDEF_CONTAINER_32BIT */ - ~0U, /* reserved */ - 48, /* OCDFMTDEF_CONTAINER_48BIT */ - ~0U, /* reserved */ - 64 /* OCDFMTDEF_CONTAINER_64BIT */ - }; +static const struct bvcsrgb xrgb1555_bits[] = { + { BVRED(10, 5), BVGREEN(5, 5), BVBLUE(0, 5), BVALPHA(15, 0) }, + { BVRED(11, 5), BVGREEN(6, 5), BVBLUE(1, 5), BVALPHA(0, 0) }, + { BVRED(0, 5), BVGREEN(5, 5), BVBLUE(10, 5), BVALPHA(15, 0) }, + { BVRED(1, 5), BVGREEN(6, 5), BVBLUE(11, 5), BVALPHA(0, 0) } +}; + +static const struct bvcsrgb argb1555_bits[] = { + { BVRED(10, 5), BVGREEN(5, 5), BVBLUE(0, 5), BVALPHA(15, 1) }, + { BVRED(11, 5), BVGREEN(6, 5), BVBLUE(1, 5), BVALPHA(0, 1) }, + { BVRED(0, 5), BVGREEN(5, 5), BVBLUE(10, 5), BVALPHA(15, 1) }, + { BVRED(1, 5), BVGREEN(6, 5), BVBLUE(11, 5), BVALPHA(0, 1) } +}; + +static const struct bvcsrgb rgb565_bits[] = { + { BVRED(11, 5), BVGREEN(5, 6), BVBLUE(0, 5), BVALPHA(0, 0) }, + { BVRED(11, 5), BVGREEN(5, 6), BVBLUE(0, 5), BVALPHA(0, 0) }, + { BVRED(0, 5), BVGREEN(5, 6), BVBLUE(11, 5), BVALPHA(0, 0) }, + { BVRED(0, 5), BVGREEN(5, 6), BVBLUE(11, 5), BVALPHA(0, 0) } +}; + +static const struct bvcsrgb xrgb8888_bits[] = { + { BVRED(8, 8), BVGREEN(16, 8), BVBLUE(24, 8), BVALPHA(0, 0) }, + { BVRED(0, 8), BVGREEN(8, 8), BVBLUE(16, 8), BVALPHA(24, 0) }, + { BVRED(24, 8), BVGREEN(16, 8), BVBLUE(8, 8), BVALPHA(0, 0) }, + { BVRED(16, 8), BVGREEN(8, 8), BVBLUE(0, 8), BVALPHA(24, 0) } +}; + +static const struct bvcsrgb argb8888_bits[] = { + { BVRED(8, 8), BVGREEN(16, 8), BVBLUE(24, 8), BVALPHA(0, 8) }, + { BVRED(0, 8), BVGREEN(8, 8), BVBLUE(16, 8), BVALPHA(24, 8) }, + { BVRED(24, 8), BVGREEN(16, 8), BVBLUE(8, 8), BVALPHA(0, 8) }, + { BVRED(16, 8), BVGREEN(8, 8), BVBLUE(0, 8), BVALPHA(24, 8) } +}; +static const unsigned int container[] = { + 8, /* OCDFMTDEF_CONTAINER_8BIT */ + 16, /* OCDFMTDEF_CONTAINER_16BIT */ + 24, /* OCDFMTDEF_CONTAINER_24BIT */ + 32, /* OCDFMTDEF_CONTAINER_32BIT */ + ~0U, /* reserved */ + 48, /* OCDFMTDEF_CONTAINER_48BIT */ + ~0U, /* reserved */ + 64 /* OCDFMTDEF_CONTAINER_64BIT */ +}; + +enum bverror parse_format(struct bvbltparams *bvbltparams, + struct surfaceinfo *surfaceinfo) +{ enum bverror bverror = BVERR_NONE; + struct bvformatxlate *format; enum ocdformat ocdformat; - unsigned int cs; - unsigned int bits; - unsigned int swizzle; - unsigned int alpha; - unsigned int index; - unsigned int cont; + unsigned int cs, std, alpha, subsample, layout; + unsigned int reversed, leftjust, swizzle, cont, bits; + format = &surfaceinfo->format; ocdformat = surfaceinfo->geom->format; GCENTERARG(GCZONE_FORMAT, "ocdformat = 0x%08X\n", ocdformat); - cs = (ocdformat & OCDFMTDEF_CS_MASK) >> OCDFMTDEF_CS_SHIFT; - bits = (ocdformat & OCDFMTDEF_COMPONENTSIZEMINUS1_MASK) - >> OCDFMTDEF_COMPONENTSIZEMINUS1_SHIFT; + cs = (ocdformat & OCDFMTDEF_CS_MASK) + >> OCDFMTDEF_CS_SHIFT; + std = (ocdformat & OCDFMTDEF_STD_MASK) + >> OCDFMTDEF_STD_SHIFT; + alpha = ocdformat & OCDFMTDEF_ALPHA; + subsample = (ocdformat & OCDFMTDEF_SUBSAMPLE_MASK) + >> OCDFMTDEF_SUBSAMPLE_SHIFT; + layout = (ocdformat & OCDFMTDEF_LAYOUT_MASK) + >> OCDFMTDEF_LAYOUT_SHIFT; cont = (ocdformat & OCDFMTDEF_CONTAINER_MASK) >> OCDFMTDEF_CONTAINER_SHIFT; + bits = ((ocdformat & OCDFMTDEF_COMPONENTSIZEMINUS1_MASK) + >> OCDFMTDEF_COMPONENTSIZEMINUS1_SHIFT) + 1; + + GCDBG(GCZONE_FORMAT, "std = %d\n", std); GCDBG(GCZONE_FORMAT, "cs = %d\n", cs); - GCDBG(GCZONE_FORMAT, "bits = %d\n", bits); + GCDBG(GCZONE_FORMAT, "alpha = %d\n", alpha ? 1 : 0); + GCDBG(GCZONE_FORMAT, "subsample = %d\n", subsample); + GCDBG(GCZONE_FORMAT, "layout = %d\n", layout); GCDBG(GCZONE_FORMAT, "cont = %d\n", cont); + GCDBG(GCZONE_FORMAT, "bits = %d\n", bits); switch (cs) { case (OCDFMTDEF_CS_RGB >> OCDFMTDEF_CS_SHIFT): GCDBG(GCZONE_FORMAT, "OCDFMTDEF_CS_RGB\n"); - if ((ocdformat & OCDFMTDEF_LAYOUT_MASK) != OCDFMTDEF_PACKED) { + /* Determine the swizzle. */ + swizzle = (ocdformat & OCDFMTDEF_PLACEMENT_MASK) + >> OCDFMTDEF_PLACEMENT_SHIFT; + GCDBG(GCZONE_FORMAT, "swizzle = %d\n", swizzle); + + /* RGB color space. */ + format->type = BVFMT_RGB; + + /* Has to be 0 for RGB. */ + if (std != 0) { BVSETBLTERROR(BVERR_UNK, - "only packed RGBA formats are supported"); + "unsupported standard"); goto exit; } - swizzle = (ocdformat & OCDFMTDEF_PLACEMENT_MASK) - >> OCDFMTDEF_PLACEMENT_SHIFT; - alpha = (ocdformat & OCDFMTDEF_ALPHA_MASK) - >> OCDFMTDEF_ALPHA_SHIFT; + /* Determine premultuplied or not. */ + if (alpha == OCDFMTDEF_ALPHA) { + format->premultiplied + = ((ocdformat & OCDFMTDEF_NON_PREMULT) == 0); + } else { + format->premultiplied = true; - GCDBG(GCZONE_FORMAT, "swizzle = %d\n", swizzle); - GCDBG(GCZONE_FORMAT, "alpha = %d\n", alpha); + if ((ocdformat & OCDFMTDEF_FILL_EMPTY_0) != 0) { + BVSETBLTERROR(BVERR_UNK, + "0 filling is not supported"); + goto exit; + } + } + GCDBG(GCZONE_FORMAT, "premultiplied = %d\n", + format->premultiplied); + + /* No subsample support. */ + if (subsample != + (OCDFMTDEF_SUBSAMPLE_NONE >> OCDFMTDEF_SUBSAMPLE_SHIFT)) { + BVSETBLTERROR(BVERR_UNK, + "subsampling for RGB is not supported"); + goto exit; + } - index = swizzle | (alpha << 2); + /* Only packed RGB is supported. */ + if (layout != + (OCDFMTDEF_PACKED >> OCDFMTDEF_LAYOUT_SHIFT)) { + BVSETBLTERROR(BVERR_UNK, + "only packed RGBA formats are supported"); + goto exit; + } + /* Determine the format. */ switch (bits) { - case 12 - 1: - index |= OCDFMTDEF_BITS12; + case 12: + format->bitspp = 16; + format->allocbitspp = 16; + format->swizzle = rgba16swizzle[swizzle]; + + if (alpha == OCDFMTDEF_ALPHA) { + format->format = GCREG_DE_FORMAT_A4R4G4B4; + format->cs.rgb.comp = &argb4444_bits[swizzle]; + } else { + format->format = GCREG_DE_FORMAT_X4R4G4B4; + format->cs.rgb.comp = &xrgb4444_bits[swizzle]; + } break; - case 15 - 1: - index |= OCDFMTDEF_BITS15; + case 15: + format->bitspp = 16; + format->allocbitspp = 16; + format->swizzle = rgba16swizzle[swizzle]; + + if (alpha == OCDFMTDEF_ALPHA) { + format->format = GCREG_DE_FORMAT_A1R5G5B5; + format->cs.rgb.comp = &argb1555_bits[swizzle]; + } else { + format->format = GCREG_DE_FORMAT_X1R5G5B5; + format->cs.rgb.comp = &xrgb1555_bits[swizzle]; + } break; - case 16 - 1: - index |= OCDFMTDEF_BITS16; + case 16: + if (alpha == OCDFMTDEF_ALPHA) { + BVSETBLTERROR(BVERR_UNK, + "alpha component is not supported" + "for this format."); + goto exit; + } + + format->bitspp = 16; + format->allocbitspp = 16; + format->swizzle = rgb16swizzle[swizzle]; + format->format = GCREG_DE_FORMAT_R5G6B5; + format->cs.rgb.comp = &rgb565_bits[swizzle]; break; - case 24 - 1: - index |= OCDFMTDEF_BITS24; + case 24: + format->bitspp = 32; + format->allocbitspp = 32; + format->swizzle = rgba32swizzle[swizzle]; + + if (alpha == OCDFMTDEF_ALPHA) { + format->format = GCREG_DE_FORMAT_A8R8G8B8; + format->cs.rgb.comp = &argb8888_bits[swizzle]; + } else { + format->format = GCREG_DE_FORMAT_X8R8G8B8; + format->cs.rgb.comp = &xrgb8888_bits[swizzle]; + } break; default: @@ -401,54 +341,159 @@ static enum bverror parse_format(struct bvbltparams *bvbltparams, goto exit; } - GCDBG(GCZONE_FORMAT, "index = %d\n", index); + if (format->allocbitspp != container[cont]) { + BVSETBLTERROR(BVERR_UNK, + "unsupported container"); + goto exit; + } break; case (OCDFMTDEF_CS_YCbCr >> OCDFMTDEF_CS_SHIFT): GCDBG(GCZONE_FORMAT, "OCDFMTDEF_CS_YCbCr\n"); - /* FIXME/TODO: add proper YUV parsing. */ - switch (ocdformat) { - case OCDFMT_NV12: - GCDBG(GCZONE_FORMAT, "OCDFMT_NV12\n"); - surfaceinfo->format = &g_format_nv12; - goto exit; + /* YUV color space. */ + format->type = BVFMT_YUV; + + /* Determine the swizzle. */ + reversed = ocdformat & OCDFMTDEF_REVERSED; + leftjust = ocdformat & OCDFMTDEF_LEFT_JUSTIFIED; + GCDBG(GCZONE_FORMAT, "reversed = %d\n", reversed ? 1 : 0); + GCDBG(GCZONE_FORMAT, "leftjust = %d\n", leftjust ? 1 : 0); + + /* Parse the standard. */ + switch (std) { + case OCDFMTDEF_STD_ITUR_601_YCbCr >> OCDFMTDEF_STD_SHIFT: + format->cs.yuv.std = GCREG_PE_CONTROL_YUV_601; + break; - case OCDFMT_UYVY: - GCDBG(GCZONE_FORMAT, "OCDFMT_UYVY\n"); - surfaceinfo->format = &g_format_uyvy; + case OCDFMTDEF_STD_ITUR_709_YCbCr >> OCDFMTDEF_STD_SHIFT: + format->cs.yuv.std = GCREG_PE_CONTROL_YUV_709; + break; + + default: + BVSETBLTERROR(BVERR_UNK, + "unsupported color standard"); goto exit; + } - case OCDFMT_YUY2: - GCDBG(GCZONE_FORMAT, "OCDFMT_YUY2\n"); - surfaceinfo->format = &g_format_yuy2; + /* Alpha is not supported. */ + if (alpha == OCDFMTDEF_ALPHA) { + BVSETBLTERROR(BVERR_UNK, + "alpha channel is not supported"); goto exit; + } + + format->premultiplied = true; + + /* Parse subsampling. */ + switch (subsample) { + case OCDFMTDEF_SUBSAMPLE_422_YCbCr >> OCDFMTDEF_SUBSAMPLE_SHIFT: + GCDBG(GCZONE_FORMAT, "OCDFMTDEF_SUBSAMPLE_422_YCbCr\n"); + + /* Parse layout. */ + switch (layout) { + case OCDFMTDEF_PACKED >> OCDFMTDEF_LAYOUT_SHIFT: + GCDBG(GCZONE_FORMAT, "OCDFMTDEF_PACKED\n"); + + if (container[cont] != 32) { + BVSETBLTERROR(BVERR_UNK, + "unsupported container"); + goto exit; + } + + format->bitspp = 16; + format->allocbitspp = 16; + format->format = leftjust + ? GCREG_DE_FORMAT_YUY2 + : GCREG_DE_FORMAT_UYVY; + format->swizzle = reversed + ? GCREG_PE_CONTROL_UV_SWIZZLE_VU + : GCREG_PE_CONTROL_UV_SWIZZLE_UV; + format->cs.yuv.planecount = 1; + break; + + default: + BVSETBLTERROR(BVERR_UNK, + "specified 4:2:2 layout " + "is not supported"); + goto exit; + } + break; + + case OCDFMTDEF_SUBSAMPLE_420_YCbCr >> OCDFMTDEF_SUBSAMPLE_SHIFT: + + /* Parse layout. */ + switch (layout) { + case OCDFMTDEF_2_PLANE_YCbCr + >> OCDFMTDEF_LAYOUT_SHIFT: + GCDBG(GCZONE_FORMAT, + "OCDFMTDEF_2_PLANE_YCbCr\n"); + + if (container[cont] != 48) { + BVSETBLTERROR(BVERR_UNK, + "unsupported container"); + goto exit; + } + + format->bitspp = 8; + format->allocbitspp = 12; + format->format = GCREG_DE_FORMAT_NV12; + format->swizzle = reversed + ? GCREG_PE_CONTROL_UV_SWIZZLE_VU + : GCREG_PE_CONTROL_UV_SWIZZLE_UV; + format->cs.yuv.planecount = 2; + break; + + case OCDFMTDEF_3_PLANE_STACKED + >> OCDFMTDEF_LAYOUT_SHIFT: + GCDBG(GCZONE_FORMAT, + "OCDFMTDEF_3_PLANE_STACKED\n"); + + if (container[cont] != 48) { + BVSETBLTERROR(BVERR_UNK, + "unsupported container"); + goto exit; + } + + format->bitspp = 8; + format->allocbitspp = 12; + format->format = GCREG_DE_FORMAT_YV12; + format->swizzle = reversed + ? GCREG_PE_CONTROL_UV_SWIZZLE_VU + : GCREG_PE_CONTROL_UV_SWIZZLE_UV; + format->cs.yuv.planecount = 3; + break; + + default: + BVSETBLTERROR(BVERR_UNK, + "specified 4:2:2 layout " + "is not supported"); + goto exit; + } + break; default: BVSETBLTERROR(BVERR_UNK, - "unsupported YUV format %d", ocdformat); + "specified subsampling is not supported"); goto exit; } + if (format->allocbitspp != bits) { + BVSETBLTERROR(BVERR_UNK, + "unsupported bit width %d", bits); + goto exit; + } + break; + default: BVSETBLTERROR(BVERR_UNK, "unsupported color space %d", cs); goto exit; } - if (formatxlate[index].bitspp != containers[cont]) { - BVSETBLTERROR(BVERR_UNK, - "unsupported bit width %d", bits); - goto exit; - } - - surfaceinfo->format = &formatxlate[index]; - - GCDBG(GCZONE_FORMAT, "format record = 0x%08X\n", - (unsigned int) &formatxlate[index]); - GCDBG(GCZONE_FORMAT, " bpp = %d\n", formatxlate[index].bitspp); - GCDBG(GCZONE_FORMAT, " format = %d\n", formatxlate[index].format); - GCDBG(GCZONE_FORMAT, " swizzle = %d\n", formatxlate[index].swizzle); + GCDBG(GCZONE_FORMAT, "bpp = %d\n", format->bitspp); + GCDBG(GCZONE_FORMAT, "gcformat = %d\n", format->format); + GCDBG(GCZONE_FORMAT, "gcswizzle = %d\n", format->swizzle); bverror = BVERR_NONE; @@ -1218,7 +1263,7 @@ static bool valid_geom(struct surfaceinfo *surfaceinfo) /* Compute the size of the surface. */ size = (surfaceinfo->geom->width * surfaceinfo->geom->height * - surfaceinfo->format->bitspp) / 8; + surfaceinfo->format.bitspp) / 8; /* Make sure the size is not greater then the surface. */ if (size > surfaceinfo->buf.desc->length) { @@ -1226,7 +1271,7 @@ static bool valid_geom(struct surfaceinfo *surfaceinfo) GCERR(" specified dimensions: %dx%d, %d bitspp\n", surfaceinfo->geom->width, surfaceinfo->geom->height, - surfaceinfo->format->bitspp); + surfaceinfo->format.bitspp); GCERR(" surface size based on the dimensions: %d\n", size); GCERR(" specified surface size: %lu\n", @@ -1247,11 +1292,11 @@ int get_pixel_offset(struct surfaceinfo *surfaceinfo, int offset) GCENTERARG(GCZONE_OFFSET, "surfaceinfo=0x%08X, offset=%d\n", surfaceinfo, offset); - alignment = ((surfaceinfo->format->type & BVFMT_MASK) == BVFMT_YUV) + alignment = (surfaceinfo->format.type == BVFMT_YUV) ? (64 - 1) : (16 - 1); - GCDBG(GCZONE_OFFSET, "bpp = %d\n", surfaceinfo->format->bitspp); + GCDBG(GCZONE_OFFSET, "bpp = %d\n", surfaceinfo->format.bitspp); GCDBG(GCZONE_OFFSET, "alignment = %d\n", alignment); /* Determine offset in bytes from the base modified by the @@ -1277,7 +1322,7 @@ int get_pixel_offset(struct surfaceinfo *surfaceinfo, int offset) alignedoffset = byteoffset & alignment; /* Convert to pixels. */ - pixeloffset = alignedoffset * 8 / surfaceinfo->format->bitspp; + pixeloffset = alignedoffset * 8 / surfaceinfo->format.bitspp; GCDBG(GCZONE_OFFSET, "alignedoffset = %d\n", alignedoffset); GCDBG(GCZONE_OFFSET, "pixeloffset = %d\n", pixeloffset); @@ -1296,7 +1341,6 @@ enum bverror parse_destination(struct bvbltparams *bvbltparams, /* Did the destination surface change? */ if ((batch->batchflags & BVBATCH_DST) != 0) { struct surfaceinfo *dstinfo; - unsigned int stridealign; /* Initialize the destination descriptor. */ dstinfo = &batch->dstinfo; @@ -1335,8 +1379,8 @@ enum bverror parse_destination(struct bvbltparams *bvbltparams, } /* Destination stride must be 8 pixel aligned. */ - stridealign = dstinfo->format->bitspp - 1; - if ((dstinfo->geom->virtstride & stridealign) != 0) { + if ((dstinfo->geom->virtstride + & (dstinfo->format.bitspp - 1)) != 0) { BVSETBLTERROR(BVERR_DSTGEOM_STRIDE, "destination stride must be 8 pixel " "aligned."); @@ -1355,7 +1399,7 @@ enum bverror parse_destination(struct bvbltparams *bvbltparams, * for the surface base address misalignment if any. */ dstinfo->pixalign = get_pixel_offset(dstinfo, 0); dstinfo->bytealign = (dstinfo->pixalign - * (int) dstinfo->format->bitspp) / 8; + * (int) dstinfo->format.bitspp) / 8; switch (dstinfo->angle) { case ROT_ANGLE_0: @@ -1467,14 +1511,6 @@ enum bverror parse_destination(struct bvbltparams *bvbltparams, /* Determine destination rectangle. */ dstrect = &dstinfo->rect; - - GCDBG(GCZONE_DEST, - "destination = (%d,%d) %dx%d\n", - bvbltparams->dstrect.left, - bvbltparams->dstrect.top, - bvbltparams->dstrect.width, - bvbltparams->dstrect.height); - GCCONVERT_RECT(GCZONE_DEST, "destination", &bvbltparams->dstrect, @@ -1485,23 +1521,16 @@ enum bverror parse_destination(struct bvbltparams *bvbltparams, /* Is clipping rectangle specified? */ if ((bvbltparams->flags & BVFLAG_CLIP) == BVFLAG_CLIP) { - /* Convert and validate clipping rectangle. */ - GCDBG(GCZONE_DEST, - "clip = (%d,%d) %dx%d\n", - bvbltparams->cliprect.left, - bvbltparams->cliprect.top, - bvbltparams->cliprect.width, - bvbltparams->cliprect.height); - + /* Convert the clipping rectangle. */ GCCONVERT_RECT(GCZONE_DEST, "clipping", &bvbltparams->cliprect, &cliprect); - if (cliprect.left < GC_CLIP_RESET_LEFT || - cliprect.top < GC_CLIP_RESET_TOP || - cliprect.right > GC_CLIP_RESET_RIGHT || - cliprect.bottom > GC_CLIP_RESET_BOTTOM) { + if ((cliprect.left < GC_CLIP_RESET_LEFT) || + (cliprect.top < GC_CLIP_RESET_TOP) || + (cliprect.right > GC_CLIP_RESET_RIGHT) || + (cliprect.bottom > GC_CLIP_RESET_BOTTOM)) { BVSETERROR(BVERR_CLIP_RECT, "clip rect is invalid"); goto exit; @@ -1588,16 +1617,8 @@ enum bverror parse_destination(struct bvbltparams *bvbltparams, &batch->dstclippedaux); } - GCDBG(GCZONE_DEST, - "clipped dest = (%d,%d)-(%d,%d), %dx%d\n", - batch->dstclipped.left, - batch->dstclipped.top, - batch->dstclipped.right, - batch->dstclipped.bottom, - batch->dstclipped.right - - batch->dstclipped.left, - batch->dstclipped.bottom - - batch->dstclipped.top); + GCPRINT_RECT(GCZONE_DEST, "clipped dest", + &batch->dstclipped); /* Check for valid dest rect after clipping. */ if (batch->dstclipped.left < 0 || @@ -1610,16 +1631,8 @@ enum bverror parse_destination(struct bvbltparams *bvbltparams, } if (haveaux) - GCDBG(GCZONE_DEST, - "clipped aux dest = (%d,%d)-(%d,%d), %dx%d\n", - batch->dstclippedaux.left, - batch->dstclippedaux.top, - batch->dstclippedaux.right, - batch->dstclippedaux.bottom, - batch->dstclippedaux.right - - batch->dstclippedaux.left, - batch->dstclippedaux.bottom - - batch->dstclippedaux.top); + GCPRINT_RECT(GCZONE_DEST, "clipped aux dest", + &batch->dstclippedaux); GCDBG(GCZONE_DEST, "clipping delta = (%d,%d)-(%d,%d)\n", @@ -1641,7 +1654,6 @@ enum bverror parse_source(struct bvbltparams *bvbltparams, struct surfaceinfo *srcinfo) { enum bverror bverror = BVERR_NONE; - unsigned int stridealign; /* Convert the rectangle. */ GCCONVERT_RECT(GCZONE_SRC, @@ -1668,8 +1680,8 @@ enum bverror parse_source(struct bvbltparams *bvbltparams, } /* Source must be 8 pixel aligned. */ - stridealign = srcinfo->format->bitspp - 1; - if ((srcinfo->geom->virtstride & stridealign) != 0) { + if ((srcinfo->geom->virtstride + & (srcinfo->format.bitspp - 1)) != 0) { BVSETBLTERROR((srcinfo->index == 0) ? BVERR_SRC1GEOM_STRIDE : BVERR_SRC2GEOM_STRIDE, |