case V4L2_PIX_FMT_GREY:
case V4L2_PIX_FMT_Y16:
case V4L2_PIX_FMT_Y16_BE:
- tpg->is_yuv = false;
+ tpg->color_enc = TGP_COLOR_ENC_RGB;
break;
case V4L2_PIX_FMT_YUV444:
case V4L2_PIX_FMT_YUV555:
case V4L2_PIX_FMT_YUV565:
case V4L2_PIX_FMT_YUV32:
- tpg->is_yuv = true;
+ tpg->color_enc = TGP_COLOR_ENC_YCBCR;
break;
case V4L2_PIX_FMT_YUV420M:
case V4L2_PIX_FMT_YVU420M:
tpg->hdownsampling[1] = 2;
tpg->hdownsampling[2] = 2;
tpg->planes = 3;
- tpg->is_yuv = true;
+ tpg->color_enc = TGP_COLOR_ENC_YCBCR;
break;
case V4L2_PIX_FMT_YUV422M:
case V4L2_PIX_FMT_YVU422M:
tpg->hdownsampling[1] = 2;
tpg->hdownsampling[2] = 2;
tpg->planes = 3;
- tpg->is_yuv = true;
+ tpg->color_enc = TGP_COLOR_ENC_YCBCR;
break;
case V4L2_PIX_FMT_NV16M:
case V4L2_PIX_FMT_NV61M:
tpg->hdownsampling[1] = 1;
tpg->hmask[1] = ~1;
tpg->planes = 2;
- tpg->is_yuv = true;
+ tpg->color_enc = TGP_COLOR_ENC_YCBCR;
break;
case V4L2_PIX_FMT_NV12M:
case V4L2_PIX_FMT_NV21M:
tpg->hdownsampling[1] = 1;
tpg->hmask[1] = ~1;
tpg->planes = 2;
- tpg->is_yuv = true;
+ tpg->color_enc = TGP_COLOR_ENC_YCBCR;
break;
case V4L2_PIX_FMT_YUV444M:
case V4L2_PIX_FMT_YVU444M:
tpg->vdownsampling[2] = 1;
tpg->hdownsampling[1] = 1;
tpg->hdownsampling[2] = 1;
- tpg->is_yuv = true;
+ tpg->color_enc = TGP_COLOR_ENC_YCBCR;
break;
case V4L2_PIX_FMT_NV24:
case V4L2_PIX_FMT_NV42:
tpg->vdownsampling[1] = 1;
tpg->hdownsampling[1] = 1;
tpg->planes = 2;
- tpg->is_yuv = true;
+ tpg->color_enc = TGP_COLOR_ENC_YCBCR;
break;
case V4L2_PIX_FMT_YUYV:
case V4L2_PIX_FMT_UYVY:
case V4L2_PIX_FMT_YVYU:
case V4L2_PIX_FMT_VYUY:
tpg->hmask[0] = ~1;
- tpg->is_yuv = true;
+ tpg->color_enc = TGP_COLOR_ENC_YCBCR;
break;
default:
return false;
* Remember that r, g and b are still in the 0 - 0xff0 range.
*/
if (tpg->real_rgb_range == V4L2_DV_RGB_RANGE_LIMITED &&
- tpg->rgb_range == V4L2_DV_RGB_RANGE_FULL && !tpg->is_yuv) {
+ tpg->rgb_range == V4L2_DV_RGB_RANGE_FULL &&
+ tpg->color_enc == TGP_COLOR_ENC_RGB) {
/*
* Convert from full range (which is what r, g and b are)
* to limited range (which is the 'real' RGB range), which
g = (g * 219) / 255 + (16 << 4);
b = (b * 219) / 255 + (16 << 4);
} else if (tpg->real_rgb_range != V4L2_DV_RGB_RANGE_LIMITED &&
- tpg->rgb_range == V4L2_DV_RGB_RANGE_LIMITED && !tpg->is_yuv) {
+ tpg->rgb_range == V4L2_DV_RGB_RANGE_LIMITED &&
+ tpg->color_enc == TGP_COLOR_ENC_RGB) {
+
/*
* Clamp r, g and b to the limited range and convert to full
* range since that's what we deliver.
cb = (128 << 4) + (tmp_cb * tpg->contrast * tpg->saturation) / (128 * 128);
cr = (128 << 4) + (tmp_cr * tpg->contrast * tpg->saturation) / (128 * 128);
- if (tpg->is_yuv) {
+ if (tpg->color_enc == TGP_COLOR_ENC_YCBCR) {
tpg->colors[k][0] = clamp(y >> 4, 1, 254);
tpg->colors[k][1] = clamp(cb >> 4, 1, 254);
tpg->colors[k][2] = clamp(cr >> 4, 1, 254);
ycbcr_to_color(tpg, y, cb, cr, &r, &g, &b);
}
- if (tpg->is_yuv) {
+ if (tpg->color_enc == TGP_COLOR_ENC_YCBCR) {
/* Convert to YCbCr */
int y, cb, cr;
if (tpg->quantization == V4L2_QUANTIZATION_DEFAULT)
tpg->real_quantization =
- V4L2_MAP_QUANTIZATION_DEFAULT(!tpg->is_yuv,
+ V4L2_MAP_QUANTIZATION_DEFAULT(
+ tpg->color_enc != TGP_COLOR_ENC_YCBCR,
tpg->colorspace, tpg->real_ycbcr_enc);
tpg_precalculate_colors(tpg);
return -1;
}
+static const char *tpg_color_enc_str(enum tgp_color_enc
+ color_enc)
+{
+ switch (color_enc) {
+ case TGP_COLOR_ENC_YCBCR:
+ return "Y'CbCr";
+ case TGP_COLOR_ENC_RGB:
+ default:
+ return "R'G'B";
+
+ }
+}
+
void tpg_log_status(struct tpg_data *tpg)
{
pr_info("tpg source WxH: %ux%u (%s)\n",
- tpg->src_width, tpg->src_height,
- tpg->is_yuv ? "YCbCr" : "RGB");
+ tpg->src_width, tpg->src_height,
+ tpg_color_enc_str(tpg->color_enc));
pr_info("tpg field: %u\n", tpg->field);
pr_info("tpg crop: %ux%u@%dx%d\n", tpg->crop.width, tpg->crop.height,
tpg->crop.left, tpg->crop.top);
.fourcc = V4L2_PIX_FMT_YUYV,
.vdownsampling = { 1 },
.bit_depth = { 16 },
- .is_yuv = true,
+ .color_enc = TGP_COLOR_ENC_YCBCR,
.planes = 1,
.buffers = 1,
.data_offset = { PLANE0_DATA_OFFSET },
.fourcc = V4L2_PIX_FMT_UYVY,
.vdownsampling = { 1 },
.bit_depth = { 16 },
- .is_yuv = true,
+ .color_enc = TGP_COLOR_ENC_YCBCR,
.planes = 1,
.buffers = 1,
},
.fourcc = V4L2_PIX_FMT_YVYU,
.vdownsampling = { 1 },
.bit_depth = { 16 },
- .is_yuv = true,
+ .color_enc = TGP_COLOR_ENC_YCBCR,
.planes = 1,
.buffers = 1,
},
.fourcc = V4L2_PIX_FMT_VYUY,
.vdownsampling = { 1 },
.bit_depth = { 16 },
- .is_yuv = true,
+ .color_enc = TGP_COLOR_ENC_YCBCR,
.planes = 1,
.buffers = 1,
},
.fourcc = V4L2_PIX_FMT_YUV422P,
.vdownsampling = { 1, 1, 1 },
.bit_depth = { 8, 4, 4 },
- .is_yuv = true,
+ .color_enc = TGP_COLOR_ENC_YCBCR,
.planes = 3,
.buffers = 1,
},
.fourcc = V4L2_PIX_FMT_YUV420,
.vdownsampling = { 1, 2, 2 },
.bit_depth = { 8, 4, 4 },
- .is_yuv = true,
+ .color_enc = TGP_COLOR_ENC_YCBCR,
.planes = 3,
.buffers = 1,
},
.fourcc = V4L2_PIX_FMT_YVU420,
.vdownsampling = { 1, 2, 2 },
.bit_depth = { 8, 4, 4 },
- .is_yuv = true,
+ .color_enc = TGP_COLOR_ENC_YCBCR,
.planes = 3,
.buffers = 1,
},
.fourcc = V4L2_PIX_FMT_NV12,
.vdownsampling = { 1, 2 },
.bit_depth = { 8, 8 },
- .is_yuv = true,
+ .color_enc = TGP_COLOR_ENC_YCBCR,
.planes = 2,
.buffers = 1,
},
.fourcc = V4L2_PIX_FMT_NV21,
.vdownsampling = { 1, 2 },
.bit_depth = { 8, 8 },
- .is_yuv = true,
+ .color_enc = TGP_COLOR_ENC_YCBCR,
.planes = 2,
.buffers = 1,
},
.fourcc = V4L2_PIX_FMT_NV16,
.vdownsampling = { 1, 1 },
.bit_depth = { 8, 8 },
- .is_yuv = true,
+ .color_enc = TGP_COLOR_ENC_YCBCR,
.planes = 2,
.buffers = 1,
},
.fourcc = V4L2_PIX_FMT_NV61,
.vdownsampling = { 1, 1 },
.bit_depth = { 8, 8 },
- .is_yuv = true,
+ .color_enc = TGP_COLOR_ENC_YCBCR,
.planes = 2,
.buffers = 1,
},
.fourcc = V4L2_PIX_FMT_NV24,
.vdownsampling = { 1, 1 },
.bit_depth = { 8, 16 },
- .is_yuv = true,
+ .color_enc = TGP_COLOR_ENC_YCBCR,
.planes = 2,
.buffers = 1,
},
.fourcc = V4L2_PIX_FMT_NV42,
.vdownsampling = { 1, 1 },
.bit_depth = { 8, 16 },
- .is_yuv = true,
+ .color_enc = TGP_COLOR_ENC_YCBCR,
.planes = 2,
.buffers = 1,
},
.fourcc = V4L2_PIX_FMT_GREY,
.vdownsampling = { 1 },
.bit_depth = { 8 },
- .is_yuv = true,
+ .color_enc = TGP_COLOR_ENC_YCBCR,
.planes = 1,
.buffers = 1,
},
.fourcc = V4L2_PIX_FMT_Y16,
.vdownsampling = { 1 },
.bit_depth = { 16 },
- .is_yuv = true,
+ .color_enc = TGP_COLOR_ENC_YCBCR,
.planes = 1,
.buffers = 1,
},
.fourcc = V4L2_PIX_FMT_Y16_BE,
.vdownsampling = { 1 },
.bit_depth = { 16 },
- .is_yuv = true,
+ .color_enc = TGP_COLOR_ENC_YCBCR,
.planes = 1,
.buffers = 1,
},
.fourcc = V4L2_PIX_FMT_NV16M,
.vdownsampling = { 1, 1 },
.bit_depth = { 8, 8 },
- .is_yuv = true,
+ .color_enc = TGP_COLOR_ENC_YCBCR,
.planes = 2,
.buffers = 2,
.data_offset = { PLANE0_DATA_OFFSET, 0 },
.fourcc = V4L2_PIX_FMT_NV61M,
.vdownsampling = { 1, 1 },
.bit_depth = { 8, 8 },
- .is_yuv = true,
+ .color_enc = TGP_COLOR_ENC_YCBCR,
.planes = 2,
.buffers = 2,
.data_offset = { 0, PLANE0_DATA_OFFSET },
.fourcc = V4L2_PIX_FMT_YUV420M,
.vdownsampling = { 1, 2, 2 },
.bit_depth = { 8, 4, 4 },
- .is_yuv = true,
+ .color_enc = TGP_COLOR_ENC_YCBCR,
.planes = 3,
.buffers = 3,
},
.fourcc = V4L2_PIX_FMT_YVU420M,
.vdownsampling = { 1, 2, 2 },
.bit_depth = { 8, 4, 4 },
- .is_yuv = true,
+ .color_enc = TGP_COLOR_ENC_YCBCR,
.planes = 3,
.buffers = 3,
},
.fourcc = V4L2_PIX_FMT_NV12M,
.vdownsampling = { 1, 2 },
.bit_depth = { 8, 8 },
- .is_yuv = true,
+ .color_enc = TGP_COLOR_ENC_YCBCR,
.planes = 2,
.buffers = 2,
},
.fourcc = V4L2_PIX_FMT_NV21M,
.vdownsampling = { 1, 2 },
.bit_depth = { 8, 8 },
- .is_yuv = true,
+ .color_enc = TGP_COLOR_ENC_YCBCR,
.planes = 2,
.buffers = 2,
},
.fourcc = V4L2_PIX_FMT_YUV422M,
.vdownsampling = { 1, 1, 1 },
.bit_depth = { 8, 4, 4 },
- .is_yuv = true,
+ .color_enc = TGP_COLOR_ENC_YCBCR,
.planes = 3,
.buffers = 3,
},
.fourcc = V4L2_PIX_FMT_YVU422M,
.vdownsampling = { 1, 1, 1 },
.bit_depth = { 8, 4, 4 },
- .is_yuv = true,
+ .color_enc = TGP_COLOR_ENC_YCBCR,
.planes = 3,
.buffers = 3,
},
.fourcc = V4L2_PIX_FMT_YUV444M,
.vdownsampling = { 1, 1, 1 },
.bit_depth = { 8, 8, 8 },
- .is_yuv = true,
+ .color_enc = TGP_COLOR_ENC_YCBCR,
.planes = 3,
.buffers = 3,
},
.fourcc = V4L2_PIX_FMT_YVU444M,
.vdownsampling = { 1, 1, 1 },
.bit_depth = { 8, 8, 8 },
- .is_yuv = true,
+ .color_enc = TGP_COLOR_ENC_YCBCR,
.planes = 3,
.buffers = 3,
},