License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 21:07:57 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2015-11-14 04:40:07 +07:00
|
|
|
#include <media/drv-intf/saa7146_vv.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
static int vbi_pixel_to_capture = 720 * 2;
|
|
|
|
|
|
|
|
static int vbi_workaround(struct saa7146_dev *dev)
|
|
|
|
{
|
|
|
|
struct saa7146_vv *vv = dev->vv_data;
|
|
|
|
|
2005-12-12 15:37:27 +07:00
|
|
|
u32 *cpu;
|
|
|
|
dma_addr_t dma_addr;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
DECLARE_WAITQUEUE(wait, current);
|
|
|
|
|
2011-08-22 05:56:44 +07:00
|
|
|
DEB_VBI("dev:%p\n", dev);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* once again, a bug in the saa7146: the brs acquisition
|
|
|
|
is buggy and especially the BXO-counter does not work
|
|
|
|
as specified. there is this workaround, but please
|
|
|
|
don't let me explain it. ;-) */
|
|
|
|
|
|
|
|
cpu = pci_alloc_consistent(dev->pci, 4096, &dma_addr);
|
|
|
|
if (NULL == cpu)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
/* setup some basic programming, just for the workaround */
|
|
|
|
saa7146_write(dev, BASE_EVEN3, dma_addr);
|
|
|
|
saa7146_write(dev, BASE_ODD3, dma_addr+vbi_pixel_to_capture);
|
|
|
|
saa7146_write(dev, PROT_ADDR3, dma_addr+4096);
|
|
|
|
saa7146_write(dev, PITCH3, vbi_pixel_to_capture);
|
|
|
|
saa7146_write(dev, BASE_PAGE3, 0x0);
|
|
|
|
saa7146_write(dev, NUM_LINE_BYTE3, (2<<16)|((vbi_pixel_to_capture)<<0));
|
|
|
|
saa7146_write(dev, MC2, MASK_04|MASK_20);
|
|
|
|
|
|
|
|
/* load brs-control register */
|
|
|
|
WRITE_RPS1(CMD_WR_REG | (1 << 8) | (BRS_CTRL/4));
|
|
|
|
/* BXO = 1h, BRS to outbound */
|
|
|
|
WRITE_RPS1(0xc000008c);
|
|
|
|
/* wait for vbi_a or vbi_b*/
|
|
|
|
if ( 0 != (SAA7146_USE_PORT_B_FOR_VBI & dev->ext_vv_data->flags)) {
|
2011-08-22 05:56:44 +07:00
|
|
|
DEB_D("...using port b\n");
|
2005-04-17 05:20:36 +07:00
|
|
|
WRITE_RPS1(CMD_PAUSE | CMD_OAN | CMD_SIG1 | CMD_E_FID_B);
|
|
|
|
WRITE_RPS1(CMD_PAUSE | CMD_OAN | CMD_SIG1 | CMD_O_FID_B);
|
|
|
|
/*
|
|
|
|
WRITE_RPS1(CMD_PAUSE | MASK_09);
|
|
|
|
*/
|
|
|
|
} else {
|
2011-08-22 05:56:44 +07:00
|
|
|
DEB_D("...using port a\n");
|
2005-04-17 05:20:36 +07:00
|
|
|
WRITE_RPS1(CMD_PAUSE | MASK_10);
|
|
|
|
}
|
|
|
|
/* upload brs */
|
|
|
|
WRITE_RPS1(CMD_UPLOAD | MASK_08);
|
|
|
|
/* load brs-control register */
|
|
|
|
WRITE_RPS1(CMD_WR_REG | (1 << 8) | (BRS_CTRL/4));
|
|
|
|
/* BYO = 1, BXO = NQBIL (=1728 for PAL, for NTSC this is 858*2) - NumByte3 (=1440) = 288 */
|
|
|
|
WRITE_RPS1(((1728-(vbi_pixel_to_capture)) << 7) | MASK_19);
|
|
|
|
/* wait for brs_done */
|
|
|
|
WRITE_RPS1(CMD_PAUSE | MASK_08);
|
|
|
|
/* upload brs */
|
|
|
|
WRITE_RPS1(CMD_UPLOAD | MASK_08);
|
|
|
|
/* load video-dma3 NumLines3 and NumBytes3 */
|
|
|
|
WRITE_RPS1(CMD_WR_REG | (1 << 8) | (NUM_LINE_BYTE3/4));
|
|
|
|
/* dev->vbi_count*2 lines, 720 pixel (= 1440 Bytes) */
|
|
|
|
WRITE_RPS1((2 << 16) | (vbi_pixel_to_capture));
|
|
|
|
/* load brs-control register */
|
|
|
|
WRITE_RPS1(CMD_WR_REG | (1 << 8) | (BRS_CTRL/4));
|
|
|
|
/* Set BRS right: note: this is an experimental value for BXO (=> PAL!) */
|
|
|
|
WRITE_RPS1((540 << 7) | (5 << 19)); // 5 == vbi_start
|
|
|
|
/* wait for brs_done */
|
|
|
|
WRITE_RPS1(CMD_PAUSE | MASK_08);
|
|
|
|
/* upload brs and video-dma3*/
|
|
|
|
WRITE_RPS1(CMD_UPLOAD | MASK_08 | MASK_04);
|
|
|
|
/* load mc2 register: enable dma3 */
|
|
|
|
WRITE_RPS1(CMD_WR_REG | (1 << 8) | (MC1/4));
|
|
|
|
WRITE_RPS1(MASK_20 | MASK_04);
|
|
|
|
/* generate interrupt */
|
|
|
|
WRITE_RPS1(CMD_INTERRUPT);
|
|
|
|
/* stop rps1 */
|
|
|
|
WRITE_RPS1(CMD_STOP);
|
|
|
|
|
|
|
|
/* we have to do the workaround twice to be sure that
|
|
|
|
everything is ok */
|
|
|
|
for(i = 0; i < 2; i++) {
|
|
|
|
|
|
|
|
/* indicate to the irq handler that we do the workaround */
|
|
|
|
saa7146_write(dev, MC2, MASK_31|MASK_15);
|
|
|
|
|
|
|
|
saa7146_write(dev, NUM_LINE_BYTE3, (1<<16)|(2<<0));
|
|
|
|
saa7146_write(dev, MC2, MASK_04|MASK_20);
|
|
|
|
|
|
|
|
/* enable rps1 irqs */
|
|
|
|
SAA7146_IER_ENABLE(dev,MASK_28);
|
|
|
|
|
|
|
|
/* prepare to wait to be woken up by the irq-handler */
|
|
|
|
add_wait_queue(&vv->vbi_wq, &wait);
|
2015-02-21 01:12:54 +07:00
|
|
|
set_current_state(TASK_INTERRUPTIBLE);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* start rps1 to enable workaround */
|
|
|
|
saa7146_write(dev, RPS_ADDR1, dev->d_rps1.dma_handle);
|
|
|
|
saa7146_write(dev, MC1, (MASK_13 | MASK_29));
|
|
|
|
|
|
|
|
schedule();
|
|
|
|
|
2011-08-22 05:56:44 +07:00
|
|
|
DEB_VBI("brs bug workaround %d/1\n", i);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
remove_wait_queue(&vv->vbi_wq, &wait);
|
2015-02-21 01:12:54 +07:00
|
|
|
__set_current_state(TASK_RUNNING);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* disable rps1 irqs */
|
|
|
|
SAA7146_IER_DISABLE(dev,MASK_28);
|
|
|
|
|
|
|
|
/* stop video-dma3 */
|
|
|
|
saa7146_write(dev, MC1, MASK_20);
|
|
|
|
|
|
|
|
if(signal_pending(current)) {
|
|
|
|
|
2011-08-22 05:56:44 +07:00
|
|
|
DEB_VBI("aborted (rps:0x%08x)\n",
|
|
|
|
saa7146_read(dev, RPS_ADDR1));
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* stop rps1 for sure */
|
|
|
|
saa7146_write(dev, MC1, MASK_29);
|
|
|
|
|
|
|
|
pci_free_consistent(dev->pci, 4096, cpu, dma_addr);
|
|
|
|
return -EINTR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pci_free_consistent(dev->pci, 4096, cpu, dma_addr);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void saa7146_set_vbi_capture(struct saa7146_dev *dev, struct saa7146_buf *buf, struct saa7146_buf *next)
|
|
|
|
{
|
|
|
|
struct saa7146_vv *vv = dev->vv_data;
|
|
|
|
|
|
|
|
struct saa7146_video_dma vdma3;
|
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
unsigned long e_wait = vv->current_hps_sync == SAA7146_HPS_SYNC_PORT_A ? CMD_E_FID_A : CMD_E_FID_B;
|
|
|
|
unsigned long o_wait = vv->current_hps_sync == SAA7146_HPS_SYNC_PORT_A ? CMD_O_FID_A : CMD_O_FID_B;
|
|
|
|
|
|
|
|
/*
|
|
|
|
vdma3.base_even = 0xc8000000+2560*70;
|
|
|
|
vdma3.base_odd = 0xc8000000;
|
|
|
|
vdma3.prot_addr = 0xc8000000+2560*164;
|
|
|
|
vdma3.pitch = 2560;
|
|
|
|
vdma3.base_page = 0;
|
|
|
|
vdma3.num_line_byte = (64<<16)|((vbi_pixel_to_capture)<<0); // set above!
|
|
|
|
*/
|
|
|
|
vdma3.base_even = buf->pt[2].offset;
|
|
|
|
vdma3.base_odd = buf->pt[2].offset + 16 * vbi_pixel_to_capture;
|
|
|
|
vdma3.prot_addr = buf->pt[2].offset + 16 * 2 * vbi_pixel_to_capture;
|
|
|
|
vdma3.pitch = vbi_pixel_to_capture;
|
|
|
|
vdma3.base_page = buf->pt[2].dma | ME1;
|
|
|
|
vdma3.num_line_byte = (16 << 16) | vbi_pixel_to_capture;
|
|
|
|
|
|
|
|
saa7146_write_out_dma(dev, 3, &vdma3);
|
|
|
|
|
|
|
|
/* write beginning of rps-program */
|
|
|
|
count = 0;
|
|
|
|
|
|
|
|
/* wait for o_fid_a/b / e_fid_a/b toggle only if bit 1 is not set */
|
|
|
|
|
|
|
|
/* we don't wait here for the first field anymore. this is different from the video
|
|
|
|
capture and might cause that the first buffer is only half filled (with only
|
|
|
|
one field). but since this is some sort of streaming data, this is not that negative.
|
2007-08-24 02:37:49 +07:00
|
|
|
but by doing this, we can use the whole engine from videobuf-dma-sg.c... */
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
WRITE_RPS1(CMD_PAUSE | CMD_OAN | CMD_SIG1 | e_wait);
|
|
|
|
WRITE_RPS1(CMD_PAUSE | CMD_OAN | CMD_SIG1 | o_wait);
|
|
|
|
*/
|
|
|
|
/* set bit 1 */
|
|
|
|
WRITE_RPS1(CMD_WR_REG | (1 << 8) | (MC2/4));
|
|
|
|
WRITE_RPS1(MASK_28 | MASK_12);
|
|
|
|
|
|
|
|
/* turn on video-dma3 */
|
|
|
|
WRITE_RPS1(CMD_WR_REG_MASK | (MC1/4));
|
|
|
|
WRITE_RPS1(MASK_04 | MASK_20); /* => mask */
|
|
|
|
WRITE_RPS1(MASK_04 | MASK_20); /* => values */
|
|
|
|
|
|
|
|
/* wait for o_fid_a/b / e_fid_a/b toggle */
|
|
|
|
WRITE_RPS1(CMD_PAUSE | o_wait);
|
|
|
|
WRITE_RPS1(CMD_PAUSE | e_wait);
|
|
|
|
|
|
|
|
/* generate interrupt */
|
|
|
|
WRITE_RPS1(CMD_INTERRUPT);
|
|
|
|
|
|
|
|
/* stop */
|
|
|
|
WRITE_RPS1(CMD_STOP);
|
|
|
|
|
|
|
|
/* enable rps1 irqs */
|
|
|
|
SAA7146_IER_ENABLE(dev, MASK_28);
|
|
|
|
|
|
|
|
/* write the address of the rps-program */
|
|
|
|
saa7146_write(dev, RPS_ADDR1, dev->d_rps1.dma_handle);
|
|
|
|
|
|
|
|
/* turn on rps */
|
|
|
|
saa7146_write(dev, MC1, (MASK_13 | MASK_29));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int buffer_activate(struct saa7146_dev *dev,
|
|
|
|
struct saa7146_buf *buf,
|
|
|
|
struct saa7146_buf *next)
|
|
|
|
{
|
|
|
|
struct saa7146_vv *vv = dev->vv_data;
|
2007-11-07 06:02:36 +07:00
|
|
|
buf->vb.state = VIDEOBUF_ACTIVE;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2011-08-22 05:56:44 +07:00
|
|
|
DEB_VBI("dev:%p, buf:%p, next:%p\n", dev, buf, next);
|
2005-04-17 05:20:36 +07:00
|
|
|
saa7146_set_vbi_capture(dev,buf,next);
|
|
|
|
|
2012-05-01 21:45:27 +07:00
|
|
|
mod_timer(&vv->vbi_dmaq.timeout, jiffies+BUFFER_TIMEOUT);
|
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 file *file = q->priv_data;
|
|
|
|
struct saa7146_fh *fh = file->private_data;
|
|
|
|
struct saa7146_dev *dev = fh->dev;
|
|
|
|
struct saa7146_buf *buf = (struct saa7146_buf *)vb;
|
|
|
|
|
|
|
|
int err = 0;
|
|
|
|
int lines, llength, size;
|
|
|
|
|
|
|
|
lines = 16 * 2 ; /* 2 fields */
|
|
|
|
llength = vbi_pixel_to_capture;
|
|
|
|
size = lines * llength;
|
|
|
|
|
2011-08-22 05:56:44 +07:00
|
|
|
DEB_VBI("vb:%p\n", vb);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
if (0 != buf->vb.baddr && buf->vb.bsize < size) {
|
2011-08-22 05:56:44 +07:00
|
|
|
DEB_VBI("size mismatch\n");
|
2005-04-17 05:20:36 +07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (buf->vb.size != size)
|
2006-03-10 22:29:15 +07:00
|
|
|
saa7146_dma_free(dev,q,buf);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-11-07 06:02:36 +07:00
|
|
|
if (VIDEOBUF_NEEDS_INIT == buf->vb.state) {
|
2007-08-24 02:37:49 +07:00
|
|
|
struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
buf->vb.width = llength;
|
|
|
|
buf->vb.height = lines;
|
|
|
|
buf->vb.size = size;
|
|
|
|
buf->vb.field = field; // FIXME: check this
|
|
|
|
|
|
|
|
saa7146_pgtable_free(dev->pci, &buf->pt[2]);
|
|
|
|
saa7146_pgtable_alloc(dev->pci, &buf->pt[2]);
|
|
|
|
|
2006-03-10 22:29:15 +07:00
|
|
|
err = videobuf_iolock(q,&buf->vb, NULL);
|
2005-04-17 05:20:36 +07:00
|
|
|
if (err)
|
|
|
|
goto oops;
|
2007-08-24 02:37:49 +07:00
|
|
|
err = saa7146_pgtable_build_single(dev->pci, &buf->pt[2],
|
|
|
|
dma->sglist, dma->sglen);
|
2005-04-17 05:20:36 +07:00
|
|
|
if (0 != err)
|
|
|
|
return err;
|
|
|
|
}
|
2007-11-07 06:02:36 +07:00
|
|
|
buf->vb.state = VIDEOBUF_PREPARED;
|
2005-04-17 05:20:36 +07:00
|
|
|
buf->activate = buffer_activate;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
oops:
|
2011-08-22 05:56:44 +07:00
|
|
|
DEB_VBI("error out\n");
|
2006-03-10 22:29:15 +07:00
|
|
|
saa7146_dma_free(dev,q,buf);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
|
|
|
|
{
|
|
|
|
int llength,lines;
|
|
|
|
|
|
|
|
lines = 16 * 2 ; /* 2 fields */
|
|
|
|
llength = vbi_pixel_to_capture;
|
|
|
|
|
|
|
|
*size = lines * llength;
|
|
|
|
*count = 2;
|
|
|
|
|
2011-08-22 05:56:44 +07:00
|
|
|
DEB_VBI("count:%d, size:%d\n", *count, *size);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
|
|
|
|
{
|
|
|
|
struct file *file = q->priv_data;
|
|
|
|
struct saa7146_fh *fh = file->private_data;
|
|
|
|
struct saa7146_dev *dev = fh->dev;
|
|
|
|
struct saa7146_vv *vv = dev->vv_data;
|
|
|
|
struct saa7146_buf *buf = (struct saa7146_buf *)vb;
|
|
|
|
|
2011-08-22 05:56:44 +07:00
|
|
|
DEB_VBI("vb:%p\n", vb);
|
2012-05-01 21:45:27 +07:00
|
|
|
saa7146_buffer_queue(dev, &vv->vbi_dmaq, buf);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
|
|
|
|
{
|
|
|
|
struct file *file = q->priv_data;
|
|
|
|
struct saa7146_fh *fh = file->private_data;
|
|
|
|
struct saa7146_dev *dev = fh->dev;
|
|
|
|
struct saa7146_buf *buf = (struct saa7146_buf *)vb;
|
|
|
|
|
2011-08-22 05:56:44 +07:00
|
|
|
DEB_VBI("vb:%p\n", vb);
|
2006-03-10 22:29:15 +07:00
|
|
|
saa7146_dma_free(dev,q,buf);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2017-08-22 19:56:33 +07:00
|
|
|
static const struct videobuf_queue_ops vbi_qops = {
|
2005-04-17 05:20:36 +07:00
|
|
|
.buf_setup = buffer_setup,
|
|
|
|
.buf_prepare = buffer_prepare,
|
|
|
|
.buf_queue = buffer_queue,
|
|
|
|
.buf_release = buffer_release,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
|
|
|
|
static void vbi_stop(struct saa7146_fh *fh, struct file *file)
|
|
|
|
{
|
|
|
|
struct saa7146_dev *dev = fh->dev;
|
|
|
|
struct saa7146_vv *vv = dev->vv_data;
|
|
|
|
unsigned long flags;
|
2011-08-22 05:56:44 +07:00
|
|
|
DEB_VBI("dev:%p, fh:%p\n", dev, fh);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
spin_lock_irqsave(&dev->slock,flags);
|
|
|
|
|
|
|
|
/* disable rps1 */
|
|
|
|
saa7146_write(dev, MC1, MASK_29);
|
|
|
|
|
|
|
|
/* disable rps1 irqs */
|
|
|
|
SAA7146_IER_DISABLE(dev, MASK_28);
|
|
|
|
|
|
|
|
/* shut down dma 3 transfers */
|
|
|
|
saa7146_write(dev, MC1, MASK_20);
|
|
|
|
|
2012-05-01 21:45:27 +07:00
|
|
|
if (vv->vbi_dmaq.curr)
|
|
|
|
saa7146_buffer_finish(dev, &vv->vbi_dmaq, VIDEOBUF_DONE);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
videobuf_queue_cancel(&fh->vbi_q);
|
|
|
|
|
|
|
|
vv->vbi_streaming = NULL;
|
|
|
|
|
2012-05-01 21:45:27 +07:00
|
|
|
del_timer(&vv->vbi_dmaq.timeout);
|
2012-05-01 21:28:20 +07:00
|
|
|
del_timer(&vv->vbi_read_timeout);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
spin_unlock_irqrestore(&dev->slock, flags);
|
|
|
|
}
|
|
|
|
|
2017-10-17 06:10:12 +07:00
|
|
|
static void vbi_read_timeout(struct timer_list *t)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2017-10-17 06:10:12 +07:00
|
|
|
struct saa7146_vv *vv = from_timer(vv, t, vbi_read_timeout);
|
|
|
|
struct file *file = vv->vbi_read_timeout_file;
|
2005-04-17 05:20:36 +07:00
|
|
|
struct saa7146_fh *fh = file->private_data;
|
|
|
|
struct saa7146_dev *dev = fh->dev;
|
|
|
|
|
2011-08-22 05:56:44 +07:00
|
|
|
DEB_VBI("dev:%p, fh:%p\n", dev, fh);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
vbi_stop(fh, file);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vbi_init(struct saa7146_dev *dev, struct saa7146_vv *vv)
|
|
|
|
{
|
2011-08-22 05:56:44 +07:00
|
|
|
DEB_VBI("dev:%p\n", dev);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2012-05-01 21:45:27 +07:00
|
|
|
INIT_LIST_HEAD(&vv->vbi_dmaq.queue);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2017-10-17 06:10:42 +07:00
|
|
|
timer_setup(&vv->vbi_dmaq.timeout, saa7146_buffer_timeout, 0);
|
2012-05-01 21:45:27 +07:00
|
|
|
vv->vbi_dmaq.dev = dev;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
init_waitqueue_head(&vv->vbi_wq);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int vbi_open(struct saa7146_dev *dev, struct file *file)
|
|
|
|
{
|
2010-07-13 03:50:03 +07:00
|
|
|
struct saa7146_fh *fh = file->private_data;
|
2012-05-01 21:28:20 +07:00
|
|
|
struct saa7146_vv *vv = fh->dev->vv_data;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
u32 arbtr_ctrl = saa7146_read(dev, PCI_BT_V1);
|
|
|
|
int ret = 0;
|
|
|
|
|
2011-08-22 05:56:44 +07:00
|
|
|
DEB_VBI("dev:%p, fh:%p\n", dev, fh);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
ret = saa7146_res_get(fh, RESOURCE_DMA3_BRS);
|
|
|
|
if (0 == ret) {
|
2011-08-22 05:56:44 +07:00
|
|
|
DEB_S("cannot get vbi RESOURCE_DMA3_BRS resource\n");
|
2005-04-17 05:20:36 +07:00
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* adjust arbitrition control for video dma 3 */
|
|
|
|
arbtr_ctrl &= ~0x1f0000;
|
|
|
|
arbtr_ctrl |= 0x1d0000;
|
|
|
|
saa7146_write(dev, PCI_BT_V1, arbtr_ctrl);
|
|
|
|
saa7146_write(dev, MC2, (MASK_04|MASK_20));
|
|
|
|
|
2008-04-23 00:42:13 +07:00
|
|
|
videobuf_queue_sg_init(&fh->vbi_q, &vbi_qops,
|
|
|
|
&dev->pci->dev, &dev->slock,
|
2005-04-17 05:20:36 +07:00
|
|
|
V4L2_BUF_TYPE_VBI_CAPTURE,
|
|
|
|
V4L2_FIELD_SEQ_TB, // FIXME: does this really work?
|
|
|
|
sizeof(struct saa7146_buf),
|
2010-12-18 19:20:59 +07:00
|
|
|
file, &dev->v4l2_lock);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2017-10-23 14:40:42 +07:00
|
|
|
vv->vbi_read_timeout.function = vbi_read_timeout;
|
2017-10-17 06:10:12 +07:00
|
|
|
vv->vbi_read_timeout_file = file;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* initialize the brs */
|
|
|
|
if ( 0 != (SAA7146_USE_PORT_B_FOR_VBI & dev->ext_vv_data->flags)) {
|
|
|
|
saa7146_write(dev, BRS_CTRL, MASK_30|MASK_29 | (7 << 19));
|
|
|
|
} else {
|
|
|
|
saa7146_write(dev, BRS_CTRL, 0x00000001);
|
|
|
|
|
|
|
|
if (0 != (ret = vbi_workaround(dev))) {
|
2011-08-22 05:56:44 +07:00
|
|
|
DEB_VBI("vbi workaround failed!\n");
|
2005-04-17 05:20:36 +07:00
|
|
|
/* return ret;*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* upload brs register */
|
|
|
|
saa7146_write(dev, MC2, (MASK_08|MASK_24));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vbi_close(struct saa7146_dev *dev, struct file *file)
|
|
|
|
{
|
2010-07-13 03:50:03 +07:00
|
|
|
struct saa7146_fh *fh = file->private_data;
|
2005-04-17 05:20:36 +07:00
|
|
|
struct saa7146_vv *vv = dev->vv_data;
|
2011-08-22 05:56:44 +07:00
|
|
|
DEB_VBI("dev:%p, fh:%p\n", dev, fh);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
if( fh == vv->vbi_streaming ) {
|
|
|
|
vbi_stop(fh, file);
|
|
|
|
}
|
|
|
|
saa7146_res_free(fh, RESOURCE_DMA3_BRS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vbi_irq_done(struct saa7146_dev *dev, unsigned long status)
|
|
|
|
{
|
|
|
|
struct saa7146_vv *vv = dev->vv_data;
|
|
|
|
spin_lock(&dev->slock);
|
|
|
|
|
2012-05-01 21:45:27 +07:00
|
|
|
if (vv->vbi_dmaq.curr) {
|
|
|
|
DEB_VBI("dev:%p, curr:%p\n", dev, vv->vbi_dmaq.curr);
|
2005-04-17 05:20:36 +07:00
|
|
|
/* this must be += 2, one count for each field */
|
|
|
|
vv->vbi_fieldcount+=2;
|
2012-05-01 21:45:27 +07:00
|
|
|
vv->vbi_dmaq.curr->vb.field_count = vv->vbi_fieldcount;
|
|
|
|
saa7146_buffer_finish(dev, &vv->vbi_dmaq, VIDEOBUF_DONE);
|
2005-04-17 05:20:36 +07:00
|
|
|
} else {
|
2011-08-22 05:56:44 +07:00
|
|
|
DEB_VBI("dev:%p\n", dev);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2012-05-01 21:45:27 +07:00
|
|
|
saa7146_buffer_next(dev, &vv->vbi_dmaq, 1);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
spin_unlock(&dev->slock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t vbi_read(struct file *file, char __user *data, size_t count, loff_t *ppos)
|
|
|
|
{
|
|
|
|
struct saa7146_fh *fh = file->private_data;
|
|
|
|
struct saa7146_dev *dev = fh->dev;
|
|
|
|
struct saa7146_vv *vv = dev->vv_data;
|
|
|
|
ssize_t ret = 0;
|
|
|
|
|
2011-08-22 05:56:44 +07:00
|
|
|
DEB_VBI("dev:%p, fh:%p\n", dev, fh);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
if( NULL == vv->vbi_streaming ) {
|
|
|
|
// fixme: check if dma3 is available
|
|
|
|
// fixme: activate vbi engine here if necessary. (really?)
|
|
|
|
vv->vbi_streaming = fh;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( fh != vv->vbi_streaming ) {
|
2011-08-22 05:56:44 +07:00
|
|
|
DEB_VBI("open %p is already using vbi capture\n",
|
|
|
|
vv->vbi_streaming);
|
2005-04-17 05:20:36 +07:00
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
2012-05-01 21:28:20 +07:00
|
|
|
mod_timer(&vv->vbi_read_timeout, jiffies+BUFFER_TIMEOUT);
|
2005-04-17 05:20:36 +07:00
|
|
|
ret = videobuf_read_stream(&fh->vbi_q, data, count, ppos, 1,
|
|
|
|
file->f_flags & O_NONBLOCK);
|
|
|
|
/*
|
|
|
|
printk("BASE_ODD3: 0x%08x\n", saa7146_read(dev, BASE_ODD3));
|
|
|
|
printk("BASE_EVEN3: 0x%08x\n", saa7146_read(dev, BASE_EVEN3));
|
|
|
|
printk("PROT_ADDR3: 0x%08x\n", saa7146_read(dev, PROT_ADDR3));
|
|
|
|
printk("PITCH3: 0x%08x\n", saa7146_read(dev, PITCH3));
|
|
|
|
printk("BASE_PAGE3: 0x%08x\n", saa7146_read(dev, BASE_PAGE3));
|
|
|
|
printk("NUM_LINE_BYTE3: 0x%08x\n", saa7146_read(dev, NUM_LINE_BYTE3));
|
|
|
|
printk("BRS_CTRL: 0x%08x\n", saa7146_read(dev, BRS_CTRL));
|
|
|
|
*/
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-09-14 02:37:50 +07:00
|
|
|
const struct saa7146_use_ops saa7146_vbi_uops = {
|
2006-01-10 00:25:34 +07:00
|
|
|
.init = vbi_init,
|
|
|
|
.open = vbi_open,
|
2005-04-17 05:20:36 +07:00
|
|
|
.release = vbi_close,
|
|
|
|
.irq_done = vbi_irq_done,
|
2006-01-10 00:25:34 +07:00
|
|
|
.read = vbi_read,
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|