diff mbox

drm/i915: Parsing LFP brightness control from VBT

Message ID 1418639301-9317-1-git-send-email-vandana.kannan@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

vandana.kannan@intel.com Dec. 15, 2014, 10:28 a.m. UTC
From: Deepak M <m.deepak@intel.com>

LFP brighness control from the VBT block 43 indicates which
controller is used for brightness.
LFP1 brightness control method:
Bit 7-4 = This field controller number of the brightnes controller.
0 = Controller 0
1 = Controller 1
2 = Controller 2
3 = Controller 3
Others = Reserved
Bits 3-0 = This field specifies the brightness control pin to be used on the
platform.
0 = PMIC pin is used for brightness control
1 = LPSS PWM is used for brightness control
2 = Display DDI is used for brightness control
3 = CABC method to control brightness
Others = Reserved

Adding the above fields in dev_priv->vbt and corresponding changes in
parse_backlight()

v2: Jani's review comments addressed
	- Move PWM definitions to intel_bios.h
	- Moving vbt_version to intel_vbt_data
	- Rename brightness to bl_ctrl_data
	- Logging just control_pin instead of string
	- Avoid adding vbt_version in dev_priv
	- Since only DDI option is available as of now, let control pin DDI
	affect dev_priv->vbt.backlight.present

v3: Jani's review comments addressed
	- Drop control_pin
	- Use bdb->version
	- set controller to 0 instead of using control pin define
	- check controller bounds
	- remove superfluous changes in intel_parse_bios

Signed-off-by: Deepak M <m.deepak@intel.com>
Signed-off-by: Vandana Kannan <vandana.kannan@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h   |  1 +
 drivers/gpu/drm/i915/intel_bios.c | 20 ++++++++++++++++++++
 drivers/gpu/drm/i915/intel_bios.h | 11 +++++++++++
 3 files changed, 32 insertions(+)

Comments

Daniel Vetter Dec. 15, 2014, 10:20 a.m. UTC | #1
On Mon, Dec 15, 2014 at 03:58:21PM +0530, Vandana Kannan wrote:
> From: Deepak M <m.deepak@intel.com>
> 
> LFP brighness control from the VBT block 43 indicates which
> controller is used for brightness.
> LFP1 brightness control method:
> Bit 7-4 = This field controller number of the brightnes controller.
> 0 = Controller 0
> 1 = Controller 1
> 2 = Controller 2
> 3 = Controller 3
> Others = Reserved
> Bits 3-0 = This field specifies the brightness control pin to be used on the
> platform.
> 0 = PMIC pin is used for brightness control
> 1 = LPSS PWM is used for brightness control
> 2 = Display DDI is used for brightness control
> 3 = CABC method to control brightness
> Others = Reserved
> 
> Adding the above fields in dev_priv->vbt and corresponding changes in
> parse_backlight()
> 
> v2: Jani's review comments addressed
> 	- Move PWM definitions to intel_bios.h
> 	- Moving vbt_version to intel_vbt_data
> 	- Rename brightness to bl_ctrl_data
> 	- Logging just control_pin instead of string
> 	- Avoid adding vbt_version in dev_priv
> 	- Since only DDI option is available as of now, let control pin DDI
> 	affect dev_priv->vbt.backlight.present
> 
> v3: Jani's review comments addressed
> 	- Drop control_pin
> 	- Use bdb->version
> 	- set controller to 0 instead of using control pin define
> 	- check controller bounds
> 	- remove superfluous changes in intel_parse_bios
> 
> Signed-off-by: Deepak M <m.deepak@intel.com>
> Signed-off-by: Vandana Kannan <vandana.kannan@intel.com>
> Reviewed-by: Jani Nikula <jani.nikula@intel.com>

Queued for -next, thanks for the patch.
-Daniel

> ---
>  drivers/gpu/drm/i915/i915_drv.h   |  1 +
>  drivers/gpu/drm/i915/intel_bios.c | 20 ++++++++++++++++++++
>  drivers/gpu/drm/i915/intel_bios.h | 11 +++++++++++
>  3 files changed, 32 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 11e85cb..f4fef28 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -1355,6 +1355,7 @@ struct intel_vbt_data {
>  		bool present;
>  		bool active_low_pwm;
>  		u8 min_brightness;	/* min_brightness/255 of max */
> +		u8 controller;		/* brightness controller number */
>  	} backlight;
>  
>  	/* MIPI DSI */
> diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
> index 3f17825..65b1fbc 100644
> --- a/drivers/gpu/drm/i915/intel_bios.c
> +++ b/drivers/gpu/drm/i915/intel_bios.c
> @@ -314,6 +314,7 @@ parse_lfp_backlight(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
>  {
>  	const struct bdb_lfp_backlight_data *backlight_data;
>  	const struct bdb_lfp_backlight_data_entry *entry;
> +	const struct bdb_lfp_backlight_control_data *bl_ctrl_data;
>  
>  	backlight_data = find_section(bdb, BDB_LVDS_BACKLIGHT);
>  	if (!backlight_data)
> @@ -326,6 +327,7 @@ parse_lfp_backlight(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
>  	}
>  
>  	entry = &backlight_data->data[panel_type];
> +	bl_ctrl_data = &backlight_data->blc_ctl[panel_type];
>  
>  	dev_priv->vbt.backlight.present = entry->type == BDB_BACKLIGHT_TYPE_PWM;
>  	if (!dev_priv->vbt.backlight.present) {
> @@ -337,12 +339,30 @@ parse_lfp_backlight(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
>  	dev_priv->vbt.backlight.pwm_freq_hz = entry->pwm_freq_hz;
>  	dev_priv->vbt.backlight.active_low_pwm = entry->active_low_pwm;
>  	dev_priv->vbt.backlight.min_brightness = entry->min_brightness;
> +
> +	dev_priv->vbt.backlight.controller = 0;
> +	if (bdb->version >= 191) {
> +		dev_priv->vbt.backlight.present =
> +				bl_ctrl_data->pin == BLC_CONTROL_PIN_DDI;
> +		if (!dev_priv->vbt.backlight.present) {
> +			DRM_DEBUG_KMS("BL control pin is not DDI (pin %u)\n",
> +					bl_ctrl_data->pin);
> +			return;
> +		}
> +		if (bl_ctrl_data->controller == 1)
> +			dev_priv->vbt.backlight.controller =
> +				bl_ctrl_data->controller;
> +	}
> +
>  	DRM_DEBUG_KMS("VBT backlight PWM modulation frequency %u Hz, "
>  		      "active %s, min brightness %u, level %u\n",
>  		      dev_priv->vbt.backlight.pwm_freq_hz,
>  		      dev_priv->vbt.backlight.active_low_pwm ? "low" : "high",
>  		      dev_priv->vbt.backlight.min_brightness,
>  		      backlight_data->level[panel_type]);
> +
> +	DRM_DEBUG_KMS("VBT BL controller %u\n",
> +		dev_priv->vbt.backlight.controller);
>  }
>  
>  /* Try to find sdvo panel data */
> diff --git a/drivers/gpu/drm/i915/intel_bios.h b/drivers/gpu/drm/i915/intel_bios.h
> index a6a8710..9a7202e 100644
> --- a/drivers/gpu/drm/i915/intel_bios.h
> +++ b/drivers/gpu/drm/i915/intel_bios.h
> @@ -402,10 +402,21 @@ struct bdb_lfp_backlight_data_entry {
>  	u8 obsolete3;
>  } __packed;
>  
> +#define BLC_CONTROL_PIN_PMIC		0
> +#define BLC_CONTROL_PIN_LPSS_PWM	1
> +#define BLC_CONTROL_PIN_DDI		2
> +#define BLC_CONTROL_PIN_CABC		3
> +
> +struct bdb_lfp_backlight_control_data {
> +	u8 controller:4;
> +	u8 pin:4;
> +} __packed;
> +
>  struct bdb_lfp_backlight_data {
>  	u8 entry_size;
>  	struct bdb_lfp_backlight_data_entry data[16];
>  	u8 level[16];
> +	struct bdb_lfp_backlight_control_data blc_ctl[16];
>  } __packed;
>  
>  struct aimdb_header {
> -- 
> 2.0.1
>
Shuang He Dec. 15, 2014, 3:13 p.m. UTC | #2
Tested-By: PRC QA PRTS (Patch Regression Test System Contact: shuang.he@intel.com)
-------------------------------------Summary-------------------------------------
Platform          Delta          drm-intel-nightly          Series Applied
PNV                                  364/364              364/364
ILK              +5                 360/366              365/366
SNB                                  448/450              448/450
IVB                                  497/498              497/498
BYT                                  289/289              289/289
HSW                                  563/564              563/564
BDW                                  417/417              417/417
-------------------------------------Detailed-------------------------------------
Platform  Test                                drm-intel-nightly          Series Applied
 ILK  igt_drv_suspend_fence-restore-untiled      DMESG_WARN(1, M26)PASS(1, M37)      PASS(1, M37)
 ILK  igt_kms_flip_bcs-flip-vs-modeset-interruptible      DMESG_WARN(1, M26)PASS(1, M37)      PASS(1, M37)
 ILK  igt_kms_flip_busy-flip-interruptible      DMESG_WARN(1, M26)PASS(1, M37)      PASS(1, M37)
 ILK  igt_kms_flip_flip-vs-rmfb-interruptible      DMESG_WARN(1, M26)PASS(1, M37)      PASS(1, M37)
 ILK  igt_kms_flip_rcs-flip-vs-dpms      DMESG_WARN(1, M26)PASS(1, M37)      PASS(1, M37)
Note: You need to pay more attention to line start with '*'
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 11e85cb..f4fef28 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1355,6 +1355,7 @@  struct intel_vbt_data {
 		bool present;
 		bool active_low_pwm;
 		u8 min_brightness;	/* min_brightness/255 of max */
+		u8 controller;		/* brightness controller number */
 	} backlight;
 
 	/* MIPI DSI */
diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
index 3f17825..65b1fbc 100644
--- a/drivers/gpu/drm/i915/intel_bios.c
+++ b/drivers/gpu/drm/i915/intel_bios.c
@@ -314,6 +314,7 @@  parse_lfp_backlight(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
 {
 	const struct bdb_lfp_backlight_data *backlight_data;
 	const struct bdb_lfp_backlight_data_entry *entry;
+	const struct bdb_lfp_backlight_control_data *bl_ctrl_data;
 
 	backlight_data = find_section(bdb, BDB_LVDS_BACKLIGHT);
 	if (!backlight_data)
@@ -326,6 +327,7 @@  parse_lfp_backlight(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
 	}
 
 	entry = &backlight_data->data[panel_type];
+	bl_ctrl_data = &backlight_data->blc_ctl[panel_type];
 
 	dev_priv->vbt.backlight.present = entry->type == BDB_BACKLIGHT_TYPE_PWM;
 	if (!dev_priv->vbt.backlight.present) {
@@ -337,12 +339,30 @@  parse_lfp_backlight(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
 	dev_priv->vbt.backlight.pwm_freq_hz = entry->pwm_freq_hz;
 	dev_priv->vbt.backlight.active_low_pwm = entry->active_low_pwm;
 	dev_priv->vbt.backlight.min_brightness = entry->min_brightness;
+
+	dev_priv->vbt.backlight.controller = 0;
+	if (bdb->version >= 191) {
+		dev_priv->vbt.backlight.present =
+				bl_ctrl_data->pin == BLC_CONTROL_PIN_DDI;
+		if (!dev_priv->vbt.backlight.present) {
+			DRM_DEBUG_KMS("BL control pin is not DDI (pin %u)\n",
+					bl_ctrl_data->pin);
+			return;
+		}
+		if (bl_ctrl_data->controller == 1)
+			dev_priv->vbt.backlight.controller =
+				bl_ctrl_data->controller;
+	}
+
 	DRM_DEBUG_KMS("VBT backlight PWM modulation frequency %u Hz, "
 		      "active %s, min brightness %u, level %u\n",
 		      dev_priv->vbt.backlight.pwm_freq_hz,
 		      dev_priv->vbt.backlight.active_low_pwm ? "low" : "high",
 		      dev_priv->vbt.backlight.min_brightness,
 		      backlight_data->level[panel_type]);
+
+	DRM_DEBUG_KMS("VBT BL controller %u\n",
+		dev_priv->vbt.backlight.controller);
 }
 
 /* Try to find sdvo panel data */
diff --git a/drivers/gpu/drm/i915/intel_bios.h b/drivers/gpu/drm/i915/intel_bios.h
index a6a8710..9a7202e 100644
--- a/drivers/gpu/drm/i915/intel_bios.h
+++ b/drivers/gpu/drm/i915/intel_bios.h
@@ -402,10 +402,21 @@  struct bdb_lfp_backlight_data_entry {
 	u8 obsolete3;
 } __packed;
 
+#define BLC_CONTROL_PIN_PMIC		0
+#define BLC_CONTROL_PIN_LPSS_PWM	1
+#define BLC_CONTROL_PIN_DDI		2
+#define BLC_CONTROL_PIN_CABC		3
+
+struct bdb_lfp_backlight_control_data {
+	u8 controller:4;
+	u8 pin:4;
+} __packed;
+
 struct bdb_lfp_backlight_data {
 	u8 entry_size;
 	struct bdb_lfp_backlight_data_entry data[16];
 	u8 level[16];
+	struct bdb_lfp_backlight_control_data blc_ctl[16];
 } __packed;
 
 struct aimdb_header {