1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Elonics E4000 silicon tuner driver
5 * Copyright (C) 2012 Antti Palosaari <crope@iki.fi>
12 #include <linux/math64.h>
13 #include <media/v4l2-ctrls.h>
14 #include <media/v4l2-subdev.h>
15 #include <linux/regmap.h>
18 struct i2c_client
*client
;
19 struct regmap
*regmap
;
21 struct dvb_frontend
*fe
;
22 struct v4l2_subdev sd
;
24 unsigned int f_frequency
;
25 unsigned int f_bandwidth
;
28 struct v4l2_ctrl_handler hdl
;
29 struct v4l2_ctrl
*bandwidth_auto
;
30 struct v4l2_ctrl
*bandwidth
;
31 struct v4l2_ctrl
*lna_gain_auto
;
32 struct v4l2_ctrl
*lna_gain
;
33 struct v4l2_ctrl
*mixer_gain_auto
;
34 struct v4l2_ctrl
*mixer_gain
;
35 struct v4l2_ctrl
*if_gain_auto
;
36 struct v4l2_ctrl
*if_gain
;
37 struct v4l2_ctrl
*pll_lock
;
46 static const struct e4000_pll e4000_pll_lut
[] = {
48 { 72400000, 0x0f, 48 }, /* .......... 3475200000 */
49 { 81200000, 0x0e, 40 }, /* 2896000000 3248000000 */
50 { 108300000, 0x0d, 32 }, /* 2598400000 3465600000 */
51 { 162500000, 0x0c, 24 }, /* 2599200000 3900000000 */
52 { 216600000, 0x0b, 16 }, /* 2600000000 3465600000 */
53 { 325000000, 0x0a, 12 }, /* 2599200000 3900000000 */
54 { 350000000, 0x09, 8 }, /* 2600000000 2800000000 */
55 { 432000000, 0x03, 8 }, /* 2800000000 3456000000 */
56 { 667000000, 0x02, 6 }, /* 2592000000 4002000000 */
57 { 1200000000, 0x01, 4 }, /* 2668000000 4800000000 */
58 { 0xffffffff, 0x00, 2 }, /* 2400000000 .......... */
61 struct e4000_lna_filter
{
66 static const struct e4000_lna_filter e400_lna_filter_lut
[] = {
107 static const struct e4000_band e4000_band_lut
[] = {
108 { 140000000, 0x01, 0x03 },
109 { 350000000, 0x03, 0x03 },
110 { 1000000000, 0x05, 0x03 },
111 { 0xffffffff, 0x07, 0x00 },
114 struct e4000_if_filter
{
120 static const struct e4000_if_filter e4000_if_filter_lut
[] = {
121 { 4300000, 0xfd, 0x1f },
122 { 4400000, 0xfd, 0x1e },
123 { 4480000, 0xfc, 0x1d },
124 { 4560000, 0xfc, 0x1c },
125 { 4600000, 0xfc, 0x1b },
126 { 4800000, 0xfc, 0x1a },
127 { 4900000, 0xfc, 0x19 },
128 { 5000000, 0xfc, 0x18 },
129 { 5100000, 0xfc, 0x17 },
130 { 5200000, 0xfc, 0x16 },
131 { 5400000, 0xfc, 0x15 },
132 { 5500000, 0xfc, 0x14 },
133 { 5600000, 0xfc, 0x13 },
134 { 5800000, 0xfb, 0x12 },
135 { 5900000, 0xfb, 0x11 },
136 { 6000000, 0xfb, 0x10 },
137 { 6200000, 0xfb, 0x0f },
138 { 6400000, 0xfa, 0x0e },
139 { 6600000, 0xfa, 0x0d },
140 { 6800000, 0xf9, 0x0c },
141 { 7200000, 0xf9, 0x0b },
142 { 7400000, 0xf9, 0x0a },
143 { 7600000, 0xf8, 0x09 },
144 { 7800000, 0xf8, 0x08 },
145 { 8200000, 0xf8, 0x07 },
146 { 8600000, 0xf7, 0x06 },
147 { 8800000, 0xf7, 0x05 },
148 { 9200000, 0xf7, 0x04 },
149 { 9600000, 0xf6, 0x03 },
150 { 10000000, 0xf6, 0x02 },
151 { 10600000, 0xf5, 0x01 },
152 { 11000000, 0xf5, 0x00 },
153 { 0xffffffff, 0x00, 0x20 },
156 struct e4000_if_gain
{
161 static const struct e4000_if_gain e4000_if_gain_lut
[] = {