2019-05-19 15:51:31 +02:00
// SPDX-License-Identifier: GPL-2.0-or-later
2010-05-29 17:18:45 -03:00
/*
au0828 - vbi . c - VBI driver for au0828
Copyright ( C ) 2010 Devin Heitmueller < dheitmueller @ kernellabs . com >
This work was sponsored by GetWellNetwork Inc .
*/
2014-08-09 21:47:17 -03:00
# include "au0828.h"
2010-05-29 17:18:45 -03:00
# include <linux/kernel.h>
# include <linux/module.h>
# include <linux/init.h>
# include <linux/slab.h>
2022-06-22 10:31:45 +01:00
# include <media/v4l2-mc.h>
2010-05-29 17:18:45 -03:00
/* ------------------------------------------------------------------ */
2015-10-28 00:50:37 -02:00
static int vbi_queue_setup ( struct vb2_queue * vq ,
2015-01-29 13:41:32 -03:00
unsigned int * nbuffers , unsigned int * nplanes ,
2016-04-15 09:15:05 -03:00
unsigned int sizes [ ] , struct device * alloc_devs [ ] )
2010-05-29 17:18:45 -03:00
{
2015-01-29 13:41:32 -03:00
struct au0828_dev * dev = vb2_get_drv_priv ( vq ) ;
2015-10-28 00:50:37 -02:00
unsigned long size = dev - > vbi_width * dev - > vbi_height * 2 ;
2010-05-29 17:18:45 -03:00
2015-10-28 00:50:37 -02:00
if ( * nplanes )
return sizes [ 0 ] < size ? - EINVAL : 0 ;
2015-01-29 13:41:32 -03:00
* nplanes = 1 ;
sizes [ 0 ] = size ;
2010-05-29 17:18:45 -03:00
return 0 ;
}
2015-01-29 13:41:32 -03:00
static int vbi_buffer_prepare ( struct vb2_buffer * vb )
2010-05-29 17:18:45 -03:00
{
2015-01-29 13:41:32 -03:00
struct au0828_dev * dev = vb2_get_drv_priv ( vb - > vb2_queue ) ;
unsigned long size ;
2010-05-29 17:18:45 -03:00
2015-01-29 13:41:32 -03:00
size = dev - > vbi_width * dev - > vbi_height * 2 ;
2010-05-29 17:18:45 -03:00
2015-01-29 13:41:32 -03:00
if ( vb2_plane_size ( vb , 0 ) < size ) {
pr_err ( " %s data will not fit into plane (%lu < %lu) \n " ,
__func__ , vb2_plane_size ( vb , 0 ) , size ) ;
2010-05-29 17:18:45 -03:00
return - EINVAL ;
}
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 10:30:30 -03:00
vb2_set_plane_payload ( vb , 0 , size ) ;
2010-05-29 17:18:45 -03:00
return 0 ;
}
static void
2015-01-29 13:41:32 -03:00
vbi_buffer_queue ( struct vb2_buffer * vb )
2010-05-29 17:18:45 -03:00
{
2015-01-29 13:41:32 -03:00
struct au0828_dev * dev = vb2_get_drv_priv ( vb - > vb2_queue ) ;
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 10:30:30 -03:00
struct vb2_v4l2_buffer * vbuf = to_vb2_v4l2_buffer ( vb ) ;
struct au0828_buffer * buf =
container_of ( vbuf , struct au0828_buffer , vb ) ;
2015-01-29 13:41:32 -03:00
struct au0828_dmaqueue * vbiq = & dev - > vbiq ;
unsigned long flags = 0 ;
buf - > mem = vb2_plane_vaddr ( vb , 0 ) ;
buf - > length = vb2_plane_size ( vb , 0 ) ;
spin_lock_irqsave ( & dev - > slock , flags ) ;
list_add_tail ( & buf - > list , & vbiq - > active ) ;
spin_unlock_irqrestore ( & dev - > slock , flags ) ;
2010-05-29 17:18:45 -03:00
}
2017-09-27 19:08:19 +02:00
const struct vb2_ops au0828_vbi_qops = {
2015-01-29 13:41:32 -03:00
. queue_setup = vbi_queue_setup ,
. buf_prepare = vbi_buffer_prepare ,
. buf_queue = vbi_buffer_queue ,
2022-06-22 10:31:45 +01:00
. prepare_streaming = v4l_vb2q_enable_media_source ,
2015-01-29 13:41:32 -03:00
. start_streaming = au0828_start_analog_streaming ,
. stop_streaming = au0828_stop_vbi_streaming ,
. wait_prepare = vb2_ops_wait_prepare ,
. wait_finish = vb2_ops_wait_finish ,
2010-05-29 17:18:45 -03:00
} ;