2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
|
|
|
|
bttv - Bt848 frame grabber driver
|
|
|
|
|
|
|
|
Copyright (C) 1996,97,98 Ralph Metzler <rjkm@thp.uni-koeln.de>
|
2005-11-09 12:37:43 +07:00
|
|
|
& Marcus Metzler <mocm@thp.uni-koeln.de>
|
2005-04-17 05:20:36 +07:00
|
|
|
(c) 1999-2002 Gerd Knorr <kraxel@bytesex.org>
|
|
|
|
|
|
|
|
some v4l2 code lines are taken from Justin's bttv2 driver which is
|
|
|
|
(c) 2000 Justin Schoeman <justin@suntiger.ee.up.ac.za>
|
|
|
|
|
2007-10-26 21:01:08 +07:00
|
|
|
V4L1 removal from:
|
|
|
|
(c) 2005-2006 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
|
|
|
|
|
2007-10-27 02:51:47 +07:00
|
|
|
Fixes to be fully V4L2 compliant by
|
|
|
|
(c) 2006 Mauro Carvalho Chehab <mchehab@infradead.org>
|
|
|
|
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
Cropping and overscan support
|
|
|
|
Copyright (C) 2005, 2006 Michael H. Schimek <mschimek@gmx.at>
|
|
|
|
Sponsored by OPQ Systems AB
|
|
|
|
|
2005-04-17 05:20:36 +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; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
2011-08-22 05:56:48 +07:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/delay.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>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/kdev_t.h>
|
2006-01-10 00:25:20 +07:00
|
|
|
#include "bttvp.h"
|
2006-01-10 00:32:31 +07:00
|
|
|
#include <media/v4l2-common.h>
|
2008-07-20 18:12:02 +07:00
|
|
|
#include <media/v4l2-ioctl.h>
|
2013-02-06 22:42:13 +07:00
|
|
|
#include <media/v4l2-event.h>
|
2015-11-10 21:01:44 +07:00
|
|
|
#include <media/i2c/tvaudio.h>
|
2015-11-14 04:40:07 +07:00
|
|
|
#include <media/drv-intf/msp3400.h>
|
2006-01-10 00:25:20 +07:00
|
|
|
|
2005-07-13 03:58:42 +07:00
|
|
|
#include <linux/dma-mapping.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/byteorder.h>
|
|
|
|
|
2015-11-10 21:01:44 +07:00
|
|
|
#include <media/i2c/saa6588.h>
|
2005-09-10 03:03:39 +07:00
|
|
|
|
[media] Stop using linux/version.h on most video drivers
All the modified drivers didn't have any version increment since
Jan, 1 2011. Several of them didn't have any version increment
for a long time, even having new features and important bug fixes
happening.
As we're now filling the QUERYCAP version with the current Kernel
Release, we don't need to maintain a per-driver version control
anymore. So, let's just use the default.
In order to preserve the Kernel module version history, a
KERNEL_VERSION() macro were added to all modified drivers, and
the extraver number were incremented.
I opted to preserve the per-driver version control to a few
pwc, pvrusb2, s2255, s5p-fimc and sh_vou.
A few drivers are still using the legacy way to handle ioctl's.
So, we can't do such change on them, otherwise, they'll break.
Those are: uvc, et61x251 and sn9c102.
The rationale is that the per-driver version control seems to be
actively maintained on those.
Yet, I think that the better for them would be to just use the
default version numbering, instead of doing that by themselves.
While here, removed a few uneeded include linux/version.h
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2011-06-25 00:45:49 +07:00
|
|
|
#define BTTV_VERSION "0.9.19"
|
2005-09-10 03:03:39 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
unsigned int bttv_num; /* number of Bt848s in use */
|
2009-01-29 07:32:59 +07:00
|
|
|
struct bttv *bttvs[BTTV_MAX];
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2006-01-13 23:10:19 +07:00
|
|
|
unsigned int bttv_debug;
|
2005-04-17 05:20:36 +07:00
|
|
|
unsigned int bttv_verbose = 1;
|
2006-01-13 23:10:19 +07:00
|
|
|
unsigned int bttv_gpio;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* config variables */
|
|
|
|
#ifdef __BIG_ENDIAN
|
|
|
|
static unsigned int bigendian=1;
|
|
|
|
#else
|
2006-01-13 23:10:19 +07:00
|
|
|
static unsigned int bigendian;
|
2005-04-17 05:20:36 +07:00
|
|
|
#endif
|
|
|
|
static unsigned int radio[BTTV_MAX];
|
2006-01-13 23:10:19 +07:00
|
|
|
static unsigned int irq_debug;
|
2005-04-17 05:20:36 +07:00
|
|
|
static unsigned int gbuffers = 8;
|
|
|
|
static unsigned int gbufsize = 0x208000;
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
static unsigned int reset_crop = 1;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-09-07 22:49:59 +07:00
|
|
|
static int video_nr[BTTV_MAX] = { [0 ... (BTTV_MAX-1)] = -1 };
|
|
|
|
static int radio_nr[BTTV_MAX] = { [0 ... (BTTV_MAX-1)] = -1 };
|
|
|
|
static int vbi_nr[BTTV_MAX] = { [0 ... (BTTV_MAX-1)] = -1 };
|
2006-01-13 23:10:19 +07:00
|
|
|
static int debug_latency;
|
2010-02-17 00:22:37 +07:00
|
|
|
static int disable_ir;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2006-01-13 23:10:19 +07:00
|
|
|
static unsigned int fdsr;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* options */
|
2006-01-13 23:10:19 +07:00
|
|
|
static unsigned int combfilter;
|
|
|
|
static unsigned int lumafilter;
|
2005-04-17 05:20:36 +07:00
|
|
|
static unsigned int automute = 1;
|
2006-01-13 23:10:19 +07:00
|
|
|
static unsigned int chroma_agc;
|
2013-02-06 22:40:28 +07:00
|
|
|
static unsigned int agc_crush = 1;
|
2005-04-17 05:20:36 +07:00
|
|
|
static unsigned int whitecrush_upper = 0xCF;
|
|
|
|
static unsigned int whitecrush_lower = 0x7F;
|
2006-01-13 23:10:19 +07:00
|
|
|
static unsigned int vcr_hack;
|
|
|
|
static unsigned int irq_iswitch;
|
2005-06-29 10:45:25 +07:00
|
|
|
static unsigned int uv_ratio = 50;
|
2006-01-13 23:10:19 +07:00
|
|
|
static unsigned int full_luma_range;
|
|
|
|
static unsigned int coring;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* API features (turn on/off stuff for testing) */
|
|
|
|
static unsigned int v4l2 = 1;
|
|
|
|
|
|
|
|
/* insmod args */
|
|
|
|
module_param(bttv_verbose, int, 0644);
|
|
|
|
module_param(bttv_gpio, int, 0644);
|
|
|
|
module_param(bttv_debug, int, 0644);
|
|
|
|
module_param(irq_debug, int, 0644);
|
|
|
|
module_param(debug_latency, int, 0644);
|
2010-02-17 00:22:37 +07:00
|
|
|
module_param(disable_ir, int, 0444);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
module_param(fdsr, int, 0444);
|
|
|
|
module_param(gbuffers, int, 0444);
|
|
|
|
module_param(gbufsize, int, 0444);
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
module_param(reset_crop, int, 0444);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
module_param(v4l2, int, 0644);
|
|
|
|
module_param(bigendian, int, 0644);
|
|
|
|
module_param(irq_iswitch, int, 0644);
|
|
|
|
module_param(combfilter, int, 0444);
|
|
|
|
module_param(lumafilter, int, 0444);
|
|
|
|
module_param(automute, int, 0444);
|
|
|
|
module_param(chroma_agc, int, 0444);
|
2013-02-06 22:40:28 +07:00
|
|
|
module_param(agc_crush, int, 0444);
|
2005-04-17 05:20:36 +07:00
|
|
|
module_param(whitecrush_upper, int, 0444);
|
|
|
|
module_param(whitecrush_lower, int, 0444);
|
|
|
|
module_param(vcr_hack, int, 0444);
|
2005-06-29 10:45:25 +07:00
|
|
|
module_param(uv_ratio, int, 0444);
|
|
|
|
module_param(full_luma_range, int, 0444);
|
|
|
|
module_param(coring, int, 0444);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-09-07 22:49:59 +07:00
|
|
|
module_param_array(radio, int, NULL, 0444);
|
|
|
|
module_param_array(video_nr, int, NULL, 0444);
|
|
|
|
module_param_array(radio_nr, int, NULL, 0444);
|
|
|
|
module_param_array(vbi_nr, int, NULL, 0444);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2013-02-06 22:40:28 +07:00
|
|
|
MODULE_PARM_DESC(radio, "The TV card supports radio, default is 0 (no)");
|
|
|
|
MODULE_PARM_DESC(bigendian, "byte order of the framebuffer, default is native endian");
|
|
|
|
MODULE_PARM_DESC(bttv_verbose, "verbose startup messages, default is 1 (yes)");
|
|
|
|
MODULE_PARM_DESC(bttv_gpio, "log gpio changes, default is 0 (no)");
|
|
|
|
MODULE_PARM_DESC(bttv_debug, "debug messages, default is 0 (no)");
|
|
|
|
MODULE_PARM_DESC(irq_debug, "irq handler debug messages, default is 0 (no)");
|
2010-02-17 00:22:37 +07:00
|
|
|
MODULE_PARM_DESC(disable_ir, "disable infrared remote support");
|
2013-02-06 22:40:28 +07:00
|
|
|
MODULE_PARM_DESC(gbuffers, "number of capture buffers. range 2-32, default 8");
|
|
|
|
MODULE_PARM_DESC(gbufsize, "size of the capture buffers, default is 0x208000");
|
|
|
|
MODULE_PARM_DESC(reset_crop, "reset cropping parameters at open(), default "
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
"is 1 (yes) for compatibility with older applications");
|
2013-02-06 22:40:28 +07:00
|
|
|
MODULE_PARM_DESC(automute, "mute audio on bad/missing video signal, default is 1 (yes)");
|
|
|
|
MODULE_PARM_DESC(chroma_agc, "enables the AGC of chroma signal, default is 0 (no)");
|
|
|
|
MODULE_PARM_DESC(agc_crush, "enables the luminance AGC crush, default is 1 (yes)");
|
|
|
|
MODULE_PARM_DESC(whitecrush_upper, "sets the white crush upper value, default is 207");
|
|
|
|
MODULE_PARM_DESC(whitecrush_lower, "sets the white crush lower value, default is 127");
|
|
|
|
MODULE_PARM_DESC(vcr_hack, "enables the VCR hack (improves synch on poor VCR tapes), default is 0 (no)");
|
|
|
|
MODULE_PARM_DESC(irq_iswitch, "switch inputs in irq handler");
|
|
|
|
MODULE_PARM_DESC(uv_ratio, "ratio between u and v gains, default is 50");
|
|
|
|
MODULE_PARM_DESC(full_luma_range, "use the full luma range, default is 0 (no)");
|
|
|
|
MODULE_PARM_DESC(coring, "set the luma coring level, default is 0 (no)");
|
2008-09-07 22:49:59 +07:00
|
|
|
MODULE_PARM_DESC(video_nr, "video device numbers");
|
|
|
|
MODULE_PARM_DESC(vbi_nr, "vbi device numbers");
|
|
|
|
MODULE_PARM_DESC(radio_nr, "radio device numbers");
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
MODULE_DESCRIPTION("bttv - v4l/v4l2 driver module for bt848/878 based cards");
|
|
|
|
MODULE_AUTHOR("Ralph Metzler & Marcus Metzler & Gerd Knorr");
|
|
|
|
MODULE_LICENSE("GPL");
|
[media] Stop using linux/version.h on most video drivers
All the modified drivers didn't have any version increment since
Jan, 1 2011. Several of them didn't have any version increment
for a long time, even having new features and important bug fixes
happening.
As we're now filling the QUERYCAP version with the current Kernel
Release, we don't need to maintain a per-driver version control
anymore. So, let's just use the default.
In order to preserve the Kernel module version history, a
KERNEL_VERSION() macro were added to all modified drivers, and
the extraver number were incremented.
I opted to preserve the per-driver version control to a few
pwc, pvrusb2, s2255, s5p-fimc and sh_vou.
A few drivers are still using the legacy way to handle ioctl's.
So, we can't do such change on them, otherwise, they'll break.
Those are: uvc, et61x251 and sn9c102.
The rationale is that the per-driver version control seems to be
actively maintained on those.
Yet, I think that the better for them would be to just use the
default version numbering, instead of doing that by themselves.
While here, removed a few uneeded include linux/version.h
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2011-06-25 00:45:49 +07:00
|
|
|
MODULE_VERSION(BTTV_VERSION);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2013-02-06 22:40:28 +07:00
|
|
|
#define V4L2_CID_PRIVATE_COMBFILTER (V4L2_CID_USER_BTTV_BASE + 0)
|
|
|
|
#define V4L2_CID_PRIVATE_AUTOMUTE (V4L2_CID_USER_BTTV_BASE + 1)
|
|
|
|
#define V4L2_CID_PRIVATE_LUMAFILTER (V4L2_CID_USER_BTTV_BASE + 2)
|
|
|
|
#define V4L2_CID_PRIVATE_AGC_CRUSH (V4L2_CID_USER_BTTV_BASE + 3)
|
|
|
|
#define V4L2_CID_PRIVATE_VCR_HACK (V4L2_CID_USER_BTTV_BASE + 4)
|
|
|
|
#define V4L2_CID_PRIVATE_WHITECRUSH_LOWER (V4L2_CID_USER_BTTV_BASE + 5)
|
|
|
|
#define V4L2_CID_PRIVATE_WHITECRUSH_UPPER (V4L2_CID_USER_BTTV_BASE + 6)
|
|
|
|
#define V4L2_CID_PRIVATE_UV_RATIO (V4L2_CID_USER_BTTV_BASE + 7)
|
|
|
|
#define V4L2_CID_PRIVATE_FULL_LUMA_RANGE (V4L2_CID_USER_BTTV_BASE + 8)
|
|
|
|
#define V4L2_CID_PRIVATE_CORING (V4L2_CID_USER_BTTV_BASE + 9)
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* ----------------------------------------------------------------------- */
|
|
|
|
/* sysfs */
|
|
|
|
|
2007-10-09 02:26:13 +07:00
|
|
|
static ssize_t show_card(struct device *cd,
|
|
|
|
struct device_attribute *attr, char *buf)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2008-07-20 16:35:02 +07:00
|
|
|
struct video_device *vfd = container_of(cd, struct video_device, dev);
|
2009-03-14 22:36:54 +07:00
|
|
|
struct bttv *btv = video_get_drvdata(vfd);
|
2005-04-17 05:20:36 +07:00
|
|
|
return sprintf(buf, "%d\n", btv ? btv->c.type : UNSET);
|
|
|
|
}
|
2007-10-09 02:26:13 +07:00
|
|
|
static DEVICE_ATTR(card, S_IRUGO, show_card, NULL);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-03-25 01:23:50 +07:00
|
|
|
/* ----------------------------------------------------------------------- */
|
|
|
|
/* dvb auto-load setup */
|
|
|
|
#if defined(CONFIG_MODULES) && defined(MODULE)
|
|
|
|
static void request_module_async(struct work_struct *work)
|
|
|
|
{
|
|
|
|
request_module("dvb-bt8xx");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void request_modules(struct bttv *dev)
|
|
|
|
{
|
|
|
|
INIT_WORK(&dev->request_module_wk, request_module_async);
|
|
|
|
schedule_work(&dev->request_module_wk);
|
|
|
|
}
|
2010-12-24 22:14:20 +07:00
|
|
|
|
|
|
|
static void flush_request_modules(struct bttv *dev)
|
|
|
|
{
|
2012-08-21 04:51:24 +07:00
|
|
|
flush_work(&dev->request_module_wk);
|
2010-12-24 22:14:20 +07:00
|
|
|
}
|
2007-03-25 01:23:50 +07:00
|
|
|
#else
|
|
|
|
#define request_modules(dev)
|
2012-10-28 02:33:41 +07:00
|
|
|
#define flush_request_modules(dev) do {} while(0)
|
2007-03-25 01:23:50 +07:00
|
|
|
#endif /* CONFIG_MODULES */
|
|
|
|
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* ----------------------------------------------------------------------- */
|
|
|
|
/* static data */
|
|
|
|
|
|
|
|
/* special timing tables from conexant... */
|
|
|
|
static u8 SRAM_Table[][60] =
|
|
|
|
{
|
|
|
|
/* PAL digital input over GPIO[7:0] */
|
|
|
|
{
|
|
|
|
45, // 45 bytes following
|
|
|
|
0x36,0x11,0x01,0x00,0x90,0x02,0x05,0x10,0x04,0x16,
|
|
|
|
0x12,0x05,0x11,0x00,0x04,0x12,0xC0,0x00,0x31,0x00,
|
|
|
|
0x06,0x51,0x08,0x03,0x89,0x08,0x07,0xC0,0x44,0x00,
|
|
|
|
0x81,0x01,0x01,0xA9,0x0D,0x02,0x02,0x50,0x03,0x37,
|
|
|
|
0x37,0x00,0xAF,0x21,0x00
|
|
|
|
},
|
|
|
|
/* NTSC digital input over GPIO[7:0] */
|
|
|
|
{
|
|
|
|
51, // 51 bytes following
|
|
|
|
0x0C,0xC0,0x00,0x00,0x90,0x02,0x03,0x10,0x03,0x06,
|
|
|
|
0x10,0x04,0x12,0x12,0x05,0x02,0x13,0x04,0x19,0x00,
|
|
|
|
0x04,0x39,0x00,0x06,0x59,0x08,0x03,0x83,0x08,0x07,
|
|
|
|
0x03,0x50,0x00,0xC0,0x40,0x00,0x86,0x01,0x01,0xA6,
|
|
|
|
0x0D,0x02,0x03,0x11,0x01,0x05,0x37,0x00,0xAC,0x21,
|
|
|
|
0x00,
|
|
|
|
},
|
|
|
|
// TGB_NTSC392 // quartzsight
|
|
|
|
// This table has been modified to be used for Fusion Rev D
|
|
|
|
{
|
|
|
|
0x2A, // size of table = 42
|
|
|
|
0x06, 0x08, 0x04, 0x0a, 0xc0, 0x00, 0x18, 0x08, 0x03, 0x24,
|
|
|
|
0x08, 0x07, 0x02, 0x90, 0x02, 0x08, 0x10, 0x04, 0x0c, 0x10,
|
|
|
|
0x05, 0x2c, 0x11, 0x04, 0x55, 0x48, 0x00, 0x05, 0x50, 0x00,
|
|
|
|
0xbf, 0x0c, 0x02, 0x2f, 0x3d, 0x00, 0x2f, 0x3f, 0x00, 0xc3,
|
|
|
|
0x20, 0x00
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
/* minhdelayx1 first video pixel we can capture on a line and
|
|
|
|
hdelayx1 start of active video, both relative to rising edge of
|
|
|
|
/HRESET pulse (0H) in 1 / fCLKx1.
|
|
|
|
swidth width of active video and
|
|
|
|
totalwidth total line width, both in 1 / fCLKx1.
|
|
|
|
sqwidth total line width in square pixels.
|
|
|
|
vdelay start of active video in 2 * field lines relative to
|
|
|
|
trailing edge of /VRESET pulse (VDELAY register).
|
|
|
|
sheight height of active video in 2 * field lines.
|
[media] [REGRESSION] bt8xx: Fix too large height in cropcap
Since commit a1fd287780c8e91fed4957b30c757b0c93021162:
"[media] bttv-driver: fix two warnings"
cropcap.defrect.height and cropcap.bounds.height for the PAL entry are 32
resp 30 pixels too large, if a userspace app (ie xawtv) actually tries to use
the full advertised height, the resulting image is broken in ways only a
screenshot can describe.
The cause of this is the fix for this warning:
drivers/media/pci/bt8xx/bttv-driver.c:308:3: warning: initialized field overwritten [-Woverride-init]
In this chunk of the commit:
@@ -301,11 +301,10 @@ const struct bttv_tvnorm bttv_tvnorms[] = {
/* totalwidth */ 1135,
/* sqwidth */ 944,
/* vdelay */ 0x20,
- /* sheight */ 576,
- /* videostart0 */ 23)
/* bt878 (and bt848?) can capture another
line below active video. */
- .cropcap.bounds.height = (576 + 2) + 0x20 - 2,
+ /* sheight */ (576 + 2) + 0x20 - 2,
+ /* videostart0 */ 23)
},{
.v4l2_id = V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_KR,
.name = "NTSC",
Which replaces the overriding of cropcap.bounds.height initialization outside
of the CROPCAP macro (which also initializes it), with passing a
different sheight value to the CROPCAP macro.
There are 2 problems with this warning fix:
1) The sheight value is used twice in the CROPCAP macro, and the old code
only changed one resulting value.
2) The old code increased the .cropcap.bounds.height value (and did not
touch the .cropcap.defrect.height value at all) by 2, where as the fixed
code increases it by 32, as the fixed code passes (576 + 2) + 0x20 - 2
to the CROPCAP macro, but the + 0x20 - 2 is already done by the macro so
now is done twice for .cropcap.bounds.height, and also is applied to
.cropcap.defrect.height where it should not be applied at all.
This patch fixes this by adding an extraheight parameter to the CROPCAP entry
and using it for the PAL entry.
Cc: stable@kernel.org # For Kernel 3.8
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-03-26 00:45:54 +07:00
|
|
|
extraheight Added to sheight for cropcap.bounds.height only
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
videostart0 ITU-R frame line number of the line corresponding
|
|
|
|
to vdelay in the first field. */
|
|
|
|
#define CROPCAP(minhdelayx1, hdelayx1, swidth, totalwidth, sqwidth, \
|
[media] [REGRESSION] bt8xx: Fix too large height in cropcap
Since commit a1fd287780c8e91fed4957b30c757b0c93021162:
"[media] bttv-driver: fix two warnings"
cropcap.defrect.height and cropcap.bounds.height for the PAL entry are 32
resp 30 pixels too large, if a userspace app (ie xawtv) actually tries to use
the full advertised height, the resulting image is broken in ways only a
screenshot can describe.
The cause of this is the fix for this warning:
drivers/media/pci/bt8xx/bttv-driver.c:308:3: warning: initialized field overwritten [-Woverride-init]
In this chunk of the commit:
@@ -301,11 +301,10 @@ const struct bttv_tvnorm bttv_tvnorms[] = {
/* totalwidth */ 1135,
/* sqwidth */ 944,
/* vdelay */ 0x20,
- /* sheight */ 576,
- /* videostart0 */ 23)
/* bt878 (and bt848?) can capture another
line below active video. */
- .cropcap.bounds.height = (576 + 2) + 0x20 - 2,
+ /* sheight */ (576 + 2) + 0x20 - 2,
+ /* videostart0 */ 23)
},{
.v4l2_id = V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_KR,
.name = "NTSC",
Which replaces the overriding of cropcap.bounds.height initialization outside
of the CROPCAP macro (which also initializes it), with passing a
different sheight value to the CROPCAP macro.
There are 2 problems with this warning fix:
1) The sheight value is used twice in the CROPCAP macro, and the old code
only changed one resulting value.
2) The old code increased the .cropcap.bounds.height value (and did not
touch the .cropcap.defrect.height value at all) by 2, where as the fixed
code increases it by 32, as the fixed code passes (576 + 2) + 0x20 - 2
to the CROPCAP macro, but the + 0x20 - 2 is already done by the macro so
now is done twice for .cropcap.bounds.height, and also is applied to
.cropcap.defrect.height where it should not be applied at all.
This patch fixes this by adding an extraheight parameter to the CROPCAP entry
and using it for the PAL entry.
Cc: stable@kernel.org # For Kernel 3.8
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-03-26 00:45:54 +07:00
|
|
|
vdelay, sheight, extraheight, videostart0) \
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
.cropcap.bounds.left = minhdelayx1, \
|
|
|
|
/* * 2 because vertically we count field lines times two, */ \
|
|
|
|
/* e.g. 23 * 2 to 23 * 2 + 576 in PAL-BGHI defrect. */ \
|
|
|
|
.cropcap.bounds.top = (videostart0) * 2 - (vdelay) + MIN_VDELAY, \
|
|
|
|
/* 4 is a safety margin at the end of the line. */ \
|
|
|
|
.cropcap.bounds.width = (totalwidth) - (minhdelayx1) - 4, \
|
[media] [REGRESSION] bt8xx: Fix too large height in cropcap
Since commit a1fd287780c8e91fed4957b30c757b0c93021162:
"[media] bttv-driver: fix two warnings"
cropcap.defrect.height and cropcap.bounds.height for the PAL entry are 32
resp 30 pixels too large, if a userspace app (ie xawtv) actually tries to use
the full advertised height, the resulting image is broken in ways only a
screenshot can describe.
The cause of this is the fix for this warning:
drivers/media/pci/bt8xx/bttv-driver.c:308:3: warning: initialized field overwritten [-Woverride-init]
In this chunk of the commit:
@@ -301,11 +301,10 @@ const struct bttv_tvnorm bttv_tvnorms[] = {
/* totalwidth */ 1135,
/* sqwidth */ 944,
/* vdelay */ 0x20,
- /* sheight */ 576,
- /* videostart0 */ 23)
/* bt878 (and bt848?) can capture another
line below active video. */
- .cropcap.bounds.height = (576 + 2) + 0x20 - 2,
+ /* sheight */ (576 + 2) + 0x20 - 2,
+ /* videostart0 */ 23)
},{
.v4l2_id = V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_KR,
.name = "NTSC",
Which replaces the overriding of cropcap.bounds.height initialization outside
of the CROPCAP macro (which also initializes it), with passing a
different sheight value to the CROPCAP macro.
There are 2 problems with this warning fix:
1) The sheight value is used twice in the CROPCAP macro, and the old code
only changed one resulting value.
2) The old code increased the .cropcap.bounds.height value (and did not
touch the .cropcap.defrect.height value at all) by 2, where as the fixed
code increases it by 32, as the fixed code passes (576 + 2) + 0x20 - 2
to the CROPCAP macro, but the + 0x20 - 2 is already done by the macro so
now is done twice for .cropcap.bounds.height, and also is applied to
.cropcap.defrect.height where it should not be applied at all.
This patch fixes this by adding an extraheight parameter to the CROPCAP entry
and using it for the PAL entry.
Cc: stable@kernel.org # For Kernel 3.8
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-03-26 00:45:54 +07:00
|
|
|
.cropcap.bounds.height = (sheight) + (extraheight) + (vdelay) - \
|
|
|
|
MIN_VDELAY, \
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
.cropcap.defrect.left = hdelayx1, \
|
|
|
|
.cropcap.defrect.top = (videostart0) * 2, \
|
|
|
|
.cropcap.defrect.width = swidth, \
|
|
|
|
.cropcap.defrect.height = sheight, \
|
|
|
|
.cropcap.pixelaspect.numerator = totalwidth, \
|
|
|
|
.cropcap.pixelaspect.denominator = sqwidth,
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
const struct bttv_tvnorm bttv_tvnorms[] = {
|
|
|
|
/* PAL-BDGHI */
|
2005-11-09 12:37:43 +07:00
|
|
|
/* max. active video is actually 922, but 924 is divisible by 4 and 3! */
|
|
|
|
/* actually, max active PAL with HSCALE=0 is 948, NTSC is 768 - nil */
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
.v4l2_id = V4L2_STD_PAL,
|
|
|
|
.name = "PAL",
|
|
|
|
.Fsc = 35468950,
|
|
|
|
.swidth = 924,
|
|
|
|
.sheight = 576,
|
|
|
|
.totalwidth = 1135,
|
|
|
|
.adelay = 0x7f,
|
|
|
|
.bdelay = 0x72,
|
|
|
|
.iform = (BT848_IFORM_PAL_BDGHI|BT848_IFORM_XT1),
|
|
|
|
.scaledtwidth = 1135,
|
|
|
|
.hdelayx1 = 186,
|
|
|
|
.hactivex1 = 924,
|
|
|
|
.vdelay = 0x20,
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
.vbipack = 255, /* min (2048 / 4, 0x1ff) & 0xff */
|
2005-04-17 05:20:36 +07:00
|
|
|
.sram = 0,
|
2006-01-10 00:25:27 +07:00
|
|
|
/* ITU-R frame line number of the first VBI line
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
we can capture, of the first and second field.
|
|
|
|
The last line is determined by cropcap.bounds. */
|
|
|
|
.vbistart = { 7, 320 },
|
|
|
|
CROPCAP(/* minhdelayx1 */ 68,
|
|
|
|
/* hdelayx1 */ 186,
|
|
|
|
/* Should be (768 * 1135 + 944 / 2) / 944.
|
|
|
|
cropcap.defrect is used for image width
|
|
|
|
checks, so we keep the old value 924. */
|
|
|
|
/* swidth */ 924,
|
|
|
|
/* totalwidth */ 1135,
|
|
|
|
/* sqwidth */ 944,
|
|
|
|
/* vdelay */ 0x20,
|
[media] [REGRESSION] bt8xx: Fix too large height in cropcap
Since commit a1fd287780c8e91fed4957b30c757b0c93021162:
"[media] bttv-driver: fix two warnings"
cropcap.defrect.height and cropcap.bounds.height for the PAL entry are 32
resp 30 pixels too large, if a userspace app (ie xawtv) actually tries to use
the full advertised height, the resulting image is broken in ways only a
screenshot can describe.
The cause of this is the fix for this warning:
drivers/media/pci/bt8xx/bttv-driver.c:308:3: warning: initialized field overwritten [-Woverride-init]
In this chunk of the commit:
@@ -301,11 +301,10 @@ const struct bttv_tvnorm bttv_tvnorms[] = {
/* totalwidth */ 1135,
/* sqwidth */ 944,
/* vdelay */ 0x20,
- /* sheight */ 576,
- /* videostart0 */ 23)
/* bt878 (and bt848?) can capture another
line below active video. */
- .cropcap.bounds.height = (576 + 2) + 0x20 - 2,
+ /* sheight */ (576 + 2) + 0x20 - 2,
+ /* videostart0 */ 23)
},{
.v4l2_id = V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_KR,
.name = "NTSC",
Which replaces the overriding of cropcap.bounds.height initialization outside
of the CROPCAP macro (which also initializes it), with passing a
different sheight value to the CROPCAP macro.
There are 2 problems with this warning fix:
1) The sheight value is used twice in the CROPCAP macro, and the old code
only changed one resulting value.
2) The old code increased the .cropcap.bounds.height value (and did not
touch the .cropcap.defrect.height value at all) by 2, where as the fixed
code increases it by 32, as the fixed code passes (576 + 2) + 0x20 - 2
to the CROPCAP macro, but the + 0x20 - 2 is already done by the macro so
now is done twice for .cropcap.bounds.height, and also is applied to
.cropcap.defrect.height where it should not be applied at all.
This patch fixes this by adding an extraheight parameter to the CROPCAP entry
and using it for the PAL entry.
Cc: stable@kernel.org # For Kernel 3.8
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-03-26 00:45:54 +07:00
|
|
|
/* sheight */ 576,
|
|
|
|
/* bt878 (and bt848?) can capture another
|
|
|
|
line below active video. */
|
|
|
|
/* extraheight */ 2,
|
2012-10-28 02:33:41 +07:00
|
|
|
/* videostart0 */ 23)
|
2005-04-17 05:20:36 +07:00
|
|
|
},{
|
2006-02-07 15:48:40 +07:00
|
|
|
.v4l2_id = V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_KR,
|
2005-04-17 05:20:36 +07:00
|
|
|
.name = "NTSC",
|
|
|
|
.Fsc = 28636363,
|
|
|
|
.swidth = 768,
|
|
|
|
.sheight = 480,
|
|
|
|
.totalwidth = 910,
|
|
|
|
.adelay = 0x68,
|
|
|
|
.bdelay = 0x5d,
|
|
|
|
.iform = (BT848_IFORM_NTSC|BT848_IFORM_XT0),
|
|
|
|
.scaledtwidth = 910,
|
|
|
|
.hdelayx1 = 128,
|
|
|
|
.hactivex1 = 910,
|
|
|
|
.vdelay = 0x1a,
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
.vbipack = 144, /* min (1600 / 4, 0x1ff) & 0xff */
|
2005-04-17 05:20:36 +07:00
|
|
|
.sram = 1,
|
2006-01-10 00:25:27 +07:00
|
|
|
.vbistart = { 10, 273 },
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
CROPCAP(/* minhdelayx1 */ 68,
|
|
|
|
/* hdelayx1 */ 128,
|
|
|
|
/* Should be (640 * 910 + 780 / 2) / 780? */
|
|
|
|
/* swidth */ 768,
|
|
|
|
/* totalwidth */ 910,
|
|
|
|
/* sqwidth */ 780,
|
|
|
|
/* vdelay */ 0x1a,
|
|
|
|
/* sheight */ 480,
|
[media] [REGRESSION] bt8xx: Fix too large height in cropcap
Since commit a1fd287780c8e91fed4957b30c757b0c93021162:
"[media] bttv-driver: fix two warnings"
cropcap.defrect.height and cropcap.bounds.height for the PAL entry are 32
resp 30 pixels too large, if a userspace app (ie xawtv) actually tries to use
the full advertised height, the resulting image is broken in ways only a
screenshot can describe.
The cause of this is the fix for this warning:
drivers/media/pci/bt8xx/bttv-driver.c:308:3: warning: initialized field overwritten [-Woverride-init]
In this chunk of the commit:
@@ -301,11 +301,10 @@ const struct bttv_tvnorm bttv_tvnorms[] = {
/* totalwidth */ 1135,
/* sqwidth */ 944,
/* vdelay */ 0x20,
- /* sheight */ 576,
- /* videostart0 */ 23)
/* bt878 (and bt848?) can capture another
line below active video. */
- .cropcap.bounds.height = (576 + 2) + 0x20 - 2,
+ /* sheight */ (576 + 2) + 0x20 - 2,
+ /* videostart0 */ 23)
},{
.v4l2_id = V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_KR,
.name = "NTSC",
Which replaces the overriding of cropcap.bounds.height initialization outside
of the CROPCAP macro (which also initializes it), with passing a
different sheight value to the CROPCAP macro.
There are 2 problems with this warning fix:
1) The sheight value is used twice in the CROPCAP macro, and the old code
only changed one resulting value.
2) The old code increased the .cropcap.bounds.height value (and did not
touch the .cropcap.defrect.height value at all) by 2, where as the fixed
code increases it by 32, as the fixed code passes (576 + 2) + 0x20 - 2
to the CROPCAP macro, but the + 0x20 - 2 is already done by the macro so
now is done twice for .cropcap.bounds.height, and also is applied to
.cropcap.defrect.height where it should not be applied at all.
This patch fixes this by adding an extraheight parameter to the CROPCAP entry
and using it for the PAL entry.
Cc: stable@kernel.org # For Kernel 3.8
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-03-26 00:45:54 +07:00
|
|
|
/* extraheight */ 0,
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
/* videostart0 */ 23)
|
2005-04-17 05:20:36 +07:00
|
|
|
},{
|
|
|
|
.v4l2_id = V4L2_STD_SECAM,
|
|
|
|
.name = "SECAM",
|
|
|
|
.Fsc = 35468950,
|
|
|
|
.swidth = 924,
|
|
|
|
.sheight = 576,
|
|
|
|
.totalwidth = 1135,
|
|
|
|
.adelay = 0x7f,
|
|
|
|
.bdelay = 0xb0,
|
|
|
|
.iform = (BT848_IFORM_SECAM|BT848_IFORM_XT1),
|
|
|
|
.scaledtwidth = 1135,
|
|
|
|
.hdelayx1 = 186,
|
|
|
|
.hactivex1 = 922,
|
|
|
|
.vdelay = 0x20,
|
|
|
|
.vbipack = 255,
|
|
|
|
.sram = 0, /* like PAL, correct? */
|
2006-01-10 00:25:27 +07:00
|
|
|
.vbistart = { 7, 320 },
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
CROPCAP(/* minhdelayx1 */ 68,
|
|
|
|
/* hdelayx1 */ 186,
|
|
|
|
/* swidth */ 924,
|
|
|
|
/* totalwidth */ 1135,
|
|
|
|
/* sqwidth */ 944,
|
|
|
|
/* vdelay */ 0x20,
|
|
|
|
/* sheight */ 576,
|
[media] [REGRESSION] bt8xx: Fix too large height in cropcap
Since commit a1fd287780c8e91fed4957b30c757b0c93021162:
"[media] bttv-driver: fix two warnings"
cropcap.defrect.height and cropcap.bounds.height for the PAL entry are 32
resp 30 pixels too large, if a userspace app (ie xawtv) actually tries to use
the full advertised height, the resulting image is broken in ways only a
screenshot can describe.
The cause of this is the fix for this warning:
drivers/media/pci/bt8xx/bttv-driver.c:308:3: warning: initialized field overwritten [-Woverride-init]
In this chunk of the commit:
@@ -301,11 +301,10 @@ const struct bttv_tvnorm bttv_tvnorms[] = {
/* totalwidth */ 1135,
/* sqwidth */ 944,
/* vdelay */ 0x20,
- /* sheight */ 576,
- /* videostart0 */ 23)
/* bt878 (and bt848?) can capture another
line below active video. */
- .cropcap.bounds.height = (576 + 2) + 0x20 - 2,
+ /* sheight */ (576 + 2) + 0x20 - 2,
+ /* videostart0 */ 23)
},{
.v4l2_id = V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_KR,
.name = "NTSC",
Which replaces the overriding of cropcap.bounds.height initialization outside
of the CROPCAP macro (which also initializes it), with passing a
different sheight value to the CROPCAP macro.
There are 2 problems with this warning fix:
1) The sheight value is used twice in the CROPCAP macro, and the old code
only changed one resulting value.
2) The old code increased the .cropcap.bounds.height value (and did not
touch the .cropcap.defrect.height value at all) by 2, where as the fixed
code increases it by 32, as the fixed code passes (576 + 2) + 0x20 - 2
to the CROPCAP macro, but the + 0x20 - 2 is already done by the macro so
now is done twice for .cropcap.bounds.height, and also is applied to
.cropcap.defrect.height where it should not be applied at all.
This patch fixes this by adding an extraheight parameter to the CROPCAP entry
and using it for the PAL entry.
Cc: stable@kernel.org # For Kernel 3.8
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-03-26 00:45:54 +07:00
|
|
|
/* extraheight */ 0,
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
/* videostart0 */ 23)
|
2005-04-17 05:20:36 +07:00
|
|
|
},{
|
|
|
|
.v4l2_id = V4L2_STD_PAL_Nc,
|
|
|
|
.name = "PAL-Nc",
|
|
|
|
.Fsc = 28636363,
|
|
|
|
.swidth = 640,
|
|
|
|
.sheight = 576,
|
|
|
|
.totalwidth = 910,
|
|
|
|
.adelay = 0x68,
|
|
|
|
.bdelay = 0x5d,
|
|
|
|
.iform = (BT848_IFORM_PAL_NC|BT848_IFORM_XT0),
|
|
|
|
.scaledtwidth = 780,
|
|
|
|
.hdelayx1 = 130,
|
|
|
|
.hactivex1 = 734,
|
|
|
|
.vdelay = 0x1a,
|
|
|
|
.vbipack = 144,
|
|
|
|
.sram = -1,
|
2006-01-10 00:25:27 +07:00
|
|
|
.vbistart = { 7, 320 },
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
CROPCAP(/* minhdelayx1 */ 68,
|
|
|
|
/* hdelayx1 */ 130,
|
|
|
|
/* swidth */ (640 * 910 + 780 / 2) / 780,
|
|
|
|
/* totalwidth */ 910,
|
|
|
|
/* sqwidth */ 780,
|
|
|
|
/* vdelay */ 0x1a,
|
|
|
|
/* sheight */ 576,
|
[media] [REGRESSION] bt8xx: Fix too large height in cropcap
Since commit a1fd287780c8e91fed4957b30c757b0c93021162:
"[media] bttv-driver: fix two warnings"
cropcap.defrect.height and cropcap.bounds.height for the PAL entry are 32
resp 30 pixels too large, if a userspace app (ie xawtv) actually tries to use
the full advertised height, the resulting image is broken in ways only a
screenshot can describe.
The cause of this is the fix for this warning:
drivers/media/pci/bt8xx/bttv-driver.c:308:3: warning: initialized field overwritten [-Woverride-init]
In this chunk of the commit:
@@ -301,11 +301,10 @@ const struct bttv_tvnorm bttv_tvnorms[] = {
/* totalwidth */ 1135,
/* sqwidth */ 944,
/* vdelay */ 0x20,
- /* sheight */ 576,
- /* videostart0 */ 23)
/* bt878 (and bt848?) can capture another
line below active video. */
- .cropcap.bounds.height = (576 + 2) + 0x20 - 2,
+ /* sheight */ (576 + 2) + 0x20 - 2,
+ /* videostart0 */ 23)
},{
.v4l2_id = V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_KR,
.name = "NTSC",
Which replaces the overriding of cropcap.bounds.height initialization outside
of the CROPCAP macro (which also initializes it), with passing a
different sheight value to the CROPCAP macro.
There are 2 problems with this warning fix:
1) The sheight value is used twice in the CROPCAP macro, and the old code
only changed one resulting value.
2) The old code increased the .cropcap.bounds.height value (and did not
touch the .cropcap.defrect.height value at all) by 2, where as the fixed
code increases it by 32, as the fixed code passes (576 + 2) + 0x20 - 2
to the CROPCAP macro, but the + 0x20 - 2 is already done by the macro so
now is done twice for .cropcap.bounds.height, and also is applied to
.cropcap.defrect.height where it should not be applied at all.
This patch fixes this by adding an extraheight parameter to the CROPCAP entry
and using it for the PAL entry.
Cc: stable@kernel.org # For Kernel 3.8
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-03-26 00:45:54 +07:00
|
|
|
/* extraheight */ 0,
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
/* videostart0 */ 23)
|
2005-04-17 05:20:36 +07:00
|
|
|
},{
|
|
|
|
.v4l2_id = V4L2_STD_PAL_M,
|
|
|
|
.name = "PAL-M",
|
|
|
|
.Fsc = 28636363,
|
|
|
|
.swidth = 640,
|
|
|
|
.sheight = 480,
|
|
|
|
.totalwidth = 910,
|
|
|
|
.adelay = 0x68,
|
|
|
|
.bdelay = 0x5d,
|
|
|
|
.iform = (BT848_IFORM_PAL_M|BT848_IFORM_XT0),
|
|
|
|
.scaledtwidth = 780,
|
|
|
|
.hdelayx1 = 135,
|
|
|
|
.hactivex1 = 754,
|
|
|
|
.vdelay = 0x1a,
|
|
|
|
.vbipack = 144,
|
|
|
|
.sram = -1,
|
2006-01-10 00:25:27 +07:00
|
|
|
.vbistart = { 10, 273 },
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
CROPCAP(/* minhdelayx1 */ 68,
|
|
|
|
/* hdelayx1 */ 135,
|
|
|
|
/* swidth */ (640 * 910 + 780 / 2) / 780,
|
|
|
|
/* totalwidth */ 910,
|
|
|
|
/* sqwidth */ 780,
|
|
|
|
/* vdelay */ 0x1a,
|
|
|
|
/* sheight */ 480,
|
[media] [REGRESSION] bt8xx: Fix too large height in cropcap
Since commit a1fd287780c8e91fed4957b30c757b0c93021162:
"[media] bttv-driver: fix two warnings"
cropcap.defrect.height and cropcap.bounds.height for the PAL entry are 32
resp 30 pixels too large, if a userspace app (ie xawtv) actually tries to use
the full advertised height, the resulting image is broken in ways only a
screenshot can describe.
The cause of this is the fix for this warning:
drivers/media/pci/bt8xx/bttv-driver.c:308:3: warning: initialized field overwritten [-Woverride-init]
In this chunk of the commit:
@@ -301,11 +301,10 @@ const struct bttv_tvnorm bttv_tvnorms[] = {
/* totalwidth */ 1135,
/* sqwidth */ 944,
/* vdelay */ 0x20,
- /* sheight */ 576,
- /* videostart0 */ 23)
/* bt878 (and bt848?) can capture another
line below active video. */
- .cropcap.bounds.height = (576 + 2) + 0x20 - 2,
+ /* sheight */ (576 + 2) + 0x20 - 2,
+ /* videostart0 */ 23)
},{
.v4l2_id = V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_KR,
.name = "NTSC",
Which replaces the overriding of cropcap.bounds.height initialization outside
of the CROPCAP macro (which also initializes it), with passing a
different sheight value to the CROPCAP macro.
There are 2 problems with this warning fix:
1) The sheight value is used twice in the CROPCAP macro, and the old code
only changed one resulting value.
2) The old code increased the .cropcap.bounds.height value (and did not
touch the .cropcap.defrect.height value at all) by 2, where as the fixed
code increases it by 32, as the fixed code passes (576 + 2) + 0x20 - 2
to the CROPCAP macro, but the + 0x20 - 2 is already done by the macro so
now is done twice for .cropcap.bounds.height, and also is applied to
.cropcap.defrect.height where it should not be applied at all.
This patch fixes this by adding an extraheight parameter to the CROPCAP entry
and using it for the PAL entry.
Cc: stable@kernel.org # For Kernel 3.8
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-03-26 00:45:54 +07:00
|
|
|
/* extraheight */ 0,
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
/* videostart0 */ 23)
|
2005-04-17 05:20:36 +07:00
|
|
|
},{
|
|
|
|
.v4l2_id = V4L2_STD_PAL_N,
|
|
|
|
.name = "PAL-N",
|
|
|
|
.Fsc = 35468950,
|
|
|
|
.swidth = 768,
|
|
|
|
.sheight = 576,
|
|
|
|
.totalwidth = 1135,
|
|
|
|
.adelay = 0x7f,
|
|
|
|
.bdelay = 0x72,
|
|
|
|
.iform = (BT848_IFORM_PAL_N|BT848_IFORM_XT1),
|
|
|
|
.scaledtwidth = 944,
|
|
|
|
.hdelayx1 = 186,
|
|
|
|
.hactivex1 = 922,
|
|
|
|
.vdelay = 0x20,
|
|
|
|
.vbipack = 144,
|
|
|
|
.sram = -1,
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
.vbistart = { 7, 320 },
|
|
|
|
CROPCAP(/* minhdelayx1 */ 68,
|
|
|
|
/* hdelayx1 */ 186,
|
|
|
|
/* swidth */ (768 * 1135 + 944 / 2) / 944,
|
|
|
|
/* totalwidth */ 1135,
|
|
|
|
/* sqwidth */ 944,
|
|
|
|
/* vdelay */ 0x20,
|
|
|
|
/* sheight */ 576,
|
[media] [REGRESSION] bt8xx: Fix too large height in cropcap
Since commit a1fd287780c8e91fed4957b30c757b0c93021162:
"[media] bttv-driver: fix two warnings"
cropcap.defrect.height and cropcap.bounds.height for the PAL entry are 32
resp 30 pixels too large, if a userspace app (ie xawtv) actually tries to use
the full advertised height, the resulting image is broken in ways only a
screenshot can describe.
The cause of this is the fix for this warning:
drivers/media/pci/bt8xx/bttv-driver.c:308:3: warning: initialized field overwritten [-Woverride-init]
In this chunk of the commit:
@@ -301,11 +301,10 @@ const struct bttv_tvnorm bttv_tvnorms[] = {
/* totalwidth */ 1135,
/* sqwidth */ 944,
/* vdelay */ 0x20,
- /* sheight */ 576,
- /* videostart0 */ 23)
/* bt878 (and bt848?) can capture another
line below active video. */
- .cropcap.bounds.height = (576 + 2) + 0x20 - 2,
+ /* sheight */ (576 + 2) + 0x20 - 2,
+ /* videostart0 */ 23)
},{
.v4l2_id = V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_KR,
.name = "NTSC",
Which replaces the overriding of cropcap.bounds.height initialization outside
of the CROPCAP macro (which also initializes it), with passing a
different sheight value to the CROPCAP macro.
There are 2 problems with this warning fix:
1) The sheight value is used twice in the CROPCAP macro, and the old code
only changed one resulting value.
2) The old code increased the .cropcap.bounds.height value (and did not
touch the .cropcap.defrect.height value at all) by 2, where as the fixed
code increases it by 32, as the fixed code passes (576 + 2) + 0x20 - 2
to the CROPCAP macro, but the + 0x20 - 2 is already done by the macro so
now is done twice for .cropcap.bounds.height, and also is applied to
.cropcap.defrect.height where it should not be applied at all.
This patch fixes this by adding an extraheight parameter to the CROPCAP entry
and using it for the PAL entry.
Cc: stable@kernel.org # For Kernel 3.8
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-03-26 00:45:54 +07:00
|
|
|
/* extraheight */ 0,
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
/* videostart0 */ 23)
|
2005-04-17 05:20:36 +07:00
|
|
|
},{
|
|
|
|
.v4l2_id = V4L2_STD_NTSC_M_JP,
|
|
|
|
.name = "NTSC-JP",
|
|
|
|
.Fsc = 28636363,
|
|
|
|
.swidth = 640,
|
|
|
|
.sheight = 480,
|
|
|
|
.totalwidth = 910,
|
|
|
|
.adelay = 0x68,
|
|
|
|
.bdelay = 0x5d,
|
|
|
|
.iform = (BT848_IFORM_NTSC_J|BT848_IFORM_XT0),
|
|
|
|
.scaledtwidth = 780,
|
|
|
|
.hdelayx1 = 135,
|
|
|
|
.hactivex1 = 754,
|
|
|
|
.vdelay = 0x16,
|
|
|
|
.vbipack = 144,
|
|
|
|
.sram = -1,
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
.vbistart = { 10, 273 },
|
|
|
|
CROPCAP(/* minhdelayx1 */ 68,
|
|
|
|
/* hdelayx1 */ 135,
|
|
|
|
/* swidth */ (640 * 910 + 780 / 2) / 780,
|
|
|
|
/* totalwidth */ 910,
|
|
|
|
/* sqwidth */ 780,
|
|
|
|
/* vdelay */ 0x16,
|
|
|
|
/* sheight */ 480,
|
[media] [REGRESSION] bt8xx: Fix too large height in cropcap
Since commit a1fd287780c8e91fed4957b30c757b0c93021162:
"[media] bttv-driver: fix two warnings"
cropcap.defrect.height and cropcap.bounds.height for the PAL entry are 32
resp 30 pixels too large, if a userspace app (ie xawtv) actually tries to use
the full advertised height, the resulting image is broken in ways only a
screenshot can describe.
The cause of this is the fix for this warning:
drivers/media/pci/bt8xx/bttv-driver.c:308:3: warning: initialized field overwritten [-Woverride-init]
In this chunk of the commit:
@@ -301,11 +301,10 @@ const struct bttv_tvnorm bttv_tvnorms[] = {
/* totalwidth */ 1135,
/* sqwidth */ 944,
/* vdelay */ 0x20,
- /* sheight */ 576,
- /* videostart0 */ 23)
/* bt878 (and bt848?) can capture another
line below active video. */
- .cropcap.bounds.height = (576 + 2) + 0x20 - 2,
+ /* sheight */ (576 + 2) + 0x20 - 2,
+ /* videostart0 */ 23)
},{
.v4l2_id = V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_KR,
.name = "NTSC",
Which replaces the overriding of cropcap.bounds.height initialization outside
of the CROPCAP macro (which also initializes it), with passing a
different sheight value to the CROPCAP macro.
There are 2 problems with this warning fix:
1) The sheight value is used twice in the CROPCAP macro, and the old code
only changed one resulting value.
2) The old code increased the .cropcap.bounds.height value (and did not
touch the .cropcap.defrect.height value at all) by 2, where as the fixed
code increases it by 32, as the fixed code passes (576 + 2) + 0x20 - 2
to the CROPCAP macro, but the + 0x20 - 2 is already done by the macro so
now is done twice for .cropcap.bounds.height, and also is applied to
.cropcap.defrect.height where it should not be applied at all.
This patch fixes this by adding an extraheight parameter to the CROPCAP entry
and using it for the PAL entry.
Cc: stable@kernel.org # For Kernel 3.8
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-03-26 00:45:54 +07:00
|
|
|
/* extraheight */ 0,
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
/* videostart0 */ 23)
|
2005-04-17 05:20:36 +07:00
|
|
|
},{
|
|
|
|
/* that one hopefully works with the strange timing
|
|
|
|
* which video recorders produce when playing a NTSC
|
|
|
|
* tape on a PAL TV ... */
|
|
|
|
.v4l2_id = V4L2_STD_PAL_60,
|
|
|
|
.name = "PAL-60",
|
|
|
|
.Fsc = 35468950,
|
|
|
|
.swidth = 924,
|
|
|
|
.sheight = 480,
|
|
|
|
.totalwidth = 1135,
|
|
|
|
.adelay = 0x7f,
|
|
|
|
.bdelay = 0x72,
|
|
|
|
.iform = (BT848_IFORM_PAL_BDGHI|BT848_IFORM_XT1),
|
|
|
|
.scaledtwidth = 1135,
|
|
|
|
.hdelayx1 = 186,
|
|
|
|
.hactivex1 = 924,
|
|
|
|
.vdelay = 0x1a,
|
|
|
|
.vbipack = 255,
|
|
|
|
.vtotal = 524,
|
|
|
|
.sram = -1,
|
2006-01-10 00:25:27 +07:00
|
|
|
.vbistart = { 10, 273 },
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
CROPCAP(/* minhdelayx1 */ 68,
|
|
|
|
/* hdelayx1 */ 186,
|
|
|
|
/* swidth */ 924,
|
|
|
|
/* totalwidth */ 1135,
|
|
|
|
/* sqwidth */ 944,
|
|
|
|
/* vdelay */ 0x1a,
|
|
|
|
/* sheight */ 480,
|
[media] [REGRESSION] bt8xx: Fix too large height in cropcap
Since commit a1fd287780c8e91fed4957b30c757b0c93021162:
"[media] bttv-driver: fix two warnings"
cropcap.defrect.height and cropcap.bounds.height for the PAL entry are 32
resp 30 pixels too large, if a userspace app (ie xawtv) actually tries to use
the full advertised height, the resulting image is broken in ways only a
screenshot can describe.
The cause of this is the fix for this warning:
drivers/media/pci/bt8xx/bttv-driver.c:308:3: warning: initialized field overwritten [-Woverride-init]
In this chunk of the commit:
@@ -301,11 +301,10 @@ const struct bttv_tvnorm bttv_tvnorms[] = {
/* totalwidth */ 1135,
/* sqwidth */ 944,
/* vdelay */ 0x20,
- /* sheight */ 576,
- /* videostart0 */ 23)
/* bt878 (and bt848?) can capture another
line below active video. */
- .cropcap.bounds.height = (576 + 2) + 0x20 - 2,
+ /* sheight */ (576 + 2) + 0x20 - 2,
+ /* videostart0 */ 23)
},{
.v4l2_id = V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_KR,
.name = "NTSC",
Which replaces the overriding of cropcap.bounds.height initialization outside
of the CROPCAP macro (which also initializes it), with passing a
different sheight value to the CROPCAP macro.
There are 2 problems with this warning fix:
1) The sheight value is used twice in the CROPCAP macro, and the old code
only changed one resulting value.
2) The old code increased the .cropcap.bounds.height value (and did not
touch the .cropcap.defrect.height value at all) by 2, where as the fixed
code increases it by 32, as the fixed code passes (576 + 2) + 0x20 - 2
to the CROPCAP macro, but the + 0x20 - 2 is already done by the macro so
now is done twice for .cropcap.bounds.height, and also is applied to
.cropcap.defrect.height where it should not be applied at all.
This patch fixes this by adding an extraheight parameter to the CROPCAP entry
and using it for the PAL entry.
Cc: stable@kernel.org # For Kernel 3.8
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-03-26 00:45:54 +07:00
|
|
|
/* extraheight */ 0,
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
/* videostart0 */ 23)
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
static const unsigned int BTTV_TVNORMS = ARRAY_SIZE(bttv_tvnorms);
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------- */
|
|
|
|
/* bttv format list
|
|
|
|
packed pixel formats must come first */
|
2007-12-28 08:20:58 +07:00
|
|
|
static const struct bttv_format formats[] = {
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
.name = "8 bpp, gray",
|
|
|
|
.fourcc = V4L2_PIX_FMT_GREY,
|
|
|
|
.btformat = BT848_COLOR_FMT_Y8,
|
|
|
|
.depth = 8,
|
|
|
|
.flags = FORMAT_FLAGS_PACKED,
|
|
|
|
},{
|
|
|
|
.name = "8 bpp, dithered color",
|
|
|
|
.fourcc = V4L2_PIX_FMT_HI240,
|
|
|
|
.btformat = BT848_COLOR_FMT_RGB8,
|
|
|
|
.depth = 8,
|
|
|
|
.flags = FORMAT_FLAGS_PACKED | FORMAT_FLAGS_DITHER,
|
|
|
|
},{
|
|
|
|
.name = "15 bpp RGB, le",
|
|
|
|
.fourcc = V4L2_PIX_FMT_RGB555,
|
|
|
|
.btformat = BT848_COLOR_FMT_RGB15,
|
|
|
|
.depth = 16,
|
|
|
|
.flags = FORMAT_FLAGS_PACKED,
|
|
|
|
},{
|
|
|
|
.name = "15 bpp RGB, be",
|
|
|
|
.fourcc = V4L2_PIX_FMT_RGB555X,
|
|
|
|
.btformat = BT848_COLOR_FMT_RGB15,
|
|
|
|
.btswap = 0x03, /* byteswap */
|
|
|
|
.depth = 16,
|
|
|
|
.flags = FORMAT_FLAGS_PACKED,
|
|
|
|
},{
|
|
|
|
.name = "16 bpp RGB, le",
|
|
|
|
.fourcc = V4L2_PIX_FMT_RGB565,
|
|
|
|
.btformat = BT848_COLOR_FMT_RGB16,
|
|
|
|
.depth = 16,
|
|
|
|
.flags = FORMAT_FLAGS_PACKED,
|
|
|
|
},{
|
|
|
|
.name = "16 bpp RGB, be",
|
|
|
|
.fourcc = V4L2_PIX_FMT_RGB565X,
|
|
|
|
.btformat = BT848_COLOR_FMT_RGB16,
|
|
|
|
.btswap = 0x03, /* byteswap */
|
|
|
|
.depth = 16,
|
|
|
|
.flags = FORMAT_FLAGS_PACKED,
|
|
|
|
},{
|
|
|
|
.name = "24 bpp RGB, le",
|
|
|
|
.fourcc = V4L2_PIX_FMT_BGR24,
|
|
|
|
.btformat = BT848_COLOR_FMT_RGB24,
|
|
|
|
.depth = 24,
|
|
|
|
.flags = FORMAT_FLAGS_PACKED,
|
|
|
|
},{
|
|
|
|
.name = "32 bpp RGB, le",
|
|
|
|
.fourcc = V4L2_PIX_FMT_BGR32,
|
|
|
|
.btformat = BT848_COLOR_FMT_RGB32,
|
|
|
|
.depth = 32,
|
|
|
|
.flags = FORMAT_FLAGS_PACKED,
|
|
|
|
},{
|
|
|
|
.name = "32 bpp RGB, be",
|
|
|
|
.fourcc = V4L2_PIX_FMT_RGB32,
|
|
|
|
.btformat = BT848_COLOR_FMT_RGB32,
|
|
|
|
.btswap = 0x0f, /* byte+word swap */
|
|
|
|
.depth = 32,
|
|
|
|
.flags = FORMAT_FLAGS_PACKED,
|
|
|
|
},{
|
|
|
|
.name = "4:2:2, packed, YUYV",
|
|
|
|
.fourcc = V4L2_PIX_FMT_YUYV,
|
|
|
|
.btformat = BT848_COLOR_FMT_YUY2,
|
|
|
|
.depth = 16,
|
|
|
|
.flags = FORMAT_FLAGS_PACKED,
|
|
|
|
},{
|
|
|
|
.name = "4:2:2, packed, UYVY",
|
|
|
|
.fourcc = V4L2_PIX_FMT_UYVY,
|
|
|
|
.btformat = BT848_COLOR_FMT_YUY2,
|
|
|
|
.btswap = 0x03, /* byteswap */
|
|
|
|
.depth = 16,
|
|
|
|
.flags = FORMAT_FLAGS_PACKED,
|
|
|
|
},{
|
|
|
|
.name = "4:2:2, planar, Y-Cb-Cr",
|
|
|
|
.fourcc = V4L2_PIX_FMT_YUV422P,
|
|
|
|
.btformat = BT848_COLOR_FMT_YCrCb422,
|
|
|
|
.depth = 16,
|
|
|
|
.flags = FORMAT_FLAGS_PLANAR,
|
|
|
|
.hshift = 1,
|
|
|
|
.vshift = 0,
|
|
|
|
},{
|
|
|
|
.name = "4:2:0, planar, Y-Cb-Cr",
|
|
|
|
.fourcc = V4L2_PIX_FMT_YUV420,
|
|
|
|
.btformat = BT848_COLOR_FMT_YCrCb422,
|
|
|
|
.depth = 12,
|
|
|
|
.flags = FORMAT_FLAGS_PLANAR,
|
|
|
|
.hshift = 1,
|
|
|
|
.vshift = 1,
|
|
|
|
},{
|
|
|
|
.name = "4:2:0, planar, Y-Cr-Cb",
|
|
|
|
.fourcc = V4L2_PIX_FMT_YVU420,
|
|
|
|
.btformat = BT848_COLOR_FMT_YCrCb422,
|
|
|
|
.depth = 12,
|
|
|
|
.flags = FORMAT_FLAGS_PLANAR | FORMAT_FLAGS_CrCb,
|
|
|
|
.hshift = 1,
|
|
|
|
.vshift = 1,
|
|
|
|
},{
|
|
|
|
.name = "4:1:1, planar, Y-Cb-Cr",
|
|
|
|
.fourcc = V4L2_PIX_FMT_YUV411P,
|
|
|
|
.btformat = BT848_COLOR_FMT_YCrCb411,
|
|
|
|
.depth = 12,
|
|
|
|
.flags = FORMAT_FLAGS_PLANAR,
|
|
|
|
.hshift = 2,
|
|
|
|
.vshift = 0,
|
|
|
|
},{
|
|
|
|
.name = "4:1:0, planar, Y-Cb-Cr",
|
|
|
|
.fourcc = V4L2_PIX_FMT_YUV410,
|
|
|
|
.btformat = BT848_COLOR_FMT_YCrCb411,
|
|
|
|
.depth = 9,
|
|
|
|
.flags = FORMAT_FLAGS_PLANAR,
|
|
|
|
.hshift = 2,
|
|
|
|
.vshift = 2,
|
|
|
|
},{
|
|
|
|
.name = "4:1:0, planar, Y-Cr-Cb",
|
|
|
|
.fourcc = V4L2_PIX_FMT_YVU410,
|
|
|
|
.btformat = BT848_COLOR_FMT_YCrCb411,
|
|
|
|
.depth = 9,
|
|
|
|
.flags = FORMAT_FLAGS_PLANAR | FORMAT_FLAGS_CrCb,
|
|
|
|
.hshift = 2,
|
|
|
|
.vshift = 2,
|
|
|
|
},{
|
|
|
|
.name = "raw scanlines",
|
|
|
|
.fourcc = -1,
|
|
|
|
.btformat = BT848_COLOR_FMT_RAW,
|
|
|
|
.depth = 8,
|
|
|
|
.flags = FORMAT_FLAGS_RAW,
|
|
|
|
}
|
|
|
|
};
|
2007-12-28 08:20:58 +07:00
|
|
|
static const unsigned int FORMATS = ARRAY_SIZE(formats);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------- */
|
|
|
|
/* resource management */
|
|
|
|
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
/*
|
|
|
|
RESOURCE_ allocated by freed by
|
|
|
|
|
|
|
|
VIDEO_READ bttv_read 1) bttv_read 2)
|
|
|
|
|
|
|
|
VIDEO_STREAM VIDIOC_STREAMON VIDIOC_STREAMOFF
|
|
|
|
VIDIOC_QBUF 1) bttv_release
|
|
|
|
VIDIOCMCAPTURE 1)
|
|
|
|
|
|
|
|
OVERLAY VIDIOCCAPTURE on VIDIOCCAPTURE off
|
|
|
|
VIDIOC_OVERLAY on VIDIOC_OVERLAY off
|
|
|
|
3) bttv_release
|
|
|
|
|
|
|
|
VBI VIDIOC_STREAMON VIDIOC_STREAMOFF
|
|
|
|
VIDIOC_QBUF 1) bttv_release
|
|
|
|
bttv_read, bttv_poll 1) 4)
|
|
|
|
|
|
|
|
1) The resource must be allocated when we enter buffer prepare functions
|
|
|
|
and remain allocated while buffers are in the DMA queue.
|
|
|
|
2) This is a single frame read.
|
|
|
|
3) VIDIOC_S_FBUF and VIDIOC_S_FMT (OVERLAY) still work when
|
|
|
|
RESOURCE_OVERLAY is allocated.
|
|
|
|
4) This is a continuous read, implies VIDIOC_STREAMON.
|
|
|
|
|
|
|
|
Note this driver permits video input and standard changes regardless if
|
|
|
|
resources are allocated.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define VBI_RESOURCES (RESOURCE_VBI)
|
|
|
|
#define VIDEO_RESOURCES (RESOURCE_VIDEO_READ | \
|
|
|
|
RESOURCE_VIDEO_STREAM | \
|
|
|
|
RESOURCE_OVERLAY)
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
static
|
2010-09-14 22:19:51 +07:00
|
|
|
int check_alloc_btres_lock(struct bttv *btv, struct bttv_fh *fh, int bit)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
int xbits; /* mutual exclusive resources */
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
if (fh->resources & bit)
|
|
|
|
/* have it already allocated */
|
|
|
|
return 1;
|
|
|
|
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
xbits = bit;
|
|
|
|
if (bit & (RESOURCE_VIDEO_READ | RESOURCE_VIDEO_STREAM))
|
|
|
|
xbits |= RESOURCE_VIDEO_READ | RESOURCE_VIDEO_STREAM;
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* is it free? */
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
if (btv->resources & xbits) {
|
2005-04-17 05:20:36 +07:00
|
|
|
/* no, someone else uses it */
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((bit & VIDEO_RESOURCES)
|
|
|
|
&& 0 == (btv->resources & VIDEO_RESOURCES)) {
|
|
|
|
/* Do crop - use current, don't - use default parameters. */
|
|
|
|
__s32 top = btv->crop[!!fh->do_crop].rect.top;
|
|
|
|
|
|
|
|
if (btv->vbi_end > top)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
/* We cannot capture the same line as video and VBI data.
|
|
|
|
Claim scan lines crop[].rect.top to bottom. */
|
|
|
|
btv->crop_start = top;
|
|
|
|
} else if (bit & VBI_RESOURCES) {
|
|
|
|
__s32 end = fh->vbi_fmt.end;
|
|
|
|
|
|
|
|
if (end > btv->crop_start)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
/* Claim scan lines above fh->vbi_fmt.end. */
|
|
|
|
btv->vbi_end = end;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* it's free, grab it */
|
|
|
|
fh->resources |= bit;
|
|
|
|
btv->resources |= bit;
|
|
|
|
return 1;
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
|
|
|
fail:
|
|
|
|
return 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static
|
|
|
|
int check_btres(struct bttv_fh *fh, int bit)
|
|
|
|
{
|
|
|
|
return (fh->resources & bit);
|
|
|
|
}
|
|
|
|
|
|
|
|
static
|
|
|
|
int locked_btres(struct bttv *btv, int bit)
|
|
|
|
{
|
|
|
|
return (btv->resources & bit);
|
|
|
|
}
|
|
|
|
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
/* Call with btv->lock down. */
|
|
|
|
static void
|
|
|
|
disclaim_vbi_lines(struct bttv *btv)
|
|
|
|
{
|
|
|
|
btv->vbi_end = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call with btv->lock down. */
|
|
|
|
static void
|
|
|
|
disclaim_video_lines(struct bttv *btv)
|
|
|
|
{
|
|
|
|
const struct bttv_tvnorm *tvnorm;
|
|
|
|
u8 crop;
|
|
|
|
|
|
|
|
tvnorm = &bttv_tvnorms[btv->tvnorm];
|
|
|
|
btv->crop_start = tvnorm->cropcap.bounds.top
|
|
|
|
+ tvnorm->cropcap.bounds.height;
|
|
|
|
|
|
|
|
/* VBI capturing ends at VDELAY, start of video capturing, no
|
|
|
|
matter how many lines the VBI RISC program expects. When video
|
|
|
|
capturing is off, it shall no longer "preempt" VBI capturing,
|
|
|
|
so we set VDELAY to maximum. */
|
|
|
|
crop = btread(BT848_E_CROP) | 0xc0;
|
|
|
|
btwrite(crop, BT848_E_CROP);
|
|
|
|
btwrite(0xfe, BT848_E_VDELAY_LO);
|
|
|
|
btwrite(crop, BT848_O_CROP);
|
|
|
|
btwrite(0xfe, BT848_O_VDELAY_LO);
|
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
static
|
2010-09-14 22:19:51 +07:00
|
|
|
void free_btres_lock(struct bttv *btv, struct bttv_fh *fh, int bits)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
if ((fh->resources & bits) != bits) {
|
2011-08-22 05:56:48 +07:00
|
|
|
/* trying to free resources not allocated by us ... */
|
|
|
|
pr_err("BUG! (btres)\n");
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
fh->resources &= ~bits;
|
|
|
|
btv->resources &= ~bits;
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
|
|
|
bits = btv->resources;
|
|
|
|
|
|
|
|
if (0 == (bits & VIDEO_RESOURCES))
|
|
|
|
disclaim_video_lines(btv);
|
|
|
|
|
|
|
|
if (0 == (bits & VBI_RESOURCES))
|
|
|
|
disclaim_vbi_lines(btv);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------- */
|
|
|
|
/* If Bt848a or Bt849, use PLL for PAL/SECAM and crystal for NTSC */
|
|
|
|
|
|
|
|
/* Frequency = (F_input / PLL_X) * PLL_I.PLL_F/PLL_C
|
|
|
|
PLL_X = Reference pre-divider (0=1, 1=2)
|
|
|
|
PLL_C = Post divider (0=6, 1=4)
|
|
|
|
PLL_I = Integer input
|
|
|
|
PLL_F = Fractional input
|
|
|
|
|
|
|
|
F_input = 28.636363 MHz:
|
|
|
|
PAL (CLKx2 = 35.46895 MHz): PLL_X = 1, PLL_I = 0x0E, PLL_F = 0xDCF9, PLL_C = 0
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void set_pll_freq(struct bttv *btv, unsigned int fin, unsigned int fout)
|
|
|
|
{
|
2005-12-12 15:37:27 +07:00
|
|
|
unsigned char fl, fh, fi;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-12-12 15:37:27 +07:00
|
|
|
/* prevent overflows */
|
|
|
|
fin/=4;
|
|
|
|
fout/=4;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-12-12 15:37:27 +07:00
|
|
|
fout*=12;
|
|
|
|
fi=fout/fin;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-12-12 15:37:27 +07:00
|
|
|
fout=(fout%fin)*256;
|
|
|
|
fh=fout/fin;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-12-12 15:37:27 +07:00
|
|
|
fout=(fout%fin)*256;
|
|
|
|
fl=fout/fin;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-12-12 15:37:27 +07:00
|
|
|
btwrite(fl, BT848_PLL_F_LO);
|
|
|
|
btwrite(fh, BT848_PLL_F_HI);
|
|
|
|
btwrite(fi|BT848_PLL_X, BT848_PLL_XCI);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void set_pll(struct bttv *btv)
|
|
|
|
{
|
2005-12-12 15:37:27 +07:00
|
|
|
int i;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-12-12 15:37:27 +07:00
|
|
|
if (!btv->pll.pll_crystal)
|
|
|
|
return;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
if (btv->pll.pll_ofreq == btv->pll.pll_current) {
|
2011-08-22 05:56:48 +07:00
|
|
|
dprintk("%d: PLL: no change required\n", btv->c.nr);
|
2005-12-12 15:37:27 +07:00
|
|
|
return;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-12-12 15:37:27 +07:00
|
|
|
if (btv->pll.pll_ifreq == btv->pll.pll_ofreq) {
|
|
|
|
/* no PLL needed */
|
|
|
|
if (btv->pll.pll_current == 0)
|
2005-12-12 15:37:28 +07:00
|
|
|
return;
|
2011-08-22 05:56:48 +07:00
|
|
|
if (bttv_verbose)
|
|
|
|
pr_info("%d: PLL can sleep, using XTAL (%d)\n",
|
|
|
|
btv->c.nr, btv->pll.pll_ifreq);
|
2005-12-12 15:37:27 +07:00
|
|
|
btwrite(0x00,BT848_TGCTRL);
|
|
|
|
btwrite(0x00,BT848_PLL_XCI);
|
|
|
|
btv->pll.pll_current = 0;
|
|
|
|
return;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2011-08-22 05:56:48 +07:00
|
|
|
if (bttv_verbose)
|
|
|
|
pr_info("%d: Setting PLL: %d => %d (needs up to 100ms)\n",
|
|
|
|
btv->c.nr,
|
|
|
|
btv->pll.pll_ifreq, btv->pll.pll_ofreq);
|
2005-04-17 05:20:36 +07:00
|
|
|
set_pll_freq(btv, btv->pll.pll_ifreq, btv->pll.pll_ofreq);
|
|
|
|
|
2005-12-12 15:37:27 +07:00
|
|
|
for (i=0; i<10; i++) {
|
2005-04-17 05:20:36 +07:00
|
|
|
/* Let other people run while the PLL stabilizes */
|
|
|
|
msleep(10);
|
|
|
|
|
2005-12-12 15:37:27 +07:00
|
|
|
if (btread(BT848_DSTATUS) & BT848_DSTATUS_PLOCK) {
|
2005-04-17 05:20:36 +07:00
|
|
|
btwrite(0,BT848_DSTATUS);
|
2005-12-12 15:37:27 +07:00
|
|
|
} else {
|
2005-12-12 15:37:28 +07:00
|
|
|
btwrite(0x08,BT848_TGCTRL);
|
|
|
|
btv->pll.pll_current = btv->pll.pll_ofreq;
|
2011-08-22 05:56:48 +07:00
|
|
|
if (bttv_verbose)
|
|
|
|
pr_info("PLL set ok\n");
|
2005-12-12 15:37:28 +07:00
|
|
|
return;
|
2005-12-12 15:37:27 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
btv->pll.pll_current = -1;
|
2011-08-22 05:56:48 +07:00
|
|
|
if (bttv_verbose)
|
|
|
|
pr_info("Setting PLL failed\n");
|
2005-12-12 15:37:27 +07:00
|
|
|
return;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* used to switch between the bt848's analog/digital video capture modes */
|
|
|
|
static void bt848A_set_timing(struct bttv *btv)
|
|
|
|
{
|
|
|
|
int i, len;
|
|
|
|
int table_idx = bttv_tvnorms[btv->tvnorm].sram;
|
|
|
|
int fsc = bttv_tvnorms[btv->tvnorm].Fsc;
|
|
|
|
|
2009-01-29 07:32:59 +07:00
|
|
|
if (btv->input == btv->dig) {
|
2011-08-22 05:56:48 +07:00
|
|
|
dprintk("%d: load digital timing table (table_idx=%d)\n",
|
2005-04-17 05:20:36 +07:00
|
|
|
btv->c.nr,table_idx);
|
|
|
|
|
|
|
|
/* timing change...reset timing generator address */
|
2005-11-09 12:37:43 +07:00
|
|
|
btwrite(0x00, BT848_TGCTRL);
|
|
|
|
btwrite(0x02, BT848_TGCTRL);
|
|
|
|
btwrite(0x00, BT848_TGCTRL);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
len=SRAM_Table[table_idx][0];
|
|
|
|
for(i = 1; i <= len; i++)
|
|
|
|
btwrite(SRAM_Table[table_idx][i],BT848_TGLB);
|
|
|
|
btv->pll.pll_ofreq = 27000000;
|
|
|
|
|
|
|
|
set_pll(btv);
|
|
|
|
btwrite(0x11, BT848_TGCTRL);
|
|
|
|
btwrite(0x41, BT848_DVSIF);
|
|
|
|
} else {
|
|
|
|
btv->pll.pll_ofreq = fsc;
|
|
|
|
set_pll(btv);
|
|
|
|
btwrite(0x0, BT848_DVSIF);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static void bt848_bright(struct bttv *btv, int bright)
|
|
|
|
{
|
|
|
|
int value;
|
|
|
|
|
2011-08-22 05:56:48 +07:00
|
|
|
// printk("set bright: %d\n", bright); // DEBUG
|
2005-04-17 05:20:36 +07:00
|
|
|
btv->bright = bright;
|
|
|
|
|
|
|
|
/* We want -128 to 127 we get 0-65535 */
|
|
|
|
value = (bright >> 8) - 128;
|
|
|
|
btwrite(value & 0xff, BT848_BRIGHT);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void bt848_hue(struct bttv *btv, int hue)
|
|
|
|
{
|
|
|
|
int value;
|
|
|
|
|
|
|
|
btv->hue = hue;
|
|
|
|
|
|
|
|
/* -128 to 127 */
|
|
|
|
value = (hue >> 8) - 128;
|
2005-11-09 12:37:43 +07:00
|
|
|
btwrite(value & 0xff, BT848_HUE);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void bt848_contrast(struct bttv *btv, int cont)
|
|
|
|
{
|
|
|
|
int value,hibit;
|
|
|
|
|
|
|
|
btv->contrast = cont;
|
|
|
|
|
|
|
|
/* 0-511 */
|
|
|
|
value = (cont >> 7);
|
|
|
|
hibit = (value >> 6) & 4;
|
2005-11-09 12:37:43 +07:00
|
|
|
btwrite(value & 0xff, BT848_CONTRAST_LO);
|
|
|
|
btaor(hibit, ~4, BT848_E_CONTROL);
|
|
|
|
btaor(hibit, ~4, BT848_O_CONTROL);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void bt848_sat(struct bttv *btv, int color)
|
|
|
|
{
|
|
|
|
int val_u,val_v,hibits;
|
|
|
|
|
|
|
|
btv->saturation = color;
|
|
|
|
|
|
|
|
/* 0-511 for the color */
|
2005-06-29 10:45:25 +07:00
|
|
|
val_u = ((color * btv->opt_uv_ratio) / 50) >> 7;
|
|
|
|
val_v = (((color * (100 - btv->opt_uv_ratio) / 50) >>7)*180L)/254;
|
2005-11-09 12:37:43 +07:00
|
|
|
hibits = (val_u >> 7) & 2;
|
2005-04-17 05:20:36 +07:00
|
|
|
hibits |= (val_v >> 8) & 1;
|
2005-11-09 12:37:43 +07:00
|
|
|
btwrite(val_u & 0xff, BT848_SAT_U_LO);
|
|
|
|
btwrite(val_v & 0xff, BT848_SAT_V_LO);
|
|
|
|
btaor(hibits, ~3, BT848_E_CONTROL);
|
|
|
|
btaor(hibits, ~3, BT848_O_CONTROL);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static int
|
|
|
|
video_mux(struct bttv *btv, unsigned int input)
|
|
|
|
{
|
|
|
|
int mux,mask2;
|
|
|
|
|
|
|
|
if (input >= bttv_tvcards[btv->c.type].video_inputs)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2005-11-09 12:37:43 +07:00
|
|
|
/* needed by RemoteVideo MX */
|
2005-04-17 05:20:36 +07:00
|
|
|
mask2 = bttv_tvcards[btv->c.type].gpiomask2;
|
|
|
|
if (mask2)
|
|
|
|
gpio_inout(mask2,mask2);
|
|
|
|
|
|
|
|
if (input == btv->svhs) {
|
|
|
|
btor(BT848_CONTROL_COMP, BT848_E_CONTROL);
|
|
|
|
btor(BT848_CONTROL_COMP, BT848_O_CONTROL);
|
|
|
|
} else {
|
|
|
|
btand(~BT848_CONTROL_COMP, BT848_E_CONTROL);
|
|
|
|
btand(~BT848_CONTROL_COMP, BT848_O_CONTROL);
|
|
|
|
}
|
V4L/DVB (10567): bttv: shrink muxsel data in card database
Over half of the card database was used to store muxsel data. 64 bytes
were used to store one 32 bit word for each of up to 16 inputs.
The Bt8x8 only has two bits to control its mux, so muxsel data for 16
inputs will fit into a single 32 bit word. There were a couple cards that
had special muxsel data that didn't fit in two bits, but I cleaned them up
in earlier patches.
Unfortunately, C doesn't allow us to have an array of bit fields. This
makes initializing the structure more of a pain. But with some cpp magic,
we can do it by changing:
.muxsel = { 2, 3, 0, 1 },
.muxsel = { 2, 2, 2, 2, 3, 3, 3, 3, 1, 1 },
Into:
.muxsel = MUXSEL(2, 3, 0, 1),
.muxsel = MUXSEL(2, 2, 2, 2, 3, 3, 3, 3, 1, 1),
That's not so bad. MUXSEL is a fancy macro that packs the arguments (of
which there can be one to sixteen!) into a single word two bits at a time.
It's a compile time constant (a variadic function wouldn't be) so we can
use it to initialize the structure. It's important the the arguments to
the macro only be plain decimal integers. Stuff like "0x01", "(2)", or
"MUX3" won't work properly.
I also created an accessor function, bttv_muxsel(btv, input), that gets the
mux bits for the selected input. It makes it cleaner to change the way the
muxsel data is stored.
This patch doesn't change the code size and decreases the datasegment by
9440 bytes.
Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2009-01-29 07:32:59 +07:00
|
|
|
mux = bttv_muxsel(btv, input);
|
2005-04-17 05:20:36 +07:00
|
|
|
btaor(mux<<5, ~(3<<5), BT848_IFORM);
|
2011-08-22 05:56:48 +07:00
|
|
|
dprintk("%d: video mux: input=%d mux=%d\n", btv->c.nr, input, mux);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* card specific hook */
|
|
|
|
if(bttv_tvcards[btv->c.type].muxsel_hook)
|
|
|
|
bttv_tvcards[btv->c.type].muxsel_hook (btv, input);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *audio_modes[] = {
|
|
|
|
"audio: tuner", "audio: radio", "audio: extern",
|
2006-03-19 07:31:00 +07:00
|
|
|
"audio: intern", "audio: mute"
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
2013-03-21 23:51:17 +07:00
|
|
|
static void
|
|
|
|
audio_mux_gpio(struct bttv *btv, int input, int mute)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2013-03-21 23:51:13 +07:00
|
|
|
int gpio_val, signal, mute_gpio;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
gpio_inout(bttv_tvcards[btv->c.type].gpiomask,
|
|
|
|
bttv_tvcards[btv->c.type].gpiomask);
|
|
|
|
signal = btread(BT848_DSTATUS) & BT848_DSTATUS_HLOC;
|
|
|
|
|
2006-03-19 07:31:00 +07:00
|
|
|
/* automute */
|
2013-03-21 23:51:13 +07:00
|
|
|
mute_gpio = mute || (btv->opt_automute && (!signal || !btv->users)
|
2013-02-10 19:24:14 +07:00
|
|
|
&& !btv->has_radio_tuner);
|
2006-03-19 07:31:00 +07:00
|
|
|
|
2013-03-21 23:51:13 +07:00
|
|
|
if (mute_gpio)
|
2006-03-19 07:31:00 +07:00
|
|
|
gpio_val = bttv_tvcards[btv->c.type].gpiomute;
|
|
|
|
else
|
|
|
|
gpio_val = bttv_tvcards[btv->c.type].gpiomux[input];
|
|
|
|
|
2009-01-29 07:32:59 +07:00
|
|
|
switch (btv->c.type) {
|
|
|
|
case BTTV_BOARD_VOODOOTV_FM:
|
|
|
|
case BTTV_BOARD_VOODOOTV_200:
|
|
|
|
gpio_val = bttv_tda9880_setnorm(btv, gpio_val);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
gpio_bits(bttv_tvcards[btv->c.type].gpiomask, gpio_val);
|
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
if (bttv_gpio)
|
2013-03-21 23:51:13 +07:00
|
|
|
bttv_gpio_tracking(btv, audio_modes[mute_gpio ? 4 : input]);
|
2013-03-21 23:51:17 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2013-03-21 23:51:18 +07:00
|
|
|
audio_mute(struct bttv *btv, int mute)
|
2013-03-21 23:51:17 +07:00
|
|
|
{
|
|
|
|
struct v4l2_ctrl *ctrl;
|
|
|
|
|
2013-03-21 23:51:18 +07:00
|
|
|
audio_mux_gpio(btv, btv->audio_input, mute);
|
2006-03-19 07:31:00 +07:00
|
|
|
|
2009-03-28 18:29:00 +07:00
|
|
|
if (btv->sd_msp34xx) {
|
2013-02-06 22:40:28 +07:00
|
|
|
ctrl = v4l2_ctrl_find(btv->sd_msp34xx->ctrl_handler, V4L2_CID_AUDIO_MUTE);
|
|
|
|
if (ctrl)
|
2013-03-21 23:51:14 +07:00
|
|
|
v4l2_ctrl_s_ctrl(ctrl, mute);
|
2013-03-21 23:51:18 +07:00
|
|
|
}
|
|
|
|
if (btv->sd_tvaudio) {
|
|
|
|
ctrl = v4l2_ctrl_find(btv->sd_tvaudio->ctrl_handler, V4L2_CID_AUDIO_MUTE);
|
|
|
|
if (ctrl)
|
|
|
|
v4l2_ctrl_s_ctrl(ctrl, mute);
|
|
|
|
}
|
|
|
|
if (btv->sd_tda7432) {
|
|
|
|
ctrl = v4l2_ctrl_find(btv->sd_tda7432->ctrl_handler, V4L2_CID_AUDIO_MUTE);
|
|
|
|
if (ctrl)
|
|
|
|
v4l2_ctrl_s_ctrl(ctrl, mute);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
audio_input(struct bttv *btv, int input)
|
|
|
|
{
|
|
|
|
audio_mux_gpio(btv, input, btv->mute);
|
|
|
|
|
|
|
|
if (btv->sd_msp34xx) {
|
|
|
|
u32 in;
|
2013-02-06 22:40:28 +07:00
|
|
|
|
2006-03-19 22:35:57 +07:00
|
|
|
/* Note: the inputs tuner/radio/extern/intern are translated
|
|
|
|
to msp routings. This assumes common behavior for all msp3400
|
|
|
|
based TV cards. When this assumption fails, then the
|
|
|
|
specific MSP routing must be added to the card table.
|
|
|
|
For now this is sufficient. */
|
|
|
|
switch (input) {
|
|
|
|
case TVAUDIO_INPUT_RADIO:
|
2012-05-21 17:46:22 +07:00
|
|
|
/* Some boards need the msp do to the radio demod */
|
|
|
|
if (btv->radio_uses_msp_demodulator) {
|
|
|
|
in = MSP_INPUT_DEFAULT;
|
|
|
|
break;
|
|
|
|
}
|
2009-04-02 21:26:22 +07:00
|
|
|
in = MSP_INPUT(MSP_IN_SCART2, MSP_IN_TUNER1,
|
2006-04-02 04:03:23 +07:00
|
|
|
MSP_DSP_IN_SCART, MSP_DSP_IN_SCART);
|
2006-03-19 22:35:57 +07:00
|
|
|
break;
|
|
|
|
case TVAUDIO_INPUT_EXTERN:
|
2009-04-02 21:26:22 +07:00
|
|
|
in = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1,
|
2006-04-02 04:03:23 +07:00
|
|
|
MSP_DSP_IN_SCART, MSP_DSP_IN_SCART);
|
2006-03-19 22:35:57 +07:00
|
|
|
break;
|
|
|
|
case TVAUDIO_INPUT_INTERN:
|
|
|
|
/* Yes, this is the same input as for RADIO. I doubt
|
|
|
|
if this is ever used. The only board with an INTERN
|
|
|
|
input is the BTTV_BOARD_AVERMEDIA98. I wonder how
|
|
|
|
that was tested. My guess is that the whole INTERN
|
|
|
|
input does not work. */
|
2009-04-02 21:26:22 +07:00
|
|
|
in = MSP_INPUT(MSP_IN_SCART2, MSP_IN_TUNER1,
|
2006-04-02 04:03:23 +07:00
|
|
|
MSP_DSP_IN_SCART, MSP_DSP_IN_SCART);
|
2006-03-19 22:35:57 +07:00
|
|
|
break;
|
|
|
|
case TVAUDIO_INPUT_TUNER:
|
|
|
|
default:
|
2007-06-25 23:02:16 +07:00
|
|
|
/* This is the only card that uses TUNER2, and afaik,
|
|
|
|
is the only difference between the VOODOOTV_FM
|
|
|
|
and VOODOOTV_200 */
|
|
|
|
if (btv->c.type == BTTV_BOARD_VOODOOTV_200)
|
2009-04-02 21:26:22 +07:00
|
|
|
in = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER2, \
|
2007-06-25 23:02:16 +07:00
|
|
|
MSP_DSP_IN_TUNER, MSP_DSP_IN_TUNER);
|
|
|
|
else
|
2009-04-02 21:26:22 +07:00
|
|
|
in = MSP_INPUT_DEFAULT;
|
2006-03-19 22:35:57 +07:00
|
|
|
break;
|
|
|
|
}
|
2009-04-02 21:26:22 +07:00
|
|
|
v4l2_subdev_call(btv->sd_msp34xx, audio, s_routing,
|
|
|
|
in, MSP_OUTPUT_DEFAULT, 0);
|
2006-03-19 22:35:57 +07:00
|
|
|
}
|
2009-03-28 18:29:00 +07:00
|
|
|
if (btv->sd_tvaudio) {
|
2009-04-02 21:26:22 +07:00
|
|
|
v4l2_subdev_call(btv->sd_tvaudio, audio, s_routing,
|
2013-03-21 23:51:18 +07:00
|
|
|
input, 0, 0);
|
2013-02-06 22:40:28 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
static void
|
|
|
|
bttv_crop_calc_limits(struct bttv_crop *c)
|
|
|
|
{
|
|
|
|
/* Scale factor min. 1:1, max. 16:1. Min. image size
|
|
|
|
48 x 32. Scaled width must be a multiple of 4. */
|
|
|
|
|
|
|
|
if (1) {
|
|
|
|
/* For bug compatibility with VIDIOCGCAP and image
|
|
|
|
size checks in earlier driver versions. */
|
|
|
|
c->min_scaled_width = 48;
|
|
|
|
c->min_scaled_height = 32;
|
|
|
|
} else {
|
|
|
|
c->min_scaled_width =
|
2013-11-26 15:31:42 +07:00
|
|
|
(max_t(unsigned int, 48, c->rect.width >> 4) + 3) & ~3;
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
c->min_scaled_height =
|
2013-11-26 15:31:42 +07:00
|
|
|
max_t(unsigned int, 32, c->rect.height >> 4);
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
c->max_scaled_width = c->rect.width & ~3;
|
|
|
|
c->max_scaled_height = c->rect.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-01-29 07:32:58 +07:00
|
|
|
bttv_crop_reset(struct bttv_crop *c, unsigned int norm)
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
{
|
|
|
|
c->rect = bttv_tvnorms[norm].cropcap.defrect;
|
|
|
|
bttv_crop_calc_limits(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call with btv->lock down. */
|
2005-04-17 05:20:36 +07:00
|
|
|
static int
|
|
|
|
set_tvnorm(struct bttv *btv, unsigned int norm)
|
|
|
|
{
|
|
|
|
const struct bttv_tvnorm *tvnorm;
|
2007-10-26 20:53:21 +07:00
|
|
|
v4l2_std_id id;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2009-01-29 07:32:58 +07:00
|
|
|
BUG_ON(norm >= BTTV_TVNORMS);
|
|
|
|
BUG_ON(btv->tvnorm >= BTTV_TVNORMS);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
tvnorm = &bttv_tvnorms[norm];
|
|
|
|
|
2009-09-21 22:42:22 +07:00
|
|
|
if (memcmp(&bttv_tvnorms[btv->tvnorm].cropcap, &tvnorm->cropcap,
|
2009-01-29 07:32:58 +07:00
|
|
|
sizeof (tvnorm->cropcap))) {
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
bttv_crop_reset(&btv->crop[0], norm);
|
|
|
|
btv->crop[1] = btv->crop[0]; /* current = default */
|
|
|
|
|
|
|
|
if (0 == (btv->resources & VIDEO_RESOURCES)) {
|
|
|
|
btv->crop_start = tvnorm->cropcap.bounds.top
|
|
|
|
+ tvnorm->cropcap.bounds.height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
btv->tvnorm = norm;
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
btwrite(tvnorm->adelay, BT848_ADELAY);
|
|
|
|
btwrite(tvnorm->bdelay, BT848_BDELAY);
|
|
|
|
btaor(tvnorm->iform,~(BT848_IFORM_NORM|BT848_IFORM_XTBOTH),
|
|
|
|
BT848_IFORM);
|
|
|
|
btwrite(tvnorm->vbipack, BT848_VBI_PACK_SIZE);
|
|
|
|
btwrite(1, BT848_VBI_PACK_DEL);
|
|
|
|
bt848A_set_timing(btv);
|
|
|
|
|
|
|
|
switch (btv->c.type) {
|
2005-11-09 12:36:52 +07:00
|
|
|
case BTTV_BOARD_VOODOOTV_FM:
|
2007-06-25 23:02:16 +07:00
|
|
|
case BTTV_BOARD_VOODOOTV_200:
|
2009-01-29 07:32:59 +07:00
|
|
|
bttv_tda9880_setnorm(btv, gpio_read());
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
}
|
2007-10-26 20:53:21 +07:00
|
|
|
id = tvnorm->v4l2_id;
|
2014-04-29 02:53:01 +07:00
|
|
|
bttv_call_all(btv, video, s_std, id);
|
2007-10-26 20:53:21 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
/* Call with btv->lock down. */
|
2005-04-17 05:20:36 +07:00
|
|
|
static void
|
V4L/DVB (5808): Bttv: fix v4l1 breaking the driver
If one uses a V4L *one* application, such as vlc or mplayer's v4l driver, as
the first user after the driver is loaded, the driver wedges itself and will
never capture properly. Even if one uses a V4L2 application later, it still
won't work.
If one uses a V4L *two* application first, such as tvtime or mplayer's v4l2
driver, then the driver will be ok. One can then run a V4L1 application, and
it will work.
It turns out the problem is with norm changing and the crop support that was
added in 2.6.21. The driver defaults to PAL, and keeps the last norm it was
set too across opens. If one changes the norm via V4L1, the cropping
parameters are not reset like they should be, and they'll remain broken across
device opens.
This patch removes the direct setting of btv->tvnorm in the V4L1 ioctl
VIDIOCSCHAN handler. The norm is set via the existing call to set_input(),
which calls set_tvnorm(), which will reset the cropping values now that it is
able to detect the norm change.
Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-07-04 01:08:10 +07:00
|
|
|
set_input(struct bttv *btv, unsigned int input, unsigned int norm)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
btv->input = input;
|
|
|
|
if (irq_iswitch) {
|
|
|
|
spin_lock_irqsave(&btv->s_lock,flags);
|
|
|
|
if (btv->curr.frame_irq) {
|
|
|
|
/* active capture -> delayed input switch */
|
|
|
|
btv->new_input = input;
|
|
|
|
} else {
|
|
|
|
video_mux(btv,input);
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&btv->s_lock,flags);
|
|
|
|
} else {
|
|
|
|
video_mux(btv,input);
|
|
|
|
}
|
2013-03-21 23:51:16 +07:00
|
|
|
btv->audio_input = (btv->tuner_type != TUNER_ABSENT && input == 0) ?
|
|
|
|
TVAUDIO_INPUT_TUNER : TVAUDIO_INPUT_EXTERN;
|
|
|
|
audio_input(btv, btv->audio_input);
|
V4L/DVB (5808): Bttv: fix v4l1 breaking the driver
If one uses a V4L *one* application, such as vlc or mplayer's v4l driver, as
the first user after the driver is loaded, the driver wedges itself and will
never capture properly. Even if one uses a V4L2 application later, it still
won't work.
If one uses a V4L *two* application first, such as tvtime or mplayer's v4l2
driver, then the driver will be ok. One can then run a V4L1 application, and
it will work.
It turns out the problem is with norm changing and the crop support that was
added in 2.6.21. The driver defaults to PAL, and keeps the last norm it was
set too across opens. If one changes the norm via V4L1, the cropping
parameters are not reset like they should be, and they'll remain broken across
device opens.
This patch removes the direct setting of btv->tvnorm in the V4L1 ioctl
VIDIOCSCHAN handler. The norm is set via the existing call to set_input(),
which calls set_tvnorm(), which will reset the cropping values now that it is
able to detect the norm change.
Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-07-04 01:08:10 +07:00
|
|
|
set_tvnorm(btv, norm);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void init_irqreg(struct bttv *btv)
|
|
|
|
{
|
|
|
|
/* clear status */
|
|
|
|
btwrite(0xfffffUL, BT848_INT_STAT);
|
|
|
|
|
|
|
|
if (bttv_tvcards[btv->c.type].no_video) {
|
|
|
|
/* i2c only */
|
|
|
|
btwrite(BT848_INT_I2CDONE,
|
|
|
|
BT848_INT_MASK);
|
|
|
|
} else {
|
|
|
|
/* full video */
|
|
|
|
btwrite((btv->triton1) |
|
|
|
|
(btv->gpioirq ? BT848_INT_GPINT : 0) |
|
|
|
|
BT848_INT_SCERR |
|
|
|
|
(fdsr ? BT848_INT_FDSR : 0) |
|
2008-08-30 20:18:21 +07:00
|
|
|
BT848_INT_RISCI | BT848_INT_OCERR |
|
2005-04-17 05:20:36 +07:00
|
|
|
BT848_INT_FMTCHG|BT848_INT_HLOCK|
|
|
|
|
BT848_INT_I2CDONE,
|
|
|
|
BT848_INT_MASK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void init_bt848(struct bttv *btv)
|
|
|
|
{
|
|
|
|
if (bttv_tvcards[btv->c.type].no_video) {
|
|
|
|
/* very basic init only */
|
|
|
|
init_irqreg(btv);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
btwrite(0x00, BT848_CAP_CTL);
|
|
|
|
btwrite(BT848_COLOR_CTL_GAMMA, BT848_COLOR_CTL);
|
|
|
|
btwrite(BT848_IFORM_XTAUTO | BT848_IFORM_AUTO, BT848_IFORM);
|
|
|
|
|
2005-11-09 12:37:43 +07:00
|
|
|
/* set planar and packed mode trigger points and */
|
|
|
|
/* set rising edge of inverted GPINTR pin as irq trigger */
|
|
|
|
btwrite(BT848_GPIO_DMA_CTL_PKTP_32|
|
|
|
|
BT848_GPIO_DMA_CTL_PLTP1_16|
|
|
|
|
BT848_GPIO_DMA_CTL_PLTP23_16|
|
|
|
|
BT848_GPIO_DMA_CTL_GPINTC|
|
|
|
|
BT848_GPIO_DMA_CTL_GPINTI,
|
|
|
|
BT848_GPIO_DMA_CTL);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-11-09 12:37:43 +07:00
|
|
|
btwrite(0x20, BT848_E_VSCALE_HI);
|
|
|
|
btwrite(0x20, BT848_O_VSCALE_HI);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2013-02-06 22:40:28 +07:00
|
|
|
v4l2_ctrl_handler_setup(&btv->ctrl_handler);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-11-09 12:37:43 +07:00
|
|
|
/* interrupt */
|
2005-04-17 05:20:36 +07:00
|
|
|
init_irqreg(btv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void bttv_reinit_bt848(struct bttv *btv)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
if (bttv_verbose)
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_info("%d: reset, reinitialize\n", btv->c.nr);
|
2005-04-17 05:20:36 +07:00
|
|
|
spin_lock_irqsave(&btv->s_lock,flags);
|
|
|
|
btv->errors=0;
|
|
|
|
bttv_set_dma(btv,0);
|
|
|
|
spin_unlock_irqrestore(&btv->s_lock,flags);
|
|
|
|
|
|
|
|
init_bt848(btv);
|
2005-11-09 12:37:43 +07:00
|
|
|
btv->pll.pll_current = -1;
|
V4L/DVB (5808): Bttv: fix v4l1 breaking the driver
If one uses a V4L *one* application, such as vlc or mplayer's v4l driver, as
the first user after the driver is loaded, the driver wedges itself and will
never capture properly. Even if one uses a V4L2 application later, it still
won't work.
If one uses a V4L *two* application first, such as tvtime or mplayer's v4l2
driver, then the driver will be ok. One can then run a V4L1 application, and
it will work.
It turns out the problem is with norm changing and the crop support that was
added in 2.6.21. The driver defaults to PAL, and keeps the last norm it was
set too across opens. If one changes the norm via V4L1, the cropping
parameters are not reset like they should be, and they'll remain broken across
device opens.
This patch removes the direct setting of btv->tvnorm in the V4L1 ioctl
VIDIOCSCHAN handler. The norm is set via the existing call to set_input(),
which calls set_tvnorm(), which will reset the cropping values now that it is
able to detect the norm change.
Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-07-04 01:08:10 +07:00
|
|
|
set_input(btv, btv->input, btv->tvnorm);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2013-02-06 22:40:28 +07:00
|
|
|
static int bttv_s_ctrl(struct v4l2_ctrl *c)
|
2007-12-28 08:23:34 +07:00
|
|
|
{
|
2013-02-06 22:40:28 +07:00
|
|
|
struct bttv *btv = container_of(c->handler, struct bttv, ctrl_handler);
|
|
|
|
int val;
|
2007-12-28 08:23:34 +07:00
|
|
|
|
|
|
|
switch (c->id) {
|
|
|
|
case V4L2_CID_BRIGHTNESS:
|
2013-02-06 22:40:28 +07:00
|
|
|
bt848_bright(btv, c->val);
|
2007-12-28 08:23:34 +07:00
|
|
|
break;
|
|
|
|
case V4L2_CID_HUE:
|
2013-02-06 22:40:28 +07:00
|
|
|
bt848_hue(btv, c->val);
|
2007-12-28 08:23:34 +07:00
|
|
|
break;
|
|
|
|
case V4L2_CID_CONTRAST:
|
2013-02-06 22:40:28 +07:00
|
|
|
bt848_contrast(btv, c->val);
|
2007-12-28 08:23:34 +07:00
|
|
|
break;
|
|
|
|
case V4L2_CID_SATURATION:
|
2013-02-06 22:40:28 +07:00
|
|
|
bt848_sat(btv, c->val);
|
2007-12-28 08:23:34 +07:00
|
|
|
break;
|
2012-09-26 04:10:52 +07:00
|
|
|
case V4L2_CID_COLOR_KILLER:
|
2013-02-06 22:40:28 +07:00
|
|
|
if (c->val) {
|
2012-09-26 04:10:52 +07:00
|
|
|
btor(BT848_SCLOOP_CKILL, BT848_E_SCLOOP);
|
|
|
|
btor(BT848_SCLOOP_CKILL, BT848_O_SCLOOP);
|
|
|
|
} else {
|
|
|
|
btand(~BT848_SCLOOP_CKILL, BT848_E_SCLOOP);
|
|
|
|
btand(~BT848_SCLOOP_CKILL, BT848_O_SCLOOP);
|
|
|
|
}
|
|
|
|
break;
|
2007-12-28 08:23:34 +07:00
|
|
|
case V4L2_CID_AUDIO_MUTE:
|
2013-02-06 22:40:28 +07:00
|
|
|
audio_mute(btv, c->val);
|
2013-03-21 23:51:14 +07:00
|
|
|
btv->mute = c->val;
|
2007-12-28 08:23:34 +07:00
|
|
|
break;
|
2013-02-06 22:40:28 +07:00
|
|
|
case V4L2_CID_AUDIO_VOLUME:
|
|
|
|
btv->volume_gpio(btv, c->val);
|
2007-12-28 08:23:34 +07:00
|
|
|
break;
|
|
|
|
|
2013-02-06 22:40:28 +07:00
|
|
|
case V4L2_CID_CHROMA_AGC:
|
|
|
|
val = c->val ? BT848_SCLOOP_CAGC : 0;
|
|
|
|
btwrite(val, BT848_E_SCLOOP);
|
|
|
|
btwrite(val, BT848_O_SCLOOP);
|
2007-12-28 08:23:34 +07:00
|
|
|
break;
|
|
|
|
case V4L2_CID_PRIVATE_COMBFILTER:
|
2013-02-06 22:40:28 +07:00
|
|
|
btv->opt_combfilter = c->val;
|
2007-12-28 08:23:34 +07:00
|
|
|
break;
|
|
|
|
case V4L2_CID_PRIVATE_LUMAFILTER:
|
2013-02-06 22:40:28 +07:00
|
|
|
if (c->val) {
|
2007-12-28 08:23:34 +07:00
|
|
|
btand(~BT848_CONTROL_LDEC, BT848_E_CONTROL);
|
|
|
|
btand(~BT848_CONTROL_LDEC, BT848_O_CONTROL);
|
|
|
|
} else {
|
|
|
|
btor(BT848_CONTROL_LDEC, BT848_E_CONTROL);
|
|
|
|
btor(BT848_CONTROL_LDEC, BT848_O_CONTROL);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case V4L2_CID_PRIVATE_AUTOMUTE:
|
2013-02-06 22:40:28 +07:00
|
|
|
btv->opt_automute = c->val;
|
2007-12-28 08:23:34 +07:00
|
|
|
break;
|
|
|
|
case V4L2_CID_PRIVATE_AGC_CRUSH:
|
|
|
|
btwrite(BT848_ADC_RESERVED |
|
2013-02-06 22:40:28 +07:00
|
|
|
(c->val ? BT848_ADC_CRUSH : 0),
|
2007-12-28 08:23:34 +07:00
|
|
|
BT848_ADC);
|
|
|
|
break;
|
|
|
|
case V4L2_CID_PRIVATE_VCR_HACK:
|
2013-02-06 22:40:28 +07:00
|
|
|
btv->opt_vcr_hack = c->val;
|
2007-12-28 08:23:34 +07:00
|
|
|
break;
|
|
|
|
case V4L2_CID_PRIVATE_WHITECRUSH_UPPER:
|
2013-02-06 22:40:28 +07:00
|
|
|
btwrite(c->val, BT848_WC_UP);
|
2007-12-28 08:23:34 +07:00
|
|
|
break;
|
|
|
|
case V4L2_CID_PRIVATE_WHITECRUSH_LOWER:
|
2013-02-06 22:40:28 +07:00
|
|
|
btwrite(c->val, BT848_WC_DOWN);
|
2007-12-28 08:23:34 +07:00
|
|
|
break;
|
|
|
|
case V4L2_CID_PRIVATE_UV_RATIO:
|
2013-02-06 22:40:28 +07:00
|
|
|
btv->opt_uv_ratio = c->val;
|
2007-12-28 08:23:34 +07:00
|
|
|
bt848_sat(btv, btv->saturation);
|
|
|
|
break;
|
|
|
|
case V4L2_CID_PRIVATE_FULL_LUMA_RANGE:
|
2013-02-06 22:40:28 +07:00
|
|
|
btaor((c->val << 7), ~BT848_OFORM_RANGE, BT848_OFORM);
|
2007-12-28 08:23:34 +07:00
|
|
|
break;
|
|
|
|
case V4L2_CID_PRIVATE_CORING:
|
2013-02-06 22:40:28 +07:00
|
|
|
btaor((c->val << 5), ~BT848_OFORM_CORE32, BT848_OFORM);
|
2007-12-28 08:23:34 +07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-02-06 22:40:28 +07:00
|
|
|
/* ----------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static const struct v4l2_ctrl_ops bttv_ctrl_ops = {
|
|
|
|
.s_ctrl = bttv_s_ctrl,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct v4l2_ctrl_config bttv_ctrl_combfilter = {
|
|
|
|
.ops = &bttv_ctrl_ops,
|
|
|
|
.id = V4L2_CID_PRIVATE_COMBFILTER,
|
|
|
|
.name = "Comb Filter",
|
|
|
|
.type = V4L2_CTRL_TYPE_BOOLEAN,
|
|
|
|
.min = 0,
|
|
|
|
.max = 1,
|
|
|
|
.step = 1,
|
|
|
|
.def = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct v4l2_ctrl_config bttv_ctrl_automute = {
|
|
|
|
.ops = &bttv_ctrl_ops,
|
|
|
|
.id = V4L2_CID_PRIVATE_AUTOMUTE,
|
|
|
|
.name = "Auto Mute",
|
|
|
|
.type = V4L2_CTRL_TYPE_BOOLEAN,
|
|
|
|
.min = 0,
|
|
|
|
.max = 1,
|
|
|
|
.step = 1,
|
|
|
|
.def = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct v4l2_ctrl_config bttv_ctrl_lumafilter = {
|
|
|
|
.ops = &bttv_ctrl_ops,
|
|
|
|
.id = V4L2_CID_PRIVATE_LUMAFILTER,
|
|
|
|
.name = "Luma Decimation Filter",
|
|
|
|
.type = V4L2_CTRL_TYPE_BOOLEAN,
|
|
|
|
.min = 0,
|
|
|
|
.max = 1,
|
|
|
|
.step = 1,
|
|
|
|
.def = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct v4l2_ctrl_config bttv_ctrl_agc_crush = {
|
|
|
|
.ops = &bttv_ctrl_ops,
|
|
|
|
.id = V4L2_CID_PRIVATE_AGC_CRUSH,
|
|
|
|
.name = "AGC Crush",
|
|
|
|
.type = V4L2_CTRL_TYPE_BOOLEAN,
|
|
|
|
.min = 0,
|
|
|
|
.max = 1,
|
|
|
|
.step = 1,
|
|
|
|
.def = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct v4l2_ctrl_config bttv_ctrl_vcr_hack = {
|
|
|
|
.ops = &bttv_ctrl_ops,
|
|
|
|
.id = V4L2_CID_PRIVATE_VCR_HACK,
|
|
|
|
.name = "VCR Hack",
|
|
|
|
.type = V4L2_CTRL_TYPE_BOOLEAN,
|
|
|
|
.min = 0,
|
|
|
|
.max = 1,
|
|
|
|
.step = 1,
|
|
|
|
.def = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct v4l2_ctrl_config bttv_ctrl_whitecrush_lower = {
|
|
|
|
.ops = &bttv_ctrl_ops,
|
|
|
|
.id = V4L2_CID_PRIVATE_WHITECRUSH_LOWER,
|
|
|
|
.name = "Whitecrush Lower",
|
|
|
|
.type = V4L2_CTRL_TYPE_INTEGER,
|
|
|
|
.min = 0,
|
|
|
|
.max = 255,
|
|
|
|
.step = 1,
|
|
|
|
.def = 0x7f,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct v4l2_ctrl_config bttv_ctrl_whitecrush_upper = {
|
|
|
|
.ops = &bttv_ctrl_ops,
|
|
|
|
.id = V4L2_CID_PRIVATE_WHITECRUSH_UPPER,
|
|
|
|
.name = "Whitecrush Upper",
|
|
|
|
.type = V4L2_CTRL_TYPE_INTEGER,
|
|
|
|
.min = 0,
|
|
|
|
.max = 255,
|
|
|
|
.step = 1,
|
|
|
|
.def = 0xcf,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct v4l2_ctrl_config bttv_ctrl_uv_ratio = {
|
|
|
|
.ops = &bttv_ctrl_ops,
|
|
|
|
.id = V4L2_CID_PRIVATE_UV_RATIO,
|
|
|
|
.name = "UV Ratio",
|
|
|
|
.type = V4L2_CTRL_TYPE_INTEGER,
|
|
|
|
.min = 0,
|
|
|
|
.max = 100,
|
|
|
|
.step = 1,
|
|
|
|
.def = 50,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct v4l2_ctrl_config bttv_ctrl_full_luma = {
|
|
|
|
.ops = &bttv_ctrl_ops,
|
|
|
|
.id = V4L2_CID_PRIVATE_FULL_LUMA_RANGE,
|
|
|
|
.name = "Full Luma Range",
|
|
|
|
.type = V4L2_CTRL_TYPE_BOOLEAN,
|
|
|
|
.min = 0,
|
|
|
|
.max = 1,
|
|
|
|
.step = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct v4l2_ctrl_config bttv_ctrl_coring = {
|
|
|
|
.ops = &bttv_ctrl_ops,
|
|
|
|
.id = V4L2_CID_PRIVATE_CORING,
|
|
|
|
.name = "Coring",
|
|
|
|
.type = V4L2_CTRL_TYPE_INTEGER,
|
|
|
|
.min = 0,
|
|
|
|
.max = 3,
|
|
|
|
.step = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* ----------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void bttv_gpio_tracking(struct bttv *btv, char *comment)
|
|
|
|
{
|
|
|
|
unsigned int outbits, data;
|
|
|
|
outbits = btread(BT848_GPIO_OUT_EN);
|
|
|
|
data = btread(BT848_GPIO_DATA);
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_debug("%d: gpio: en=%08x, out=%08x in=%08x [%s]\n",
|
|
|
|
btv->c.nr, outbits, data & outbits, data & ~outbits, comment);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void bttv_field_count(struct bttv *btv)
|
|
|
|
{
|
|
|
|
int need_count = 0;
|
|
|
|
|
|
|
|
if (btv->users)
|
|
|
|
need_count++;
|
|
|
|
|
|
|
|
if (need_count) {
|
|
|
|
/* start field counter */
|
|
|
|
btor(BT848_INT_VSYNC,BT848_INT_MASK);
|
|
|
|
} else {
|
|
|
|
/* stop field counter */
|
|
|
|
btand(~BT848_INT_VSYNC,BT848_INT_MASK);
|
|
|
|
btv->field_count = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct bttv_format*
|
|
|
|
format_by_fourcc(int fourcc)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
for (i = 0; i < FORMATS; i++) {
|
|
|
|
if (-1 == formats[i].fourcc)
|
2005-04-17 05:20:36 +07:00
|
|
|
continue;
|
2007-12-28 08:20:58 +07:00
|
|
|
if (formats[i].fourcc == fourcc)
|
|
|
|
return formats+i;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------- */
|
|
|
|
/* misc helpers */
|
|
|
|
|
|
|
|
static int
|
|
|
|
bttv_switch_overlay(struct bttv *btv, struct bttv_fh *fh,
|
|
|
|
struct bttv_buffer *new)
|
|
|
|
{
|
|
|
|
struct bttv_buffer *old;
|
|
|
|
unsigned long flags;
|
|
|
|
|
2011-08-22 05:56:48 +07:00
|
|
|
dprintk("switch_overlay: enter [new=%p]\n", new);
|
2005-04-17 05:20:36 +07:00
|
|
|
if (new)
|
2007-11-07 06:02:36 +07:00
|
|
|
new->vb.state = VIDEOBUF_DONE;
|
2005-04-17 05:20:36 +07:00
|
|
|
spin_lock_irqsave(&btv->s_lock,flags);
|
|
|
|
old = btv->screen;
|
|
|
|
btv->screen = new;
|
|
|
|
btv->loop_irq |= 1;
|
|
|
|
bttv_set_dma(btv, 0x03);
|
|
|
|
spin_unlock_irqrestore(&btv->s_lock,flags);
|
|
|
|
if (NULL != old) {
|
2011-08-22 05:56:48 +07:00
|
|
|
dprintk("switch_overlay: old=%p state is %d\n",
|
|
|
|
old, old->vb.state);
|
2006-03-10 22:29:15 +07:00
|
|
|
bttv_dma_free(&fh->cap,btv, old);
|
2005-04-17 05:20:36 +07:00
|
|
|
kfree(old);
|
|
|
|
}
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
if (NULL == new)
|
2010-09-14 22:19:51 +07:00
|
|
|
free_btres_lock(btv,fh,RESOURCE_OVERLAY);
|
2005-04-17 05:20:36 +07:00
|
|
|
dprintk("switch_overlay: done\n");
|
2014-09-04 01:30:41 +07:00
|
|
|
return 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------- */
|
|
|
|
/* video4linux (1) interface */
|
|
|
|
|
2006-03-10 22:29:15 +07:00
|
|
|
static int bttv_prepare_buffer(struct videobuf_queue *q,struct bttv *btv,
|
|
|
|
struct bttv_buffer *buf,
|
2005-11-09 12:37:43 +07:00
|
|
|
const struct bttv_format *fmt,
|
2005-04-17 05:20:36 +07:00
|
|
|
unsigned int width, unsigned int height,
|
|
|
|
enum v4l2_field field)
|
|
|
|
{
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
struct bttv_fh *fh = q->priv_data;
|
2005-04-17 05:20:36 +07:00
|
|
|
int redo_dma_risc = 0;
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
struct bttv_crop c;
|
|
|
|
int norm;
|
2005-04-17 05:20:36 +07:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
/* check settings */
|
|
|
|
if (NULL == fmt)
|
|
|
|
return -EINVAL;
|
|
|
|
if (fmt->btformat == BT848_COLOR_FMT_RAW) {
|
|
|
|
width = RAW_BPL;
|
|
|
|
height = RAW_LINES*2;
|
|
|
|
if (width*height > buf->vb.bsize)
|
|
|
|
return -EINVAL;
|
|
|
|
buf->vb.size = buf->vb.bsize;
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
|
|
|
/* Make sure tvnorm and vbi_end remain consistent
|
|
|
|
until we're done. */
|
|
|
|
|
|
|
|
norm = btv->tvnorm;
|
|
|
|
|
|
|
|
/* In this mode capturing always starts at defrect.top
|
|
|
|
(default VDELAY), ignoring cropping parameters. */
|
|
|
|
if (btv->vbi_end > bttv_tvnorms[norm].cropcap.defrect.top) {
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
c.rect = bttv_tvnorms[norm].cropcap.defrect;
|
2005-04-17 05:20:36 +07:00
|
|
|
} else {
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
norm = btv->tvnorm;
|
|
|
|
c = btv->crop[!!fh->do_crop];
|
|
|
|
|
|
|
|
if (width < c.min_scaled_width ||
|
|
|
|
width > c.max_scaled_width ||
|
|
|
|
height < c.min_scaled_height)
|
2005-04-17 05:20:36 +07:00
|
|
|
return -EINVAL;
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
|
|
|
switch (field) {
|
|
|
|
case V4L2_FIELD_TOP:
|
|
|
|
case V4L2_FIELD_BOTTOM:
|
|
|
|
case V4L2_FIELD_ALTERNATE:
|
|
|
|
/* btv->crop counts frame lines. Max. scale
|
|
|
|
factor is 16:1 for frames, 8:1 for fields. */
|
|
|
|
if (height * 2 > c.max_scaled_height)
|
|
|
|
return -EINVAL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if (height > c.max_scaled_height)
|
|
|
|
return -EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
buf->vb.size = (width * height * fmt->depth) >> 3;
|
|
|
|
if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size)
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* alloc + fill struct bttv_buffer (if changed) */
|
|
|
|
if (buf->vb.width != width || buf->vb.height != height ||
|
|
|
|
buf->vb.field != field ||
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
buf->tvnorm != norm || buf->fmt != fmt ||
|
|
|
|
buf->crop.top != c.rect.top ||
|
|
|
|
buf->crop.left != c.rect.left ||
|
|
|
|
buf->crop.width != c.rect.width ||
|
|
|
|
buf->crop.height != c.rect.height) {
|
2005-04-17 05:20:36 +07:00
|
|
|
buf->vb.width = width;
|
|
|
|
buf->vb.height = height;
|
|
|
|
buf->vb.field = field;
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
buf->tvnorm = norm;
|
2005-04-17 05:20:36 +07:00
|
|
|
buf->fmt = fmt;
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
buf->crop = c.rect;
|
2005-04-17 05:20:36 +07:00
|
|
|
redo_dma_risc = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* alloc risc memory */
|
2007-11-07 06:02:36 +07:00
|
|
|
if (VIDEOBUF_NEEDS_INIT == buf->vb.state) {
|
2005-04-17 05:20:36 +07:00
|
|
|
redo_dma_risc = 1;
|
2006-03-10 22:29:15 +07:00
|
|
|
if (0 != (rc = videobuf_iolock(q,&buf->vb,&btv->fbuf)))
|
2005-04-17 05:20:36 +07:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (redo_dma_risc)
|
|
|
|
if (0 != (rc = bttv_buffer_risc(btv,buf)))
|
|
|
|
goto fail;
|
|
|
|
|
2007-11-07 06:02:36 +07:00
|
|
|
buf->vb.state = VIDEOBUF_PREPARED;
|
2005-04-17 05:20:36 +07:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
fail:
|
2006-03-10 22:29:15 +07:00
|
|
|
bttv_dma_free(q,btv,buf);
|
2005-04-17 05:20:36 +07:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
|
|
|
|
{
|
|
|
|
struct bttv_fh *fh = q->priv_data;
|
|
|
|
|
|
|
|
*size = fh->fmt->depth*fh->width*fh->height >> 3;
|
|
|
|
if (0 == *count)
|
|
|
|
*count = gbuffers;
|
2010-03-22 02:02:45 +07:00
|
|
|
if (*size * *count > gbuffers * gbufsize)
|
|
|
|
*count = (gbuffers * gbufsize) / *size;
|
2005-04-17 05:20:36 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
|
|
|
|
enum v4l2_field field)
|
|
|
|
{
|
|
|
|
struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb);
|
|
|
|
struct bttv_fh *fh = q->priv_data;
|
|
|
|
|
2006-03-10 22:29:15 +07:00
|
|
|
return bttv_prepare_buffer(q,fh->btv, buf, fh->fmt,
|
2005-04-17 05:20:36 +07:00
|
|
|
fh->width, fh->height, field);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
|
|
|
|
{
|
|
|
|
struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb);
|
|
|
|
struct bttv_fh *fh = q->priv_data;
|
|
|
|
struct bttv *btv = fh->btv;
|
|
|
|
|
2007-11-07 06:02:36 +07:00
|
|
|
buf->vb.state = VIDEOBUF_QUEUED;
|
2005-04-17 05:20:36 +07:00
|
|
|
list_add_tail(&buf->vb.queue,&btv->capture);
|
|
|
|
if (!btv->curr.frame_irq) {
|
|
|
|
btv->loop_irq |= 1;
|
|
|
|
bttv_set_dma(btv, 0x03);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
|
|
|
|
{
|
|
|
|
struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb);
|
|
|
|
struct bttv_fh *fh = q->priv_data;
|
|
|
|
|
2007-01-26 18:30:05 +07:00
|
|
|
bttv_dma_free(q,fh->btv,buf);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct videobuf_queue_ops bttv_video_qops = {
|
|
|
|
.buf_setup = buffer_setup,
|
|
|
|
.buf_prepare = buffer_prepare,
|
|
|
|
.buf_queue = buffer_queue,
|
|
|
|
.buf_release = buffer_release,
|
|
|
|
};
|
|
|
|
|
2013-02-10 19:24:14 +07:00
|
|
|
static void radio_enable(struct bttv *btv)
|
|
|
|
{
|
|
|
|
/* Switch to the radio tuner */
|
|
|
|
if (!btv->has_radio_tuner) {
|
|
|
|
btv->has_radio_tuner = 1;
|
|
|
|
bttv_call_all(btv, tuner, s_radio);
|
2013-03-21 23:51:16 +07:00
|
|
|
btv->audio_input = TVAUDIO_INPUT_RADIO;
|
|
|
|
audio_input(btv, btv->audio_input);
|
2013-02-10 19:24:14 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-15 16:10:40 +07:00
|
|
|
static int bttv_s_std(struct file *file, void *priv, v4l2_std_id id)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2007-12-28 08:20:58 +07:00
|
|
|
struct bttv_fh *fh = priv;
|
|
|
|
struct bttv *btv = fh->btv;
|
|
|
|
unsigned int i;
|
2013-02-06 22:42:40 +07:00
|
|
|
int err = 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
for (i = 0; i < BTTV_TVNORMS; i++)
|
2013-03-15 16:10:40 +07:00
|
|
|
if (id & bttv_tvnorms[i].v4l2_id)
|
2007-12-28 08:20:58 +07:00
|
|
|
break;
|
2010-09-15 18:18:31 +07:00
|
|
|
if (i == BTTV_TVNORMS) {
|
|
|
|
err = -EINVAL;
|
|
|
|
goto err;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2013-03-15 16:10:40 +07:00
|
|
|
btv->std = id;
|
2007-12-28 08:20:58 +07:00
|
|
|
set_tvnorm(btv, i);
|
2010-09-15 18:18:31 +07:00
|
|
|
|
|
|
|
err:
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2010-09-15 18:18:31 +07:00
|
|
|
return err;
|
2007-12-28 08:20:58 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2013-02-06 22:43:07 +07:00
|
|
|
static int bttv_g_std(struct file *file, void *priv, v4l2_std_id *id)
|
|
|
|
{
|
|
|
|
struct bttv_fh *fh = priv;
|
|
|
|
struct bttv *btv = fh->btv;
|
|
|
|
|
|
|
|
*id = btv->std;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-12-28 08:22:59 +07:00
|
|
|
static int bttv_querystd(struct file *file, void *f, v4l2_std_id *id)
|
2007-12-28 08:20:58 +07:00
|
|
|
{
|
|
|
|
struct bttv_fh *fh = f;
|
|
|
|
struct bttv *btv = fh->btv;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
if (btread(BT848_DSTATUS) & BT848_DSTATUS_NUML)
|
2013-05-29 20:19:02 +07:00
|
|
|
*id &= V4L2_STD_625_50;
|
2007-12-28 08:20:58 +07:00
|
|
|
else
|
2013-05-29 20:19:02 +07:00
|
|
|
*id &= V4L2_STD_525_60;
|
2007-12-28 08:20:58 +07:00
|
|
|
return 0;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-28 08:22:59 +07:00
|
|
|
static int bttv_enum_input(struct file *file, void *priv,
|
2007-12-28 08:20:58 +07:00
|
|
|
struct v4l2_input *i)
|
|
|
|
{
|
|
|
|
struct bttv_fh *fh = priv;
|
|
|
|
struct bttv *btv = fh->btv;
|
2010-09-15 18:18:31 +07:00
|
|
|
int rc = 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2010-09-15 18:18:31 +07:00
|
|
|
if (i->index >= bttv_tvcards[btv->c.type].video_inputs) {
|
|
|
|
rc = -EINVAL;
|
|
|
|
goto err;
|
|
|
|
}
|
2006-08-26 02:53:04 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
i->type = V4L2_INPUT_TYPE_CAMERA;
|
2013-01-31 18:45:13 +07:00
|
|
|
i->audioset = 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2009-01-29 07:32:59 +07:00
|
|
|
if (btv->tuner_type != TUNER_ABSENT && i->index == 0) {
|
2007-12-28 08:20:58 +07:00
|
|
|
sprintf(i->name, "Television");
|
|
|
|
i->type = V4L2_INPUT_TYPE_TUNER;
|
|
|
|
i->tuner = 0;
|
|
|
|
} else if (i->index == btv->svhs) {
|
|
|
|
sprintf(i->name, "S-Video");
|
|
|
|
} else {
|
|
|
|
sprintf(i->name, "Composite%d", i->index);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
if (i->index == btv->input) {
|
|
|
|
__u32 dstatus = btread(BT848_DSTATUS);
|
|
|
|
if (0 == (dstatus & BT848_DSTATUS_PRES))
|
|
|
|
i->status |= V4L2_IN_ST_NO_SIGNAL;
|
|
|
|
if (0 == (dstatus & BT848_DSTATUS_HLOC))
|
|
|
|
i->status |= V4L2_IN_ST_NO_H_LOCK;
|
2007-06-29 10:17:36 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2010-09-15 18:18:31 +07:00
|
|
|
i->std = BTTV_NORMS;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2010-09-15 18:18:31 +07:00
|
|
|
err:
|
|
|
|
|
|
|
|
return rc;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2007-12-28 08:22:59 +07:00
|
|
|
static int bttv_g_input(struct file *file, void *priv, unsigned int *i)
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
{
|
2007-12-28 08:20:58 +07:00
|
|
|
struct bttv_fh *fh = priv;
|
|
|
|
struct bttv *btv = fh->btv;
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
*i = btv->input;
|
2010-09-15 18:18:31 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
return 0;
|
|
|
|
}
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
2007-12-28 08:22:59 +07:00
|
|
|
static int bttv_s_input(struct file *file, void *priv, unsigned int i)
|
2007-12-28 08:20:58 +07:00
|
|
|
{
|
|
|
|
struct bttv_fh *fh = priv;
|
|
|
|
struct bttv *btv = fh->btv;
|
|
|
|
|
2013-01-31 18:45:13 +07:00
|
|
|
if (i >= bttv_tvcards[btv->c.type].video_inputs)
|
|
|
|
return -EINVAL;
|
2007-12-28 08:20:58 +07:00
|
|
|
|
|
|
|
set_input(btv, i, btv->tvnorm);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-12-28 08:22:59 +07:00
|
|
|
static int bttv_s_tuner(struct file *file, void *priv,
|
2013-03-15 16:10:06 +07:00
|
|
|
const struct v4l2_tuner *t)
|
2007-12-28 08:20:58 +07:00
|
|
|
{
|
|
|
|
struct bttv_fh *fh = priv;
|
|
|
|
struct bttv *btv = fh->btv;
|
|
|
|
|
2013-02-06 21:43:07 +07:00
|
|
|
if (t->index)
|
2007-12-28 08:20:58 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2009-03-28 18:29:00 +07:00
|
|
|
bttv_call_all(btv, tuner, s_tuner, t);
|
2007-12-28 08:20:58 +07:00
|
|
|
|
2013-03-15 16:10:06 +07:00
|
|
|
if (btv->audio_mode_gpio) {
|
|
|
|
struct v4l2_tuner copy = *t;
|
|
|
|
|
|
|
|
btv->audio_mode_gpio(btv, ©, 1);
|
|
|
|
}
|
2007-12-28 08:20:58 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-12-28 08:22:59 +07:00
|
|
|
static int bttv_g_frequency(struct file *file, void *priv,
|
2007-12-28 08:20:58 +07:00
|
|
|
struct v4l2_frequency *f)
|
|
|
|
{
|
|
|
|
struct bttv_fh *fh = priv;
|
|
|
|
struct bttv *btv = fh->btv;
|
|
|
|
|
2013-02-06 21:43:07 +07:00
|
|
|
if (f->tuner)
|
|
|
|
return -EINVAL;
|
2007-12-28 08:20:58 +07:00
|
|
|
|
2013-02-10 19:24:14 +07:00
|
|
|
if (f->type == V4L2_TUNER_RADIO)
|
|
|
|
radio_enable(btv);
|
2013-02-06 21:49:14 +07:00
|
|
|
f->frequency = f->type == V4L2_TUNER_RADIO ?
|
|
|
|
btv->radio_freq : btv->tv_freq;
|
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-03-19 14:09:26 +07:00
|
|
|
static void bttv_set_frequency(struct bttv *btv, const struct v4l2_frequency *f)
|
2013-02-06 21:49:14 +07:00
|
|
|
{
|
2013-03-19 14:09:26 +07:00
|
|
|
struct v4l2_frequency new_freq = *f;
|
|
|
|
|
2013-02-06 21:49:14 +07:00
|
|
|
bttv_call_all(btv, tuner, s_frequency, f);
|
|
|
|
/* s_frequency may clamp the frequency, so get the actual
|
|
|
|
frequency before assigning radio/tv_freq. */
|
2013-03-19 14:09:26 +07:00
|
|
|
bttv_call_all(btv, tuner, g_frequency, &new_freq);
|
|
|
|
if (new_freq.type == V4L2_TUNER_RADIO) {
|
2013-02-10 19:24:14 +07:00
|
|
|
radio_enable(btv);
|
2013-03-19 14:09:26 +07:00
|
|
|
btv->radio_freq = new_freq.frequency;
|
2015-01-16 03:10:45 +07:00
|
|
|
if (btv->has_tea575x) {
|
|
|
|
btv->tea.freq = btv->radio_freq;
|
|
|
|
snd_tea575x_set_freq(&btv->tea);
|
|
|
|
}
|
2013-02-06 21:49:14 +07:00
|
|
|
} else {
|
2013-03-19 14:09:26 +07:00
|
|
|
btv->tv_freq = new_freq.frequency;
|
2013-02-06 21:49:14 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-28 08:22:59 +07:00
|
|
|
static int bttv_s_frequency(struct file *file, void *priv,
|
2013-03-19 14:09:26 +07:00
|
|
|
const struct v4l2_frequency *f)
|
2007-12-28 08:20:58 +07:00
|
|
|
{
|
|
|
|
struct bttv_fh *fh = priv;
|
|
|
|
struct bttv *btv = fh->btv;
|
|
|
|
|
2013-02-06 21:43:07 +07:00
|
|
|
if (f->tuner)
|
2007-12-28 08:20:58 +07:00
|
|
|
return -EINVAL;
|
2010-09-15 18:18:31 +07:00
|
|
|
|
2013-02-06 21:49:14 +07:00
|
|
|
bttv_set_frequency(btv, f);
|
2007-12-28 08:20:58 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-12-28 08:22:59 +07:00
|
|
|
static int bttv_log_status(struct file *file, void *f)
|
2007-12-28 08:20:58 +07:00
|
|
|
{
|
2013-02-06 22:40:28 +07:00
|
|
|
struct video_device *vdev = video_devdata(file);
|
2007-12-28 08:20:58 +07:00
|
|
|
struct bttv_fh *fh = f;
|
|
|
|
struct bttv *btv = fh->btv;
|
|
|
|
|
2013-02-06 22:40:28 +07:00
|
|
|
v4l2_ctrl_handler_log_status(vdev->ctrl_handler, btv->c.v4l2_dev.name);
|
2009-03-28 18:29:00 +07:00
|
|
|
bttv_call_all(btv, core, log_status);
|
2007-12-28 08:20:58 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_VIDEO_ADV_DEBUG
|
2007-12-28 08:22:59 +07:00
|
|
|
static int bttv_g_register(struct file *file, void *f,
|
2008-12-30 17:14:19 +07:00
|
|
|
struct v4l2_dbg_register *reg)
|
2007-12-28 08:20:58 +07:00
|
|
|
{
|
|
|
|
struct bttv_fh *fh = f;
|
|
|
|
struct bttv *btv = fh->btv;
|
|
|
|
|
|
|
|
/* bt848 has a 12-bit register space */
|
|
|
|
reg->reg &= 0xfff;
|
|
|
|
reg->val = btread(reg->reg);
|
2008-12-30 17:14:19 +07:00
|
|
|
reg->size = 1;
|
2007-12-28 08:20:58 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-12-28 08:22:59 +07:00
|
|
|
static int bttv_s_register(struct file *file, void *f,
|
2013-03-24 18:28:46 +07:00
|
|
|
const struct v4l2_dbg_register *reg)
|
2007-12-28 08:20:58 +07:00
|
|
|
{
|
|
|
|
struct bttv_fh *fh = f;
|
|
|
|
struct bttv *btv = fh->btv;
|
|
|
|
|
|
|
|
/* bt848 has a 12-bit register space */
|
2013-03-24 18:28:46 +07:00
|
|
|
btwrite(reg->val, reg->reg & 0xfff);
|
2007-12-28 08:20:58 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Given cropping boundaries b and the scaled width and height of a
|
|
|
|
single field or frame, which must not exceed hardware limits, this
|
|
|
|
function adjusts the cropping parameters c. */
|
|
|
|
static void
|
|
|
|
bttv_crop_adjust (struct bttv_crop * c,
|
|
|
|
const struct v4l2_rect * b,
|
|
|
|
__s32 width,
|
|
|
|
__s32 height,
|
|
|
|
enum v4l2_field field)
|
|
|
|
{
|
|
|
|
__s32 frame_height = height << !V4L2_FIELD_HAS_BOTH(field);
|
|
|
|
__s32 max_left;
|
|
|
|
__s32 max_top;
|
|
|
|
|
|
|
|
if (width < c->min_scaled_width) {
|
|
|
|
/* Max. hor. scale factor 16:1. */
|
|
|
|
c->rect.width = width * 16;
|
|
|
|
} else if (width > c->max_scaled_width) {
|
|
|
|
/* Min. hor. scale factor 1:1. */
|
|
|
|
c->rect.width = width;
|
|
|
|
|
|
|
|
max_left = b->left + b->width - width;
|
|
|
|
max_left = min(max_left, (__s32) MAX_HDELAY);
|
|
|
|
if (c->rect.left > max_left)
|
|
|
|
c->rect.left = max_left;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (height < c->min_scaled_height) {
|
|
|
|
/* Max. vert. scale factor 16:1, single fields 8:1. */
|
|
|
|
c->rect.height = height * 16;
|
|
|
|
} else if (frame_height > c->max_scaled_height) {
|
|
|
|
/* Min. vert. scale factor 1:1.
|
|
|
|
Top and height count field lines times two. */
|
|
|
|
c->rect.height = (frame_height + 1) & ~1;
|
|
|
|
|
|
|
|
max_top = b->top + b->height - c->rect.height;
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
if (c->rect.top > max_top)
|
|
|
|
c->rect.top = max_top;
|
|
|
|
}
|
|
|
|
|
|
|
|
bttv_crop_calc_limits(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns an error if scaling to a frame or single field with the given
|
|
|
|
width and height is not possible with the current cropping parameters
|
|
|
|
and width aligned according to width_mask. If adjust_size is TRUE the
|
|
|
|
function may adjust the width and/or height instead, rounding width
|
|
|
|
to (width + width_bias) & width_mask. If adjust_crop is TRUE it may
|
|
|
|
also adjust the current cropping parameters to get closer to the
|
|
|
|
desired image size. */
|
|
|
|
static int
|
2010-09-14 22:19:51 +07:00
|
|
|
limit_scaled_size_lock (struct bttv_fh * fh,
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
__s32 * width,
|
|
|
|
__s32 * height,
|
|
|
|
enum v4l2_field field,
|
|
|
|
unsigned int width_mask,
|
|
|
|
unsigned int width_bias,
|
|
|
|
int adjust_size,
|
|
|
|
int adjust_crop)
|
|
|
|
{
|
|
|
|
struct bttv *btv = fh->btv;
|
|
|
|
const struct v4l2_rect *b;
|
|
|
|
struct bttv_crop *c;
|
|
|
|
__s32 min_width;
|
|
|
|
__s32 min_height;
|
|
|
|
__s32 max_width;
|
|
|
|
__s32 max_height;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
BUG_ON((int) width_mask >= 0 ||
|
|
|
|
width_bias >= (unsigned int) -width_mask);
|
|
|
|
|
|
|
|
/* Make sure tvnorm, vbi_end and the current cropping parameters
|
|
|
|
remain consistent until we're done. */
|
|
|
|
|
|
|
|
b = &bttv_tvnorms[btv->tvnorm].cropcap.bounds;
|
|
|
|
|
|
|
|
/* Do crop - use current, don't - use default parameters. */
|
|
|
|
c = &btv->crop[!!fh->do_crop];
|
|
|
|
|
|
|
|
if (fh->do_crop
|
|
|
|
&& adjust_size
|
|
|
|
&& adjust_crop
|
|
|
|
&& !locked_btres(btv, VIDEO_RESOURCES)) {
|
|
|
|
min_width = 48;
|
|
|
|
min_height = 32;
|
|
|
|
|
|
|
|
/* We cannot scale up. When the scaled image is larger
|
|
|
|
than crop.rect we adjust the crop.rect as required
|
|
|
|
by the V4L2 spec, hence cropcap.bounds are our limit. */
|
2013-11-26 15:31:42 +07:00
|
|
|
max_width = min_t(unsigned int, b->width, MAX_HACTIVE);
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
max_height = b->height;
|
|
|
|
|
|
|
|
/* We cannot capture the same line as video and VBI data.
|
|
|
|
Note btv->vbi_end is really a minimum, see
|
|
|
|
bttv_vbi_try_fmt(). */
|
|
|
|
if (btv->vbi_end > b->top) {
|
|
|
|
max_height -= btv->vbi_end - b->top;
|
|
|
|
rc = -EBUSY;
|
|
|
|
if (min_height > max_height)
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
rc = -EBUSY;
|
|
|
|
if (btv->vbi_end > c->rect.top)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
min_width = c->min_scaled_width;
|
|
|
|
min_height = c->min_scaled_height;
|
|
|
|
max_width = c->max_scaled_width;
|
|
|
|
max_height = c->max_scaled_height;
|
|
|
|
|
|
|
|
adjust_crop = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
min_width = (min_width - width_mask - 1) & width_mask;
|
|
|
|
max_width = max_width & width_mask;
|
|
|
|
|
|
|
|
/* Max. scale factor is 16:1 for frames, 8:1 for fields. */
|
|
|
|
min_height = min_height;
|
|
|
|
/* Min. scale factor is 1:1. */
|
|
|
|
max_height >>= !V4L2_FIELD_HAS_BOTH(field);
|
|
|
|
|
|
|
|
if (adjust_size) {
|
|
|
|
*width = clamp(*width, min_width, max_width);
|
|
|
|
*height = clamp(*height, min_height, max_height);
|
|
|
|
|
|
|
|
/* Round after clamping to avoid overflow. */
|
|
|
|
*width = (*width + width_bias) & width_mask;
|
|
|
|
|
|
|
|
if (adjust_crop) {
|
|
|
|
bttv_crop_adjust(c, b, *width, *height, field);
|
|
|
|
|
|
|
|
if (btv->vbi_end > c->rect.top) {
|
|
|
|
/* Move the crop window out of the way. */
|
|
|
|
c->rect.top = btv->vbi_end;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
rc = -EINVAL;
|
|
|
|
if (*width < min_width ||
|
|
|
|
*height < min_height ||
|
|
|
|
*width > max_width ||
|
|
|
|
*height > max_height ||
|
|
|
|
0 != (*width & ~width_mask))
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = 0; /* success */
|
|
|
|
|
|
|
|
fail:
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns an error if the given overlay window dimensions are not
|
|
|
|
possible with the current cropping parameters. If adjust_size is
|
|
|
|
TRUE the function may adjust the window width and/or height
|
|
|
|
instead, however it always rounds the horizontal position and
|
|
|
|
width as btcx_align() does. If adjust_crop is TRUE the function
|
|
|
|
may also adjust the current cropping parameters to get closer
|
|
|
|
to the desired window size. */
|
|
|
|
static int
|
2013-02-07 17:56:11 +07:00
|
|
|
verify_window_lock(struct bttv_fh *fh, struct v4l2_window *win,
|
|
|
|
int adjust_size, int adjust_crop)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
enum v4l2_field field;
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
unsigned int width_mask;
|
|
|
|
int rc;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2013-02-07 17:56:11 +07:00
|
|
|
if (win->w.width < 48)
|
|
|
|
win->w.width = 48;
|
|
|
|
if (win->w.height < 32)
|
|
|
|
win->w.height = 32;
|
2005-04-17 05:20:36 +07:00
|
|
|
if (win->clipcount > 2048)
|
2013-02-07 17:56:11 +07:00
|
|
|
win->clipcount = 2048;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2013-02-07 17:56:11 +07:00
|
|
|
win->chromakey = 0;
|
|
|
|
win->global_alpha = 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
field = win->field;
|
|
|
|
|
2013-02-07 17:56:11 +07:00
|
|
|
switch (field) {
|
|
|
|
case V4L2_FIELD_TOP:
|
|
|
|
case V4L2_FIELD_BOTTOM:
|
|
|
|
case V4L2_FIELD_INTERLACED:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
field = V4L2_FIELD_ANY;
|
|
|
|
break;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
if (V4L2_FIELD_ANY == field) {
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
__s32 height2;
|
|
|
|
|
|
|
|
height2 = fh->btv->crop[!!fh->do_crop].rect.height >> 1;
|
|
|
|
field = (win->w.height > height2)
|
2005-04-17 05:20:36 +07:00
|
|
|
? V4L2_FIELD_INTERLACED
|
|
|
|
: V4L2_FIELD_TOP;
|
|
|
|
}
|
2013-02-07 17:56:11 +07:00
|
|
|
win->field = field;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
if (NULL == fh->ovfmt)
|
2005-04-17 05:20:36 +07:00
|
|
|
return -EINVAL;
|
2013-02-07 17:56:11 +07:00
|
|
|
/* 4-byte alignment. */
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
width_mask = ~0;
|
|
|
|
switch (fh->ovfmt->depth) {
|
|
|
|
case 8:
|
|
|
|
case 24:
|
|
|
|
width_mask = ~3;
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
width_mask = ~1;
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BUG();
|
|
|
|
}
|
|
|
|
|
|
|
|
win->w.width -= win->w.left & ~width_mask;
|
|
|
|
win->w.left = (win->w.left - width_mask - 1) & width_mask;
|
|
|
|
|
2010-09-14 22:19:51 +07:00
|
|
|
rc = limit_scaled_size_lock(fh, &win->w.width, &win->w.height,
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
field, width_mask,
|
|
|
|
/* width_bias: round down */ 0,
|
|
|
|
adjust_size, adjust_crop);
|
|
|
|
if (0 != rc)
|
|
|
|
return rc;
|
2005-04-17 05:20:36 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-09-14 22:19:51 +07:00
|
|
|
static int setup_window_lock(struct bttv_fh *fh, struct bttv *btv,
|
2005-04-17 05:20:36 +07:00
|
|
|
struct v4l2_window *win, int fixup)
|
|
|
|
{
|
|
|
|
struct v4l2_clip *clips = NULL;
|
|
|
|
int n,size,retval = 0;
|
|
|
|
|
|
|
|
if (NULL == fh->ovfmt)
|
|
|
|
return -EINVAL;
|
|
|
|
if (!(fh->ovfmt->flags & FORMAT_FLAGS_PACKED))
|
|
|
|
return -EINVAL;
|
2010-09-14 22:19:51 +07:00
|
|
|
retval = verify_window_lock(fh, win,
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
/* adjust_size */ fixup,
|
|
|
|
/* adjust_crop */ fixup);
|
2005-04-17 05:20:36 +07:00
|
|
|
if (0 != retval)
|
|
|
|
return retval;
|
|
|
|
|
|
|
|
/* copy clips -- luckily v4l1 + v4l2 are binary
|
|
|
|
compatible here ...*/
|
|
|
|
n = win->clipcount;
|
|
|
|
size = sizeof(*clips)*(n+4);
|
|
|
|
clips = kmalloc(size,GFP_KERNEL);
|
|
|
|
if (NULL == clips)
|
|
|
|
return -ENOMEM;
|
|
|
|
if (n > 0) {
|
|
|
|
if (copy_from_user(clips,win->clips,sizeof(struct v4l2_clip)*n)) {
|
|
|
|
kfree(clips);
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
}
|
2010-09-15 18:18:31 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* clip against screen */
|
|
|
|
if (NULL != btv->fbuf.base)
|
|
|
|
n = btcx_screen_clips(btv->fbuf.fmt.width, btv->fbuf.fmt.height,
|
|
|
|
&win->w, clips, n);
|
|
|
|
btcx_sort_clips(clips,n);
|
|
|
|
|
|
|
|
/* 4-byte alignments */
|
|
|
|
switch (fh->ovfmt->depth) {
|
|
|
|
case 8:
|
|
|
|
case 24:
|
|
|
|
btcx_align(&win->w, clips, n, 3);
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
btcx_align(&win->w, clips, n, 1);
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
/* no alignment fixups needed */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BUG();
|
|
|
|
}
|
|
|
|
|
2008-01-31 23:57:53 +07:00
|
|
|
kfree(fh->ov.clips);
|
2005-04-17 05:20:36 +07:00
|
|
|
fh->ov.clips = clips;
|
|
|
|
fh->ov.nclips = n;
|
|
|
|
|
|
|
|
fh->ov.w = win->w;
|
|
|
|
fh->ov.field = win->field;
|
|
|
|
fh->ov.setup_ok = 1;
|
2010-09-15 18:18:31 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
btv->init.ov.w.width = win->w.width;
|
|
|
|
btv->init.ov.w.height = win->w.height;
|
|
|
|
btv->init.ov.field = win->field;
|
|
|
|
|
|
|
|
/* update overlay if needed */
|
|
|
|
retval = 0;
|
|
|
|
if (check_btres(fh, RESOURCE_OVERLAY)) {
|
|
|
|
struct bttv_buffer *new;
|
|
|
|
|
2008-04-23 00:42:13 +07:00
|
|
|
new = videobuf_sg_alloc(sizeof(*new));
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
new->crop = btv->crop[!!fh->do_crop].rect;
|
2005-04-17 05:20:36 +07:00
|
|
|
bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new);
|
|
|
|
retval = bttv_switch_overlay(btv,fh,new);
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static struct videobuf_queue* bttv_queue(struct bttv_fh *fh)
|
|
|
|
{
|
|
|
|
struct videobuf_queue* q = NULL;
|
|
|
|
|
|
|
|
switch (fh->type) {
|
|
|
|
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
|
|
|
|
q = &fh->cap;
|
|
|
|
break;
|
|
|
|
case V4L2_BUF_TYPE_VBI_CAPTURE:
|
|
|
|
q = &fh->vbi;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BUG();
|
|
|
|
}
|
|
|
|
return q;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int bttv_resource(struct bttv_fh *fh)
|
|
|
|
{
|
|
|
|
int res = 0;
|
|
|
|
|
|
|
|
switch (fh->type) {
|
|
|
|
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
res = RESOURCE_VIDEO_STREAM;
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
case V4L2_BUF_TYPE_VBI_CAPTURE:
|
|
|
|
res = RESOURCE_VBI;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BUG();
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int bttv_switch_type(struct bttv_fh *fh, enum v4l2_buf_type type)
|
|
|
|
{
|
|
|
|
struct videobuf_queue *q = bttv_queue(fh);
|
|
|
|
int res = bttv_resource(fh);
|
|
|
|
|
|
|
|
if (check_btres(fh,res))
|
|
|
|
return -EBUSY;
|
|
|
|
if (videobuf_queue_is_busy(q))
|
|
|
|
return -EBUSY;
|
|
|
|
fh->type = type;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-12-01 15:51:33 +07:00
|
|
|
static void
|
|
|
|
pix_format_set_size (struct v4l2_pix_format * f,
|
|
|
|
const struct bttv_format * fmt,
|
|
|
|
unsigned int width,
|
|
|
|
unsigned int height)
|
|
|
|
{
|
|
|
|
f->width = width;
|
|
|
|
f->height = height;
|
|
|
|
|
|
|
|
if (fmt->flags & FORMAT_FLAGS_PLANAR) {
|
|
|
|
f->bytesperline = width; /* Y plane */
|
|
|
|
f->sizeimage = (width * height * fmt->depth) >> 3;
|
|
|
|
} else {
|
|
|
|
f->bytesperline = (width * fmt->depth) >> 3;
|
|
|
|
f->sizeimage = height * f->bytesperline;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-28 22:16:41 +07:00
|
|
|
static int bttv_g_fmt_vid_cap(struct file *file, void *priv,
|
2007-12-28 08:20:58 +07:00
|
|
|
struct v4l2_format *f)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2007-12-28 08:20:58 +07:00
|
|
|
struct bttv_fh *fh = priv;
|
|
|
|
|
|
|
|
pix_format_set_size(&f->fmt.pix, fh->fmt,
|
|
|
|
fh->width, fh->height);
|
|
|
|
f->fmt.pix.field = fh->cap.field;
|
|
|
|
f->fmt.pix.pixelformat = fh->fmt->fourcc;
|
2013-02-06 21:58:59 +07:00
|
|
|
f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
|
2007-12-28 08:20:58 +07:00
|
|
|
|
|
|
|
return 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2008-05-28 22:16:41 +07:00
|
|
|
static int bttv_g_fmt_vid_overlay(struct file *file, void *priv,
|
2007-12-28 08:20:58 +07:00
|
|
|
struct v4l2_format *f)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2007-12-28 08:20:58 +07:00
|
|
|
struct bttv_fh *fh = priv;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
f->fmt.win.w = fh->ov.w;
|
|
|
|
f->fmt.win.field = fh->ov.field;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
return 0;
|
|
|
|
}
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
2008-05-28 22:16:41 +07:00
|
|
|
static int bttv_try_fmt_vid_cap(struct file *file, void *priv,
|
2007-12-28 08:20:58 +07:00
|
|
|
struct v4l2_format *f)
|
|
|
|
{
|
|
|
|
const struct bttv_format *fmt;
|
|
|
|
struct bttv_fh *fh = priv;
|
|
|
|
struct bttv *btv = fh->btv;
|
|
|
|
enum v4l2_field field;
|
|
|
|
__s32 width, height;
|
2013-02-06 22:03:30 +07:00
|
|
|
__s32 height2;
|
2007-12-28 08:28:31 +07:00
|
|
|
int rc;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
fmt = format_by_fourcc(f->fmt.pix.pixelformat);
|
|
|
|
if (NULL == fmt)
|
|
|
|
return -EINVAL;
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
field = f->fmt.pix.field;
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
switch (field) {
|
|
|
|
case V4L2_FIELD_TOP:
|
|
|
|
case V4L2_FIELD_BOTTOM:
|
|
|
|
case V4L2_FIELD_ALTERNATE:
|
|
|
|
case V4L2_FIELD_INTERLACED:
|
|
|
|
break;
|
2013-02-06 22:03:30 +07:00
|
|
|
case V4L2_FIELD_SEQ_BT:
|
2007-12-28 08:20:58 +07:00
|
|
|
case V4L2_FIELD_SEQ_TB:
|
2013-02-06 22:03:30 +07:00
|
|
|
if (!(fmt->flags & FORMAT_FLAGS_PLANAR)) {
|
|
|
|
field = V4L2_FIELD_SEQ_TB;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* fall through */
|
|
|
|
default: /* FIELD_ANY case */
|
|
|
|
height2 = btv->crop[!!fh->do_crop].rect.height >> 1;
|
|
|
|
field = (f->fmt.pix.height > height2)
|
|
|
|
? V4L2_FIELD_INTERLACED
|
|
|
|
: V4L2_FIELD_BOTTOM;
|
2007-12-28 08:20:58 +07:00
|
|
|
break;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2007-12-28 08:20:58 +07:00
|
|
|
|
|
|
|
width = f->fmt.pix.width;
|
|
|
|
height = f->fmt.pix.height;
|
|
|
|
|
2010-09-14 22:19:51 +07:00
|
|
|
rc = limit_scaled_size_lock(fh, &width, &height, field,
|
2007-12-28 08:28:31 +07:00
|
|
|
/* width_mask: 4 pixels */ ~3,
|
|
|
|
/* width_bias: nearest */ 2,
|
|
|
|
/* adjust_size */ 1,
|
|
|
|
/* adjust_crop */ 0);
|
|
|
|
if (0 != rc)
|
|
|
|
return rc;
|
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
/* update data for the application */
|
|
|
|
f->fmt.pix.field = field;
|
|
|
|
pix_format_set_size(&f->fmt.pix, fmt, width, height);
|
2013-02-06 21:58:59 +07:00
|
|
|
f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
|
2007-12-28 08:20:58 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-05-28 22:16:41 +07:00
|
|
|
static int bttv_try_fmt_vid_overlay(struct file *file, void *priv,
|
2007-12-28 08:20:58 +07:00
|
|
|
struct v4l2_format *f)
|
|
|
|
{
|
|
|
|
struct bttv_fh *fh = priv;
|
|
|
|
|
2013-02-07 17:56:11 +07:00
|
|
|
verify_window_lock(fh, &f->fmt.win,
|
2007-12-28 08:20:58 +07:00
|
|
|
/* adjust_size */ 1,
|
|
|
|
/* adjust_crop */ 0);
|
2013-02-07 17:56:11 +07:00
|
|
|
return 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2008-05-28 22:16:41 +07:00
|
|
|
static int bttv_s_fmt_vid_cap(struct file *file, void *priv,
|
2007-12-28 08:20:58 +07:00
|
|
|
struct v4l2_format *f)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
int retval;
|
2007-12-28 08:20:58 +07:00
|
|
|
const struct bttv_format *fmt;
|
|
|
|
struct bttv_fh *fh = priv;
|
|
|
|
struct bttv *btv = fh->btv;
|
2007-12-28 08:28:31 +07:00
|
|
|
__s32 width, height;
|
|
|
|
enum v4l2_field field;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
retval = bttv_switch_type(fh, f->type);
|
|
|
|
if (0 != retval)
|
|
|
|
return retval;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-05-28 22:16:41 +07:00
|
|
|
retval = bttv_try_fmt_vid_cap(file, priv, f);
|
2007-12-28 08:20:58 +07:00
|
|
|
if (0 != retval)
|
|
|
|
return retval;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-28 08:28:31 +07:00
|
|
|
width = f->fmt.pix.width;
|
|
|
|
height = f->fmt.pix.height;
|
|
|
|
field = f->fmt.pix.field;
|
|
|
|
|
2010-09-14 22:19:51 +07:00
|
|
|
retval = limit_scaled_size_lock(fh, &width, &height, f->fmt.pix.field,
|
2007-12-28 08:28:31 +07:00
|
|
|
/* width_mask: 4 pixels */ ~3,
|
|
|
|
/* width_bias: nearest */ 2,
|
|
|
|
/* adjust_size */ 1,
|
|
|
|
/* adjust_crop */ 1);
|
|
|
|
if (0 != retval)
|
|
|
|
return retval;
|
|
|
|
|
|
|
|
f->fmt.pix.field = field;
|
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
fmt = format_by_fourcc(f->fmt.pix.pixelformat);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
/* update our state informations */
|
|
|
|
fh->fmt = fmt;
|
|
|
|
fh->cap.field = f->fmt.pix.field;
|
|
|
|
fh->cap.last = V4L2_FIELD_NONE;
|
|
|
|
fh->width = f->fmt.pix.width;
|
|
|
|
fh->height = f->fmt.pix.height;
|
|
|
|
btv->init.fmt = fmt;
|
|
|
|
btv->init.width = f->fmt.pix.width;
|
|
|
|
btv->init.height = f->fmt.pix.height;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-05-28 22:16:41 +07:00
|
|
|
static int bttv_s_fmt_vid_overlay(struct file *file, void *priv,
|
2007-12-28 08:20:58 +07:00
|
|
|
struct v4l2_format *f)
|
|
|
|
{
|
|
|
|
struct bttv_fh *fh = priv;
|
|
|
|
struct bttv *btv = fh->btv;
|
|
|
|
|
2007-12-28 08:28:31 +07:00
|
|
|
if (no_overlay > 0) {
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_err("V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n");
|
2005-04-17 05:20:36 +07:00
|
|
|
return -EINVAL;
|
2007-12-28 08:28:31 +07:00
|
|
|
}
|
2007-12-28 08:20:58 +07:00
|
|
|
|
2010-09-14 22:19:51 +07:00
|
|
|
return setup_window_lock(fh, btv, &f->fmt.win, 1);
|
2007-12-28 08:20:58 +07:00
|
|
|
}
|
|
|
|
|
2007-12-28 08:22:59 +07:00
|
|
|
static int bttv_querycap(struct file *file, void *priv,
|
2007-12-28 08:20:58 +07:00
|
|
|
struct v4l2_capability *cap)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2012-09-09 19:03:29 +07:00
|
|
|
struct video_device *vdev = video_devdata(file);
|
2007-12-28 08:20:58 +07:00
|
|
|
struct bttv_fh *fh = priv;
|
|
|
|
struct bttv *btv = fh->btv;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
if (0 == v4l2)
|
|
|
|
return -EINVAL;
|
2006-01-10 00:32:31 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
strlcpy(cap->driver, "bttv", sizeof(cap->driver));
|
2015-03-09 23:34:02 +07:00
|
|
|
strlcpy(cap->card, btv->video_dev.name, sizeof(cap->card));
|
2007-12-28 08:20:58 +07:00
|
|
|
snprintf(cap->bus_info, sizeof(cap->bus_info),
|
|
|
|
"PCI:%s", pci_name(btv->c.pci));
|
|
|
|
cap->capabilities =
|
|
|
|
V4L2_CAP_VIDEO_CAPTURE |
|
|
|
|
V4L2_CAP_READWRITE |
|
2012-09-09 19:03:29 +07:00
|
|
|
V4L2_CAP_STREAMING |
|
|
|
|
V4L2_CAP_DEVICE_CAPS;
|
2007-12-28 08:20:58 +07:00
|
|
|
if (no_overlay <= 0)
|
|
|
|
cap->capabilities |= V4L2_CAP_VIDEO_OVERLAY;
|
2015-03-09 23:34:02 +07:00
|
|
|
if (video_is_registered(&btv->vbi_dev))
|
2012-09-09 19:03:29 +07:00
|
|
|
cap->capabilities |= V4L2_CAP_VBI_CAPTURE;
|
2015-03-09 23:34:02 +07:00
|
|
|
if (video_is_registered(&btv->radio_dev))
|
2012-09-09 19:03:29 +07:00
|
|
|
cap->capabilities |= V4L2_CAP_RADIO;
|
2007-12-28 08:20:58 +07:00
|
|
|
|
2010-09-15 18:18:31 +07:00
|
|
|
/*
|
|
|
|
* No need to lock here: those vars are initialized during board
|
|
|
|
* probe and remains untouched during the rest of the driver lifecycle
|
|
|
|
*/
|
|
|
|
if (btv->has_saa6588)
|
|
|
|
cap->capabilities |= V4L2_CAP_RDS_CAPTURE;
|
2009-01-29 07:32:59 +07:00
|
|
|
if (btv->tuner_type != TUNER_ABSENT)
|
2007-12-28 08:20:58 +07:00
|
|
|
cap->capabilities |= V4L2_CAP_TUNER;
|
2012-09-09 19:03:29 +07:00
|
|
|
if (vdev->vfl_type == VFL_TYPE_GRABBER)
|
|
|
|
cap->device_caps = cap->capabilities &
|
|
|
|
(V4L2_CAP_VIDEO_CAPTURE |
|
|
|
|
V4L2_CAP_READWRITE |
|
|
|
|
V4L2_CAP_STREAMING |
|
|
|
|
V4L2_CAP_VIDEO_OVERLAY |
|
|
|
|
V4L2_CAP_TUNER);
|
|
|
|
else if (vdev->vfl_type == VFL_TYPE_VBI)
|
|
|
|
cap->device_caps = cap->capabilities &
|
|
|
|
(V4L2_CAP_VBI_CAPTURE |
|
|
|
|
V4L2_CAP_READWRITE |
|
|
|
|
V4L2_CAP_STREAMING |
|
|
|
|
V4L2_CAP_TUNER);
|
|
|
|
else {
|
|
|
|
cap->device_caps = V4L2_CAP_RADIO | V4L2_CAP_TUNER;
|
|
|
|
if (btv->has_saa6588)
|
|
|
|
cap->device_caps |= V4L2_CAP_READWRITE |
|
|
|
|
V4L2_CAP_RDS_CAPTURE;
|
2015-01-16 16:58:32 +07:00
|
|
|
if (btv->has_tea575x)
|
|
|
|
cap->device_caps |= V4L2_CAP_HW_FREQ_SEEK;
|
2012-09-09 19:03:29 +07:00
|
|
|
}
|
2007-12-28 08:20:58 +07:00
|
|
|
return 0;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-28 08:28:31 +07:00
|
|
|
static int bttv_enum_fmt_cap_ovr(struct v4l2_fmtdesc *f)
|
|
|
|
{
|
|
|
|
int index = -1, i;
|
|
|
|
|
|
|
|
for (i = 0; i < FORMATS; i++) {
|
|
|
|
if (formats[i].fourcc != -1)
|
|
|
|
index++;
|
|
|
|
if ((unsigned int)index == f->index)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (FORMATS == i)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
f->pixelformat = formats[i].fourcc;
|
|
|
|
strlcpy(f->description, formats[i].name, sizeof(f->description));
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2008-05-28 22:16:41 +07:00
|
|
|
static int bttv_enum_fmt_vid_cap(struct file *file, void *priv,
|
2007-12-28 08:20:58 +07:00
|
|
|
struct v4l2_fmtdesc *f)
|
|
|
|
{
|
2007-12-28 08:28:31 +07:00
|
|
|
int rc = bttv_enum_fmt_cap_ovr(f);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-28 08:28:31 +07:00
|
|
|
if (rc < 0)
|
|
|
|
return rc;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
return 0;
|
|
|
|
}
|
2007-10-06 02:26:27 +07:00
|
|
|
|
2008-05-28 22:16:41 +07:00
|
|
|
static int bttv_enum_fmt_vid_overlay(struct file *file, void *priv,
|
2007-12-28 08:20:58 +07:00
|
|
|
struct v4l2_fmtdesc *f)
|
|
|
|
{
|
2007-12-28 08:28:31 +07:00
|
|
|
int rc;
|
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
if (no_overlay > 0) {
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_err("V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n");
|
2007-12-28 08:20:58 +07:00
|
|
|
return -EINVAL;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2007-12-28 08:28:31 +07:00
|
|
|
rc = bttv_enum_fmt_cap_ovr(f);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-28 08:28:31 +07:00
|
|
|
if (rc < 0)
|
|
|
|
return rc;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-28 08:28:31 +07:00
|
|
|
if (!(formats[rc].flags & FORMAT_FLAGS_PACKED))
|
|
|
|
return -EINVAL;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-12-28 08:22:59 +07:00
|
|
|
static int bttv_g_fbuf(struct file *file, void *f,
|
2007-12-28 08:20:58 +07:00
|
|
|
struct v4l2_framebuffer *fb)
|
|
|
|
{
|
|
|
|
struct bttv_fh *fh = f;
|
|
|
|
struct bttv *btv = fh->btv;
|
|
|
|
|
|
|
|
*fb = btv->fbuf;
|
|
|
|
fb->capability = V4L2_FBUF_CAP_LIST_CLIPPING;
|
2013-02-06 22:00:03 +07:00
|
|
|
fb->flags = V4L2_FBUF_FLAG_PRIMARY;
|
2007-12-28 08:20:58 +07:00
|
|
|
if (fh->ovfmt)
|
|
|
|
fb->fmt.pixelformat = fh->ovfmt->fourcc;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-12-28 08:22:59 +07:00
|
|
|
static int bttv_overlay(struct file *file, void *f, unsigned int on)
|
2007-12-28 08:20:58 +07:00
|
|
|
{
|
|
|
|
struct bttv_fh *fh = f;
|
|
|
|
struct bttv *btv = fh->btv;
|
|
|
|
struct bttv_buffer *new;
|
2010-09-15 18:18:31 +07:00
|
|
|
int retval = 0;
|
2007-12-28 08:20:58 +07:00
|
|
|
|
|
|
|
if (on) {
|
|
|
|
/* verify args */
|
2010-09-15 18:18:31 +07:00
|
|
|
if (unlikely(!btv->fbuf.base)) {
|
2007-12-28 08:20:58 +07:00
|
|
|
return -EINVAL;
|
2010-09-15 18:18:31 +07:00
|
|
|
}
|
|
|
|
if (unlikely(!fh->ov.setup_ok)) {
|
2011-08-22 05:56:48 +07:00
|
|
|
dprintk("%d: overlay: !setup_ok\n", btv->c.nr);
|
2010-09-15 18:18:31 +07:00
|
|
|
retval = -EINVAL;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2010-09-15 18:18:31 +07:00
|
|
|
if (retval)
|
|
|
|
return retval;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2007-12-28 08:20:58 +07:00
|
|
|
|
2010-09-14 22:19:51 +07:00
|
|
|
if (!check_alloc_btres_lock(btv, fh, RESOURCE_OVERLAY))
|
2007-12-28 08:20:58 +07:00
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
if (on) {
|
|
|
|
fh->ov.tvnorm = btv->tvnorm;
|
2008-04-23 00:42:13 +07:00
|
|
|
new = videobuf_sg_alloc(sizeof(*new));
|
2008-02-14 02:38:11 +07:00
|
|
|
new->crop = btv->crop[!!fh->do_crop].rect;
|
2007-12-28 08:20:58 +07:00
|
|
|
bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new);
|
|
|
|
} else {
|
|
|
|
new = NULL;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
/* switch over */
|
|
|
|
retval = bttv_switch_overlay(btv, fh, new);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2007-12-28 08:22:59 +07:00
|
|
|
static int bttv_s_fbuf(struct file *file, void *f,
|
2012-09-04 20:26:45 +07:00
|
|
|
const struct v4l2_framebuffer *fb)
|
2007-12-28 08:20:58 +07:00
|
|
|
{
|
|
|
|
struct bttv_fh *fh = f;
|
|
|
|
struct bttv *btv = fh->btv;
|
|
|
|
const struct bttv_format *fmt;
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
if (!capable(CAP_SYS_ADMIN) &&
|
|
|
|
!capable(CAP_SYS_RAWIO))
|
|
|
|
return -EPERM;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
/* check args */
|
|
|
|
fmt = format_by_fourcc(fb->fmt.pixelformat);
|
|
|
|
if (NULL == fmt)
|
|
|
|
return -EINVAL;
|
|
|
|
if (0 == (fmt->flags & FORMAT_FLAGS_PACKED))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
retval = -EINVAL;
|
|
|
|
if (fb->flags & V4L2_FBUF_FLAG_OVERLAY) {
|
|
|
|
__s32 width = fb->fmt.width;
|
|
|
|
__s32 height = fb->fmt.height;
|
|
|
|
|
2010-09-14 22:19:51 +07:00
|
|
|
retval = limit_scaled_size_lock(fh, &width, &height,
|
2007-12-28 08:20:58 +07:00
|
|
|
V4L2_FIELD_INTERLACED,
|
|
|
|
/* width_mask */ ~3,
|
|
|
|
/* width_bias */ 2,
|
|
|
|
/* adjust_size */ 0,
|
|
|
|
/* adjust_crop */ 0);
|
|
|
|
if (0 != retval)
|
|
|
|
return retval;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2007-10-26 21:01:08 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
/* ok, accept it */
|
|
|
|
btv->fbuf.base = fb->base;
|
|
|
|
btv->fbuf.fmt.width = fb->fmt.width;
|
|
|
|
btv->fbuf.fmt.height = fb->fmt.height;
|
|
|
|
if (0 != fb->fmt.bytesperline)
|
|
|
|
btv->fbuf.fmt.bytesperline = fb->fmt.bytesperline;
|
|
|
|
else
|
|
|
|
btv->fbuf.fmt.bytesperline = btv->fbuf.fmt.width*fmt->depth/8;
|
2007-10-26 21:01:08 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
retval = 0;
|
|
|
|
fh->ovfmt = fmt;
|
|
|
|
btv->init.ovfmt = fmt;
|
|
|
|
if (fb->flags & V4L2_FBUF_FLAG_OVERLAY) {
|
|
|
|
fh->ov.w.left = 0;
|
|
|
|
fh->ov.w.top = 0;
|
|
|
|
fh->ov.w.width = fb->fmt.width;
|
|
|
|
fh->ov.w.height = fb->fmt.height;
|
|
|
|
btv->init.ov.w.width = fb->fmt.width;
|
|
|
|
btv->init.ov.w.height = fb->fmt.height;
|
2015-04-29 19:41:34 +07:00
|
|
|
|
|
|
|
kfree(fh->ov.clips);
|
2007-12-28 08:20:58 +07:00
|
|
|
fh->ov.clips = NULL;
|
|
|
|
fh->ov.nclips = 0;
|
|
|
|
|
|
|
|
if (check_btres(fh, RESOURCE_OVERLAY)) {
|
|
|
|
struct bttv_buffer *new;
|
2007-10-26 21:01:08 +07:00
|
|
|
|
2008-04-23 00:42:13 +07:00
|
|
|
new = videobuf_sg_alloc(sizeof(*new));
|
2007-12-28 08:20:58 +07:00
|
|
|
new->crop = btv->crop[!!fh->do_crop].rect;
|
2007-10-26 21:01:08 +07:00
|
|
|
bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new);
|
2007-12-28 08:20:58 +07:00
|
|
|
retval = bttv_switch_overlay(btv, fh, new);
|
2007-10-26 21:01:08 +07:00
|
|
|
}
|
|
|
|
}
|
2007-12-28 08:20:58 +07:00
|
|
|
return retval;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-28 08:22:59 +07:00
|
|
|
static int bttv_reqbufs(struct file *file, void *priv,
|
2007-12-28 08:20:58 +07:00
|
|
|
struct v4l2_requestbuffers *p)
|
|
|
|
{
|
|
|
|
struct bttv_fh *fh = priv;
|
|
|
|
return videobuf_reqbufs(bttv_queue(fh), p);
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-28 08:22:59 +07:00
|
|
|
static int bttv_querybuf(struct file *file, void *priv,
|
2007-12-28 08:20:58 +07:00
|
|
|
struct v4l2_buffer *b)
|
|
|
|
{
|
|
|
|
struct bttv_fh *fh = priv;
|
|
|
|
return videobuf_querybuf(bttv_queue(fh), b);
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-28 08:22:59 +07:00
|
|
|
static int bttv_qbuf(struct file *file, void *priv, struct v4l2_buffer *b)
|
2007-12-28 08:20:58 +07:00
|
|
|
{
|
|
|
|
struct bttv_fh *fh = priv;
|
|
|
|
struct bttv *btv = fh->btv;
|
|
|
|
int res = bttv_resource(fh);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2010-09-14 22:19:51 +07:00
|
|
|
if (!check_alloc_btres_lock(btv, fh, res))
|
2007-12-28 08:20:58 +07:00
|
|
|
return -EBUSY;
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
return videobuf_qbuf(bttv_queue(fh), b);
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-28 08:22:59 +07:00
|
|
|
static int bttv_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b)
|
2007-12-28 08:20:58 +07:00
|
|
|
{
|
|
|
|
struct bttv_fh *fh = priv;
|
|
|
|
return videobuf_dqbuf(bttv_queue(fh), b,
|
|
|
|
file->f_flags & O_NONBLOCK);
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-28 08:22:59 +07:00
|
|
|
static int bttv_streamon(struct file *file, void *priv,
|
2007-12-28 08:20:58 +07:00
|
|
|
enum v4l2_buf_type type)
|
|
|
|
{
|
|
|
|
struct bttv_fh *fh = priv;
|
|
|
|
struct bttv *btv = fh->btv;
|
|
|
|
int res = bttv_resource(fh);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2010-09-14 22:19:51 +07:00
|
|
|
if (!check_alloc_btres_lock(btv, fh, res))
|
2007-12-28 08:20:58 +07:00
|
|
|
return -EBUSY;
|
|
|
|
return videobuf_streamon(bttv_queue(fh));
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2006-08-26 02:53:04 +07:00
|
|
|
|
2007-12-28 08:22:59 +07:00
|
|
|
static int bttv_streamoff(struct file *file, void *priv,
|
2007-12-28 08:20:58 +07:00
|
|
|
enum v4l2_buf_type type)
|
|
|
|
{
|
|
|
|
struct bttv_fh *fh = priv;
|
|
|
|
struct bttv *btv = fh->btv;
|
|
|
|
int retval;
|
|
|
|
int res = bttv_resource(fh);
|
2006-08-26 02:53:04 +07:00
|
|
|
|
2007-10-26 21:01:08 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
retval = videobuf_streamoff(bttv_queue(fh));
|
|
|
|
if (retval < 0)
|
|
|
|
return retval;
|
2010-09-14 22:19:51 +07:00
|
|
|
free_btres_lock(btv, fh, res);
|
2007-12-28 08:20:58 +07:00
|
|
|
return 0;
|
|
|
|
}
|
2006-08-26 02:53:04 +07:00
|
|
|
|
2007-12-28 08:22:59 +07:00
|
|
|
static int bttv_g_parm(struct file *file, void *f,
|
2007-12-28 08:20:58 +07:00
|
|
|
struct v4l2_streamparm *parm)
|
|
|
|
{
|
|
|
|
struct bttv_fh *fh = f;
|
|
|
|
struct bttv *btv = fh->btv;
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
2012-09-09 20:27:57 +07:00
|
|
|
if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
|
|
|
return -EINVAL;
|
|
|
|
parm->parm.capture.readbuffers = gbuffers;
|
2009-03-04 11:21:02 +07:00
|
|
|
v4l2_video_std_frame_period(bttv_tvnorms[btv->tvnorm].v4l2_id,
|
|
|
|
&parm->parm.capture.timeperframe);
|
2010-09-15 18:18:31 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
return 0;
|
|
|
|
}
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
2007-12-28 08:22:59 +07:00
|
|
|
static int bttv_g_tuner(struct file *file, void *priv,
|
2007-12-28 08:20:58 +07:00
|
|
|
struct v4l2_tuner *t)
|
|
|
|
{
|
|
|
|
struct bttv_fh *fh = priv;
|
|
|
|
struct bttv *btv = fh->btv;
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
if (0 != t->index)
|
|
|
|
return -EINVAL;
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
t->rxsubchans = V4L2_TUNER_SUB_MONO;
|
2013-02-06 22:44:07 +07:00
|
|
|
t->capability = V4L2_TUNER_CAP_NORM;
|
2009-03-28 18:29:00 +07:00
|
|
|
bttv_call_all(btv, tuner, g_tuner, t);
|
2007-12-28 08:20:58 +07:00
|
|
|
strcpy(t->name, "Television");
|
|
|
|
t->type = V4L2_TUNER_ANALOG_TV;
|
|
|
|
if (btread(BT848_DSTATUS)&BT848_DSTATUS_HLOC)
|
|
|
|
t->signal = 0xffff;
|
|
|
|
|
|
|
|
if (btv->audio_mode_gpio)
|
|
|
|
btv->audio_mode_gpio(btv, t, 0);
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
return 0;
|
|
|
|
}
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
2007-12-28 08:22:59 +07:00
|
|
|
static int bttv_cropcap(struct file *file, void *priv,
|
2007-12-28 08:20:58 +07:00
|
|
|
struct v4l2_cropcap *cap)
|
|
|
|
{
|
|
|
|
struct bttv_fh *fh = priv;
|
|
|
|
struct bttv *btv = fh->btv;
|
|
|
|
|
|
|
|
if (cap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
|
|
|
|
cap->type != V4L2_BUF_TYPE_VIDEO_OVERLAY)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
*cap = bttv_tvnorms[btv->tvnorm].cropcap;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
2007-12-28 08:22:59 +07:00
|
|
|
static int bttv_g_crop(struct file *file, void *f, struct v4l2_crop *crop)
|
2007-12-28 08:20:58 +07:00
|
|
|
{
|
|
|
|
struct bttv_fh *fh = f;
|
|
|
|
struct bttv *btv = fh->btv;
|
|
|
|
|
|
|
|
if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
|
|
|
|
crop->type != V4L2_BUF_TYPE_VIDEO_OVERLAY)
|
|
|
|
return -EINVAL;
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
/* No fh->do_crop = 1; because btv->crop[1] may be
|
|
|
|
inconsistent with fh->width or fh->height and apps
|
|
|
|
do not expect a change here. */
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
crop->c = btv->crop[!!fh->do_crop].rect;
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-09-05 15:10:48 +07:00
|
|
|
static int bttv_s_crop(struct file *file, void *f, const struct v4l2_crop *crop)
|
2007-12-28 08:20:58 +07:00
|
|
|
{
|
|
|
|
struct bttv_fh *fh = f;
|
|
|
|
struct bttv *btv = fh->btv;
|
|
|
|
const struct v4l2_rect *b;
|
|
|
|
int retval;
|
|
|
|
struct bttv_crop c;
|
|
|
|
__s32 b_left;
|
|
|
|
__s32 b_top;
|
|
|
|
__s32 b_right;
|
|
|
|
__s32 b_bottom;
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
|
|
|
|
crop->type != V4L2_BUF_TYPE_VIDEO_OVERLAY)
|
|
|
|
return -EINVAL;
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
/* Make sure tvnorm, vbi_end and the current cropping
|
|
|
|
parameters remain consistent until we're done. Note
|
2010-09-14 22:19:51 +07:00
|
|
|
read() may change vbi_end in check_alloc_btres_lock(). */
|
2007-12-28 08:20:58 +07:00
|
|
|
retval = -EBUSY;
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
if (locked_btres(fh->btv, VIDEO_RESOURCES)) {
|
|
|
|
return retval;
|
|
|
|
}
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
b = &bttv_tvnorms[btv->tvnorm].cropcap.bounds;
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
b_left = b->left;
|
|
|
|
b_right = b_left + b->width;
|
|
|
|
b_bottom = b->top + b->height;
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
b_top = max(b->top, btv->vbi_end);
|
|
|
|
if (b_top + 32 >= b_bottom) {
|
|
|
|
return retval;
|
|
|
|
}
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
/* Min. scaled size 48 x 32. */
|
2012-09-05 15:10:48 +07:00
|
|
|
c.rect.left = clamp_t(s32, crop->c.left, b_left, b_right - 48);
|
2007-12-28 08:20:58 +07:00
|
|
|
c.rect.left = min(c.rect.left, (__s32) MAX_HDELAY);
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
2012-09-05 15:10:48 +07:00
|
|
|
c.rect.width = clamp_t(s32, crop->c.width,
|
2007-12-28 08:20:58 +07:00
|
|
|
48, b_right - c.rect.left);
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
2012-09-05 15:10:48 +07:00
|
|
|
c.rect.top = clamp_t(s32, crop->c.top, b_top, b_bottom - 32);
|
2007-12-28 08:20:58 +07:00
|
|
|
/* Top and height must be a multiple of two. */
|
|
|
|
c.rect.top = (c.rect.top + 1) & ~1;
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
2012-09-05 15:10:48 +07:00
|
|
|
c.rect.height = clamp_t(s32, crop->c.height,
|
2007-12-28 08:20:58 +07:00
|
|
|
32, b_bottom - c.rect.top);
|
|
|
|
c.rect.height = (c.rect.height + 1) & ~1;
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
bttv_crop_calc_limits(&c);
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
btv->crop[1] = c;
|
|
|
|
|
|
|
|
fh->do_crop = 1;
|
|
|
|
|
|
|
|
if (fh->width < c.min_scaled_width) {
|
|
|
|
fh->width = c.min_scaled_width;
|
|
|
|
btv->init.width = c.min_scaled_width;
|
|
|
|
} else if (fh->width > c.max_scaled_width) {
|
|
|
|
fh->width = c.max_scaled_width;
|
|
|
|
btv->init.width = c.max_scaled_width;
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
}
|
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
if (fh->height < c.min_scaled_height) {
|
|
|
|
fh->height = c.min_scaled_height;
|
|
|
|
btv->init.height = c.min_scaled_height;
|
|
|
|
} else if (fh->height > c.max_scaled_height) {
|
|
|
|
fh->height = c.max_scaled_height;
|
|
|
|
btv->init.height = c.max_scaled_height;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
static ssize_t bttv_read(struct file *file, char __user *data,
|
|
|
|
size_t count, loff_t *ppos)
|
|
|
|
{
|
|
|
|
struct bttv_fh *fh = file->private_data;
|
|
|
|
int retval = 0;
|
|
|
|
|
|
|
|
if (fh->btv->errors)
|
|
|
|
bttv_reinit_bt848(fh->btv);
|
2011-08-22 05:56:48 +07:00
|
|
|
dprintk("%d: read count=%d type=%s\n",
|
|
|
|
fh->btv->c.nr, (int)count, v4l2_type_names[fh->type]);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
switch (fh->type) {
|
|
|
|
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
|
2010-09-14 22:19:51 +07:00
|
|
|
if (!check_alloc_btres_lock(fh->btv, fh, RESOURCE_VIDEO_READ)) {
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
/* VIDEO_READ in use by another fh,
|
|
|
|
or VIDEO_STREAM by any fh. */
|
2005-04-17 05:20:36 +07:00
|
|
|
return -EBUSY;
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
retval = videobuf_read_one(&fh->cap, data, count, ppos,
|
|
|
|
file->f_flags & O_NONBLOCK);
|
2010-09-14 22:19:51 +07:00
|
|
|
free_btres_lock(fh->btv, fh, RESOURCE_VIDEO_READ);
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
case V4L2_BUF_TYPE_VBI_CAPTURE:
|
2010-09-14 22:19:51 +07:00
|
|
|
if (!check_alloc_btres_lock(fh->btv,fh,RESOURCE_VBI))
|
2005-04-17 05:20:36 +07:00
|
|
|
return -EBUSY;
|
|
|
|
retval = videobuf_read_stream(&fh->vbi, data, count, ppos, 1,
|
|
|
|
file->f_flags & O_NONBLOCK);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BUG();
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int bttv_poll(struct file *file, poll_table *wait)
|
|
|
|
{
|
|
|
|
struct bttv_fh *fh = file->private_data;
|
|
|
|
struct bttv_buffer *buf;
|
|
|
|
enum v4l2_field field;
|
2013-02-06 22:42:13 +07:00
|
|
|
unsigned int rc = 0;
|
|
|
|
unsigned long req_events = poll_requested_events(wait);
|
|
|
|
|
|
|
|
if (v4l2_event_pending(&fh->fh))
|
|
|
|
rc = POLLPRI;
|
|
|
|
else if (req_events & POLLPRI)
|
|
|
|
poll_wait(file, &fh->fh.wait, wait);
|
|
|
|
|
|
|
|
if (!(req_events & (POLLIN | POLLRDNORM)))
|
|
|
|
return rc;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type) {
|
2010-09-14 22:19:51 +07:00
|
|
|
if (!check_alloc_btres_lock(fh->btv,fh,RESOURCE_VBI))
|
2013-02-06 22:42:13 +07:00
|
|
|
return rc | POLLERR;
|
|
|
|
return rc | videobuf_poll_stream(file, &fh->vbi, wait);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
if (check_btres(fh,RESOURCE_VIDEO_STREAM)) {
|
2005-04-17 05:20:36 +07:00
|
|
|
/* streaming capture */
|
|
|
|
if (list_empty(&fh->cap.stream))
|
2013-02-06 22:42:13 +07:00
|
|
|
return rc | POLLERR;
|
2005-04-17 05:20:36 +07:00
|
|
|
buf = list_entry(fh->cap.stream.next,struct bttv_buffer,vb.stream);
|
|
|
|
} else {
|
|
|
|
/* read() capture */
|
|
|
|
if (NULL == fh->cap.read_buf) {
|
|
|
|
/* need to capture a new frame */
|
2008-01-31 23:57:53 +07:00
|
|
|
if (locked_btres(fh->btv,RESOURCE_VIDEO_STREAM))
|
2013-02-06 22:42:13 +07:00
|
|
|
return rc | POLLERR;
|
2008-04-23 00:42:13 +07:00
|
|
|
fh->cap.read_buf = videobuf_sg_alloc(fh->cap.msize);
|
2008-01-31 23:57:53 +07:00
|
|
|
if (NULL == fh->cap.read_buf)
|
2013-02-06 22:42:13 +07:00
|
|
|
return rc | POLLERR;
|
2005-04-17 05:20:36 +07:00
|
|
|
fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR;
|
|
|
|
field = videobuf_next_field(&fh->cap);
|
|
|
|
if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,field)) {
|
2005-12-01 15:51:32 +07:00
|
|
|
kfree (fh->cap.read_buf);
|
|
|
|
fh->cap.read_buf = NULL;
|
2013-02-06 22:42:13 +07:00
|
|
|
return rc | POLLERR;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf);
|
|
|
|
fh->cap.read_off = 0;
|
|
|
|
}
|
|
|
|
buf = (struct bttv_buffer*)fh->cap.read_buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
poll_wait(file, &buf->vb.done, wait);
|
2007-11-07 06:02:36 +07:00
|
|
|
if (buf->vb.state == VIDEOBUF_DONE ||
|
|
|
|
buf->vb.state == VIDEOBUF_ERROR)
|
2013-02-06 22:42:13 +07:00
|
|
|
rc = rc | POLLIN|POLLRDNORM;
|
2009-06-16 23:31:29 +07:00
|
|
|
return rc;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2008-12-30 16:58:20 +07:00
|
|
|
static int bttv_open(struct file *file)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2009-12-10 20:47:13 +07:00
|
|
|
struct video_device *vdev = video_devdata(file);
|
2009-01-29 07:32:59 +07:00
|
|
|
struct bttv *btv = video_drvdata(file);
|
2005-04-17 05:20:36 +07:00
|
|
|
struct bttv_fh *fh;
|
|
|
|
enum v4l2_buf_type type = 0;
|
|
|
|
|
2011-08-22 05:56:48 +07:00
|
|
|
dprintk("open dev=%s\n", video_device_node_name(vdev));
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2009-11-27 23:57:55 +07:00
|
|
|
if (vdev->vfl_type == VFL_TYPE_GRABBER) {
|
2009-01-29 07:32:59 +07:00
|
|
|
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
2009-11-27 23:57:55 +07:00
|
|
|
} else if (vdev->vfl_type == VFL_TYPE_VBI) {
|
2009-01-29 07:32:59 +07:00
|
|
|
type = V4L2_BUF_TYPE_VBI_CAPTURE;
|
|
|
|
} else {
|
|
|
|
WARN_ON(1);
|
2005-04-17 05:20:36 +07:00
|
|
|
return -ENODEV;
|
2008-07-30 18:43:36 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2011-08-22 05:56:48 +07:00
|
|
|
dprintk("%d: open called (type=%s)\n",
|
|
|
|
btv->c.nr, v4l2_type_names[type]);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* allocate per filehandle data */
|
2010-09-15 18:18:31 +07:00
|
|
|
fh = kmalloc(sizeof(*fh), GFP_KERNEL);
|
|
|
|
if (unlikely(!fh))
|
2005-04-17 05:20:36 +07:00
|
|
|
return -ENOMEM;
|
2013-02-06 22:40:28 +07:00
|
|
|
btv->users++;
|
2005-04-17 05:20:36 +07:00
|
|
|
file->private_data = fh;
|
2010-09-15 18:18:31 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
*fh = btv->init;
|
2013-02-06 22:42:13 +07:00
|
|
|
v4l2_fh_init(&fh->fh, vdev);
|
2010-09-15 18:18:31 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
fh->type = type;
|
|
|
|
fh->ov.setup_ok = 0;
|
2010-09-15 18:18:31 +07:00
|
|
|
|
2008-04-23 00:42:13 +07:00
|
|
|
videobuf_queue_sg_init(&fh->cap, &bttv_video_qops,
|
|
|
|
&btv->c.pci->dev, &btv->s_lock,
|
2005-04-17 05:20:36 +07:00
|
|
|
V4L2_BUF_TYPE_VIDEO_CAPTURE,
|
|
|
|
V4L2_FIELD_INTERLACED,
|
|
|
|
sizeof(struct bttv_buffer),
|
[media] bttv: fix mutex use before init (BZ#24602)
Fix a regression where bttv driver causes oopses when loading, since it
were using some non-initialized mutexes. While it would be possible to
fix the issue, there are some other lock troubles, like to the presence of
lock code at free_btres_lock().
It is possible to fix, but the better is to just use the core-assisted
locking schema. This way, V4L2 core will serialize access to all
ioctl's/open/close/mmap/read/poll operations, avoiding to have two
processes accessing the hardware at the same time. Also, as there's just
one lock, instead of 3, there's no risk of dead locks.
The net result is a cleaner code, with just one lock.
Reported-by: Dan Carpenter <error27@gmail.com>
Reported-by: Brandon Philips<brandon@ifup.org>
Reported-by: Chris Clayton <chris2553@googlemail.com>
Reported-by: Torsten Kaiser <just.for.lkml@googlemail.com>
Tested-by: Chris Clayton <chris2553@googlemail.com>
Tested-by: Torsten Kaiser <just.for.lkml@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-12-16 04:45:42 +07:00
|
|
|
fh, &btv->lock);
|
2008-04-23 00:42:13 +07:00
|
|
|
videobuf_queue_sg_init(&fh->vbi, &bttv_vbi_qops,
|
|
|
|
&btv->c.pci->dev, &btv->s_lock,
|
2005-04-17 05:20:36 +07:00
|
|
|
V4L2_BUF_TYPE_VBI_CAPTURE,
|
|
|
|
V4L2_FIELD_SEQ_TB,
|
|
|
|
sizeof(struct bttv_buffer),
|
[media] bttv: fix mutex use before init (BZ#24602)
Fix a regression where bttv driver causes oopses when loading, since it
were using some non-initialized mutexes. While it would be possible to
fix the issue, there are some other lock troubles, like to the presence of
lock code at free_btres_lock().
It is possible to fix, but the better is to just use the core-assisted
locking schema. This way, V4L2 core will serialize access to all
ioctl's/open/close/mmap/read/poll operations, avoiding to have two
processes accessing the hardware at the same time. Also, as there's just
one lock, instead of 3, there's no risk of dead locks.
The net result is a cleaner code, with just one lock.
Reported-by: Dan Carpenter <error27@gmail.com>
Reported-by: Brandon Philips<brandon@ifup.org>
Reported-by: Chris Clayton <chris2553@googlemail.com>
Reported-by: Torsten Kaiser <just.for.lkml@googlemail.com>
Tested-by: Chris Clayton <chris2553@googlemail.com>
Tested-by: Torsten Kaiser <just.for.lkml@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-12-16 04:45:42 +07:00
|
|
|
fh, &btv->lock);
|
2007-10-26 20:53:21 +07:00
|
|
|
set_tvnorm(btv,btv->tvnorm);
|
2008-08-05 20:12:35 +07:00
|
|
|
set_input(btv, btv->input, btv->tvnorm);
|
2013-03-21 23:51:20 +07:00
|
|
|
audio_mute(btv, btv->mute);
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
|
|
|
|
/* The V4L2 spec requires one global set of cropping parameters
|
|
|
|
which only change on request. These are stored in btv->crop[1].
|
|
|
|
However for compatibility with V4L apps and cropping unaware
|
|
|
|
V4L2 apps we now reset the cropping parameters as seen through
|
|
|
|
this fh, which is to say VIDIOC_G_CROP and scaling limit checks
|
|
|
|
will use btv->crop[0], the default cropping parameters for the
|
|
|
|
current video standard, and VIDIOC_S_FMT will not implicitely
|
|
|
|
change the cropping parameters until VIDIOC_S_CROP has been
|
|
|
|
called. */
|
|
|
|
fh->do_crop = !reset_crop; /* module parameter */
|
|
|
|
|
|
|
|
/* Likewise there should be one global set of VBI capture
|
|
|
|
parameters, but for compatibility with V4L apps and earlier
|
|
|
|
driver versions each fh has its own parameters. */
|
|
|
|
bttv_vbi_fmt_reset(&fh->vbi_fmt, btv->tvnorm);
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
bttv_field_count(btv);
|
2013-02-06 22:42:13 +07:00
|
|
|
v4l2_fh_add(&fh->fh);
|
2005-04-17 05:20:36 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-12-30 16:58:20 +07:00
|
|
|
static int bttv_release(struct file *file)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
struct bttv_fh *fh = file->private_data;
|
|
|
|
struct bttv *btv = fh->btv;
|
|
|
|
|
|
|
|
/* turn off overlay */
|
|
|
|
if (check_btres(fh, RESOURCE_OVERLAY))
|
|
|
|
bttv_switch_overlay(btv,fh,NULL);
|
|
|
|
|
|
|
|
/* stop video capture */
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
if (check_btres(fh, RESOURCE_VIDEO_STREAM)) {
|
2005-04-17 05:20:36 +07:00
|
|
|
videobuf_streamoff(&fh->cap);
|
2010-09-14 22:19:51 +07:00
|
|
|
free_btres_lock(btv,fh,RESOURCE_VIDEO_STREAM);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
if (fh->cap.read_buf) {
|
|
|
|
buffer_release(&fh->cap,fh->cap.read_buf);
|
|
|
|
kfree(fh->cap.read_buf);
|
|
|
|
}
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
if (check_btres(fh, RESOURCE_VIDEO_READ)) {
|
2010-09-14 22:19:51 +07:00
|
|
|
free_btres_lock(btv, fh, RESOURCE_VIDEO_READ);
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* stop vbi capture */
|
|
|
|
if (check_btres(fh, RESOURCE_VBI)) {
|
2007-11-14 06:11:26 +07:00
|
|
|
videobuf_stop(&fh->vbi);
|
2010-09-14 22:19:51 +07:00
|
|
|
free_btres_lock(btv,fh,RESOURCE_VBI);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* free stuff */
|
2010-09-15 18:18:31 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
videobuf_mmap_free(&fh->cap);
|
|
|
|
videobuf_mmap_free(&fh->vbi);
|
|
|
|
file->private_data = NULL;
|
|
|
|
|
|
|
|
btv->users--;
|
|
|
|
bttv_field_count(btv);
|
2008-08-05 20:12:35 +07:00
|
|
|
|
|
|
|
if (!btv->users)
|
2013-02-06 22:40:28 +07:00
|
|
|
audio_mute(btv, btv->mute);
|
2008-08-05 20:12:35 +07:00
|
|
|
|
2013-02-06 22:42:13 +07:00
|
|
|
v4l2_fh_del(&fh->fh);
|
|
|
|
v4l2_fh_exit(&fh->fh);
|
|
|
|
kfree(fh);
|
2005-04-17 05:20:36 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
bttv_mmap(struct file *file, struct vm_area_struct *vma)
|
|
|
|
{
|
|
|
|
struct bttv_fh *fh = file->private_data;
|
|
|
|
|
2011-08-22 05:56:48 +07:00
|
|
|
dprintk("%d: mmap type=%s 0x%lx+%ld\n",
|
2005-04-17 05:20:36 +07:00
|
|
|
fh->btv->c.nr, v4l2_type_names[fh->type],
|
|
|
|
vma->vm_start, vma->vm_end - vma->vm_start);
|
|
|
|
return videobuf_mmap_mapper(bttv_queue(fh),vma);
|
|
|
|
}
|
|
|
|
|
2008-12-30 16:58:20 +07:00
|
|
|
static const struct v4l2_file_operations bttv_fops =
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2010-09-15 18:22:09 +07:00
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.open = bttv_open,
|
|
|
|
.release = bttv_release,
|
|
|
|
.unlocked_ioctl = video_ioctl2,
|
|
|
|
.read = bttv_read,
|
|
|
|
.mmap = bttv_mmap,
|
|
|
|
.poll = bttv_poll,
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
2008-07-21 12:57:38 +07:00
|
|
|
static const struct v4l2_ioctl_ops bttv_ioctl_ops = {
|
2007-12-28 08:22:59 +07:00
|
|
|
.vidioc_querycap = bttv_querycap,
|
2008-05-28 22:16:41 +07:00
|
|
|
.vidioc_enum_fmt_vid_cap = bttv_enum_fmt_vid_cap,
|
|
|
|
.vidioc_g_fmt_vid_cap = bttv_g_fmt_vid_cap,
|
|
|
|
.vidioc_try_fmt_vid_cap = bttv_try_fmt_vid_cap,
|
|
|
|
.vidioc_s_fmt_vid_cap = bttv_s_fmt_vid_cap,
|
|
|
|
.vidioc_enum_fmt_vid_overlay = bttv_enum_fmt_vid_overlay,
|
|
|
|
.vidioc_g_fmt_vid_overlay = bttv_g_fmt_vid_overlay,
|
|
|
|
.vidioc_try_fmt_vid_overlay = bttv_try_fmt_vid_overlay,
|
|
|
|
.vidioc_s_fmt_vid_overlay = bttv_s_fmt_vid_overlay,
|
|
|
|
.vidioc_g_fmt_vbi_cap = bttv_g_fmt_vbi_cap,
|
|
|
|
.vidioc_try_fmt_vbi_cap = bttv_try_fmt_vbi_cap,
|
|
|
|
.vidioc_s_fmt_vbi_cap = bttv_s_fmt_vbi_cap,
|
2007-12-28 08:22:59 +07:00
|
|
|
.vidioc_cropcap = bttv_cropcap,
|
|
|
|
.vidioc_reqbufs = bttv_reqbufs,
|
|
|
|
.vidioc_querybuf = bttv_querybuf,
|
|
|
|
.vidioc_qbuf = bttv_qbuf,
|
|
|
|
.vidioc_dqbuf = bttv_dqbuf,
|
|
|
|
.vidioc_s_std = bttv_s_std,
|
2013-02-06 22:43:07 +07:00
|
|
|
.vidioc_g_std = bttv_g_std,
|
2007-12-28 08:22:59 +07:00
|
|
|
.vidioc_enum_input = bttv_enum_input,
|
|
|
|
.vidioc_g_input = bttv_g_input,
|
|
|
|
.vidioc_s_input = bttv_s_input,
|
|
|
|
.vidioc_streamon = bttv_streamon,
|
|
|
|
.vidioc_streamoff = bttv_streamoff,
|
|
|
|
.vidioc_g_tuner = bttv_g_tuner,
|
|
|
|
.vidioc_s_tuner = bttv_s_tuner,
|
|
|
|
.vidioc_g_crop = bttv_g_crop,
|
|
|
|
.vidioc_s_crop = bttv_s_crop,
|
|
|
|
.vidioc_g_fbuf = bttv_g_fbuf,
|
|
|
|
.vidioc_s_fbuf = bttv_s_fbuf,
|
|
|
|
.vidioc_overlay = bttv_overlay,
|
|
|
|
.vidioc_g_parm = bttv_g_parm,
|
|
|
|
.vidioc_g_frequency = bttv_g_frequency,
|
|
|
|
.vidioc_s_frequency = bttv_s_frequency,
|
|
|
|
.vidioc_log_status = bttv_log_status,
|
|
|
|
.vidioc_querystd = bttv_querystd,
|
2013-02-06 22:42:13 +07:00
|
|
|
.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
|
|
|
|
.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
|
2008-01-14 23:24:38 +07:00
|
|
|
#ifdef CONFIG_VIDEO_ADV_DEBUG
|
2007-12-28 08:22:59 +07:00
|
|
|
.vidioc_g_register = bttv_g_register,
|
|
|
|
.vidioc_s_register = bttv_s_register,
|
2008-01-14 23:24:38 +07:00
|
|
|
#endif
|
2008-07-21 12:57:38 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct video_device bttv_video_template = {
|
|
|
|
.fops = &bttv_fops,
|
|
|
|
.ioctl_ops = &bttv_ioctl_ops,
|
|
|
|
.tvnorms = BTTV_NORMS,
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------- */
|
|
|
|
/* radio interface */
|
|
|
|
|
2008-12-30 16:58:20 +07:00
|
|
|
static int radio_open(struct file *file)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2009-12-10 20:47:13 +07:00
|
|
|
struct video_device *vdev = video_devdata(file);
|
2009-01-29 07:32:59 +07:00
|
|
|
struct bttv *btv = video_drvdata(file);
|
2008-04-01 21:41:54 +07:00
|
|
|
struct bttv_fh *fh;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2011-08-22 05:56:48 +07:00
|
|
|
dprintk("open dev=%s\n", video_device_node_name(vdev));
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2011-08-22 05:56:48 +07:00
|
|
|
dprintk("%d: open called (radio)\n", btv->c.nr);
|
2008-04-01 21:41:54 +07:00
|
|
|
|
|
|
|
/* allocate per filehandle data */
|
|
|
|
fh = kmalloc(sizeof(*fh), GFP_KERNEL);
|
2010-09-15 18:18:31 +07:00
|
|
|
if (unlikely(!fh))
|
2008-04-01 21:41:54 +07:00
|
|
|
return -ENOMEM;
|
|
|
|
file->private_data = fh;
|
|
|
|
*fh = btv->init;
|
2013-02-06 22:42:40 +07:00
|
|
|
v4l2_fh_init(&fh->fh, vdev);
|
2005-09-10 03:03:39 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
btv->radio_user++;
|
2013-03-21 23:51:20 +07:00
|
|
|
audio_mute(btv, btv->mute);
|
2005-09-10 03:03:39 +07:00
|
|
|
|
2013-02-06 22:42:40 +07:00
|
|
|
v4l2_fh_add(&fh->fh);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-11-09 12:37:43 +07:00
|
|
|
return 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2008-12-30 16:58:20 +07:00
|
|
|
static int radio_release(struct file *file)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2008-04-01 21:41:54 +07:00
|
|
|
struct bttv_fh *fh = file->private_data;
|
|
|
|
struct bttv *btv = fh->btv;
|
2010-12-27 22:22:46 +07:00
|
|
|
struct saa6588_command cmd;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-04-10 19:40:31 +07:00
|
|
|
file->private_data = NULL;
|
2013-02-06 22:42:40 +07:00
|
|
|
v4l2_fh_del(&fh->fh);
|
|
|
|
v4l2_fh_exit(&fh->fh);
|
2008-04-10 19:40:31 +07:00
|
|
|
kfree(fh);
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
btv->radio_user--;
|
2005-09-10 03:03:39 +07:00
|
|
|
|
2010-12-27 22:22:46 +07:00
|
|
|
bttv_call_all(btv, core, ioctl, SAA6588_CMD_CLOSE, &cmd);
|
2005-09-10 03:03:39 +07:00
|
|
|
|
2013-02-10 19:24:14 +07:00
|
|
|
if (btv->radio_user == 0)
|
|
|
|
btv->has_radio_tuner = 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
static int radio_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
|
|
|
|
{
|
|
|
|
struct bttv_fh *fh = priv;
|
|
|
|
struct bttv *btv = fh->btv;
|
2007-10-26 21:01:08 +07:00
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
if (0 != t->index)
|
|
|
|
return -EINVAL;
|
|
|
|
strcpy(t->name, "Radio");
|
|
|
|
t->type = V4L2_TUNER_RADIO;
|
2013-02-10 19:24:14 +07:00
|
|
|
radio_enable(btv);
|
2006-08-26 02:53:04 +07:00
|
|
|
|
2009-03-28 18:29:00 +07:00
|
|
|
bttv_call_all(btv, tuner, g_tuner, t);
|
2007-12-28 08:20:58 +07:00
|
|
|
|
|
|
|
if (btv->audio_mode_gpio)
|
|
|
|
btv->audio_mode_gpio(btv, t, 0);
|
|
|
|
|
2015-01-16 16:58:32 +07:00
|
|
|
if (btv->has_tea575x)
|
|
|
|
return snd_tea575x_g_tuner(&btv->tea, t);
|
|
|
|
|
2007-12-28 08:20:58 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int radio_s_tuner(struct file *file, void *priv,
|
2013-03-15 16:10:06 +07:00
|
|
|
const struct v4l2_tuner *t)
|
2007-12-28 08:20:58 +07:00
|
|
|
{
|
|
|
|
struct bttv_fh *fh = priv;
|
|
|
|
struct bttv *btv = fh->btv;
|
|
|
|
|
|
|
|
if (0 != t->index)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2013-02-10 19:24:14 +07:00
|
|
|
radio_enable(btv);
|
2011-06-12 17:02:43 +07:00
|
|
|
bttv_call_all(btv, tuner, s_tuner, t);
|
2007-12-28 08:20:58 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-01-16 16:58:32 +07:00
|
|
|
static int radio_s_hw_freq_seek(struct file *file, void *priv,
|
|
|
|
const struct v4l2_hw_freq_seek *a)
|
|
|
|
{
|
|
|
|
struct bttv_fh *fh = priv;
|
|
|
|
struct bttv *btv = fh->btv;
|
|
|
|
|
|
|
|
if (btv->has_tea575x)
|
|
|
|
return snd_tea575x_s_hw_freq_seek(file, &btv->tea, a);
|
|
|
|
|
|
|
|
return -ENOTTY;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int radio_enum_freq_bands(struct file *file, void *priv,
|
|
|
|
struct v4l2_frequency_band *band)
|
|
|
|
{
|
|
|
|
struct bttv_fh *fh = priv;
|
|
|
|
struct bttv *btv = fh->btv;
|
|
|
|
|
|
|
|
if (btv->has_tea575x)
|
|
|
|
return snd_tea575x_enum_freq_bands(&btv->tea, band);
|
|
|
|
|
|
|
|
return -ENOTTY;
|
|
|
|
}
|
|
|
|
|
2005-09-10 03:03:39 +07:00
|
|
|
static ssize_t radio_read(struct file *file, char __user *data,
|
|
|
|
size_t count, loff_t *ppos)
|
|
|
|
{
|
2008-04-01 21:41:54 +07:00
|
|
|
struct bttv_fh *fh = file->private_data;
|
|
|
|
struct bttv *btv = fh->btv;
|
2010-12-27 22:22:46 +07:00
|
|
|
struct saa6588_command cmd;
|
2013-12-14 18:28:36 +07:00
|
|
|
|
|
|
|
cmd.block_count = count / 3;
|
|
|
|
cmd.nonblocking = file->f_flags & O_NONBLOCK;
|
2005-09-10 03:03:39 +07:00
|
|
|
cmd.buffer = data;
|
|
|
|
cmd.instance = file;
|
|
|
|
cmd.result = -ENODEV;
|
2013-02-10 19:24:14 +07:00
|
|
|
radio_enable(btv);
|
2005-09-10 03:03:39 +07:00
|
|
|
|
2010-12-27 22:22:46 +07:00
|
|
|
bttv_call_all(btv, core, ioctl, SAA6588_CMD_READ, &cmd);
|
2005-09-10 03:03:39 +07:00
|
|
|
|
|
|
|
return cmd.result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int radio_poll(struct file *file, poll_table *wait)
|
|
|
|
{
|
2008-04-01 21:41:54 +07:00
|
|
|
struct bttv_fh *fh = file->private_data;
|
|
|
|
struct bttv *btv = fh->btv;
|
2013-02-06 22:42:13 +07:00
|
|
|
unsigned long req_events = poll_requested_events(wait);
|
2010-12-27 22:22:46 +07:00
|
|
|
struct saa6588_command cmd;
|
2013-02-06 22:42:13 +07:00
|
|
|
unsigned int res = 0;
|
|
|
|
|
|
|
|
if (v4l2_event_pending(&fh->fh))
|
|
|
|
res = POLLPRI;
|
|
|
|
else if (req_events & POLLPRI)
|
|
|
|
poll_wait(file, &fh->fh.wait, wait);
|
2013-02-10 19:24:14 +07:00
|
|
|
radio_enable(btv);
|
2005-09-10 03:03:39 +07:00
|
|
|
cmd.instance = file;
|
|
|
|
cmd.event_list = wait;
|
2013-02-06 22:42:13 +07:00
|
|
|
cmd.result = res;
|
2010-12-27 22:22:46 +07:00
|
|
|
bttv_call_all(btv, core, ioctl, SAA6588_CMD_POLL, &cmd);
|
2005-09-10 03:03:39 +07:00
|
|
|
|
|
|
|
return cmd.result;
|
|
|
|
}
|
|
|
|
|
2008-12-30 16:58:20 +07:00
|
|
|
static const struct v4l2_file_operations radio_fops =
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.open = radio_open,
|
2005-09-10 03:03:39 +07:00
|
|
|
.read = radio_read,
|
2005-04-17 05:20:36 +07:00
|
|
|
.release = radio_release,
|
[media] bttv: fix mutex use before init (BZ#24602)
Fix a regression where bttv driver causes oopses when loading, since it
were using some non-initialized mutexes. While it would be possible to
fix the issue, there are some other lock troubles, like to the presence of
lock code at free_btres_lock().
It is possible to fix, but the better is to just use the core-assisted
locking schema. This way, V4L2 core will serialize access to all
ioctl's/open/close/mmap/read/poll operations, avoiding to have two
processes accessing the hardware at the same time. Also, as there's just
one lock, instead of 3, there's no risk of dead locks.
The net result is a cleaner code, with just one lock.
Reported-by: Dan Carpenter <error27@gmail.com>
Reported-by: Brandon Philips<brandon@ifup.org>
Reported-by: Chris Clayton <chris2553@googlemail.com>
Reported-by: Torsten Kaiser <just.for.lkml@googlemail.com>
Tested-by: Chris Clayton <chris2553@googlemail.com>
Tested-by: Torsten Kaiser <just.for.lkml@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-12-16 04:45:42 +07:00
|
|
|
.unlocked_ioctl = video_ioctl2,
|
2005-09-10 03:03:39 +07:00
|
|
|
.poll = radio_poll,
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
2008-07-21 12:57:38 +07:00
|
|
|
static const struct v4l2_ioctl_ops radio_ioctl_ops = {
|
2012-09-09 19:03:29 +07:00
|
|
|
.vidioc_querycap = bttv_querycap,
|
2013-02-06 22:40:28 +07:00
|
|
|
.vidioc_log_status = bttv_log_status,
|
2007-12-28 08:20:58 +07:00
|
|
|
.vidioc_g_tuner = radio_g_tuner,
|
|
|
|
.vidioc_s_tuner = radio_s_tuner,
|
2007-12-28 08:22:59 +07:00
|
|
|
.vidioc_g_frequency = bttv_g_frequency,
|
|
|
|
.vidioc_s_frequency = bttv_s_frequency,
|
2015-01-16 16:58:32 +07:00
|
|
|
.vidioc_s_hw_freq_seek = radio_s_hw_freq_seek,
|
|
|
|
.vidioc_enum_freq_bands = radio_enum_freq_bands,
|
2013-02-06 22:42:13 +07:00
|
|
|
.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
|
|
|
|
.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
2008-07-21 12:57:38 +07:00
|
|
|
static struct video_device radio_template = {
|
|
|
|
.fops = &radio_fops,
|
|
|
|
.ioctl_ops = &radio_ioctl_ops,
|
|
|
|
};
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* ----------------------------------------------------------------------- */
|
|
|
|
/* some debug code */
|
|
|
|
|
2005-05-01 22:59:29 +07:00
|
|
|
static int bttv_risc_decode(u32 risc)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
static char *instr[16] = {
|
|
|
|
[ BT848_RISC_WRITE >> 28 ] = "write",
|
|
|
|
[ BT848_RISC_SKIP >> 28 ] = "skip",
|
|
|
|
[ BT848_RISC_WRITEC >> 28 ] = "writec",
|
|
|
|
[ BT848_RISC_JUMP >> 28 ] = "jump",
|
|
|
|
[ BT848_RISC_SYNC >> 28 ] = "sync",
|
|
|
|
[ BT848_RISC_WRITE123 >> 28 ] = "write123",
|
|
|
|
[ BT848_RISC_SKIP123 >> 28 ] = "skip123",
|
|
|
|
[ BT848_RISC_WRITE1S23 >> 28 ] = "write1s23",
|
|
|
|
};
|
|
|
|
static int incr[16] = {
|
|
|
|
[ BT848_RISC_WRITE >> 28 ] = 2,
|
|
|
|
[ BT848_RISC_JUMP >> 28 ] = 2,
|
|
|
|
[ BT848_RISC_SYNC >> 28 ] = 2,
|
|
|
|
[ BT848_RISC_WRITE123 >> 28 ] = 5,
|
|
|
|
[ BT848_RISC_SKIP123 >> 28 ] = 2,
|
|
|
|
[ BT848_RISC_WRITE1S23 >> 28 ] = 3,
|
|
|
|
};
|
|
|
|
static char *bits[] = {
|
|
|
|
"be0", "be1", "be2", "be3/resync",
|
|
|
|
"set0", "set1", "set2", "set3",
|
|
|
|
"clr0", "clr1", "clr2", "clr3",
|
|
|
|
"irq", "res", "eol", "sol",
|
|
|
|
};
|
|
|
|
int i;
|
|
|
|
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_cont("0x%08x [ %s", risc,
|
2005-04-17 05:20:36 +07:00
|
|
|
instr[risc >> 28] ? instr[risc >> 28] : "INVALID");
|
|
|
|
for (i = ARRAY_SIZE(bits)-1; i >= 0; i--)
|
|
|
|
if (risc & (1 << (i + 12)))
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_cont(" %s", bits[i]);
|
|
|
|
pr_cont(" count=%d ]\n", risc & 0xfff);
|
2005-04-17 05:20:36 +07:00
|
|
|
return incr[risc >> 28] ? incr[risc >> 28] : 1;
|
|
|
|
}
|
|
|
|
|
2005-05-01 22:59:29 +07:00
|
|
|
static void bttv_risc_disasm(struct bttv *btv,
|
|
|
|
struct btcx_riscmem *risc)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
unsigned int i,j,n;
|
|
|
|
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_info("%s: risc disasm: %p [dma=0x%08lx]\n",
|
|
|
|
btv->c.v4l2_dev.name, risc->cpu, (unsigned long)risc->dma);
|
2005-04-17 05:20:36 +07:00
|
|
|
for (i = 0; i < (risc->size >> 2); i += n) {
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_info("%s: 0x%lx: ",
|
|
|
|
btv->c.v4l2_dev.name,
|
|
|
|
(unsigned long)(risc->dma + (i<<2)));
|
2008-06-23 00:20:09 +07:00
|
|
|
n = bttv_risc_decode(le32_to_cpu(risc->cpu[i]));
|
2005-04-17 05:20:36 +07:00
|
|
|
for (j = 1; j < n; j++)
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_info("%s: 0x%lx: 0x%08x [ arg #%d ]\n",
|
|
|
|
btv->c.v4l2_dev.name,
|
|
|
|
(unsigned long)(risc->dma + ((i+j)<<2)),
|
|
|
|
risc->cpu[i+j], j);
|
2005-04-17 05:20:36 +07:00
|
|
|
if (0 == risc->cpu[i])
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void bttv_print_riscaddr(struct bttv *btv)
|
|
|
|
{
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_info(" main: %08llx\n", (unsigned long long)btv->main.dma);
|
|
|
|
pr_info(" vbi : o=%08llx e=%08llx\n",
|
|
|
|
btv->cvbi ? (unsigned long long)btv->cvbi->top.dma : 0,
|
|
|
|
btv->cvbi ? (unsigned long long)btv->cvbi->bottom.dma : 0);
|
|
|
|
pr_info(" cap : o=%08llx e=%08llx\n",
|
|
|
|
btv->curr.top
|
|
|
|
? (unsigned long long)btv->curr.top->top.dma : 0,
|
|
|
|
btv->curr.bottom
|
|
|
|
? (unsigned long long)btv->curr.bottom->bottom.dma : 0);
|
|
|
|
pr_info(" scr : o=%08llx e=%08llx\n",
|
|
|
|
btv->screen ? (unsigned long long)btv->screen->top.dma : 0,
|
|
|
|
btv->screen ? (unsigned long long)btv->screen->bottom.dma : 0);
|
2005-04-17 05:20:36 +07:00
|
|
|
bttv_risc_disasm(btv, &btv->main);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------- */
|
|
|
|
/* irq handler */
|
|
|
|
|
|
|
|
static char *irq_name[] = {
|
|
|
|
"FMTCHG", // format change detected (525 vs. 625)
|
|
|
|
"VSYNC", // vertical sync (new field)
|
|
|
|
"HSYNC", // horizontal sync
|
|
|
|
"OFLOW", // chroma/luma AGC overflow
|
|
|
|
"HLOCK", // horizontal lock changed
|
|
|
|
"VPRES", // video presence changed
|
|
|
|
"6", "7",
|
|
|
|
"I2CDONE", // hw irc operation finished
|
|
|
|
"GPINT", // gpio port triggered irq
|
|
|
|
"10",
|
|
|
|
"RISCI", // risc instruction triggered irq
|
|
|
|
"FBUS", // pixel data fifo dropped data (high pci bus latencies)
|
|
|
|
"FTRGT", // pixel data fifo overrun
|
|
|
|
"FDSR", // fifo data stream resyncronisation
|
|
|
|
"PPERR", // parity error (data transfer)
|
|
|
|
"RIPERR", // parity error (read risc instructions)
|
|
|
|
"PABORT", // pci abort
|
|
|
|
"OCERR", // risc instruction error
|
|
|
|
"SCERR", // syncronisation error
|
|
|
|
};
|
|
|
|
|
|
|
|
static void bttv_print_irqbits(u32 print, u32 mark)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_cont("bits:");
|
2005-04-17 05:20:36 +07:00
|
|
|
for (i = 0; i < ARRAY_SIZE(irq_name); i++) {
|
|
|
|
if (print & (1 << i))
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_cont(" %s", irq_name[i]);
|
2005-04-17 05:20:36 +07:00
|
|
|
if (mark & (1 << i))
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_cont("*");
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void bttv_irq_debug_low_latency(struct bttv *btv, u32 rc)
|
|
|
|
{
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_warn("%d: irq: skipped frame [main=%lx,o_vbi=%lx,o_field=%lx,rc=%lx]\n",
|
|
|
|
btv->c.nr,
|
|
|
|
(unsigned long)btv->main.dma,
|
|
|
|
(unsigned long)le32_to_cpu(btv->main.cpu[RISC_SLOT_O_VBI+1]),
|
|
|
|
(unsigned long)le32_to_cpu(btv->main.cpu[RISC_SLOT_O_FIELD+1]),
|
|
|
|
(unsigned long)rc);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
if (0 == (btread(BT848_DSTATUS) & BT848_DSTATUS_HLOC)) {
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_notice("%d: Oh, there (temporarily?) is no input signal. "
|
|
|
|
"Ok, then this is harmless, don't worry ;)\n",
|
|
|
|
btv->c.nr);
|
2005-04-17 05:20:36 +07:00
|
|
|
return;
|
|
|
|
}
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_notice("%d: Uhm. Looks like we have unusual high IRQ latencies\n",
|
|
|
|
btv->c.nr);
|
|
|
|
pr_notice("%d: Lets try to catch the culpit red-handed ...\n",
|
|
|
|
btv->c.nr);
|
2005-04-17 05:20:36 +07:00
|
|
|
dump_stack();
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
bttv_irq_next_video(struct bttv *btv, struct bttv_buffer_set *set)
|
|
|
|
{
|
|
|
|
struct bttv_buffer *item;
|
|
|
|
|
|
|
|
memset(set,0,sizeof(*set));
|
|
|
|
|
|
|
|
/* capture request ? */
|
|
|
|
if (!list_empty(&btv->capture)) {
|
|
|
|
set->frame_irq = 1;
|
|
|
|
item = list_entry(btv->capture.next, struct bttv_buffer, vb.queue);
|
|
|
|
if (V4L2_FIELD_HAS_TOP(item->vb.field))
|
|
|
|
set->top = item;
|
|
|
|
if (V4L2_FIELD_HAS_BOTTOM(item->vb.field))
|
|
|
|
set->bottom = item;
|
|
|
|
|
|
|
|
/* capture request for other field ? */
|
|
|
|
if (!V4L2_FIELD_HAS_BOTH(item->vb.field) &&
|
|
|
|
(item->vb.queue.next != &btv->capture)) {
|
|
|
|
item = list_entry(item->vb.queue.next, struct bttv_buffer, vb.queue);
|
V4L/DVB (13169): bttv: Fix potential out-of-order field processing
There is a subtle interaction in the bttv driver which can result in
fields being repeatedly processed out of order. This is a problem
specifically when running in V4L2_FIELD_ALTERNATE mode (probably the
most common case).
1. The determination of which fields are associated with which buffers
happens in videobuf, before the bttv driver gets a chance to queue the
corresponding DMA. Thus by the point when the DMA is queued for a
given buffer, the algorithm has to do the queuing based on the
buffer's already assigned field type - not based on which field is
"next" in the video stream.
2. The driver normally tries to queue both the top and bottom fields
at the same time (see bttv_irq_next_video()). It tries to sort out
top vs bottom by looking at the field type for the next 2 available
buffers and assigning them appropriately.
3. However the bttv driver *always* actually processes the top field
first. There's even an interrupt set aside for specifically
recognizing when the top field has been processed so that it can be
marked done even while the bottom field is still being DMAed.
Given all of the above, if one gets into a situation where
bttv_irq_next_video() gets entered when the first available buffer has
been pre-associated as a bottom field, then the function is going to
process the buffers out of order. That first available buffer will be
put into the bottom field slot and the buffer after that will be put
into the top field slot. Problem is, since the top field is always
processed first by the driver, then that second buffer (the one after
the first available buffer) will be the first one to be finished.
Because of the strict fifo handling of all video buffers, then that
top field won't be seen by the app until after the bottom field is
also processed. Worse still, the app will get back the
chronologically later bottom field first, *before* the top field is
received. The buffer's timestamps will even be backwards.
While not fatal to most TV apps, this behavior can subtlely degrade
userspace deinterlacing (probably will cause jitter). That's probably
why it has gone unnoticed. But it will also cause serious problems if
the app in question discards all but the latest received buffer (a
latency minimizing tactic) - causing one field to only ever be
displayed since the other is now always late. Unfortunately once you
get into this state, you're stuck this way - because having consumed
two buffers, now the next time around the "first" available buffer
will again be a bottom field and the same thing happens.
How can we get into this state? In a perfect world, where there's
always a few free buffers queued to the driver, it should be
impossible. However if something disrupts streaming, e.g. if the
userspace app can't queue free buffers fast enough for a moment due
perhaps to a CPU scheduling glitch, then the driver can get
momentarily starved and some number of fields will be dropped. That's
OK. But if an odd number of fields get dropped, then that "first"
available buffer might be the bottom field and now we're stuck...
This patch fixes that problem by deliberately only setting up a single
field for one frame if we don't get a top field as the first available
buffer. By purposely skipping the other field, then we only handle a
single buffer thus bringing things back into proper sync (i.e. top
field first) for the next frame. To do this we just drop the few
lines in bttv_irq_next_video() that attempt to set up the second
buffer when that second buffer isn't for the bottom field.
This is definitely a problem in when in V4L2_FIELD_ALTERNATE mode. In
the other modes this change either has no effect or doesn't harm
things any further anyway.
Signed-off-by: Mike Isely <isely@pobox.com>
CC: stable@kernel.org
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2009-09-21 22:09:08 +07:00
|
|
|
/* Mike Isely <isely@pobox.com> - Only check
|
|
|
|
* and set up the bottom field in the logic
|
|
|
|
* below. Don't ever do the top field. This
|
|
|
|
* of course means that if we set up the
|
|
|
|
* bottom field in the above code that we'll
|
|
|
|
* actually skip a field. But that's OK.
|
|
|
|
* Having processed only a single buffer this
|
|
|
|
* time, then the next time around the first
|
|
|
|
* available buffer should be for a top field.
|
|
|
|
* That will then cause us here to set up a
|
|
|
|
* top then a bottom field in the normal way.
|
|
|
|
* The alternative to this understanding is
|
|
|
|
* that we set up the second available buffer
|
|
|
|
* as a top field, but that's out of order
|
|
|
|
* since this driver always processes the top
|
|
|
|
* field first - the effect will be the two
|
|
|
|
* buffers being returned in the wrong order,
|
|
|
|
* with the second buffer also being delayed
|
|
|
|
* by one field time (owing to the fifo nature
|
|
|
|
* of videobuf). Worse still, we'll be stuck
|
|
|
|
* doing fields out of order now every time
|
|
|
|
* until something else causes a field to be
|
|
|
|
* dropped. By effectively forcing a field to
|
|
|
|
* drop this way then we always get back into
|
|
|
|
* sync within a single frame time. (Out of
|
|
|
|
* order fields can screw up deinterlacing
|
|
|
|
* algorithms.) */
|
2005-04-17 05:20:36 +07:00
|
|
|
if (!V4L2_FIELD_HAS_BOTH(item->vb.field)) {
|
|
|
|
if (NULL == set->bottom &&
|
|
|
|
V4L2_FIELD_BOTTOM == item->vb.field) {
|
|
|
|
set->bottom = item;
|
|
|
|
}
|
|
|
|
if (NULL != set->top && NULL != set->bottom)
|
|
|
|
set->top_irq = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* screen overlay ? */
|
|
|
|
if (NULL != btv->screen) {
|
|
|
|
if (V4L2_FIELD_HAS_BOTH(btv->screen->vb.field)) {
|
|
|
|
if (NULL == set->top && NULL == set->bottom) {
|
|
|
|
set->top = btv->screen;
|
|
|
|
set->bottom = btv->screen;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (V4L2_FIELD_TOP == btv->screen->vb.field &&
|
|
|
|
NULL == set->top) {
|
|
|
|
set->top = btv->screen;
|
|
|
|
}
|
|
|
|
if (V4L2_FIELD_BOTTOM == btv->screen->vb.field &&
|
|
|
|
NULL == set->bottom) {
|
|
|
|
set->bottom = btv->screen;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-22 05:56:48 +07:00
|
|
|
dprintk("%d: next set: top=%p bottom=%p [screen=%p,irq=%d,%d]\n",
|
|
|
|
btv->c.nr, set->top, set->bottom,
|
|
|
|
btv->screen, set->frame_irq, set->top_irq);
|
2005-04-17 05:20:36 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
bttv_irq_wakeup_video(struct bttv *btv, struct bttv_buffer_set *wakeup,
|
|
|
|
struct bttv_buffer_set *curr, unsigned int state)
|
|
|
|
{
|
|
|
|
struct timeval ts;
|
|
|
|
|
2012-09-16 01:14:42 +07:00
|
|
|
v4l2_get_timestamp(&ts);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
if (wakeup->top == wakeup->bottom) {
|
|
|
|
if (NULL != wakeup->top && curr->top != wakeup->top) {
|
|
|
|
if (irq_debug > 1)
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_debug("%d: wakeup: both=%p\n",
|
|
|
|
btv->c.nr, wakeup->top);
|
2005-04-17 05:20:36 +07:00
|
|
|
wakeup->top->vb.ts = ts;
|
|
|
|
wakeup->top->vb.field_count = btv->field_count;
|
|
|
|
wakeup->top->vb.state = state;
|
|
|
|
wake_up(&wakeup->top->vb.done);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (NULL != wakeup->top && curr->top != wakeup->top) {
|
|
|
|
if (irq_debug > 1)
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_debug("%d: wakeup: top=%p\n",
|
|
|
|
btv->c.nr, wakeup->top);
|
2005-04-17 05:20:36 +07:00
|
|
|
wakeup->top->vb.ts = ts;
|
|
|
|
wakeup->top->vb.field_count = btv->field_count;
|
|
|
|
wakeup->top->vb.state = state;
|
|
|
|
wake_up(&wakeup->top->vb.done);
|
|
|
|
}
|
|
|
|
if (NULL != wakeup->bottom && curr->bottom != wakeup->bottom) {
|
|
|
|
if (irq_debug > 1)
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_debug("%d: wakeup: bottom=%p\n",
|
|
|
|
btv->c.nr, wakeup->bottom);
|
2005-04-17 05:20:36 +07:00
|
|
|
wakeup->bottom->vb.ts = ts;
|
|
|
|
wakeup->bottom->vb.field_count = btv->field_count;
|
|
|
|
wakeup->bottom->vb.state = state;
|
|
|
|
wake_up(&wakeup->bottom->vb.done);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
bttv_irq_wakeup_vbi(struct bttv *btv, struct bttv_buffer *wakeup,
|
|
|
|
unsigned int state)
|
|
|
|
{
|
|
|
|
if (NULL == wakeup)
|
|
|
|
return;
|
|
|
|
|
2015-09-18 04:19:37 +07:00
|
|
|
v4l2_get_timestamp(&wakeup->vb.ts);
|
2005-04-17 05:20:36 +07:00
|
|
|
wakeup->vb.field_count = btv->field_count;
|
|
|
|
wakeup->vb.state = state;
|
|
|
|
wake_up(&wakeup->vb.done);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void bttv_irq_timeout(unsigned long data)
|
|
|
|
{
|
|
|
|
struct bttv *btv = (struct bttv *)data;
|
|
|
|
struct bttv_buffer_set old,new;
|
|
|
|
struct bttv_buffer *ovbi;
|
|
|
|
struct bttv_buffer *item;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
if (bttv_verbose) {
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_info("%d: timeout: drop=%d irq=%d/%d, risc=%08x, ",
|
|
|
|
btv->c.nr, btv->framedrop, btv->irq_me, btv->irq_total,
|
|
|
|
btread(BT848_RISC_COUNT));
|
2005-04-17 05:20:36 +07:00
|
|
|
bttv_print_irqbits(btread(BT848_INT_STAT),0);
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_cont("\n");
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
spin_lock_irqsave(&btv->s_lock,flags);
|
|
|
|
|
|
|
|
/* deactivate stuff */
|
|
|
|
memset(&new,0,sizeof(new));
|
|
|
|
old = btv->curr;
|
|
|
|
ovbi = btv->cvbi;
|
|
|
|
btv->curr = new;
|
|
|
|
btv->cvbi = NULL;
|
|
|
|
btv->loop_irq = 0;
|
|
|
|
bttv_buffer_activate_video(btv, &new);
|
|
|
|
bttv_buffer_activate_vbi(btv, NULL);
|
|
|
|
bttv_set_dma(btv, 0);
|
|
|
|
|
|
|
|
/* wake up */
|
2007-11-07 06:02:36 +07:00
|
|
|
bttv_irq_wakeup_video(btv, &old, &new, VIDEOBUF_ERROR);
|
|
|
|
bttv_irq_wakeup_vbi(btv, ovbi, VIDEOBUF_ERROR);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* cancel all outstanding capture / vbi requests */
|
|
|
|
while (!list_empty(&btv->capture)) {
|
|
|
|
item = list_entry(btv->capture.next, struct bttv_buffer, vb.queue);
|
|
|
|
list_del(&item->vb.queue);
|
2007-11-07 06:02:36 +07:00
|
|
|
item->vb.state = VIDEOBUF_ERROR;
|
2005-04-17 05:20:36 +07:00
|
|
|
wake_up(&item->vb.done);
|
|
|
|
}
|
|
|
|
while (!list_empty(&btv->vcapture)) {
|
|
|
|
item = list_entry(btv->vcapture.next, struct bttv_buffer, vb.queue);
|
|
|
|
list_del(&item->vb.queue);
|
2007-11-07 06:02:36 +07:00
|
|
|
item->vb.state = VIDEOBUF_ERROR;
|
2005-04-17 05:20:36 +07:00
|
|
|
wake_up(&item->vb.done);
|
|
|
|
}
|
|
|
|
|
|
|
|
btv->errors++;
|
|
|
|
spin_unlock_irqrestore(&btv->s_lock,flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
bttv_irq_wakeup_top(struct bttv *btv)
|
|
|
|
{
|
|
|
|
struct bttv_buffer *wakeup = btv->curr.top;
|
|
|
|
|
|
|
|
if (NULL == wakeup)
|
|
|
|
return;
|
|
|
|
|
|
|
|
spin_lock(&btv->s_lock);
|
|
|
|
btv->curr.top_irq = 0;
|
|
|
|
btv->curr.top = NULL;
|
|
|
|
bttv_risc_hook(btv, RISC_SLOT_O_FIELD, NULL, 0);
|
|
|
|
|
2012-09-16 01:14:42 +07:00
|
|
|
v4l2_get_timestamp(&wakeup->vb.ts);
|
2005-04-17 05:20:36 +07:00
|
|
|
wakeup->vb.field_count = btv->field_count;
|
2007-11-07 06:02:36 +07:00
|
|
|
wakeup->vb.state = VIDEOBUF_DONE;
|
2005-04-17 05:20:36 +07:00
|
|
|
wake_up(&wakeup->vb.done);
|
|
|
|
spin_unlock(&btv->s_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int is_active(struct btcx_riscmem *risc, u32 rc)
|
|
|
|
{
|
|
|
|
if (rc < risc->dma)
|
|
|
|
return 0;
|
|
|
|
if (rc > risc->dma + risc->size)
|
|
|
|
return 0;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
bttv_irq_switch_video(struct bttv *btv)
|
|
|
|
{
|
|
|
|
struct bttv_buffer_set new;
|
|
|
|
struct bttv_buffer_set old;
|
|
|
|
dma_addr_t rc;
|
|
|
|
|
|
|
|
spin_lock(&btv->s_lock);
|
|
|
|
|
|
|
|
/* new buffer set */
|
|
|
|
bttv_irq_next_video(btv, &new);
|
|
|
|
rc = btread(BT848_RISC_COUNT);
|
|
|
|
if ((btv->curr.top && is_active(&btv->curr.top->top, rc)) ||
|
|
|
|
(btv->curr.bottom && is_active(&btv->curr.bottom->bottom, rc))) {
|
|
|
|
btv->framedrop++;
|
|
|
|
if (debug_latency)
|
|
|
|
bttv_irq_debug_low_latency(btv, rc);
|
|
|
|
spin_unlock(&btv->s_lock);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* switch over */
|
|
|
|
old = btv->curr;
|
|
|
|
btv->curr = new;
|
|
|
|
btv->loop_irq &= ~1;
|
|
|
|
bttv_buffer_activate_video(btv, &new);
|
|
|
|
bttv_set_dma(btv, 0);
|
|
|
|
|
|
|
|
/* switch input */
|
|
|
|
if (UNSET != btv->new_input) {
|
|
|
|
video_mux(btv,btv->new_input);
|
|
|
|
btv->new_input = UNSET;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* wake up finished buffers */
|
2007-11-07 06:02:36 +07:00
|
|
|
bttv_irq_wakeup_video(btv, &old, &new, VIDEOBUF_DONE);
|
2005-04-17 05:20:36 +07:00
|
|
|
spin_unlock(&btv->s_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
bttv_irq_switch_vbi(struct bttv *btv)
|
|
|
|
{
|
|
|
|
struct bttv_buffer *new = NULL;
|
|
|
|
struct bttv_buffer *old;
|
|
|
|
u32 rc;
|
|
|
|
|
|
|
|
spin_lock(&btv->s_lock);
|
|
|
|
|
|
|
|
if (!list_empty(&btv->vcapture))
|
|
|
|
new = list_entry(btv->vcapture.next, struct bttv_buffer, vb.queue);
|
|
|
|
old = btv->cvbi;
|
|
|
|
|
|
|
|
rc = btread(BT848_RISC_COUNT);
|
|
|
|
if (NULL != old && (is_active(&old->top, rc) ||
|
|
|
|
is_active(&old->bottom, rc))) {
|
|
|
|
btv->framedrop++;
|
|
|
|
if (debug_latency)
|
|
|
|
bttv_irq_debug_low_latency(btv, rc);
|
|
|
|
spin_unlock(&btv->s_lock);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* switch */
|
|
|
|
btv->cvbi = new;
|
|
|
|
btv->loop_irq &= ~4;
|
|
|
|
bttv_buffer_activate_vbi(btv, new);
|
|
|
|
bttv_set_dma(btv, 0);
|
|
|
|
|
2007-11-07 06:02:36 +07:00
|
|
|
bttv_irq_wakeup_vbi(btv, old, VIDEOBUF_DONE);
|
2005-04-17 05:20:36 +07:00
|
|
|
spin_unlock(&btv->s_lock);
|
|
|
|
}
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 20:55:46 +07:00
|
|
|
static irqreturn_t bttv_irq(int irq, void *dev_id)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
u32 stat,astat;
|
|
|
|
u32 dstat;
|
|
|
|
int count;
|
|
|
|
struct bttv *btv;
|
|
|
|
int handled = 0;
|
|
|
|
|
|
|
|
btv=(struct bttv *)dev_id;
|
2005-11-14 07:07:52 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
count=0;
|
|
|
|
while (1) {
|
|
|
|
/* get/clear interrupt status bits */
|
|
|
|
stat=btread(BT848_INT_STAT);
|
|
|
|
astat=stat&btread(BT848_INT_MASK);
|
|
|
|
if (!astat)
|
|
|
|
break;
|
|
|
|
handled = 1;
|
|
|
|
btwrite(stat,BT848_INT_STAT);
|
|
|
|
|
|
|
|
/* get device status bits */
|
|
|
|
dstat=btread(BT848_DSTATUS);
|
|
|
|
|
|
|
|
if (irq_debug) {
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_debug("%d: irq loop=%d fc=%d riscs=%x, riscc=%08x, ",
|
|
|
|
btv->c.nr, count, btv->field_count,
|
|
|
|
stat>>28, btread(BT848_RISC_COUNT));
|
2005-04-17 05:20:36 +07:00
|
|
|
bttv_print_irqbits(stat,astat);
|
|
|
|
if (stat & BT848_INT_HLOCK)
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_cont(" HLOC => %s",
|
|
|
|
dstat & BT848_DSTATUS_HLOC
|
|
|
|
? "yes" : "no");
|
2005-04-17 05:20:36 +07:00
|
|
|
if (stat & BT848_INT_VPRES)
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_cont(" PRES => %s",
|
|
|
|
dstat & BT848_DSTATUS_PRES
|
|
|
|
? "yes" : "no");
|
2005-04-17 05:20:36 +07:00
|
|
|
if (stat & BT848_INT_FMTCHG)
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_cont(" NUML => %s",
|
|
|
|
dstat & BT848_DSTATUS_NUML
|
|
|
|
? "625" : "525");
|
|
|
|
pr_cont("\n");
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (astat&BT848_INT_VSYNC)
|
2005-11-09 12:37:43 +07:00
|
|
|
btv->field_count++;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2006-01-10 00:25:25 +07:00
|
|
|
if ((astat & BT848_INT_GPINT) && btv->remote) {
|
|
|
|
bttv_input_irq(btv);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (astat & BT848_INT_I2CDONE) {
|
|
|
|
btv->i2c_done = stat;
|
|
|
|
wake_up(&btv->i2c_queue);
|
|
|
|
}
|
|
|
|
|
2005-11-09 12:37:43 +07:00
|
|
|
if ((astat & BT848_INT_RISCI) && (stat & (4<<28)))
|
2005-04-17 05:20:36 +07:00
|
|
|
bttv_irq_switch_vbi(btv);
|
|
|
|
|
2005-11-09 12:37:43 +07:00
|
|
|
if ((astat & BT848_INT_RISCI) && (stat & (2<<28)))
|
2005-04-17 05:20:36 +07:00
|
|
|
bttv_irq_wakeup_top(btv);
|
|
|
|
|
2005-11-09 12:37:43 +07:00
|
|
|
if ((astat & BT848_INT_RISCI) && (stat & (1<<28)))
|
2005-04-17 05:20:36 +07:00
|
|
|
bttv_irq_switch_video(btv);
|
|
|
|
|
|
|
|
if ((astat & BT848_INT_HLOCK) && btv->opt_automute)
|
2013-03-21 23:51:17 +07:00
|
|
|
/* trigger automute */
|
|
|
|
audio_mux_gpio(btv, btv->audio_input, btv->mute);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
if (astat & (BT848_INT_SCERR|BT848_INT_OCERR)) {
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_info("%d: %s%s @ %08x,",
|
|
|
|
btv->c.nr,
|
|
|
|
(astat & BT848_INT_SCERR) ? "SCERR" : "",
|
|
|
|
(astat & BT848_INT_OCERR) ? "OCERR" : "",
|
|
|
|
btread(BT848_RISC_COUNT));
|
2005-04-17 05:20:36 +07:00
|
|
|
bttv_print_irqbits(stat,astat);
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_cont("\n");
|
2005-04-17 05:20:36 +07:00
|
|
|
if (bttv_debug)
|
|
|
|
bttv_print_riscaddr(btv);
|
|
|
|
}
|
|
|
|
if (fdsr && astat & BT848_INT_FDSR) {
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_info("%d: FDSR @ %08x\n",
|
|
|
|
btv->c.nr, btread(BT848_RISC_COUNT));
|
2005-04-17 05:20:36 +07:00
|
|
|
if (bttv_debug)
|
|
|
|
bttv_print_riscaddr(btv);
|
|
|
|
}
|
|
|
|
|
|
|
|
count++;
|
|
|
|
if (count > 4) {
|
2005-11-09 12:37:41 +07:00
|
|
|
|
|
|
|
if (count > 8 || !(astat & BT848_INT_GPINT)) {
|
2005-11-09 12:37:43 +07:00
|
|
|
btwrite(0, BT848_INT_MASK);
|
2005-11-09 12:37:41 +07:00
|
|
|
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_err("%d: IRQ lockup, cleared int mask [",
|
|
|
|
btv->c.nr);
|
2005-11-09 12:37:41 +07:00
|
|
|
} else {
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_err("%d: IRQ lockup, clearing GPINT from int mask [",
|
|
|
|
btv->c.nr);
|
2005-11-09 12:37:41 +07:00
|
|
|
|
|
|
|
btwrite(btread(BT848_INT_MASK) & (-1 ^ BT848_INT_GPINT),
|
|
|
|
BT848_INT_MASK);
|
2014-09-04 01:32:07 +07:00
|
|
|
}
|
2005-11-09 12:37:41 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
bttv_print_irqbits(stat,astat);
|
2005-11-09 12:37:41 +07:00
|
|
|
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_cont("]\n");
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
btv->irq_total++;
|
|
|
|
if (handled)
|
|
|
|
btv->irq_me++;
|
|
|
|
return IRQ_RETVAL(handled);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------- */
|
2013-02-06 21:43:07 +07:00
|
|
|
/* initialization */
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2015-03-09 23:34:02 +07:00
|
|
|
static void vdev_init(struct bttv *btv,
|
|
|
|
struct video_device *vfd,
|
|
|
|
const struct video_device *template,
|
|
|
|
const char *type_name)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
*vfd = *template;
|
2009-03-14 22:36:54 +07:00
|
|
|
vfd->v4l2_dev = &btv->c.v4l2_dev;
|
2015-03-09 23:34:02 +07:00
|
|
|
vfd->release = video_device_release_empty;
|
2009-01-29 07:32:59 +07:00
|
|
|
video_set_drvdata(vfd, btv);
|
2005-04-17 05:20:36 +07:00
|
|
|
snprintf(vfd->name, sizeof(vfd->name), "BT%d%s %s (%s)",
|
|
|
|
btv->id, (btv->id==848 && btv->revision==0x12) ? "A" : "",
|
2007-12-28 08:28:31 +07:00
|
|
|
type_name, bttv_tvcards[btv->c.type].name);
|
2013-02-06 21:43:07 +07:00
|
|
|
if (btv->tuner_type == TUNER_ABSENT) {
|
|
|
|
v4l2_disable_ioctl(vfd, VIDIOC_G_FREQUENCY);
|
|
|
|
v4l2_disable_ioctl(vfd, VIDIOC_S_FREQUENCY);
|
|
|
|
v4l2_disable_ioctl(vfd, VIDIOC_G_TUNER);
|
|
|
|
v4l2_disable_ioctl(vfd, VIDIOC_S_TUNER);
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void bttv_unregister_video(struct bttv *btv)
|
|
|
|
{
|
2015-03-09 23:34:02 +07:00
|
|
|
video_unregister_device(&btv->video_dev);
|
|
|
|
video_unregister_device(&btv->vbi_dev);
|
|
|
|
video_unregister_device(&btv->radio_dev);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* register video4linux devices */
|
2012-12-22 04:17:53 +07:00
|
|
|
static int bttv_register_video(struct bttv *btv)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2008-07-26 18:26:43 +07:00
|
|
|
if (no_overlay > 0)
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_notice("Overlay support disabled\n");
|
2005-08-05 02:53:30 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* video */
|
2015-03-09 23:34:02 +07:00
|
|
|
vdev_init(btv, &btv->video_dev, &bttv_video_template, "video");
|
2007-12-28 08:28:31 +07:00
|
|
|
|
2015-03-09 23:34:02 +07:00
|
|
|
if (video_register_device(&btv->video_dev, VFL_TYPE_GRABBER,
|
2008-09-07 22:49:59 +07:00
|
|
|
video_nr[btv->c.nr]) < 0)
|
2005-04-17 05:20:36 +07:00
|
|
|
goto err;
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_info("%d: registered device %s\n",
|
2015-03-09 23:34:02 +07:00
|
|
|
btv->c.nr, video_device_node_name(&btv->video_dev));
|
|
|
|
if (device_create_file(&btv->video_dev.dev,
|
2007-10-09 02:26:13 +07:00
|
|
|
&dev_attr_card)<0) {
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_err("%d: device_create_file 'card' failed\n", btv->c.nr);
|
2006-07-30 03:18:06 +07:00
|
|
|
goto err;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* vbi */
|
2015-03-09 23:34:02 +07:00
|
|
|
vdev_init(btv, &btv->vbi_dev, &bttv_video_template, "vbi");
|
2007-12-28 08:28:31 +07:00
|
|
|
|
2015-03-09 23:34:02 +07:00
|
|
|
if (video_register_device(&btv->vbi_dev, VFL_TYPE_VBI,
|
2008-09-07 22:49:59 +07:00
|
|
|
vbi_nr[btv->c.nr]) < 0)
|
2005-04-17 05:20:36 +07:00
|
|
|
goto err;
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_info("%d: registered device %s\n",
|
2015-03-09 23:34:02 +07:00
|
|
|
btv->c.nr, video_device_node_name(&btv->vbi_dev));
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-11-09 12:37:43 +07:00
|
|
|
if (!btv->has_radio)
|
2005-04-17 05:20:36 +07:00
|
|
|
return 0;
|
|
|
|
/* radio */
|
2015-03-09 23:34:02 +07:00
|
|
|
vdev_init(btv, &btv->radio_dev, &radio_template, "radio");
|
|
|
|
btv->radio_dev.ctrl_handler = &btv->radio_ctrl_handler;
|
|
|
|
if (video_register_device(&btv->radio_dev, VFL_TYPE_RADIO,
|
2008-09-07 22:49:59 +07:00
|
|
|
radio_nr[btv->c.nr]) < 0)
|
2005-04-17 05:20:36 +07:00
|
|
|
goto err;
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_info("%d: registered device %s\n",
|
2015-03-09 23:34:02 +07:00
|
|
|
btv->c.nr, video_device_node_name(&btv->radio_dev));
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* all done */
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err:
|
|
|
|
bttv_unregister_video(btv);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* on OpenFirmware machines (PowerMac at least), PCI memory cycle */
|
|
|
|
/* response on cards with no firmware is not enabled by OF */
|
|
|
|
static void pci_set_command(struct pci_dev *dev)
|
|
|
|
{
|
|
|
|
#if defined(__powerpc__)
|
2005-11-09 12:37:43 +07:00
|
|
|
unsigned int cmd;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-11-09 12:37:43 +07:00
|
|
|
pci_read_config_dword(dev, PCI_COMMAND, &cmd);
|
|
|
|
cmd = (cmd | PCI_COMMAND_MEMORY );
|
|
|
|
pci_write_config_dword(dev, PCI_COMMAND, cmd);
|
2005-04-17 05:20:36 +07:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-12-22 04:17:53 +07:00
|
|
|
static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2013-02-06 21:49:14 +07:00
|
|
|
struct v4l2_frequency init_freq = {
|
|
|
|
.tuner = 0,
|
|
|
|
.type = V4L2_TUNER_ANALOG_TV,
|
|
|
|
.frequency = 980,
|
|
|
|
};
|
2005-04-17 05:20:36 +07:00
|
|
|
int result;
|
|
|
|
unsigned char lat;
|
|
|
|
struct bttv *btv;
|
2013-02-06 22:40:28 +07:00
|
|
|
struct v4l2_ctrl_handler *hdl;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
if (bttv_num == BTTV_MAX)
|
|
|
|
return -ENOMEM;
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_info("Bt8xx card found (%d)\n", bttv_num);
|
2009-01-29 07:32:59 +07:00
|
|
|
bttvs[bttv_num] = btv = kzalloc(sizeof(*btv), GFP_KERNEL);
|
2009-03-14 22:36:54 +07:00
|
|
|
if (btv == NULL) {
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_err("out of memory\n");
|
2009-03-14 22:36:54 +07:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
btv->c.nr = bttv_num;
|
2009-03-14 22:36:54 +07:00
|
|
|
snprintf(btv->c.v4l2_dev.name, sizeof(btv->c.v4l2_dev.name),
|
|
|
|
"bttv%d", btv->c.nr);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* initialize structs / fill in defaults */
|
2006-01-13 23:10:24 +07:00
|
|
|
mutex_init(&btv->lock);
|
2005-11-09 12:37:43 +07:00
|
|
|
spin_lock_init(&btv->s_lock);
|
|
|
|
spin_lock_init(&btv->gpio_lock);
|
|
|
|
init_waitqueue_head(&btv->i2c_queue);
|
|
|
|
INIT_LIST_HEAD(&btv->c.subs);
|
|
|
|
INIT_LIST_HEAD(&btv->capture);
|
|
|
|
INIT_LIST_HEAD(&btv->vcapture);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
init_timer(&btv->timeout);
|
|
|
|
btv->timeout.function = bttv_irq_timeout;
|
|
|
|
btv->timeout.data = (unsigned long)btv;
|
|
|
|
|
2005-11-09 12:36:21 +07:00
|
|
|
btv->i2c_rc = -1;
|
|
|
|
btv->tuner_type = UNSET;
|
2005-04-17 05:20:36 +07:00
|
|
|
btv->new_input = UNSET;
|
|
|
|
btv->has_radio=radio[btv->c.nr];
|
|
|
|
|
|
|
|
/* pci stuff (init, get irq/mmio, ... */
|
|
|
|
btv->c.pci = dev;
|
2005-11-09 12:36:21 +07:00
|
|
|
btv->id = dev->device;
|
2005-04-17 05:20:36 +07:00
|
|
|
if (pci_enable_device(dev)) {
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_warn("%d: Can't enable device\n", btv->c.nr);
|
2005-04-17 05:20:36 +07:00
|
|
|
return -EIO;
|
|
|
|
}
|
2009-04-07 09:01:15 +07:00
|
|
|
if (pci_set_dma_mask(dev, DMA_BIT_MASK(32))) {
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_warn("%d: No suitable DMA available\n", btv->c.nr);
|
2005-04-17 05:20:36 +07:00
|
|
|
return -EIO;
|
2005-11-09 12:37:43 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
if (!request_mem_region(pci_resource_start(dev,0),
|
|
|
|
pci_resource_len(dev,0),
|
2009-03-14 22:36:54 +07:00
|
|
|
btv->c.v4l2_dev.name)) {
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_warn("%d: can't request iomem (0x%llx)\n",
|
|
|
|
btv->c.nr,
|
|
|
|
(unsigned long long)pci_resource_start(dev, 0));
|
2005-04-17 05:20:36 +07:00
|
|
|
return -EBUSY;
|
|
|
|
}
|
2005-11-09 12:37:43 +07:00
|
|
|
pci_set_master(dev);
|
2005-04-17 05:20:36 +07:00
|
|
|
pci_set_command(dev);
|
2009-03-14 22:36:54 +07:00
|
|
|
|
|
|
|
result = v4l2_device_register(&dev->dev, &btv->c.v4l2_dev);
|
|
|
|
if (result < 0) {
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_warn("%d: v4l2_device_register() failed\n", btv->c.nr);
|
2009-03-14 22:36:54 +07:00
|
|
|
goto fail0;
|
|
|
|
}
|
2013-02-06 22:40:28 +07:00
|
|
|
hdl = &btv->ctrl_handler;
|
|
|
|
v4l2_ctrl_handler_init(hdl, 20);
|
|
|
|
btv->c.v4l2_dev.ctrl_handler = hdl;
|
|
|
|
v4l2_ctrl_handler_init(&btv->radio_ctrl_handler, 6);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2011-03-21 21:35:56 +07:00
|
|
|
btv->revision = dev->revision;
|
2005-11-09 12:37:43 +07:00
|
|
|
pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_info("%d: Bt%d (rev %d) at %s, irq: %d, latency: %d, mmio: 0x%llx\n",
|
|
|
|
bttv_num, btv->id, btv->revision, pci_name(dev),
|
|
|
|
btv->c.pci->irq, lat,
|
|
|
|
(unsigned long long)pci_resource_start(dev, 0));
|
2005-04-17 05:20:36 +07:00
|
|
|
schedule();
|
|
|
|
|
2006-12-20 20:08:56 +07:00
|
|
|
btv->bt848_mmio = ioremap(pci_resource_start(dev, 0), 0x1000);
|
|
|
|
if (NULL == btv->bt848_mmio) {
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_err("%d: ioremap() failed\n", btv->c.nr);
|
2005-04-17 05:20:36 +07:00
|
|
|
result = -EIO;
|
|
|
|
goto fail1;
|
|
|
|
}
|
|
|
|
|
2005-11-09 12:37:43 +07:00
|
|
|
/* identify card */
|
2005-04-17 05:20:36 +07:00
|
|
|
bttv_idcard(btv);
|
|
|
|
|
2005-11-09 12:37:43 +07:00
|
|
|
/* disable irqs, register irq handler */
|
2005-04-17 05:20:36 +07:00
|
|
|
btwrite(0, BT848_INT_MASK);
|
2005-11-09 12:37:43 +07:00
|
|
|
result = request_irq(btv->c.pci->irq, bttv_irq,
|
2013-10-13 12:49:29 +07:00
|
|
|
IRQF_SHARED, btv->c.v4l2_dev.name, (void *)btv);
|
2005-11-09 12:37:43 +07:00
|
|
|
if (result < 0) {
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_err("%d: can't get IRQ %d\n",
|
|
|
|
bttv_num, btv->c.pci->irq);
|
2005-04-17 05:20:36 +07:00
|
|
|
goto fail1;
|
2005-11-09 12:37:43 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
if (0 != bttv_handle_chipset(btv)) {
|
|
|
|
result = -EIO;
|
|
|
|
goto fail2;
|
2005-11-09 12:37:43 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* init options from insmod args */
|
|
|
|
btv->opt_combfilter = combfilter;
|
2013-02-06 22:40:28 +07:00
|
|
|
bttv_ctrl_combfilter.def = combfilter;
|
|
|
|
bttv_ctrl_lumafilter.def = lumafilter;
|
2005-04-17 05:20:36 +07:00
|
|
|
btv->opt_automute = automute;
|
2013-02-06 22:40:28 +07:00
|
|
|
bttv_ctrl_automute.def = automute;
|
|
|
|
bttv_ctrl_agc_crush.def = agc_crush;
|
2005-04-17 05:20:36 +07:00
|
|
|
btv->opt_vcr_hack = vcr_hack;
|
2013-02-06 22:40:28 +07:00
|
|
|
bttv_ctrl_vcr_hack.def = vcr_hack;
|
|
|
|
bttv_ctrl_whitecrush_upper.def = whitecrush_upper;
|
|
|
|
bttv_ctrl_whitecrush_lower.def = whitecrush_lower;
|
2005-06-29 10:45:25 +07:00
|
|
|
btv->opt_uv_ratio = uv_ratio;
|
2013-02-06 22:40:28 +07:00
|
|
|
bttv_ctrl_uv_ratio.def = uv_ratio;
|
|
|
|
bttv_ctrl_full_luma.def = full_luma_range;
|
|
|
|
bttv_ctrl_coring.def = coring;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* fill struct bttv with some useful defaults */
|
|
|
|
btv->init.btv = btv;
|
|
|
|
btv->init.ov.w.width = 320;
|
|
|
|
btv->init.ov.w.height = 240;
|
2007-10-27 02:51:47 +07:00
|
|
|
btv->init.fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24);
|
2005-04-17 05:20:36 +07:00
|
|
|
btv->init.width = 320;
|
|
|
|
btv->init.height = 240;
|
2013-02-07 17:56:11 +07:00
|
|
|
btv->init.ov.w.width = 320;
|
|
|
|
btv->init.ov.w.height = 240;
|
|
|
|
btv->init.ov.field = V4L2_FIELD_INTERLACED;
|
2005-04-17 05:20:36 +07:00
|
|
|
btv->input = 0;
|
|
|
|
|
2013-02-06 22:40:28 +07:00
|
|
|
v4l2_ctrl_new_std(hdl, &bttv_ctrl_ops,
|
|
|
|
V4L2_CID_BRIGHTNESS, 0, 0xff00, 0x100, 32768);
|
|
|
|
v4l2_ctrl_new_std(hdl, &bttv_ctrl_ops,
|
|
|
|
V4L2_CID_CONTRAST, 0, 0xff80, 0x80, 0x6c00);
|
|
|
|
v4l2_ctrl_new_std(hdl, &bttv_ctrl_ops,
|
|
|
|
V4L2_CID_SATURATION, 0, 0xff80, 0x80, 32768);
|
|
|
|
v4l2_ctrl_new_std(hdl, &bttv_ctrl_ops,
|
|
|
|
V4L2_CID_COLOR_KILLER, 0, 1, 1, 0);
|
|
|
|
v4l2_ctrl_new_std(hdl, &bttv_ctrl_ops,
|
|
|
|
V4L2_CID_HUE, 0, 0xff00, 0x100, 32768);
|
|
|
|
v4l2_ctrl_new_std(hdl, &bttv_ctrl_ops,
|
|
|
|
V4L2_CID_CHROMA_AGC, 0, 1, 1, !!chroma_agc);
|
|
|
|
v4l2_ctrl_new_std(hdl, &bttv_ctrl_ops,
|
|
|
|
V4L2_CID_AUDIO_MUTE, 0, 1, 1, 0);
|
|
|
|
if (btv->volume_gpio)
|
|
|
|
v4l2_ctrl_new_std(hdl, &bttv_ctrl_ops,
|
|
|
|
V4L2_CID_AUDIO_VOLUME, 0, 0xff00, 0x100, 0xff00);
|
|
|
|
v4l2_ctrl_new_custom(hdl, &bttv_ctrl_combfilter, NULL);
|
|
|
|
v4l2_ctrl_new_custom(hdl, &bttv_ctrl_automute, NULL);
|
|
|
|
v4l2_ctrl_new_custom(hdl, &bttv_ctrl_lumafilter, NULL);
|
|
|
|
v4l2_ctrl_new_custom(hdl, &bttv_ctrl_agc_crush, NULL);
|
|
|
|
v4l2_ctrl_new_custom(hdl, &bttv_ctrl_vcr_hack, NULL);
|
|
|
|
v4l2_ctrl_new_custom(hdl, &bttv_ctrl_whitecrush_lower, NULL);
|
|
|
|
v4l2_ctrl_new_custom(hdl, &bttv_ctrl_whitecrush_upper, NULL);
|
|
|
|
v4l2_ctrl_new_custom(hdl, &bttv_ctrl_uv_ratio, NULL);
|
|
|
|
v4l2_ctrl_new_custom(hdl, &bttv_ctrl_full_luma, NULL);
|
|
|
|
v4l2_ctrl_new_custom(hdl, &bttv_ctrl_coring, NULL);
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* initialize hardware */
|
2005-11-09 12:37:43 +07:00
|
|
|
if (bttv_gpio)
|
|
|
|
bttv_gpio_tracking(btv,"pre-init");
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
bttv_risc_init_main(btv);
|
|
|
|
init_bt848(btv);
|
|
|
|
|
|
|
|
/* gpio */
|
2005-11-09 12:37:43 +07:00
|
|
|
btwrite(0x00, BT848_GPIO_REG_INP);
|
|
|
|
btwrite(0x00, BT848_GPIO_OUT_EN);
|
|
|
|
if (bttv_verbose)
|
|
|
|
bttv_gpio_tracking(btv,"init");
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-11-09 12:37:43 +07:00
|
|
|
/* needs to be done before i2c is registered */
|
|
|
|
bttv_init_card1(btv);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-11-09 12:37:43 +07:00
|
|
|
/* register i2c + gpio */
|
|
|
|
init_bttv_i2c(btv);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-11-09 12:37:43 +07:00
|
|
|
/* some card-specific stuff (needs working i2c) */
|
|
|
|
bttv_init_card2(btv);
|
2009-07-20 18:14:17 +07:00
|
|
|
bttv_init_tuner(btv);
|
2013-02-06 21:49:14 +07:00
|
|
|
if (btv->tuner_type != TUNER_ABSENT) {
|
|
|
|
bttv_set_frequency(btv, &init_freq);
|
|
|
|
btv->radio_freq = 90500 * 16; /* 90.5Mhz default */
|
|
|
|
}
|
2013-02-06 22:43:07 +07:00
|
|
|
btv->std = V4L2_STD_PAL;
|
2005-04-17 05:20:36 +07:00
|
|
|
init_irqreg(btv);
|
2013-11-11 18:16:03 +07:00
|
|
|
if (!bttv_tvcards[btv->c.type].no_video)
|
|
|
|
v4l2_ctrl_handler_setup(hdl);
|
2013-02-06 22:40:28 +07:00
|
|
|
if (hdl->error) {
|
|
|
|
result = hdl->error;
|
|
|
|
goto fail2;
|
|
|
|
}
|
2013-03-21 23:51:19 +07:00
|
|
|
/* mute device */
|
|
|
|
audio_mute(btv, 1);
|
|
|
|
|
2005-11-09 12:37:43 +07:00
|
|
|
/* register video4linux + input */
|
2005-04-17 05:20:36 +07:00
|
|
|
if (!bttv_tvcards[btv->c.type].no_video) {
|
2013-02-06 22:40:28 +07:00
|
|
|
v4l2_ctrl_add_handler(&btv->radio_ctrl_handler, hdl,
|
|
|
|
v4l2_ctrl_radio_filter);
|
|
|
|
if (btv->radio_ctrl_handler.error) {
|
|
|
|
result = btv->radio_ctrl_handler.error;
|
|
|
|
goto fail2;
|
|
|
|
}
|
V4L/DVB (5808): Bttv: fix v4l1 breaking the driver
If one uses a V4L *one* application, such as vlc or mplayer's v4l driver, as
the first user after the driver is loaded, the driver wedges itself and will
never capture properly. Even if one uses a V4L2 application later, it still
won't work.
If one uses a V4L *two* application first, such as tvtime or mplayer's v4l2
driver, then the driver will be ok. One can then run a V4L1 application, and
it will work.
It turns out the problem is with norm changing and the crop support that was
added in 2.6.21. The driver defaults to PAL, and keeps the last norm it was
set too across opens. If one changes the norm via V4L1, the cropping
parameters are not reset like they should be, and they'll remain broken across
device opens.
This patch removes the direct setting of btv->tvnorm in the V4L1 ioctl
VIDIOCSCHAN handler. The norm is set via the existing call to set_input(),
which calls set_tvnorm(), which will reset the cropping values now that it is
able to detect the norm change.
Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-07-04 01:08:10 +07:00
|
|
|
set_input(btv, 0, btv->tvnorm);
|
V4L/DVB (5077): Bttv cropping support
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-01-19 02:17:39 +07:00
|
|
|
bttv_crop_reset(&btv->crop[0], btv->tvnorm);
|
|
|
|
btv->crop[1] = btv->crop[0]; /* current = default */
|
|
|
|
disclaim_vbi_lines(btv);
|
|
|
|
disclaim_video_lines(btv);
|
2013-02-06 22:40:28 +07:00
|
|
|
bttv_register_video(btv);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2007-03-25 01:23:50 +07:00
|
|
|
/* add subdevices and autoload dvb-bt8xx if needed */
|
|
|
|
if (bttv_tvcards[btv->c.type].has_dvb) {
|
2005-04-17 05:20:36 +07:00
|
|
|
bttv_sub_add_device(&btv->c, "dvb");
|
2007-03-25 01:23:50 +07:00
|
|
|
request_modules(btv);
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2010-02-17 00:22:37 +07:00
|
|
|
if (!disable_ir) {
|
|
|
|
init_bttv_i2c_ir(btv);
|
|
|
|
bttv_input_init(btv);
|
|
|
|
}
|
2006-01-10 00:25:25 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* everything is fine */
|
|
|
|
bttv_num++;
|
2005-11-09 12:37:43 +07:00
|
|
|
return 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2009-03-14 22:36:54 +07:00
|
|
|
fail2:
|
2005-11-09 12:37:43 +07:00
|
|
|
free_irq(btv->c.pci->irq,btv);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2009-03-14 22:36:54 +07:00
|
|
|
fail1:
|
2013-02-06 22:40:28 +07:00
|
|
|
v4l2_ctrl_handler_free(&btv->ctrl_handler);
|
|
|
|
v4l2_ctrl_handler_free(&btv->radio_ctrl_handler);
|
2009-03-14 22:36:54 +07:00
|
|
|
v4l2_device_unregister(&btv->c.v4l2_dev);
|
|
|
|
|
|
|
|
fail0:
|
2005-04-17 05:20:36 +07:00
|
|
|
if (btv->bt848_mmio)
|
|
|
|
iounmap(btv->bt848_mmio);
|
|
|
|
release_mem_region(pci_resource_start(btv->c.pci,0),
|
|
|
|
pci_resource_len(btv->c.pci,0));
|
2015-04-03 18:13:14 +07:00
|
|
|
pci_disable_device(btv->c.pci);
|
2005-04-17 05:20:36 +07:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-12-22 04:17:53 +07:00
|
|
|
static void bttv_remove(struct pci_dev *pci_dev)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2009-03-14 22:36:54 +07:00
|
|
|
struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev);
|
|
|
|
struct bttv *btv = to_bttv(v4l2_dev);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
if (bttv_verbose)
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_info("%d: unloading\n", btv->c.nr);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2010-12-24 22:14:20 +07:00
|
|
|
if (bttv_tvcards[btv->c.type].has_dvb)
|
|
|
|
flush_request_modules(btv);
|
|
|
|
|
2005-11-09 12:37:43 +07:00
|
|
|
/* shutdown everything (DMA+IRQs) */
|
2005-04-17 05:20:36 +07:00
|
|
|
btand(~15, BT848_GPIO_DMA_CTL);
|
|
|
|
btwrite(0, BT848_INT_MASK);
|
|
|
|
btwrite(~0x0, BT848_INT_STAT);
|
|
|
|
btwrite(0x0, BT848_GPIO_OUT_EN);
|
|
|
|
if (bttv_gpio)
|
|
|
|
bttv_gpio_tracking(btv,"cleanup");
|
|
|
|
|
|
|
|
/* tell gpio modules we are leaving ... */
|
|
|
|
btv->shutdown=1;
|
2006-01-10 00:25:25 +07:00
|
|
|
bttv_input_fini(btv);
|
2006-01-10 00:25:28 +07:00
|
|
|
bttv_sub_del_devices(&btv->c);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-11-09 12:37:43 +07:00
|
|
|
/* unregister i2c_bus + input */
|
2005-04-17 05:20:36 +07:00
|
|
|
fini_bttv_i2c(btv);
|
|
|
|
|
|
|
|
/* unregister video4linux */
|
|
|
|
bttv_unregister_video(btv);
|
|
|
|
|
|
|
|
/* free allocated memory */
|
2013-02-06 22:40:28 +07:00
|
|
|
v4l2_ctrl_handler_free(&btv->ctrl_handler);
|
|
|
|
v4l2_ctrl_handler_free(&btv->radio_ctrl_handler);
|
2005-04-17 05:20:36 +07:00
|
|
|
btcx_riscmem_free(btv->c.pci,&btv->main);
|
|
|
|
|
2013-02-06 22:40:28 +07:00
|
|
|
/* free resources */
|
2005-11-09 12:37:43 +07:00
|
|
|
free_irq(btv->c.pci->irq,btv);
|
2005-04-17 05:20:36 +07:00
|
|
|
iounmap(btv->bt848_mmio);
|
2005-11-09 12:37:43 +07:00
|
|
|
release_mem_region(pci_resource_start(btv->c.pci,0),
|
|
|
|
pci_resource_len(btv->c.pci,0));
|
2015-04-03 18:13:14 +07:00
|
|
|
pci_disable_device(btv->c.pci);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2009-03-14 22:36:54 +07:00
|
|
|
v4l2_device_unregister(&btv->c.v4l2_dev);
|
2009-01-29 07:32:59 +07:00
|
|
|
bttvs[btv->c.nr] = NULL;
|
|
|
|
kfree(btv);
|
|
|
|
|
2005-11-09 12:37:43 +07:00
|
|
|
return;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2006-08-13 08:01:27 +07:00
|
|
|
#ifdef CONFIG_PM
|
2005-04-17 05:20:36 +07:00
|
|
|
static int bttv_suspend(struct pci_dev *pci_dev, pm_message_t state)
|
|
|
|
{
|
2009-03-14 22:36:54 +07:00
|
|
|
struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev);
|
|
|
|
struct bttv *btv = to_bttv(v4l2_dev);
|
2005-04-17 05:20:36 +07:00
|
|
|
struct bttv_buffer_set idle;
|
|
|
|
unsigned long flags;
|
|
|
|
|
2011-08-22 05:56:48 +07:00
|
|
|
dprintk("%d: suspend %d\n", btv->c.nr, state.event);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* stop dma + irqs */
|
|
|
|
spin_lock_irqsave(&btv->s_lock,flags);
|
|
|
|
memset(&idle, 0, sizeof(idle));
|
|
|
|
btv->state.video = btv->curr;
|
|
|
|
btv->state.vbi = btv->cvbi;
|
|
|
|
btv->state.loop_irq = btv->loop_irq;
|
|
|
|
btv->curr = idle;
|
|
|
|
btv->loop_irq = 0;
|
|
|
|
bttv_buffer_activate_video(btv, &idle);
|
|
|
|
bttv_buffer_activate_vbi(btv, NULL);
|
|
|
|
bttv_set_dma(btv, 0);
|
|
|
|
btwrite(0, BT848_INT_MASK);
|
|
|
|
spin_unlock_irqrestore(&btv->s_lock,flags);
|
|
|
|
|
|
|
|
/* save bt878 state */
|
|
|
|
btv->state.gpio_enable = btread(BT848_GPIO_OUT_EN);
|
|
|
|
btv->state.gpio_data = gpio_read();
|
|
|
|
|
|
|
|
/* save pci state */
|
|
|
|
pci_save_state(pci_dev);
|
|
|
|
if (0 != pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state))) {
|
|
|
|
pci_disable_device(pci_dev);
|
|
|
|
btv->state.disabled = 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int bttv_resume(struct pci_dev *pci_dev)
|
|
|
|
{
|
2009-03-14 22:36:54 +07:00
|
|
|
struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev);
|
|
|
|
struct bttv *btv = to_bttv(v4l2_dev);
|
2005-04-17 05:20:36 +07:00
|
|
|
unsigned long flags;
|
2005-09-10 03:03:55 +07:00
|
|
|
int err;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2011-08-22 05:56:48 +07:00
|
|
|
dprintk("%d: resume\n", btv->c.nr);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* restore pci state */
|
|
|
|
if (btv->state.disabled) {
|
2005-09-10 03:03:55 +07:00
|
|
|
err=pci_enable_device(pci_dev);
|
|
|
|
if (err) {
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_warn("%d: Can't enable device\n", btv->c.nr);
|
2005-09-10 03:03:55 +07:00
|
|
|
return err;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
btv->state.disabled = 0;
|
|
|
|
}
|
2005-09-10 03:03:55 +07:00
|
|
|
err=pci_set_power_state(pci_dev, PCI_D0);
|
|
|
|
if (err) {
|
|
|
|
pci_disable_device(pci_dev);
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_warn("%d: Can't enable device\n", btv->c.nr);
|
2005-09-10 03:03:55 +07:00
|
|
|
btv->state.disabled = 1;
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
pci_restore_state(pci_dev);
|
|
|
|
|
|
|
|
/* restore bt878 state */
|
|
|
|
bttv_reinit_bt848(btv);
|
|
|
|
gpio_inout(0xffffff, btv->state.gpio_enable);
|
|
|
|
gpio_write(btv->state.gpio_data);
|
|
|
|
|
|
|
|
/* restart dma */
|
|
|
|
spin_lock_irqsave(&btv->s_lock,flags);
|
|
|
|
btv->curr = btv->state.video;
|
|
|
|
btv->cvbi = btv->state.vbi;
|
|
|
|
btv->loop_irq = btv->state.loop_irq;
|
|
|
|
bttv_buffer_activate_video(btv, &btv->curr);
|
|
|
|
bttv_buffer_activate_vbi(btv, btv->cvbi);
|
|
|
|
bttv_set_dma(btv, 0);
|
|
|
|
spin_unlock_irqrestore(&btv->s_lock,flags);
|
|
|
|
return 0;
|
|
|
|
}
|
2006-08-13 08:01:27 +07:00
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
static struct pci_device_id bttv_pci_tbl[] = {
|
2009-07-06 01:59:21 +07:00
|
|
|
{PCI_VDEVICE(BROOKTREE, PCI_DEVICE_ID_BT848), 0},
|
|
|
|
{PCI_VDEVICE(BROOKTREE, PCI_DEVICE_ID_BT849), 0},
|
|
|
|
{PCI_VDEVICE(BROOKTREE, PCI_DEVICE_ID_BT878), 0},
|
|
|
|
{PCI_VDEVICE(BROOKTREE, PCI_DEVICE_ID_BT879), 0},
|
2011-11-06 20:47:58 +07:00
|
|
|
{PCI_VDEVICE(BROOKTREE, PCI_DEVICE_ID_FUSION879), 0},
|
2005-11-09 12:37:43 +07:00
|
|
|
{0,}
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(pci, bttv_pci_tbl);
|
|
|
|
|
|
|
|
static struct pci_driver bttv_pci_driver = {
|
2005-11-09 12:37:43 +07:00
|
|
|
.name = "bttv",
|
|
|
|
.id_table = bttv_pci_tbl,
|
|
|
|
.probe = bttv_probe,
|
2012-12-22 04:17:53 +07:00
|
|
|
.remove = bttv_remove,
|
2006-08-13 08:01:27 +07:00
|
|
|
#ifdef CONFIG_PM
|
2005-04-17 05:20:36 +07:00
|
|
|
.suspend = bttv_suspend,
|
|
|
|
.resume = bttv_resume,
|
2006-08-13 08:01:27 +07:00
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
2007-12-12 05:23:43 +07:00
|
|
|
static int __init bttv_init_module(void)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2006-07-15 19:08:26 +07:00
|
|
|
int ret;
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
bttv_num = 0;
|
|
|
|
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_info("driver version %s loaded\n", BTTV_VERSION);
|
2005-04-17 05:20:36 +07:00
|
|
|
if (gbuffers < 2 || gbuffers > VIDEO_MAX_FRAME)
|
|
|
|
gbuffers = 2;
|
2009-05-28 21:11:53 +07:00
|
|
|
if (gbufsize > BTTV_MAX_FBUF)
|
2005-04-17 05:20:36 +07:00
|
|
|
gbufsize = BTTV_MAX_FBUF;
|
|
|
|
gbufsize = (gbufsize + PAGE_SIZE - 1) & PAGE_MASK;
|
|
|
|
if (bttv_verbose)
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_info("using %d buffers with %dk (%d pages) each for capture\n",
|
|
|
|
gbuffers, gbufsize >> 10, gbufsize >> PAGE_SHIFT);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
bttv_check_chipset();
|
|
|
|
|
2006-07-15 19:08:26 +07:00
|
|
|
ret = bus_register(&bttv_sub_bus_type);
|
|
|
|
if (ret < 0) {
|
2011-08-22 05:56:48 +07:00
|
|
|
pr_warn("bus_register error: %d\n", ret);
|
2006-07-15 19:08:26 +07:00
|
|
|
return ret;
|
|
|
|
}
|
2007-12-18 00:26:29 +07:00
|
|
|
ret = pci_register_driver(&bttv_pci_driver);
|
|
|
|
if (ret < 0)
|
|
|
|
bus_unregister(&bttv_sub_bus_type);
|
|
|
|
|
|
|
|
return ret;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2007-12-12 05:23:43 +07:00
|
|
|
static void __exit bttv_cleanup_module(void)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
pci_unregister_driver(&bttv_pci_driver);
|
|
|
|
bus_unregister(&bttv_sub_bus_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(bttv_init_module);
|
|
|
|
module_exit(bttv_cleanup_module);
|