Example #1
0
/**
 * vmw_kms_stdu_surface_dirty - Dirty part of a surface backed framebuffer
 *
 * @dev_priv: Pointer to the device private structure.
 * @framebuffer: Pointer to the surface-buffer backed framebuffer.
 * @clips: Array of clip rects. Either @clips or @vclips must be NULL.
 * @vclips: Alternate array of clip rects. Either @clips or @vclips must
 * be NULL.
 * @srf: Pointer to surface to blit from. If NULL, the surface attached
 * to @framebuffer will be used.
 * @dest_x: X coordinate offset to align @srf with framebuffer coordinates.
 * @dest_y: Y coordinate offset to align @srf with framebuffer coordinates.
 * @num_clips: Number of clip rects in @clips.
 * @inc: Increment to use when looping over @clips.
 * @out_fence: If non-NULL, will return a ref-counted pointer to a
 * struct vmw_fence_obj. The returned fence pointer may be NULL in which
 * case the device has already synchronized.
 *
 * Returns 0 on success, negative error code on failure. -ERESTARTSYS if
 * interrupted.
 */
int vmw_kms_stdu_surface_dirty(struct vmw_private *dev_priv,
                               struct vmw_framebuffer *framebuffer,
                               struct drm_clip_rect *clips,
                               struct drm_vmw_rect *vclips,
                               struct vmw_resource *srf,
                               s32 dest_x,
                               s32 dest_y,
                               unsigned num_clips, int inc,
                               struct vmw_fence_obj **out_fence)
{
    struct vmw_framebuffer_surface *vfbs =
        container_of(framebuffer, typeof(*vfbs), base);
    struct vmw_stdu_dirty sdirty;
    int ret;

    if (!srf)
        srf = &vfbs->surface->res;

    ret = vmw_kms_helper_resource_prepare(srf, true);
    if (ret)
        return ret;

    if (vfbs->is_dmabuf_proxy) {
        ret = vmw_kms_update_proxy(srf, clips, num_clips, inc);
        if (ret)
            goto out_finish;
    }

    sdirty.base.fifo_commit = vmw_kms_stdu_surface_fifo_commit;
    sdirty.base.clip = vmw_kms_stdu_surface_clip;
    sdirty.base.fifo_reserve_size = sizeof(struct vmw_stdu_surface_copy) +
                                    sizeof(SVGA3dCopyBox) * num_clips +
                                    sizeof(struct vmw_stdu_update);
    sdirty.sid = srf->id;
    sdirty.left = sdirty.top = S32_MAX;
    sdirty.right = sdirty.bottom = S32_MIN;

    ret = vmw_kms_helper_dirty(dev_priv, framebuffer, clips, vclips,
                               dest_x, dest_y, num_clips, inc,
                               &sdirty.base);
out_finish:
    vmw_kms_helper_resource_finish(srf, out_fence);

    return ret;
}
Example #2
0
/**
 * vmw_kms_sou_do_surface_dirty - Dirty part of a surface backed framebuffer
 *
 * @dev_priv: Pointer to the device private structure.
 * @framebuffer: Pointer to the surface-buffer backed framebuffer.
 * @clips: Array of clip rects. Either @clips or @vclips must be NULL.
 * @vclips: Alternate array of clip rects. Either @clips or @vclips must
 * be NULL.
 * @srf: Pointer to surface to blit from. If NULL, the surface attached
 * to @framebuffer will be used.
 * @dest_x: X coordinate offset to align @srf with framebuffer coordinates.
 * @dest_y: Y coordinate offset to align @srf with framebuffer coordinates.
 * @num_clips: Number of clip rects in @clips.
 * @inc: Increment to use when looping over @clips.
 * @out_fence: If non-NULL, will return a ref-counted pointer to a
 * struct vmw_fence_obj. The returned fence pointer may be NULL in which
 * case the device has already synchronized.
 * @crtc: If crtc is passed, perform surface dirty on that crtc only.
 *
 * Returns 0 on success, negative error code on failure. -ERESTARTSYS if
 * interrupted.
 */
int vmw_kms_sou_do_surface_dirty(struct vmw_private *dev_priv,
				 struct vmw_framebuffer *framebuffer,
				 struct drm_clip_rect *clips,
				 struct drm_vmw_rect *vclips,
				 struct vmw_resource *srf,
				 s32 dest_x,
				 s32 dest_y,
				 unsigned num_clips, int inc,
				 struct vmw_fence_obj **out_fence,
				 struct drm_crtc *crtc)
{
	struct vmw_framebuffer_surface *vfbs =
		container_of(framebuffer, typeof(*vfbs), base);
	struct vmw_kms_sou_surface_dirty sdirty;
	struct vmw_validation_ctx ctx;
	int ret;

	if (!srf)
		srf = &vfbs->surface->res;

	ret = vmw_kms_helper_resource_prepare(srf, true, &ctx);
	if (ret)
		return ret;

	sdirty.base.fifo_commit = vmw_sou_surface_fifo_commit;
	sdirty.base.clip = vmw_sou_surface_clip;
	sdirty.base.dev_priv = dev_priv;
	sdirty.base.fifo_reserve_size = sizeof(struct vmw_kms_sou_dirty_cmd) +
	  sizeof(SVGASignedRect) * num_clips;
	sdirty.base.crtc = crtc;

	sdirty.sid = srf->id;
	sdirty.left = sdirty.top = S32_MAX;
	sdirty.right = sdirty.bottom = S32_MIN;
	sdirty.dst_x = dest_x;
	sdirty.dst_y = dest_y;

	ret = vmw_kms_helper_dirty(dev_priv, framebuffer, clips, vclips,
				   dest_x, dest_y, num_clips, inc,
				   &sdirty.base);
	vmw_kms_helper_resource_finish(&ctx, out_fence);

	return ret;
}
Example #3
0
/**
 * vmw_kms_stdu_dma - Perform a DMA transfer between a dma-buffer backed
 * framebuffer and the screen target system.
 *
 * @dev_priv: Pointer to the device private structure.
 * @file_priv: Pointer to a struct drm-file identifying the caller. May be
 * set to NULL, but then @user_fence_rep must also be set to NULL.
 * @vfb: Pointer to the dma-buffer backed framebuffer.
 * @clips: Array of clip rects. Either @clips or @vclips must be NULL.
 * @vclips: Alternate array of clip rects. Either @clips or @vclips must
 * be NULL.
 * @num_clips: Number of clip rects in @clips or @vclips.
 * @increment: Increment to use when looping over @clips or @vclips.
 * @to_surface: Whether to DMA to the screen target system as opposed to
 * from the screen target system.
 * @interruptible: Whether to perform waits interruptible if possible.
 *
 * If DMA-ing till the screen target system, the function will also notify
 * the screen target system that a bounding box of the cliprects has been
 * updated.
 * Returns 0 on success, negative error code on failure. -ERESTARTSYS if
 * interrupted.
 */
int vmw_kms_stdu_dma(struct vmw_private *dev_priv,
                     struct drm_file *file_priv,
                     struct vmw_framebuffer *vfb,
                     struct drm_vmw_fence_rep __user *user_fence_rep,
                     struct drm_clip_rect *clips,
                     struct drm_vmw_rect *vclips,
                     uint32_t num_clips,
                     int increment,
                     bool to_surface,
                     bool interruptible)
{
    struct vmw_dma_buffer *buf =
        container_of(vfb, struct vmw_framebuffer_dmabuf, base)->buffer;
    struct vmw_stdu_dirty ddirty;
    int ret;

    ret = vmw_kms_helper_buffer_prepare(dev_priv, buf, interruptible,
                                        false);
    if (ret)
        return ret;

    ddirty.transfer = (to_surface) ? SVGA3D_WRITE_HOST_VRAM :
                      SVGA3D_READ_HOST_VRAM;
    ddirty.left = ddirty.top = S32_MAX;
    ddirty.right = ddirty.bottom = S32_MIN;
    ddirty.pitch = vfb->base.pitches[0];
    ddirty.buf = buf;
    ddirty.base.fifo_commit = vmw_stdu_dmabuf_fifo_commit;
    ddirty.base.clip = vmw_stdu_dmabuf_clip;
    ddirty.base.fifo_reserve_size = sizeof(struct vmw_stdu_dma) +
                                    num_clips * sizeof(SVGA3dCopyBox) +
                                    sizeof(SVGA3dCmdSurfaceDMASuffix);
    if (to_surface)
        ddirty.base.fifo_reserve_size += sizeof(struct vmw_stdu_update);

    ret = vmw_kms_helper_dirty(dev_priv, vfb, clips, vclips,
                               0, 0, num_clips, increment, &ddirty.base);
    vmw_kms_helper_buffer_finish(dev_priv, file_priv, buf, NULL,
                                 user_fence_rep);

    return ret;
}
Example #4
0
/**
 * vmw_kms_do_bo_dirty - Dirty part of a buffer-object backed framebuffer
 *
 * @dev_priv: Pointer to the device private structure.
 * @framebuffer: Pointer to the buffer-object backed framebuffer.
 * @clips: Array of clip rects.
 * @vclips: Alternate array of clip rects. Either @clips or @vclips must
 * be NULL.
 * @num_clips: Number of clip rects in @clips.
 * @increment: Increment to use when looping over @clips.
 * @interruptible: Whether to perform waits interruptible if possible.
 * @out_fence: If non-NULL, will return a ref-counted pointer to a
 * struct vmw_fence_obj. The returned fence pointer may be NULL in which
 * case the device has already synchronized.
 * @crtc: If crtc is passed, perform bo dirty on that crtc only.
 *
 * Returns 0 on success, negative error code on failure. -ERESTARTSYS if
 * interrupted.
 */
int vmw_kms_sou_do_bo_dirty(struct vmw_private *dev_priv,
				struct vmw_framebuffer *framebuffer,
				struct drm_clip_rect *clips,
				struct drm_vmw_rect *vclips,
				unsigned num_clips, int increment,
				bool interruptible,
				struct vmw_fence_obj **out_fence,
				struct drm_crtc *crtc)
{
	struct vmw_buffer_object *buf =
		container_of(framebuffer, struct vmw_framebuffer_bo,
			     base)->buffer;
	struct vmw_kms_dirty dirty;
	int ret;

	ret = vmw_kms_helper_buffer_prepare(dev_priv, buf, interruptible,
					    false, false);
	if (ret)
		return ret;

	ret = do_bo_define_gmrfb(dev_priv, framebuffer);
	if (unlikely(ret != 0))
		goto out_revert;

	dirty.crtc = crtc;
	dirty.fifo_commit = vmw_sou_bo_fifo_commit;
	dirty.clip = vmw_sou_bo_clip;
	dirty.fifo_reserve_size = sizeof(struct vmw_kms_sou_bo_blit) *
		num_clips;
	ret = vmw_kms_helper_dirty(dev_priv, framebuffer, clips, vclips,
				   0, 0, num_clips, increment, &dirty);
	vmw_kms_helper_buffer_finish(dev_priv, NULL, buf, out_fence, NULL);

	return ret;

out_revert:
	vmw_kms_helper_buffer_revert(buf);

	return ret;
}
Example #5
0
/**
 * vmw_kms_sou_readback - Perform a readback from the screen object system to
 * a buffer-object backed framebuffer.
 *
 * @dev_priv: Pointer to the device private structure.
 * @file_priv: Pointer to a struct drm_file identifying the caller.
 * Must be set to NULL if @user_fence_rep is NULL.
 * @vfb: Pointer to the buffer-object backed framebuffer.
 * @user_fence_rep: User-space provided structure for fence information.
 * Must be set to non-NULL if @file_priv is non-NULL.
 * @vclips: Array of clip rects.
 * @num_clips: Number of clip rects in @vclips.
 * @crtc: If crtc is passed, readback on that crtc only.
 *
 * Returns 0 on success, negative error code on failure. -ERESTARTSYS if
 * interrupted.
 */
int vmw_kms_sou_readback(struct vmw_private *dev_priv,
			 struct drm_file *file_priv,
			 struct vmw_framebuffer *vfb,
			 struct drm_vmw_fence_rep __user *user_fence_rep,
			 struct drm_vmw_rect *vclips,
			 uint32_t num_clips,
			 struct drm_crtc *crtc)
{
	struct vmw_buffer_object *buf =
		container_of(vfb, struct vmw_framebuffer_bo, base)->buffer;
	struct vmw_kms_dirty dirty;
	int ret;

	ret = vmw_kms_helper_buffer_prepare(dev_priv, buf, true, false,
					    false);
	if (ret)
		return ret;

	ret = do_bo_define_gmrfb(dev_priv, vfb);
	if (unlikely(ret != 0))
		goto out_revert;

	dirty.crtc = crtc;
	dirty.fifo_commit = vmw_sou_readback_fifo_commit;
	dirty.clip = vmw_sou_readback_clip;
	dirty.fifo_reserve_size = sizeof(struct vmw_kms_sou_readback_blit) *
		num_clips;
	ret = vmw_kms_helper_dirty(dev_priv, vfb, NULL, vclips,
				   0, 0, num_clips, 1, &dirty);
	vmw_kms_helper_buffer_finish(dev_priv, file_priv, buf, NULL,
				     user_fence_rep);

	return ret;

out_revert:
	vmw_kms_helper_buffer_revert(buf);

	return ret;
}