18ae5b155SLewis Huang /*
2*23a63e91SJonathan Gray  * Copyright 2019 Advanced Micro Devices, Inc.
38ae5b155SLewis Huang  *
4*23a63e91SJonathan Gray  * Permission is hereby granted, free of charge, to any person obtaining a
5*23a63e91SJonathan Gray  * copy of this software and associated documentation files (the "Software"),
6*23a63e91SJonathan Gray  * to deal in the Software without restriction, including without limitation
7*23a63e91SJonathan Gray  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*23a63e91SJonathan Gray  * and/or sell copies of the Software, and to permit persons to whom the
9*23a63e91SJonathan Gray  * Software is furnished to do so, subject to the following conditions:
10*23a63e91SJonathan Gray  *
11*23a63e91SJonathan Gray  * The above copyright notice and this permission notice shall be included in
12*23a63e91SJonathan Gray  * all copies or substantial portions of the Software.
13*23a63e91SJonathan Gray  *
14*23a63e91SJonathan Gray  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15*23a63e91SJonathan Gray  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16*23a63e91SJonathan Gray  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17*23a63e91SJonathan Gray  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18*23a63e91SJonathan Gray  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19*23a63e91SJonathan Gray  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20*23a63e91SJonathan Gray  * OTHER DEALINGS IN THE SOFTWARE.
21*23a63e91SJonathan Gray  *
22*23a63e91SJonathan Gray  * Authors: AMD
23*23a63e91SJonathan Gray  *
248ae5b155SLewis Huang  */
258ae5b155SLewis Huang 
268ae5b155SLewis Huang #include "color_table.h"
278ae5b155SLewis Huang 
288ae5b155SLewis Huang static struct fixed31_32 pq_table[MAX_HW_POINTS + 2];
298ae5b155SLewis Huang static struct fixed31_32 de_pq_table[MAX_HW_POINTS + 2];
308ae5b155SLewis Huang static bool pq_initialized;
318ae5b155SLewis Huang static bool de_pg_initialized;
328ae5b155SLewis Huang 
mod_color_is_table_init(enum table_type type)338ae5b155SLewis Huang bool mod_color_is_table_init(enum table_type type)
348ae5b155SLewis Huang {
358ae5b155SLewis Huang 	bool ret = false;
368ae5b155SLewis Huang 
378ae5b155SLewis Huang 	if (type == type_pq_table)
388ae5b155SLewis Huang 		ret = pq_initialized;
398ae5b155SLewis Huang 	if (type == type_de_pq_table)
408ae5b155SLewis Huang 		ret = de_pg_initialized;
418ae5b155SLewis Huang 
428ae5b155SLewis Huang 	return ret;
438ae5b155SLewis Huang }
448ae5b155SLewis Huang 
mod_color_get_table(enum table_type type)458ae5b155SLewis Huang struct fixed31_32 *mod_color_get_table(enum table_type type)
468ae5b155SLewis Huang {
478ae5b155SLewis Huang 	struct fixed31_32 *table = NULL;
488ae5b155SLewis Huang 
498ae5b155SLewis Huang 	if (type == type_pq_table)
508ae5b155SLewis Huang 		table = pq_table;
518ae5b155SLewis Huang 	if (type == type_de_pq_table)
528ae5b155SLewis Huang 		table = de_pq_table;
538ae5b155SLewis Huang 
548ae5b155SLewis Huang 	return table;
558ae5b155SLewis Huang }
568ae5b155SLewis Huang 
mod_color_set_table_init_state(enum table_type type,bool state)578ae5b155SLewis Huang void mod_color_set_table_init_state(enum table_type type, bool state)
588ae5b155SLewis Huang {
598ae5b155SLewis Huang 	if (type == type_pq_table)
608ae5b155SLewis Huang 		pq_initialized = state;
618ae5b155SLewis Huang 	if (type == type_de_pq_table)
628ae5b155SLewis Huang 		de_pg_initialized = state;
638ae5b155SLewis Huang }
648ae5b155SLewis Huang 
65