static int dsi_vc_write_common(struct intel_dsi *intel_dsi, int channel, const u8 *data, int len, enum dsi_type type) { int ret; if (len == 0) { BUG_ON(type == DSI_GENERIC); ret = dsi_vc_send_short(intel_dsi, channel, MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM, 0); } else if (len == 1) { ret = dsi_vc_send_short(intel_dsi, channel, type == DSI_GENERIC ? MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM : MIPI_DSI_DCS_SHORT_WRITE, data[0]); } else if (len == 2) { ret = dsi_vc_send_short(intel_dsi, channel, type == DSI_GENERIC ? MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM : MIPI_DSI_DCS_SHORT_WRITE_PARAM, (data[1] << 8) | data[0]); } else { ret = dsi_vc_send_long(intel_dsi, channel, type == DSI_GENERIC ? MIPI_DSI_GENERIC_LONG_WRITE : MIPI_DSI_DCS_LONG_WRITE, data, len); } return ret; }
static int dsi_vc_generic_send_read_request(struct intel_dsi *intel_dsi, int channel, u8 *reqdata, int reqlen) { u16 data = 0; u8 data_type = 0; switch (reqlen) { case 0: data_type = MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM; data = 0; break; case 1: data_type = MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM; data = reqdata[0]; break; case 2: data_type = MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM; data = (reqdata[1] << 8) | reqdata[0]; break; default: BUG(); } return dsi_vc_send_short(intel_dsi, channel, data_type, data); }
static int dsi_vc_send_long(struct intel_dsi *intel_dsi, int channel, u8 data_type, const u8 *data, int len) { struct drm_encoder *encoder = &intel_dsi->base.base; struct drm_device *dev = encoder->dev; struct drm_i915_private *dev_priv = dev->dev_private; struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); enum pipe pipe = intel_crtc->pipe; u32 data_reg; int i, j, n; u32 mask; DRM_DEBUG_KMS("channel %d, data_type %d, len %04x\n", channel, data_type, len); if (intel_dsi->hs) { data_reg = MIPI_HS_GEN_DATA(pipe); mask = HS_DATA_FIFO_FULL; } else { data_reg = MIPI_LP_GEN_DATA(pipe); mask = LP_DATA_FIFO_FULL; } if (wait_for((I915_READ(MIPI_GEN_FIFO_STAT(pipe)) & mask) == 0, 50)) DRM_ERROR("Timeout waiting for HS/LP DATA FIFO !full\n"); for (i = 0; i < len; i += n) { u32 val = 0; n = min_t(int, len - i, 4); for (j = 0; j < n; j++) val |= *data++ << 8 * j; I915_WRITE(data_reg, val); /* XXX: check for data fifo full, once that is set, write 4 * dwords, then wait for not set, then continue. */ } return dsi_vc_send_short(intel_dsi, channel, data_type, len); }
static int dsi_vc_dcs_send_read_request(struct intel_dsi *intel_dsi, int channel, u8 dcs_cmd) { return dsi_vc_send_short(intel_dsi, channel, MIPI_DSI_DCS_READ, dcs_cmd); }