[Intel-gfx] [PATCH 5/5] CABC support for Panel PWM backlight control
Deepak M
m.deepak at intel.com
Mon Mar 28 09:40:42 UTC 2016
In CABC (Content Adaptive Brightness Control) content grey level
scale can be increased while simultaneously decreasing
brightness of the backlight to achieve same perceived brightness.
The CABC is not standardized and panel vendors are free to follow
their implementation. The CABC implementaion here assumes that the
panels use standard SW register for control.
CABC is supported only when the PWM source for backlight is
from the panel.
Signed-off-by: Deepak M <m.deepak at intel.com>
---
drivers/gpu/drm/i915/intel_dsi.c | 19 +++++++++++++++++++
drivers/gpu/drm/i915/intel_dsi.h | 3 +++
drivers/gpu/drm/i915/intel_dsi_panel_pwm.c | 30 ++++++++++++++++++++++++++++++
3 files changed, 52 insertions(+)
diff --git a/drivers/gpu/drm/i915/intel_dsi.c b/drivers/gpu/drm/i915/intel_dsi.c
index 1ba757a..a7b2949 100644
--- a/drivers/gpu/drm/i915/intel_dsi.c
+++ b/drivers/gpu/drm/i915/intel_dsi.c
@@ -1229,9 +1229,28 @@ void intel_dsi_init(struct drm_device *dev)
default:
intel_dsi->panel_pwm_dcs_ports = BIT(PORT_A) | BIT(PORT_C);
}
+
+ /*
+ * Based on the VBT value assign the ports on
+ * which CABC ON/OFF comands needs to be sent
+ */
+ switch (dev_priv->vbt.dsi.config->dl_cabc_ports) {
+ case CABC_PORT_A:
+ intel_dsi->cabc_dcs_ports = BIT(PORT_A);
+ break;
+ case CABC_PORT_C:
+ intel_dsi->cabc_dcs_ports = BIT(PORT_C);
+ break;
+ case CABC_PORT_A_AND_C:
+ intel_dsi->cabc_dcs_ports = BIT(PORT_A) | BIT(PORT_C);
+ break;
+ default:
+ intel_dsi->cabc_dcs_ports = BIT(PORT_A) | BIT(PORT_C);
+ }
} else {
intel_dsi->ports = BIT(port);
intel_dsi->panel_pwm_dcs_ports = BIT(port);
+ intel_dsi->cabc_dcs_ports = BIT(port);
}
/* Create a DSI host (and a device) for each port. */
diff --git a/drivers/gpu/drm/i915/intel_dsi.h b/drivers/gpu/drm/i915/intel_dsi.h
index dcd2265..322eebd 100644
--- a/drivers/gpu/drm/i915/intel_dsi.h
+++ b/drivers/gpu/drm/i915/intel_dsi.h
@@ -37,6 +37,9 @@
#define PANEL_PWM_PORT_A 0x00
#define PANEL_PWM_PORT_C 0x01
#define PANEL_PWM_PORT_A_AND_C 0x02
+#define CABC_PORT_A 0x00
+#define CABC_PORT_C 0x01
+#define CABC_PORT_A_AND_C 0x02
struct intel_dsi_host;
diff --git a/drivers/gpu/drm/i915/intel_dsi_panel_pwm.c b/drivers/gpu/drm/i915/intel_dsi_panel_pwm.c
index 4d7f0eb..5417f80 100644
--- a/drivers/gpu/drm/i915/intel_dsi_panel_pwm.c
+++ b/drivers/gpu/drm/i915/intel_dsi_panel_pwm.c
@@ -33,6 +33,11 @@
#define PANEL_PWM_DISP_DIMMING (1 << 3)
#define PANEL_PWM_BCTRL (1 << 5)
+#define CABC_OFF (0 << 0)
+#define CABC_USER_INTERFACE_IMAGE (1 << 0)
+#define CABC_STILL_PICTURE (2 << 0)
+#define CABC_VIDEO_MODE (3 << 0)
+
#define PANEL_PWM_MAX_VALUE 0xFF
static u32 panel_pwm_get_backlight(struct intel_connector *connector)
@@ -81,6 +86,8 @@ static void panel_pwm_set_backlight(struct intel_connector *connector, u32 level
static void panel_pwm_disable_backlight(struct intel_connector *connector)
{
+ struct drm_device *dev = connector->base.dev;
+ struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_encoder *encoder = connector->encoder;
struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
struct mipi_dsi_device *dsi_device;
@@ -89,6 +96,16 @@ static void panel_pwm_disable_backlight(struct intel_connector *connector)
panel_pwm_set_backlight(connector, 0);
+ if (dev_priv->vbt.dsi.config->cabc_supported) {
+ data = 0;
+ for_each_dsi_port(port, intel_dsi->cabc_dcs_ports) {
+ dsi_device = intel_dsi->dsi_hosts[port]->device;
+ data = CABC_OFF;
+ mipi_dsi_dcs_write(dsi_device, MIPI_DCS_WRITE_POWER_SAVE,
+ &data, sizeof(data));
+ }
+ }
+
for_each_dsi_port(port, intel_dsi->panel_pwm_dcs_ports) {
dsi_device = intel_dsi->dsi_hosts[port]->device;
data &= ~PANEL_PWM_BKL_EN; /* Turn Off Backlight */
@@ -101,6 +118,8 @@ static void panel_pwm_disable_backlight(struct intel_connector *connector)
static void panel_pwm_enable_backlight(struct intel_connector *connector)
{
+ struct drm_device *dev = connector->base.dev;
+ struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_encoder *encoder = connector->encoder;
struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
struct intel_panel *panel = &connector->panel;
@@ -117,6 +136,17 @@ static void panel_pwm_enable_backlight(struct intel_connector *connector)
&data, sizeof(data));
}
+ if (dev_priv->vbt.dsi.config->cabc_supported) {
+ data = 0;
+ for_each_dsi_port(port, intel_dsi->cabc_dcs_ports) {
+ dsi_device = intel_dsi->dsi_hosts[port]->device;
+ /* Enabling CABC in still mode */
+ data = CABC_STILL_PICTURE;
+ mipi_dsi_dcs_write(dsi_device, MIPI_DCS_WRITE_POWER_SAVE,
+ &data, sizeof(data));
+ }
+ }
+
panel_pwm_set_backlight(connector, panel->backlight.level);
}
--
1.9.1
More information about the Intel-gfx
mailing list