示例#1
0
文件: vmwgfx_stdu.c 项目: mhei/linux
/**
 * 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;
}
示例#2
0
文件: vmwgfx_scrn.c 项目: Lyude/linux
/**
 * 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;
}