2009-06-09 15:55:37 +07:00
/*
* vpif - display - VPIF display driver
* Display driver for TI DaVinci VPIF
*
* Copyright ( C ) 2009 Texas Instruments Incorporated - http : //www.ti.com/
2014-05-16 20:33:55 +07:00
* Copyright ( C ) 2014 Lad , Prabhakar < prabhakar . csengg @ gmail . com >
2009-06-09 15:55:37 +07:00
*
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation version 2.
*
* This program is distributed . as is . WITHOUT ANY WARRANTY of any
* kind , whether express or implied ; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*/
# include <linux/interrupt.h>
2013-04-19 15:53:29 +07:00
# include <linux/module.h>
2009-06-09 15:55:37 +07:00
# include <linux/platform_device.h>
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 15:04:11 +07:00
# include <linux/slab.h>
2009-06-09 15:55:37 +07:00
2013-04-19 15:53:29 +07:00
# include <media/v4l2-ioctl.h>
2009-06-09 15:55:37 +07:00
# include "vpif.h"
2013-04-19 15:53:29 +07:00
# include "vpif_display.h"
2009-06-09 15:55:37 +07:00
MODULE_DESCRIPTION ( " TI DaVinci VPIF Display driver " ) ;
MODULE_LICENSE ( " GPL " ) ;
2011-06-25 21:28:37 +07:00
MODULE_VERSION ( VPIF_DISPLAY_VERSION ) ;
2009-06-09 15:55:37 +07:00
2012-04-13 14:44:00 +07:00
# define VPIF_V4L2_STD (V4L2_STD_525_60 | V4L2_STD_625_50)
2009-06-09 15:55:37 +07:00
# define vpif_err(fmt, arg...) v4l2_err(&vpif_obj.v4l2_dev, fmt, ## arg)
# define vpif_dbg(level, debug, fmt, arg...) \
v4l2_dbg ( level , debug , & vpif_obj . v4l2_dev , fmt , # # arg )
static int debug = 1 ;
module_param ( debug , int , 0644 ) ;
MODULE_PARM_DESC ( debug , " Debug level 0-1 " ) ;
2014-05-16 20:33:22 +07:00
# define VPIF_DRIVER_NAME "vpif_display"
2016-12-17 07:47:54 +07:00
MODULE_ALIAS ( " platform: " VPIF_DRIVER_NAME ) ;
2014-05-16 20:33:21 +07:00
/* Is set to 1 in case of SDTV formats, 2 in case of HDTV formats. */
static int ycmux_mode ;
2014-05-16 20:33:13 +07:00
static u8 channel_first_int [ VPIF_NUMOBJECTS ] [ 2 ] = { { 1 , 1 } } ;
2009-06-09 15:55:37 +07:00
static struct vpif_device vpif_obj = { { NULL } } ;
static struct device * vpif_dev ;
2012-06-28 19:28:36 +07:00
static void vpif_calculate_offsets ( struct channel_obj * ch ) ;
static void vpif_config_addr ( struct channel_obj * ch , int muxmode ) ;
2009-06-09 15:55:37 +07:00
[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 20:30:30 +07:00
static inline
struct vpif_disp_buffer * to_vpif_buffer ( struct vb2_v4l2_buffer * vb )
2014-05-16 20:33:13 +07:00
{
return container_of ( vb , struct vpif_disp_buffer , vb ) ;
}
2014-05-16 20:33:11 +07:00
/**
* vpif_buffer_prepare : callback function for buffer prepare
* @ vb : ptr to vb2_buffer
*
* This is the callback function for buffer prepare when vb2_qbuf ( )
* function is called . The buffer is prepared and user space virtual address
* or user address is converted into physical address
2009-06-09 15:55:37 +07:00
*/
2012-06-28 19:28:36 +07:00
static int vpif_buffer_prepare ( struct vb2_buffer * vb )
2009-06-09 15:55:37 +07:00
{
[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 20:30:30 +07:00
struct vb2_v4l2_buffer * vbuf = to_vb2_v4l2_buffer ( vb ) ;
2014-05-16 20:33:11 +07:00
struct channel_obj * ch = vb2_get_drv_priv ( vb - > vb2_queue ) ;
2009-06-09 15:55:37 +07:00
struct common_obj * common ;
2014-05-16 20:33:06 +07:00
common = & ch - > common [ VPIF_VIDEO_INDEX ] ;
2014-05-16 20:33:11 +07:00
vb2_set_plane_payload ( vb , 0 , common - > fmt . fmt . pix . sizeimage ) ;
if ( vb2_get_plane_payload ( vb , 0 ) > vb2_plane_size ( vb , 0 ) )
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 20:30:30 +07:00
vbuf - > field = common - > fmt . fmt . pix . field ;
2014-05-16 20:33:11 +07:00
if ( vb - > vb2_queue - > type ! = V4L2_BUF_TYPE_SLICED_VBI_OUTPUT ) {
unsigned long addr = vb2_dma_contig_plane_dma_addr ( vb , 0 ) ;
if ( ! ISALIGNED ( addr + common - > ytop_off ) | |
2012-06-28 19:28:36 +07:00
! ISALIGNED ( addr + common - > ybtm_off ) | |
! ISALIGNED ( addr + common - > ctop_off ) | |
2014-05-16 20:33:11 +07:00
! ISALIGNED ( addr + common - > cbtm_off ) ) {
vpif_err ( " buffer offset not aligned to 8 bytes \n " ) ;
return - EINVAL ;
2012-06-28 19:28:36 +07:00
}
2009-06-09 15:55:37 +07:00
}
2014-05-16 20:33:11 +07:00
return 0 ;
2009-06-09 15:55:37 +07:00
}
2014-05-16 20:33:12 +07:00
/**
* vpif_buffer_queue_setup : Callback function for buffer setup .
* @ vq : vb2_queue ptr
* @ nbuffers : ptr to number of buffers requested by application
* @ nplanes : : contains number of distinct video planes needed to hold a frame
2017-11-29 16:20:45 +07:00
* @ sizes : contains the size ( in bytes ) of each plane .
2016-04-15 19:15:05 +07:00
* @ alloc_devs : ptr to allocation context
2014-05-16 20:33:12 +07:00
*
* This callback function is called when reqbuf ( ) is called to adjust
* the buffer count and buffer size
2009-06-09 15:55:37 +07:00
*/
2012-06-28 19:28:36 +07:00
static int vpif_buffer_queue_setup ( struct vb2_queue * vq ,
unsigned int * nbuffers , unsigned int * nplanes ,
2016-04-15 19:15:05 +07:00
unsigned int sizes [ ] , struct device * alloc_devs [ ] )
2009-06-09 15:55:37 +07:00
{
2014-05-16 20:33:06 +07:00
struct channel_obj * ch = vb2_get_drv_priv ( vq ) ;
2009-06-09 15:55:37 +07:00
struct common_obj * common = & ch - > common [ VPIF_VIDEO_INDEX ] ;
2015-10-28 09:50:37 +07:00
unsigned size = common - > fmt . fmt . pix . sizeimage ;
2012-04-13 14:49:10 +07:00
2015-10-28 09:50:37 +07:00
if ( * nplanes ) {
if ( sizes [ 0 ] < size )
return - EINVAL ;
size = sizes [ 0 ] ;
}
2014-05-16 20:33:12 +07:00
if ( vq - > num_buffers + * nbuffers < 3 )
* nbuffers = 3 - vq - > num_buffers ;
2009-06-09 15:55:37 +07:00
2012-06-28 19:28:36 +07:00
* nplanes = 1 ;
2015-10-28 09:50:37 +07:00
sizes [ 0 ] = size ;
2014-05-16 20:33:12 +07:00
/* Calculate the offset for Y and C data in the buffer */
vpif_calculate_offsets ( ch ) ;
2009-06-09 15:55:37 +07:00
return 0 ;
}
2014-05-16 20:33:13 +07:00
/**
* vpif_buffer_queue : Callback function to add buffer to DMA queue
* @ vb : ptr to vb2_buffer
*
* This callback fucntion queues the buffer to DMA engine
2009-06-09 15:55:37 +07:00
*/
2012-06-28 19:28:36 +07:00
static void vpif_buffer_queue ( struct vb2_buffer * vb )
2009-06-09 15:55:37 +07:00
{
[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 20:30:30 +07:00
struct vb2_v4l2_buffer * vbuf = to_vb2_v4l2_buffer ( vb ) ;
struct vpif_disp_buffer * buf = to_vpif_buffer ( vbuf ) ;
2014-05-16 20:33:06 +07:00
struct channel_obj * ch = vb2_get_drv_priv ( vb - > vb2_queue ) ;
2009-06-09 15:55:37 +07:00
struct common_obj * common ;
2012-11-16 22:03:07 +07:00
unsigned long flags ;
2009-06-09 15:55:37 +07:00
2012-06-28 19:28:36 +07:00
common = & ch - > common [ VPIF_VIDEO_INDEX ] ;
2009-06-09 15:55:37 +07:00
/* add the buffer to the DMA queue */
2012-11-16 22:03:07 +07:00
spin_lock_irqsave ( & common - > irqlock , flags ) ;
2012-06-28 19:28:36 +07:00
list_add_tail ( & buf - > list , & common - > dma_queue ) ;
2012-11-16 22:03:07 +07:00
spin_unlock_irqrestore ( & common - > irqlock , flags ) ;
2009-06-09 15:55:37 +07:00
}
2014-05-16 20:33:13 +07:00
/**
* vpif_start_streaming : Starts the DMA engine for streaming
2017-11-29 16:20:45 +07:00
* @ vq : ptr to vb2_buffer
2014-05-16 20:33:13 +07:00
* @ count : number of buffers
*/
2012-06-28 19:28:36 +07:00
static int vpif_start_streaming ( struct vb2_queue * vq , unsigned int count )
{
struct vpif_display_config * vpif_config_data =
vpif_dev - > platform_data ;
2014-05-16 20:33:06 +07:00
struct channel_obj * ch = vb2_get_drv_priv ( vq ) ;
2012-06-28 19:28:36 +07:00
struct common_obj * common = & ch - > common [ VPIF_VIDEO_INDEX ] ;
struct vpif_params * vpif = & ch - > vpifparams ;
2014-05-16 20:33:09 +07:00
struct vpif_disp_buffer * buf , * tmp ;
unsigned long addr , flags ;
2012-06-28 19:28:36 +07:00
int ret ;
2012-11-16 22:03:07 +07:00
spin_lock_irqsave ( & common - > irqlock , flags ) ;
2012-06-28 19:28:36 +07:00
2014-05-16 20:33:21 +07:00
/* Initialize field_id */
2012-06-28 19:28:36 +07:00
ch - > field_id = 0 ;
2014-05-16 20:33:09 +07:00
2012-06-28 19:28:36 +07:00
/* clock settings */
2012-09-27 12:33:12 +07:00
if ( vpif_config_data - > set_clock ) {
ret = vpif_config_data - > set_clock ( ch - > vpifparams . std_info .
ycmux_mode , ch - > vpifparams . std_info . hd_sd ) ;
if ( ret < 0 ) {
vpif_err ( " can't set clock \n " ) ;
2014-05-16 20:33:09 +07:00
goto err ;
2012-09-27 12:33:12 +07:00
}
2012-06-28 19:28:36 +07:00
}
/* set the parameters and addresses */
ret = vpif_set_video_params ( vpif , ch - > channel_id + 2 ) ;
if ( ret < 0 )
2014-05-16 20:33:09 +07:00
goto err ;
2012-06-28 19:28:36 +07:00
2014-05-16 20:33:21 +07:00
ycmux_mode = ret ;
2012-06-28 19:28:36 +07:00
vpif_config_addr ( ch , ret ) ;
2014-05-16 20:33:09 +07:00
/* Get the next frame from the buffer queue */
common - > next_frm = common - > cur_frm =
list_entry ( common - > dma_queue . next ,
struct vpif_disp_buffer , list ) ;
list_del ( & common - > cur_frm - > list ) ;
spin_unlock_irqrestore ( & common - > irqlock , flags ) ;
[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 20:30:30 +07:00
addr = vb2_dma_contig_plane_dma_addr ( & common - > cur_frm - > vb . vb2_buf , 0 ) ;
2012-06-28 19:28:36 +07:00
common - > set_addr ( ( addr + common - > ytop_off ) ,
( addr + common - > ybtm_off ) ,
( addr + common - > ctop_off ) ,
( addr + common - > cbtm_off ) ) ;
2014-05-16 20:33:13 +07:00
/*
* Set interrupt for both the fields in VPIF
* Register enable channel in VPIF register
*/
2012-09-14 20:22:24 +07:00
channel_first_int [ VPIF_VIDEO_INDEX ] [ ch - > channel_id ] = 1 ;
2012-06-28 19:28:36 +07:00
if ( VPIF_CHANNEL2_VIDEO = = ch - > channel_id ) {
channel2_intr_assert ( ) ;
channel2_intr_enable ( 1 ) ;
enable_channel2 ( 1 ) ;
2012-09-25 18:11:49 +07:00
if ( vpif_config_data - > chan_config [ VPIF_CHANNEL2_VIDEO ] . clip_en )
2012-06-29 13:20:12 +07:00
channel2_clipping_enable ( 1 ) ;
2012-06-28 19:28:36 +07:00
}
2014-05-16 20:33:21 +07:00
if ( VPIF_CHANNEL3_VIDEO = = ch - > channel_id | | ycmux_mode = = 2 ) {
2012-06-28 19:28:36 +07:00
channel3_intr_assert ( ) ;
channel3_intr_enable ( 1 ) ;
enable_channel3 ( 1 ) ;
2012-09-25 18:11:49 +07:00
if ( vpif_config_data - > chan_config [ VPIF_CHANNEL3_VIDEO ] . clip_en )
2012-06-29 13:20:12 +07:00
channel3_clipping_enable ( 1 ) ;
2012-06-28 19:28:36 +07:00
}
return 0 ;
2014-05-16 20:33:09 +07:00
err :
list_for_each_entry_safe ( buf , tmp , & common - > dma_queue , list ) {
list_del ( & buf - > list ) ;
[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 20:30:30 +07:00
vb2_buffer_done ( & buf - > vb . vb2_buf , VB2_BUF_STATE_QUEUED ) ;
2014-05-16 20:33:09 +07:00
}
2014-06-12 14:01:45 +07:00
spin_unlock_irqrestore ( & common - > irqlock , flags ) ;
2014-05-16 20:33:09 +07:00
return ret ;
2012-06-28 19:28:36 +07:00
}
2014-05-16 20:33:13 +07:00
/**
* vpif_stop_streaming : Stop the DMA engine
* @ vq : ptr to vb2_queue
*
* This callback stops the DMA engine and any remaining buffers
* in the DMA queue are released .
*/
2014-04-17 12:47:21 +07:00
static void vpif_stop_streaming ( struct vb2_queue * vq )
2012-06-28 19:28:36 +07:00
{
2014-05-16 20:33:06 +07:00
struct channel_obj * ch = vb2_get_drv_priv ( vq ) ;
2012-06-28 19:28:36 +07:00
struct common_obj * common ;
2012-11-16 22:03:07 +07:00
unsigned long flags ;
2012-06-28 19:28:36 +07:00
common = & ch - > common [ VPIF_VIDEO_INDEX ] ;
2014-03-22 18:03:08 +07:00
/* Disable channel */
if ( VPIF_CHANNEL2_VIDEO = = ch - > channel_id ) {
enable_channel2 ( 0 ) ;
channel2_intr_enable ( 0 ) ;
}
2014-05-16 20:33:21 +07:00
if ( VPIF_CHANNEL3_VIDEO = = ch - > channel_id | | ycmux_mode = = 2 ) {
2014-03-22 18:03:08 +07:00
enable_channel3 ( 0 ) ;
channel3_intr_enable ( 0 ) ;
}
2012-06-28 19:28:36 +07:00
/* release all active buffers */
2012-11-16 22:03:07 +07:00
spin_lock_irqsave ( & common - > irqlock , flags ) ;
2014-03-22 18:03:08 +07:00
if ( common - > cur_frm = = common - > next_frm ) {
[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 20:30:30 +07:00
vb2_buffer_done ( & common - > cur_frm - > vb . vb2_buf ,
VB2_BUF_STATE_ERROR ) ;
2014-03-22 18:03:08 +07:00
} else {
2016-10-12 20:40:32 +07:00
if ( common - > cur_frm )
[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 20:30:30 +07:00
vb2_buffer_done ( & common - > cur_frm - > vb . vb2_buf ,
2014-03-22 18:03:08 +07:00
VB2_BUF_STATE_ERROR ) ;
2016-10-12 20:40:32 +07:00
if ( common - > next_frm )
[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 20:30:30 +07:00
vb2_buffer_done ( & common - > next_frm - > vb . vb2_buf ,
2014-03-22 18:03:08 +07:00
VB2_BUF_STATE_ERROR ) ;
}
2012-06-28 19:28:36 +07:00
while ( ! list_empty ( & common - > dma_queue ) ) {
common - > next_frm = list_entry ( common - > dma_queue . next ,
struct vpif_disp_buffer , list ) ;
list_del ( & common - > next_frm - > list ) ;
[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 20:30:30 +07:00
vb2_buffer_done ( & common - > next_frm - > vb . vb2_buf ,
VB2_BUF_STATE_ERROR ) ;
2012-06-28 19:28:36 +07:00
}
2012-11-16 22:03:07 +07:00
spin_unlock_irqrestore ( & common - > irqlock , flags ) ;
2012-06-28 19:28:36 +07:00
}
2017-07-07 03:35:53 +07:00
static const struct vb2_ops video_qops = {
2012-06-28 19:28:36 +07:00
. queue_setup = vpif_buffer_queue_setup ,
2014-05-16 20:33:08 +07:00
. wait_prepare = vb2_ops_wait_prepare ,
. wait_finish = vb2_ops_wait_finish ,
2012-06-28 19:28:36 +07:00
. buf_prepare = vpif_buffer_prepare ,
. start_streaming = vpif_start_streaming ,
. stop_streaming = vpif_stop_streaming ,
. buf_queue = vpif_buffer_queue ,
} ;
2009-06-09 15:55:37 +07:00
static void process_progressive_mode ( struct common_obj * common )
{
2016-10-12 20:45:03 +07:00
unsigned long addr ;
2009-06-09 15:55:37 +07:00
2012-11-16 22:03:07 +07:00
spin_lock ( & common - > irqlock ) ;
2009-06-09 15:55:37 +07:00
/* Get the next buffer from buffer queue */
common - > next_frm = list_entry ( common - > dma_queue . next ,
2012-06-28 19:28:36 +07:00
struct vpif_disp_buffer , list ) ;
2009-06-09 15:55:37 +07:00
/* Remove that buffer from the buffer queue */
2012-06-28 19:28:36 +07:00
list_del ( & common - > next_frm - > list ) ;
2012-11-16 22:03:07 +07:00
spin_unlock ( & common - > irqlock ) ;
2009-06-09 15:55:37 +07:00
/* Set top and bottom field addrs in VPIF registers */
[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 20:30:30 +07:00
addr = vb2_dma_contig_plane_dma_addr ( & common - > next_frm - > vb . vb2_buf , 0 ) ;
2009-06-09 15:55:37 +07:00
common - > set_addr ( addr + common - > ytop_off ,
addr + common - > ybtm_off ,
addr + common - > ctop_off ,
addr + common - > cbtm_off ) ;
}
static void process_interlaced_mode ( int fid , struct common_obj * common )
{
/* device field id and local field id are in sync */
/* If this is even field */
if ( 0 = = fid ) {
if ( common - > cur_frm = = common - > next_frm )
return ;
/* one frame is displayed If next frame is
* available , release cur_frm and move on */
/* Copy frame display time */
2015-11-03 17:16:37 +07:00
common - > cur_frm - > vb . vb2_buf . timestamp = ktime_get_ns ( ) ;
2009-06-09 15:55:37 +07:00
/* Change status of the cur_frm */
[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 20:30:30 +07:00
vb2_buffer_done ( & common - > cur_frm - > vb . vb2_buf ,
VB2_BUF_STATE_DONE ) ;
2009-06-09 15:55:37 +07:00
/* Make cur_frm pointing to next_frm */
common - > cur_frm = common - > next_frm ;
} else if ( 1 = = fid ) { /* odd field */
2012-11-16 22:03:07 +07:00
spin_lock ( & common - > irqlock ) ;
2009-06-09 15:55:37 +07:00
if ( list_empty ( & common - > dma_queue )
| | ( common - > cur_frm ! = common - > next_frm ) ) {
2012-11-16 22:03:07 +07:00
spin_unlock ( & common - > irqlock ) ;
2009-06-09 15:55:37 +07:00
return ;
}
2012-11-16 22:03:07 +07:00
spin_unlock ( & common - > irqlock ) ;
2009-06-09 15:55:37 +07:00
/* one field is displayed configure the next
* frame if it is available else hold on current
* frame */
/* Get next from the buffer queue */
process_progressive_mode ( common ) ;
}
}
/*
* vpif_channel_isr : It changes status of the displayed buffer , takes next
* buffer from the queue and sets its address in VPIF registers
*/
static irqreturn_t vpif_channel_isr ( int irq , void * dev_id )
{
struct vpif_device * dev = & vpif_obj ;
struct channel_obj * ch ;
struct common_obj * common ;
int fid = - 1 , i ;
2016-10-12 20:43:12 +07:00
int channel_id ;
2009-06-09 15:55:37 +07:00
channel_id = * ( int * ) ( dev_id ) ;
2012-04-13 14:43:10 +07:00
if ( ! vpif_intr_status ( channel_id + 2 ) )
return IRQ_NONE ;
2009-06-09 15:55:37 +07:00
ch = dev - > dev [ channel_id ] ;
for ( i = 0 ; i < VPIF_NUMOBJECTS ; i + + ) {
common = & ch - > common [ i ] ;
/* If streaming is started in this channel */
if ( 1 = = ch - > vpifparams . std_info . frm_fmt ) {
2012-11-16 22:03:07 +07:00
spin_lock ( & common - > irqlock ) ;
if ( list_empty ( & common - > dma_queue ) ) {
spin_unlock ( & common - > irqlock ) ;
2009-06-09 15:55:37 +07:00
continue ;
2012-11-16 22:03:07 +07:00
}
spin_unlock ( & common - > irqlock ) ;
2009-06-09 15:55:37 +07:00
/* Progressive mode */
if ( ! channel_first_int [ i ] [ channel_id ] ) {
/* Mark status of the cur_frm to
* done and unlock semaphore on it */
2015-11-03 17:16:37 +07:00
common - > cur_frm - > vb . vb2_buf . timestamp =
ktime_get_ns ( ) ;
[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 20:30:30 +07:00
vb2_buffer_done ( & common - > cur_frm - > vb . vb2_buf ,
VB2_BUF_STATE_DONE ) ;
2009-06-09 15:55:37 +07:00
/* Make cur_frm pointing to next_frm */
common - > cur_frm = common - > next_frm ;
}
channel_first_int [ i ] [ channel_id ] = 0 ;
process_progressive_mode ( common ) ;
} else {
/* Interlaced mode */
/* If it is first interrupt, ignore it */
if ( channel_first_int [ i ] [ channel_id ] ) {
channel_first_int [ i ] [ channel_id ] = 0 ;
continue ;
}
if ( 0 = = i ) {
ch - > field_id ^ = 1 ;
/* Get field id from VPIF registers */
fid = vpif_channel_getfid ( ch - > channel_id + 2 ) ;
/* If fid does not match with stored field id */
if ( fid ! = ch - > field_id ) {
/* Make them in sync */
if ( 0 = = fid )
ch - > field_id = fid ;
return IRQ_HANDLED ;
}
}
process_interlaced_mode ( fid , common ) ;
}
}
return IRQ_HANDLED ;
}
2010-12-16 22:17:44 +07:00
static int vpif_update_std_info ( struct channel_obj * ch )
2009-06-09 15:55:37 +07:00
{
struct video_obj * vid_ch = & ch - > video ;
struct vpif_params * vpifparams = & ch - > vpifparams ;
struct vpif_channel_config_params * std_info = & vpifparams - > std_info ;
const struct vpif_channel_config_params * config ;
2010-12-16 22:17:44 +07:00
int i ;
2009-06-09 15:55:37 +07:00
2010-12-16 22:17:44 +07:00
for ( i = 0 ; i < vpif_ch_params_count ; i + + ) {
2013-03-20 11:28:27 +07:00
config = & vpif_ch_params [ i ] ;
2010-12-16 22:17:43 +07:00
if ( config - > hd_sd = = 0 ) {
vpif_dbg ( 2 , debug , " SD format \n " ) ;
if ( config - > stdid & vid_ch - > stdid ) {
memcpy ( std_info , config , sizeof ( * config ) ) ;
break ;
}
2009-06-09 15:55:37 +07:00
}
}
2010-12-16 22:17:44 +07:00
if ( i = = vpif_ch_params_count ) {
vpif_dbg ( 1 , debug , " Format not found \n " ) ;
2010-12-16 22:17:42 +07:00
return - EINVAL ;
2010-12-16 22:17:44 +07:00
}
return 0 ;
}
static int vpif_update_resolution ( struct channel_obj * ch )
{
struct common_obj * common = & ch - > common [ VPIF_VIDEO_INDEX ] ;
struct video_obj * vid_ch = & ch - > video ;
struct vpif_params * vpifparams = & ch - > vpifparams ;
struct vpif_channel_config_params * std_info = & vpifparams - > std_info ;
2012-09-18 17:18:47 +07:00
if ( ! vid_ch - > stdid & & ! vid_ch - > dv_timings . bt . height )
2010-12-16 22:17:44 +07:00
return - EINVAL ;
2012-09-18 17:18:47 +07:00
if ( vid_ch - > stdid ) {
2010-12-16 22:17:44 +07:00
if ( vpif_update_std_info ( ch ) )
return - EINVAL ;
}
2009-06-09 15:55:37 +07:00
2014-05-16 20:33:30 +07:00
common - > fmt . fmt . pix . pixelformat = V4L2_PIX_FMT_YUV422P ;
2009-06-09 15:55:37 +07:00
common - > fmt . fmt . pix . width = std_info - > width ;
common - > fmt . fmt . pix . height = std_info - > height ;
vpif_dbg ( 1 , debug , " Pixel details: Width = %d,Height = %d \n " ,
common - > fmt . fmt . pix . width , common - > fmt . fmt . pix . height ) ;
/* Set height and width paramateres */
2010-12-16 22:17:44 +07:00
common - > height = std_info - > height ;
common - > width = std_info - > width ;
2014-05-16 20:33:30 +07:00
common - > fmt . fmt . pix . sizeimage = common - > height * common - > width * 2 ;
if ( vid_ch - > stdid )
common - > fmt . fmt . pix . colorspace = V4L2_COLORSPACE_SMPTE170M ;
else
common - > fmt . fmt . pix . colorspace = V4L2_COLORSPACE_REC709 ;
if ( ch - > vpifparams . std_info . frm_fmt )
common - > fmt . fmt . pix . field = V4L2_FIELD_NONE ;
else
common - > fmt . fmt . pix . field = V4L2_FIELD_INTERLACED ;
2009-06-09 15:55:37 +07:00
return 0 ;
}
/*
* vpif_calculate_offsets : This function calculates buffers offset for Y and C
* in the top and bottom field
*/
static void vpif_calculate_offsets ( struct channel_obj * ch )
{
struct common_obj * common = & ch - > common [ VPIF_VIDEO_INDEX ] ;
struct vpif_params * vpifparams = & ch - > vpifparams ;
enum v4l2_field field = common - > fmt . fmt . pix . field ;
struct video_obj * vid_ch = & ch - > video ;
2014-08-22 03:46:46 +07:00
unsigned int hpitch , sizeimage ;
2009-06-09 15:55:37 +07:00
if ( V4L2_FIELD_ANY = = common - > fmt . fmt . pix . field ) {
if ( ch - > vpifparams . std_info . frm_fmt )
vid_ch - > buf_field = V4L2_FIELD_NONE ;
else
vid_ch - > buf_field = V4L2_FIELD_INTERLACED ;
} else {
vid_ch - > buf_field = common - > fmt . fmt . pix . field ;
}
2012-06-28 19:28:36 +07:00
sizeimage = common - > fmt . fmt . pix . sizeimage ;
2009-06-09 15:55:37 +07:00
hpitch = common - > fmt . fmt . pix . bytesperline ;
if ( ( V4L2_FIELD_NONE = = vid_ch - > buf_field ) | |
( V4L2_FIELD_INTERLACED = = vid_ch - > buf_field ) ) {
common - > ytop_off = 0 ;
common - > ybtm_off = hpitch ;
common - > ctop_off = sizeimage / 2 ;
common - > cbtm_off = sizeimage / 2 + hpitch ;
} else if ( V4L2_FIELD_SEQ_TB = = vid_ch - > buf_field ) {
common - > ytop_off = 0 ;
common - > ybtm_off = sizeimage / 4 ;
common - > ctop_off = sizeimage / 2 ;
common - > cbtm_off = common - > ctop_off + sizeimage / 4 ;
} else if ( V4L2_FIELD_SEQ_BT = = vid_ch - > buf_field ) {
common - > ybtm_off = 0 ;
common - > ytop_off = sizeimage / 4 ;
common - > cbtm_off = sizeimage / 2 ;
common - > ctop_off = common - > cbtm_off + sizeimage / 4 ;
}
if ( ( V4L2_FIELD_NONE = = vid_ch - > buf_field ) | |
( V4L2_FIELD_INTERLACED = = vid_ch - > buf_field ) ) {
vpifparams - > video_params . storage_mode = 1 ;
} else {
vpifparams - > video_params . storage_mode = 0 ;
}
if ( ch - > vpifparams . std_info . frm_fmt = = 1 ) {
vpifparams - > video_params . hpitch =
common - > fmt . fmt . pix . bytesperline ;
} else {
if ( ( field = = V4L2_FIELD_ANY ) | |
( field = = V4L2_FIELD_INTERLACED ) )
vpifparams - > video_params . hpitch =
common - > fmt . fmt . pix . bytesperline * 2 ;
else
vpifparams - > video_params . hpitch =
common - > fmt . fmt . pix . bytesperline ;
}
ch - > vpifparams . video_params . stdid = ch - > vpifparams . std_info . stdid ;
}
static void vpif_config_addr ( struct channel_obj * ch , int muxmode )
{
struct common_obj * common = & ch - > common [ VPIF_VIDEO_INDEX ] ;
if ( VPIF_CHANNEL3_VIDEO = = ch - > channel_id ) {
common - > set_addr = ch3_set_videobuf_addr ;
} else {
if ( 2 = = muxmode )
common - > set_addr = ch2_set_videobuf_addr_yc_nmux ;
else
common - > set_addr = ch2_set_videobuf_addr ;
}
}
/* functions implementing ioctls */
2010-12-16 22:17:45 +07:00
/**
* vpif_querycap ( ) - QUERYCAP handler
* @ file : file ptr
* @ priv : file handle
* @ cap : ptr to v4l2_capability structure
*/
2009-06-09 15:55:37 +07:00
static int vpif_querycap ( struct file * file , void * priv ,
struct v4l2_capability * cap )
{
2009-09-17 00:30:53 +07:00
struct vpif_display_config * config = vpif_dev - > platform_data ;
2009-06-09 15:55:37 +07:00
2012-09-25 21:21:55 +07:00
cap - > device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING ;
cap - > capabilities = cap - > device_caps | V4L2_CAP_DEVICE_CAPS ;
2014-05-16 20:33:22 +07:00
strlcpy ( cap - > driver , VPIF_DRIVER_NAME , sizeof ( cap - > driver ) ) ;
2012-09-25 21:21:55 +07:00
snprintf ( cap - > bus_info , sizeof ( cap - > bus_info ) , " platform:%s " ,
dev_name ( vpif_dev ) ) ;
2009-06-09 15:55:37 +07:00
strlcpy ( cap - > card , config - > card_name , sizeof ( cap - > card ) ) ;
return 0 ;
}
static int vpif_enum_fmt_vid_out ( struct file * file , void * priv ,
struct v4l2_fmtdesc * fmt )
{
2014-05-16 20:33:30 +07:00
if ( fmt - > index ! = 0 )
2009-06-09 15:55:37 +07:00
return - EINVAL ;
/* Fill in the information about format */
fmt - > type = V4L2_BUF_TYPE_VIDEO_OUTPUT ;
strcpy ( fmt - > description , " YCbCr4:2:2 YC Planar " ) ;
fmt - > pixelformat = V4L2_PIX_FMT_YUV422P ;
2014-05-16 20:33:30 +07:00
fmt - > flags = 0 ;
2009-06-09 15:55:37 +07:00
return 0 ;
}
static int vpif_g_fmt_vid_out ( struct file * file , void * priv ,
struct v4l2_format * fmt )
{
2014-05-16 20:33:15 +07:00
struct video_device * vdev = video_devdata ( file ) ;
struct channel_obj * ch = video_get_drvdata ( vdev ) ;
2009-06-09 15:55:37 +07:00
struct common_obj * common = & ch - > common [ VPIF_VIDEO_INDEX ] ;
/* Check the validity of the buffer type */
if ( common - > fmt . type ! = fmt - > type )
return - EINVAL ;
2010-12-16 22:17:44 +07:00
if ( vpif_update_resolution ( ch ) )
2011-01-05 23:35:45 +07:00
return - EINVAL ;
* fmt = common - > fmt ;
return 0 ;
2009-06-09 15:55:37 +07:00
}
2014-05-16 20:33:30 +07:00
static int vpif_try_fmt_vid_out ( struct file * file , void * priv ,
2009-06-09 15:55:37 +07:00
struct v4l2_format * fmt )
{
2014-05-16 20:33:15 +07:00
struct video_device * vdev = video_devdata ( file ) ;
struct channel_obj * ch = video_get_drvdata ( vdev ) ;
2009-06-09 15:55:37 +07:00
struct common_obj * common = & ch - > common [ VPIF_VIDEO_INDEX ] ;
2014-05-16 20:33:30 +07:00
struct v4l2_pix_format * pixfmt = & fmt - > fmt . pix ;
2009-06-09 15:55:37 +07:00
2014-05-16 20:33:30 +07:00
/*
* to supress v4l - compliance warnings silently correct
* the pixelformat
*/
if ( pixfmt - > pixelformat ! = V4L2_PIX_FMT_YUV422P )
pixfmt - > pixelformat = common - > fmt . fmt . pix . pixelformat ;
2009-06-09 15:55:37 +07:00
2014-05-16 20:33:30 +07:00
if ( vpif_update_resolution ( ch ) )
return - EINVAL ;
pixfmt - > colorspace = common - > fmt . fmt . pix . colorspace ;
pixfmt - > field = common - > fmt . fmt . pix . field ;
pixfmt - > bytesperline = common - > fmt . fmt . pix . width ;
pixfmt - > width = common - > fmt . fmt . pix . width ;
pixfmt - > height = common - > fmt . fmt . pix . height ;
pixfmt - > sizeimage = pixfmt - > bytesperline * pixfmt - > height * 2 ;
2009-06-09 15:55:37 +07:00
return 0 ;
}
2014-05-16 20:33:30 +07:00
static int vpif_s_fmt_vid_out ( struct file * file , void * priv ,
2009-06-09 15:55:37 +07:00
struct v4l2_format * fmt )
{
2014-05-16 20:33:15 +07:00
struct video_device * vdev = video_devdata ( file ) ;
struct channel_obj * ch = video_get_drvdata ( vdev ) ;
2009-06-09 15:55:37 +07:00
struct common_obj * common = & ch - > common [ VPIF_VIDEO_INDEX ] ;
struct v4l2_pix_format * pixfmt = & fmt - > fmt . pix ;
2014-05-16 20:33:30 +07:00
int ret ;
2009-06-09 15:55:37 +07:00
2014-05-16 20:33:30 +07:00
if ( vb2_is_busy ( & common - > buffer_queue ) )
return - EBUSY ;
2009-06-09 15:55:37 +07:00
2014-05-16 20:33:30 +07:00
ret = vpif_try_fmt_vid_out ( file , priv , fmt ) ;
if ( ret )
return ret ;
/* store the pix format in the channel object */
common - > fmt . fmt . pix = * pixfmt ;
/* store the format in the channel object */
common - > fmt = * fmt ;
return 0 ;
2009-06-09 15:55:37 +07:00
}
2013-03-15 16:10:40 +07:00
static int vpif_s_std ( struct file * file , void * priv , v4l2_std_id std_id )
2009-06-09 15:55:37 +07:00
{
2014-05-16 20:33:28 +07:00
struct vpif_display_config * config = vpif_dev - > platform_data ;
2014-05-16 20:33:15 +07:00
struct video_device * vdev = video_devdata ( file ) ;
struct channel_obj * ch = video_get_drvdata ( vdev ) ;
2009-06-09 15:55:37 +07:00
struct common_obj * common = & ch - > common [ VPIF_VIDEO_INDEX ] ;
2014-05-16 20:33:28 +07:00
struct vpif_display_chan_config * chan_cfg ;
struct v4l2_output output ;
int ret ;
2016-10-12 20:40:32 +07:00
if ( ! config - > chan_config [ ch - > channel_id ] . outputs )
2014-05-16 20:33:28 +07:00
return - ENODATA ;
chan_cfg = & config - > chan_config [ ch - > channel_id ] ;
output = chan_cfg - > outputs [ ch - > output_idx ] . output ;
if ( output . capabilities ! = V4L2_OUT_CAP_STD )
return - ENODATA ;
2009-06-09 15:55:37 +07:00
2014-05-16 20:33:21 +07:00
if ( vb2_is_busy ( & common - > buffer_queue ) )
return - EBUSY ;
2014-05-16 20:33:28 +07:00
2013-03-15 16:10:40 +07:00
if ( ! ( std_id & VPIF_V4L2_STD ) )
2009-06-09 15:55:37 +07:00
return - EINVAL ;
/* Call encoder subdevice function to set the standard */
2013-03-15 16:10:40 +07:00
ch - > video . stdid = std_id ;
2012-09-18 17:18:47 +07:00
memset ( & ch - > video . dv_timings , 0 , sizeof ( ch - > video . dv_timings ) ) ;
2009-06-09 15:55:37 +07:00
/* Get the information about the standard */
2011-01-05 23:35:45 +07:00
if ( vpif_update_resolution ( ch ) )
return - EINVAL ;
2009-06-09 15:55:37 +07:00
common - > fmt . fmt . pix . bytesperline = common - > fmt . fmt . pix . width ;
ret = v4l2_device_call_until_err ( & vpif_obj . v4l2_dev , 1 , video ,
2013-03-15 16:10:40 +07:00
s_std_output , std_id ) ;
2009-06-09 15:55:37 +07:00
if ( ret < 0 ) {
vpif_err ( " Failed to set output standard \n " ) ;
2011-01-05 23:35:45 +07:00
return ret ;
2009-06-09 15:55:37 +07:00
}
2014-04-29 02:53:01 +07:00
ret = v4l2_device_call_until_err ( & vpif_obj . v4l2_dev , 1 , video ,
2013-03-15 16:10:40 +07:00
s_std , std_id ) ;
2009-06-09 15:55:37 +07:00
if ( ret < 0 )
vpif_err ( " Failed to set standard for sub devices \n " ) ;
return ret ;
}
static int vpif_g_std ( struct file * file , void * priv , v4l2_std_id * std )
{
2014-05-16 20:33:28 +07:00
struct vpif_display_config * config = vpif_dev - > platform_data ;
2014-05-16 20:33:15 +07:00
struct video_device * vdev = video_devdata ( file ) ;
struct channel_obj * ch = video_get_drvdata ( vdev ) ;
2014-05-16 20:33:28 +07:00
struct vpif_display_chan_config * chan_cfg ;
struct v4l2_output output ;
2016-10-12 20:40:32 +07:00
if ( ! config - > chan_config [ ch - > channel_id ] . outputs )
2014-05-16 20:33:28 +07:00
return - ENODATA ;
chan_cfg = & config - > chan_config [ ch - > channel_id ] ;
output = chan_cfg - > outputs [ ch - > output_idx ] . output ;
if ( output . capabilities ! = V4L2_OUT_CAP_STD )
return - ENODATA ;
2009-06-09 15:55:37 +07:00
* std = ch - > video . stdid ;
return 0 ;
}
static int vpif_enum_output ( struct file * file , void * fh ,
struct v4l2_output * output )
{
2009-09-17 00:30:53 +07:00
struct vpif_display_config * config = vpif_dev - > platform_data ;
2014-05-16 20:33:15 +07:00
struct video_device * vdev = video_devdata ( file ) ;
struct channel_obj * ch = video_get_drvdata ( vdev ) ;
2012-09-25 18:11:49 +07:00
struct vpif_display_chan_config * chan_cfg ;
2009-06-09 15:55:37 +07:00
2012-09-25 18:11:49 +07:00
chan_cfg = & config - > chan_config [ ch - > channel_id ] ;
if ( output - > index > = chan_cfg - > output_count ) {
2009-06-09 15:55:37 +07:00
vpif_dbg ( 1 , debug , " Invalid output index \n " ) ;
return - EINVAL ;
}
2012-09-25 18:11:49 +07:00
* output = chan_cfg - > outputs [ output - > index ] . output ;
return 0 ;
}
/**
* vpif_output_to_subdev ( ) - Maps output to sub device
2017-11-29 16:20:45 +07:00
* @ vpif_cfg : global config ptr
* @ chan_cfg : channel config ptr
* @ index : Given output index from application
2012-09-25 18:11:49 +07:00
*
* lookup the sub device information for a given output index .
* we report all the output to application . output table also
* has sub device name for the each output
*/
static int
vpif_output_to_subdev ( struct vpif_display_config * vpif_cfg ,
struct vpif_display_chan_config * chan_cfg , int index )
{
struct vpif_subdev_info * subdev_info ;
const char * subdev_name ;
int i ;
vpif_dbg ( 2 , debug , " vpif_output_to_subdev \n " ) ;
2016-10-12 20:40:32 +07:00
if ( ! chan_cfg - > outputs )
2012-09-25 18:11:49 +07:00
return - 1 ;
subdev_name = chan_cfg - > outputs [ index ] . subdev_name ;
2016-10-12 20:40:32 +07:00
if ( ! subdev_name )
2012-09-25 18:11:49 +07:00
return - 1 ;
/* loop through the sub device list to get the sub device info */
for ( i = 0 ; i < vpif_cfg - > subdev_count ; i + + ) {
subdev_info = & vpif_cfg - > subdevinfo [ i ] ;
if ( ! strcmp ( subdev_info - > name , subdev_name ) )
return i ;
}
return - 1 ;
}
/**
* vpif_set_output ( ) - Select an output
2017-11-29 16:20:45 +07:00
* @ vpif_cfg : global config ptr
* @ ch : channel
* @ index : Given output index from application
2012-09-25 18:11:49 +07:00
*
* Select the given output .
*/
static int vpif_set_output ( struct vpif_display_config * vpif_cfg ,
struct channel_obj * ch , int index )
{
struct vpif_display_chan_config * chan_cfg =
& vpif_cfg - > chan_config [ ch - > channel_id ] ;
struct v4l2_subdev * sd = NULL ;
u32 input = 0 , output = 0 ;
int sd_index ;
int ret ;
sd_index = vpif_output_to_subdev ( vpif_cfg , chan_cfg , index ) ;
2014-08-22 03:46:46 +07:00
if ( sd_index > = 0 )
2012-09-25 18:11:49 +07:00
sd = vpif_obj . sd [ sd_index ] ;
2009-06-09 15:55:37 +07:00
2012-09-25 18:11:49 +07:00
if ( sd ) {
input = chan_cfg - > outputs [ index ] . input_route ;
output = chan_cfg - > outputs [ index ] . output_route ;
ret = v4l2_subdev_call ( sd , video , s_routing , input , output , 0 ) ;
if ( ret < 0 & & ret ! = - ENOIOCTLCMD ) {
vpif_err ( " Failed to set output \n " ) ;
return ret ;
}
}
ch - > output_idx = index ;
ch - > sd = sd ;
2016-10-12 20:40:32 +07:00
if ( chan_cfg - > outputs )
2012-09-25 18:11:49 +07:00
/* update tvnorms from the sub device output info */
2015-03-09 04:57:24 +07:00
ch - > video_dev . tvnorms = chan_cfg - > outputs [ index ] . output . std ;
2009-06-09 15:55:37 +07:00
return 0 ;
}
static int vpif_s_output ( struct file * file , void * priv , unsigned int i )
{
2012-09-25 18:11:49 +07:00
struct vpif_display_config * config = vpif_dev - > platform_data ;
2014-05-16 20:33:15 +07:00
struct video_device * vdev = video_devdata ( file ) ;
struct channel_obj * ch = video_get_drvdata ( vdev ) ;
2012-09-25 18:11:49 +07:00
struct vpif_display_chan_config * chan_cfg ;
2009-06-09 15:55:37 +07:00
struct common_obj * common = & ch - > common [ VPIF_VIDEO_INDEX ] ;
2012-09-25 18:11:49 +07:00
2014-05-16 20:33:21 +07:00
if ( vb2_is_busy ( & common - > buffer_queue ) )
return - EBUSY ;
2012-09-25 18:11:49 +07:00
chan_cfg = & config - > chan_config [ ch - > channel_id ] ;
if ( i > = chan_cfg - > output_count )
return - EINVAL ;
2009-06-09 15:55:37 +07:00
2012-09-25 18:11:49 +07:00
return vpif_set_output ( config , ch , i ) ;
2009-06-09 15:55:37 +07:00
}
static int vpif_g_output ( struct file * file , void * priv , unsigned int * i )
{
2014-05-16 20:33:15 +07:00
struct video_device * vdev = video_devdata ( file ) ;
struct channel_obj * ch = video_get_drvdata ( vdev ) ;
2009-06-09 15:55:37 +07:00
2012-09-20 19:06:23 +07:00
* i = ch - > output_idx ;
2009-06-09 15:55:37 +07:00
return 0 ;
}
2010-12-16 22:17:43 +07:00
/**
2012-09-18 17:18:47 +07:00
* vpif_enum_dv_timings ( ) - ENUM_DV_TIMINGS handler
2010-12-16 22:17:43 +07:00
* @ file : file ptr
* @ priv : file handle
2012-09-18 17:18:47 +07:00
* @ timings : input timings
2010-12-16 22:17:43 +07:00
*/
2012-09-18 17:18:47 +07:00
static int
vpif_enum_dv_timings ( struct file * file , void * priv ,
struct v4l2_enum_dv_timings * timings )
2010-12-16 22:17:43 +07:00
{
2014-05-16 20:33:27 +07:00
struct vpif_display_config * config = vpif_dev - > platform_data ;
2014-05-16 20:33:15 +07:00
struct video_device * vdev = video_devdata ( file ) ;
struct channel_obj * ch = video_get_drvdata ( vdev ) ;
2014-05-16 20:33:27 +07:00
struct vpif_display_chan_config * chan_cfg ;
struct v4l2_output output ;
2012-09-25 18:11:49 +07:00
int ret ;
2010-12-16 22:17:43 +07:00
2016-10-12 20:40:32 +07:00
if ( ! config - > chan_config [ ch - > channel_id ] . outputs )
2014-05-16 20:33:27 +07:00
return - ENODATA ;
chan_cfg = & config - > chan_config [ ch - > channel_id ] ;
output = chan_cfg - > outputs [ ch - > output_idx ] . output ;
if ( output . capabilities ! = V4L2_OUT_CAP_DV_TIMINGS )
return - ENODATA ;
2014-01-31 19:04:19 +07:00
timings - > pad = 0 ;
ret = v4l2_subdev_call ( ch - > sd , pad , enum_dv_timings , timings ) ;
2012-10-30 19:49:38 +07:00
if ( ret = = - ENOIOCTLCMD | | ret = = - ENODEV )
2012-09-25 18:11:49 +07:00
return - EINVAL ;
return ret ;
2010-12-16 22:17:43 +07:00
}
2010-12-16 22:17:44 +07:00
/**
* vpif_s_dv_timings ( ) - S_DV_TIMINGS handler
* @ file : file ptr
* @ priv : file handle
* @ timings : digital video timings
*/
static int vpif_s_dv_timings ( struct file * file , void * priv ,
struct v4l2_dv_timings * timings )
{
2014-05-16 20:33:27 +07:00
struct vpif_display_config * config = vpif_dev - > platform_data ;
2014-05-16 20:33:15 +07:00
struct video_device * vdev = video_devdata ( file ) ;
struct channel_obj * ch = video_get_drvdata ( vdev ) ;
2010-12-16 22:17:44 +07:00
struct vpif_params * vpifparams = & ch - > vpifparams ;
2014-05-16 20:33:27 +07:00
struct common_obj * common = & ch - > common [ VPIF_VIDEO_INDEX ] ;
2010-12-16 22:17:44 +07:00
struct vpif_channel_config_params * std_info = & vpifparams - > std_info ;
struct video_obj * vid_ch = & ch - > video ;
2012-09-18 17:18:47 +07:00
struct v4l2_bt_timings * bt = & vid_ch - > dv_timings . bt ;
2014-05-16 20:33:27 +07:00
struct vpif_display_chan_config * chan_cfg ;
struct v4l2_output output ;
2010-12-16 22:17:44 +07:00
int ret ;
2016-10-12 20:40:32 +07:00
if ( ! config - > chan_config [ ch - > channel_id ] . outputs )
2014-05-16 20:33:27 +07:00
return - ENODATA ;
chan_cfg = & config - > chan_config [ ch - > channel_id ] ;
output = chan_cfg - > outputs [ ch - > output_idx ] . output ;
if ( output . capabilities ! = V4L2_OUT_CAP_DV_TIMINGS )
return - ENODATA ;
if ( vb2_is_busy ( & common - > buffer_queue ) )
return - EBUSY ;
2010-12-16 22:17:44 +07:00
if ( timings - > type ! = V4L2_DV_BT_656_1120 ) {
vpif_dbg ( 2 , debug , " Timing type not defined \n " ) ;
return - EINVAL ;
}
/* Configure subdevice timings, if any */
2012-09-20 19:06:31 +07:00
ret = v4l2_subdev_call ( ch - > sd , video , s_dv_timings , timings ) ;
2012-09-25 18:11:49 +07:00
if ( ret = = - ENOIOCTLCMD | | ret = = - ENODEV )
ret = 0 ;
if ( ret < 0 ) {
2010-12-16 22:17:44 +07:00
vpif_dbg ( 2 , debug , " Error setting custom DV timings \n " ) ;
return ret ;
}
if ( ! ( timings - > bt . width & & timings - > bt . height & &
( timings - > bt . hbackporch | |
timings - > bt . hfrontporch | |
timings - > bt . hsync ) & &
timings - > bt . vfrontporch & &
( timings - > bt . vbackporch | |
timings - > bt . vsync ) ) ) {
[media] davinci: don't break long lines
Due to the 80-cols restrictions, and latter due to checkpatch
warnings, several strings were broken into multiple lines. This
is not considered a good practice anymore, as it makes harder
to grep for strings at the source code.
As we're right now fixing other drivers due to KERN_CONT, we need
to be able to identify what printk strings don't end with a "\n".
It is a way easier to detect those if we don't break long lines.
So, join those continuation lines.
The patch was generated via the script below, and manually
adjusted if needed.
</script>
use Text::Tabs;
while (<>) {
if ($next ne "") {
$c=$_;
if ($c =~ /^\s+\"(.*)/) {
$c2=$1;
$next =~ s/\"\n$//;
$n = expand($next);
$funpos = index($n, '(');
$pos = index($c2, '",');
if ($funpos && $pos > 0) {
$s1 = substr $c2, 0, $pos + 2;
$s2 = ' ' x ($funpos + 1) . substr $c2, $pos + 2;
$s2 =~ s/^\s+//;
$s2 = ' ' x ($funpos + 1) . $s2 if ($s2 ne "");
print unexpand("$next$s1\n");
print unexpand("$s2\n") if ($s2 ne "");
} else {
print "$next$c2\n";
}
$next="";
next;
} else {
print $next;
}
$next="";
} else {
if (m/\"$/) {
if (!m/\\n\"$/) {
$next=$_;
next;
}
}
}
print $_;
}
</script>
Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-10-19 02:44:08 +07:00
vpif_dbg ( 2 , debug , " Timings for width, height, horizontal back porch, horizontal sync, horizontal front porch, vertical back porch, vertical sync and vertical back porch must be defined \n " ) ;
2010-12-16 22:17:44 +07:00
return - EINVAL ;
}
2012-09-18 17:18:47 +07:00
vid_ch - > dv_timings = * timings ;
2010-12-16 22:17:44 +07:00
/* Configure video port timings */
2013-07-29 18:41:00 +07:00
std_info - > eav2sav = V4L2_DV_BT_BLANKING_WIDTH ( bt ) - 8 ;
2010-12-16 22:17:44 +07:00
std_info - > sav2eav = bt - > width ;
std_info - > l1 = 1 ;
std_info - > l3 = bt - > vsync + bt - > vbackporch + 1 ;
2013-07-29 18:41:00 +07:00
std_info - > vsize = V4L2_DV_BT_FRAME_HEIGHT ( bt ) ;
2010-12-16 22:17:44 +07:00
if ( bt - > interlaced ) {
if ( bt - > il_vbackporch | | bt - > il_vfrontporch | | bt - > il_vsync ) {
std_info - > l5 = std_info - > vsize / 2 -
( bt - > vfrontporch - 1 ) ;
std_info - > l7 = std_info - > vsize / 2 + 1 ;
std_info - > l9 = std_info - > l7 + bt - > il_vsync +
bt - > il_vbackporch + 1 ;
std_info - > l11 = std_info - > vsize -
( bt - > il_vfrontporch - 1 ) ;
} else {
[media] davinci: don't break long lines
Due to the 80-cols restrictions, and latter due to checkpatch
warnings, several strings were broken into multiple lines. This
is not considered a good practice anymore, as it makes harder
to grep for strings at the source code.
As we're right now fixing other drivers due to KERN_CONT, we need
to be able to identify what printk strings don't end with a "\n".
It is a way easier to detect those if we don't break long lines.
So, join those continuation lines.
The patch was generated via the script below, and manually
adjusted if needed.
</script>
use Text::Tabs;
while (<>) {
if ($next ne "") {
$c=$_;
if ($c =~ /^\s+\"(.*)/) {
$c2=$1;
$next =~ s/\"\n$//;
$n = expand($next);
$funpos = index($n, '(');
$pos = index($c2, '",');
if ($funpos && $pos > 0) {
$s1 = substr $c2, 0, $pos + 2;
$s2 = ' ' x ($funpos + 1) . substr $c2, $pos + 2;
$s2 =~ s/^\s+//;
$s2 = ' ' x ($funpos + 1) . $s2 if ($s2 ne "");
print unexpand("$next$s1\n");
print unexpand("$s2\n") if ($s2 ne "");
} else {
print "$next$c2\n";
}
$next="";
next;
} else {
print $next;
}
$next="";
} else {
if (m/\"$/) {
if (!m/\\n\"$/) {
$next=$_;
next;
}
}
}
print $_;
}
</script>
Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-10-19 02:44:08 +07:00
vpif_dbg ( 2 , debug , " Required timing values for interlaced BT format missing \n " ) ;
2010-12-16 22:17:44 +07:00
return - EINVAL ;
}
} else {
std_info - > l5 = std_info - > vsize - ( bt - > vfrontporch - 1 ) ;
}
strncpy ( std_info - > name , " Custom timings BT656/1120 " ,
VPIF_MAX_NAME ) ;
std_info - > width = bt - > width ;
std_info - > height = bt - > height ;
std_info - > frm_fmt = bt - > interlaced ? 0 : 1 ;
std_info - > ycmux_mode = 0 ;
std_info - > capture_format = 0 ;
std_info - > vbi_supported = 0 ;
std_info - > hd_sd = 1 ;
std_info - > stdid = 0 ;
vid_ch - > stdid = 0 ;
return 0 ;
}
/**
* vpif_g_dv_timings ( ) - G_DV_TIMINGS handler
* @ file : file ptr
* @ priv : file handle
* @ timings : digital video timings
*/
static int vpif_g_dv_timings ( struct file * file , void * priv ,
struct v4l2_dv_timings * timings )
{
2014-05-16 20:33:27 +07:00
struct vpif_display_config * config = vpif_dev - > platform_data ;
2014-05-16 20:33:15 +07:00
struct video_device * vdev = video_devdata ( file ) ;
struct channel_obj * ch = video_get_drvdata ( vdev ) ;
2014-05-16 20:33:27 +07:00
struct vpif_display_chan_config * chan_cfg ;
2010-12-16 22:17:44 +07:00
struct video_obj * vid_ch = & ch - > video ;
2014-05-16 20:33:27 +07:00
struct v4l2_output output ;
2016-10-12 20:40:32 +07:00
if ( ! config - > chan_config [ ch - > channel_id ] . outputs )
2014-05-16 20:33:27 +07:00
goto error ;
chan_cfg = & config - > chan_config [ ch - > channel_id ] ;
output = chan_cfg - > outputs [ ch - > output_idx ] . output ;
if ( output . capabilities ! = V4L2_OUT_CAP_DV_TIMINGS )
goto error ;
2010-12-16 22:17:44 +07:00
2012-09-18 17:18:47 +07:00
* timings = vid_ch - > dv_timings ;
2010-12-16 22:17:44 +07:00
return 0 ;
2014-05-16 20:33:27 +07:00
error :
return - ENODATA ;
2010-12-16 22:17:44 +07:00
}
2010-12-16 22:17:41 +07:00
/*
* vpif_log_status ( ) - Status information
* @ file : file ptr
* @ priv : file handle
*
* Returns zero .
*/
static int vpif_log_status ( struct file * filep , void * priv )
{
/* status for sub devices */
v4l2_device_call_all ( & vpif_obj . v4l2_dev , 0 , core , log_status ) ;
return 0 ;
}
2009-06-09 15:55:37 +07:00
/* vpif display ioctl operations */
static const struct v4l2_ioctl_ops vpif_ioctl_ops = {
2014-05-16 20:33:25 +07:00
. vidioc_querycap = vpif_querycap ,
2009-06-09 15:55:37 +07:00
. vidioc_enum_fmt_vid_out = vpif_enum_fmt_vid_out ,
2014-05-16 20:33:25 +07:00
. vidioc_g_fmt_vid_out = vpif_g_fmt_vid_out ,
. vidioc_s_fmt_vid_out = vpif_s_fmt_vid_out ,
. vidioc_try_fmt_vid_out = vpif_try_fmt_vid_out ,
2014-05-16 20:33:16 +07:00
. vidioc_reqbufs = vb2_ioctl_reqbufs ,
. vidioc_create_bufs = vb2_ioctl_create_bufs ,
. vidioc_querybuf = vb2_ioctl_querybuf ,
. vidioc_qbuf = vb2_ioctl_qbuf ,
. vidioc_dqbuf = vb2_ioctl_dqbuf ,
. vidioc_expbuf = vb2_ioctl_expbuf ,
. vidioc_streamon = vb2_ioctl_streamon ,
. vidioc_streamoff = vb2_ioctl_streamoff ,
2014-05-16 20:33:25 +07:00
. vidioc_s_std = vpif_s_std ,
2009-06-09 15:55:37 +07:00
. vidioc_g_std = vpif_g_std ,
2014-05-16 20:33:25 +07:00
2009-06-09 15:55:37 +07:00
. vidioc_enum_output = vpif_enum_output ,
. vidioc_s_output = vpif_s_output ,
. vidioc_g_output = vpif_g_output ,
2014-05-16 20:33:25 +07:00
. vidioc_enum_dv_timings = vpif_enum_dv_timings ,
. vidioc_s_dv_timings = vpif_s_dv_timings ,
. vidioc_g_dv_timings = vpif_g_dv_timings ,
2010-12-16 22:17:41 +07:00
. vidioc_log_status = vpif_log_status ,
2009-06-09 15:55:37 +07:00
} ;
static const struct v4l2_file_operations vpif_fops = {
. owner = THIS_MODULE ,
2014-05-16 20:33:15 +07:00
. open = v4l2_fh_open ,
. release = vb2_fop_release ,
2011-01-05 23:35:45 +07:00
. unlocked_ioctl = video_ioctl2 ,
2014-05-16 20:33:14 +07:00
. mmap = vb2_fop_mmap ,
. poll = vb2_fop_poll
2009-06-09 15:55:37 +07:00
} ;
/*Configure the channels, buffer sizei, request irq */
static int initialize_vpif ( void )
{
int free_channel_objects_index ;
2014-05-16 20:33:23 +07:00
int err , i , j ;
2009-06-09 15:55:37 +07:00
/* Allocate memory for six channel objects */
for ( i = 0 ; i < VPIF_DISPLAY_MAX_DEVICES ; i + + ) {
vpif_obj . dev [ i ] =
2010-08-30 20:30:37 +07:00
kzalloc ( sizeof ( struct channel_obj ) , GFP_KERNEL ) ;
2009-06-09 15:55:37 +07:00
/* If memory allocation fails, return error */
if ( ! vpif_obj . dev [ i ] ) {
free_channel_objects_index = i ;
err = - ENOMEM ;
goto vpif_init_free_channel_objects ;
}
}
return 0 ;
vpif_init_free_channel_objects :
for ( j = 0 ; j < free_channel_objects_index ; j + + )
kfree ( vpif_obj . dev [ j ] ) ;
return err ;
}
2013-06-25 21:17:35 +07:00
static int vpif_async_bound ( struct v4l2_async_notifier * notifier ,
struct v4l2_subdev * subdev ,
struct v4l2_async_subdev * asd )
{
int i ;
for ( i = 0 ; i < vpif_obj . config - > subdev_count ; i + + )
if ( ! strcmp ( vpif_obj . config - > subdevinfo [ i ] . name ,
subdev - > name ) ) {
vpif_obj . sd [ i ] = subdev ;
vpif_obj . sd [ i ] - > grp_id = 1 < < i ;
return 0 ;
}
return - EINVAL ;
}
static int vpif_probe_complete ( void )
{
struct common_obj * common ;
2014-05-16 20:33:14 +07:00
struct video_device * vdev ;
2013-06-25 21:17:35 +07:00
struct channel_obj * ch ;
2014-05-16 20:33:06 +07:00
struct vb2_queue * q ;
2013-06-25 21:17:35 +07:00
int j , err , k ;
for ( j = 0 ; j < VPIF_DISPLAY_MAX_DEVICES ; j + + ) {
ch = vpif_obj . dev [ j ] ;
/* Initialize field of the channel objects */
for ( k = 0 ; k < VPIF_NUMOBJECTS ; k + + ) {
common = & ch - > common [ k ] ;
spin_lock_init ( & common - > irqlock ) ;
mutex_init ( & common - > lock ) ;
common - > set_addr = NULL ;
common - > ytop_off = 0 ;
common - > ybtm_off = 0 ;
common - > ctop_off = 0 ;
common - > cbtm_off = 0 ;
common - > cur_frm = NULL ;
common - > next_frm = NULL ;
memset ( & common - > fmt , 0 , sizeof ( common - > fmt ) ) ;
}
ch - > initialized = 0 ;
if ( vpif_obj . config - > subdev_count )
ch - > sd = vpif_obj . sd [ 0 ] ;
ch - > channel_id = j ;
memset ( & ch - > vpifparams , 0 , sizeof ( ch - > vpifparams ) ) ;
ch - > common [ VPIF_VIDEO_INDEX ] . fmt . type =
V4L2_BUF_TYPE_VIDEO_OUTPUT ;
/* select output 0 */
err = vpif_set_output ( vpif_obj . config , ch , 0 ) ;
if ( err )
goto probe_out ;
2014-05-16 20:33:30 +07:00
/* set initial format */
ch - > video . stdid = V4L2_STD_525_60 ;
memset ( & ch - > video . dv_timings , 0 , sizeof ( ch - > video . dv_timings ) ) ;
vpif_update_resolution ( ch ) ;
2014-05-16 20:33:06 +07:00
/* Initialize vb2 queue */
q = & common - > buffer_queue ;
q - > type = V4L2_BUF_TYPE_VIDEO_OUTPUT ;
q - > io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF ;
q - > drv_priv = ch ;
q - > ops = & video_qops ;
q - > mem_ops = & vb2_dma_contig_memops ;
q - > buf_struct_size = sizeof ( struct vpif_disp_buffer ) ;
q - > timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ;
q - > min_buffers_needed = 1 ;
2014-05-16 20:33:08 +07:00
q - > lock = & common - > lock ;
2016-02-15 22:09:10 +07:00
q - > dev = vpif_dev ;
2014-05-16 20:33:06 +07:00
err = vb2_queue_init ( q ) ;
if ( err ) {
vpif_err ( " vpif_display: vb2_queue_init() failed \n " ) ;
goto probe_out ;
}
INIT_LIST_HEAD ( & common - > dma_queue ) ;
2013-06-25 21:17:35 +07:00
/* register video device */
2014-08-22 18:38:14 +07:00
vpif_dbg ( 1 , debug , " channel=%p,channel->video_dev=%p \n " ,
ch , & ch - > video_dev ) ;
2013-06-25 21:17:35 +07:00
2014-05-16 20:33:22 +07:00
/* Initialize the video_device structure */
2015-03-09 04:57:24 +07:00
vdev = & ch - > video_dev ;
2014-05-16 20:33:22 +07:00
strlcpy ( vdev - > name , VPIF_DRIVER_NAME , sizeof ( vdev - > name ) ) ;
2015-03-09 04:57:24 +07:00
vdev - > release = video_device_release_empty ;
2014-05-16 20:33:22 +07:00
vdev - > fops = & vpif_fops ;
vdev - > ioctl_ops = & vpif_ioctl_ops ;
vdev - > v4l2_dev = & vpif_obj . v4l2_dev ;
vdev - > vfl_dir = VFL_DIR_TX ;
2014-05-16 20:33:14 +07:00
vdev - > queue = q ;
2014-05-16 20:33:15 +07:00
vdev - > lock = & common - > lock ;
2015-03-09 04:57:24 +07:00
video_set_drvdata ( & ch - > video_dev , ch ) ;
2014-05-16 20:33:14 +07:00
err = video_register_device ( vdev , VFL_TYPE_GRABBER ,
( j ? 3 : 2 ) ) ;
2013-06-25 21:17:35 +07:00
if ( err < 0 )
goto probe_out ;
}
return 0 ;
probe_out :
for ( k = 0 ; k < j ; k + + ) {
ch = vpif_obj . dev [ k ] ;
2014-05-16 20:33:06 +07:00
common = & ch - > common [ k ] ;
2015-03-09 04:57:24 +07:00
video_unregister_device ( & ch - > video_dev ) ;
2013-06-25 21:17:35 +07:00
}
return err ;
}
static int vpif_async_complete ( struct v4l2_async_notifier * notifier )
{
return vpif_probe_complete ( ) ;
}
2017-08-31 00:18:04 +07:00
static const struct v4l2_async_notifier_operations vpif_async_ops = {
. bound = vpif_async_bound ,
. complete = vpif_async_complete ,
} ;
2009-06-09 15:55:37 +07:00
/*
* vpif_probe : This function creates device entries by register itself to the
* V4L2 driver and initializes fields of each channel objects
*/
static __init int vpif_probe ( struct platform_device * pdev )
{
2009-09-17 00:30:53 +07:00
struct vpif_subdev_info * subdevdata ;
2009-06-09 15:55:37 +07:00
struct i2c_adapter * i2c_adap ;
struct resource * res ;
int subdev_count ;
2015-03-09 04:57:24 +07:00
int res_idx = 0 ;
int i , err ;
2009-06-09 15:55:37 +07:00
2016-12-17 07:47:54 +07:00
if ( ! pdev - > dev . platform_data ) {
dev_warn ( & pdev - > dev , " Missing platform data. Giving up. \n " ) ;
return - EINVAL ;
}
2017-06-07 06:37:39 +07:00
if ( ! pdev - > dev . platform_data ) {
dev_warn ( & pdev - > dev , " Missing platform data. Giving up. \n " ) ;
return - EINVAL ;
}
2009-06-09 15:55:37 +07:00
vpif_dev = & pdev - > dev ;
2009-09-17 00:30:53 +07:00
err = initialize_vpif ( ) ;
2009-06-09 15:55:37 +07:00
2009-09-17 00:30:53 +07:00
if ( err ) {
v4l2_err ( vpif_dev - > driver , " Error initializing vpif \n " ) ;
return err ;
2009-06-09 15:55:37 +07:00
}
err = v4l2_device_register ( vpif_dev , & vpif_obj . v4l2_dev ) ;
if ( err ) {
v4l2_err ( vpif_dev - > driver , " Error registering v4l2 device \n " ) ;
return err ;
}
2012-09-20 19:06:28 +07:00
while ( ( res = platform_get_resource ( pdev , IORESOURCE_IRQ , res_idx ) ) ) {
2013-06-17 21:20:51 +07:00
err = devm_request_irq ( & pdev - > dev , res - > start , vpif_channel_isr ,
2014-05-16 20:33:22 +07:00
IRQF_SHARED , VPIF_DRIVER_NAME ,
2013-06-17 21:20:51 +07:00
( void * ) ( & vpif_obj . dev [ res_idx ] - >
channel_id ) ) ;
if ( err ) {
err = - EINVAL ;
vpif_err ( " VPIF IRQ request failed \n " ) ;
goto vpif_unregister ;
2009-06-09 15:55:37 +07:00
}
2012-09-20 19:06:28 +07:00
res_idx + + ;
2009-06-09 15:55:37 +07:00
}
2013-06-25 21:17:35 +07:00
vpif_obj . config = pdev - > dev . platform_data ;
subdev_count = vpif_obj . config - > subdev_count ;
subdevdata = vpif_obj . config - > subdevinfo ;
2016-10-12 20:30:44 +07:00
vpif_obj . sd = kcalloc ( subdev_count , sizeof ( * vpif_obj . sd ) , GFP_KERNEL ) ;
2016-10-12 20:40:32 +07:00
if ( ! vpif_obj . sd ) {
2012-09-20 19:06:27 +07:00
err = - ENOMEM ;
2015-03-09 04:57:24 +07:00
goto vpif_unregister ;
2012-09-20 19:06:27 +07:00
}
2013-06-25 21:17:35 +07:00
if ( ! vpif_obj . config - > asd_sizes ) {
2017-02-17 01:08:01 +07:00
i2c_adap = i2c_get_adapter ( vpif_obj . config - > i2c_adapter_id ) ;
2013-06-25 21:17:35 +07:00
for ( i = 0 ; i < subdev_count ; i + + ) {
vpif_obj . sd [ i ] =
v4l2_i2c_new_subdev_board ( & vpif_obj . v4l2_dev ,
i2c_adap ,
& subdevdata [ i ] .
board_info ,
NULL ) ;
if ( ! vpif_obj . sd [ i ] ) {
vpif_err ( " Error registering v4l2 subdevice \n " ) ;
2013-08-23 08:59:44 +07:00
err = - ENODEV ;
2013-06-25 21:17:35 +07:00
goto probe_subdev_out ;
}
2009-06-09 15:55:37 +07:00
2013-06-25 21:17:35 +07:00
if ( vpif_obj . sd [ i ] )
vpif_obj . sd [ i ] - > grp_id = 1 < < i ;
}
vpif_probe_complete ( ) ;
} else {
2013-07-19 22:31:10 +07:00
vpif_obj . notifier . subdevs = vpif_obj . config - > asd ;
2013-06-25 21:17:35 +07:00
vpif_obj . notifier . num_subdevs = vpif_obj . config - > asd_sizes [ 0 ] ;
2017-08-31 00:18:04 +07:00
vpif_obj . notifier . ops = & vpif_async_ops ;
2013-06-25 21:17:35 +07:00
err = v4l2_async_notifier_register ( & vpif_obj . v4l2_dev ,
& vpif_obj . notifier ) ;
if ( err ) {
vpif_err ( " Error registering async notifier \n " ) ;
err = - EINVAL ;
goto probe_subdev_out ;
2009-06-09 15:55:37 +07:00
}
}
return 0 ;
2012-09-20 19:06:27 +07:00
probe_subdev_out :
kfree ( vpif_obj . sd ) ;
2013-06-17 21:20:50 +07:00
vpif_unregister :
2009-06-09 15:55:37 +07:00
v4l2_device_unregister ( & vpif_obj . v4l2_dev ) ;
return err ;
}
/*
* vpif_remove : It un - register channels from V4L2 driver
*/
static int vpif_remove ( struct platform_device * device )
{
struct channel_obj * ch ;
2013-06-17 21:20:50 +07:00
int i ;
2009-06-09 15:55:37 +07:00
v4l2_device_unregister ( & vpif_obj . v4l2_dev ) ;
2013-06-17 21:20:48 +07:00
kfree ( vpif_obj . sd ) ;
2009-06-09 15:55:37 +07:00
/* un-register device */
for ( i = 0 ; i < VPIF_DISPLAY_MAX_DEVICES ; i + + ) {
/* Get the pointer to the channel object */
ch = vpif_obj . dev [ i ] ;
/* Unregister video device */
2015-03-09 04:57:24 +07:00
video_unregister_device ( & ch - > video_dev ) ;
2013-06-17 21:20:48 +07:00
kfree ( vpif_obj . dev [ i ] ) ;
2009-06-09 15:55:37 +07:00
}
return 0 ;
}
2014-05-16 20:33:26 +07:00
# ifdef CONFIG_PM_SLEEP
2012-04-13 14:50:35 +07:00
static int vpif_suspend ( struct device * dev )
{
struct common_obj * common ;
struct channel_obj * ch ;
int i ;
for ( i = 0 ; i < VPIF_DISPLAY_MAX_DEVICES ; i + + ) {
/* Get the pointer to the channel object */
ch = vpif_obj . dev [ i ] ;
common = & ch - > common [ VPIF_VIDEO_INDEX ] ;
2014-05-16 20:33:26 +07:00
2014-09-06 22:26:50 +07:00
if ( ! vb2_start_streaming_called ( & common - > buffer_queue ) )
2014-05-16 20:33:26 +07:00
continue ;
2012-04-13 14:50:35 +07:00
mutex_lock ( & common - > lock ) ;
2014-05-16 20:33:26 +07:00
/* Disable channel */
if ( ch - > channel_id = = VPIF_CHANNEL2_VIDEO ) {
enable_channel2 ( 0 ) ;
channel2_intr_enable ( 0 ) ;
}
if ( ch - > channel_id = = VPIF_CHANNEL3_VIDEO | |
ycmux_mode = = 2 ) {
enable_channel3 ( 0 ) ;
channel3_intr_enable ( 0 ) ;
2012-04-13 14:50:35 +07:00
}
mutex_unlock ( & common - > lock ) ;
}
return 0 ;
}
static int vpif_resume ( struct device * dev )
{
struct common_obj * common ;
struct channel_obj * ch ;
int i ;
for ( i = 0 ; i < VPIF_DISPLAY_MAX_DEVICES ; i + + ) {
/* Get the pointer to the channel object */
ch = vpif_obj . dev [ i ] ;
common = & ch - > common [ VPIF_VIDEO_INDEX ] ;
2014-05-16 20:33:26 +07:00
2014-09-06 22:26:50 +07:00
if ( ! vb2_start_streaming_called ( & common - > buffer_queue ) )
2014-05-16 20:33:26 +07:00
continue ;
2012-04-13 14:50:35 +07:00
mutex_lock ( & common - > lock ) ;
2014-05-16 20:33:26 +07:00
/* Enable channel */
if ( ch - > channel_id = = VPIF_CHANNEL2_VIDEO ) {
enable_channel2 ( 1 ) ;
channel2_intr_enable ( 1 ) ;
}
if ( ch - > channel_id = = VPIF_CHANNEL3_VIDEO | |
ycmux_mode = = 2 ) {
enable_channel3 ( 1 ) ;
channel3_intr_enable ( 1 ) ;
2012-04-13 14:50:35 +07:00
}
mutex_unlock ( & common - > lock ) ;
}
return 0 ;
}
# endif
2014-05-16 20:33:26 +07:00
static SIMPLE_DEV_PM_OPS ( vpif_pm_ops , vpif_suspend , vpif_resume ) ;
2010-08-30 20:30:36 +07:00
static __refdata struct platform_driver vpif_driver = {
2009-06-09 15:55:37 +07:00
. driver = {
2014-05-16 20:33:22 +07:00
. name = VPIF_DRIVER_NAME ,
2014-05-16 20:33:26 +07:00
. pm = & vpif_pm_ops ,
2009-06-09 15:55:37 +07:00
} ,
. probe = vpif_probe ,
. remove = vpif_remove ,
} ;
2013-06-17 21:20:49 +07:00
module_platform_driver ( vpif_driver ) ;