2019-05-27 06:55:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2008-04-28 23:24:33 +00:00
|
|
|
/*
|
|
|
|
* cx18 ioctl control functions
|
|
|
|
*
|
|
|
|
* Derived from ivtv-controls.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Hans Verkuil <hverkuil@xs4all.nl>
|
|
|
|
*/
|
2009-07-24 00:51:29 +00:00
|
|
|
#include <linux/kernel.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 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2008-04-28 23:24:33 +00:00
|
|
|
|
|
|
|
#include "cx18-driver.h"
|
|
|
|
#include "cx18-cards.h"
|
|
|
|
#include "cx18-ioctl.h"
|
|
|
|
#include "cx18-audio.h"
|
|
|
|
#include "cx18-mailbox.h"
|
|
|
|
#include "cx18-controls.h"
|
|
|
|
|
2010-12-31 13:22:52 +00:00
|
|
|
static int cx18_s_stream_vbi_fmt(struct cx2341x_handler *cxhdl, u32 fmt)
|
2008-04-28 23:24:33 +00:00
|
|
|
{
|
2010-12-31 13:22:52 +00:00
|
|
|
struct cx18 *cx = container_of(cxhdl, struct cx18, cxhdl);
|
|
|
|
int type = cxhdl->stream_type->val;
|
2009-02-21 02:52:13 +00:00
|
|
|
|
2008-05-25 14:21:27 +00:00
|
|
|
if (atomic_read(&cx->ana_capturing) > 0)
|
2008-04-28 23:24:33 +00:00
|
|
|
return -EBUSY;
|
|
|
|
|
2009-03-02 02:10:07 +00:00
|
|
|
if (fmt != V4L2_MPEG_STREAM_VBI_FMT_IVTV ||
|
2009-04-26 19:34:36 +00:00
|
|
|
!(type == V4L2_MPEG_STREAM_TYPE_MPEG2_PS ||
|
|
|
|
type == V4L2_MPEG_STREAM_TYPE_MPEG2_DVD ||
|
|
|
|
type == V4L2_MPEG_STREAM_TYPE_MPEG2_SVCD)) {
|
|
|
|
/* Only IVTV fmt VBI insertion & only MPEG-2 PS type streams */
|
2009-03-02 02:10:07 +00:00
|
|
|
cx->vbi.insert_mpeg = V4L2_MPEG_STREAM_VBI_FMT_NONE;
|
[media] cx18: don't break long lines
Due to the 80-cols restrictions, and latter due to checkpatch
warnings, several strings were broken into multiple lines. This
is not considered a good practice anymore, as it makes harder
to grep for strings at the source code.
As we're right now fixing other drivers due to KERN_CONT, we need
to be able to identify what printk strings don't end with a "\n".
It is a way easier to detect those if we don't break long lines.
So, join those continuation lines.
The patch was generated via the script below, and manually
adjusted if needed.
</script>
use Text::Tabs;
while (<>) {
if ($next ne "") {
$c=$_;
if ($c =~ /^\s+\"(.*)/) {
$c2=$1;
$next =~ s/\"\n$//;
$n = expand($next);
$funpos = index($n, '(');
$pos = index($c2, '",');
if ($funpos && $pos > 0) {
$s1 = substr $c2, 0, $pos + 2;
$s2 = ' ' x ($funpos + 1) . substr $c2, $pos + 2;
$s2 =~ s/^\s+//;
$s2 = ' ' x ($funpos + 1) . $s2 if ($s2 ne "");
print unexpand("$next$s1\n");
print unexpand("$s2\n") if ($s2 ne "");
} else {
print "$next$c2\n";
}
$next="";
next;
} else {
print $next;
}
$next="";
} else {
if (m/\"$/) {
if (!m/\\n\"$/) {
$next=$_;
next;
}
}
}
print $_;
}
</script>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-10-18 19:44:03 +00:00
|
|
|
CX18_DEBUG_INFO("disabled insertion of sliced VBI data into the MPEG stream\n");
|
2009-03-02 02:10:07 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate sliced VBI buffers if needed. */
|
|
|
|
if (cx->vbi.sliced_mpeg_data[0] == NULL) {
|
2008-04-28 23:24:33 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < CX18_VBI_FRAMES; i++) {
|
2009-01-31 03:33:02 +00:00
|
|
|
cx->vbi.sliced_mpeg_data[i] =
|
|
|
|
kmalloc(CX18_SLICED_MPEG_DATA_BUFSZ, GFP_KERNEL);
|
2008-04-28 23:24:33 +00:00
|
|
|
if (cx->vbi.sliced_mpeg_data[i] == NULL) {
|
|
|
|
while (--i >= 0) {
|
|
|
|
kfree(cx->vbi.sliced_mpeg_data[i]);
|
|
|
|
cx->vbi.sliced_mpeg_data[i] = NULL;
|
|
|
|
}
|
2009-03-02 02:10:07 +00:00
|
|
|
cx->vbi.insert_mpeg =
|
|
|
|
V4L2_MPEG_STREAM_VBI_FMT_NONE;
|
[media] cx18: don't break long lines
Due to the 80-cols restrictions, and latter due to checkpatch
warnings, several strings were broken into multiple lines. This
is not considered a good practice anymore, as it makes harder
to grep for strings at the source code.
As we're right now fixing other drivers due to KERN_CONT, we need
to be able to identify what printk strings don't end with a "\n".
It is a way easier to detect those if we don't break long lines.
So, join those continuation lines.
The patch was generated via the script below, and manually
adjusted if needed.
</script>
use Text::Tabs;
while (<>) {
if ($next ne "") {
$c=$_;
if ($c =~ /^\s+\"(.*)/) {
$c2=$1;
$next =~ s/\"\n$//;
$n = expand($next);
$funpos = index($n, '(');
$pos = index($c2, '",');
if ($funpos && $pos > 0) {
$s1 = substr $c2, 0, $pos + 2;
$s2 = ' ' x ($funpos + 1) . substr $c2, $pos + 2;
$s2 =~ s/^\s+//;
$s2 = ' ' x ($funpos + 1) . $s2 if ($s2 ne "");
print unexpand("$next$s1\n");
print unexpand("$s2\n") if ($s2 ne "");
} else {
print "$next$c2\n";
}
$next="";
next;
} else {
print $next;
}
$next="";
} else {
if (m/\"$/) {
if (!m/\\n\"$/) {
$next=$_;
next;
}
}
}
print $_;
}
</script>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-10-18 19:44:03 +00:00
|
|
|
CX18_WARN("Unable to allocate buffers for sliced VBI data insertion\n");
|
2008-04-28 23:24:33 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cx->vbi.insert_mpeg = fmt;
|
[media] cx18: don't break long lines
Due to the 80-cols restrictions, and latter due to checkpatch
warnings, several strings were broken into multiple lines. This
is not considered a good practice anymore, as it makes harder
to grep for strings at the source code.
As we're right now fixing other drivers due to KERN_CONT, we need
to be able to identify what printk strings don't end with a "\n".
It is a way easier to detect those if we don't break long lines.
So, join those continuation lines.
The patch was generated via the script below, and manually
adjusted if needed.
</script>
use Text::Tabs;
while (<>) {
if ($next ne "") {
$c=$_;
if ($c =~ /^\s+\"(.*)/) {
$c2=$1;
$next =~ s/\"\n$//;
$n = expand($next);
$funpos = index($n, '(');
$pos = index($c2, '",');
if ($funpos && $pos > 0) {
$s1 = substr $c2, 0, $pos + 2;
$s2 = ' ' x ($funpos + 1) . substr $c2, $pos + 2;
$s2 =~ s/^\s+//;
$s2 = ' ' x ($funpos + 1) . $s2 if ($s2 ne "");
print unexpand("$next$s1\n");
print unexpand("$s2\n") if ($s2 ne "");
} else {
print "$next$c2\n";
}
$next="";
next;
} else {
print $next;
}
$next="";
} else {
if (m/\"$/) {
if (!m/\\n\"$/) {
$next=$_;
next;
}
}
}
print $_;
}
</script>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-10-18 19:44:03 +00:00
|
|
|
CX18_DEBUG_INFO("enabled insertion of sliced VBI data into the MPEG PS,when sliced VBI is enabled\n");
|
2008-04-28 23:24:33 +00:00
|
|
|
|
2009-03-02 02:10:07 +00:00
|
|
|
/*
|
|
|
|
* If our current settings have no lines set for capture, store a valid,
|
|
|
|
* default set of service lines to capture, in our current settings.
|
|
|
|
*/
|
2008-04-30 00:38:51 +00:00
|
|
|
if (cx18_get_service_set(cx->vbi.sliced_in) == 0) {
|
2008-04-28 23:24:33 +00:00
|
|
|
if (cx->is_60hz)
|
2009-03-02 02:10:07 +00:00
|
|
|
cx->vbi.sliced_in->service_set =
|
|
|
|
V4L2_SLICED_CAPTION_525;
|
2008-04-28 23:24:33 +00:00
|
|
|
else
|
|
|
|
cx->vbi.sliced_in->service_set = V4L2_SLICED_WSS_625;
|
2008-04-30 00:38:51 +00:00
|
|
|
cx18_expand_service_set(cx->vbi.sliced_in, cx->is_50hz);
|
2008-04-28 23:24:33 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-12-31 13:22:52 +00:00
|
|
|
static int cx18_s_video_encoding(struct cx2341x_handler *cxhdl, u32 val)
|
2008-04-28 23:24:33 +00:00
|
|
|
{
|
2010-12-31 13:22:52 +00:00
|
|
|
struct cx18 *cx = container_of(cxhdl, struct cx18, cxhdl);
|
|
|
|
int is_mpeg1 = val == V4L2_MPEG_VIDEO_ENCODING_MPEG_1;
|
2015-04-09 07:05:59 +00:00
|
|
|
struct v4l2_subdev_format format = {
|
|
|
|
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
|
|
|
|
};
|
|
|
|
struct v4l2_mbus_framefmt *fmt = &format.format;
|
2010-12-31 13:22:52 +00:00
|
|
|
|
|
|
|
/* fix videodecoder resolution */
|
2015-04-09 07:05:59 +00:00
|
|
|
fmt->width = cxhdl->width / (is_mpeg1 ? 2 : 1);
|
|
|
|
fmt->height = cxhdl->height;
|
|
|
|
fmt->code = MEDIA_BUS_FMT_FIXED;
|
|
|
|
v4l2_subdev_call(cx->sd_av, pad, set_fmt, NULL, &format);
|
2010-12-31 13:22:52 +00:00
|
|
|
return 0;
|
2008-06-21 11:36:31 +00:00
|
|
|
}
|
2008-04-28 23:24:33 +00:00
|
|
|
|
2010-12-31 13:22:52 +00:00
|
|
|
static int cx18_s_audio_sampling_freq(struct cx2341x_handler *cxhdl, u32 idx)
|
2008-06-21 11:36:31 +00:00
|
|
|
{
|
2010-12-31 13:22:52 +00:00
|
|
|
static const u32 freqs[3] = { 44100, 48000, 32000 };
|
|
|
|
struct cx18 *cx = container_of(cxhdl, struct cx18, cxhdl);
|
2008-04-28 23:24:33 +00:00
|
|
|
|
2010-12-31 13:22:52 +00:00
|
|
|
/* The audio clock of the digitizer must match the codec sample
|
|
|
|
rate otherwise you get some very strange effects. */
|
|
|
|
if (idx < ARRAY_SIZE(freqs))
|
|
|
|
cx18_call_all(cx, audio, s_clock_freq, freqs[idx]);
|
|
|
|
return 0;
|
2008-06-21 11:36:31 +00:00
|
|
|
}
|
2008-04-28 23:24:33 +00:00
|
|
|
|
2010-12-31 13:22:52 +00:00
|
|
|
static int cx18_s_audio_mode(struct cx2341x_handler *cxhdl, u32 val)
|
2008-06-21 11:36:31 +00:00
|
|
|
{
|
2010-12-31 13:22:52 +00:00
|
|
|
struct cx18 *cx = container_of(cxhdl, struct cx18, cxhdl);
|
2008-06-21 11:36:31 +00:00
|
|
|
|
2010-12-31 13:22:52 +00:00
|
|
|
cx->dualwatch_stereo_mode = val;
|
|
|
|
return 0;
|
2008-04-28 23:24:33 +00:00
|
|
|
}
|
2010-12-31 13:22:52 +00:00
|
|
|
|
2015-11-22 17:44:38 +00:00
|
|
|
const struct cx2341x_handler_ops cx18_cxhdl_ops = {
|
2010-12-31 13:22:52 +00:00
|
|
|
.s_audio_mode = cx18_s_audio_mode,
|
|
|
|
.s_audio_sampling_freq = cx18_s_audio_sampling_freq,
|
|
|
|
.s_video_encoding = cx18_s_video_encoding,
|
|
|
|
.s_stream_vbi_fmt = cx18_s_stream_vbi_fmt,
|
|
|
|
};
|