summaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb-frontends/stv0367.c
Commit message (Collapse)AuthorAgeFilesLines
* media: dvb-frontends/stv0367: remove QAM_AUTO from ddb_fe_opsDaniel Scheller2017-08-271-1/+1
| | | | | | | | | Since the cab_* codepath doesn't recognize QAM_AUTO, don't announce that it is supported when it really isn't. Fixes ie. w_scan from unconditionally using QAM_AUTO on DVB-C scans. Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* media: dvb-frontends/stv0367: improve QAM fe_statusDaniel Scheller2017-07-201-63/+85
| | | | | | | | | | | | | | | | | | | | | While cab_state->state gives a quite accurate indication of the demod signal status, it might be incorrect if cab_algo() wasn't able to determine the exact status, with cab_algo() being the only place where this status was updated from, and it is only called upon tuning to new parameters passed to set_frontend(). Thus, the status will be wrong until the demod is retuned. With the cab_signal_type parsing in read_status(), this results in unusual fe_states like FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_LOCK, which, while userspace applications check for FE_HAS_LOCK and work fine, leads to missing CNR or UCB stats. Fix this by re-reading CAB_FSM_STATUS and updating cab_state->state() in read_status(). While at it, refactor the fsm/qamfeclock and the fsm->signaltype parsing into separate functions to make things cleaner and deduplicate code. Also, assume full QAM FEC lock equals full FE_STATUS. Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* media: dvb-frontends/stv0367: DDB frontend status inquiry fixupDaniel Scheller2017-07-201-3/+3
| | | | | | | | | | | | Return 0 instead of -EINVAL in get_frontend if no demod mode is active. This fixes ie. dvb-fe-tool getting confused and assuming a DVBv3 FE on idle frontends when the FE has been put to sleep using sleep(). Also, in read_status(), don't immediately return when no demod is active, so the remaining code has a chance to clear the signal statistics. Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* media: dvb-frontends/stv0367: Improve DVB-C/T frontend statusMauro Carvalho Chehab2017-06-251-1/+14
| | | | | | | | | | The stv0367 driver provide a lot of status on its state machine. Change the logic to provide more information about frontend locking status. Also, while any detailed status isn't available, provide a more complete FE_STATUS for DVB-T. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com> Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
* media: dvb-frontends/stv0367: DVB-C signal strength statisticsDaniel Scheller2017-06-251-0/+21
| | | | | | | | | Provide QAM/DVB-C signal strength in decibel scale. Values returned from stv0367cab_get_rf_lvl() are good but need to be multiplied as they're in 1dBm precision. Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* media: dvb-frontends/stv0367: update UCB readout condition logicDaniel Scheller2017-06-251-6/+4Star
| | | | | | | | Since the other statistics are read when fe_status conditions are TRUE, change the ucblocks readout logic to match this aswell. Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* media: stv0367: prevent division by zeroMauro Carvalho Chehab2017-06-251-1/+3
| | | | | | | | While there's a test at the SNR calculus to avoid division by zero, it will still follow the path that would do the division. So, add a missing break there. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* media: dvb-frontends/stv0367: SNR DVBv5 statistics for DVB-C and TDaniel Scheller2017-06-251-0/+39
| | | | | | | | | Add signal-to-noise-ratio as provided by the demodulator in decibel scale. QAM/DVB-C needs some intlog calculation to have usable dB values, OFDM/ DVB-T values from the demod look alright already and are provided as-is. Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* media: dvb-frontends/stv0367: split SNR determination into functionsDaniel Scheller2017-06-241-26/+42
| | | | | | | | | The read_snr() functions currently do some magic to return relative scale values when called. Split out register readouts into separate functions so the functionality can be reused in some other way. Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* media: dvb-frontends/stv0367: initial DDB DVBv5 stats, implement ucblocksDaniel Scheller2017-06-241-4/+50
| | | | | | | | | | This adds the basics to stv0367ddb_read_status() to be able to properly provide signal statistics in DVBv5 format. Also adds UCB readout and provides those values. Also, don't return -EINVAL in ddb_read_status() if active_demod_state indicates no delivery system. Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* media: dvb-frontends/stv0367: deduplicate DDB dvb_frontend_ops capsDaniel Scheller2017-06-241-8/+5Star
| | | | | Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] dvb-frontends/stv0367: add Digital Devices compatibilityDaniel Scheller2017-06-201-0/+324
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This - in conjunction with the previous changes - makes it possible to use the STV0367 DVB-C/T demodulator driver with Digital Devices hardware having this demodulator soldered on them (namely CineCTv6 bridges and some earlier DuoFlex CT addon modules). The changes do the following: - add a third *_attach function which will make use of a third frontend_ops struct which announces both -C and -T support (the same as with DD's own driver stv0367dd). This is necessary to support both delivery systems on one FE without having to do large conversions to VB2 or the need to select either -C or -T mode via modparams and the like. Additionally, the frontend_ops point to new "glue" functions which will then call into the existing functionality depending on the active delivery system/demod state (all used functionality works almost OOTB). - Demod initialisation has been ported from stv0367dd. DD's driver always does a full init of both OFDM and QAM cores, with some additional things. The active delivery system is remembered and upon switch, the Demod will be reconfigured to work in OFDM or QAM mode (that's what the ddb_setup_XX functions are used for). Note that in QAM mode, the DD demods work with an IC speed of 58Mhz. It's not very good to perform full reinits upon Demod mode changes since in very rare occasions this can lead to the I2C interface or the whole Demod to crash, requiring a powercycle, thus the flag to perform full reinit is set to disabled. - A little enum is added for named identifiers of the current Demod state. Initialisation code/register writes originate from stv0367dd. Permission to reuse was formally granted by Ralph Metzler <rjkm@metzlerbros.de>. Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] dvb-frontends/stv0367: fix symbol rate conditions in cab_SetQamSize()Daniel Scheller2017-06-201-6/+6
| | | | | | | | | The values used for comparing symbol rates and the resulting conditional reg writes seem wrong (rates multiplied by ten), so fix those values. While this doesn't seem to influence operation, it should be fixed anyway. Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] dvb-frontends/stv0367: selectable QAM FEC Lock status registerDaniel Scheller2017-06-201-2/+7
| | | | | | | | | | In some configurations (due to different PIN config, wiring or so), the QAM FECLock might be signalled using a different register than F367CAB_QAMFEC_LOCK (e.g. F367CAB_DESCR_SYNCSTATE on Digital Devices hw), so make that register selectable. Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] dvb-frontends/stv0367: support reading if_khz from tuner configDaniel Scheller2017-06-201-13/+32
| | | | | | | | | | | | | Currently, if_khz is set and provided using the configuration var in struct stv0367_config. However, in some constellations, the value might be different for differing channel bandwidths or even -T and -C operation. When e.g. used in conjunction with TDA18212 tuners, the tuner frontend might be aware of the different freqs. This factors if_khz retrieval in a function, which checks a new flag if an automatic retrieval attempt should be made, and if the tuner provides it, use it whenever needed. Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] dvb-frontends/stv0367: make full reinit on set_frontend() optionalDaniel Scheller2017-06-201-2/+7
| | | | | | | | | | | | | Every time dvb_frontend_ops.set_frontend() is called, an almost full reinit of the demodulator will be performed. While this might cause a slight delay when switching channels due to all involved tables being rewritten, it can even be dangerous in certain causes in that the demod may lock up and requires to be powercycled (this can happen on Digital Devices hardware). So this adds a flag if it should be done, and to not change behaviour with existing card support, it'll be enabled in all cases. Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] dvb-frontends/stv0367: make PLLSETUP a function, add 58MHz IC speedDaniel Scheller2017-06-201-25/+48
| | | | | | | | | This moves the PLL SETUP code from stv0367ter_init() into a dedicated function, and also make it possible to configure 58Mhz IC speed at 27MHz Xtal (used on STV0367-based DDB cards/modules in QAM mode). Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] dvb-frontends/stv0367: move out tables, support multiple tab variantsDaniel Scheller2017-06-201-650/+8Star
| | | | | | | | | | | | | Move the *ter and *cab st_register tables into a separate header file and additionally organize them via a multidimensional array, allowing to add more tables with differing init values, and also prepare for a base init table which should contain general setup values. Also add a state var to store the table triplet to be used. Also fixes three minor style problems reported by checkpatch. Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] dvb-frontends/stv0367: refactor defaults table handlingDaniel Scheller2017-06-201-10/+20
| | | | | | | | | | | Change defaults table writing so tables can be of dynamic length without having to keep track of their lengths by adding and evaluating an end marker (reg 0x0000), also move table writing to a dedicated function to remove code duplication. Additionally mark st_register tables const since they're used read-only. Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] dvb-frontends/stv0367: print CPAMP status only if stv_debug is enabledDaniel Scheller2017-06-201-2/+2
| | | | | | | | | | The CPAMP log lines generated in stv0367_ter_check_cpamp() are printed everytime tuning succeeds or fails, quite cluttering the normal kernel log. Use dprintk() instead of printk(KERN_ERR...) so that if the information is needed, it'll be printed when the stv_debug modparam is enabled. Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] dvb-frontends/stv0367: add flag to make i2c_gatectrl optionalDaniel Scheller2017-06-201-4/+12
| | | | | | | | | | | | | | | | Some hardware and bridges (namely ddbridge) require that tuner access is limited to one concurrent access and wrap i2c gate control with a mutex_lock when attaching frontends. According to vendor information, this is required as concurrent tuner reconfiguration can interfere each other and at worst cause tuning fails or bad reception quality. If the demod driver does gate_ctrl before setting up tuner parameters, and the tuner does another I2C enable, it will deadlock forever when gate_ctrl is wrapped into the mutex_lock. This adds a flag and a conditional before triggering gate_ctrl in the demodulator driver. Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: Drop FSF's postal address from the source code filesSakari Ailus2017-01-271-4/+0Star
| | | | | | | | | | | | | | | | | | | | | Drop the FSF's postal address from the source code files that typically contain mostly the license text. Of the 628 removed instances, 578 are outdated. The patch has been created with the following command without manual edits: git grep -l "675 Mass Ave\|59 Temple Place\|51 Franklin St" -- \ drivers/media/ include/media|while read i; do i=$i perl -e ' open(F,"< $ENV{i}"); $a=join("", <F>); $a =~ s/[ \t]*\*\n.*You should.*\n.*along with.*\n.*(\n.*USA.*$)?\n//m && $a =~ s/(^.*)Or, (point your browser to) /$1To obtain the license, $2\n$1/m; close(F); open(F, "> $ENV{i}"); print F $a; close(F);'; done Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
* [media] dvb: make DVB frontend *_ops instances "const"Max Kellermann2016-11-181-2/+2
| | | | | | | | | | | | | These are immutable. Making them "const" allows the compiler to move them to the "rodata" section. Note that cxd2841er_t_c_ops cannot be made "const", because cxd2841er_attach() modifies it. Ouch! [mchehab@s-opensource.com: fix merge conflicts] Signed-off-by: Max Kellermann <max.kellermann@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] dvb_frontend: pass the props cache to get_frontend() as argMauro Carvalho Chehab2016-02-041-4/+4
| | | | | | | | | | | | | | | | | Instead of using the DTV properties cache directly, pass the get frontend data as an argument. For now, everything should remain the same, but the next patch will prevent get_frontend to affect the global cache. This is needed because several drivers don't care enough to only change the properties if locked. Due to that, calling G_PROPERTY before locking on those drivers will make them to never lock. Ok, those drivers are crap and should never be merged like that, but the core should not rely that the drivers would be doing the right thing. Reviewed-by: Michael Ira Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] stv0367: Add support for 16Mhz reference clockPeter Griffin2015-08-111-0/+5
| | | | | | | | | | The B2100A dvb NIM card from ST has 2x stv0367 demodulators and 2x TDA18212 silicon tuners, with a 16Mhz crystal. To get this working properly with the upstream driver we need to add support for the 16Mhz reference clock. Signed-off-by: Peter Griffin <peter.griffin@linaro.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] stv0367: Refine i2c error trace to include i2c addressPeter Griffin2015-08-111-4/+8
| | | | | | | | | | | | | | | | When using stv0367 demodulator with STi STB platforms, we can have easily have four or more stv0367 demods running in the system at one time. As typically the b2120 reference design ships with a b2004a daughter board, which can accept two dvb NIM cards, and each b2100A NIM has 2x stv0367 demods and 2x NXPs tuner on it. In such circumstances it is useful to print the i2c address on error messages to know which one is failing due to I2C issues. Signed-off-by: Peter Griffin <peter.griffin@linaro.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] dvb: Get rid of typedev usage for enumsMauro Carvalho Chehab2015-06-091-5/+7
| | | | | | | | | | | | | | | | | The DVB API was originally defined using typedefs. This is against Kernel CodingStyle, and there's no good usage here. While we can't remove its usage on userspace, we can avoid its usage in Kernelspace. So, let's do it. This patch was generated by this shell script: for j in $(grep typedef include/uapi/linux/dvb/frontend.h |cut -d' ' -f 3); do for i in $(find drivers/media -name '*.[ch]' -type f) $(find drivers/staging/media -name '*.[ch]' -type f); do sed "s,${j}_t,enum $j," <$i >a && mv a $i; done; done While here, make CodingStyle fixes on the affected lines. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com> Acked-by: Stefan Richter <stefanr@s5r6.in-berlin.de> # for drivers/media/firewire/*
* [media] stv0367: Remove an unused parameterMauro Carvalho Chehab2014-09-221-2/+0Star
| | | | | | | | | | | | | | | cab_state->modulation is initialized with a wrong value: drivers/media/dvb-frontends/stv0367.c:3000:42: warning: mixing different enum types drivers/media/dvb-frontends/stv0367.c:3000:42: int enum fe_modulation versus drivers/media/dvb-frontends/stv0367.c:3000:42: int enum stv0367cab_mod as it was declared as "enum stv0367cab_mod". While it could be fixed, there's no value on it, as this is never used. So, just remove the modulation from cab_state structure. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media: stv0367: fix frontend modulation initialization with ↵Maks Naumov2014-09-221-1/+1
| | | | | | | | | FE_CAB_MOD_QAM256 It was using the wrong constant for QAM256 on get_frontend. Signed-off-by: Maks Naumov <maksqwe1@ukr.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] stv0367: just return 0 instead of using a varMauro Carvalho Chehab2014-09-031-3/+1Star
| | | | | | | Instead of allocating a var to store 0 and just return it, change the code to return 0 directly. Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
* [media] stv0367: fix sparse warningsHans Verkuil2014-09-031-2/+2
| | | | | | | | drivers/media/dvb-frontends/stv0367.c:557:5: warning: symbol 'stv0367cab_RF_LookUp1' was not declared. Should it be static? drivers/media/dvb-frontends/stv0367.c:569:5: warning: symbol 'stv0367cab_RF_LookUp2' was not declared. Should it be static? Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
* [media] Remove checks of struct member addressesEmil Goode2014-07-231-7/+2Star
| | | | | | | | | | This removes checks of struct member addresses since they likely result in the condition always being true. Also in the stb6100_get_bandwidth and tda8261_get_bandwidth functions the pointers frontend_ops and tuner_ops are assigned the same addresses twice. Signed-off-by: Emil Goode <emilgoode@gmail.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
* [media] stv0367: Don't use dynamic static allocationMauro Carvalho Chehab2013-11-081-1/+12
| | | | | | | | | | | | | | | | | | Dynamic static allocation is evil, as Kernel stack is too low, and compilation complains about it on some archs: drivers/media/dvb-frontends/stv0367.c:791:1: warning: 'stv0367_writeregs.constprop.4' uses dynamic stack allocation [enabled by default] Instead, let's enforce a limit for the buffer. Considering that I2C transfers are generally limited, and that devices used on USB has a max data length of 64 bytes for the control URBs. So, it seem safe to use 64 bytes as the hard limit for all those devices. On most cases, the limit is a way lower than that, but this limit is small enough to not affect the Kernel stack, and it is a no brain limit, as using smaller ones would require to either carefully each driver or to take a look on each datasheet. Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com> Reviewed-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
* treewide: relase -> releaseGeert Uytterhoeven2013-06-281-1/+1
| | | | | Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
* [media] stv0367: get rid of warning: no previous prototypeMauro Carvalho Chehab2012-10-271-9/+10
| | | | | | | | | | drivers/media/dvb-frontends/stv0367.c:1267:25: warning: no previous prototype for 'stv0367ter_lock_algo' [-Wmissing-prototypes] drivers/media/dvb-frontends/stv0367.c:1531:5: warning: no previous prototype for 'stv0367ter_init' [-Wmissing-prototypes] drivers/media/dvb-frontends/stv0367.c:2381:21: warning: no previous prototype for 'stv0367cab_SetQamSize' [-Wmissing-prototypes] drivers/media/dvb-frontends/stv0367.c:2765:5: warning: no previous prototype for 'stv0367cab_init' [-Wmissing-prototypes] drivers/media/dvb-frontends/stv0367.c:882:4: warning: no previous prototype for 'stv0367_getbits' [-Wmissing-prototypes] Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* [media] move the dvb/frontends to drivers/media/dvb-frontendsMauro Carvalho Chehab2012-08-141-0/+3450
Raise the DVB frontends one level up, as the intention is to remove the drivers/media/dvb directory. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>