Sakari Ailus [Tue, 25 Feb 2014 22:12:19 +0000 (19:12 -0300)]
[media] v4l: Rename vb2_queue.timestamp_type as timestamp_flags
The timestamp_type field used to contain only the timestamp type. Soon it
will be used for timestamp source flags as well. Rename the field
accordingly.
[m.chehab@samsung.com: do the change also to drivers/staging/media and at s2255] Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Sakari Ailus [Sun, 25 Aug 2013 17:00:43 +0000 (14:00 -0300)]
[media] v4l: Use full 32 bits for buffer flags
The buffer flags field is 32 bits but the defined only used 16. This is
fine, but as more than 16 bits will be used in the very near future, define
them as 32-bit numbers for consistency.
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Sakari Ailus [Fri, 25 Jan 2013 18:00:07 +0000 (15:00 -0300)]
[media] v4l: Document timestamp behaviour to correspond to reality
Document that monotonic timestamps are taken after the corresponding frame
has been received, not when the reception has begun. This corresponds to the
reality of current drivers: the timestamp is naturally taken when the
hardware triggers an interrupt to tell the driver to handle the received
frame.
Remove the note on timestamp accuracy as it is fairly subjective what is
actually an unstable timestamp.
Also remove explanation that output buffer timestamps can be used to delay
outputting a frame.
Remove the footnote saying we always use realtime clock.
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Hans Verkuil [Mon, 24 Feb 2014 17:44:50 +0000 (14:44 -0300)]
[media] vb2: fix timecode and flags handling for output buffers
When sending a buffer to a video output device some of the fields need
to be copied so they arrive in the driver. These are the KEY/P/BFRAME
flags and the TIMECODE flag, and, if that flag is set, the timecode field
itself.
There are a number of functions involved in this: the __fill_vb2_buffer()
is called while preparing a buffer. For output buffers the buffer contains
the video data, so any meta data associated with that (KEY/P/BFRAME and
the field information) should be stored at that point.
The timecode, timecode flag and timestamp information is not part of that,
that information will have to be set when vb2_internal_qbuf() is called to
actually queue the buffer to the driver. Usually VIDIOC_QBUF will do the
prepare as well, but you can call PREPARE_BUF first and only later VIDIOC_QBUF.
You most likely will want to set the timestamp and timecode when you actually
queue the buffer, not when you prepare it.
Finally, in buf_prepare() make sure the timestamp and sequence fields are
actually cleared so that when you do a QUERYBUF of a prepared-but-not-yet-queued
buffer you will not see stale timestamp/sequence data.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Antti Palosaari [Sat, 25 Jan 2014 02:44:26 +0000 (23:44 -0300)]
[media] v4l: add RF tuner gain controls
Modern silicon RF tuners used nowadays has many controllable gain
stages on signal path. Usually, but not always, there is at least
3 gain stages. Also on some cases there could be multiple gain
stages within the ones specified here. However, I think that having
these three controllable gain stages offers enough fine-tuning for
real use cases.
1) LNA gain. That is first gain just after antenna input.
2) Mixer gain. It is located quite middle of the signal path, where
RF signal is down-converted to IF/BB.
3) IF gain. That is last gain in order to adjust output signal level
to optimal level for receiving party (usually demodulator ADC).
Each gain stage could be set rather often both manual or automatic
(AGC) mode. Due to that add separate controls for controlling
operation mode.
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Antti Palosaari [Sat, 8 Feb 2014 06:50:04 +0000 (03:50 -0300)]
[media] rtl2832: implement delayed I2C gate close
Delay possible I2C gate close a little bit in order to see if there
is next message coming to tuner in a sequence.
Also, export private muxed I2C adapter. That is aimed only for SDR
extension module as SDR belongs to same RTL2832 physical I2C bus (it
is physically property of RTL2832, whilst it is own kernel module).
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Antti Palosaari [Tue, 3 Dec 2013 21:19:39 +0000 (18:19 -0300)]
[media] rtl2832: add muxed I2C adapter for demod itself
There was a deadlock between master I2C adapter and muxed I2C
adapter. Implement two I2C muxed I2C adapters and leave master
alone, just only for offering I2C adapter for these mux adapters.
Reported-by: Luis Alves <ljalvs@gmail.com> Reported-by: Benjamin Larsson <benjamin@southpole.se> Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
All used tuners has get_if_frequency() callback and that parameter
is not needed and will not needed as all upcoming tuner drivers
should implement get_if_frequency().
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Antti Palosaari [Fri, 22 Nov 2013 17:20:14 +0000 (14:20 -0300)]
[media] rtl28xxu: add module parameter to disable IR
Disable IR interrupts in order to avoid SDR sample loss.
IR interrupts causes some extra load for device and it seems
be one reason to loss samples when sampling rate is high.
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Antti Palosaari [Sat, 1 Feb 2014 00:55:47 +0000 (21:55 -0300)]
[media] xc2028: silence compiler warnings
There is now new tuner types which are not handled on that switch-case.
Print error if unknown tuner type is meet.
drivers/media/tuners/tuner-xc2028.c: In function ‘generic_set_freq’:
drivers/media/tuners/tuner-xc2028.c:1037:2: warning: enumeration value ‘V4L2_TUNER_ADC’ not handled in switch [-Wswitch]
switch (new_type) {
^
drivers/media/tuners/tuner-xc2028.c:1037:2: warning: enumeration value ‘V4L2_TUNER_RF’ not handled in switch [-Wswitch]
Antti Palosaari [Wed, 11 Dec 2013 23:24:02 +0000 (20:24 -0300)]
[media] v4l: add new tuner types for SDR
Define tuner types V4L2_TUNER_ADC and V4L2_TUNER_RF for SDR usage.
ADC is used for setting sampling rate (sampling frequency) to SDR
device.
Another tuner type, named as V4L2_TUNER_RF, is possible RF tuner.
Is is used to down-convert RF frequency to range ADC could sample.
Having RF tuner is optional, whilst in practice it is almost always
there.
Also add checks to VIDIOC_G_FREQUENCY, VIDIOC_S_FREQUENCY and
VIDIOC_ENUM_FREQ_BANDS only allow these two tuner types when device
type is SDR (VFL_TYPE_SDR). For VIDIOC_G_FREQUENCY we do not check
tuner type, instead override type with V4L2_TUNER_ADC in every
case (requested by Hans in order to keep functionality in line with
existing tuners and existing API does not specify it).
Prohibit VIDIOC_S_HW_FREQ_SEEK explicitly when device type is SDR,
as device cannot do hardware seek without a hardware demodulator.
Signed-off-by: Antti Palosaari <crope@iki.fi> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Antti Palosaari [Wed, 22 Jan 2014 04:07:25 +0000 (01:07 -0300)]
[media] devices.txt: add video4linux device for Software Defined Radio
Add new video4linux device named /dev/swradio for Software Defined
Radio use. V4L device minor numbers are allocated dynamically
nowadays, but there is still configuration option for old fixed style.
Add note to mention that configuration option too.
Signed-off-by: Antti Palosaari <crope@iki.fi> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Alan Cox <alan@linux.intel.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
[media] drx-j: Properly initialize mpeg struct before using it
The cfg_mpeg_output has more fields than what it is initialized
when the code is called. Be sure to initialize everything before
use, in order to avoid random behaviors.
Shuah Khan [Fri, 28 Feb 2014 21:23:02 +0000 (18:23 -0300)]
[media] drx-j: fix boot failure due to null pointer dereference
DJH_DEBUG only code path in drxbsp_i2c_write_read() dereferences
w_dev_addr and subsequently w_dev_addr->user_data->i2c which results
in failure during boot. This patch fixes the null pointer derefence
bug as well as the following compile errors:
LD arch/x86/built-in.o
CC drivers/media/dvb-frontends/drx39xyj/drxj.o
drivers/media/dvb-frontends/drx39xyj/drxj.c: In function ‘drxbsp_i2c_write_read’:
drivers/media/dvb-frontends/drx39xyj/drxj.c:1558:25: error: redeclaration of ‘state’ with no linkage
struct drx39xxj_state *state = w_dev_addr->user_data;
^
drivers/media/dvb-frontends/drx39xyj/drxj.c:1512:25: note: previous declaration of ‘state’ was here
struct drx39xxj_state *state;
^
drivers/media/dvb-frontends/drx39xyj/drxj.c:1558:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
struct drx39xxj_state *state = w_dev_addr->user_data;
^
drivers/media/dvb-frontends/drx39xyj/drxj.c:1560:17: error: redeclaration of ‘msg’ with no linkage
struct i2c_msg msg[2] = {
^
drivers/media/dvb-frontends/drx39xyj/drxj.c:1513:17: note: previous declaration of ‘msg’ was here
struct i2c_msg msg[2];
^
This file contains an abstract layer for the I2C transfer
functions. Get rid of it, merging it at drxj. This will allow
to remove another abstraction layer there, making the code
easier to read, and removing the functions that just return
-EIO.
[media] drx-j: use the proper timeout code on scu_command
Checking if a time is after another one can have issues, as
times are generally u32 wide.
Use the proper macros for that at scu_command().
It should be noticed that other places also use jiffies
calculus on an improper way. This should be fixed too,
but the logic there is more complex. So, let's do it in
separate patches.
When switching from one video standard to another one,
power_down_vsb is called twice. Well, as the device is already
in power_down mode, the second call always fail. This causes that
any subsequent frontend set to fail as well:
[145074.501243] drx39xyj:power_down_vsb: called
[145089.195396] drx39xyj:power_down_vsb: error -5
[145089.195404] drx39xyj:ctrl_set_standard: error -5
[145089.195417] drx39xyj:drx39xxj_set_frontend: Failed to set standard! result=fffffffb
[145089.195470] drx39xyj:ctrl_sig_quality: error -5
[145089.195473] drx39xyj:drx39xxj_read_ber: drx39xxj: could not get ber!
[145089.195475] drx39xyj:ctrl_sig_quality: error -5
[145089.195477] drx39xyj:drx39xxj_read_signal_strength: drx39xxj: could not get signal strength!
[145089.195479] drx39xyj:ctrl_sig_quality: error -5
[145089.195480] drx39xyj:drx39xxj_read_snr: drx39xxj: could not read snr!
[145089.195482] drx39xyj:ctrl_sig_quality: error -5
[145089.195484] drx39xyj:drx39xxj_read_ucblocks: drx39xxj: could not get uc blocks!
[145089.195498] drx39xyj:ctrl_sig_quality: error -5
[145089.195500] drx39xyj:drx39xxj_read_ber: drx39xxj: could not get ber!
[145089.195502] drx39xyj:ctrl_sig_quality: error -5
[145089.195503] drx39xyj:drx39xxj_read_signal_strength: drx39xxj: could not get signal strength!
[145089.195505] drx39xyj:ctrl_sig_quality: error -5
[145089.195506] drx39xyj:drx39xxj_read_snr: drx39xxj: could not read snr!
[145089.195508] drx39xyj:ctrl_sig_quality: error -5
[145089.195510] drx39xyj:drx39xxj_read_ucblocks: drx39xxj: could not get uc blocks!
[145090.196291] drx39xyj:drx39xxj_read_status: drx39xxj: could not get lock status!
[145090.196508] drx39xyj:ctrl_sig_quality: error -5
[145090.196511] drx39xyj:drx39xxj_read_ber: drx39xxj: could not get ber!
[145090.196514] drx39xyj:ctrl_sig_quality: error -5
[145090.196515] drx39xyj:drx39xxj_read_signal_strength: drx39xxj: could not get signal strength!
[145090.196518] drx39xyj:ctrl_sig_quality: error -5
[145090.196519] drx39xyj:drx39xxj_read_snr: drx39xxj: could not read snr!
[145090.196522] drx39xyj:ctrl_sig_quality: error -5
[145090.196523] drx39xyj:drx39xxj_read_ucblocks: drx39xxj: could not get uc blocks!
[145090.196553] drx39xyj:ctrl_sig_quality: error -5
[145090.196554] drx39xyj:drx39xxj_read_ber: drx39xxj: could not get ber!
[145090.196557] drx39xyj:ctrl_sig_quality: error -5
[145090.196558] drx39xyj:drx39xxj_read_signal_strength: drx39xxj: could not get signal strength!
[145090.196560] drx39xyj:ctrl_sig_quality: error -5
[145090.196562] drx39xyj:drx39xxj_read_snr: drx39xxj: could not read snr!
[145090.196564] drx39xyj:ctrl_sig_quality: error -5
[145090.196565] drx39xyj:drx39xxj_read_ucblocks: drx39xxj: could not get uc blocks!
[145091.119265] drx39xyj:ctrl_sig_quality: error -5
[145091.119271] drx39xyj:drx39xxj_read_ber: drx39xxj: could not get ber!
[145091.119274] drx39xyj:ctrl_sig_quality: error -5
[145091.119276] drx39xyj:drx39xxj_read_signal_strength: drx39xxj: could not get signal strength!
[145091.119278] drx39xyj:ctrl_sig_quality: error -5
[145091.119280] drx39xyj:drx39xxj_read_snr: drx39xxj: could not read snr!
[145091.119282] drx39xyj:ctrl_sig_quality: error -5
[145091.119283] drx39xyj:drx39xxj_read_ucblocks: drx39xxj: could not get uc blocks!
[media] drx-j: remove some ugly bindings from drx39xxj_dummy.c
This file does an ugly binding between drxj and DVB frontend.
Remove most of the functions there. We still need to get rid of
get_frequency and set_frequency, but such patch is a little more
complex, as it should also remove some previous tuner bindings.
In order to avoid warnings and to remove dead code, remove
the functions that don't make sense to happen, while commenting
the others that might still be useful some day.
That reduced a lot the text size:
Before:
text data bss dec hex filename
58419 2916 4 61339 ef9b drivers/media/dvb-frontends/drx39xyj/drx39xyj.ko
After:
text data bss dec hex filename
78331 2916 4 81251 13d63 drivers/media/dvb-frontends/drx39xyj/drx39xyj.ko
Without any functional changes.
It could be make sense latter to remove those drivers or to
move them into an analog-specific part of the driver.
With this change, we finally got rid of all abstraction
layers on this driver.
This patch also fixes the LNA GPIO settings, as the original
code were using a wrong control name for it.
This patch exposes the several functions that aren't used.
Some of them are related to analog demod that might be
used some day, but others will likely never be needed, as
they don't fit on Linux media APIs.
ClearQAM is currently not working. Add support for it too.
Unlikely other ATSC tuners, though, this device will not
auto-detect between ATSC and ClearQAM. So, the delivery
system should be properly set.
Also, this frontend seems to also support DVB-C annex A/C. Add
experimental support for them.
[media] drx-j: Split firmware size check from the main routine
The firmware upload routine is already complex enough. Split the
first loop that verifies the firmware size into a separate routine,
making the code more readable.
Instead of defining its own set of error codes, use the linux
native ones.
Please note that this patch made a "stupid" error code mapping, just
replacing the codes with the closest one. In special, -EIO is being
used on several places. I'm pretty sure this could be better assigned,
but a change like that would require lots o time and efforts, without
much benefit.
So lets do adjstments at the error codes latter, when we have more
time.
Fix almost all checkpatch.pl warnings/errors on drxj.c, except for:
- 80 cols whitespacing;
- too many leading tabs;
- a false positive at DRXJ_16TO8() macro.
- static char array declaration should probably be static const char
as adding "const" would cause warnings.
Using return and goto inside macros is ugly and makes harder to
understand the code and the labels. Remove those macros, and add
a proper error debug message, when something bad happens.
This was generated using the following coccinelle script:
[media] drx-j: Don't use buffer if an error occurs
drivers/media/dvb-frontends/drx39xyj/drxj.c: In function ‘drxj_dap_scu_atomic_read_reg16’:
drivers/media/dvb-frontends/drx39xyj/drxj.c:4170:9: warning: ‘*((void *)&buf+1)’ may be used uninitialized in this function [-Wmaybe-uninitialized]
word = (u16) (buf[0] + (buf[1] << 8));
^
drivers/media/dvb-frontends/drx39xyj/drxj.c:4170:9: warning: ‘buf’ may be used uninitialized in this function [-Wmaybe-uninitialized]
drivers/media/dvb-frontends/drx39xyj/drxj.c: In function ‘drxj_dap_atomic_read_reg32.isra.59’:
drivers/media/dvb-frontends/drx39xyj/drxj.c:2186:7: warning: ‘*((void *)&buf+3)’ may be used uninitialized in this function [-Wmaybe-uninitialized]
word = (u32) buf[3];
^
drivers/media/dvb-frontends/drx39xyj/drxj.c:2188:10: warning: ‘*((void *)&buf+2)’ may be used uninitialized in this function [-Wmaybe-uninitialized]
word |= (u32) buf[2];
^
drivers/media/dvb-frontends/drx39xyj/drxj.c:2190:10: warning: ‘*((void *)&buf+1)’ may be used uninitialized in this function [-Wmaybe-uninitialized]
word |= (u32) buf[1];
^
drivers/media/dvb-frontends/drx39xyj/drxj.c:2192:10: warning: ‘buf’ may be used uninitialized in this function [-Wmaybe-uninitialized]
word |= (u32) buf[0];
^
This were fixed with the help of this small perl script:
#!/usr/bin/perl
my $dir = shift or die "need a dir";
my $type = shift or die "need type";
my $var = shift or die "need var";
sub handle_file {
my $file = shift;
my $out;
open IN, $file or die "can't open $file";
$out .= $_ while (<IN>);
close IN;
$out =~ s/\btypedef\s+($type)\s+\{([\d\D]+?)\s*\}\s+\b($var)[^\;]+\;/$type $var \{\2\};/;
$out =~ s,\b($var)_t\s+,$type \1 ,g;
$out =~ s,\bp_*($var)_t\s+,$type \1 *,g;
$out =~ s,\b($var)_t\b,$type \1,g;
$out =~ s,\bp_*($var)_t\b,$type \1 *,g;
open OUT, ">$file" or die "can't open $file";
print OUT $out;
close OUT;
}
sub parse_dir {
my $file = $File::Find::name;
return if (!($file =~ /.[ch]$/));
handle_file $file;
}
find({wanted => \&parse_dir, no_chdir => 1}, $dir);
[media] drx-j: get rid of typedefs in drx_driver.h
Most of the changes were done with scripts like:
for i in drivers/media/dvb-frontends/drx39xyj/*.[ch]; do perl -ne '$var = "drx_sig_quality"; s,\b($var)_t\s+,struct \1 ,g; s,\bp_*($var)_t\s+,struct \1 *,g; s,\b($var)_t\b,struct \1,g; s,\bp_*($var)_t\b,struct \1 *,g; print $_' <$i >a && mv a $i; done
drivers/media/dvb-frontends/drx39xyj/drx_driver.c:181:7: warning: no previous prototype for 'get_scan_context' [-Wmissing-prototypes]
void *get_scan_context(pdrx_demod_instance_t demod, void *scan_context)
drivers/media/dvb-frontends/drx39xyj/drx_driver.c: At top level:
drivers/media/dvb-frontends/drx39xyj/drx_driver.c:842:5: warning: no previous prototype for 'ctrl_dump_registers' [-Wmissing-prototypes]
int ctrl_dump_registers(pdrx_demod_instance_t demod,
[media] drx-j: Remove a bunch of unused but assigned vars
None of those vars are used on those functions. Just remove them.
After this patch, there's just one of such warnings:
drivers/media/dvb-frontends/drx39xyj/drxj.c: In function 'ctrl_get_qam_sig_quality':
drivers/media/dvb-frontends/drx39xyj/drxj.c:7872:6: warning: variable 'ber_cnt' set but not used [-Wunused-but-set-variable]
u32 ber_cnt = 0; /* BER count */
We'll keep it, as BER count will be useful when converting the
frontend to report statistics via DVBv5 API