drm/rockchip: add rk3399 vop big csc support
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / drm / i915 / intel_display.c
index a95445fc46d61a37eb691139f26817894cd74ba0..6f2502e16ecc6257314caadce86d640761adf76e 100644 (file)
@@ -2950,13 +2950,13 @@ u32 intel_fb_stride_alignment(struct drm_device *dev, uint64_t fb_modifier,
        }
 }
 
-unsigned long intel_plane_obj_offset(struct intel_plane *intel_plane,
-                                    struct drm_i915_gem_object *obj,
-                                    unsigned int plane)
+u32 intel_plane_obj_offset(struct intel_plane *intel_plane,
+                          struct drm_i915_gem_object *obj,
+                          unsigned int plane)
 {
        const struct i915_ggtt_view *view = &i915_ggtt_view_normal;
        struct i915_vma *vma;
-       unsigned char *offset;
+       u64 offset;
 
        if (intel_rotation_90_or_270(intel_plane->base.state->rotation))
                view = &i915_ggtt_view_rotated;
@@ -2966,14 +2966,16 @@ unsigned long intel_plane_obj_offset(struct intel_plane *intel_plane,
                view->type))
                return -1;
 
-       offset = (unsigned char *)vma->node.start;
+       offset = vma->node.start;
 
        if (plane == 1) {
                offset += vma->ggtt_view.rotation_info.uv_start_page *
                          PAGE_SIZE;
        }
 
-       return (unsigned long)offset;
+       WARN_ON(upper_32_bits(offset));
+
+       return lower_32_bits(offset);
 }
 
 static void skl_detach_scaler(struct intel_crtc *intel_crtc, int id)
@@ -3099,7 +3101,7 @@ static void skylake_update_primary_plane(struct drm_crtc *crtc,
        u32 tile_height, plane_offset, plane_size;
        unsigned int rotation;
        int x_offset, y_offset;
-       unsigned long surf_addr;
+       u32 surf_addr;
        struct intel_crtc_state *crtc_state = intel_crtc->config;
        struct intel_plane_state *plane_state;
        int src_x = 0, src_y = 0, src_w = 0, src_h = 0;
@@ -13719,7 +13721,7 @@ static struct drm_plane *intel_primary_plane_create(struct drm_device *dev,
        drm_universal_plane_init(dev, &primary->base, 0,
                                 &intel_plane_funcs,
                                 intel_primary_formats, num_formats,
-                                DRM_PLANE_TYPE_PRIMARY);
+                                DRM_PLANE_TYPE_PRIMARY, NULL);
 
        if (INTEL_INFO(dev)->gen >= 4)
                intel_create_rotation_property(dev, primary);
@@ -13871,7 +13873,7 @@ static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev,
                                 &intel_plane_funcs,
                                 intel_cursor_formats,
                                 ARRAY_SIZE(intel_cursor_formats),
-                                DRM_PLANE_TYPE_CURSOR);
+                                DRM_PLANE_TYPE_CURSOR, NULL);
 
        if (INTEL_INFO(dev)->gen >= 4) {
                if (!dev->mode_config.rotation_property)
@@ -13948,7 +13950,7 @@ static void intel_crtc_init(struct drm_device *dev, int pipe)
                goto fail;
 
        ret = drm_crtc_init_with_planes(dev, &intel_crtc->base, primary,
-                                       cursor, &intel_crtc_funcs);
+                                       cursor, &intel_crtc_funcs, NULL);
        if (ret)
                goto fail;
 
@@ -14160,7 +14162,7 @@ static void intel_setup_outputs(struct drm_device *dev)
                if (I915_READ(PCH_DP_D) & DP_DETECTED)
                        intel_dp_init(dev, PCH_DP_D, PORT_D);
        } else if (IS_VALLEYVIEW(dev)) {
-               bool has_edp;
+               bool has_edp, has_port;
 
                /*
                 * The DP_DETECTED bit is the latched state of the DDC
@@ -14170,25 +14172,37 @@ static void intel_setup_outputs(struct drm_device *dev)
                 * Thus we can't rely on the DP_DETECTED bit alone to detect
                 * eDP ports. Consult the VBT as well as DP_DETECTED to
                 * detect eDP ports.
+                *
+                * Sadly the straps seem to be missing sometimes even for HDMI
+                * ports (eg. on Voyo V3 - CHT x7-Z8700), so check both strap
+                * and VBT for the presence of the port. Additionally we can't
+                * trust the port type the VBT declares as we've seen at least
+                * HDMI ports that the VBT claim are DP or eDP.
                 */
                has_edp = intel_dp_is_edp(dev, PORT_B);
-               if (I915_READ(VLV_DP_B) & DP_DETECTED || has_edp)
+               has_port = intel_bios_is_port_present(dev_priv, PORT_B);
+               if (I915_READ(VLV_DP_B) & DP_DETECTED || has_port)
                        has_edp &= intel_dp_init(dev, VLV_DP_B, PORT_B);
-               if (I915_READ(VLV_HDMIB) & SDVO_DETECTED && !has_edp)
+               if ((I915_READ(VLV_HDMIB) & SDVO_DETECTED || has_port) && !has_edp)
                        intel_hdmi_init(dev, VLV_HDMIB, PORT_B);
 
                has_edp = intel_dp_is_edp(dev, PORT_C);
-               if (I915_READ(VLV_DP_C) & DP_DETECTED || has_edp)
+               has_port = intel_bios_is_port_present(dev_priv, PORT_C);
+               if (I915_READ(VLV_DP_C) & DP_DETECTED || has_port)
                        has_edp &= intel_dp_init(dev, VLV_DP_C, PORT_C);
-               if (I915_READ(VLV_HDMIC) & SDVO_DETECTED && !has_edp)
+               if ((I915_READ(VLV_HDMIC) & SDVO_DETECTED || has_port) && !has_edp)
                        intel_hdmi_init(dev, VLV_HDMIC, PORT_C);
 
                if (IS_CHERRYVIEW(dev)) {
-                       /* eDP not supported on port D, so don't check VBT */
-                       if (I915_READ(CHV_HDMID) & SDVO_DETECTED)
-                               intel_hdmi_init(dev, CHV_HDMID, PORT_D);
-                       if (I915_READ(CHV_DP_D) & DP_DETECTED)
+                       /*
+                        * eDP not supported on port D,
+                        * so no need to worry about it
+                        */
+                       has_port = intel_bios_is_port_present(dev_priv, PORT_D);
+                       if (I915_READ(CHV_DP_D) & DP_DETECTED || has_port)
                                intel_dp_init(dev, CHV_DP_D, PORT_D);
+                       if (I915_READ(CHV_HDMID) & SDVO_DETECTED || has_port)
+                               intel_hdmi_init(dev, CHV_HDMID, PORT_D);
                }
 
                intel_dsi_init(dev);