* [PATCH 00/12] dt3155v4l: clean up and move out of staging
@ 2015-04-25 15:42 Hans Verkuil
2015-04-25 15:42 ` [PATCH 01/12] dt3155v4l: code cleanup Hans Verkuil
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: Hans Verkuil @ 2015-04-25 15:42 UTC (permalink / raw)
To: linux-media
From: Hans Verkuil <hans.verkuil@cisco.com>
This has been on my TODO list for a long time and I finally got time to
work on this driver.
These patches clean up this driver, make it pass the v4l2-compliance tests
and even adds support for the breakout cable (at least the additional 3
inputs). Tested with my dt3155 card + breakout cable that I bought a few
years ago.
The code is now in good shape and so this driver is moved out of staging into
drivers/media/pci and renamed to dt3155 (the v4l suffix was silly).
It's unlikely that anyone will ever care about this driver, but, as they say,
"Have hardware, must have proper driver" :-)
Or just call me nuts, that's OK too...
Regards,
Hans
Hans Verkuil (12):
dt3155v4l: code cleanup
dt3155v4l: remove unused statistics
dt3155v4l: add v4l2_device support
dt3155v4l: remove pointless dt3155_alloc/free_coherent
dt3155v4l: remove bogus single-frame capture in init_board
dt3155v4l: move vb2_queue to top-level
dt3155v4l: drop CONFIG_DT3155_STREAMING
dt3155v4l: correctly start and stop streaming
dt3155v4l: drop CONFIG_DT3155_CCIR, use s_std instead
dt3155v4l: fix format handling
dt3155v4l: support inputs VID0-3
dt3155: move out of staging into drivers/media/pci
MAINTAINERS | 8 +
drivers/media/pci/Kconfig | 1 +
drivers/media/pci/Makefile | 1 +
drivers/media/pci/dt3155/Kconfig | 13 +
drivers/media/pci/dt3155/Makefile | 1 +
drivers/media/pci/dt3155/dt3155.c | 626 +++++++++++++
.../dt3155v4l.h => media/pci/dt3155/dt3155.h} | 64 +-
drivers/staging/media/Kconfig | 2 -
drivers/staging/media/Makefile | 1 -
drivers/staging/media/dt3155v4l/Kconfig | 29 -
drivers/staging/media/dt3155v4l/Makefile | 1 -
drivers/staging/media/dt3155v4l/dt3155v4l.c | 981 ---------------------
12 files changed, 674 insertions(+), 1054 deletions(-)
create mode 100644 drivers/media/pci/dt3155/Kconfig
create mode 100644 drivers/media/pci/dt3155/Makefile
create mode 100644 drivers/media/pci/dt3155/dt3155.c
rename drivers/{staging/media/dt3155v4l/dt3155v4l.h => media/pci/dt3155/dt3155.h} (82%)
delete mode 100644 drivers/staging/media/dt3155v4l/Kconfig
delete mode 100644 drivers/staging/media/dt3155v4l/Makefile
delete mode 100644 drivers/staging/media/dt3155v4l/dt3155v4l.c
--
2.1.4
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 01/12] dt3155v4l: code cleanup
2015-04-25 15:42 [PATCH 00/12] dt3155v4l: clean up and move out of staging Hans Verkuil
@ 2015-04-25 15:42 ` Hans Verkuil
2015-04-25 15:42 ` [PATCH 02/12] dt3155v4l: remove unused statistics Hans Verkuil
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Hans Verkuil @ 2015-04-25 15:42 UTC (permalink / raw)
To: linux-media; +Cc: Hans Verkuil
From: Hans Verkuil <hans.verkuil@cisco.com>
- Fix various spelling mistakes
- Whitespace cleanups
- Remove _ioc_ from ioctl names to shorten those names
- Remove bogus ifdef __KERNEL__
- Remove commented out code
No actual code is changed in this patch.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
drivers/staging/media/dt3155v4l/dt3155v4l.c | 202 +++++++++-------------------
drivers/staging/media/dt3155v4l/dt3155v4l.h | 8 --
2 files changed, 66 insertions(+), 144 deletions(-)
diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.c b/drivers/staging/media/dt3155v4l/dt3155v4l.c
index 52a8ffe..07cf8c3 100644
--- a/drivers/staging/media/dt3155v4l/dt3155v4l.c
+++ b/drivers/staging/media/dt3155v4l/dt3155v4l.c
@@ -12,10 +12,6 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <linux/module.h>
@@ -96,12 +92,11 @@ static u8 config_init = ACQ_MODE_EVEN;
* and busy waits for the process to finish. The result is placed
* in a byte pointed by data.
*/
-static int
-read_i2c_reg(void __iomem *addr, u8 index, u8 *data)
+static int read_i2c_reg(void __iomem *addr, u8 index, u8 *data)
{
u32 tmp = index;
- iowrite32((tmp<<17) | IIC_READ, addr + IIC_CSR2);
+ iowrite32((tmp << 17) | IIC_READ, addr + IIC_CSR2);
mmiowb();
udelay(45); /* wait at least 43 usec for NEW_CYCLE to clear */
if (ioread32(addr + IIC_CSR2) & NEW_CYCLE)
@@ -112,7 +107,7 @@ read_i2c_reg(void __iomem *addr, u8 index, u8 *data)
iowrite32(DIRECT_ABORT, addr + IIC_CSR1);
return -EIO; /* error: DIRECT_ABORT set */
}
- *data = tmp>>24;
+ *data = tmp >> 24;
return 0;
}
@@ -125,15 +120,14 @@ read_i2c_reg(void __iomem *addr, u8 index, u8 *data)
*
* returns: zero on success or error code
*
- * This function starts writting the specified (by index) register
+ * This function starts writing the specified (by index) register
* and busy waits for the process to finish.
*/
-static int
-write_i2c_reg(void __iomem *addr, u8 index, u8 data)
+static int write_i2c_reg(void __iomem *addr, u8 index, u8 data)
{
u32 tmp = index;
- iowrite32((tmp<<17) | IIC_WRITE | data, addr + IIC_CSR2);
+ iowrite32((tmp << 17) | IIC_WRITE | data, addr + IIC_CSR2);
mmiowb();
udelay(65); /* wait at least 63 usec for NEW_CYCLE to clear */
if (ioread32(addr + IIC_CSR2) & NEW_CYCLE)
@@ -153,14 +147,14 @@ write_i2c_reg(void __iomem *addr, u8 index, u8 data)
* @index: index (internal address) of register to read
* @data: data to be written
*
- * This function starts writting the specified (by index) register
+ * This function starts writing the specified (by index) register
* and then returns.
*/
static void write_i2c_reg_nowait(void __iomem *addr, u8 index, u8 data)
{
u32 tmp = index;
- iowrite32((tmp<<17) | IIC_WRITE | data, addr + IIC_CSR2);
+ iowrite32((tmp << 17) | IIC_WRITE | data, addr + IIC_CSR2);
mmiowb();
}
@@ -171,7 +165,7 @@ static void write_i2c_reg_nowait(void __iomem *addr, u8 index, u8 data)
*
* returns: zero on success or error code
*
- * This function waits reading/writting to finish.
+ * This function waits reading/writing to finish.
*/
static int wait_i2c_reg(void __iomem *addr)
{
@@ -187,8 +181,7 @@ static int wait_i2c_reg(void __iomem *addr)
return 0;
}
-static int
-dt3155_start_acq(struct dt3155_priv *pd)
+static int dt3155_start_acq(struct dt3155_priv *pd)
{
struct vb2_buffer *vb = pd->curr_buf;
dma_addr_t dma_addr;
@@ -214,9 +207,6 @@ dt3155_start_acq(struct dt3155_priv *pd)
return 0; /* success */
}
-/*
- * driver-specific callbacks (vb2_ops)
- */
static int
dt3155_queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt,
unsigned int *num_buffers, unsigned int *num_planes,
@@ -239,31 +229,27 @@ dt3155_queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt,
return 0;
}
-static void
-dt3155_wait_prepare(struct vb2_queue *q)
+static void dt3155_wait_prepare(struct vb2_queue *q)
{
struct dt3155_priv *pd = vb2_get_drv_priv(q);
mutex_unlock(pd->vdev.lock);
}
-static void
-dt3155_wait_finish(struct vb2_queue *q)
+static void dt3155_wait_finish(struct vb2_queue *q)
{
struct dt3155_priv *pd = vb2_get_drv_priv(q);
mutex_lock(pd->vdev.lock);
}
-static int
-dt3155_buf_prepare(struct vb2_buffer *vb)
+static int dt3155_buf_prepare(struct vb2_buffer *vb)
{
vb2_set_plane_payload(vb, 0, img_width * img_height);
return 0;
}
-static void
-dt3155_stop_streaming(struct vb2_queue *q)
+static void dt3155_stop_streaming(struct vb2_queue *q)
{
struct dt3155_priv *pd = vb2_get_drv_priv(q);
struct vb2_buffer *vb;
@@ -278,8 +264,7 @@ dt3155_stop_streaming(struct vb2_queue *q)
msleep(45); /* irq hendler will stop the hardware */
}
-static void
-dt3155_buf_queue(struct vb2_buffer *vb)
+static void dt3155_buf_queue(struct vb2_buffer *vb)
{
struct dt3155_priv *pd = vb2_get_drv_priv(vb->vb2_queue);
@@ -293,9 +278,6 @@ dt3155_buf_queue(struct vb2_buffer *vb)
}
spin_unlock_irq(&pd->lock);
}
-/*
- * end driver-specific callbacks
- */
static const struct vb2_ops q_ops = {
.queue_setup = dt3155_queue_setup,
@@ -306,8 +288,7 @@ static const struct vb2_ops q_ops = {
.buf_queue = dt3155_buf_queue,
};
-static irqreturn_t
-dt3155_irq_handler_even(int irq, void *dev_id)
+static irqreturn_t dt3155_irq_handler_even(int irq, void *dev_id)
{
struct dt3155_priv *ipd = dev_id;
struct vb2_buffer *ivb;
@@ -325,9 +306,6 @@ dt3155_irq_handler_even(int irq, void *dev_id)
}
if ((tmp & FLD_START) && (tmp & FLD_END_ODD))
ipd->stats.start_before_end++;
- /* check for corrupted fields */
-/* write_i2c_reg(ipd->regs, EVEN_CSR, CSR_ERROR | CSR_DONE); */
-/* write_i2c_reg(ipd->regs, ODD_CSR, CSR_ERROR | CSR_DONE); */
tmp = ioread32(ipd->regs + CSR1) & (FLD_CRPT_EVEN | FLD_CRPT_ODD);
if (tmp) {
ipd->stats.corrupted_fields++;
@@ -374,8 +352,7 @@ stop_dma:
return IRQ_HANDLED;
}
-static int
-dt3155_open(struct file *filp)
+static int dt3155_open(struct file *filp)
{
int ret = 0;
struct dt3155_priv *pd = video_drvdata(filp);
@@ -420,8 +397,7 @@ err_alloc_queue:
return ret;
}
-static int
-dt3155_release(struct file *filp)
+static int dt3155_release(struct file *filp)
{
struct dt3155_priv *pd = video_drvdata(filp);
@@ -440,8 +416,7 @@ dt3155_release(struct file *filp)
return 0;
}
-static ssize_t
-dt3155_read(struct file *filp, char __user *user, size_t size, loff_t *loff)
+static ssize_t dt3155_read(struct file *filp, char __user *user, size_t size, loff_t *loff)
{
struct dt3155_priv *pd = video_drvdata(filp);
ssize_t res;
@@ -453,8 +428,7 @@ dt3155_read(struct file *filp, char __user *user, size_t size, loff_t *loff)
return res;
}
-static unsigned int
-dt3155_poll(struct file *filp, struct poll_table_struct *polltbl)
+static unsigned int dt3155_poll(struct file *filp, struct poll_table_struct *polltbl)
{
struct dt3155_priv *pd = video_drvdata(filp);
unsigned int res;
@@ -465,8 +439,7 @@ dt3155_poll(struct file *filp, struct poll_table_struct *polltbl)
return res;
}
-static int
-dt3155_mmap(struct file *filp, struct vm_area_struct *vma)
+static int dt3155_mmap(struct file *filp, struct vm_area_struct *vma)
{
struct dt3155_priv *pd = video_drvdata(filp);
int res;
@@ -488,24 +461,21 @@ static const struct v4l2_file_operations dt3155_fops = {
.mmap = dt3155_mmap,
};
-static int
-dt3155_ioc_streamon(struct file *filp, void *p, enum v4l2_buf_type type)
+static int dt3155_streamon(struct file *filp, void *p, enum v4l2_buf_type type)
{
struct dt3155_priv *pd = video_drvdata(filp);
return vb2_streamon(pd->q, type);
}
-static int
-dt3155_ioc_streamoff(struct file *filp, void *p, enum v4l2_buf_type type)
+static int dt3155_streamoff(struct file *filp, void *p, enum v4l2_buf_type type)
{
struct dt3155_priv *pd = video_drvdata(filp);
return vb2_streamoff(pd->q, type);
}
-static int
-dt3155_ioc_querycap(struct file *filp, void *p, struct v4l2_capability *cap)
+static int dt3155_querycap(struct file *filp, void *p, struct v4l2_capability *cap)
{
struct dt3155_priv *pd = video_drvdata(filp);
@@ -518,8 +488,7 @@ dt3155_ioc_querycap(struct file *filp, void *p, struct v4l2_capability *cap)
return 0;
}
-static int
-dt3155_ioc_enum_fmt_vid_cap(struct file *filp, void *p, struct v4l2_fmtdesc *f)
+static int dt3155_enum_fmt_vid_cap(struct file *filp, void *p, struct v4l2_fmtdesc *f)
{
if (f->index >= NUM_OF_FORMATS)
return -EINVAL;
@@ -527,8 +496,7 @@ dt3155_ioc_enum_fmt_vid_cap(struct file *filp, void *p, struct v4l2_fmtdesc *f)
return 0;
}
-static int
-dt3155_ioc_g_fmt_vid_cap(struct file *filp, void *p, struct v4l2_format *f)
+static int dt3155_g_fmt_vid_cap(struct file *filp, void *p, struct v4l2_format *f)
{
if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
@@ -543,8 +511,7 @@ dt3155_ioc_g_fmt_vid_cap(struct file *filp, void *p, struct v4l2_format *f)
return 0;
}
-static int
-dt3155_ioc_try_fmt_vid_cap(struct file *filp, void *p, struct v4l2_format *f)
+static int dt3155_try_fmt_vid_cap(struct file *filp, void *p, struct v4l2_format *f)
{
if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
@@ -559,68 +526,59 @@ dt3155_ioc_try_fmt_vid_cap(struct file *filp, void *p, struct v4l2_format *f)
return -EINVAL;
}
-static int
-dt3155_ioc_s_fmt_vid_cap(struct file *filp, void *p, struct v4l2_format *f)
+static int dt3155_s_fmt_vid_cap(struct file *filp, void *p, struct v4l2_format *f)
{
- return dt3155_ioc_g_fmt_vid_cap(filp, p, f);
+ return dt3155_g_fmt_vid_cap(filp, p, f);
}
-static int
-dt3155_ioc_reqbufs(struct file *filp, void *p, struct v4l2_requestbuffers *b)
+static int dt3155_reqbufs(struct file *filp, void *p, struct v4l2_requestbuffers *b)
{
struct dt3155_priv *pd = video_drvdata(filp);
return vb2_reqbufs(pd->q, b);
}
-static int
-dt3155_ioc_querybuf(struct file *filp, void *p, struct v4l2_buffer *b)
+static int dt3155_querybuf(struct file *filp, void *p, struct v4l2_buffer *b)
{
struct dt3155_priv *pd = video_drvdata(filp);
return vb2_querybuf(pd->q, b);
}
-static int
-dt3155_ioc_qbuf(struct file *filp, void *p, struct v4l2_buffer *b)
+static int dt3155_qbuf(struct file *filp, void *p, struct v4l2_buffer *b)
{
struct dt3155_priv *pd = video_drvdata(filp);
return vb2_qbuf(pd->q, b);
}
-static int
-dt3155_ioc_dqbuf(struct file *filp, void *p, struct v4l2_buffer *b)
+static int dt3155_dqbuf(struct file *filp, void *p, struct v4l2_buffer *b)
{
struct dt3155_priv *pd = video_drvdata(filp);
return vb2_dqbuf(pd->q, b, filp->f_flags & O_NONBLOCK);
}
-static int
-dt3155_ioc_querystd(struct file *filp, void *p, v4l2_std_id *norm)
+static int dt3155_querystd(struct file *filp, void *p, v4l2_std_id *norm)
{
*norm = DT3155_CURRENT_NORM;
return 0;
}
-static int
-dt3155_ioc_g_std(struct file *filp, void *p, v4l2_std_id *norm)
+static int dt3155_g_std(struct file *filp, void *p, v4l2_std_id *norm)
{
*norm = DT3155_CURRENT_NORM;
return 0;
}
-static int
-dt3155_ioc_s_std(struct file *filp, void *p, v4l2_std_id norm)
+static int dt3155_s_std(struct file *filp, void *p, v4l2_std_id norm)
{
if (norm & DT3155_CURRENT_NORM)
return 0;
return -EINVAL;
}
-static int
-dt3155_ioc_enum_input(struct file *filp, void *p, struct v4l2_input *input)
+static int dt3155_enum_input(struct file *filp, void *p, struct v4l2_input *input)
{
if (input->index)
return -EINVAL;
@@ -636,23 +594,20 @@ dt3155_ioc_enum_input(struct file *filp, void *p, struct v4l2_input *input)
return 0;
}
-static int
-dt3155_ioc_g_input(struct file *filp, void *p, unsigned int *i)
+static int dt3155_g_input(struct file *filp, void *p, unsigned int *i)
{
*i = 0;
return 0;
}
-static int
-dt3155_ioc_s_input(struct file *filp, void *p, unsigned int i)
+static int dt3155_s_input(struct file *filp, void *p, unsigned int i)
{
if (i)
return -EINVAL;
return 0;
}
-static int
-dt3155_ioc_g_parm(struct file *filp, void *p, struct v4l2_streamparm *parms)
+static int dt3155_g_parm(struct file *filp, void *p, struct v4l2_streamparm *parms)
{
if (parms->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
@@ -665,8 +620,7 @@ dt3155_ioc_g_parm(struct file *filp, void *p, struct v4l2_streamparm *parms)
return 0;
}
-static int
-dt3155_ioc_s_parm(struct file *filp, void *p, struct v4l2_streamparm *parms)
+static int dt3155_s_parm(struct file *filp, void *p, struct v4l2_streamparm *parms)
{
if (parms->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
@@ -680,48 +634,28 @@ dt3155_ioc_s_parm(struct file *filp, void *p, struct v4l2_streamparm *parms)
}
static const struct v4l2_ioctl_ops dt3155_ioctl_ops = {
- .vidioc_streamon = dt3155_ioc_streamon,
- .vidioc_streamoff = dt3155_ioc_streamoff,
- .vidioc_querycap = dt3155_ioc_querycap,
-/*
- .vidioc_g_priority = dt3155_ioc_g_priority,
- .vidioc_s_priority = dt3155_ioc_s_priority,
-*/
- .vidioc_enum_fmt_vid_cap = dt3155_ioc_enum_fmt_vid_cap,
- .vidioc_try_fmt_vid_cap = dt3155_ioc_try_fmt_vid_cap,
- .vidioc_g_fmt_vid_cap = dt3155_ioc_g_fmt_vid_cap,
- .vidioc_s_fmt_vid_cap = dt3155_ioc_s_fmt_vid_cap,
- .vidioc_reqbufs = dt3155_ioc_reqbufs,
- .vidioc_querybuf = dt3155_ioc_querybuf,
- .vidioc_qbuf = dt3155_ioc_qbuf,
- .vidioc_dqbuf = dt3155_ioc_dqbuf,
- .vidioc_querystd = dt3155_ioc_querystd,
- .vidioc_g_std = dt3155_ioc_g_std,
- .vidioc_s_std = dt3155_ioc_s_std,
- .vidioc_enum_input = dt3155_ioc_enum_input,
- .vidioc_g_input = dt3155_ioc_g_input,
- .vidioc_s_input = dt3155_ioc_s_input,
-/*
- .vidioc_queryctrl = dt3155_ioc_queryctrl,
- .vidioc_g_ctrl = dt3155_ioc_g_ctrl,
- .vidioc_s_ctrl = dt3155_ioc_s_ctrl,
- .vidioc_querymenu = dt3155_ioc_querymenu,
- .vidioc_g_ext_ctrls = dt3155_ioc_g_ext_ctrls,
- .vidioc_s_ext_ctrls = dt3155_ioc_s_ext_ctrls,
-*/
- .vidioc_g_parm = dt3155_ioc_g_parm,
- .vidioc_s_parm = dt3155_ioc_s_parm,
-/*
- .vidioc_cropcap = dt3155_ioc_cropcap,
- .vidioc_g_crop = dt3155_ioc_g_crop,
- .vidioc_s_crop = dt3155_ioc_s_crop,
- .vidioc_enum_framesizes = dt3155_ioc_enum_framesizes,
- .vidioc_enum_frameintervals = dt3155_ioc_enum_frameintervals,
-*/
+ .vidioc_streamon = dt3155_streamon,
+ .vidioc_streamoff = dt3155_streamoff,
+ .vidioc_querycap = dt3155_querycap,
+ .vidioc_enum_fmt_vid_cap = dt3155_enum_fmt_vid_cap,
+ .vidioc_try_fmt_vid_cap = dt3155_try_fmt_vid_cap,
+ .vidioc_g_fmt_vid_cap = dt3155_g_fmt_vid_cap,
+ .vidioc_s_fmt_vid_cap = dt3155_s_fmt_vid_cap,
+ .vidioc_reqbufs = dt3155_reqbufs,
+ .vidioc_querybuf = dt3155_querybuf,
+ .vidioc_qbuf = dt3155_qbuf,
+ .vidioc_dqbuf = dt3155_dqbuf,
+ .vidioc_querystd = dt3155_querystd,
+ .vidioc_g_std = dt3155_g_std,
+ .vidioc_s_std = dt3155_s_std,
+ .vidioc_enum_input = dt3155_enum_input,
+ .vidioc_g_input = dt3155_g_input,
+ .vidioc_s_input = dt3155_s_input,
+ .vidioc_g_parm = dt3155_g_parm,
+ .vidioc_s_parm = dt3155_s_parm,
};
-static int
-dt3155_init_board(struct pci_dev *pdev)
+static int dt3155_init_board(struct pci_dev *pdev)
{
struct dt3155_priv *pd = pci_get_drvdata(pdev);
void *buf_cpu;
@@ -737,7 +671,7 @@ dt3155_init_board(struct pci_dev *pdev)
mmiowb();
msleep(20);
- /* initializing adaper registers */
+ /* initializing adapter registers */
iowrite32(FIFO_EN | SRST, pd->regs + CSR1);
mmiowb();
iowrite32(0xEEEEEE01, pd->regs + EVEN_PIXEL_FMT);
@@ -837,8 +771,7 @@ struct dma_coherent_mem {
unsigned long *bitmap;
};
-static int
-dt3155_alloc_coherent(struct device *dev, size_t size, int flags)
+static int dt3155_alloc_coherent(struct device *dev, size_t size, int flags)
{
struct dma_coherent_mem *mem;
dma_addr_t dev_base;
@@ -878,8 +811,7 @@ out:
return 0;
}
-static void
-dt3155_free_coherent(struct device *dev)
+static void dt3155_free_coherent(struct device *dev)
{
struct dma_coherent_mem *mem = dev->dma_mem;
@@ -892,8 +824,7 @@ dt3155_free_coherent(struct device *dev)
kfree(mem);
}
-static int
-dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id)
+static int dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
int err;
struct dt3155_priv *pd;
@@ -948,8 +879,7 @@ err_req_region:
return err;
}
-static void
-dt3155_remove(struct pci_dev *pdev)
+static void dt3155_remove(struct pci_dev *pdev)
{
struct dt3155_priv *pd = pci_get_drvdata(pdev);
diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.h b/drivers/staging/media/dt3155v4l/dt3155v4l.h
index 96f01a0..5aeee75 100644
--- a/drivers/staging/media/dt3155v4l/dt3155v4l.h
+++ b/drivers/staging/media/dt3155v4l/dt3155v4l.h
@@ -12,18 +12,12 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/* DT3155 header file */
#ifndef _DT3155_H_
#define _DT3155_H_
-#ifdef __KERNEL__
-
#include <linux/pci.h>
#include <linux/interrupt.h>
@@ -207,6 +201,4 @@ struct dt3155_priv {
u8 csr2, config;
};
-#endif /* __KERNEL__ */
-
#endif /* _DT3155_H_ */
--
2.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 02/12] dt3155v4l: remove unused statistics
2015-04-25 15:42 [PATCH 00/12] dt3155v4l: clean up and move out of staging Hans Verkuil
2015-04-25 15:42 ` [PATCH 01/12] dt3155v4l: code cleanup Hans Verkuil
@ 2015-04-25 15:42 ` Hans Verkuil
2015-04-25 15:42 ` [PATCH 03/12] dt3155v4l: add v4l2_device support Hans Verkuil
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Hans Verkuil @ 2015-04-25 15:42 UTC (permalink / raw)
To: linux-media; +Cc: Hans Verkuil
From: Hans Verkuil <hans.verkuil@cisco.com>
Remove struct dt3155_stats since it isn't used.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
drivers/staging/media/dt3155v4l/dt3155v4l.c | 3 ---
drivers/staging/media/dt3155v4l/dt3155v4l.h | 16 ----------------
2 files changed, 19 deletions(-)
diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.c b/drivers/staging/media/dt3155v4l/dt3155v4l.c
index 07cf8c3..5734dde 100644
--- a/drivers/staging/media/dt3155v4l/dt3155v4l.c
+++ b/drivers/staging/media/dt3155v4l/dt3155v4l.c
@@ -304,11 +304,8 @@ static irqreturn_t dt3155_irq_handler_even(int irq, void *dev_id)
ipd->field_count++;
return IRQ_HANDLED; /* start of field irq */
}
- if ((tmp & FLD_START) && (tmp & FLD_END_ODD))
- ipd->stats.start_before_end++;
tmp = ioread32(ipd->regs + CSR1) & (FLD_CRPT_EVEN | FLD_CRPT_ODD);
if (tmp) {
- ipd->stats.corrupted_fields++;
iowrite32(FIFO_EN | SRST | FLD_CRPT_ODD | FLD_CRPT_EVEN |
FLD_DN_ODD | FLD_DN_EVEN |
CAP_CONT_EVEN | CAP_CONT_ODD,
diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.h b/drivers/staging/media/dt3155v4l/dt3155v4l.h
index 5aeee75..b4cb412 100644
--- a/drivers/staging/media/dt3155v4l/dt3155v4l.h
+++ b/drivers/staging/media/dt3155v4l/dt3155v4l.h
@@ -153,21 +153,6 @@
#define DMA_STRIDE 640
#endif
-/**
- * struct dt3155_stats - statistics structure
- *
- * @free_bufs_empty: no free image buffers
- * @corrupted_fields: corrupted fields
- * @dma_map_failed: dma mapping failed
- * @start_before_end: new started before old ended
- */
-struct dt3155_stats {
- int free_bufs_empty;
- int corrupted_fields;
- int dma_map_failed;
- int start_before_end;
-};
-
/* per board private data structure */
/**
* struct dt3155_priv - private data structure
@@ -195,7 +180,6 @@ struct dt3155_priv {
struct list_head dmaq;
spinlock_t lock;
unsigned int field_count;
- struct dt3155_stats stats;
void __iomem *regs;
int users;
u8 csr2, config;
--
2.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 03/12] dt3155v4l: add v4l2_device support
2015-04-25 15:42 [PATCH 00/12] dt3155v4l: clean up and move out of staging Hans Verkuil
2015-04-25 15:42 ` [PATCH 01/12] dt3155v4l: code cleanup Hans Verkuil
2015-04-25 15:42 ` [PATCH 02/12] dt3155v4l: remove unused statistics Hans Verkuil
@ 2015-04-25 15:42 ` Hans Verkuil
2015-04-25 15:42 ` [PATCH 04/12] dt3155v4l: remove pointless dt3155_alloc/free_coherent Hans Verkuil
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Hans Verkuil @ 2015-04-25 15:42 UTC (permalink / raw)
To: linux-media; +Cc: Hans Verkuil
From: Hans Verkuil <hans.verkuil@cisco.com>
Add struct v4l2_device and register it. Also move the request_irq to
probe instead of doing that in open().
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
drivers/staging/media/dt3155v4l/dt3155v4l.c | 45 +++++++++++++++++------------
drivers/staging/media/dt3155v4l/dt3155v4l.h | 4 +++
2 files changed, 31 insertions(+), 18 deletions(-)
diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.c b/drivers/staging/media/dt3155v4l/dt3155v4l.c
index 5734dde..564483a 100644
--- a/drivers/staging/media/dt3155v4l/dt3155v4l.c
+++ b/drivers/staging/media/dt3155v4l/dt3155v4l.c
@@ -378,10 +378,6 @@ static int dt3155_open(struct file *filp)
/* disable all irqs, clear all irq flags */
iowrite32(FLD_START | FLD_END_EVEN | FLD_END_ODD,
pd->regs + INT_CSR);
- ret = request_irq(pd->pdev->irq, dt3155_irq_handler_even,
- IRQF_SHARED, DT3155_NAME, pd);
- if (ret)
- goto err_request_irq;
}
pd->users++;
mutex_unlock(&pd->mux);
@@ -403,7 +399,6 @@ static int dt3155_release(struct file *filp)
BUG_ON(pd->users < 0);
if (!pd->users) {
vb2_queue_release(pd->q);
- free_irq(pd->pdev->irq, pd);
if (pd->q->alloc_ctx[0])
vb2_dma_contig_cleanup_ctx(pd->q->alloc_ctx[0]);
kfree(pd->q);
@@ -652,9 +647,9 @@ static const struct v4l2_ioctl_ops dt3155_ioctl_ops = {
.vidioc_s_parm = dt3155_s_parm,
};
-static int dt3155_init_board(struct pci_dev *pdev)
+static int dt3155_init_board(struct dt3155_priv *pd)
{
- struct dt3155_priv *pd = pci_get_drvdata(pdev);
+ struct pci_dev *pdev = pd->pdev;
void *buf_cpu;
dma_addr_t buf_dma;
int i;
@@ -833,8 +828,11 @@ static int dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id)
if (!pd)
return -ENOMEM;
+ err = v4l2_device_register(&pdev->dev, &pd->v4l2_dev);
+ if (err)
+ return err;
pd->vdev = dt3155_vdev;
- pci_set_drvdata(pdev, pd); /* for use in dt3155_remove() */
+ pd->vdev.v4l2_dev = &pd->v4l2_dev;
video_set_drvdata(&pd->vdev, pd); /* for use in video_fops */
pd->users = 0;
pd->pdev = pdev;
@@ -846,42 +844,53 @@ static int dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id)
pd->config = config_init;
err = pci_enable_device(pdev);
if (err)
- return err;
+ goto err_v4l2_dev_unreg;
err = pci_request_region(pdev, 0, pci_name(pdev));
if (err)
- goto err_req_region;
+ goto err_pci_disable;
pd->regs = pci_iomap(pdev, 0, pci_resource_len(pd->pdev, 0));
if (!pd->regs) {
err = -ENOMEM;
- goto err_pci_iomap;
+ goto err_free_reg;
}
- err = dt3155_init_board(pdev);
+ err = dt3155_init_board(pd);
+ if (err)
+ goto err_iounmap;
+ err = request_irq(pd->pdev->irq, dt3155_irq_handler_even,
+ IRQF_SHARED, DT3155_NAME, pd);
if (err)
- goto err_init_board;
+ goto err_iounmap;
err = video_register_device(&pd->vdev, VFL_TYPE_GRABBER, -1);
if (err)
- goto err_init_board;
+ goto err_free_irq;
if (dt3155_alloc_coherent(&pdev->dev, DT3155_CHUNK_SIZE,
DMA_MEMORY_MAP))
dev_info(&pdev->dev, "preallocated 8 buffers\n");
dev_info(&pdev->dev, "/dev/video%i is ready\n", pd->vdev.minor);
return 0; /* success */
-err_init_board:
+err_free_irq:
+ free_irq(pd->pdev->irq, pd);
+err_iounmap:
pci_iounmap(pdev, pd->regs);
-err_pci_iomap:
+err_free_reg:
pci_release_region(pdev, 0);
-err_req_region:
+err_pci_disable:
pci_disable_device(pdev);
+err_v4l2_dev_unreg:
+ v4l2_device_unregister(&pd->v4l2_dev);
return err;
}
static void dt3155_remove(struct pci_dev *pdev)
{
- struct dt3155_priv *pd = pci_get_drvdata(pdev);
+ struct v4l2_device *v4l2_dev = pci_get_drvdata(pdev);
+ struct dt3155_priv *pd = container_of(v4l2_dev, struct dt3155_priv, v4l2_dev);
dt3155_free_coherent(&pdev->dev);
video_unregister_device(&pd->vdev);
+ free_irq(pd->pdev->irq, pd);
+ v4l2_device_unregister(&pd->v4l2_dev);
pci_iounmap(pdev, pd->regs);
pci_release_region(pdev, 0);
pci_disable_device(pdev);
diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.h b/drivers/staging/media/dt3155v4l/dt3155v4l.h
index b4cb412..16faefe 100644
--- a/drivers/staging/media/dt3155v4l/dt3155v4l.h
+++ b/drivers/staging/media/dt3155v4l/dt3155v4l.h
@@ -20,6 +20,8 @@
#include <linux/pci.h>
#include <linux/interrupt.h>
+#include <media/v4l2-device.h>
+#include <media/v4l2-dev.h>
#define DT3155_NAME "dt3155"
#define DT3155_VER_MAJ 1
@@ -157,6 +159,7 @@
/**
* struct dt3155_priv - private data structure
*
+ * @v4l2_dev: v4l2_device structure
* @vdev: video_device structure
* @pdev: pointer to pci_dev structure
* @q pointer to vb2_queue structure
@@ -172,6 +175,7 @@
* @config: local copy of config register
*/
struct dt3155_priv {
+ struct v4l2_device v4l2_dev;
struct video_device vdev;
struct pci_dev *pdev;
struct vb2_queue *q;
--
2.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 04/12] dt3155v4l: remove pointless dt3155_alloc/free_coherent
2015-04-25 15:42 [PATCH 00/12] dt3155v4l: clean up and move out of staging Hans Verkuil
` (2 preceding siblings ...)
2015-04-25 15:42 ` [PATCH 03/12] dt3155v4l: add v4l2_device support Hans Verkuil
@ 2015-04-25 15:42 ` Hans Verkuil
2015-04-25 15:42 ` [PATCH 05/12] dt3155v4l: remove bogus single-frame capture in init_board Hans Verkuil
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Hans Verkuil @ 2015-04-25 15:42 UTC (permalink / raw)
To: linux-media; +Cc: Hans Verkuil
From: Hans Verkuil <hans.verkuil@cisco.com>
No idea what the purpose is of these functions. I suspect this was used
once upon a time to pre-allocate buffer memory. But the allocated memory
isn't used anywhere anymore, so just remove this code.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
drivers/staging/media/dt3155v4l/dt3155v4l.c | 71 -----------------------------
1 file changed, 71 deletions(-)
diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.c b/drivers/staging/media/dt3155v4l/dt3155v4l.c
index 564483a..34836f6 100644
--- a/drivers/staging/media/dt3155v4l/dt3155v4l.c
+++ b/drivers/staging/media/dt3155v4l/dt3155v4l.c
@@ -29,11 +29,6 @@
#define DT3155_DEVICE_ID 0x1223
-/* DT3155_CHUNK_SIZE is 4M (2^22) 8 full size buffers */
-#define DT3155_CHUNK_SIZE (1U << 22)
-
-#define DT3155_COH_FLAGS (GFP_KERNEL | GFP_DMA32 | __GFP_COLD | __GFP_NOWARN)
-
#define DT3155_BUF_SIZE (768 * 576)
#ifdef CONFIG_DT3155_STREAMING
@@ -754,68 +749,6 @@ static struct video_device dt3155_vdev = {
.tvnorms = DT3155_CURRENT_NORM,
};
-/* same as in drivers/base/dma-coherent.c */
-struct dma_coherent_mem {
- void *virt_base;
- dma_addr_t device_base;
- int size;
- int flags;
- unsigned long *bitmap;
-};
-
-static int dt3155_alloc_coherent(struct device *dev, size_t size, int flags)
-{
- struct dma_coherent_mem *mem;
- dma_addr_t dev_base;
- int pages = size >> PAGE_SHIFT;
- int bitmap_size = BITS_TO_LONGS(pages) * sizeof(long);
-
- if ((flags & DMA_MEMORY_MAP) == 0)
- goto out;
- if (!size)
- goto out;
- if (dev->dma_mem)
- goto out;
-
- mem = kzalloc(sizeof(*mem), GFP_KERNEL);
- if (!mem)
- goto out;
- mem->virt_base = dma_alloc_coherent(dev, size, &dev_base,
- DT3155_COH_FLAGS);
- if (!mem->virt_base)
- goto err_alloc_coherent;
- mem->bitmap = kzalloc(bitmap_size, GFP_KERNEL);
- if (!mem->bitmap)
- goto err_bitmap;
-
- /* coherent_dma_mask is already set to 32 bits */
- mem->device_base = dev_base;
- mem->size = pages;
- mem->flags = flags;
- dev->dma_mem = mem;
- return DMA_MEMORY_MAP;
-
-err_bitmap:
- dma_free_coherent(dev, size, mem->virt_base, dev_base);
-err_alloc_coherent:
- kfree(mem);
-out:
- return 0;
-}
-
-static void dt3155_free_coherent(struct device *dev)
-{
- struct dma_coherent_mem *mem = dev->dma_mem;
-
- if (!mem)
- return;
- dev->dma_mem = NULL;
- dma_free_coherent(dev, mem->size << PAGE_SHIFT,
- mem->virt_base, mem->device_base);
- kfree(mem->bitmap);
- kfree(mem);
-}
-
static int dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
int err;
@@ -863,9 +796,6 @@ static int dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id)
err = video_register_device(&pd->vdev, VFL_TYPE_GRABBER, -1);
if (err)
goto err_free_irq;
- if (dt3155_alloc_coherent(&pdev->dev, DT3155_CHUNK_SIZE,
- DMA_MEMORY_MAP))
- dev_info(&pdev->dev, "preallocated 8 buffers\n");
dev_info(&pdev->dev, "/dev/video%i is ready\n", pd->vdev.minor);
return 0; /* success */
@@ -887,7 +817,6 @@ static void dt3155_remove(struct pci_dev *pdev)
struct v4l2_device *v4l2_dev = pci_get_drvdata(pdev);
struct dt3155_priv *pd = container_of(v4l2_dev, struct dt3155_priv, v4l2_dev);
- dt3155_free_coherent(&pdev->dev);
video_unregister_device(&pd->vdev);
free_irq(pd->pdev->irq, pd);
v4l2_device_unregister(&pd->v4l2_dev);
--
2.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 05/12] dt3155v4l: remove bogus single-frame capture in init_board
2015-04-25 15:42 [PATCH 00/12] dt3155v4l: clean up and move out of staging Hans Verkuil
` (3 preceding siblings ...)
2015-04-25 15:42 ` [PATCH 04/12] dt3155v4l: remove pointless dt3155_alloc/free_coherent Hans Verkuil
@ 2015-04-25 15:42 ` Hans Verkuil
2015-04-25 15:42 ` [PATCH 06/12] dt3155v4l: move vb2_queue to top-level Hans Verkuil
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Hans Verkuil @ 2015-04-25 15:42 UTC (permalink / raw)
To: linux-media; +Cc: Hans Verkuil
From: Hans Verkuil <hans.verkuil@cisco.com>
For some weird reason an attempt is made in init_board to capture a
single frame. No clue why, and everything works fine without that
code.
I suspect this was test code that was never removed.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
drivers/staging/media/dt3155v4l/dt3155v4l.c | 41 +++++------------------------
drivers/staging/media/dt3155v4l/dt3155v4l.h | 3 +++
2 files changed, 10 insertions(+), 34 deletions(-)
diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.c b/drivers/staging/media/dt3155v4l/dt3155v4l.c
index 34836f6..28b649d 100644
--- a/drivers/staging/media/dt3155v4l/dt3155v4l.c
+++ b/drivers/staging/media/dt3155v4l/dt3155v4l.c
@@ -29,8 +29,6 @@
#define DT3155_DEVICE_ID 0x1223
-#define DT3155_BUF_SIZE (768 * 576)
-
#ifdef CONFIG_DT3155_STREAMING
#define DT3155_CAPTURE_METHOD V4L2_CAP_STREAMING
#else
@@ -645,16 +643,14 @@ static const struct v4l2_ioctl_ops dt3155_ioctl_ops = {
static int dt3155_init_board(struct dt3155_priv *pd)
{
struct pci_dev *pdev = pd->pdev;
- void *buf_cpu;
- dma_addr_t buf_dma;
int i;
- u8 tmp;
+ u8 tmp = 0;
pci_set_master(pdev); /* dt3155 needs it */
/* resetting the adapter */
- iowrite32(FLD_CRPT_ODD | FLD_CRPT_EVEN | FLD_DN_ODD | FLD_DN_EVEN,
- pd->regs + CSR1);
+ iowrite32(ADDR_ERR_ODD | ADDR_ERR_EVEN | FLD_CRPT_ODD | FLD_CRPT_EVEN |
+ FLD_DN_ODD | FLD_DN_EVEN, pd->regs + CSR1);
mmiowb();
msleep(20);
@@ -710,33 +706,10 @@ static int dt3155_init_board(struct dt3155_priv *pd)
write_i2c_reg(pd->regs, AD_ADDR, AD_CMD_REG);
write_i2c_reg(pd->regs, AD_CMD, VIDEO_CNL_1 | SYNC_CNL_1 | SYNC_LVL_3);
- /* allocate memory, and initialize the DMA machine */
- buf_cpu = dma_alloc_coherent(&pdev->dev, DT3155_BUF_SIZE, &buf_dma,
- GFP_KERNEL);
- if (!buf_cpu)
- return -ENOMEM;
- iowrite32(buf_dma, pd->regs + EVEN_DMA_START);
- iowrite32(buf_dma, pd->regs + ODD_DMA_START);
- iowrite32(0, pd->regs + EVEN_DMA_STRIDE);
- iowrite32(0, pd->regs + ODD_DMA_STRIDE);
-
- /* Perform a pseudo even field acquire */
- iowrite32(FIFO_EN | SRST | CAP_CONT_ODD, pd->regs + CSR1);
- write_i2c_reg(pd->regs, CSR2, pd->csr2 | SYNC_SNTL);
- write_i2c_reg(pd->regs, CONFIG, pd->config);
- write_i2c_reg(pd->regs, EVEN_CSR, CSR_SNGL);
- write_i2c_reg(pd->regs, CSR2, pd->csr2 | BUSY_EVEN | SYNC_SNTL);
- msleep(100);
- read_i2c_reg(pd->regs, CSR2, &tmp);
- write_i2c_reg(pd->regs, EVEN_CSR, CSR_ERROR | CSR_SNGL | CSR_DONE);
- write_i2c_reg(pd->regs, ODD_CSR, CSR_ERROR | CSR_SNGL | CSR_DONE);
- write_i2c_reg(pd->regs, CSR2, pd->csr2);
- iowrite32(FIFO_EN | SRST | FLD_DN_EVEN | FLD_DN_ODD, pd->regs + CSR1);
-
- /* deallocate memory */
- dma_free_coherent(&pdev->dev, DT3155_BUF_SIZE, buf_cpu, buf_dma);
- if (tmp & BUSY_EVEN)
- return -EIO;
+ /* disable all irqs, clear all irq flags */
+ iowrite32(FLD_START | FLD_END_EVEN | FLD_END_ODD,
+ pd->regs + INT_CSR);
+
return 0;
}
diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.h b/drivers/staging/media/dt3155v4l/dt3155v4l.h
index 16faefe..3c8073a 100644
--- a/drivers/staging/media/dt3155v4l/dt3155v4l.h
+++ b/drivers/staging/media/dt3155v4l/dt3155v4l.h
@@ -74,7 +74,10 @@
#define AD_NEG_REF 0x02
/* CSR1 bit masks */
+#define RANGE_EN 0x00008000
#define CRPT_DIS 0x00004000
+#define ADDR_ERR_ODD 0x00000800
+#define ADDR_ERR_EVEN 0x00000400
#define FLD_CRPT_ODD 0x00000200
#define FLD_CRPT_EVEN 0x00000100
#define FIFO_EN 0x00000080
--
2.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 06/12] dt3155v4l: move vb2_queue to top-level
2015-04-25 15:42 [PATCH 00/12] dt3155v4l: clean up and move out of staging Hans Verkuil
` (4 preceding siblings ...)
2015-04-25 15:42 ` [PATCH 05/12] dt3155v4l: remove bogus single-frame capture in init_board Hans Verkuil
@ 2015-04-25 15:42 ` Hans Verkuil
2015-04-25 15:42 ` [PATCH 07/12] dt3155v4l: drop CONFIG_DT3155_STREAMING Hans Verkuil
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Hans Verkuil @ 2015-04-25 15:42 UTC (permalink / raw)
To: linux-media; +Cc: Hans Verkuil
From: Hans Verkuil <hans.verkuil@cisco.com>
Instead of initializing the vb2_queue in open (and freeing in release)
do this in probe/remove instead. And as a bonus use the vb2 helper
functions to greatly simplify the driver.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
drivers/staging/media/dt3155v4l/dt3155v4l.c | 233 +++++++---------------------
drivers/staging/media/dt3155v4l/dt3155v4l.h | 8 +-
2 files changed, 57 insertions(+), 184 deletions(-)
diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.c b/drivers/staging/media/dt3155v4l/dt3155v4l.c
index 28b649d..6d571f6 100644
--- a/drivers/staging/media/dt3155v4l/dt3155v4l.c
+++ b/drivers/staging/media/dt3155v4l/dt3155v4l.c
@@ -201,41 +201,24 @@ static int dt3155_start_acq(struct dt3155_priv *pd)
}
static int
-dt3155_queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt,
- unsigned int *num_buffers, unsigned int *num_planes,
+dt3155_queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt,
+ unsigned int *nbuffers, unsigned int *num_planes,
unsigned int sizes[], void *alloc_ctxs[])
{
- struct dt3155_priv *pd = vb2_get_drv_priv(q);
- void *ret;
+ struct dt3155_priv *pd = vb2_get_drv_priv(vq);
+ unsigned size = img_width * img_height;
- if (*num_buffers == 0)
- *num_buffers = 1;
+ if (vq->num_buffers + *nbuffers < 2)
+ *nbuffers = 2 - vq->num_buffers;
+ if (fmt && fmt->fmt.pix.sizeimage < size)
+ return -EINVAL;
*num_planes = 1;
- sizes[0] = img_width * img_height;
- if (pd->q->alloc_ctx[0])
- return 0;
- ret = vb2_dma_contig_init_ctx(&pd->pdev->dev);
- if (IS_ERR(ret))
- return PTR_ERR(ret);
- pd->q->alloc_ctx[0] = ret;
+ sizes[0] = fmt ? fmt->fmt.pix.sizeimage : size;
+ alloc_ctxs[0] = pd->alloc_ctx;
return 0;
}
-static void dt3155_wait_prepare(struct vb2_queue *q)
-{
- struct dt3155_priv *pd = vb2_get_drv_priv(q);
-
- mutex_unlock(pd->vdev.lock);
-}
-
-static void dt3155_wait_finish(struct vb2_queue *q)
-{
- struct dt3155_priv *pd = vb2_get_drv_priv(q);
-
- mutex_lock(pd->vdev.lock);
-}
-
static int dt3155_buf_prepare(struct vb2_buffer *vb)
{
vb2_set_plane_payload(vb, 0, img_width * img_height);
@@ -255,6 +238,9 @@ static void dt3155_stop_streaming(struct vb2_queue *q)
}
spin_unlock_irq(&pd->lock);
msleep(45); /* irq hendler will stop the hardware */
+ /* disable all irqs, clear all irq flags */
+ iowrite32(FLD_START | FLD_END_EVEN | FLD_END_ODD,
+ pd->regs + INT_CSR);
}
static void dt3155_buf_queue(struct vb2_buffer *vb)
@@ -274,8 +260,8 @@ static void dt3155_buf_queue(struct vb2_buffer *vb)
static const struct vb2_ops q_ops = {
.queue_setup = dt3155_queue_setup,
- .wait_prepare = dt3155_wait_prepare,
- .wait_finish = dt3155_wait_finish,
+ .wait_prepare = vb2_ops_wait_prepare,
+ .wait_finish = vb2_ops_wait_finish,
.buf_prepare = dt3155_buf_prepare,
.stop_streaming = dt3155_stop_streaming,
.buf_queue = dt3155_buf_queue,
@@ -313,7 +299,7 @@ static irqreturn_t dt3155_irq_handler_even(int irq, void *dev_id)
vb2_buffer_done(ipd->curr_buf, VB2_BUF_STATE_DONE);
}
- if (!ipd->q->streaming || list_empty(&ipd->dmaq))
+ if (!ipd->vidq.streaming || list_empty(&ipd->dmaq))
goto stop_dma;
ivb = list_first_entry(&ipd->dmaq, typeof(*ivb), done_entry);
list_del(&ivb->done_entry);
@@ -342,124 +328,16 @@ stop_dma:
return IRQ_HANDLED;
}
-static int dt3155_open(struct file *filp)
-{
- int ret = 0;
- struct dt3155_priv *pd = video_drvdata(filp);
-
- if (mutex_lock_interruptible(&pd->mux))
- return -ERESTARTSYS;
- if (!pd->users) {
- pd->q = kzalloc(sizeof(*pd->q), GFP_KERNEL);
- if (!pd->q) {
- ret = -ENOMEM;
- goto err_alloc_queue;
- }
- pd->q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- pd->q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
- pd->q->io_modes = VB2_READ | VB2_MMAP;
- pd->q->ops = &q_ops;
- pd->q->mem_ops = &vb2_dma_contig_memops;
- pd->q->drv_priv = pd;
- pd->curr_buf = NULL;
- pd->field_count = 0;
- ret = vb2_queue_init(pd->q);
- if (ret < 0)
- goto err_request_irq;
- INIT_LIST_HEAD(&pd->dmaq);
- spin_lock_init(&pd->lock);
- /* disable all irqs, clear all irq flags */
- iowrite32(FLD_START | FLD_END_EVEN | FLD_END_ODD,
- pd->regs + INT_CSR);
- }
- pd->users++;
- mutex_unlock(&pd->mux);
- return 0; /* success */
-err_request_irq:
- kfree(pd->q);
- pd->q = NULL;
-err_alloc_queue:
- mutex_unlock(&pd->mux);
- return ret;
-}
-
-static int dt3155_release(struct file *filp)
-{
- struct dt3155_priv *pd = video_drvdata(filp);
-
- mutex_lock(&pd->mux);
- pd->users--;
- BUG_ON(pd->users < 0);
- if (!pd->users) {
- vb2_queue_release(pd->q);
- if (pd->q->alloc_ctx[0])
- vb2_dma_contig_cleanup_ctx(pd->q->alloc_ctx[0]);
- kfree(pd->q);
- pd->q = NULL;
- }
- mutex_unlock(&pd->mux);
- return 0;
-}
-
-static ssize_t dt3155_read(struct file *filp, char __user *user, size_t size, loff_t *loff)
-{
- struct dt3155_priv *pd = video_drvdata(filp);
- ssize_t res;
-
- if (mutex_lock_interruptible(&pd->mux))
- return -ERESTARTSYS;
- res = vb2_read(pd->q, user, size, loff, filp->f_flags & O_NONBLOCK);
- mutex_unlock(&pd->mux);
- return res;
-}
-
-static unsigned int dt3155_poll(struct file *filp, struct poll_table_struct *polltbl)
-{
- struct dt3155_priv *pd = video_drvdata(filp);
- unsigned int res;
-
- mutex_lock(&pd->mux);
- res = vb2_poll(pd->q, filp, polltbl);
- mutex_unlock(&pd->mux);
- return res;
-}
-
-static int dt3155_mmap(struct file *filp, struct vm_area_struct *vma)
-{
- struct dt3155_priv *pd = video_drvdata(filp);
- int res;
-
- if (mutex_lock_interruptible(&pd->mux))
- return -ERESTARTSYS;
- res = vb2_mmap(pd->q, vma);
- mutex_unlock(&pd->mux);
- return res;
-}
-
static const struct v4l2_file_operations dt3155_fops = {
.owner = THIS_MODULE,
- .open = dt3155_open,
- .release = dt3155_release,
- .read = dt3155_read,
- .poll = dt3155_poll,
- .unlocked_ioctl = video_ioctl2, /* V4L2 ioctl handler */
- .mmap = dt3155_mmap,
+ .open = v4l2_fh_open,
+ .release = vb2_fop_release,
+ .unlocked_ioctl = video_ioctl2,
+ .read = vb2_fop_read,
+ .mmap = vb2_fop_mmap,
+ .poll = vb2_fop_poll
};
-static int dt3155_streamon(struct file *filp, void *p, enum v4l2_buf_type type)
-{
- struct dt3155_priv *pd = video_drvdata(filp);
-
- return vb2_streamon(pd->q, type);
-}
-
-static int dt3155_streamoff(struct file *filp, void *p, enum v4l2_buf_type type)
-{
- struct dt3155_priv *pd = video_drvdata(filp);
-
- return vb2_streamoff(pd->q, type);
-}
-
static int dt3155_querycap(struct file *filp, void *p, struct v4l2_capability *cap)
{
struct dt3155_priv *pd = video_drvdata(filp);
@@ -516,34 +394,6 @@ static int dt3155_s_fmt_vid_cap(struct file *filp, void *p, struct v4l2_format *
return dt3155_g_fmt_vid_cap(filp, p, f);
}
-static int dt3155_reqbufs(struct file *filp, void *p, struct v4l2_requestbuffers *b)
-{
- struct dt3155_priv *pd = video_drvdata(filp);
-
- return vb2_reqbufs(pd->q, b);
-}
-
-static int dt3155_querybuf(struct file *filp, void *p, struct v4l2_buffer *b)
-{
- struct dt3155_priv *pd = video_drvdata(filp);
-
- return vb2_querybuf(pd->q, b);
-}
-
-static int dt3155_qbuf(struct file *filp, void *p, struct v4l2_buffer *b)
-{
- struct dt3155_priv *pd = video_drvdata(filp);
-
- return vb2_qbuf(pd->q, b);
-}
-
-static int dt3155_dqbuf(struct file *filp, void *p, struct v4l2_buffer *b)
-{
- struct dt3155_priv *pd = video_drvdata(filp);
-
- return vb2_dqbuf(pd->q, b, filp->f_flags & O_NONBLOCK);
-}
-
static int dt3155_querystd(struct file *filp, void *p, v4l2_std_id *norm)
{
*norm = DT3155_CURRENT_NORM;
@@ -619,17 +469,19 @@ static int dt3155_s_parm(struct file *filp, void *p, struct v4l2_streamparm *par
}
static const struct v4l2_ioctl_ops dt3155_ioctl_ops = {
- .vidioc_streamon = dt3155_streamon,
- .vidioc_streamoff = dt3155_streamoff,
.vidioc_querycap = dt3155_querycap,
.vidioc_enum_fmt_vid_cap = dt3155_enum_fmt_vid_cap,
.vidioc_try_fmt_vid_cap = dt3155_try_fmt_vid_cap,
.vidioc_g_fmt_vid_cap = dt3155_g_fmt_vid_cap,
.vidioc_s_fmt_vid_cap = dt3155_s_fmt_vid_cap,
- .vidioc_reqbufs = dt3155_reqbufs,
- .vidioc_querybuf = dt3155_querybuf,
- .vidioc_qbuf = dt3155_qbuf,
- .vidioc_dqbuf = dt3155_dqbuf,
+ .vidioc_reqbufs = vb2_ioctl_reqbufs,
+ .vidioc_create_bufs = vb2_ioctl_create_bufs,
+ .vidioc_querybuf = vb2_ioctl_querybuf,
+ .vidioc_expbuf = vb2_ioctl_expbuf,
+ .vidioc_qbuf = vb2_ioctl_qbuf,
+ .vidioc_dqbuf = vb2_ioctl_dqbuf,
+ .vidioc_streamon = vb2_ioctl_streamon,
+ .vidioc_streamoff = vb2_ioctl_streamoff,
.vidioc_querystd = dt3155_querystd,
.vidioc_g_std = dt3155_g_std,
.vidioc_s_std = dt3155_s_std,
@@ -740,17 +592,34 @@ static int dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id)
pd->vdev = dt3155_vdev;
pd->vdev.v4l2_dev = &pd->v4l2_dev;
video_set_drvdata(&pd->vdev, pd); /* for use in video_fops */
- pd->users = 0;
pd->pdev = pdev;
INIT_LIST_HEAD(&pd->dmaq);
mutex_init(&pd->mux);
pd->vdev.lock = &pd->mux; /* for locking v4l2_file_operations */
+ pd->vidq.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ pd->vidq.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+ pd->vidq.io_modes = VB2_MMAP | VB2_DMABUF | VB2_READ;
+ pd->vidq.ops = &q_ops;
+ pd->vidq.mem_ops = &vb2_dma_contig_memops;
+ pd->vidq.drv_priv = pd;
+ pd->vidq.min_buffers_needed = 2;
+ pd->vidq.lock = &pd->mux; /* for locking v4l2_file_operations */
+ pd->vdev.queue = &pd->vidq;
+ err = vb2_queue_init(&pd->vidq);
+ if (err < 0)
+ goto err_v4l2_dev_unreg;
+ pd->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev);
+ if (IS_ERR(pd->alloc_ctx)) {
+ dev_err(&pdev->dev, "Can't allocate buffer context");
+ err = PTR_ERR(pd->alloc_ctx);
+ goto err_v4l2_dev_unreg;
+ }
spin_lock_init(&pd->lock);
pd->csr2 = csr2_init;
pd->config = config_init;
err = pci_enable_device(pdev);
if (err)
- goto err_v4l2_dev_unreg;
+ goto err_free_ctx;
err = pci_request_region(pdev, 0, pci_name(pdev));
if (err)
goto err_pci_disable;
@@ -780,6 +649,8 @@ err_free_reg:
pci_release_region(pdev, 0);
err_pci_disable:
pci_disable_device(pdev);
+err_free_ctx:
+ vb2_dma_contig_cleanup_ctx(pd->alloc_ctx);
err_v4l2_dev_unreg:
v4l2_device_unregister(&pd->v4l2_dev);
return err;
@@ -792,10 +663,12 @@ static void dt3155_remove(struct pci_dev *pdev)
video_unregister_device(&pd->vdev);
free_irq(pd->pdev->irq, pd);
+ vb2_queue_release(&pd->vidq);
v4l2_device_unregister(&pd->v4l2_dev);
pci_iounmap(pdev, pd->regs);
pci_release_region(pdev, 0);
pci_disable_device(pdev);
+ vb2_dma_contig_cleanup_ctx(pd->alloc_ctx);
}
static const struct pci_device_id pci_ids[] = {
diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.h b/drivers/staging/media/dt3155v4l/dt3155v4l.h
index 3c8073a..11a8146 100644
--- a/drivers/staging/media/dt3155v4l/dt3155v4l.h
+++ b/drivers/staging/media/dt3155v4l/dt3155v4l.h
@@ -165,14 +165,14 @@
* @v4l2_dev: v4l2_device structure
* @vdev: video_device structure
* @pdev: pointer to pci_dev structure
- * @q pointer to vb2_queue structure
+ * @vidq: vb2_queue structure
+ * @alloc_ctx: dma_contig allocation context
* @curr_buf: pointer to curren buffer
* @mux: mutex to protect the instance
* @dmaq queue for dma buffers
* @lock spinlock for dma queue
* @field_count fields counter
* @stats: statistics structure
- * @users open count
* @regs: local copy of mmio base register
* @csr2: local copy of csr2 register
* @config: local copy of config register
@@ -181,14 +181,14 @@ struct dt3155_priv {
struct v4l2_device v4l2_dev;
struct video_device vdev;
struct pci_dev *pdev;
- struct vb2_queue *q;
+ struct vb2_queue vidq;
+ struct vb2_alloc_ctx *alloc_ctx;
struct vb2_buffer *curr_buf;
struct mutex mux;
struct list_head dmaq;
spinlock_t lock;
unsigned int field_count;
void __iomem *regs;
- int users;
u8 csr2, config;
};
--
2.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 07/12] dt3155v4l: drop CONFIG_DT3155_STREAMING
2015-04-25 15:42 [PATCH 00/12] dt3155v4l: clean up and move out of staging Hans Verkuil
` (5 preceding siblings ...)
2015-04-25 15:42 ` [PATCH 06/12] dt3155v4l: move vb2_queue to top-level Hans Verkuil
@ 2015-04-25 15:42 ` Hans Verkuil
2015-04-25 15:42 ` [PATCH 08/12] dt3155v4l: correctly start and stop streaming Hans Verkuil
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Hans Verkuil @ 2015-04-25 15:42 UTC (permalink / raw)
To: linux-media; +Cc: Hans Verkuil
From: Hans Verkuil <hans.verkuil@cisco.com>
No need to do this as a config option. Just support both MMAP and read()
methods like any other driver.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
drivers/staging/media/dt3155v4l/Kconfig | 8 --------
drivers/staging/media/dt3155v4l/dt3155v4l.c | 8 +-------
2 files changed, 1 insertion(+), 15 deletions(-)
diff --git a/drivers/staging/media/dt3155v4l/Kconfig b/drivers/staging/media/dt3155v4l/Kconfig
index 2d49600..fcba866 100644
--- a/drivers/staging/media/dt3155v4l/Kconfig
+++ b/drivers/staging/media/dt3155v4l/Kconfig
@@ -19,11 +19,3 @@ config DT3155_CCIR
---help---
Select it for CCIR/50Hz (European region),
or leave it unselected for RS-170/60Hz (North America).
-
-config DT3155_STREAMING
- bool "Selects streaming capture method"
- depends on VIDEO_DT3155
- default y
- ---help---
- Select it if you want to use streaming of memory mapped buffers
- or leave it unselected if you want to use read method (one copy more).
diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.c b/drivers/staging/media/dt3155v4l/dt3155v4l.c
index 6d571f6..0162c62 100644
--- a/drivers/staging/media/dt3155v4l/dt3155v4l.c
+++ b/drivers/staging/media/dt3155v4l/dt3155v4l.c
@@ -29,12 +29,6 @@
#define DT3155_DEVICE_ID 0x1223
-#ifdef CONFIG_DT3155_STREAMING
-#define DT3155_CAPTURE_METHOD V4L2_CAP_STREAMING
-#else
-#define DT3155_CAPTURE_METHOD V4L2_CAP_READWRITE
-#endif
-
/* global initializers (for all boards) */
#ifdef CONFIG_DT3155_CCIR
static const u8 csr2_init = VT_50HZ;
@@ -346,7 +340,7 @@ static int dt3155_querycap(struct file *filp, void *p, struct v4l2_capability *c
strcpy(cap->card, DT3155_NAME " frame grabber");
sprintf(cap->bus_info, "PCI:%s", pci_name(pd->pdev));
cap->device_caps = V4L2_CAP_VIDEO_CAPTURE |
- DT3155_CAPTURE_METHOD;
+ V4L2_CAP_STREAMING | V4L2_CAP_READWRITE;
cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
return 0;
}
--
2.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 08/12] dt3155v4l: correctly start and stop streaming
2015-04-25 15:42 [PATCH 00/12] dt3155v4l: clean up and move out of staging Hans Verkuil
` (6 preceding siblings ...)
2015-04-25 15:42 ` [PATCH 07/12] dt3155v4l: drop CONFIG_DT3155_STREAMING Hans Verkuil
@ 2015-04-25 15:42 ` Hans Verkuil
2015-04-25 15:42 ` [PATCH 09/12] dt3155v4l: drop CONFIG_DT3155_CCIR, use s_std instead Hans Verkuil
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Hans Verkuil @ 2015-04-25 15:42 UTC (permalink / raw)
To: linux-media; +Cc: Hans Verkuil
From: Hans Verkuil <hans.verkuil@cisco.com>
Don't start streaming when a buffer is queued, instead implement the
start_streaming op and do it there, leaving it up to the vb2 framework
to call start_streaming when enough buffers have been queued.
And don't stop streaming from within the interrupt routine, instead do
that in stop_streaming.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
drivers/staging/media/dt3155v4l/dt3155v4l.c | 124 +++++++++++++++-------------
drivers/staging/media/dt3155v4l/dt3155v4l.h | 4 +-
2 files changed, 67 insertions(+), 61 deletions(-)
diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.c b/drivers/staging/media/dt3155v4l/dt3155v4l.c
index 0162c62..0ce7523 100644
--- a/drivers/staging/media/dt3155v4l/dt3155v4l.c
+++ b/drivers/staging/media/dt3155v4l/dt3155v4l.c
@@ -168,32 +168,6 @@ static int wait_i2c_reg(void __iomem *addr)
return 0;
}
-static int dt3155_start_acq(struct dt3155_priv *pd)
-{
- struct vb2_buffer *vb = pd->curr_buf;
- dma_addr_t dma_addr;
-
- dma_addr = vb2_dma_contig_plane_dma_addr(vb, 0);
- iowrite32(dma_addr, pd->regs + EVEN_DMA_START);
- iowrite32(dma_addr + img_width, pd->regs + ODD_DMA_START);
- iowrite32(img_width, pd->regs + EVEN_DMA_STRIDE);
- iowrite32(img_width, pd->regs + ODD_DMA_STRIDE);
- /* enable interrupts, clear all irq flags */
- iowrite32(FLD_START_EN | FLD_END_ODD_EN | FLD_START |
- FLD_END_EVEN | FLD_END_ODD, pd->regs + INT_CSR);
- iowrite32(FIFO_EN | SRST | FLD_CRPT_ODD | FLD_CRPT_EVEN |
- FLD_DN_ODD | FLD_DN_EVEN | CAP_CONT_EVEN | CAP_CONT_ODD,
- pd->regs + CSR1);
- wait_i2c_reg(pd->regs);
- write_i2c_reg(pd->regs, CONFIG, pd->config);
- write_i2c_reg(pd->regs, EVEN_CSR, CSR_ERROR | CSR_DONE);
- write_i2c_reg(pd->regs, ODD_CSR, CSR_ERROR | CSR_DONE);
-
- /* start the board */
- write_i2c_reg(pd->regs, CSR2, pd->csr2 | BUSY_EVEN | BUSY_ODD);
- return 0; /* success */
-}
-
static int
dt3155_queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt,
unsigned int *nbuffers, unsigned int *num_planes,
@@ -219,36 +193,79 @@ static int dt3155_buf_prepare(struct vb2_buffer *vb)
return 0;
}
+static int dt3155_start_streaming(struct vb2_queue *q, unsigned count)
+{
+ struct dt3155_priv *pd = vb2_get_drv_priv(q);
+ struct vb2_buffer *vb = pd->curr_buf;
+ dma_addr_t dma_addr;
+
+ pd->sequence = 0;
+ dma_addr = vb2_dma_contig_plane_dma_addr(vb, 0);
+ iowrite32(dma_addr, pd->regs + EVEN_DMA_START);
+ iowrite32(dma_addr + img_width, pd->regs + ODD_DMA_START);
+ iowrite32(img_width, pd->regs + EVEN_DMA_STRIDE);
+ iowrite32(img_width, pd->regs + ODD_DMA_STRIDE);
+ /* enable interrupts, clear all irq flags */
+ iowrite32(FLD_START_EN | FLD_END_ODD_EN | FLD_START |
+ FLD_END_EVEN | FLD_END_ODD, pd->regs + INT_CSR);
+ iowrite32(FIFO_EN | SRST | FLD_CRPT_ODD | FLD_CRPT_EVEN |
+ FLD_DN_ODD | FLD_DN_EVEN | CAP_CONT_EVEN | CAP_CONT_ODD,
+ pd->regs + CSR1);
+ wait_i2c_reg(pd->regs);
+ write_i2c_reg(pd->regs, CONFIG, pd->config);
+ write_i2c_reg(pd->regs, EVEN_CSR, CSR_ERROR | CSR_DONE);
+ write_i2c_reg(pd->regs, ODD_CSR, CSR_ERROR | CSR_DONE);
+
+ /* start the board */
+ write_i2c_reg(pd->regs, CSR2, pd->csr2 | BUSY_EVEN | BUSY_ODD);
+ return 0;
+}
+
static void dt3155_stop_streaming(struct vb2_queue *q)
{
struct dt3155_priv *pd = vb2_get_drv_priv(q);
struct vb2_buffer *vb;
spin_lock_irq(&pd->lock);
+ /* stop the board */
+ write_i2c_reg_nowait(pd->regs, CSR2, pd->csr2);
+ iowrite32(FIFO_EN | SRST | FLD_CRPT_ODD | FLD_CRPT_EVEN |
+ FLD_DN_ODD | FLD_DN_EVEN, pd->regs + CSR1);
+ /* disable interrupts, clear all irq flags */
+ iowrite32(FLD_START | FLD_END_EVEN | FLD_END_ODD, pd->regs + INT_CSR);
+ spin_unlock_irq(&pd->lock);
+
+ /*
+ * It is not clear whether the DMA stops at once or whether it
+ * will finish the current frame or field first. To be on the
+ * safe side we wait a bit.
+ */
+ msleep(45);
+
+ spin_lock_irq(&pd->lock);
+ if (pd->curr_buf) {
+ vb2_buffer_done(pd->curr_buf, VB2_BUF_STATE_ERROR);
+ pd->curr_buf = NULL;
+ }
+
while (!list_empty(&pd->dmaq)) {
vb = list_first_entry(&pd->dmaq, typeof(*vb), done_entry);
list_del(&vb->done_entry);
vb2_buffer_done(vb, VB2_BUF_STATE_ERROR);
}
spin_unlock_irq(&pd->lock);
- msleep(45); /* irq hendler will stop the hardware */
- /* disable all irqs, clear all irq flags */
- iowrite32(FLD_START | FLD_END_EVEN | FLD_END_ODD,
- pd->regs + INT_CSR);
}
static void dt3155_buf_queue(struct vb2_buffer *vb)
{
struct dt3155_priv *pd = vb2_get_drv_priv(vb->vb2_queue);
- /* pd->q->streaming = 1 when dt3155_buf_queue() is invoked */
+ /* pd->vidq.streaming = 1 when dt3155_buf_queue() is invoked */
spin_lock_irq(&pd->lock);
if (pd->curr_buf)
list_add_tail(&vb->done_entry, &pd->dmaq);
- else {
+ else
pd->curr_buf = vb;
- dt3155_start_acq(pd);
- }
spin_unlock_irq(&pd->lock);
}
@@ -257,6 +274,7 @@ static const struct vb2_ops q_ops = {
.wait_prepare = vb2_ops_wait_prepare,
.wait_finish = vb2_ops_wait_finish,
.buf_prepare = dt3155_buf_prepare,
+ .start_streaming = dt3155_start_streaming,
.stop_streaming = dt3155_stop_streaming,
.buf_queue = dt3155_buf_queue,
};
@@ -274,7 +292,6 @@ static irqreturn_t dt3155_irq_handler_even(int irq, void *dev_id)
if ((tmp & FLD_START) && !(tmp & FLD_END_ODD)) {
iowrite32(FLD_START_EN | FLD_END_ODD_EN | FLD_START,
ipd->regs + INT_CSR);
- ipd->field_count++;
return IRQ_HANDLED; /* start of field irq */
}
tmp = ioread32(ipd->regs + CSR1) & (FLD_CRPT_EVEN | FLD_CRPT_ODD);
@@ -287,39 +304,28 @@ static irqreturn_t dt3155_irq_handler_even(int irq, void *dev_id)
}
spin_lock(&ipd->lock);
- if (ipd->curr_buf) {
+ if (ipd->curr_buf && !list_empty(&ipd->dmaq)) {
v4l2_get_timestamp(&ipd->curr_buf->v4l2_buf.timestamp);
- ipd->curr_buf->v4l2_buf.sequence = (ipd->field_count) >> 1;
+ ipd->curr_buf->v4l2_buf.sequence = ipd->sequence++;
+ ipd->curr_buf->v4l2_buf.field = V4L2_FIELD_NONE;
vb2_buffer_done(ipd->curr_buf, VB2_BUF_STATE_DONE);
+
+ ivb = list_first_entry(&ipd->dmaq, typeof(*ivb), done_entry);
+ list_del(&ivb->done_entry);
+ ipd->curr_buf = ivb;
+ dma_addr = vb2_dma_contig_plane_dma_addr(ivb, 0);
+ iowrite32(dma_addr, ipd->regs + EVEN_DMA_START);
+ iowrite32(dma_addr + img_width, ipd->regs + ODD_DMA_START);
+ iowrite32(img_width, ipd->regs + EVEN_DMA_STRIDE);
+ iowrite32(img_width, ipd->regs + ODD_DMA_STRIDE);
+ mmiowb();
}
- if (!ipd->vidq.streaming || list_empty(&ipd->dmaq))
- goto stop_dma;
- ivb = list_first_entry(&ipd->dmaq, typeof(*ivb), done_entry);
- list_del(&ivb->done_entry);
- ipd->curr_buf = ivb;
- dma_addr = vb2_dma_contig_plane_dma_addr(ivb, 0);
- iowrite32(dma_addr, ipd->regs + EVEN_DMA_START);
- iowrite32(dma_addr + img_width, ipd->regs + ODD_DMA_START);
- iowrite32(img_width, ipd->regs + EVEN_DMA_STRIDE);
- iowrite32(img_width, ipd->regs + ODD_DMA_STRIDE);
- mmiowb();
/* enable interrupts, clear all irq flags */
iowrite32(FLD_START_EN | FLD_END_ODD_EN | FLD_START |
FLD_END_EVEN | FLD_END_ODD, ipd->regs + INT_CSR);
spin_unlock(&ipd->lock);
return IRQ_HANDLED;
-
-stop_dma:
- ipd->curr_buf = NULL;
- /* stop the board */
- write_i2c_reg_nowait(ipd->regs, CSR2, ipd->csr2);
- iowrite32(FIFO_EN | SRST | FLD_CRPT_ODD | FLD_CRPT_EVEN |
- FLD_DN_ODD | FLD_DN_EVEN, ipd->regs + CSR1);
- /* disable interrupts, clear all irq flags */
- iowrite32(FLD_START | FLD_END_EVEN | FLD_END_ODD, ipd->regs + INT_CSR);
- spin_unlock(&ipd->lock);
- return IRQ_HANDLED;
}
static const struct v4l2_file_operations dt3155_fops = {
diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.h b/drivers/staging/media/dt3155v4l/dt3155v4l.h
index 11a8146..acecf83 100644
--- a/drivers/staging/media/dt3155v4l/dt3155v4l.h
+++ b/drivers/staging/media/dt3155v4l/dt3155v4l.h
@@ -171,7 +171,7 @@
* @mux: mutex to protect the instance
* @dmaq queue for dma buffers
* @lock spinlock for dma queue
- * @field_count fields counter
+ * @sequence frame counter
* @stats: statistics structure
* @regs: local copy of mmio base register
* @csr2: local copy of csr2 register
@@ -187,7 +187,7 @@ struct dt3155_priv {
struct mutex mux;
struct list_head dmaq;
spinlock_t lock;
- unsigned int field_count;
+ unsigned int sequence;
void __iomem *regs;
u8 csr2, config;
};
--
2.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 09/12] dt3155v4l: drop CONFIG_DT3155_CCIR, use s_std instead
2015-04-25 15:42 [PATCH 00/12] dt3155v4l: clean up and move out of staging Hans Verkuil
` (7 preceding siblings ...)
2015-04-25 15:42 ` [PATCH 08/12] dt3155v4l: correctly start and stop streaming Hans Verkuil
@ 2015-04-25 15:42 ` Hans Verkuil
2015-04-25 15:42 ` [PATCH 10/12] dt3155v4l: fix format handling Hans Verkuil
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Hans Verkuil @ 2015-04-25 15:42 UTC (permalink / raw)
To: linux-media; +Cc: Hans Verkuil
From: Hans Verkuil <hans.verkuil@cisco.com>
There is no need for CONFIG_DT3155_CCIR to select between 50/60 Hz,
that's why we have s_std.
Since this is a simple framegrabber there is no need for g/s_parm.
The frame period can be obtained via ENUMSTD instead.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
drivers/staging/media/dt3155v4l/Kconfig | 8 --
drivers/staging/media/dt3155v4l/dt3155v4l.c | 132 ++++++++++------------------
drivers/staging/media/dt3155v4l/dt3155v4l.h | 17 ++--
3 files changed, 54 insertions(+), 103 deletions(-)
diff --git a/drivers/staging/media/dt3155v4l/Kconfig b/drivers/staging/media/dt3155v4l/Kconfig
index fcba866..fcbcba6 100644
--- a/drivers/staging/media/dt3155v4l/Kconfig
+++ b/drivers/staging/media/dt3155v4l/Kconfig
@@ -11,11 +11,3 @@ config VIDEO_DT3155
To compile this driver as a module, choose M here: the
module will be called dt3155v4l.
-
-config DT3155_CCIR
- bool "Selects CCIR/50Hz vertical refresh"
- depends on VIDEO_DT3155
- default y
- ---help---
- Select it for CCIR/50Hz (European region),
- or leave it unselected for RS-170/60Hz (North America).
diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.c b/drivers/staging/media/dt3155v4l/dt3155v4l.c
index 0ce7523..f026ab6 100644
--- a/drivers/staging/media/dt3155v4l/dt3155v4l.c
+++ b/drivers/staging/media/dt3155v4l/dt3155v4l.c
@@ -29,43 +29,18 @@
#define DT3155_DEVICE_ID 0x1223
-/* global initializers (for all boards) */
-#ifdef CONFIG_DT3155_CCIR
-static const u8 csr2_init = VT_50HZ;
-#define DT3155_CURRENT_NORM V4L2_STD_625_50
-static const unsigned int img_width = 768;
-static const unsigned int img_height = 576;
-static const unsigned int frames_per_sec = 25;
static const struct v4l2_fmtdesc frame_std[] = {
{
.index = 0,
.type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
.flags = 0,
- .description = "CCIR/50Hz 8 bits gray",
+ .description = "8-bit Greyscale",
.pixelformat = V4L2_PIX_FMT_GREY,
},
};
-#else
-static const u8 csr2_init = VT_60HZ;
-#define DT3155_CURRENT_NORM V4L2_STD_525_60
-static const unsigned int img_width = 640;
-static const unsigned int img_height = 480;
-static const unsigned int frames_per_sec = 30;
-static const struct v4l2_fmtdesc frame_std[] = {
- {
- .index = 0,
- .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
- .flags = 0,
- .description = "RS-170/60Hz 8 bits gray",
- .pixelformat = V4L2_PIX_FMT_GREY,
- },
-};
-#endif
#define NUM_OF_FORMATS ARRAY_SIZE(frame_std)
-static u8 config_init = ACQ_MODE_EVEN;
-
/**
* read_i2c_reg - reads an internal i2c register
*
@@ -175,7 +150,7 @@ dt3155_queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt,
{
struct dt3155_priv *pd = vb2_get_drv_priv(vq);
- unsigned size = img_width * img_height;
+ unsigned size = pd->width * pd->height;
if (vq->num_buffers + *nbuffers < 2)
*nbuffers = 2 - vq->num_buffers;
@@ -189,7 +164,9 @@ dt3155_queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt,
static int dt3155_buf_prepare(struct vb2_buffer *vb)
{
- vb2_set_plane_payload(vb, 0, img_width * img_height);
+ struct dt3155_priv *pd = vb2_get_drv_priv(vb->vb2_queue);
+
+ vb2_set_plane_payload(vb, 0, pd->width * pd->height);
return 0;
}
@@ -202,9 +179,9 @@ static int dt3155_start_streaming(struct vb2_queue *q, unsigned count)
pd->sequence = 0;
dma_addr = vb2_dma_contig_plane_dma_addr(vb, 0);
iowrite32(dma_addr, pd->regs + EVEN_DMA_START);
- iowrite32(dma_addr + img_width, pd->regs + ODD_DMA_START);
- iowrite32(img_width, pd->regs + EVEN_DMA_STRIDE);
- iowrite32(img_width, pd->regs + ODD_DMA_STRIDE);
+ iowrite32(dma_addr + pd->width, pd->regs + ODD_DMA_START);
+ iowrite32(pd->width, pd->regs + EVEN_DMA_STRIDE);
+ iowrite32(pd->width, pd->regs + ODD_DMA_STRIDE);
/* enable interrupts, clear all irq flags */
iowrite32(FLD_START_EN | FLD_END_ODD_EN | FLD_START |
FLD_END_EVEN | FLD_END_ODD, pd->regs + INT_CSR);
@@ -315,9 +292,9 @@ static irqreturn_t dt3155_irq_handler_even(int irq, void *dev_id)
ipd->curr_buf = ivb;
dma_addr = vb2_dma_contig_plane_dma_addr(ivb, 0);
iowrite32(dma_addr, ipd->regs + EVEN_DMA_START);
- iowrite32(dma_addr + img_width, ipd->regs + ODD_DMA_START);
- iowrite32(img_width, ipd->regs + EVEN_DMA_STRIDE);
- iowrite32(img_width, ipd->regs + ODD_DMA_STRIDE);
+ iowrite32(dma_addr + ipd->width, ipd->regs + ODD_DMA_START);
+ iowrite32(ipd->width, ipd->regs + EVEN_DMA_STRIDE);
+ iowrite32(ipd->width, ipd->regs + ODD_DMA_STRIDE);
mmiowb();
}
@@ -361,10 +338,12 @@ static int dt3155_enum_fmt_vid_cap(struct file *filp, void *p, struct v4l2_fmtde
static int dt3155_g_fmt_vid_cap(struct file *filp, void *p, struct v4l2_format *f)
{
+ struct dt3155_priv *pd = video_drvdata(filp);
+
if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
- f->fmt.pix.width = img_width;
- f->fmt.pix.height = img_height;
+ f->fmt.pix.width = pd->width;
+ f->fmt.pix.height = pd->height;
f->fmt.pix.pixelformat = V4L2_PIX_FMT_GREY;
f->fmt.pix.field = V4L2_FIELD_NONE;
f->fmt.pix.bytesperline = f->fmt.pix.width;
@@ -376,10 +355,12 @@ static int dt3155_g_fmt_vid_cap(struct file *filp, void *p, struct v4l2_format *
static int dt3155_try_fmt_vid_cap(struct file *filp, void *p, struct v4l2_format *f)
{
+ struct dt3155_priv *pd = video_drvdata(filp);
+
if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
- if (f->fmt.pix.width == img_width &&
- f->fmt.pix.height == img_height &&
+ if (f->fmt.pix.width == pd->width &&
+ f->fmt.pix.height == pd->height &&
f->fmt.pix.pixelformat == V4L2_PIX_FMT_GREY &&
f->fmt.pix.field == V4L2_FIELD_NONE &&
f->fmt.pix.bytesperline == f->fmt.pix.width &&
@@ -394,23 +375,33 @@ static int dt3155_s_fmt_vid_cap(struct file *filp, void *p, struct v4l2_format *
return dt3155_g_fmt_vid_cap(filp, p, f);
}
-static int dt3155_querystd(struct file *filp, void *p, v4l2_std_id *norm)
-{
- *norm = DT3155_CURRENT_NORM;
- return 0;
-}
-
static int dt3155_g_std(struct file *filp, void *p, v4l2_std_id *norm)
{
- *norm = DT3155_CURRENT_NORM;
+ struct dt3155_priv *pd = video_drvdata(filp);
+
+ *norm = pd->std;
return 0;
}
static int dt3155_s_std(struct file *filp, void *p, v4l2_std_id norm)
{
- if (norm & DT3155_CURRENT_NORM)
+ struct dt3155_priv *pd = video_drvdata(filp);
+
+ if (pd->std == norm)
return 0;
- return -EINVAL;
+ if (vb2_is_busy(&pd->vidq))
+ return -EBUSY;
+ pd->std = norm;
+ if (pd->std & V4L2_STD_525_60) {
+ pd->csr2 = VT_60HZ;
+ pd->width = 640;
+ pd->height = 480;
+ } else {
+ pd->csr2 = VT_50HZ;
+ pd->width = 768;
+ pd->height = 576;
+ }
+ return 0;
}
static int dt3155_enum_input(struct file *filp, void *p, struct v4l2_input *input)
@@ -419,13 +410,8 @@ static int dt3155_enum_input(struct file *filp, void *p, struct v4l2_input *inpu
return -EINVAL;
strcpy(input->name, "Coax in");
input->type = V4L2_INPUT_TYPE_CAMERA;
- /*
- * FIXME: input->std = 0 according to v4l2 API
- * VIDIOC_G_STD, VIDIOC_S_STD, VIDIOC_QUERYSTD and VIDIOC_ENUMSTD
- * should return -EINVAL
- */
- input->std = DT3155_CURRENT_NORM;
- input->status = 0;/* FIXME: add sync detection & V4L2_IN_ST_NO_H_LOCK */
+ input->std = V4L2_STD_ALL;
+ input->status = 0;
return 0;
}
@@ -442,32 +428,6 @@ static int dt3155_s_input(struct file *filp, void *p, unsigned int i)
return 0;
}
-static int dt3155_g_parm(struct file *filp, void *p, struct v4l2_streamparm *parms)
-{
- if (parms->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
- return -EINVAL;
- parms->parm.capture.capability = V4L2_CAP_TIMEPERFRAME;
- parms->parm.capture.capturemode = 0;
- parms->parm.capture.timeperframe.numerator = 1001;
- parms->parm.capture.timeperframe.denominator = frames_per_sec * 1000;
- parms->parm.capture.extendedmode = 0;
- parms->parm.capture.readbuffers = 1; /* FIXME: 2 buffers? */
- return 0;
-}
-
-static int dt3155_s_parm(struct file *filp, void *p, struct v4l2_streamparm *parms)
-{
- if (parms->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
- return -EINVAL;
- parms->parm.capture.capability = V4L2_CAP_TIMEPERFRAME;
- parms->parm.capture.capturemode = 0;
- parms->parm.capture.timeperframe.numerator = 1001;
- parms->parm.capture.timeperframe.denominator = frames_per_sec * 1000;
- parms->parm.capture.extendedmode = 0;
- parms->parm.capture.readbuffers = 1; /* FIXME: 2 buffers? */
- return 0;
-}
-
static const struct v4l2_ioctl_ops dt3155_ioctl_ops = {
.vidioc_querycap = dt3155_querycap,
.vidioc_enum_fmt_vid_cap = dt3155_enum_fmt_vid_cap,
@@ -482,14 +442,11 @@ static const struct v4l2_ioctl_ops dt3155_ioctl_ops = {
.vidioc_dqbuf = vb2_ioctl_dqbuf,
.vidioc_streamon = vb2_ioctl_streamon,
.vidioc_streamoff = vb2_ioctl_streamoff,
- .vidioc_querystd = dt3155_querystd,
.vidioc_g_std = dt3155_g_std,
.vidioc_s_std = dt3155_s_std,
.vidioc_enum_input = dt3155_enum_input,
.vidioc_g_input = dt3155_g_input,
.vidioc_s_input = dt3155_s_input,
- .vidioc_g_parm = dt3155_g_parm,
- .vidioc_s_parm = dt3155_s_parm,
};
static int dt3155_init_board(struct dt3155_priv *pd)
@@ -571,7 +528,7 @@ static struct video_device dt3155_vdev = {
.ioctl_ops = &dt3155_ioctl_ops,
.minor = -1,
.release = video_device_release_empty,
- .tvnorms = DT3155_CURRENT_NORM,
+ .tvnorms = V4L2_STD_ALL,
};
static int dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id)
@@ -593,6 +550,10 @@ static int dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id)
pd->vdev.v4l2_dev = &pd->v4l2_dev;
video_set_drvdata(&pd->vdev, pd); /* for use in video_fops */
pd->pdev = pdev;
+ pd->std = V4L2_STD_625_50;
+ pd->csr2 = VT_50HZ;
+ pd->width = 768;
+ pd->height = 576;
INIT_LIST_HEAD(&pd->dmaq);
mutex_init(&pd->mux);
pd->vdev.lock = &pd->mux; /* for locking v4l2_file_operations */
@@ -615,8 +576,7 @@ static int dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id)
goto err_v4l2_dev_unreg;
}
spin_lock_init(&pd->lock);
- pd->csr2 = csr2_init;
- pd->config = config_init;
+ pd->config = ACQ_MODE_EVEN;
err = pci_enable_device(pdev);
if (err)
goto err_free_ctx;
diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.h b/drivers/staging/media/dt3155v4l/dt3155v4l.h
index acecf83..75c7281 100644
--- a/drivers/staging/media/dt3155v4l/dt3155v4l.h
+++ b/drivers/staging/media/dt3155v4l/dt3155v4l.h
@@ -152,12 +152,6 @@
/* DT3155 identificator */
#define DT3155_ID 0x20
-#ifdef CONFIG_DT3155_CCIR
-#define DMA_STRIDE 768
-#else
-#define DMA_STRIDE 640
-#endif
-
/* per board private data structure */
/**
* struct dt3155_priv - private data structure
@@ -169,9 +163,12 @@
* @alloc_ctx: dma_contig allocation context
* @curr_buf: pointer to curren buffer
* @mux: mutex to protect the instance
- * @dmaq queue for dma buffers
- * @lock spinlock for dma queue
- * @sequence frame counter
+ * @dmaq: queue for dma buffers
+ * @lock: spinlock for dma queue
+ * @std: input standard
+ * @width: frame width
+ * @height: frame height
+ * @sequence: frame counter
* @stats: statistics structure
* @regs: local copy of mmio base register
* @csr2: local copy of csr2 register
@@ -187,6 +184,8 @@ struct dt3155_priv {
struct mutex mux;
struct list_head dmaq;
spinlock_t lock;
+ v4l2_std_id std;
+ unsigned width, height;
unsigned int sequence;
void __iomem *regs;
u8 csr2, config;
--
2.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 10/12] dt3155v4l: fix format handling
2015-04-25 15:42 [PATCH 00/12] dt3155v4l: clean up and move out of staging Hans Verkuil
` (8 preceding siblings ...)
2015-04-25 15:42 ` [PATCH 09/12] dt3155v4l: drop CONFIG_DT3155_CCIR, use s_std instead Hans Verkuil
@ 2015-04-25 15:42 ` Hans Verkuil
2015-04-25 15:42 ` [PATCH 11/12] dt3155v4l: support inputs VID0-3 Hans Verkuil
2015-04-25 15:42 ` [PATCH 12/12] dt3155: move out of staging into drivers/media/pci Hans Verkuil
11 siblings, 0 replies; 13+ messages in thread
From: Hans Verkuil @ 2015-04-25 15:42 UTC (permalink / raw)
To: linux-media; +Cc: Hans Verkuil
From: Hans Verkuil <hans.verkuil@cisco.com>
Fix various v4l2-compliance issues regarding format handling.
Main problem was a missing colorspace value and incorrect format
checks. This driver supports a single format only.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
drivers/staging/media/dt3155v4l/dt3155v4l.c | 52 +++++------------------------
1 file changed, 8 insertions(+), 44 deletions(-)
diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.c b/drivers/staging/media/dt3155v4l/dt3155v4l.c
index f026ab6..450728f 100644
--- a/drivers/staging/media/dt3155v4l/dt3155v4l.c
+++ b/drivers/staging/media/dt3155v4l/dt3155v4l.c
@@ -29,18 +29,6 @@
#define DT3155_DEVICE_ID 0x1223
-static const struct v4l2_fmtdesc frame_std[] = {
- {
- .index = 0,
- .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
- .flags = 0,
- .description = "8-bit Greyscale",
- .pixelformat = V4L2_PIX_FMT_GREY,
- },
-};
-
-#define NUM_OF_FORMATS ARRAY_SIZE(frame_std)
-
/**
* read_i2c_reg - reads an internal i2c register
*
@@ -330,51 +318,27 @@ static int dt3155_querycap(struct file *filp, void *p, struct v4l2_capability *c
static int dt3155_enum_fmt_vid_cap(struct file *filp, void *p, struct v4l2_fmtdesc *f)
{
- if (f->index >= NUM_OF_FORMATS)
+ if (f->index)
return -EINVAL;
- *f = frame_std[f->index];
+ f->pixelformat = V4L2_PIX_FMT_GREY;
+ strcpy(f->description, "8-bit Greyscale");
return 0;
}
-static int dt3155_g_fmt_vid_cap(struct file *filp, void *p, struct v4l2_format *f)
+static int dt3155_fmt_vid_cap(struct file *filp, void *p, struct v4l2_format *f)
{
struct dt3155_priv *pd = video_drvdata(filp);
- if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
- return -EINVAL;
f->fmt.pix.width = pd->width;
f->fmt.pix.height = pd->height;
f->fmt.pix.pixelformat = V4L2_PIX_FMT_GREY;
f->fmt.pix.field = V4L2_FIELD_NONE;
f->fmt.pix.bytesperline = f->fmt.pix.width;
f->fmt.pix.sizeimage = f->fmt.pix.width * f->fmt.pix.height;
- f->fmt.pix.colorspace = 0;
- f->fmt.pix.priv = 0;
+ f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
return 0;
}
-static int dt3155_try_fmt_vid_cap(struct file *filp, void *p, struct v4l2_format *f)
-{
- struct dt3155_priv *pd = video_drvdata(filp);
-
- if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
- return -EINVAL;
- if (f->fmt.pix.width == pd->width &&
- f->fmt.pix.height == pd->height &&
- f->fmt.pix.pixelformat == V4L2_PIX_FMT_GREY &&
- f->fmt.pix.field == V4L2_FIELD_NONE &&
- f->fmt.pix.bytesperline == f->fmt.pix.width &&
- f->fmt.pix.sizeimage == f->fmt.pix.width * f->fmt.pix.height)
- return 0;
- else
- return -EINVAL;
-}
-
-static int dt3155_s_fmt_vid_cap(struct file *filp, void *p, struct v4l2_format *f)
-{
- return dt3155_g_fmt_vid_cap(filp, p, f);
-}
-
static int dt3155_g_std(struct file *filp, void *p, v4l2_std_id *norm)
{
struct dt3155_priv *pd = video_drvdata(filp);
@@ -431,9 +395,9 @@ static int dt3155_s_input(struct file *filp, void *p, unsigned int i)
static const struct v4l2_ioctl_ops dt3155_ioctl_ops = {
.vidioc_querycap = dt3155_querycap,
.vidioc_enum_fmt_vid_cap = dt3155_enum_fmt_vid_cap,
- .vidioc_try_fmt_vid_cap = dt3155_try_fmt_vid_cap,
- .vidioc_g_fmt_vid_cap = dt3155_g_fmt_vid_cap,
- .vidioc_s_fmt_vid_cap = dt3155_s_fmt_vid_cap,
+ .vidioc_try_fmt_vid_cap = dt3155_fmt_vid_cap,
+ .vidioc_g_fmt_vid_cap = dt3155_fmt_vid_cap,
+ .vidioc_s_fmt_vid_cap = dt3155_fmt_vid_cap,
.vidioc_reqbufs = vb2_ioctl_reqbufs,
.vidioc_create_bufs = vb2_ioctl_create_bufs,
.vidioc_querybuf = vb2_ioctl_querybuf,
--
2.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 11/12] dt3155v4l: support inputs VID0-3
2015-04-25 15:42 [PATCH 00/12] dt3155v4l: clean up and move out of staging Hans Verkuil
` (9 preceding siblings ...)
2015-04-25 15:42 ` [PATCH 10/12] dt3155v4l: fix format handling Hans Verkuil
@ 2015-04-25 15:42 ` Hans Verkuil
2015-04-25 15:42 ` [PATCH 12/12] dt3155: move out of staging into drivers/media/pci Hans Verkuil
11 siblings, 0 replies; 13+ messages in thread
From: Hans Verkuil @ 2015-04-25 15:42 UTC (permalink / raw)
To: linux-media; +Cc: Hans Verkuil
From: Hans Verkuil <hans.verkuil@cisco.com>
The dt3155 together with the J1 breakout cable supports 4 inputs. Add
support for all inputs VID0 - VID3. Note that input VID0 is shared with
input J2.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Tested-by: Hans Verkuil <hans.verkuil@cisco.com>
---
drivers/staging/media/dt3155v4l/dt3155v4l.c | 18 ++++++++++++++----
drivers/staging/media/dt3155v4l/dt3155v4l.h | 2 ++
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.c b/drivers/staging/media/dt3155v4l/dt3155v4l.c
index 450728f..43c9e0f 100644
--- a/drivers/staging/media/dt3155v4l/dt3155v4l.c
+++ b/drivers/staging/media/dt3155v4l/dt3155v4l.c
@@ -370,9 +370,12 @@ static int dt3155_s_std(struct file *filp, void *p, v4l2_std_id norm)
static int dt3155_enum_input(struct file *filp, void *p, struct v4l2_input *input)
{
- if (input->index)
+ if (input->index > 3)
return -EINVAL;
- strcpy(input->name, "Coax in");
+ if (input->index)
+ snprintf(input->name, sizeof(input->name), "VID%d", input->index);
+ else
+ strlcpy(input->name, "J2/VID0", sizeof(input->name));
input->type = V4L2_INPUT_TYPE_CAMERA;
input->std = V4L2_STD_ALL;
input->status = 0;
@@ -381,14 +384,21 @@ static int dt3155_enum_input(struct file *filp, void *p, struct v4l2_input *inpu
static int dt3155_g_input(struct file *filp, void *p, unsigned int *i)
{
- *i = 0;
+ struct dt3155_priv *pd = video_drvdata(filp);
+
+ *i = pd->input;
return 0;
}
static int dt3155_s_input(struct file *filp, void *p, unsigned int i)
{
- if (i)
+ struct dt3155_priv *pd = video_drvdata(filp);
+
+ if (i > 3)
return -EINVAL;
+ pd->input = i;
+ write_i2c_reg(pd->regs, AD_ADDR, AD_CMD_REG);
+ write_i2c_reg(pd->regs, AD_CMD, (i << 6) | (i << 4) | SYNC_LVL_3);
return 0;
}
diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.h b/drivers/staging/media/dt3155v4l/dt3155v4l.h
index 75c7281..bcf7b5e 100644
--- a/drivers/staging/media/dt3155v4l/dt3155v4l.h
+++ b/drivers/staging/media/dt3155v4l/dt3155v4l.h
@@ -168,6 +168,7 @@
* @std: input standard
* @width: frame width
* @height: frame height
+ * @input: current input
* @sequence: frame counter
* @stats: statistics structure
* @regs: local copy of mmio base register
@@ -186,6 +187,7 @@ struct dt3155_priv {
spinlock_t lock;
v4l2_std_id std;
unsigned width, height;
+ unsigned input;
unsigned int sequence;
void __iomem *regs;
u8 csr2, config;
--
2.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 12/12] dt3155: move out of staging into drivers/media/pci
2015-04-25 15:42 [PATCH 00/12] dt3155v4l: clean up and move out of staging Hans Verkuil
` (10 preceding siblings ...)
2015-04-25 15:42 ` [PATCH 11/12] dt3155v4l: support inputs VID0-3 Hans Verkuil
@ 2015-04-25 15:42 ` Hans Verkuil
11 siblings, 0 replies; 13+ messages in thread
From: Hans Verkuil @ 2015-04-25 15:42 UTC (permalink / raw)
To: linux-media; +Cc: Hans Verkuil
From: Hans Verkuil <hans.verkuil@cisco.com>
The dt3155 code is now in good shape, so move it out of staging into
drivers/media/pci. Mark in MAINTAINERS that I'll do Odd Fixes for this
driver.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
MAINTAINERS | 8 ++++++++
drivers/media/pci/Kconfig | 1 +
drivers/media/pci/Makefile | 1 +
drivers/{staging/media/dt3155v4l => media/pci/dt3155}/Kconfig | 4 ++--
drivers/media/pci/dt3155/Makefile | 1 +
.../media/dt3155v4l/dt3155v4l.c => media/pci/dt3155/dt3155.c} | 2 +-
.../media/dt3155v4l/dt3155v4l.h => media/pci/dt3155/dt3155.h} | 4 ++--
drivers/staging/media/Kconfig | 2 --
drivers/staging/media/Makefile | 1 -
drivers/staging/media/dt3155v4l/Makefile | 1 -
10 files changed, 16 insertions(+), 9 deletions(-)
rename drivers/{staging/media/dt3155v4l => media/pci/dt3155}/Kconfig (78%)
create mode 100644 drivers/media/pci/dt3155/Makefile
rename drivers/{staging/media/dt3155v4l/dt3155v4l.c => media/pci/dt3155/dt3155.c} (99%)
rename drivers/{staging/media/dt3155v4l/dt3155v4l.h => media/pci/dt3155/dt3155.h} (99%)
delete mode 100644 drivers/staging/media/dt3155v4l/Makefile
diff --git a/MAINTAINERS b/MAINTAINERS
index 30e7e38..a010eca 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3394,6 +3394,14 @@ L: netdev@vger.kernel.org
S: Maintained
F: drivers/net/wan/dscc4.c
+DT3155 MEDIA DRIVER
+M: Hans Verkuil <hverkuil@xs4all.nl>
+L: linux-media@vger.kernel.org
+T: git git://linuxtv.org/media_tree.git
+W: http://linuxtv.org
+S: Odd Fixes
+F: drivers/media/pci/dt3155/
+
DVB_USB_AF9015 MEDIA DRIVER
M: Antti Palosaari <crope@iki.fi>
L: linux-media@vger.kernel.org
diff --git a/drivers/media/pci/Kconfig b/drivers/media/pci/Kconfig
index 218144a..fd359fb 100644
--- a/drivers/media/pci/Kconfig
+++ b/drivers/media/pci/Kconfig
@@ -21,6 +21,7 @@ source "drivers/media/pci/zoran/Kconfig"
source "drivers/media/pci/saa7146/Kconfig"
source "drivers/media/pci/solo6x10/Kconfig"
source "drivers/media/pci/tw68/Kconfig"
+source "drivers/media/pci/dt3155/Kconfig"
endif
if MEDIA_ANALOG_TV_SUPPORT || MEDIA_DIGITAL_TV_SUPPORT
diff --git a/drivers/media/pci/Makefile b/drivers/media/pci/Makefile
index 0baf0d2..3471ab6 100644
--- a/drivers/media/pci/Makefile
+++ b/drivers/media/pci/Makefile
@@ -24,6 +24,7 @@ obj-$(CONFIG_VIDEO_BT848) += bt8xx/
obj-$(CONFIG_VIDEO_SAA7134) += saa7134/
obj-$(CONFIG_VIDEO_SAA7164) += saa7164/
obj-$(CONFIG_VIDEO_TW68) += tw68/
+obj-$(CONFIG_VIDEO_DT3155) += dt3155/
obj-$(CONFIG_VIDEO_MEYE) += meye/
obj-$(CONFIG_STA2X11_VIP) += sta2x11/
obj-$(CONFIG_VIDEO_SOLO6X10) += solo6x10/
diff --git a/drivers/staging/media/dt3155v4l/Kconfig b/drivers/media/pci/dt3155/Kconfig
similarity index 78%
rename from drivers/staging/media/dt3155v4l/Kconfig
rename to drivers/media/pci/dt3155/Kconfig
index fcbcba6..5145e0d 100644
--- a/drivers/staging/media/dt3155v4l/Kconfig
+++ b/drivers/media/pci/dt3155/Kconfig
@@ -1,5 +1,5 @@
config VIDEO_DT3155
- tristate "DT3155 frame grabber, Video4Linux interface"
+ tristate "DT3155 frame grabber"
depends on PCI && VIDEO_DEV && VIDEO_V4L2
depends on HAS_DMA
select VIDEOBUF2_DMA_CONTIG
@@ -10,4 +10,4 @@ config VIDEO_DT3155
In doubt, say N.
To compile this driver as a module, choose M here: the
- module will be called dt3155v4l.
+ module will be called dt3155.
diff --git a/drivers/media/pci/dt3155/Makefile b/drivers/media/pci/dt3155/Makefile
new file mode 100644
index 0000000..89fa637
--- /dev/null
+++ b/drivers/media/pci/dt3155/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_VIDEO_DT3155) += dt3155.o
diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.c b/drivers/media/pci/dt3155/dt3155.c
similarity index 99%
rename from drivers/staging/media/dt3155v4l/dt3155v4l.c
rename to drivers/media/pci/dt3155/dt3155.c
index 43c9e0f..3131c2e 100644
--- a/drivers/staging/media/dt3155v4l/dt3155v4l.c
+++ b/drivers/media/pci/dt3155/dt3155.c
@@ -25,7 +25,7 @@
#include <media/v4l2-common.h>
#include <media/videobuf2-dma-contig.h>
-#include "dt3155v4l.h"
+#include "dt3155.h"
#define DT3155_DEVICE_ID 0x1223
diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.h b/drivers/media/pci/dt3155/dt3155.h
similarity index 99%
rename from drivers/staging/media/dt3155v4l/dt3155v4l.h
rename to drivers/media/pci/dt3155/dt3155.h
index bcf7b5e..4e1f4d5 100644
--- a/drivers/staging/media/dt3155v4l/dt3155v4l.h
+++ b/drivers/media/pci/dt3155/dt3155.h
@@ -24,8 +24,8 @@
#include <media/v4l2-dev.h>
#define DT3155_NAME "dt3155"
-#define DT3155_VER_MAJ 1
-#define DT3155_VER_MIN 1
+#define DT3155_VER_MAJ 2
+#define DT3155_VER_MIN 0
#define DT3155_VER_EXT 0
#define DT3155_VERSION __stringify(DT3155_VER_MAJ) "." \
__stringify(DT3155_VER_MIN) "." \
diff --git a/drivers/staging/media/Kconfig b/drivers/staging/media/Kconfig
index 96498b7..1469768 100644
--- a/drivers/staging/media/Kconfig
+++ b/drivers/staging/media/Kconfig
@@ -25,8 +25,6 @@ source "drivers/staging/media/cxd2099/Kconfig"
source "drivers/staging/media/davinci_vpfe/Kconfig"
-source "drivers/staging/media/dt3155v4l/Kconfig"
-
source "drivers/staging/media/mn88472/Kconfig"
source "drivers/staging/media/mn88473/Kconfig"
diff --git a/drivers/staging/media/Makefile b/drivers/staging/media/Makefile
index a9006bc..34c557b 100644
--- a/drivers/staging/media/Makefile
+++ b/drivers/staging/media/Makefile
@@ -1,7 +1,6 @@
obj-$(CONFIG_I2C_BCM2048) += bcm2048/
obj-$(CONFIG_DVB_CXD2099) += cxd2099/
obj-$(CONFIG_LIRC_STAGING) += lirc/
-obj-$(CONFIG_VIDEO_DT3155) += dt3155v4l/
obj-$(CONFIG_VIDEO_DM365_VPFE) += davinci_vpfe/
obj-$(CONFIG_VIDEO_OMAP4) += omap4iss/
obj-$(CONFIG_DVB_MN88472) += mn88472/
diff --git a/drivers/staging/media/dt3155v4l/Makefile b/drivers/staging/media/dt3155v4l/Makefile
deleted file mode 100644
index ce7a3ec..0000000
--- a/drivers/staging/media/dt3155v4l/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-obj-$(CONFIG_VIDEO_DT3155) += dt3155v4l.o
--
2.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
end of thread, other threads:[~2015-04-25 15:43 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-25 15:42 [PATCH 00/12] dt3155v4l: clean up and move out of staging Hans Verkuil
2015-04-25 15:42 ` [PATCH 01/12] dt3155v4l: code cleanup Hans Verkuil
2015-04-25 15:42 ` [PATCH 02/12] dt3155v4l: remove unused statistics Hans Verkuil
2015-04-25 15:42 ` [PATCH 03/12] dt3155v4l: add v4l2_device support Hans Verkuil
2015-04-25 15:42 ` [PATCH 04/12] dt3155v4l: remove pointless dt3155_alloc/free_coherent Hans Verkuil
2015-04-25 15:42 ` [PATCH 05/12] dt3155v4l: remove bogus single-frame capture in init_board Hans Verkuil
2015-04-25 15:42 ` [PATCH 06/12] dt3155v4l: move vb2_queue to top-level Hans Verkuil
2015-04-25 15:42 ` [PATCH 07/12] dt3155v4l: drop CONFIG_DT3155_STREAMING Hans Verkuil
2015-04-25 15:42 ` [PATCH 08/12] dt3155v4l: correctly start and stop streaming Hans Verkuil
2015-04-25 15:42 ` [PATCH 09/12] dt3155v4l: drop CONFIG_DT3155_CCIR, use s_std instead Hans Verkuil
2015-04-25 15:42 ` [PATCH 10/12] dt3155v4l: fix format handling Hans Verkuil
2015-04-25 15:42 ` [PATCH 11/12] dt3155v4l: support inputs VID0-3 Hans Verkuil
2015-04-25 15:42 ` [PATCH 12/12] dt3155: move out of staging into drivers/media/pci Hans Verkuil
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.