1 // SPDX-License-Identifier: MIT
3 * Copyright © 2018 Intel Corporation
6 #include <drm/drm_mipi_dsi.h>
9 int intel_dsi_bitrate(const struct intel_dsi *intel_dsi)
11 int bpp = mipi_dsi_pixel_format_to_bpp(intel_dsi->pixel_format);
16 return intel_dsi->pclk * bpp / intel_dsi->lane_count;
19 int intel_dsi_tlpx_ns(const struct intel_dsi *intel_dsi)
21 switch (intel_dsi->escape_clk_div) {
32 int intel_dsi_get_modes(struct drm_connector *connector)
34 struct intel_connector *intel_connector = to_intel_connector(connector);
35 struct drm_display_mode *mode;
39 if (!intel_connector->panel.fixed_mode) {
40 DRM_DEBUG_KMS("no fixed mode\n");
44 mode = drm_mode_duplicate(connector->dev,
45 intel_connector->panel.fixed_mode);
47 DRM_DEBUG_KMS("drm_mode_duplicate failed\n");
51 drm_mode_probed_add(connector, mode);
55 enum drm_mode_status intel_dsi_mode_valid(struct drm_connector *connector,
56 struct drm_display_mode *mode)
58 struct intel_connector *intel_connector = to_intel_connector(connector);
59 const struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
60 int max_dotclk = to_i915(connector->dev)->max_dotclk_freq;
64 if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
65 return MODE_NO_DBLESCAN;
68 if (mode->hdisplay > fixed_mode->hdisplay)
70 if (mode->vdisplay > fixed_mode->vdisplay)
72 if (fixed_mode->clock > max_dotclk)
73 return MODE_CLOCK_HIGH;
79 struct intel_dsi_host *intel_dsi_host_init(struct intel_dsi *intel_dsi,
80 const struct mipi_dsi_host_ops *funcs,
83 struct intel_dsi_host *host;
84 struct mipi_dsi_device *device;
86 host = kzalloc(sizeof(*host), GFP_KERNEL);
90 host->base.ops = funcs;
91 host->intel_dsi = intel_dsi;
95 * We should call mipi_dsi_host_register(&host->base) here, but we don't
96 * have a host->dev, and we don't have OF stuff either. So just use the
97 * dsi framework as a library and hope for the best. Create the dsi
98 * devices by ourselves here too. Need to be careful though, because we
99 * don't initialize any of the driver model devices here.
101 device = kzalloc(sizeof(*device), GFP_KERNEL);
107 device->host = &host->base;
108 host->device = device;
113 enum drm_panel_orientation
114 intel_dsi_get_panel_orientation(struct intel_connector *connector)
116 struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
117 enum drm_panel_orientation orientation;
119 orientation = dev_priv->vbt.dsi.orientation;
120 if (orientation != DRM_MODE_PANEL_ORIENTATION_UNKNOWN)
123 orientation = dev_priv->vbt.orientation;
124 if (orientation != DRM_MODE_PANEL_ORIENTATION_UNKNOWN)
127 return DRM_MODE_PANEL_ORIENTATION_NORMAL;