Merge tag 'drm-misc-next-2020-02-10' of git://anongit.freedesktop.org/drm/drm-misc...
[sfrench/cifs-2.6.git] / drivers / gpu / drm / drm_dp_helper.c
index f629fc5494a435873fe01b3e21d0e0cd131cf992..5a103e9b3c86d8ab04f6bf4280e1a95465d17f07 100644 (file)
@@ -32,6 +32,7 @@
 #include <drm/drm_dp_helper.h>
 #include <drm/drm_print.h>
 #include <drm/drm_vblank.h>
+#include <drm/drm_dp_mst_helper.h>
 
 #include "drm_crtc_helper_internal.h"
 
@@ -266,7 +267,7 @@ unlock:
 
 /**
  * drm_dp_dpcd_read() - read a series of bytes from the DPCD
- * @aux: DisplayPort AUX channel
+ * @aux: DisplayPort AUX channel (SST or MST)
  * @offset: address of the (first) register to read
  * @buffer: buffer to store the register values
  * @size: number of bytes in @buffer
@@ -295,13 +296,18 @@ ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset,
         * We just have to do it before any DPCD access and hope that the
         * monitor doesn't power down exactly after the throw away read.
         */
-       ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, DP_DPCD_REV, buffer,
-                                1);
-       if (ret != 1)
-               goto out;
+       if (!aux->is_remote) {
+               ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, DP_DPCD_REV,
+                                        buffer, 1);
+               if (ret != 1)
+                       goto out;
+       }
 
-       ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, offset, buffer,
-                                size);
+       if (aux->is_remote)
+               ret = drm_dp_mst_dpcd_read(aux, offset, buffer, size);
+       else
+               ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, offset,
+                                        buffer, size);
 
 out:
        drm_dp_dump_access(aux, DP_AUX_NATIVE_READ, offset, buffer, ret);
@@ -311,7 +317,7 @@ EXPORT_SYMBOL(drm_dp_dpcd_read);
 
 /**
  * drm_dp_dpcd_write() - write a series of bytes to the DPCD
- * @aux: DisplayPort AUX channel
+ * @aux: DisplayPort AUX channel (SST or MST)
  * @offset: address of the (first) register to write
  * @buffer: buffer containing the values to write
  * @size: number of bytes in @buffer
@@ -328,8 +334,12 @@ ssize_t drm_dp_dpcd_write(struct drm_dp_aux *aux, unsigned int offset,
 {
        int ret;
 
-       ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_WRITE, offset, buffer,
-                                size);
+       if (aux->is_remote)
+               ret = drm_dp_mst_dpcd_write(aux, offset, buffer, size);
+       else
+               ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_WRITE, offset,
+                                        buffer, size);
+
        drm_dp_dump_access(aux, DP_AUX_NATIVE_WRITE, offset, buffer, ret);
        return ret;
 }
@@ -967,6 +977,19 @@ static void drm_dp_aux_crc_work(struct work_struct *work)
        }
 }
 
+/**
+ * drm_dp_remote_aux_init() - minimally initialise a remote aux channel
+ * @aux: DisplayPort AUX channel
+ *
+ * Used for remote aux channel in general. Merely initialize the crc work
+ * struct.
+ */
+void drm_dp_remote_aux_init(struct drm_dp_aux *aux)
+{
+       INIT_WORK(&aux->crc_work, drm_dp_aux_crc_work);
+}
+EXPORT_SYMBOL(drm_dp_remote_aux_init);
+
 /**
  * drm_dp_aux_init() - minimally initialise an aux channel
  * @aux: DisplayPort AUX channel
@@ -1154,6 +1177,8 @@ static const struct dpcd_quirk dpcd_quirk_list[] = {
        { OUI(0x00, 0x10, 0xfa), DEVICE_ID_ANY, false, BIT(DP_DPCD_QUIRK_NO_PSR) },
        /* CH7511 seems to leave SINK_COUNT zeroed */
        { OUI(0x00, 0x00, 0x00), DEVICE_ID('C', 'H', '7', '5', '1', '1'), false, BIT(DP_DPCD_QUIRK_NO_SINK_COUNT) },
+       /* Synaptics DP1.4 MST hubs can support DSC without virtual DPCD */
+       { OUI(0x90, 0xCC, 0x24), DEVICE_ID_ANY, true, BIT(DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD) },
 };
 
 #undef OUI