/*
* 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.
*
* This program is free software; you may redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#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