linux/drivers/media/dvb-frontends/cx24116.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
    Conexant cx24116/cx24118 - DVBS/S2 Satellite demod/tuner driver

    Copyright (C) 2006-2008 Steven Toth <[email protected]>
    Copyright (C) 2006-2007 Georg Acher
    Copyright (C) 2007-2008 Darron Broad
	March 2007
	    Fixed some bugs.
	    Added diseqc support.
	    Added corrected signal strength support.
	August 2007
	    Sync with legacy version.
	    Some clean ups.
    Copyright (C) 2008 Igor Liplianin
	September, 9th 2008
	    Fixed locking on high symbol rates (>30000).
	    Implement MPEG initialization parameter.
	January, 17th 2009
	    Fill set_voltage with actually control voltage code.
	    Correct set tone to not affect voltage.

*/

#include <linux/slab.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/firmware.h>

#include <media/dvb_frontend.h>
#include "cx24116.h"

static int debug;
module_param(debug, int, 0644);
MODULE_PARM_DESC();

#define dprintk(args...)

#define CX24116_DEFAULT_FIRMWARE
#define CX24116_SEARCH_RANGE_KHZ

/* known registers */
#define CX24116_REG_COMMAND
#define CX24116_REG_EXECUTE
#define CX24116_REG_MAILBOX
#define CX24116_REG_RESET
#define CX24116_REG_SIGNAL
#define CX24116_REG_SSTATUS
#define CX24116_REG_QUALITY8
#define CX24116_REG_QSTATUS
#define CX24116_REG_QUALITY0
#define CX24116_REG_BER0
#define CX24116_REG_BER8
#define CX24116_REG_BER16
#define CX24116_REG_BER24
#define CX24116_REG_UCB0
#define CX24116_REG_UCB8
#define CX24116_REG_CLKDIV
#define CX24116_REG_RATEDIV

/* configured fec (not tuned) or actual FEC (tuned) 1=1/2 2=2/3 etc */
#define CX24116_REG_FECSTATUS

/* FECSTATUS bits */
/* mask to determine configured fec (not tuned) or actual fec (tuned) */
#define CX24116_FEC_FECMASK

/* Select DVB-S demodulator, else DVB-S2 */
#define CX24116_FEC_DVBS
#define CX24116_FEC_UNKNOWN

/* Pilot mode requested when tuning else always reset when tuned */
#define CX24116_FEC_PILOT

/* arg buffer size */
#define CX24116_ARGLEN

/* rolloff */
#define CX24116_ROLLOFF_020
#define CX24116_ROLLOFF_025
#define CX24116_ROLLOFF_035

/* pilot bit */
#define CX24116_PILOT_OFF
#define CX24116_PILOT_ON

/* signal status */
#define CX24116_HAS_SIGNAL
#define CX24116_HAS_CARRIER
#define CX24116_HAS_VITERBI
#define CX24116_HAS_SYNCLOCK
#define CX24116_HAS_UNKNOWN1
#define CX24116_HAS_UNKNOWN2
#define CX24116_STATUS_MASK
#define CX24116_SIGNAL_MASK

#define CX24116_DISEQC_TONEOFF
#define CX24116_DISEQC_TONECACHE
#define CX24116_DISEQC_MESGCACHE

/* arg offset for DiSEqC */
#define CX24116_DISEQC_BURST
#define CX24116_DISEQC_ARG2_2
#define CX24116_DISEQC_ARG3_0
#define CX24116_DISEQC_ARG4_0
#define CX24116_DISEQC_MSGLEN
#define CX24116_DISEQC_MSGOFS

/* DiSEqC burst */
#define CX24116_DISEQC_MINI_A
#define CX24116_DISEQC_MINI_B

/* DiSEqC tone burst */
static int toneburst =;
module_param(toneburst, int, 0644);
MODULE_PARM_DESC();

/* SNR measurements */
static int esno_snr;
module_param(esno_snr, int, 0644);
MODULE_PARM_DESC();

enum cmds {};

/* The Demod/Tuner can't easily provide these, we cache them */
struct cx24116_tuning {};

/* Basic commands that are sent to the firmware */
struct cx24116_cmd {};

struct cx24116_state {};

static int cx24116_writereg(struct cx24116_state *state, int reg, int data)
{}

/* Bulk byte writes to a single I2C address, for 32k firmware load */
static int cx24116_writeregN(struct cx24116_state *state, int reg,
			     const u8 *data, u16 len)
{}

static int cx24116_readreg(struct cx24116_state *state, u8 reg)
{}

static int cx24116_set_inversion(struct cx24116_state *state,
	enum fe_spectral_inversion inversion)
{}

/*
 * modfec (modulation and FEC)
 * ===========================
 *
 * MOD          FEC             mask/val    standard
 * ----         --------        ----------- --------
 * QPSK         FEC_1_2         0x02 0x02+X DVB-S
 * QPSK         FEC_2_3         0x04 0x02+X DVB-S
 * QPSK         FEC_3_4         0x08 0x02+X DVB-S
 * QPSK         FEC_4_5         0x10 0x02+X DVB-S (?)
 * QPSK         FEC_5_6         0x20 0x02+X DVB-S
 * QPSK         FEC_6_7         0x40 0x02+X DVB-S
 * QPSK         FEC_7_8         0x80 0x02+X DVB-S
 * QPSK         FEC_8_9         0x01 0x02+X DVB-S (?) (NOT SUPPORTED?)
 * QPSK         AUTO            0xff 0x02+X DVB-S
 *
 * For DVB-S high byte probably represents FEC
 * and low byte selects the modulator. The high
 * byte is search range mask. Bit 5 may turn
 * on DVB-S and remaining bits represent some
 * kind of calibration (how/what i do not know).
 *
 * Eg.(2/3) szap "Zone Horror"
 *
 * mask/val = 0x04, 0x20
 * status 1f | signal c3c0 | snr a333 | ber 00000098 | unc 0 | FE_HAS_LOCK
 *
 * mask/val = 0x04, 0x30
 * status 1f | signal c3c0 | snr a333 | ber 00000000 | unc 0 | FE_HAS_LOCK
 *
 * After tuning FECSTATUS contains actual FEC
 * in use numbered 1 through to 8 for 1/2 .. 2/3 etc
 *
 * NBC=NOT/NON BACKWARD COMPATIBLE WITH DVB-S (DVB-S2 only)
 *
 * NBC-QPSK     FEC_1_2         0x00, 0x04      DVB-S2
 * NBC-QPSK     FEC_3_5         0x00, 0x05      DVB-S2
 * NBC-QPSK     FEC_2_3         0x00, 0x06      DVB-S2
 * NBC-QPSK     FEC_3_4         0x00, 0x07      DVB-S2
 * NBC-QPSK     FEC_4_5         0x00, 0x08      DVB-S2
 * NBC-QPSK     FEC_5_6         0x00, 0x09      DVB-S2
 * NBC-QPSK     FEC_8_9         0x00, 0x0a      DVB-S2
 * NBC-QPSK     FEC_9_10        0x00, 0x0b      DVB-S2
 *
 * NBC-8PSK     FEC_3_5         0x00, 0x0c      DVB-S2
 * NBC-8PSK     FEC_2_3         0x00, 0x0d      DVB-S2
 * NBC-8PSK     FEC_3_4         0x00, 0x0e      DVB-S2
 * NBC-8PSK     FEC_5_6         0x00, 0x0f      DVB-S2
 * NBC-8PSK     FEC_8_9         0x00, 0x10      DVB-S2
 * NBC-8PSK     FEC_9_10        0x00, 0x11      DVB-S2
 *
 * For DVB-S2 low bytes selects both modulator
 * and FEC. High byte is meaningless here. To
 * set pilot, bit 6 (0x40) is set. When inspecting
 * FECSTATUS bit 7 (0x80) represents the pilot
 * selection whilst not tuned. When tuned, actual FEC
 * in use is found in FECSTATUS as per above. Pilot
 * value is reset.
 */

/* A table of modulation, fec and configuration bytes for the demod.
 * Not all S2 mmodulation schemes are support and not all rates with
 * a scheme are support. Especially, no auto detect when in S2 mode.
 */
static struct cx24116_modfec {} CX24116_MODFEC_MODES[] =;

static int cx24116_lookup_fecmod(struct cx24116_state *state,
	enum fe_delivery_system d, enum fe_modulation m, enum fe_code_rate f)
{}

static int cx24116_set_fec(struct cx24116_state *state,
			   enum fe_delivery_system delsys,
			   enum fe_modulation mod,
			   enum fe_code_rate fec)
{}

static int cx24116_set_symbolrate(struct cx24116_state *state, u32 rate)
{}

static int cx24116_load_firmware(struct dvb_frontend *fe,
	const struct firmware *fw);

static int cx24116_firmware_ondemand(struct dvb_frontend *fe)
{}

/* Take a basic firmware command structure, format it
 * and forward it for processing
 */
static int cx24116_cmd_execute(struct dvb_frontend *fe, struct cx24116_cmd *cmd)
{}

static int cx24116_load_firmware(struct dvb_frontend *fe,
	const struct firmware *fw)
{}

static int cx24116_read_status(struct dvb_frontend *fe, enum fe_status *status)
{}

static int cx24116_read_ber(struct dvb_frontend *fe, u32 *ber)
{}

/* TODO Determine function and scale appropriately */
static int cx24116_read_signal_strength(struct dvb_frontend *fe,
	u16 *signal_strength)
{}

/* SNR (0..100)% = (sig & 0xf0) * 10 + (sig & 0x0f) * 10 / 16 */
static int cx24116_read_snr_pct(struct dvb_frontend *fe, u16 *snr)
{}

/* The reelbox patches show the value in the registers represents
 * ESNO, from 0->30db (values 0->300). We provide this value by
 * default.
 */
static int cx24116_read_snr_esno(struct dvb_frontend *fe, u16 *snr)
{}

static int cx24116_read_snr(struct dvb_frontend *fe, u16 *snr)
{}

static int cx24116_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
{}

/* Overwrite the current tuning params, we are about to tune */
static void cx24116_clone_params(struct dvb_frontend *fe)
{}

/* Wait for LNB */
static int cx24116_wait_for_lnb(struct dvb_frontend *fe)
{}

static int cx24116_set_voltage(struct dvb_frontend *fe,
	enum fe_sec_voltage voltage)
{}

static int cx24116_set_tone(struct dvb_frontend *fe,
	enum fe_sec_tone_mode tone)
{}

/* Initialise DiSEqC */
static int cx24116_diseqc_init(struct dvb_frontend *fe)
{}

/* Send DiSEqC message with derived burst (hack) || previous burst */
static int cx24116_send_diseqc_msg(struct dvb_frontend *fe,
	struct dvb_diseqc_master_cmd *d)
{}

/* Send DiSEqC burst */
static int cx24116_diseqc_send_burst(struct dvb_frontend *fe,
	enum fe_sec_mini_cmd burst)
{}

static void cx24116_release(struct dvb_frontend *fe)
{}

static const struct dvb_frontend_ops cx24116_ops;

struct dvb_frontend *cx24116_attach(const struct cx24116_config *config,
	struct i2c_adapter *i2c)
{}
EXPORT_SYMBOL_GPL();

/*
 * Initialise or wake up device
 *
 * Power config will reset and load initial firmware if required
 */
static int cx24116_initfe(struct dvb_frontend *fe)
{}

/*
 * Put device to sleep
 */
static int cx24116_sleep(struct dvb_frontend *fe)
{}

/* dvb-core told us to tune, the tv property cache will be complete,
 * it's safe for is to pull values and use them for tuning purposes.
 */
static int cx24116_set_frontend(struct dvb_frontend *fe)
{}

static int cx24116_tune(struct dvb_frontend *fe, bool re_tune,
	unsigned int mode_flags, unsigned int *delay, enum fe_status *status)
{}

static enum dvbfe_algo cx24116_get_algo(struct dvb_frontend *fe)
{}

static const struct dvb_frontend_ops cx24116_ops =;

MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_LICENSE();