Home | History | Annotate | Line # | Download | only in hw
      1 /*	$NetBSD: abm.h,v 1.2 2021/12/18 23:45:05 riastradh Exp $	*/
      2 
      3 /* Copyright 2012-15 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_ABM_H__
     28 #define __DC_ABM_H__
     29 
     30 #include "dm_services_types.h"
     31 
     32 struct abm_backlight_registers {
     33 	unsigned int BL_PWM_CNTL;
     34 	unsigned int BL_PWM_CNTL2;
     35 	unsigned int BL_PWM_PERIOD_CNTL;
     36 	unsigned int LVTMA_PWRSEQ_REF_DIV_BL_PWM_REF_DIV;
     37 };
     38 
     39 struct abm {
     40 	struct dc_context *ctx;
     41 	const struct abm_funcs *funcs;
     42 	bool dmcu_is_running;
     43 	/* registers setting needs to be saved and restored at InitBacklight */
     44 	struct abm_backlight_registers stored_backlight_registers;
     45 };
     46 
     47 struct abm_funcs {
     48 	void (*abm_init)(struct abm *abm);
     49 	bool (*set_abm_level)(struct abm *abm, unsigned int abm_level);
     50 	bool (*set_abm_immediate_disable)(struct abm *abm);
     51 	bool (*set_pipe)(struct abm *abm, unsigned int controller_id);
     52 	bool (*init_backlight)(struct abm *abm);
     53 
     54 	/* backlight_pwm_u16_16 is unsigned 32 bit,
     55 	 * 16 bit integer + 16 fractional, where 1.0 is max backlight value.
     56 	 */
     57 	bool (*set_backlight_level_pwm)(struct abm *abm,
     58 			unsigned int backlight_pwm_u16_16,
     59 			unsigned int frame_ramp,
     60 			unsigned int controller_id,
     61 			bool use_smooth_brightness);
     62 
     63 	unsigned int (*get_current_backlight)(struct abm *abm);
     64 	unsigned int (*get_target_backlight)(struct abm *abm);
     65 };
     66 
     67 #endif
     68