Skip to content

Commit

Permalink
gma500: allow the creation of 'stolen' memory objects
Browse files Browse the repository at this point in the history
For things like cursors and many kinds of framebuffer set up we are actually
best using the stolen memory when possible.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Alan Cox authored and Greg Kroah-Hartman committed Jul 15, 2011
1 parent 7dfe43c commit 7d7b7ad
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
24 changes: 24 additions & 0 deletions drivers/staging/gma500/gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,37 @@ int psb_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
}
}

static int psb_gem_create_stolen(struct drm_file *file, struct drm_device *dev,
int size, u32 *handle)
{
struct gtt_range *gtt = psb_gtt_alloc_range(dev, size, "gem", 1);
if (gtt == NULL)
return -ENOMEM;
if (drm_gem_private_object_init(dev, &gtt->gem, size) != 0)
goto free_gtt;
if (drm_gem_handle_create(file, &gtt->gem, handle) == 0)
return 0;
free_gtt:
psb_gtt_free_range(dev, gtt);
return -ENOMEM;
}

/*
* GEM interfaces for our specific client
*/
int psb_gem_create_ioctl(struct drm_device *dev, void *data,
struct drm_file *file)
{
struct drm_psb_gem_create *args = data;
int ret;
if (args->flags & PSB_GEM_CREATE_STOLEN) {
ret = psb_gem_create_stolen(file, dev, args->size,
&args->handle);
if (ret == 0)
return 0;
/* Fall throguh */
args->flags &= ~PSB_GEM_CREATE_STOLEN;
}
return psb_gem_create(file, dev, args->size, &args->handle);
}

Expand Down
3 changes: 2 additions & 1 deletion drivers/staging/gma500/psb_drm.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ struct psb_drm_dpu_rect {
struct drm_psb_gem_create {
__u64 size;
__u32 handle;
__u32 pad;
__u32 flags;
#define PSB_GEM_CREATE_STOLEN 1 /* Stolen memory can be used */
};

#define PSB_2D_OP_BUFLEN 16
Expand Down

0 comments on commit 7d7b7ad

Please sign in to comment.