Skip to contentSkip to conversation

drm/i915: Add Backlight Control using DPCD for eDP connectors (v4)

PATCH New Yetunde Adebisi 2 participants 2 messages Dec 15, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915: Add Backlight Control using DPCD for eDP connectors (v4)

This patch adds support for eDP backlight control using DPCD registers to backlight hooks in intel_panel.

It checks for backlight control over AUX channel capability and sets up function pointers to get and set the backlight brightness level if supported.

v2: Moved backlight functions from intel_dp.c into a new file intel_dp_aux_backlight.c. Also moved reading of eDP display control registers to intel_dp_get_dpcd

v3: Correct some formatting mistakes

v4: Updated to use AUX backlight control if PWM control is not possible (Jani)

This patch depends on http://patchwork.freedesktop.org/patch/64253/

---
 drivers/gpu/drm/i915/Makefile                 |   1 +
 drivers/gpu/drm/i915/intel_dp.c               |  17 ++-
 drivers/gpu/drm/i915/intel_dp_aux_backlight.c | 180 ++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_drv.h              |   6 +
 drivers/gpu/drm/i915/intel_panel.c            |   4 +
 5 files changed, 202 insertions(+), 6 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_dp_aux_backlight.c
drivers/gpu/drm/i915/Makefile +1 -0
index 0851de07..41250cc 100644
@@ -77,6 +77,7 @@ i915-y += dvo_ch7017.o \
 	  dvo_tfp410.o \
 	  intel_crt.o \
 	  intel_ddi.o \
+	  intel_dp_aux_backlight.o \
 	  intel_dp_link_training.o \
 	  intel_dp_mst.o \
 	  intel_dp.o \
drivers/gpu/drm/i915/intel_dp.c +11 -6
index 8071247..bd40d33 100644
@@ -3156,7 +3156,7 @@ static void chv_dp_post_pll_disable(struct intel_encoder *encoder)
  * Sinks are *supposed* to come up within 1ms from an off state, but we're also
  * supposed to retry 3 times per the spec.
  */
-static ssize_t
+ssize_t
 intel_dp_dpcd_read_wake(struct drm_dp_aux *aux, unsigned int offset,
 			void *buffer, size_t size)
 {
@@ -3823,7 +3823,6 @@ intel_dp_get_dpcd(struct intel_dp *intel_dp)
 	struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
 	struct drm_device *dev = dig_port->base.base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	uint8_t rev;
 
 	if (intel_dp_dpcd_read_wake(&intel_dp->aux, 0x000, intel_dp->dpcd,
 				    sizeof(intel_dp->dpcd)) < 0)
@@ -3859,6 +3858,15 @@ intel_dp_get_dpcd(struct intel_dp *intel_dp)
 			DRM_DEBUG_KMS("PSR2 %s on sink",
 				dev_priv->psr.psr2_support ? "supported" : "not supported");
 		}
+
+		/* Read the eDP Display control capabilities registers */
+		memset(intel_dp->edp_dpcd, 0, sizeof(intel_dp->edp_dpcd));
+		if ((intel_dp->dpcd[DP_EDP_CONFIGURATION_CAP] & DP_DPCD_DISPLAY_CONTROL_CAPABLE) &&
+				(intel_dp_dpcd_read_wake(&intel_dp->aux, DP_EDP_DPCD_REV,
+						intel_dp->edp_dpcd, sizeof(intel_dp->edp_dpcd)) ==
+								sizeof(intel_dp->edp_dpcd)))
+			DRM_DEBUG_KMS("EDP DPCD : %*ph\n", (int) sizeof(intel_dp->edp_dpcd),
+					intel_dp->edp_dpcd);
 	}
 
 	DRM_DEBUG_KMS("Display Port TPS3 support: source %s, sink %s\n",
@@ -3866,10 +3874,7 @@ intel_dp_get_dpcd(struct intel_dp *intel_dp)
 		      yesno(drm_dp_tps3_supported(intel_dp->dpcd)));
 
 	/* Intermediate frequency support */
-	if (is_edp(intel_dp) &&
-	    (intel_dp->dpcd[DP_EDP_CONFIGURATION_CAP] &	DP_DPCD_DISPLAY_CONTROL_CAPABLE) &&
-	    (intel_dp_dpcd_read_wake(&intel_dp->aux, DP_EDP_DPCD_REV, &rev, 1) == 1) &&
-	    (rev >= 0x03)) { /* eDp v1.4 or higher */
+	if (is_edp(intel_dp) && (intel_dp->edp_dpcd[0] >= 0x03)) { /* eDp v1.4 or higher */
 		__le16 sink_rates[DP_MAX_SUPPORTED_RATES];
 		int i;
 
drivers/gpu/drm/i915/intel_dp_aux_backlight.c new file +180 -0

180 lines not on this page · raw message

drivers/gpu/drm/i915/intel_drv.h +6 -0
index 78ea023..eb271d5 100644
@@ -756,6 +756,7 @@ struct intel_dp {
 	uint8_t dpcd[DP_RECEIVER_CAP_SIZE];
 	uint8_t psr_dpcd[EDP_PSR_RECEIVER_CAP_SIZE];
 	uint8_t downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
+	uint8_t edp_dpcd[EDP_DISPLAY_CTL_CAP_SIZE];
 	/* sink rates as reported by DP_SUPPORTED_LINK_RATES */
 	uint8_t num_sink_rates;
 	int sink_rates[DP_MAX_SUPPORTED_RATES];
@@ -1277,6 +1278,11 @@ void intel_dp_compute_rate(struct intel_dp *intel_dp, int port_clock,
 bool intel_dp_source_supports_hbr2(struct intel_dp *intel_dp);
 bool
 intel_dp_get_link_status(struct intel_dp *intel_dp, uint8_t link_status[DP_LINK_STATUS_SIZE]);
+ssize_t intel_dp_dpcd_read_wake(struct drm_dp_aux *aux, unsigned int offset,
+		void *buffer, size_t size);
+
+/* intel_dp_aux_backlight.c */
+int intel_dp_aux_init_backlight_funcs(struct intel_connector *intel_connector);
 
 /* intel_dp_mst.c */
 int intel_dp_mst_encoder_init(struct intel_digital_port *intel_dig_port, int conn_id);
drivers/gpu/drm/i915/intel_panel.c +4 -0
index a24df35..7da49b5 100644
@@ -1744,6 +1744,10 @@ intel_panel_init_backlight_funcs(struct intel_panel *panel)
 	struct drm_device *dev = intel_connector->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 
+	if (intel_connector->base.connector_type == DRM_MODE_CONNECTOR_eDP &&
+			intel_dp_aux_init_backlight_funcs(intel_connector) == 0)
+		return;
+
 	if (IS_BROXTON(dev)) {
 		panel->backlight.setup = bxt_setup_backlight;
 		panel->backlight.enable = bxt_enable_backlight;
Signature · 6 lines
1.9.3

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw
reproduce:

Hi Yetunde,

[auto build test ERROR on drm-intel/for-linux-next] [also build test ERROR on next-20151215] [cannot apply to v4.4-rc5]

url:    https://github.com/0day-ci/linux/commits/Yetunde-Adebisi/drm-i915-Add-Backlight-Control-using-DPCD-for-eDP-connectors-v4/20151216-030252
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: x86_64-randconfig-x013-12141150 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

drivers/gpu/drm/i915/i915_drv.c:247:9: sparse: Initializer entry defined twice
drivers/gpu/drm/i915/i915_drv.c:249:10: also defined here
drivers/gpu/drm/i915/i915_drv.c:278:9: sparse: Initializer entry defined twice
drivers/gpu/drm/i915/i915_drv.c:278:9: also defined here
drivers/gpu/drm/i915/i915_drv.c:283:9: sparse: Initializer entry defined twice
drivers/gpu/drm/i915/i915_drv.c:283:9: also defined here
drivers/gpu/drm/i915/i915_drv.c:289:9: sparse: Initializer entry defined twice
drivers/gpu/drm/i915/i915_drv.c:290:10: also defined here
drivers/gpu/drm/i915/i915_drv.c:294:9: sparse: Initializer entry defined twice
drivers/gpu/drm/i915/i915_drv.c:295:10: also defined here
drivers/gpu/drm/i915/i915_drv.c:299:9: sparse: Initializer entry defined twice
drivers/gpu/drm/i915/i915_drv.c:300:10: also defined here
drivers/gpu/drm/i915/i915_drv.c:305:9: sparse: Initializer entry defined twice
drivers/gpu/drm/i915/i915_drv.c:306:10: also defined here
drivers/gpu/drm/i915/i915_drv.c:321:9: sparse: Initializer entry defined twice
drivers/gpu/drm/i915/i915_drv.c:323:10: also defined here
drivers/gpu/drm/i915/i915_drv.c:327:9: sparse: Initializer entry defined twice
drivers/gpu/drm/i915/i915_drv.c:329:10: also defined here
drivers/gpu/drm/i915/i915_drv.c:348:9: sparse: Initializer entry defined twice
drivers/gpu/drm/i915/i915_drv.c:351:10: also defined here
drivers/gpu/drm/i915/i915_drv.c:355:9: sparse: Initializer entry defined twice
drivers/gpu/drm/i915/i915_drv.c:358:10: also defined here
In file included from drivers/gpu/drm/i915/i915_trace.h:10:0,

                    from drivers/gpu/drm/i915/i915_drv.h:2646,
                    from drivers/gpu/drm/i915/i915_drv.c:34:
>> drivers/gpu/drm/i915/intel_drv.h:756:19: error: 'EDP_DISPLAY_CTL_CAP_SIZE' undeclared here (not in a function)
     uint8_t edp_dpcd[EDP_DISPLAY_CTL_CAP_SIZE];
                      ^
--
   In file included from drivers/gpu/drm/i915/i915_trace.h:10:0,
                    from drivers/gpu/drm/i915/i915_drv.h:2646,
                    from drivers/gpu/drm/i915/i915_irq.c:36:
>> drivers/gpu/drm/i915/intel_drv.h:756:19: error: 'EDP_DISPLAY_CTL_CAP_SIZE' undeclared here (not in a function)
     uint8_t edp_dpcd[EDP_DISPLAY_CTL_CAP_SIZE];
                      ^

--
drivers/gpu/drm/i915/intel_drv.h:756:26: sparse: undefined identifier 'EDP_DISPLAY_CTL_CAP_SIZE' drivers/gpu/drm/i915/intel_drv.h:756:26: sparse: bad constant expression type
In file included from drivers/gpu/drm/i915/i915_trace.h:10:0,

                    from drivers/gpu/drm/i915/i915_drv.h:2646,
                    from drivers/gpu/drm/i915/intel_runtime_pm.c:32:
>> drivers/gpu/drm/i915/intel_drv.h:756:19: error: 'EDP_DISPLAY_CTL_CAP_SIZE' undeclared here (not in a function)
     uint8_t edp_dpcd[EDP_DISPLAY_CTL_CAP_SIZE];
                      ^

--
drivers/gpu/drm/i915/intel_ringbuffer.c:1987:31: sparse: incorrect type in argument 1 (different address spaces)
drivers/gpu/drm/i915/intel_ringbuffer.c:1987:31: expected void const *addr
drivers/gpu/drm/i915/intel_ringbuffer.c:1987:31: got void [noderef] <asn:2>*virtual_start
drivers/gpu/drm/i915/intel_ringbuffer.c:2033:40: sparse: incorrect type in assignment (different address spaces)
drivers/gpu/drm/i915/intel_ringbuffer.c:2033:40: expected void [noderef] <asn:2>*virtual_start
drivers/gpu/drm/i915/intel_ringbuffer.c:2033:40: got unsigned int [usertype] *
In file included from drivers/gpu/drm/i915/i915_trace.h:10:0,

                    from drivers/gpu/drm/i915/i915_drv.h:2646,
                    from drivers/gpu/drm/i915/intel_ringbuffer.c:32:
>> drivers/gpu/drm/i915/intel_drv.h:756:19: error: 'EDP_DISPLAY_CTL_CAP_SIZE' undeclared here (not in a function)
     uint8_t edp_dpcd[EDP_DISPLAY_CTL_CAP_SIZE];
                      ^

--
drivers/gpu/drm/i915/intel_drv.h:756:26: sparse: undefined identifier 'EDP_DISPLAY_CTL_CAP_SIZE' drivers/gpu/drm/i915/intel_drv.h:756:26: sparse: bad constant expression type drivers/gpu/drm/i915/intel_dp.c:3895:47: sparse: cannot size expression drivers/gpu/drm/i915/intel_dp.c:3898:69: sparse: cannot size expression drivers/gpu/drm/i915/intel_dp.c:3899:65: sparse: cannot size expression drivers/gpu/drm/i915/intel_dp.c:3900:25: sparse: cannot size expression
In file included from drivers/gpu/drm/i915/intel_dp.c:38:0:

>> drivers/gpu/drm/i915/intel_drv.h:756:19: error: 'EDP_DISPLAY_CTL_CAP_SIZE' undeclared here (not in a function)
     uint8_t edp_dpcd[EDP_DISPLAY_CTL_CAP_SIZE];
                      ^
--
   drivers/gpu/drm/i915/i915_dma.c:682:31: sparse: Variable length array is used.
   In file included from drivers/gpu/drm/i915/i915_dma.c:35:0:
>> drivers/gpu/drm/i915/intel_drv.h:756:19: error: 'EDP_DISPLAY_CTL_CAP_SIZE' undeclared here (not in a function)
     uint8_t edp_dpcd[EDP_DISPLAY_CTL_CAP_SIZE];
                      ^

vim +/EDP_DISPLAY_CTL_CAP_SIZE +756 drivers/gpu/drm/i915/intel_drv.h

750 enum hdmi_force_audio force_audio;
751 bool limited_color_range;
752 bool color_range_auto;
753 uint8_t dpcd[DP_RECEIVER_CAP_SIZE];
754 uint8_t psr_dpcd[EDP_PSR_RECEIVER_CAP_SIZE];
755 uint8_t downstream_ports[DP_MAX_DOWNSTREAM_PORTS];

 > 756		uint8_t edp_dpcd[EDP_DISPLAY_CTL_CAP_SIZE];

757 /* sink rates as reported by DP_SUPPORTED_LINK_RATES */
758 uint8_t num_sink_rates;
759 int sink_rates[DP_MAX_SUPPORTED_RATES];

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx