/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Elonics E4000 silicon tuner driver
*
* Copyright (C) 2012 Antti Palosaari <crope@iki.fi>
*/
#ifndef E4000_PRIV_H
#define E4000_PRIV_H
#include "e4000.h"
#include <linux/math64.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-subdev.h>
#include <linux/regmap.h>
struct e4000_dev {
struct i2c_client *client;
struct regmap *regmap;
u32 clk;
struct dvb_frontend *fe;
struct v4l2_subdev sd;
bool active;
unsigned int f_frequency;
unsigned int f_bandwidth;
/* Controls */
struct v4l2_ctrl_handler hdl;
struct v4l2_ctrl *bandwidth_auto;
struct v4l2_ctrl *bandwidth;
struct v4l2_ctrl *lna_gain_auto;
struct v4l2_ctrl *lna_gain;
struct v4l2_ctrl *mixer_gain_auto;
struct v4l2_ctrl *mixer_gain;
struct v4l2_ctrl *if_gain_auto;
struct v4l2_ctrl *if_gain;
struct v4l2_ctrl *pll_lock;
};
struct e4000_pll {
u32 freq;
u8 div_out_reg;
u8 div_out;
};
static const struct e4000_pll e4000_pll_lut[] = {
/* VCO min VCO max */
{ 72400000 , 0 x0f, 48 }, /* .......... 3475200000 */
{ 81200000 , 0 x0e, 40 }, /* 2896000000 3248000000 */
{ 108300000 , 0 x0d, 32 }, /* 2598400000 3465600000 */
{ 162500000 , 0 x0c, 24 }, /* 2599200000 3900000000 */
{ 216600000 , 0 x0b, 16 }, /* 2600000000 3465600000 */
{ 325000000 , 0 x0a, 12 }, /* 2599200000 3900000000 */
{ 350000000 , 0 x09, 8 }, /* 2600000000 2800000000 */
{ 432000000 , 0 x03, 8 }, /* 2800000000 3456000000 */
{ 667000000 , 0 x02, 6 }, /* 2592000000 4002000000 */
{ 1200000000 , 0 x01, 4 }, /* 2668000000 4800000000 */
{ 0 xffffffff, 0 x00, 2 }, /* 2400000000 .......... */
};
struct e4000_lna_filter {
u32 freq;
u8 val;
};
static const struct e4000_lna_filter e400_lna_filter_lut[] = {
{ 370000000 , 0 },
{ 392500000 , 1 },
{ 415000000 , 2 },
{ 437500000 , 3 },
{ 462500000 , 4 },
{ 490000000 , 5 },
{ 522500000 , 6 },
{ 557500000 , 7 },
{ 595000000 , 8 },
{ 642500000 , 9 },
{ 695000000 , 10 },
{ 740000000 , 11 },
{ 800000000 , 12 },
{ 865000000 , 13 },
{ 930000000 , 14 },
{ 1000000000 , 15 },
{ 1310000000 , 0 },
{ 1340000000 , 1 },
{ 1385000000 , 2 },
{ 1427500000 , 3 },
{ 1452500000 , 4 },
{ 1475000000 , 5 },
{ 1510000000 , 6 },
{ 1545000000 , 7 },
{ 1575000000 , 8 },
{ 1615000000 , 9 },
{ 1650000000 , 10 },
{ 1670000000 , 11 },
{ 1690000000 , 12 },
{ 1710000000 , 13 },
{ 1735000000 , 14 },
{ 0 xffffffff, 15 },
};
struct e4000_band {
u32 freq;
u8 reg07_val;
u8 reg78_val;
};
static const struct e4000_band e4000_band_lut[] = {
{ 140000000 , 0 x01, 0 x03 },
{ 350000000 , 0 x03, 0 x03 },
{ 1000000000 , 0 x05, 0 x03 },
{ 0 xffffffff, 0 x07, 0 x00 },
};
struct e4000_if_filter {
u32 freq;
u8 reg11_val;
u8 reg12_val;
};
static const struct e4000_if_filter e4000_if_filter_lut[] = {
{ 4300000 , 0 xfd, 0 x1f },
{ 4400000 , 0 xfd, 0 x1e },
{ 4480000 , 0 xfc, 0 x1d },
{ 4560000 , 0 xfc, 0 x1c },
{ 4600000 , 0 xfc, 0 x1b },
{ 4800000 , 0 xfc, 0 x1a },
{ 4900000 , 0 xfc, 0 x19 },
{ 5000000 , 0 xfc, 0 x18 },
{ 5100000 , 0 xfc, 0 x17 },
{ 5200000 , 0 xfc, 0 x16 },
{ 5400000 , 0 xfc, 0 x15 },
{ 5500000 , 0 xfc, 0 x14 },
{ 5600000 , 0 xfc, 0 x13 },
{ 5800000 , 0 xfb, 0 x12 },
{ 5900000 , 0 xfb, 0 x11 },
{ 6000000 , 0 xfb, 0 x10 },
{ 6200000 , 0 xfb, 0 x0f },
{ 6400000 , 0 xfa, 0 x0e },
{ 6600000 , 0 xfa, 0 x0d },
{ 6800000 , 0 xf9, 0 x0c },
{ 7200000 , 0 xf9, 0 x0b },
{ 7400000 , 0 xf9, 0 x0a },
{ 7600000 , 0 xf8, 0 x09 },
{ 7800000 , 0 xf8, 0 x08 },
{ 8200000 , 0 xf8, 0 x07 },
{ 8600000 , 0 xf7, 0 x06 },
{ 8800000 , 0 xf7, 0 x05 },
{ 9200000 , 0 xf7, 0 x04 },
{ 9600000 , 0 xf6, 0 x03 },
{ 10000000 , 0 xf6, 0 x02 },
{ 10600000 , 0 xf5, 0 x01 },
{ 11000000 , 0 xf5, 0 x00 },
{ 0 xffffffff, 0 x00, 0 x20 },
};
struct e4000_if_gain {
u8 reg16_val;
u8 reg17_val;
};
static const struct e4000_if_gain e4000_if_gain_lut[] = {
{0 x00, 0 x00},
{0 x20, 0 x00},
{0 x40, 0 x00},
{0 x02, 0 x00},
{0 x22, 0 x00},
{0 x42, 0 x00},
{0 x04, 0 x00},
{0 x24, 0 x00},
{0 x44, 0 x00},
{0 x01, 0 x00},
{0 x21, 0 x00},
{0 x41, 0 x00},
{0 x03, 0 x00},
{0 x23, 0 x00},
{0 x43, 0 x00},
{0 x05, 0 x00},
{0 x25, 0 x00},
{0 x45, 0 x00},
{0 x07, 0 x00},
{0 x27, 0 x00},
{0 x47, 0 x00},
{0 x0f, 0 x00},
{0 x2f, 0 x00},
{0 x4f, 0 x00},
{0 x17, 0 x00},
{0 x37, 0 x00},
{0 x57, 0 x00},
{0 x1f, 0 x00},
{0 x3f, 0 x00},
{0 x5f, 0 x00},
{0 x1f, 0 x01},
{0 x3f, 0 x01},
{0 x5f, 0 x01},
{0 x1f, 0 x02},
{0 x3f, 0 x02},
{0 x5f, 0 x02},
{0 x1f, 0 x03},
{0 x3f, 0 x03},
{0 x5f, 0 x03},
{0 x1f, 0 x04},
{0 x3f, 0 x04},
{0 x5f, 0 x04},
{0 x1f, 0 x0c},
{0 x3f, 0 x0c},
{0 x5f, 0 x0c},
{0 x1f, 0 x14},
{0 x3f, 0 x14},
{0 x5f, 0 x14},
{0 x1f, 0 x1c},
{0 x3f, 0 x1c},
{0 x5f, 0 x1c},
{0 x1f, 0 x24},
{0 x3f, 0 x24},
{0 x5f, 0 x24},
{0 x7f, 0 x24},
};
#endif
Messung V0.5 in Prozent C=94 H=100 G=96