// SPDX-License-Identifier: GPL-2.0-only
/*
* v4l2-tpg-colors.c - A table that converts colors to various colorspaces
*
* The test pattern generator uses the tpg_colors for its test patterns.
* For testing colorspaces the first 8 colors of that table need to be
* converted to their equivalent in the target colorspace.
*
* The tpg_csc_colors[] table is the result of that conversion and since
* it is precalculated the colorspace conversion is just a simple table
* lookup.
*
* This source also contains the code used to generate the tpg_csc_colors
* table. Run the following command to compile it:
*
* gcc v4l2-tpg-colors.c -DCOMPILE_APP -o gen-colors -lm
*
* and run the utility.
*
* Note that the converted colors are in the range 0x000-0xff0 (so times 16)
* in order to preserve precision.
*
* Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
*/
#include <linux/videodev2.h>
#include <media/tpg/v4l2-tpg.h>
/* sRGB colors with range [0-255] */
const struct tpg_rbg_color8 tpg_colors[TPG_COLOR_MAX] = {
/*
* Colors to test colorspace conversion: converting these colors
* to other colorspaces will never lead to out-of-gamut colors.
*/
{ 191, 191, 191 }, /* TPG_COLOR_CSC_WHITE */
{ 191, 191, 50 }, /* TPG_COLOR_CSC_YELLOW */
{ 50, 191, 191 }, /* TPG_COLOR_CSC_CYAN */
{ 50, 191, 50 }, /* TPG_COLOR_CSC_GREEN */
{ 191, 50, 191 }, /* TPG_COLOR_CSC_MAGENTA */
{ 191, 50, 50 }, /* TPG_COLOR_CSC_RED */
{ 50, 50, 191 }, /* TPG_COLOR_CSC_BLUE */
{ 50, 50, 50 }, /* TPG_COLOR_CSC_BLACK */
/* 75% colors */
{ 191, 191, 0 }, /* TPG_COLOR_75_YELLOW */
{ 0, 191, 191 }, /* TPG_COLOR_75_CYAN */
{ 0, 191, 0 }, /* TPG_COLOR_75_GREEN */
{ 191, 0, 191 }, /* TPG_COLOR_75_MAGENTA */
{ 191, 0, 0 }, /* TPG_COLOR_75_RED */
{ 0,