Re: [PATCH RFC] [media] blackfin: add video display driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Hans,

>> +/*
>> + * Analog Devices video display driver
>> + *
>> + * Copyright (c) 2011 Analog Devices Inc.
>
> Analog Devices? What has this to do with Analog Devices?
>
I wrote this driver for Analog Devices Blackfin.


>> +
>> +static int disp_mmap(struct file *file, struct vm_area_struct *vma)
>> +{
>> +     struct disp_device *disp = video_drvdata(file);
>> +     int ret;
>> +
>> +     if (mutex_lock_interruptible(&disp->mutex))
>> +             return -ERESTARTSYS;
>> +     ret = vb2_mmap(&disp->buffer_queue, vma);
>> +     mutex_unlock(&disp->mutex);
>> +     return ret;
>> +}
>> +
>> +#ifndef CONFIG_MMU
>> +static unsigned long disp_get_unmapped_area(struct file *file,
>> +                                         unsigned long addr,
>> +                                         unsigned long len,
>> +                                         unsigned long pgoff,
>> +                                         unsigned long flags)
>> +{
>> +     struct disp_device *disp = video_drvdata(file);
>> +     int ret;
>> +
>> +     if (mutex_lock_interruptible(&disp->mutex))
>> +             return -ERESTARTSYS;
>> +     ret = vb2_get_unmapped_area(&disp->buffer_queue,
>> +                                 addr,
>> +                                 len,
>> +                                 pgoff,
>> +                                 flags);
>> +     mutex_unlock(&disp->mutex);
>> +     return ret;
>> +}
>> +#endif
>> +
>> +static unsigned int disp_poll(struct file *file, poll_table *wait)
>> +{
>> +     struct disp_device *disp = video_drvdata(file);
>> +     int ret;
>> +
>> +     mutex_lock(&disp->mutex);
>> +     ret = vb2_poll(&disp->buffer_queue, file, wait);
>> +     mutex_unlock(&disp->mutex);
>> +     return ret;
>> +}
>
> Use the helper functions in media/videobuf2-core.h for these file ops.
>
OK, I will use vb2_fop_mmap. But I'm not sure if I need to lock it.

>> +static int disp_reqbufs(struct file *file, void *priv,
>> +                     struct v4l2_requestbuffers *req_buf)
>> +{
>> +     struct disp_device *disp = video_drvdata(file);
>> +     struct vb2_queue *vq = &disp->buffer_queue;
>> +     struct v4l2_fh *fh = file->private_data;
>> +     struct disp_fh *disp_fh = container_of(fh, struct disp_fh, fh);
>> +
>> +     if (vb2_is_busy(vq))
>> +             return -EBUSY;
>> +
>> +     disp_fh->io_allowed = true;
>
> There is no need for io_allowed. The vb2_is_busy() function does the same
> thing. It saves a lot of code since you now can just use v4l2_fh instead of
> disp_fh, which allows you to use even more helper functions (v4l2_fh_open and
> v4l2_fh_release for starters).
>
> In fact, you can use all the vb2 ioctl helpers saving you a lot of code.
>
I don't think so. vb2_is_busy can't check if this file instance has
the right to stream off output.
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux