[PATCH v5 6/7] drm: add SimpleDRM driver
David Herrmann
dh.herrmann at gmail.com
Sat Sep 3 12:05:28 UTC 2016
Hey
On Sat, Sep 3, 2016 at 2:01 PM, Noralf Trønnes <noralf at tronnes.org> wrote:
>
> Den 02.09.2016 10:22, skrev David Herrmann:
>>
>> The SimpleDRM driver binds to simple-framebuffer devices and provides a
>> DRM/KMS API. It provides only a single CRTC+encoder+connector combination
>> plus one initial mode.
>>
>> Userspace can create dumb-buffers which can be blit into the real
>> framebuffer similar to UDL. No access to the real framebuffer is allowed
>> (compared to earlier version of this driver) to avoid security issues.
>> Furthermore, this way we can support arbitrary modes as long as we have a
>> conversion-helper.
>>
>> Signed-off-by: David Herrmann <dh.herrmann at gmail.com>
>> ---
>
>
> [...]
>
>> diff --git a/drivers/gpu/drm/simpledrm/simpledrm_drv.c
>> b/drivers/gpu/drm/simpledrm/simpledrm_drv.c
>
>
> [...]
>
>> +static int sdrm_fop_mmap(struct file *file, struct vm_area_struct *vma)
>> +{
>> + struct drm_file *dfile = file->private_data;
>> + struct drm_device *dev = dfile->minor->dev;
>> + struct drm_gem_object *obj = NULL;
>> + struct drm_vma_offset_node *node;
>> + int r;
>> +
>> + drm_vma_offset_lock_lookup(dev->vma_offset_manager);
>> + node = drm_vma_offset_exact_lookup_locked(dev->vma_offset_manager,
>> + vma->vm_pgoff,
>> + vma_pages(vma));
>> + if (likely(node)) {
>> + obj = container_of(node, struct drm_gem_object, vma_node);
>> + if (!kref_get_unless_zero(&obj->refcount))
>> + obj = NULL;
>> + }
>> + drm_vma_offset_unlock_lookup(dev->vma_offset_manager);
>> +
>> + if (!obj)
>> + return -EINVAL;
>> +
>> + if (!drm_vma_node_is_allowed(node, dfile)) {
>
>
> I get:
> drivers/gpu/drm/simpledrm/simpledrm_drv.c:320:2: warning: passing argument 2
> of ‘drm_vma_node_is_allowed’ from incompatible pointer type [enabled by
> default]
>
> dfile -> file
Yeah, either change that, or apply "[PATCH 0/6] DRM Core Cleanups"
before. I suspect the cleanups to go in before this driver, so didn't
bother changing it.
>> + drm_gem_object_unreference_unlocked(obj);
>> + return -EACCES;
>> + }
>> +
>> + if (vma->vm_file)
>> + fput(vma->vm_file);
>> + vma->vm_file = get_file(obj->filp);
>> + vma->vm_pgoff = 0;
>> +
>> + r = obj->filp->f_op->mmap(obj->filp, vma);
>> + drm_gem_object_unreference_unlocked(obj);
>> + return r;
>> +}
>
>
> [...]
>
>> diff --git a/drivers/gpu/drm/simpledrm/simpledrm_kms.c
>> b/drivers/gpu/drm/simpledrm/simpledrm_kms.c
>
>
> [...]
>
>
>> +static void sdrm_crtc_send_vblank_event(struct drm_crtc *crtc)
>> +{
>> + if (crtc->state && crtc->state->event) {
>> + spin_lock_irq(&crtc->dev->event_lock);
>> + drm_crtc_send_vblank_event(crtc, crtc->state->event);
>> + spin_unlock_irq(&crtc->dev->event_lock);
>> + crtc->state->event = NULL;
>> + }
>> +}
>> +
>> +void sdrm_display_pipe_update(struct drm_simple_display_pipe *pipe,
>> + struct drm_plane_state *plane_state)
>> +{
>> + struct drm_framebuffer *dfb = pipe->plane.state->fb;
>> + struct sdrm_fb *fb;
>> +
>> + sdrm_crtc_send_vblank_event(&pipe->crtc);
>> +
>> + if (dfb) {
>> + fb = container_of(dfb, struct sdrm_fb, base);
>> + pipe->plane.fb = dfb;
>> + sdrm_dirty(fb, 0, 0, dfb->width, dfb->height);
>> + }
>> +}
>> +
>> +static void sdrm_display_pipe_enable(struct drm_simple_display_pipe
>> *pipe,
>> + struct drm_crtc_state *crtc_state)
>> +{
>> + sdrm_crtc_send_vblank_event(&pipe->crtc);
>> +}
>> +
>> +static void sdrm_display_pipe_disable(struct drm_simple_display_pipe
>> *pipe)
>> +{
>> + sdrm_crtc_send_vblank_event(&pipe->crtc);
>> +}
>> +
>> +static const struct drm_simple_display_pipe_funcs sdrm_pipe_funcs = {
>> + .update = sdrm_display_pipe_update,
>> + .enable = sdrm_display_pipe_enable,
>> + .disable = sdrm_display_pipe_disable,
>> +};
>
>
> The enable and disable callbacks can be removed.
> This commit in drm-misc fixed the flip done timeout:
> drm/simple-helpers: Always add planes to the state update
Right, Daniel told me on IRC already. With this fix applied, I can run
Xorg on top of it just fine.
I dropped the enable/disable callbacks as well now.
Thanks
David
More information about the dri-devel
mailing list