linux/drivers/gpu/drm/i915/display/intel_backlight.c

// SPDX-License-Identifier: MIT
/*
 * Copyright © 2021 Intel Corporation
 */

#include <linux/backlight.h>
#include <linux/kernel.h>
#include <linux/pwm.h>
#include <linux/string_helpers.h>

#include <acpi/video.h>

#include "i915_reg.h"
#include "intel_backlight.h"
#include "intel_backlight_regs.h"
#include "intel_connector.h"
#include "intel_de.h"
#include "intel_display_types.h"
#include "intel_dp_aux_backlight.h"
#include "intel_dsi_dcs_backlight.h"
#include "intel_panel.h"
#include "intel_pci_config.h"
#include "intel_pps.h"
#include "intel_quirks.h"

/**
 * scale - scale values from one range to another
 * @source_val: value in range [@source_min..@source_max]
 * @source_min: minimum legal value for @source_val
 * @source_max: maximum legal value for @source_val
 * @target_min: corresponding target value for @source_min
 * @target_max: corresponding target value for @source_max
 *
 * Return @source_val in range [@source_min..@source_max] scaled to range
 * [@target_min..@target_max].
 */
static u32 scale(u32 source_val,
		 u32 source_min, u32 source_max,
		 u32 target_min, u32 target_max)
{}

/*
 * Scale user_level in range [0..user_max] to [0..hw_max], clamping the result
 * to [hw_min..hw_max].
 */
static u32 clamp_user_to_hw(struct intel_connector *connector,
			    u32 user_level, u32 user_max)
{}

/* Scale hw_level in range [hw_min..hw_max] to [0..user_max]. */
static u32 scale_hw_to_user(struct intel_connector *connector,
			    u32 hw_level, u32 user_max)
{}

u32 intel_backlight_invert_pwm_level(struct intel_connector *connector, u32 val)
{}

void intel_backlight_set_pwm_level(const struct drm_connector_state *conn_state, u32 val)
{}

u32 intel_backlight_level_to_pwm(struct intel_connector *connector, u32 val)
{}

u32 intel_backlight_level_from_pwm(struct intel_connector *connector, u32 val)
{}

static u32 lpt_get_backlight(struct intel_connector *connector, enum pipe unused)
{}

static u32 pch_get_backlight(struct intel_connector *connector, enum pipe unused)
{}

static u32 i9xx_get_backlight(struct intel_connector *connector, enum pipe unused)
{}

static u32 vlv_get_backlight(struct intel_connector *connector, enum pipe pipe)
{}

static u32 bxt_get_backlight(struct intel_connector *connector, enum pipe unused)
{}

static u32 ext_pwm_get_backlight(struct intel_connector *connector, enum pipe unused)
{}

static void lpt_set_backlight(const struct drm_connector_state *conn_state, u32 level)
{}

static void pch_set_backlight(const struct drm_connector_state *conn_state, u32 level)
{}

static void i9xx_set_backlight(const struct drm_connector_state *conn_state, u32 level)
{}

static void vlv_set_backlight(const struct drm_connector_state *conn_state, u32 level)
{}

static void bxt_set_backlight(const struct drm_connector_state *conn_state, u32 level)
{}

static void ext_pwm_set_backlight(const struct drm_connector_state *conn_state, u32 level)
{}

static void
intel_panel_actually_set_backlight(const struct drm_connector_state *conn_state, u32 level)
{}

/* set backlight brightness to level in range [0..max], assuming hw min is
 * respected.
 */
void intel_backlight_set_acpi(const struct drm_connector_state *conn_state,
			      u32 user_level, u32 user_max)
{}

static void lpt_disable_backlight(const struct drm_connector_state *old_conn_state, u32 level)
{}

static void pch_disable_backlight(const struct drm_connector_state *old_conn_state, u32 val)
{}

static void i9xx_disable_backlight(const struct drm_connector_state *old_conn_state, u32 val)
{}

static void i965_disable_backlight(const struct drm_connector_state *old_conn_state, u32 val)
{}

static void vlv_disable_backlight(const struct drm_connector_state *old_conn_state, u32 val)
{}

static void bxt_disable_backlight(const struct drm_connector_state *old_conn_state, u32 val)
{}

static void cnp_disable_backlight(const struct drm_connector_state *old_conn_state, u32 val)
{}

static void ext_pwm_disable_backlight(const struct drm_connector_state *old_conn_state, u32 level)
{}

void intel_backlight_disable(const struct drm_connector_state *old_conn_state)
{}

static void lpt_enable_backlight(const struct intel_crtc_state *crtc_state,
				 const struct drm_connector_state *conn_state, u32 level)
{}

static void pch_enable_backlight(const struct intel_crtc_state *crtc_state,
				 const struct drm_connector_state *conn_state, u32 level)
{}

static void i9xx_enable_backlight(const struct intel_crtc_state *crtc_state,
				  const struct drm_connector_state *conn_state, u32 level)
{}

static void i965_enable_backlight(const struct intel_crtc_state *crtc_state,
				  const struct drm_connector_state *conn_state, u32 level)
{}

static void vlv_enable_backlight(const struct intel_crtc_state *crtc_state,
				 const struct drm_connector_state *conn_state, u32 level)
{}

static void bxt_enable_backlight(const struct intel_crtc_state *crtc_state,
				 const struct drm_connector_state *conn_state, u32 level)
{}

static void cnp_enable_backlight(const struct intel_crtc_state *crtc_state,
				 const struct drm_connector_state *conn_state, u32 level)
{}

static void ext_pwm_enable_backlight(const struct intel_crtc_state *crtc_state,
				     const struct drm_connector_state *conn_state, u32 level)
{}

static void __intel_backlight_enable(const struct intel_crtc_state *crtc_state,
				     const struct drm_connector_state *conn_state)
{}

void intel_backlight_enable(const struct intel_crtc_state *crtc_state,
			    const struct drm_connector_state *conn_state)
{}

#if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE)
static u32 intel_panel_get_backlight(struct intel_connector *connector)
{}

/* Scale user_level in range [0..user_max] to [hw_min..hw_max]. */
static u32 scale_user_to_hw(struct intel_connector *connector,
			    u32 user_level, u32 user_max)
{}

/* set backlight brightness to level in range [0..max], scaling wrt hw min */
static void intel_panel_set_backlight(const struct drm_connector_state *conn_state,
				      u32 user_level, u32 user_max)
{}

static int intel_backlight_device_update_status(struct backlight_device *bd)
{}

static int intel_backlight_device_get_brightness(struct backlight_device *bd)
{}

static const struct backlight_ops intel_backlight_device_ops =;

int intel_backlight_device_register(struct intel_connector *connector)
{}

void intel_backlight_device_unregister(struct intel_connector *connector)
{}
#endif /* CONFIG_BACKLIGHT_CLASS_DEVICE */

/*
 * CNP: PWM clock frequency is 19.2 MHz or 24 MHz.
 *      PWM increment = 1
 */
static u32 cnp_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
{}

/*
 * BXT: PWM clock frequency = 19.2 MHz.
 */
static u32 bxt_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
{}

/*
 * SPT: This value represents the period of the PWM stream in clock periods
 * multiplied by 16 (default increment) or 128 (alternate increment selected in
 * SCHICKEN_1 bit 0). PWM clock is 24 MHz.
 */
static u32 spt_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
{}

/*
 * LPT: This value represents the period of the PWM stream in clock periods
 * multiplied by 128 (default increment) or 16 (alternate increment, selected in
 * LPT SOUTH_CHICKEN2 register bit 5).
 */
static u32 lpt_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
{}

/*
 * ILK/SNB/IVB: This value represents the period of the PWM stream in PCH
 * display raw clocks multiplied by 128.
 */
static u32 pch_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
{}

/*
 * Gen2: This field determines the number of time base events (display core
 * clock frequency/32) in total for a complete cycle of modulated backlight
 * control.
 *
 * Gen3: A time base event equals the display core clock ([DevPNV] HRAW clock)
 * divided by 32.
 */
static u32 i9xx_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
{}

/*
 * Gen4: This value represents the period of the PWM stream in display core
 * clocks ([DevCTG] HRAW clocks) multiplied by 128.
 *
 */
static u32 i965_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
{}

/*
 * VLV: This value represents the period of the PWM stream in display core
 * clocks ([DevCTG] 200MHz HRAW clocks) multiplied by 128 or 25MHz S0IX clocks
 * multiplied by 16. CHV uses a 19.2MHz S0IX clock.
 */
static u32 vlv_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
{}

static u16 get_vbt_pwm_freq(struct intel_connector *connector)
{}

static u32 get_backlight_max_vbt(struct intel_connector *connector)
{}

/*
 * Note: The setup hooks can't assume pipe is set!
 */
static u32 get_backlight_min_vbt(struct intel_connector *connector)
{}

static int lpt_setup_backlight(struct intel_connector *connector, enum pipe unused)
{}

static int pch_setup_backlight(struct intel_connector *connector, enum pipe unused)
{}

static int i9xx_setup_backlight(struct intel_connector *connector, enum pipe unused)
{}

static int i965_setup_backlight(struct intel_connector *connector, enum pipe unused)
{}

static int vlv_setup_backlight(struct intel_connector *connector, enum pipe pipe)
{}

static int
bxt_setup_backlight(struct intel_connector *connector, enum pipe unused)
{}

static int cnp_num_backlight_controllers(struct drm_i915_private *i915)
{}

static bool cnp_backlight_controller_is_valid(struct drm_i915_private *i915, int controller)
{}

static int
cnp_setup_backlight(struct intel_connector *connector, enum pipe unused)
{}

static int ext_pwm_setup_backlight(struct intel_connector *connector,
				   enum pipe pipe)
{}

static void intel_pwm_set_backlight(const struct drm_connector_state *conn_state, u32 level)
{}

static u32 intel_pwm_get_backlight(struct intel_connector *connector, enum pipe pipe)
{}

static void intel_pwm_enable_backlight(const struct intel_crtc_state *crtc_state,
				       const struct drm_connector_state *conn_state, u32 level)
{}

static void intel_pwm_disable_backlight(const struct drm_connector_state *conn_state, u32 level)
{}

static int intel_pwm_setup_backlight(struct intel_connector *connector, enum pipe pipe)
{}

void intel_backlight_update(struct intel_atomic_state *state,
			    struct intel_encoder *encoder,
			    const struct intel_crtc_state *crtc_state,
			    const struct drm_connector_state *conn_state)
{}

int intel_backlight_setup(struct intel_connector *connector, enum pipe pipe)
{}

void intel_backlight_destroy(struct intel_panel *panel)
{}

static const struct intel_panel_bl_funcs bxt_pwm_funcs =;

static const struct intel_panel_bl_funcs cnp_pwm_funcs =;

static const struct intel_panel_bl_funcs lpt_pwm_funcs =;

static const struct intel_panel_bl_funcs spt_pwm_funcs =;

static const struct intel_panel_bl_funcs pch_pwm_funcs =;

static const struct intel_panel_bl_funcs ext_pwm_funcs =;

static const struct intel_panel_bl_funcs vlv_pwm_funcs =;

static const struct intel_panel_bl_funcs i965_pwm_funcs =;

static const struct intel_panel_bl_funcs i9xx_pwm_funcs =;

static const struct intel_panel_bl_funcs pwm_bl_funcs =;

/* Set up chip specific backlight functions */
void intel_backlight_init_funcs(struct intel_panel *panel)
{}