2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
|
|
|
|
bttv - Bt848 frame grabber driver
|
|
|
|
|
|
|
|
bttv's *private* header file -- nobody other than bttv itself
|
|
|
|
should ever include this file.
|
|
|
|
|
|
|
|
(c) 2000-2002 Gerd Knorr <kraxel@bytesex.org>
|
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _BTTVP_H_
|
|
|
|
#define _BTTVP_H_
|
|
|
|
|
2005-09-10 04:04:03 +08:00
|
|
|
#include <linux/version.h>
|
2009-04-01 14:15:52 +08:00
|
|
|
#define BTTV_VERSION_CODE KERNEL_VERSION(0,9,18)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/wait.h>
|
|
|
|
#include <linux/i2c.h>
|
|
|
|
#include <linux/i2c-algo-bit.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/input.h>
|
2006-01-14 00:10:24 +08:00
|
|
|
#include <linux/mutex.h>
|
2007-10-30 17:35:04 +08:00
|
|
|
#include <linux/scatterlist.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/io.h>
|
2007-07-03 02:39:57 +08:00
|
|
|
#include <media/v4l2-common.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/device.h>
|
2007-08-24 03:37:49 +08:00
|
|
|
#include <media/videobuf-dma-sg.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <media/tveeprom.h>
|
2010-11-18 00:28:38 +08:00
|
|
|
#include <media/rc-core.h>
|
2010-09-23 10:24:04 +08:00
|
|
|
#include <media/ir-kbd-i2c.h>
|
2005-12-12 16:37:28 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#include "bt848.h"
|
|
|
|
#include "bttv.h"
|
|
|
|
#include "btcx-risc.h"
|
|
|
|
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
|
|
|
|
#define FORMAT_FLAGS_DITHER 0x01
|
|
|
|
#define FORMAT_FLAGS_PACKED 0x02
|
|
|
|
#define FORMAT_FLAGS_PLANAR 0x04
|
|
|
|
#define FORMAT_FLAGS_RAW 0x08
|
|
|
|
#define FORMAT_FLAGS_CrCb 0x10
|
|
|
|
|
|
|
|
#define RISC_SLOT_O_VBI 4
|
|
|
|
#define RISC_SLOT_O_FIELD 6
|
|
|
|
#define RISC_SLOT_E_VBI 10
|
|
|
|
#define RISC_SLOT_E_FIELD 12
|
|
|
|
#define RISC_SLOT_LOOP 14
|
|
|
|
|
|
|
|
#define RESOURCE_OVERLAY 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 03:17:39 +08:00
|
|
|
#define RESOURCE_VIDEO_STREAM 2
|
2005-04-17 06:20:36 +08:00
|
|
|
#define RESOURCE_VBI 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 03:17:39 +08:00
|
|
|
#define RESOURCE_VIDEO_READ 8
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define RAW_LINES 640
|
|
|
|
#define RAW_BPL 1024
|
|
|
|
|
|
|
|
#define UNSET (-1U)
|
|
|
|
|
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 03:17:39 +08:00
|
|
|
/* Min. value in VDELAY register. */
|
|
|
|
#define MIN_VDELAY 2
|
|
|
|
/* Even to get Cb first, odd for Cr. */
|
|
|
|
#define MAX_HDELAY (0x3FF & -2)
|
|
|
|
/* Limits scaled width, which must be a multiple of 4. */
|
|
|
|
#define MAX_HACTIVE (0x3FF & -4)
|
|
|
|
|
2007-12-28 09:20:58 +08:00
|
|
|
#define BTTV_NORMS (\
|
|
|
|
V4L2_STD_PAL | V4L2_STD_PAL_N | \
|
|
|
|
V4L2_STD_PAL_Nc | V4L2_STD_SECAM | \
|
|
|
|
V4L2_STD_NTSC | V4L2_STD_PAL_M | \
|
|
|
|
V4L2_STD_PAL_60)
|
2005-04-17 06:20:36 +08:00
|
|
|
/* ---------------------------------------------------------- */
|
|
|
|
|
|
|
|
struct bttv_tvnorm {
|
|
|
|
int v4l2_id;
|
|
|
|
char *name;
|
2005-11-09 13:37:43 +08:00
|
|
|
u32 Fsc;
|
|
|
|
u16 swidth, sheight; /* scaled standard width, height */
|
2005-04-17 06:20:36 +08:00
|
|
|
u16 totalwidth;
|
|
|
|
u8 adelay, bdelay, iform;
|
|
|
|
u32 scaledtwidth;
|
|
|
|
u16 hdelayx1, hactivex1;
|
|
|
|
u16 vdelay;
|
2005-11-09 13:37:43 +08:00
|
|
|
u8 vbipack;
|
2005-04-17 06:20:36 +08:00
|
|
|
u16 vtotal;
|
|
|
|
int sram;
|
2006-01-10 01:25:27 +08:00
|
|
|
/* ITU-R frame line number of the first VBI line we can
|
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 03:17:39 +08:00
|
|
|
capture, of the first and second field. The last possible line
|
|
|
|
is determined by cropcap.bounds. */
|
2006-01-10 01:25:27 +08:00
|
|
|
u16 vbistart[2];
|
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 03:17:39 +08:00
|
|
|
/* Horizontally this counts fCLKx1 samples following the leading
|
|
|
|
edge of the horizontal sync pulse, vertically ITU-R frame line
|
|
|
|
numbers of the first field times two (2, 4, 6, ... 524 or 624). */
|
|
|
|
struct v4l2_cropcap cropcap;
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
extern const struct bttv_tvnorm bttv_tvnorms[];
|
|
|
|
|
|
|
|
struct bttv_format {
|
|
|
|
char *name;
|
|
|
|
int fourcc; /* video4linux 2 */
|
|
|
|
int btformat; /* BT848_COLOR_FMT_* */
|
|
|
|
int btswap; /* BT848_COLOR_CTL_* */
|
|
|
|
int depth; /* bit/pixel */
|
|
|
|
int flags;
|
|
|
|
int hshift,vshift; /* for planar modes */
|
|
|
|
};
|
|
|
|
|
2010-11-20 07:43:12 +08:00
|
|
|
struct bttv_ir {
|
2010-11-17 21:05:29 +08:00
|
|
|
struct rc_dev *dev;
|
|
|
|
|
|
|
|
char name[32];
|
|
|
|
char phys[32];
|
2010-11-20 07:43:12 +08:00
|
|
|
|
2010-11-17 21:05:29 +08:00
|
|
|
/* Usual gpio signalling */
|
|
|
|
u32 mask_keycode;
|
|
|
|
u32 mask_keydown;
|
|
|
|
u32 mask_keyup;
|
|
|
|
u32 polling;
|
|
|
|
u32 last_gpio;
|
|
|
|
int shift_by;
|
|
|
|
int start; // What should RC5_START() be
|
|
|
|
int addr; // What RC5_ADDR() should be.
|
|
|
|
int rc5_remote_gap;
|
|
|
|
struct timer_list timer;
|
|
|
|
|
|
|
|
/* RC5 gpio */
|
2010-11-20 07:43:12 +08:00
|
|
|
u32 rc5_gpio;
|
|
|
|
struct timer_list timer_end; /* timer_end for code completion */
|
|
|
|
u32 last_bit; /* last raw bit seen */
|
|
|
|
u32 code; /* raw code under construction */
|
|
|
|
struct timeval base_time; /* time of last seen code */
|
|
|
|
bool active; /* building raw code */
|
2010-11-17 21:05:29 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* ---------------------------------------------------------- */
|
|
|
|
|
|
|
|
struct bttv_geometry {
|
|
|
|
u8 vtc,crop,comb;
|
|
|
|
u16 width,hscale,hdelay;
|
|
|
|
u16 sheight,vscale,vdelay,vtotal;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bttv_buffer {
|
|
|
|
/* common v4l buffer stuff -- must be first */
|
|
|
|
struct videobuf_buffer vb;
|
|
|
|
|
|
|
|
/* bttv specific */
|
|
|
|
const struct bttv_format *fmt;
|
2009-01-29 08:32:58 +08:00
|
|
|
unsigned int tvnorm;
|
2005-04-17 06:20:36 +08:00
|
|
|
int btformat;
|
|
|
|
int btswap;
|
|
|
|
struct bttv_geometry geo;
|
|
|
|
struct btcx_riscmem top;
|
|
|
|
struct btcx_riscmem 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 03:17:39 +08:00
|
|
|
struct v4l2_rect crop;
|
|
|
|
unsigned int vbi_skip[2];
|
|
|
|
unsigned int vbi_count[2];
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct bttv_buffer_set {
|
|
|
|
struct bttv_buffer *top; /* top field buffer */
|
|
|
|
struct bttv_buffer *bottom; /* bottom field buffer */
|
|
|
|
unsigned int top_irq;
|
|
|
|
unsigned int frame_irq;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bttv_overlay {
|
2009-01-29 08:32:58 +08:00
|
|
|
unsigned int tvnorm;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct v4l2_rect w;
|
|
|
|
enum v4l2_field field;
|
|
|
|
struct v4l2_clip *clips;
|
|
|
|
int nclips;
|
|
|
|
int setup_ok;
|
|
|
|
};
|
|
|
|
|
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 03:17:39 +08:00
|
|
|
struct bttv_vbi_fmt {
|
|
|
|
struct v4l2_vbi_format fmt;
|
|
|
|
|
|
|
|
/* fmt.start[] and count[] refer to this video standard. */
|
|
|
|
const struct bttv_tvnorm *tvnorm;
|
|
|
|
|
|
|
|
/* Earliest possible start of video capturing with this
|
|
|
|
v4l2_vbi_format, in struct bttv_crop.rect units. */
|
|
|
|
__s32 end;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* bttv-vbi.c */
|
2009-01-29 08:32:58 +08:00
|
|
|
void bttv_vbi_fmt_reset(struct bttv_vbi_fmt *f, 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 03:17:39 +08:00
|
|
|
|
|
|
|
struct bttv_crop {
|
|
|
|
/* A cropping rectangle in struct bttv_tvnorm.cropcap units. */
|
|
|
|
struct v4l2_rect rect;
|
|
|
|
|
|
|
|
/* Scaled image size limits with this crop rect. Divide
|
|
|
|
max_height, but not min_height, by two when capturing
|
|
|
|
single fields. See also bttv_crop_reset() and
|
|
|
|
bttv_crop_adjust() in bttv-driver.c. */
|
|
|
|
__s32 min_scaled_width;
|
|
|
|
__s32 min_scaled_height;
|
|
|
|
__s32 max_scaled_width;
|
|
|
|
__s32 max_scaled_height;
|
|
|
|
};
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
struct bttv_fh {
|
|
|
|
struct bttv *btv;
|
|
|
|
int resources;
|
|
|
|
#ifdef VIDIOC_G_PRIORITY
|
|
|
|
enum v4l2_priority prio;
|
|
|
|
#endif
|
|
|
|
enum v4l2_buf_type type;
|
|
|
|
|
|
|
|
/* video capture */
|
|
|
|
struct videobuf_queue cap;
|
|
|
|
const struct bttv_format *fmt;
|
|
|
|
int width;
|
|
|
|
int 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 03:17:39 +08:00
|
|
|
/* video overlay */
|
2005-04-17 06:20:36 +08:00
|
|
|
const struct bttv_format *ovfmt;
|
|
|
|
struct bttv_overlay ov;
|
|
|
|
|
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 03:17:39 +08:00
|
|
|
/* Application called VIDIOC_S_CROP. */
|
|
|
|
int do_crop;
|
|
|
|
|
|
|
|
/* vbi capture */
|
2005-04-17 06:20:36 +08:00
|
|
|
struct videobuf_queue vbi;
|
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 03:17:39 +08:00
|
|
|
/* Current VBI capture window as seen through this fh (cannot
|
|
|
|
be global for compatibility with earlier drivers). Protected
|
|
|
|
by struct bttv.lock and struct bttv_fh.vbi.lock. */
|
|
|
|
struct bttv_vbi_fmt vbi_fmt;
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------- */
|
|
|
|
/* bttv-risc.c */
|
|
|
|
|
|
|
|
/* risc code generators - capture */
|
|
|
|
int bttv_risc_packed(struct bttv *btv, struct btcx_riscmem *risc,
|
|
|
|
struct scatterlist *sglist,
|
|
|
|
unsigned int offset, unsigned int bpl,
|
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 03:17:39 +08:00
|
|
|
unsigned int pitch, unsigned int skip_lines,
|
|
|
|
unsigned int store_lines);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* control dma register + risc main loop */
|
|
|
|
void bttv_set_dma(struct bttv *btv, int override);
|
|
|
|
int bttv_risc_init_main(struct bttv *btv);
|
|
|
|
int bttv_risc_hook(struct bttv *btv, int slot, struct btcx_riscmem *risc,
|
|
|
|
int irqflags);
|
|
|
|
|
|
|
|
/* capture buffer handling */
|
|
|
|
int bttv_buffer_risc(struct bttv *btv, struct bttv_buffer *buf);
|
|
|
|
int bttv_buffer_activate_video(struct bttv *btv,
|
|
|
|
struct bttv_buffer_set *set);
|
|
|
|
int bttv_buffer_activate_vbi(struct bttv *btv,
|
|
|
|
struct bttv_buffer *vbi);
|
2006-03-10 23:29:15 +08:00
|
|
|
void bttv_dma_free(struct videobuf_queue *q, struct bttv *btv,
|
|
|
|
struct bttv_buffer *buf);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* overlay handling */
|
|
|
|
int bttv_overlay_risc(struct bttv *btv, struct bttv_overlay *ov,
|
|
|
|
const struct bttv_format *fmt,
|
|
|
|
struct bttv_buffer *buf);
|
|
|
|
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------- */
|
|
|
|
/* bttv-vbi.c */
|
|
|
|
|
2008-05-28 23:16:41 +08:00
|
|
|
int bttv_try_fmt_vbi_cap(struct file *file, void *fh, struct v4l2_format *f);
|
|
|
|
int bttv_g_fmt_vbi_cap(struct file *file, void *fh, struct v4l2_format *f);
|
|
|
|
int bttv_s_fmt_vbi_cap(struct file *file, void *fh, struct v4l2_format *f);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
extern struct videobuf_queue_ops bttv_vbi_qops;
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------- */
|
|
|
|
/* bttv-gpio.c */
|
|
|
|
|
|
|
|
extern struct bus_type bttv_sub_bus_type;
|
|
|
|
int bttv_sub_add_device(struct bttv_core *core, char *name);
|
|
|
|
int bttv_sub_del_devices(struct bttv_core *core);
|
|
|
|
|
2008-09-04 04:11:54 +08:00
|
|
|
/* ---------------------------------------------------------- */
|
|
|
|
/* bttv-cards.c */
|
|
|
|
|
|
|
|
extern int no_overlay;
|
|
|
|
|
2010-09-23 10:24:04 +08:00
|
|
|
/* ---------------------------------------------------------- */
|
|
|
|
/* bttv-input.c */
|
|
|
|
|
|
|
|
extern void init_bttv_i2c_ir(struct bttv *btv);
|
|
|
|
extern int fini_bttv_i2c(struct bttv *btv);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* ---------------------------------------------------------- */
|
|
|
|
/* bttv-driver.c */
|
|
|
|
|
|
|
|
/* insmod options */
|
|
|
|
extern unsigned int bttv_verbose;
|
|
|
|
extern unsigned int bttv_debug;
|
|
|
|
extern unsigned int bttv_gpio;
|
|
|
|
extern void bttv_gpio_tracking(struct bttv *btv, char *comment);
|
|
|
|
extern int init_bttv_i2c(struct bttv *btv);
|
|
|
|
|
2005-09-23 12:43:53 +08:00
|
|
|
#define bttv_printk if (bttv_verbose) printk
|
2005-04-17 06:20:36 +08:00
|
|
|
#define dprintk if (bttv_debug >= 1) printk
|
|
|
|
#define d2printk if (bttv_debug >= 2) printk
|
|
|
|
|
|
|
|
#define BTTV_MAX_FBUF 0x208000
|
2007-07-18 03:36:20 +08:00
|
|
|
#define BTTV_TIMEOUT msecs_to_jiffies(500) /* 0.5 seconds */
|
|
|
|
#define BTTV_FREE_IDLE msecs_to_jiffies(1000) /* one second */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
|
|
|
|
struct bttv_pll_info {
|
|
|
|
unsigned int pll_ifreq; /* PLL input frequency */
|
|
|
|
unsigned int pll_ofreq; /* PLL output frequency */
|
|
|
|
unsigned int pll_crystal; /* Crystal used for input */
|
|
|
|
unsigned int pll_current; /* Currently programmed ofreq */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* for gpio-connected remote control */
|
|
|
|
struct bttv_input {
|
2005-09-15 15:01:53 +08:00
|
|
|
struct input_dev *dev;
|
2005-04-17 06:20:36 +08:00
|
|
|
char name[32];
|
|
|
|
char phys[32];
|
|
|
|
u32 mask_keycode;
|
|
|
|
u32 mask_keydown;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bttv_suspend_state {
|
|
|
|
u32 gpio_enable;
|
|
|
|
u32 gpio_data;
|
|
|
|
int disabled;
|
|
|
|
int loop_irq;
|
|
|
|
struct bttv_buffer_set video;
|
|
|
|
struct bttv_buffer *vbi;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bttv {
|
|
|
|
struct bttv_core c;
|
|
|
|
|
|
|
|
/* pci device config */
|
|
|
|
unsigned short id;
|
|
|
|
unsigned char revision;
|
|
|
|
unsigned char __iomem *bt848_mmio; /* pointer to mmio */
|
|
|
|
|
|
|
|
/* card configuration info */
|
|
|
|
unsigned int cardid; /* pci subsystem id (bt878 based ones) */
|
2005-11-09 13:37:43 +08:00
|
|
|
unsigned int tuner_type; /* tuner chip type */
|
2006-01-10 01:25:16 +08:00
|
|
|
unsigned int tda9887_conf;
|
2009-01-29 08:32:59 +08:00
|
|
|
unsigned int svhs, dig;
|
2009-03-28 19:29:00 +08:00
|
|
|
unsigned int has_saa6588:1;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct bttv_pll_info pll;
|
|
|
|
int triton1;
|
|
|
|
int gpioirq;
|
2006-01-10 01:25:25 +08:00
|
|
|
int (*custom_irq)(struct bttv *btv);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
int use_i2c_hw;
|
|
|
|
|
|
|
|
/* old gpio interface */
|
|
|
|
wait_queue_head_t gpioq;
|
|
|
|
int shutdown;
|
2006-08-26 03:53:04 +08:00
|
|
|
|
|
|
|
void (*volume_gpio)(struct bttv *btv, __u16 volume);
|
|
|
|
void (*audio_mode_gpio)(struct bttv *btv, struct v4l2_tuner *tuner, int set);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* new gpio interface */
|
|
|
|
spinlock_t gpio_lock;
|
|
|
|
|
|
|
|
/* i2c layer */
|
|
|
|
struct i2c_algo_bit_data i2c_algo;
|
|
|
|
struct i2c_client i2c_client;
|
|
|
|
int i2c_state, i2c_rc;
|
|
|
|
int i2c_done;
|
|
|
|
wait_queue_head_t i2c_queue;
|
2009-03-28 19:29:00 +08:00
|
|
|
struct v4l2_subdev *sd_msp34xx;
|
|
|
|
struct v4l2_subdev *sd_tvaudio;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* video4linux (1) */
|
|
|
|
struct video_device *video_dev;
|
|
|
|
struct video_device *radio_dev;
|
|
|
|
struct video_device *vbi_dev;
|
|
|
|
|
|
|
|
/* infrared remote */
|
|
|
|
int has_remote;
|
2010-11-20 07:43:12 +08:00
|
|
|
struct bttv_ir *remote;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-09-23 10:24:04 +08:00
|
|
|
/* I2C remote data */
|
|
|
|
struct IR_i2c_init_data init_data;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* locking */
|
|
|
|
spinlock_t s_lock;
|
2006-01-14 00:10:24 +08:00
|
|
|
struct mutex lock;
|
2005-04-17 06:20:36 +08:00
|
|
|
int resources;
|
|
|
|
#ifdef VIDIOC_G_PRIORITY
|
|
|
|
struct v4l2_prio_state prio;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* video state */
|
|
|
|
unsigned int input;
|
|
|
|
unsigned int audio;
|
2006-03-19 08:31:00 +08:00
|
|
|
unsigned int mute;
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned long freq;
|
2009-01-29 08:32:58 +08:00
|
|
|
unsigned int tvnorm;
|
|
|
|
int hue, contrast, bright, saturation;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct v4l2_framebuffer fbuf;
|
|
|
|
unsigned int field_count;
|
|
|
|
|
|
|
|
/* various options */
|
|
|
|
int opt_combfilter;
|
|
|
|
int opt_lumafilter;
|
|
|
|
int opt_automute;
|
|
|
|
int opt_chroma_agc;
|
|
|
|
int opt_adc_crush;
|
|
|
|
int opt_vcr_hack;
|
|
|
|
int opt_whitecrush_upper;
|
|
|
|
int opt_whitecrush_lower;
|
2005-06-29 11:45:25 +08:00
|
|
|
int opt_uv_ratio;
|
|
|
|
int opt_full_luma_range;
|
|
|
|
int opt_coring;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* radio data/state */
|
|
|
|
int has_radio;
|
|
|
|
int radio_user;
|
|
|
|
|
|
|
|
/* miro/pinnacle + Aimslab VHX
|
|
|
|
philips matchbox (tea5757 radio tuner) support */
|
|
|
|
int has_matchbox;
|
|
|
|
int mbox_we;
|
|
|
|
int mbox_data;
|
|
|
|
int mbox_clk;
|
|
|
|
int mbox_most;
|
|
|
|
int mbox_mask;
|
|
|
|
|
|
|
|
/* ISA stuff (Terratec Active Radio Upgrade) */
|
|
|
|
int mbox_ior;
|
|
|
|
int mbox_iow;
|
|
|
|
int mbox_csel;
|
|
|
|
|
|
|
|
/* risc memory management data
|
2006-07-01 00:23:04 +08:00
|
|
|
- must acquire s_lock before changing these
|
2005-04-17 06:20:36 +08:00
|
|
|
- only the irq handler is supported to touch top + bottom + vcurr */
|
|
|
|
struct btcx_riscmem main;
|
|
|
|
struct bttv_buffer *screen; /* overlay */
|
|
|
|
struct list_head capture; /* video capture queue */
|
|
|
|
struct list_head vcapture; /* vbi capture queue */
|
|
|
|
struct bttv_buffer_set curr; /* active buffers */
|
|
|
|
struct bttv_buffer *cvbi; /* active vbi buffer */
|
|
|
|
int loop_irq;
|
|
|
|
int new_input;
|
|
|
|
|
|
|
|
unsigned long cap_ctl;
|
|
|
|
unsigned long dma_on;
|
|
|
|
struct timer_list timeout;
|
|
|
|
struct bttv_suspend_state state;
|
|
|
|
|
|
|
|
/* stats */
|
|
|
|
unsigned int errors;
|
|
|
|
unsigned int framedrop;
|
|
|
|
unsigned int irq_total;
|
|
|
|
unsigned int irq_me;
|
|
|
|
|
|
|
|
unsigned int users;
|
|
|
|
struct bttv_fh init;
|
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 03:17:39 +08:00
|
|
|
|
2007-03-25 02:23:50 +08:00
|
|
|
/* used to make dvb-bt8xx autoloadable */
|
|
|
|
struct work_struct request_module_wk;
|
|
|
|
|
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 03:17:39 +08:00
|
|
|
/* Default (0) and current (1) video capturing and overlay
|
|
|
|
cropping parameters in bttv_tvnorm.cropcap units. Protected
|
|
|
|
by bttv.lock. */
|
|
|
|
struct bttv_crop crop[2];
|
|
|
|
|
|
|
|
/* Earliest possible start of video capturing in
|
|
|
|
bttv_tvnorm.cropcap line units. Set by check_alloc_btres()
|
|
|
|
and free_btres(). Protected by bttv.lock. */
|
|
|
|
__s32 vbi_end;
|
|
|
|
|
|
|
|
/* Latest possible end of VBI capturing (= crop[x].rect.top when
|
|
|
|
VIDEO_RESOURCES are locked). Set by check_alloc_btres()
|
|
|
|
and free_btres(). Protected by bttv.lock. */
|
|
|
|
__s32 crop_start;
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
2005-06-24 13:04:58 +08:00
|
|
|
|
2009-03-14 23:36:54 +08:00
|
|
|
static inline struct bttv *to_bttv(struct v4l2_device *v4l2_dev)
|
|
|
|
{
|
|
|
|
return container_of(v4l2_dev, struct bttv, c.v4l2_dev);
|
|
|
|
}
|
|
|
|
|
2005-06-24 13:04:58 +08:00
|
|
|
/* our devices */
|
2008-03-20 09:18:11 +08:00
|
|
|
#define BTTV_MAX 32
|
2005-06-24 13:04:58 +08:00
|
|
|
extern unsigned int bttv_num;
|
2009-01-29 08:32:59 +08:00
|
|
|
extern struct bttv *bttvs[BTTV_MAX];
|
2005-04-17 06:20:36 +08:00
|
|
|
|
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 08:32:59 +08:00
|
|
|
static inline unsigned int bttv_muxsel(const struct bttv *btv,
|
|
|
|
unsigned int input)
|
|
|
|
{
|
|
|
|
return (bttv_tvcards[btv->c.type].muxsel >> (input * 2)) & 3;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define btwrite(dat,adr) writel((dat), btv->bt848_mmio+(adr))
|
|
|
|
#define btread(adr) readl(btv->bt848_mmio+(adr))
|
|
|
|
|
|
|
|
#define btand(dat,adr) btwrite((dat) & btread(adr), adr)
|
|
|
|
#define btor(dat,adr) btwrite((dat) | btread(adr), adr)
|
|
|
|
#define btaor(dat,mask,adr) btwrite((dat) | ((mask) & btread(adr)), adr)
|
|
|
|
|
|
|
|
#endif /* _BTTVP_H_ */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* End:
|
|
|
|
*/
|