Home | History | Annotate | Line # | Download | only in hw
      1 /*	$NetBSD: transform.h,v 1.2 2021/12/18 23:45:05 riastradh Exp $	*/
      2 
      3 /*
      4  * Copyright 2012-15 Advanced Micro Devices, Inc.
      5  *
      6  * Permission is hereby granted, free of charge, to any person obtaining a
      7  * copy of this software and associated documentation files (the "Software"),
      8  * to deal in the Software without restriction, including without limitation
      9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     10  * and/or sell copies of the Software, and to permit persons to whom the
     11  * Software is furnished to do so, subject to the following conditions:
     12  *
     13  * The above copyright notice and this permission notice shall be included in
     14  * all copies or substantial portions of the Software.
     15  *
     16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     19  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
     20  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     22  * OTHER DEALINGS IN THE SOFTWARE.
     23  *
     24  * Authors: AMD
     25  *
     26  */
     27 
     28 #ifndef __DAL_TRANSFORM_H__
     29 #define __DAL_TRANSFORM_H__
     30 
     31 #include "hw_shared.h"
     32 #include "dc_hw_types.h"
     33 #include "fixed31_32.h"
     34 
     35 #define CSC_TEMPERATURE_MATRIX_SIZE 12
     36 
     37 struct bit_depth_reduction_params;
     38 
     39 struct transform {
     40 	const struct transform_funcs *funcs;
     41 	struct dc_context *ctx;
     42 	int inst;
     43 	struct dpp_caps *caps;
     44 	struct pwl_params regamma_params;
     45 };
     46 
     47 /* Colorimetry */
     48 enum colorimetry {
     49 	COLORIMETRY_NO_DATA = 0,
     50 	COLORIMETRY_ITU601 = 1,
     51 	COLORIMETRY_ITU709 = 2,
     52 	COLORIMETRY_EXTENDED = 3
     53 };
     54 
     55 enum colorimetry_ext {
     56 	COLORIMETRYEX_XVYCC601 = 0,
     57 	COLORIMETRYEX_XVYCC709 = 1,
     58 	COLORIMETRYEX_SYCC601 = 2,
     59 	COLORIMETRYEX_ADOBEYCC601 = 3,
     60 	COLORIMETRYEX_ADOBERGB = 4,
     61 	COLORIMETRYEX_BT2020YCC = 5,
     62 	COLORIMETRYEX_BT2020RGBYCBCR = 6,
     63 	COLORIMETRYEX_RESERVED = 7
     64 };
     65 
     66 enum active_format_info {
     67 	ACTIVE_FORMAT_NO_DATA = 0,
     68 	ACTIVE_FORMAT_VALID = 1
     69 };
     70 
     71 /* Active format aspect ratio */
     72 enum active_format_aspect_ratio {
     73 	ACTIVE_FORMAT_ASPECT_RATIO_SAME_AS_PICTURE = 8,
     74 	ACTIVE_FORMAT_ASPECT_RATIO_4_3 = 9,
     75 	ACTIVE_FORMAT_ASPECT_RATIO_16_9 = 0XA,
     76 	ACTIVE_FORMAT_ASPECT_RATIO_14_9 = 0XB
     77 };
     78 
     79 enum bar_info {
     80 	BAR_INFO_NOT_VALID = 0,
     81 	BAR_INFO_VERTICAL_VALID = 1,
     82 	BAR_INFO_HORIZONTAL_VALID = 2,
     83 	BAR_INFO_BOTH_VALID = 3
     84 };
     85 
     86 enum picture_scaling {
     87 	PICTURE_SCALING_UNIFORM = 0,
     88 	PICTURE_SCALING_HORIZONTAL = 1,
     89 	PICTURE_SCALING_VERTICAL = 2,
     90 	PICTURE_SCALING_BOTH = 3
     91 };
     92 
     93 /* RGB quantization range */
     94 enum rgb_quantization_range {
     95 	RGB_QUANTIZATION_DEFAULT_RANGE = 0,
     96 	RGB_QUANTIZATION_LIMITED_RANGE = 1,
     97 	RGB_QUANTIZATION_FULL_RANGE = 2,
     98 	RGB_QUANTIZATION_RESERVED = 3
     99 };
    100 
    101 /* YYC quantization range */
    102 enum yyc_quantization_range {
    103 	YYC_QUANTIZATION_LIMITED_RANGE = 0,
    104 	YYC_QUANTIZATION_FULL_RANGE = 1,
    105 	YYC_QUANTIZATION_RESERVED2 = 2,
    106 	YYC_QUANTIZATION_RESERVED3 = 3
    107 };
    108 
    109 enum graphics_gamut_adjust_type {
    110 	GRAPHICS_GAMUT_ADJUST_TYPE_BYPASS = 0,
    111 	GRAPHICS_GAMUT_ADJUST_TYPE_HW, /* without adjustments */
    112 	GRAPHICS_GAMUT_ADJUST_TYPE_SW /* use adjustments */
    113 };
    114 
    115 enum lb_memory_config {
    116 	/* Enable all 3 pieces of memory */
    117 	LB_MEMORY_CONFIG_0 = 0,
    118 
    119 	/* Enable only the first piece of memory */
    120 	LB_MEMORY_CONFIG_1 = 1,
    121 
    122 	/* Enable only the second piece of memory */
    123 	LB_MEMORY_CONFIG_2 = 2,
    124 
    125 	/* Only applicable in 4:2:0 mode, enable all 3 pieces of memory and the
    126 	 * last piece of chroma memory used for the luma storage
    127 	 */
    128 	LB_MEMORY_CONFIG_3 = 3
    129 };
    130 
    131 struct xfm_grph_csc_adjustment {
    132 	struct fixed31_32 temperature_matrix[CSC_TEMPERATURE_MATRIX_SIZE];
    133 	enum graphics_gamut_adjust_type gamut_adjust_type;
    134 };
    135 
    136 struct overscan_info {
    137 	int left;
    138 	int right;
    139 	int top;
    140 	int bottom;
    141 };
    142 
    143 struct scaling_ratios {
    144 	struct fixed31_32 horz;
    145 	struct fixed31_32 vert;
    146 	struct fixed31_32 horz_c;
    147 	struct fixed31_32 vert_c;
    148 };
    149 
    150 struct sharpness_adj {
    151 	int horz;
    152 	int vert;
    153 };
    154 
    155 struct line_buffer_params {
    156 	bool alpha_en;
    157 	bool pixel_expan_mode;
    158 	bool interleave_en;
    159 	int dynamic_pixel_depth;
    160 	enum lb_pixel_depth depth;
    161 };
    162 
    163 struct scl_inits {
    164 	struct fixed31_32 h;
    165 	struct fixed31_32 h_c;
    166 	struct fixed31_32 v;
    167 	struct fixed31_32 v_bot;
    168 	struct fixed31_32 v_c;
    169 	struct fixed31_32 v_c_bot;
    170 };
    171 
    172 struct scaler_data {
    173 	int h_active;
    174 	int v_active;
    175 	struct scaling_taps taps;
    176 	struct rect viewport;
    177 	struct rect viewport_c;
    178 	struct rect recout;
    179 	struct scaling_ratios ratios;
    180 	struct scl_inits inits;
    181 	struct sharpness_adj sharpness;
    182 	enum pixel_format format;
    183 	struct line_buffer_params lb_params;
    184 };
    185 
    186 struct transform_funcs {
    187 	void (*transform_reset)(struct transform *xfm);
    188 
    189 	void (*transform_set_scaler)(struct transform *xfm,
    190 			const struct scaler_data *scl_data);
    191 
    192 	void (*transform_set_pixel_storage_depth)(
    193 			struct transform *xfm,
    194 			enum lb_pixel_depth depth,
    195 			const struct bit_depth_reduction_params *bit_depth_params);
    196 
    197 	bool (*transform_get_optimal_number_of_taps)(
    198 			struct transform *xfm,
    199 			struct scaler_data *scl_data,
    200 			const struct scaling_taps *in_taps);
    201 
    202 	void (*transform_set_gamut_remap)(
    203 			struct transform *xfm,
    204 			const struct xfm_grph_csc_adjustment *adjust);
    205 
    206 	void (*opp_set_csc_default)(
    207 		struct transform *xfm,
    208 		const struct default_adjustment *default_adjust);
    209 
    210 	void (*opp_set_csc_adjustment)(
    211 		struct transform *xfm,
    212 		const struct out_csc_color_matrix *tbl_entry);
    213 
    214 	void (*opp_power_on_regamma_lut)(
    215 		struct transform *xfm,
    216 		bool power_on);
    217 
    218 	void (*opp_program_regamma_lut)(
    219 			struct transform *xfm,
    220 			const struct pwl_result_data *rgb,
    221 			uint32_t num);
    222 
    223 	void (*opp_configure_regamma_lut)(
    224 			struct transform *xfm,
    225 			bool is_ram_a);
    226 
    227 	void (*opp_program_regamma_lutb_settings)(
    228 			struct transform *xfm,
    229 			const struct pwl_params *params);
    230 
    231 	void (*opp_program_regamma_luta_settings)(
    232 			struct transform *xfm,
    233 			const struct pwl_params *params);
    234 
    235 	void (*opp_program_regamma_pwl)(
    236 		struct transform *xfm, const struct pwl_params *params);
    237 
    238 	void (*opp_set_regamma_mode)(
    239 			struct transform *xfm_base,
    240 			enum opp_regamma mode);
    241 
    242 	void (*ipp_set_degamma)(
    243 			struct transform *xfm_base,
    244 			enum ipp_degamma_mode mode);
    245 
    246 	void (*ipp_program_input_lut)(
    247 			struct transform *xfm_base,
    248 			const struct dc_gamma *gamma);
    249 
    250 	void (*ipp_program_degamma_pwl)(struct transform *xfm_base,
    251 									 const struct pwl_params *params);
    252 
    253 	void (*ipp_setup)(
    254 			struct transform *xfm_base,
    255 			enum surface_pixel_format format,
    256 			enum expansion_mode mode,
    257 			struct dc_csc_transform input_csc_color_matrix,
    258 			enum dc_color_space input_color_space);
    259 
    260 	void (*ipp_full_bypass)(struct transform *xfm_base);
    261 
    262 	void (*set_cursor_attributes)(
    263 			struct transform *xfm_base,
    264 			const struct dc_cursor_attributes *attr);
    265 
    266 };
    267 
    268 const uint16_t *get_filter_2tap_16p(void);
    269 const uint16_t *get_filter_2tap_64p(void);
    270 const uint16_t *get_filter_3tap_16p(struct fixed31_32 ratio);
    271 const uint16_t *get_filter_3tap_64p(struct fixed31_32 ratio);
    272 const uint16_t *get_filter_4tap_16p(struct fixed31_32 ratio);
    273 const uint16_t *get_filter_4tap_64p(struct fixed31_32 ratio);
    274 const uint16_t *get_filter_5tap_64p(struct fixed31_32 ratio);
    275 const uint16_t *get_filter_6tap_64p(struct fixed31_32 ratio);
    276 const uint16_t *get_filter_7tap_64p(struct fixed31_32 ratio);
    277 const uint16_t *get_filter_8tap_64p(struct fixed31_32 ratio);
    278 
    279 
    280 /* Defines the pixel processing capability of the DSCL */
    281 enum dscl_data_processing_format {
    282 	DSCL_DATA_PRCESSING_FIXED_FORMAT,	/* The DSCL processes pixel data in fixed format */
    283 	DSCL_DATA_PRCESSING_FLOAT_FORMAT,	/* The DSCL processes pixel data in float format */
    284 };
    285 
    286 /*
    287  * The DPP capabilities structure contains enumerations to specify the
    288  * HW processing features and an associated function pointers to
    289  * provide the function interface that can be overloaded for implementations
    290  * based on different capabilities
    291  */
    292 struct dpp_caps {
    293 	/* DSCL processing pixel data in fixed or float format */
    294 	enum dscl_data_processing_format dscl_data_proc_format;
    295 
    296 	/* Calculates the number of partitions in the line buffer.
    297 	 * The implementation of this function is overloaded for
    298 	 * different versions of DSCL LB.
    299 	 */
    300 	void (*dscl_calc_lb_num_partitions)(
    301 			const struct scaler_data *scl_data,
    302 			enum lb_memory_config lb_config,
    303 			int *num_part_y,
    304 			int *num_part_c);
    305 };
    306 
    307 
    308 #endif
    309