Home | History | Annotate | Line # | Download | only in hw
      1 /*	$NetBSD: dwb.h,v 1.2 2021/12/18 23:45:05 riastradh Exp $	*/
      2 
      3 /* Copyright 2012-17 Advanced Micro Devices, Inc.
      4  *
      5  * Permission is hereby granted, free of charge, to any person obtaining a
      6  * copy of this software and associated documentation files (the "Software"),
      7  * to deal in the Software without restriction, including without limitation
      8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      9  * and/or sell copies of the Software, and to permit persons to whom the
     10  * Software is furnished to do so, subject to the following conditions:
     11  *
     12  * The above copyright notice and this permission notice shall be included in
     13  * all copies or substantial portions of the Software.
     14  *
     15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     18  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
     19  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     21  * OTHER DEALINGS IN THE SOFTWARE.
     22  *
     23  * Authors: AMD
     24  *
     25  */
     26 
     27 #ifndef __DC_DWBC_H__
     28 #define __DC_DWBC_H__
     29 
     30 #include "dc_hw_types.h"
     31 
     32 
     33 #define DWB_SW_V2	1
     34 #define DWB_MCIF_BUF_COUNT 4
     35 
     36 /* forward declaration of mcif_wb struct */
     37 struct mcif_wb;
     38 
     39 enum dce_version;
     40 
     41 enum dwb_sw_version {
     42 	dwb_ver_1_0 = 1,
     43 	dwb_ver_2_0 = 2,
     44 };
     45 
     46 enum dwb_source {
     47 	dwb_src_scl = 0,	/* for DCE7x/9x, DCN won't support. */
     48 	dwb_src_blnd,		/* for DCE7x/9x */
     49 	dwb_src_fmt,		/* for DCE7x/9x */
     50 	dwb_src_otg0 = 0x100,	/* for DCN1.x/DCN2.x, register: mmDWB_SOURCE_SELECT */
     51 	dwb_src_otg1,		/* for DCN1.x/DCN2.x */
     52 	dwb_src_otg2,		/* for DCN1.x/DCN2.x */
     53 	dwb_src_otg3,		/* for DCN1.x/DCN2.x */
     54 };
     55 
     56 /* DCN1.x, DCN2.x support 2 pipes */
     57 enum dwb_pipe {
     58 	dwb_pipe0 = 0,
     59 #if defined(CONFIG_DRM_AMD_DC_DCN)
     60 	dwb_pipe1,
     61 #endif
     62 	dwb_pipe_max_num,
     63 };
     64 
     65 enum dwb_frame_capture_enable {
     66 	DWB_FRAME_CAPTURE_DISABLE = 0,
     67 	DWB_FRAME_CAPTURE_ENABLE = 1,
     68 };
     69 
     70 enum wbscl_coef_filter_type_sel {
     71 	WBSCL_COEF_LUMA_VERT_FILTER = 0,
     72 	WBSCL_COEF_CHROMA_VERT_FILTER = 1,
     73 	WBSCL_COEF_LUMA_HORZ_FILTER = 2,
     74 	WBSCL_COEF_CHROMA_HORZ_FILTER = 3
     75 };
     76 
     77 
     78 struct dwb_warmup_params {
     79 	bool	warmup_en;	/* false: normal mode, true: enable pattern generator */
     80 	bool	warmup_mode;	/* false: 420, true: 444 */
     81 	bool	warmup_depth;	/* false: 8bit, true: 10bit */
     82 	int	warmup_data;	/* Data to be sent by pattern generator (same for each pixel component) */
     83 	int	warmup_width;	/* Pattern width (pixels) */
     84 	int	warmup_height;	/* Pattern height (lines) */
     85 };
     86 
     87 struct dwb_caps {
     88 	enum dce_version hw_version;	/* DCN engine version. */
     89 	enum dwb_sw_version sw_version;	/* DWB sw implementation version. */
     90 	unsigned int	reserved[6];	/* Reserved for future use, MUST BE 0. */
     91 	unsigned int	adapter_id;
     92 	unsigned int	num_pipes;	/* number of DWB pipes */
     93 	struct {
     94 		unsigned int support_dwb	:1;
     95 		unsigned int support_ogam	:1;
     96 		unsigned int support_wbscl	:1;
     97 		unsigned int support_ocsc	:1;
     98 		unsigned int support_stereo :1;
     99 	} caps;
    100 	unsigned int	 reserved2[9];	/* Reserved for future use, MUST BE 0. */
    101 };
    102 
    103 struct dwbc {
    104 	const struct dwbc_funcs *funcs;
    105 	struct dc_context *ctx;
    106 	int inst;
    107 	struct mcif_wb *mcif;
    108 	bool status;
    109 	int inputSrcSelect;
    110 	bool dwb_output_black;
    111 	enum dc_transfer_func_predefined tf;
    112 	enum dc_color_space output_color_space;
    113 	bool dwb_is_efc_transition;
    114 	bool dwb_is_drc;
    115 	int wb_src_plane_inst;/*hubp, mpcc, inst*/
    116 	bool update_privacymask;
    117 	uint32_t mask_id;
    118         int otg_inst;
    119         bool mvc_cfg;
    120 };
    121 
    122 struct dwbc_funcs {
    123 	bool (*get_caps)(
    124 		struct dwbc *dwbc,
    125 		struct dwb_caps *caps);
    126 
    127 	bool (*enable)(
    128 		struct dwbc *dwbc,
    129 		struct dc_dwb_params *params);
    130 
    131 	bool (*disable)(struct dwbc *dwbc);
    132 
    133 	bool (*update)(
    134 		struct dwbc *dwbc,
    135 		struct dc_dwb_params *params);
    136 
    137 	bool (*is_enabled)(
    138 		struct dwbc *dwbc);
    139 
    140 	void (*set_stereo)(
    141 		struct dwbc *dwbc,
    142 		struct dwb_stereo_params *stereo_params);
    143 
    144 	void (*set_new_content)(
    145 		struct dwbc *dwbc,
    146 		bool is_new_content);
    147 
    148 
    149 	void (*set_warmup)(
    150 		struct dwbc *dwbc,
    151 		struct dwb_warmup_params *warmup_params);
    152 
    153 
    154 	bool (*get_dwb_status)(
    155 		struct dwbc *dwbc);
    156 	void (*dwb_set_scaler)(
    157 		struct dwbc *dwbc,
    158 		struct dc_dwb_params *params);
    159 };
    160 
    161 #endif
    162