static void crtc_invalid_params(struct kms_atomic_crtc_state *crtc_old,
				struct kms_atomic_plane_state *plane,
				struct kms_atomic_connector_state *conn)
{
	struct kms_atomic_crtc_state crtc = *crtc_old;
	drmModeAtomicReq *req = drmModeAtomicAlloc();

	igt_assert(req);

	/* Pass a series of invalid object IDs for the mode ID. */
	crtc.mode.id = plane->obj;
	crtc_commit_atomic_err(&crtc, plane, crtc_old, plane, req,
	                       ATOMIC_RELAX_NONE, EINVAL);

	crtc.mode.id = crtc.obj;
	crtc_commit_atomic_err(&crtc, plane, crtc_old, plane, req,
	                       ATOMIC_RELAX_NONE, EINVAL);

	crtc.mode.id = conn->obj;
	crtc_commit_atomic_err(&crtc, plane, crtc_old, plane, req,
	                       ATOMIC_RELAX_NONE, EINVAL);

	crtc.mode.id = plane->fb_id;
	crtc_commit_atomic_err(&crtc, plane, crtc_old, plane, req,
	                       ATOMIC_RELAX_NONE, EINVAL);

	crtc.mode.id = crtc_old->mode.id;
	crtc_commit_atomic(&crtc, plane, req, ATOMIC_RELAX_NONE);

	/* Create a blob which is the wrong size to be a valid mode. */
	do_or_die(drmModeCreatePropertyBlob(crtc.state->desc->fd,
					    crtc.mode.data,
					    sizeof(struct drm_mode_modeinfo) - 1,
					    &crtc.mode.id));
	crtc_commit_atomic_err(&crtc, plane, crtc_old, plane, req,
	                       ATOMIC_RELAX_NONE, EINVAL);


	do_or_die(drmModeCreatePropertyBlob(crtc.state->desc->fd,
					    crtc.mode.data,
					    sizeof(struct drm_mode_modeinfo) + 1,
					    &crtc.mode.id));
	crtc_commit_atomic_err(&crtc, plane, crtc_old, plane, req,
	                       ATOMIC_RELAX_NONE, EINVAL);

	/* Restore the CRTC and check the state matches the old. */
	crtc_commit_atomic(crtc_old, plane, req, ATOMIC_RELAX_NONE);

	drmModeAtomicFree(req);
}
Exemple #2
0
static int drm_atomic_commit(uint32_t fb_id, uint32_t flags)
{
	drmModeAtomicReq *req;
	uint32_t plane_id = drm.plane->plane->plane_id;
	uint32_t blob_id;
	int ret;

	req = drmModeAtomicAlloc();

	if (flags & DRM_MODE_ATOMIC_ALLOW_MODESET) {
		if (add_connector_property(req, drm.connector_id, "CRTC_ID",
						drm.crtc_id) < 0)
			return -1;

		if (drmModeCreatePropertyBlob(drm.fd, drm.mode, sizeof(*drm.mode),
					      &blob_id) != 0)
			return -1;

		if (add_crtc_property(req, drm.crtc_id, "MODE_ID", blob_id) < 0)
			return -1;

		if (add_crtc_property(req, drm.crtc_id, "ACTIVE", 1) < 0)
			return -1;
	}

	add_plane_property(req, plane_id, "FB_ID", fb_id);
	add_plane_property(req, plane_id, "CRTC_ID", drm.crtc_id);
	add_plane_property(req, plane_id, "SRC_X", 0);
	add_plane_property(req, plane_id, "SRC_Y", 0);
	add_plane_property(req, plane_id, "SRC_W", drm.mode->hdisplay << 16);
	add_plane_property(req, plane_id, "SRC_H", drm.mode->vdisplay << 16);
	add_plane_property(req, plane_id, "CRTC_X", 0);
	add_plane_property(req, plane_id, "CRTC_Y", 0);
	add_plane_property(req, plane_id, "CRTC_W", drm.mode->hdisplay);
	add_plane_property(req, plane_id, "CRTC_H", drm.mode->vdisplay);

	if (drm.kms_in_fence_fd != -1) {
		add_crtc_property(req, drm.crtc_id, "OUT_FENCE_PTR",
				VOID2U64(&drm.kms_out_fence_fd));
		add_plane_property(req, plane_id, "IN_FENCE_FD", drm.kms_in_fence_fd);
	}

	ret = drmModeAtomicCommit(drm.fd, req, flags, NULL);
	if (ret)
		goto out;

	if (drm.kms_in_fence_fd != -1) {
		close(drm.kms_in_fence_fd);
		drm.kms_in_fence_fd = -1;
	}

out:
	drmModeAtomicFree(req);

	return ret;
}
Exemple #3
0
bool drm_mode_ensure_blob(int fd, struct drm_mode *mode)
{
    int ret = 0;

    if (!mode->blob_id) {
        ret = drmModeCreatePropertyBlob(fd, &mode->mode, sizeof(drmModeModeInfo),
                                        &mode->blob_id);
    }

    return (ret == 0);
}
static uint32_t blob_duplicate(int fd, uint32_t id_orig)
{
	drmModePropertyBlobPtr orig = drmModeGetPropertyBlob(fd, id_orig);
	uint32_t id_new;

	igt_assert(orig);
	do_or_die(drmModeCreatePropertyBlob(fd, orig->data, orig->length,
					    &id_new));
	drmModeFreePropertyBlob(orig);

	return id_new;
}
Exemple #5
0
void CDRMAtomic::DrmAtomicCommit(int fb_id, int flags, bool rendered, bool videoLayer)
{
  uint32_t blob_id;
  struct plane *plane;

  if (flags & DRM_MODE_ATOMIC_ALLOW_MODESET)
  {
    if (!AddProperty(m_req, m_connector, "CRTC_ID", m_crtc->crtc->crtc_id))
    {
      return;
    }

    if (drmModeCreatePropertyBlob(m_fd, m_mode, sizeof(*m_mode), &blob_id) != 0)
    {
      return;
    }

    if (!AddProperty(m_req, m_crtc, "MODE_ID", blob_id))
    {
      return;
    }

    if (!AddProperty(m_req, m_crtc, "ACTIVE", m_active ? 1 : 0))
    {
      return;
    }

    if (!videoLayer)
    {
      // disable overlay plane on modeset
      AddProperty(m_req, m_overlay_plane, "FB_ID", 0);
      AddProperty(m_req, m_overlay_plane, "CRTC_ID", 0);
    }
  }

  if (videoLayer)
    plane = m_overlay_plane;
  else
    plane = m_primary_plane;

  if (rendered)
  {
    AddProperty(m_req, plane, "FB_ID", fb_id);
    AddProperty(m_req, plane, "CRTC_ID", m_crtc->crtc->crtc_id);
    AddProperty(m_req, plane, "SRC_X", 0);
    AddProperty(m_req, plane, "SRC_Y", 0);
    AddProperty(m_req, plane, "SRC_W", m_mode->hdisplay << 16);
    AddProperty(m_req, plane, "SRC_H", m_mode->vdisplay << 16);
    AddProperty(m_req, plane, "CRTC_X", 0);
    AddProperty(m_req, plane, "CRTC_Y", 0);
    AddProperty(m_req, plane, "CRTC_W", m_mode->hdisplay);
    AddProperty(m_req, plane, "CRTC_H", m_mode->vdisplay);
  }
  else if (videoLayer && !CServiceBroker::GetGUI()->GetWindowManager().HasVisibleControls())
  {
    // disable gui plane when video layer is active and gui has no visible controls
    AddProperty(m_req, plane, "FB_ID", 0);
    AddProperty(m_req, plane, "CRTC_ID", 0);
  }

  auto ret = drmModeAtomicCommit(m_fd, m_req, flags | DRM_MODE_ATOMIC_TEST_ONLY, nullptr);
  if (ret < 0)
  {
    CLog::Log(LOGERROR, "CDRMAtomic::%s - test commit failed: %s", __FUNCTION__, strerror(errno));
  }
  else if (ret == 0)
  {
    ret = drmModeAtomicCommit(m_fd, m_req, flags, nullptr);
    if (ret < 0)
    {
      CLog::Log(LOGERROR, "CDRMAtomic::%s - atomic commit failed: %s", __FUNCTION__, strerror(errno));
    }
  }

  if (flags & DRM_MODE_ATOMIC_ALLOW_MODESET)
  {
    if (drmModeDestroyPropertyBlob(m_fd, blob_id) != 0)
      CLog::Log(LOGERROR, "CDRMAtomic::%s - failed to destroy property blob: %s", __FUNCTION__, strerror(errno));
  }

  drmModeAtomicFree(m_req);
  m_req = drmModeAtomicAlloc();
}