summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCraig Stout <craig.stout@ti.com>2012-09-24 17:16:38 -0700
committerCraig Stout <craig.stout@ti.com>2012-09-24 20:27:24 -0700
commitfdd2bb1b9935d66e32bafc10f5c7c28b2226acb9 (patch)
tree9601b89be4708587c61e86e84ff05b78f194a832
parentb984e557e8fd8af253a1ebf4b44fc1e7d09e8de8 (diff)
downloadhardware_ti_omap4-fdd2bb1b9935d66e32bafc10f5c7c28b2226acb9.zip
hardware_ti_omap4-fdd2bb1b9935d66e32bafc10f5c7c28b2226acb9.tar.gz
hardware_ti_omap4-fdd2bb1b9935d66e32bafc10f5c7c28b2226acb9.tar.bz2
gcbv-user: added generic format parser.
RGB and YUV formats are now generically supported. Change-Id: I8bb3e2060fa1d0912b53671f60dff1269ce6bf96 Signed-off-by: Alexei Shlychkov <x0177296@ti.com>
-rw-r--r--gcbv/mirror/gcblit.c42
-rw-r--r--gcbv/mirror/gcbv.h37
-rw-r--r--gcbv/mirror/gcfill.c18
-rw-r--r--gcbv/mirror/gcfilter.c81
-rw-r--r--gcbv/mirror/gcparser.c666
5 files changed, 464 insertions, 380 deletions
diff --git a/gcbv/mirror/gcblit.c b/gcbv/mirror/gcblit.c
index 3145080..78dedac 100644
--- a/gcbv/mirror/gcblit.c
+++ b/gcbv/mirror/gcblit.c
@@ -94,17 +94,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;
@@ -242,7 +240,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. */
@@ -257,7 +255,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",
@@ -272,7 +270,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. */
@@ -286,7 +284,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
@@ -294,7 +292,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",
@@ -527,8 +525,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;
@@ -559,25 +557,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) {
@@ -636,7 +634,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/gcbv/mirror/gcbv.h b/gcbv/mirror/gcbv.h
index 403080a..bc8ed87 100644
--- a/gcbv/mirror/gcbv.h
+++ b/gcbv/mirror/gcbv.h
@@ -91,6 +91,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.
@@ -195,13 +205,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;
@@ -219,9 +224,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;
};
@@ -298,7 +315,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;
@@ -438,6 +455,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/gcbv/mirror/gcfill.c b/gcbv/mirror/gcfill.c
index 06ff240..86d023d 100644
--- a/gcbv/mirror/gcfill.c
+++ b/gcbv/mirror/gcfill.c
@@ -43,7 +43,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;
@@ -107,10 +107,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);
@@ -211,11 +211,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.
@@ -224,8 +224,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/gcbv/mirror/gcfilter.c b/gcbv/mirror/gcfilter.c
index 424bdcb..700ed41 100644
--- a/gcbv/mirror/gcfilter.c
+++ b/gcbv/mirror/gcfilter.c
@@ -625,8 +625,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;
@@ -648,7 +648,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:
@@ -708,11 +708,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;
@@ -776,6 +777,47 @@ static enum bverror startvr(struct bvbltparams *bvbltparams,
= GCREG_COLOR_MULTIPLY_MODES_DST_DEMULTIPLY_DISABLE;
}
+ if (srcinfo->format.format == GCREG_DE_FORMAT_NV12) {
+ struct gcmoxsrcyuv *gcmoxsrcyuv;
+ int index = 0;
+ int uvshift;
+
+ uvshift = srcbytealign
+ + srcinfo->geom->virtstride
+ * srcinfo->geom->height;
+ GCDBG(GCZONE_FILTER, " uvshift = 0x%08X (%d)\n",
+ uvshift, uvshift);
+
+ bverror = claim_buffer(bvbltparams, batch,
+ sizeof(struct gcmoxsrcyuv),
+ (void **) &gcmoxsrcyuv);
+ if (bverror != BVERR_NONE)
+ goto exit;
+
+ gcmoxsrcyuv->uplaneaddress_ldst =
+ gcmoxsrcyuv_uplaneaddress_ldst[index];
+ gcmoxsrcyuv->uplaneaddress = GET_MAP_HANDLE(srcmap);
+ add_fixup(bvbltparams, batch, &gcmoxsrcyuv->uplaneaddress,
+ uvshift);
+
+ gcmoxsrcyuv->uplanestride_ldst =
+ gcmoxsrcyuv_uplanestride_ldst[index];
+ gcmoxsrcyuv->uplanestride = srcinfo->geom->virtstride;
+
+ gcmoxsrcyuv->vplaneaddress_ldst =
+ gcmoxsrcyuv_vplaneaddress_ldst[index];
+ gcmoxsrcyuv->vplaneaddress = GET_MAP_HANDLE(srcmap);
+ add_fixup(bvbltparams, batch, &gcmoxsrcyuv->vplaneaddress,
+ uvshift);
+
+ gcmoxsrcyuv->vplanestride_ldst =
+ gcmoxsrcyuv_vplanestride_ldst[index];
+ gcmoxsrcyuv->vplanestride = srcinfo->geom->virtstride;
+
+ gcmoxsrcyuv->pectrl_ldst =
+ gcmoxsrcyuv_pectrl_ldst[index];
+ gcmoxsrcyuv->pectrl = GCREG_PE_CONTROL_ResetValue;
+ }
/***********************************************************************
* Program blending.
@@ -910,10 +952,23 @@ enum bverror do_filter(struct bvbltparams *bvbltparams,
GCENTER(GCZONE_FILTER);
- /* Finish previous batch if any. */
- bverror = batch->batchend(bvbltparams, batch);
- if (bverror != BVERR_NONE)
- goto exit;
+ /* Additional stride requirements. */
+ 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.
+ */
+ int min_stride = srcinfo->geom->width + 32;
+
+ if (srcinfo->geom->virtstride < min_stride) {
+ BVSETBLTERROR((srcinfo->index == 0)
+ ? BVERR_SRC1GEOM_STRIDE
+ : BVERR_SRC2GEOM_STRIDE,
+ "nv12 source stride too small (%ld < %d)\n",
+ srcinfo->geom->virtstride,
+ min_stride);
+ goto exit;
+ }
+ }
/* Determine the destination rectangle. */
if ((srcinfo->index == 1) &&
@@ -1079,7 +1134,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 {
@@ -1089,7 +1144,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
@@ -1126,7 +1181,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/gcbv/mirror/gcparser.c b/gcbv/mirror/gcparser.c
index d41223d..6d74304 100644
--- a/gcbv/mirror/gcparser.c
+++ b/gcbv/mirror/gcparser.c
@@ -61,12 +61,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); \
}
@@ -74,39 +69,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 }
@@ -122,255 +87,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:
@@ -379,54 +319,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;
@@ -1196,7 +1241,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) {
@@ -1204,7 +1249,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",
@@ -1225,11 +1270,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
@@ -1255,7 +1300,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);
@@ -1274,7 +1319,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;
@@ -1313,8 +1357,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.");
@@ -1333,7 +1377,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:
@@ -1445,14 +1489,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,
@@ -1463,23 +1499,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;
@@ -1566,16 +1595,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 ||
@@ -1588,16 +1609,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",
@@ -1619,7 +1632,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,
@@ -1646,8 +1658,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,