forked from Minki/linux
5a0e3ad6af
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>
256 lines
7.3 KiB
C
256 lines
7.3 KiB
C
/*
|
|
*
|
|
* device driver for philips saa7134 based TV cards
|
|
* video4linux video interface
|
|
*
|
|
* (c) 2001,02 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
|
|
*
|
|
* 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.
|
|
*/
|
|
|
|
#include <linux/init.h>
|
|
#include <linux/list.h>
|
|
#include <linux/module.h>
|
|
#include <linux/kernel.h>
|
|
|
|
#include "saa7134-reg.h"
|
|
#include "saa7134.h"
|
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
static unsigned int vbi_debug;
|
|
module_param(vbi_debug, int, 0644);
|
|
MODULE_PARM_DESC(vbi_debug,"enable debug messages [vbi]");
|
|
|
|
static unsigned int vbibufs = 4;
|
|
module_param(vbibufs, int, 0444);
|
|
MODULE_PARM_DESC(vbibufs,"number of vbi buffers, range 2-32");
|
|
|
|
#define dprintk(fmt, arg...) if (vbi_debug) \
|
|
printk(KERN_DEBUG "%s/vbi: " fmt, dev->name , ## arg)
|
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
#define VBI_LINE_COUNT 16
|
|
#define VBI_LINE_LENGTH 2048
|
|
#define VBI_SCALE 0x200
|
|
|
|
static void task_init(struct saa7134_dev *dev, struct saa7134_buf *buf,
|
|
int task)
|
|
{
|
|
struct saa7134_tvnorm *norm = dev->tvnorm;
|
|
|
|
/* setup video scaler */
|
|
saa_writeb(SAA7134_VBI_H_START1(task), norm->h_start & 0xff);
|
|
saa_writeb(SAA7134_VBI_H_START2(task), norm->h_start >> 8);
|
|
saa_writeb(SAA7134_VBI_H_STOP1(task), norm->h_stop & 0xff);
|
|
saa_writeb(SAA7134_VBI_H_STOP2(task), norm->h_stop >> 8);
|
|
saa_writeb(SAA7134_VBI_V_START1(task), norm->vbi_v_start_0 & 0xff);
|
|
saa_writeb(SAA7134_VBI_V_START2(task), norm->vbi_v_start_0 >> 8);
|
|
saa_writeb(SAA7134_VBI_V_STOP1(task), norm->vbi_v_stop_0 & 0xff);
|
|
saa_writeb(SAA7134_VBI_V_STOP2(task), norm->vbi_v_stop_0 >> 8);
|
|
|
|
saa_writeb(SAA7134_VBI_H_SCALE_INC1(task), VBI_SCALE & 0xff);
|
|
saa_writeb(SAA7134_VBI_H_SCALE_INC2(task), VBI_SCALE >> 8);
|
|
saa_writeb(SAA7134_VBI_PHASE_OFFSET_LUMA(task), 0x00);
|
|
saa_writeb(SAA7134_VBI_PHASE_OFFSET_CHROMA(task), 0x00);
|
|
|
|
saa_writeb(SAA7134_VBI_H_LEN1(task), buf->vb.width & 0xff);
|
|
saa_writeb(SAA7134_VBI_H_LEN2(task), buf->vb.width >> 8);
|
|
saa_writeb(SAA7134_VBI_V_LEN1(task), buf->vb.height & 0xff);
|
|
saa_writeb(SAA7134_VBI_V_LEN2(task), buf->vb.height >> 8);
|
|
|
|
saa_andorb(SAA7134_DATA_PATH(task), 0xc0, 0x00);
|
|
}
|
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
static int buffer_activate(struct saa7134_dev *dev,
|
|
struct saa7134_buf *buf,
|
|
struct saa7134_buf *next)
|
|
{
|
|
unsigned long control,base;
|
|
|
|
dprintk("buffer_activate [%p]\n",buf);
|
|
buf->vb.state = VIDEOBUF_ACTIVE;
|
|
buf->top_seen = 0;
|
|
|
|
task_init(dev,buf,TASK_A);
|
|
task_init(dev,buf,TASK_B);
|
|
saa_writeb(SAA7134_OFMT_DATA_A, 0x06);
|
|
saa_writeb(SAA7134_OFMT_DATA_B, 0x06);
|
|
|
|
/* DMA: setup channel 2+3 (= VBI Task A+B) */
|
|
base = saa7134_buffer_base(buf);
|
|
control = SAA7134_RS_CONTROL_BURST_16 |
|
|
SAA7134_RS_CONTROL_ME |
|
|
(buf->pt->dma >> 12);
|
|
saa_writel(SAA7134_RS_BA1(2),base);
|
|
saa_writel(SAA7134_RS_BA2(2),base + buf->vb.size/2);
|
|
saa_writel(SAA7134_RS_PITCH(2),buf->vb.width);
|
|
saa_writel(SAA7134_RS_CONTROL(2),control);
|
|
saa_writel(SAA7134_RS_BA1(3),base);
|
|
saa_writel(SAA7134_RS_BA2(3),base + buf->vb.size/2);
|
|
saa_writel(SAA7134_RS_PITCH(3),buf->vb.width);
|
|
saa_writel(SAA7134_RS_CONTROL(3),control);
|
|
|
|
/* start DMA */
|
|
saa7134_set_dmabits(dev);
|
|
mod_timer(&dev->vbi_q.timeout, jiffies+BUFFER_TIMEOUT);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int buffer_prepare(struct videobuf_queue *q,
|
|
struct videobuf_buffer *vb,
|
|
enum v4l2_field field)
|
|
{
|
|
struct saa7134_fh *fh = q->priv_data;
|
|
struct saa7134_dev *dev = fh->dev;
|
|
struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb);
|
|
struct saa7134_tvnorm *norm = dev->tvnorm;
|
|
unsigned int lines, llength, size;
|
|
int err;
|
|
|
|
lines = norm->vbi_v_stop_0 - norm->vbi_v_start_0 +1;
|
|
if (lines > VBI_LINE_COUNT)
|
|
lines = VBI_LINE_COUNT;
|
|
llength = VBI_LINE_LENGTH;
|
|
size = lines * llength * 2;
|
|
if (0 != buf->vb.baddr && buf->vb.bsize < size)
|
|
return -EINVAL;
|
|
|
|
if (buf->vb.size != size)
|
|
saa7134_dma_free(q,buf);
|
|
|
|
if (VIDEOBUF_NEEDS_INIT == buf->vb.state) {
|
|
struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
|
|
|
|
buf->vb.width = llength;
|
|
buf->vb.height = lines;
|
|
buf->vb.size = size;
|
|
buf->pt = &fh->pt_vbi;
|
|
|
|
err = videobuf_iolock(q,&buf->vb,NULL);
|
|
if (err)
|
|
goto oops;
|
|
err = saa7134_pgtable_build(dev->pci,buf->pt,
|
|
dma->sglist,
|
|
dma->sglen,
|
|
saa7134_buffer_startpage(buf));
|
|
if (err)
|
|
goto oops;
|
|
}
|
|
buf->vb.state = VIDEOBUF_PREPARED;
|
|
buf->activate = buffer_activate;
|
|
buf->vb.field = field;
|
|
return 0;
|
|
|
|
oops:
|
|
saa7134_dma_free(q,buf);
|
|
return err;
|
|
}
|
|
|
|
static int
|
|
buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
|
|
{
|
|
struct saa7134_fh *fh = q->priv_data;
|
|
struct saa7134_dev *dev = fh->dev;
|
|
int llength,lines;
|
|
|
|
lines = dev->tvnorm->vbi_v_stop_0 - dev->tvnorm->vbi_v_start_0 +1;
|
|
llength = VBI_LINE_LENGTH;
|
|
*size = lines * llength * 2;
|
|
if (0 == *count)
|
|
*count = vbibufs;
|
|
*count = saa7134_buffer_count(*size,*count);
|
|
return 0;
|
|
}
|
|
|
|
static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
|
|
{
|
|
struct saa7134_fh *fh = q->priv_data;
|
|
struct saa7134_dev *dev = fh->dev;
|
|
struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb);
|
|
|
|
saa7134_buffer_queue(dev,&dev->vbi_q,buf);
|
|
}
|
|
|
|
static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
|
|
{
|
|
struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb);
|
|
|
|
saa7134_dma_free(q,buf);
|
|
}
|
|
|
|
struct videobuf_queue_ops saa7134_vbi_qops = {
|
|
.buf_setup = buffer_setup,
|
|
.buf_prepare = buffer_prepare,
|
|
.buf_queue = buffer_queue,
|
|
.buf_release = buffer_release,
|
|
};
|
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
int saa7134_vbi_init1(struct saa7134_dev *dev)
|
|
{
|
|
INIT_LIST_HEAD(&dev->vbi_q.queue);
|
|
init_timer(&dev->vbi_q.timeout);
|
|
dev->vbi_q.timeout.function = saa7134_buffer_timeout;
|
|
dev->vbi_q.timeout.data = (unsigned long)(&dev->vbi_q);
|
|
dev->vbi_q.dev = dev;
|
|
|
|
if (vbibufs < 2)
|
|
vbibufs = 2;
|
|
if (vbibufs > VIDEO_MAX_FRAME)
|
|
vbibufs = VIDEO_MAX_FRAME;
|
|
return 0;
|
|
}
|
|
|
|
int saa7134_vbi_fini(struct saa7134_dev *dev)
|
|
{
|
|
/* nothing */
|
|
return 0;
|
|
}
|
|
|
|
void saa7134_irq_vbi_done(struct saa7134_dev *dev, unsigned long status)
|
|
{
|
|
spin_lock(&dev->slock);
|
|
if (dev->vbi_q.curr) {
|
|
dev->vbi_fieldcount++;
|
|
/* make sure we have seen both fields */
|
|
if ((status & 0x10) == 0x00) {
|
|
dev->vbi_q.curr->top_seen = 1;
|
|
goto done;
|
|
}
|
|
if (!dev->vbi_q.curr->top_seen)
|
|
goto done;
|
|
|
|
dev->vbi_q.curr->vb.field_count = dev->vbi_fieldcount;
|
|
saa7134_buffer_finish(dev,&dev->vbi_q,VIDEOBUF_DONE);
|
|
}
|
|
saa7134_buffer_next(dev,&dev->vbi_q);
|
|
|
|
done:
|
|
spin_unlock(&dev->slock);
|
|
}
|
|
|
|
/* ----------------------------------------------------------- */
|
|
/*
|
|
* Local variables:
|
|
* c-basic-offset: 8
|
|
* End:
|
|
*/
|