diff options
Diffstat (limited to 'drivers/media/tuners')
36 files changed, 82 insertions, 709 deletions
diff --git a/drivers/media/tuners/Kconfig b/drivers/media/tuners/Kconfig index 42e5a01b9192..983510d282f6 100644 --- a/drivers/media/tuners/Kconfig +++ b/drivers/media/tuners/Kconfig @@ -224,14 +224,6 @@ config MEDIA_TUNER_FC2580 help FCI FC2580 silicon tuner driver. -config MEDIA_TUNER_M88TS2022 - tristate "Montage M88TS2022 silicon tuner" - depends on MEDIA_SUPPORT && I2C - select REGMAP_I2C - default m if !MEDIA_SUBDRV_AUTOSELECT - help - Montage M88TS2022 silicon tuner driver. - config MEDIA_TUNER_M88RS6000T tristate "Montage M88RS6000 internal tuner" depends on MEDIA_SUPPORT && I2C diff --git a/drivers/media/tuners/Makefile b/drivers/media/tuners/Makefile index da4fe6ef73e7..06a9ab65e5fa 100644 --- a/drivers/media/tuners/Makefile +++ b/drivers/media/tuners/Makefile @@ -33,7 +33,6 @@ obj-$(CONFIG_MEDIA_TUNER_E4000) += e4000.o obj-$(CONFIG_MEDIA_TUNER_FC2580) += fc2580.o obj-$(CONFIG_MEDIA_TUNER_TUA9001) += tua9001.o obj-$(CONFIG_MEDIA_TUNER_SI2157) += si2157.o -obj-$(CONFIG_MEDIA_TUNER_M88TS2022) += m88ts2022.o obj-$(CONFIG_MEDIA_TUNER_FC0011) += fc0011.o obj-$(CONFIG_MEDIA_TUNER_FC0012) += fc0012.o obj-$(CONFIG_MEDIA_TUNER_FC0013) += fc0013.o diff --git a/drivers/media/tuners/fc0011.h b/drivers/media/tuners/fc0011.h index 43ec893a6877..81bb568d6943 100644 --- a/drivers/media/tuners/fc0011.h +++ b/drivers/media/tuners/fc0011.h @@ -23,7 +23,7 @@ enum fc0011_fe_callback_commands { FC0011_FE_CALLBACK_RESET, }; -#if IS_ENABLED(CONFIG_MEDIA_TUNER_FC0011) +#if IS_REACHABLE(CONFIG_MEDIA_TUNER_FC0011) struct dvb_frontend *fc0011_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, const struct fc0011_config *config); diff --git a/drivers/media/tuners/fc0012.h b/drivers/media/tuners/fc0012.h index 1d08057e3275..9ad32859bab0 100644 --- a/drivers/media/tuners/fc0012.h +++ b/drivers/media/tuners/fc0012.h @@ -49,7 +49,7 @@ struct fc0012_config { bool clock_out; }; -#if IS_ENABLED(CONFIG_MEDIA_TUNER_FC0012) +#if IS_REACHABLE(CONFIG_MEDIA_TUNER_FC0012) extern struct dvb_frontend *fc0012_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, const struct fc0012_config *cfg); diff --git a/drivers/media/tuners/fc0013.h b/drivers/media/tuners/fc0013.h index d65d5b37f56e..e130bd7a3230 100644 --- a/drivers/media/tuners/fc0013.h +++ b/drivers/media/tuners/fc0013.h @@ -26,7 +26,7 @@ #include "dvb_frontend.h" #include "fc001x-common.h" -#if IS_ENABLED(CONFIG_MEDIA_TUNER_FC0013) +#if IS_REACHABLE(CONFIG_MEDIA_TUNER_FC0013) extern struct dvb_frontend *fc0013_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 i2c_address, int dual_master, diff --git a/drivers/media/tuners/fc2580.h b/drivers/media/tuners/fc2580.h index 9c43c1cc82d9..b1ce6770f88e 100644 --- a/drivers/media/tuners/fc2580.h +++ b/drivers/media/tuners/fc2580.h @@ -37,7 +37,7 @@ struct fc2580_config { u32 clock; }; -#if IS_ENABLED(CONFIG_MEDIA_TUNER_FC2580) +#if IS_REACHABLE(CONFIG_MEDIA_TUNER_FC2580) extern struct dvb_frontend *fc2580_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, const struct fc2580_config *cfg); #else diff --git a/drivers/media/tuners/m88ts2022.c b/drivers/media/tuners/m88ts2022.c deleted file mode 100644 index 066e5431da93..000000000000 --- a/drivers/media/tuners/m88ts2022.c +++ /dev/null @@ -1,579 +0,0 @@ -/* - * Montage M88TS2022 silicon tuner driver - * - * Copyright (C) 2013 Antti Palosaari <crope@iki.fi> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Some calculations are taken from existing TS2020 driver. - */ - -#include "m88ts2022_priv.h" - -static int m88ts2022_cmd(struct m88ts2022_dev *dev, int op, int sleep, u8 reg, - u8 mask, u8 val, u8 *reg_val) -{ - int ret, i; - unsigned int utmp; - struct m88ts2022_reg_val reg_vals[] = { - {0x51, 0x1f - op}, - {0x51, 0x1f}, - {0x50, 0x00 + op}, - {0x50, 0x00}, - }; - - for (i = 0; i < 2; i++) { - dev_dbg(&dev->client->dev, - "i=%d op=%02x reg=%02x mask=%02x val=%02x\n", - i, op, reg, mask, val); - - for (i = 0; i < ARRAY_SIZE(reg_vals); i++) { - ret = regmap_write(dev->regmap, reg_vals[i].reg, - reg_vals[i].val); - if (ret) - goto err; - } - - usleep_range(sleep * 1000, sleep * 10000); - - ret = regmap_read(dev->regmap, reg, &utmp); - if (ret) - goto err; - - if ((utmp & mask) != val) - break; - } - - if (reg_val) - *reg_val = utmp; -err: - return ret; -} - -static int m88ts2022_set_params(struct dvb_frontend *fe) -{ - struct m88ts2022_dev *dev = fe->tuner_priv; - struct dtv_frontend_properties *c = &fe->dtv_property_cache; - int ret; - unsigned int utmp, frequency_khz, frequency_offset_khz, f_3db_hz; - unsigned int f_ref_khz, f_vco_khz, div_ref, div_out, pll_n, gdiv28; - u8 buf[3], u8tmp, cap_code, lpf_gm, lpf_mxdiv, div_max, div_min; - u16 u16tmp; - - dev_dbg(&dev->client->dev, - "frequency=%d symbol_rate=%d rolloff=%d\n", - c->frequency, c->symbol_rate, c->rolloff); - /* - * Integer-N PLL synthesizer - * kHz is used for all calculations to keep calculations within 32-bit - */ - f_ref_khz = DIV_ROUND_CLOSEST(dev->cfg.clock, 1000); - div_ref = DIV_ROUND_CLOSEST(f_ref_khz, 2000); - - if (c->symbol_rate < 5000000) - frequency_offset_khz = 3000; /* 3 MHz */ - else - frequency_offset_khz = 0; - - frequency_khz = c->frequency + frequency_offset_khz; - - if (frequency_khz < 1103000) { - div_out = 4; - u8tmp = 0x1b; - } else { - div_out = 2; - u8tmp = 0x0b; - } - - buf[0] = u8tmp; - buf[1] = 0x40; - ret = regmap_bulk_write(dev->regmap, 0x10, buf, 2); - if (ret) - goto err; - - f_vco_khz = frequency_khz * div_out; - pll_n = f_vco_khz * div_ref / f_ref_khz; - pll_n += pll_n % 2; - dev->frequency_khz = pll_n * f_ref_khz / div_ref / div_out; - - if (pll_n < 4095) - u16tmp = pll_n - 1024; - else if (pll_n < 6143) - u16tmp = pll_n + 1024; - else - u16tmp = pll_n + 3072; - - buf[0] = (u16tmp >> 8) & 0x3f; - buf[1] = (u16tmp >> 0) & 0xff; - buf[2] = div_ref - 8; - ret = regmap_bulk_write(dev->regmap, 0x01, buf, 3); - if (ret) - goto err; - - dev_dbg(&dev->client->dev, - "frequency=%u offset=%d f_vco_khz=%u pll_n=%u div_ref=%u div_out=%u\n", - dev->frequency_khz, dev->frequency_khz - c->frequency, - f_vco_khz, pll_n, div_ref, div_out); - - ret = m88ts2022_cmd(dev, 0x10, 5, 0x15, 0x40, 0x00, NULL); - if (ret) - goto err; - - ret = regmap_read(dev->regmap, 0x14, &utmp); - if (ret) - goto err; - - utmp &= 0x7f; - if (utmp < 64) { - ret = regmap_update_bits(dev->regmap, 0x10, 0x80, 0x80); - if (ret) - goto err; - - ret = regmap_write(dev->regmap, 0x11, 0x6f); - if (ret) - goto err; - - ret = m88ts2022_cmd(dev, 0x10, 5, 0x15, 0x40, 0x00, NULL); - if (ret) - goto err; - } - - ret = regmap_read(dev->regmap, 0x14, &utmp); - if (ret) - goto err; - - utmp &= 0x1f; - if (utmp > 19) { - ret = regmap_update_bits(dev->regmap, 0x10, 0x02, 0x00); - if (ret) - goto err; - } - - ret = m88ts2022_cmd(dev, 0x08, 5, 0x3c, 0xff, 0x00, NULL); - if (ret) - goto err; - - ret = regmap_write(dev->regmap, 0x25, 0x00); - if (ret) - goto err; - - ret = regmap_write(dev->regmap, 0x27, 0x70); - if (ret) - goto err; - - ret = regmap_write(dev->regmap, 0x41, 0x09); - if (ret) - goto err; - - ret = regmap_write(dev->regmap, 0x08, 0x0b); - if (ret) - goto err; - - /* filters */ - gdiv28 = DIV_ROUND_CLOSEST(f_ref_khz * 1694U, 1000000U); - - ret = regmap_write(dev->regmap, 0x04, gdiv28); - if (ret) - goto err; - - ret = m88ts2022_cmd(dev, 0x04, 2, 0x26, 0xff, 0x00, &u8tmp); - if (ret) - goto err; - - cap_code = u8tmp & 0x3f; - - ret = regmap_write(dev->regmap, 0x41, 0x0d); - if (ret) - goto err; - - ret = m88ts2022_cmd(dev, 0x04, 2, 0x26, 0xff, 0x00, &u8tmp); - if (ret) - goto err; - - u8tmp &= 0x3f; - cap_code = (cap_code + u8tmp) / 2; - gdiv28 = gdiv28 * 207 / (cap_code * 2 + 151); - div_max = gdiv28 * 135 / 100; - div_min = gdiv28 * 78 / 100; - div_max = clamp_val(div_max, 0U, 63U); - - f_3db_hz = mult_frac(c->symbol_rate, 135, 200); - f_3db_hz += 2000000U + (frequency_offset_khz * 1000U); - f_3db_hz = clamp(f_3db_hz, 7000000U, 40000000U); - -#define LPF_COEFF 3200U - lpf_gm = DIV_ROUND_CLOSEST(f_3db_hz * gdiv28, LPF_COEFF * f_ref_khz); - lpf_gm = clamp_val(lpf_gm, 1U, 23U); - - lpf_mxdiv = DIV_ROUND_CLOSEST(lpf_gm * LPF_COEFF * f_ref_khz, f_3db_hz); - if (lpf_mxdiv < div_min) - lpf_mxdiv = DIV_ROUND_CLOSEST(++lpf_gm * LPF_COEFF * f_ref_khz, f_3db_hz); - lpf_mxdiv = clamp_val(lpf_mxdiv, 0U, div_max); - - ret = regmap_write(dev->regmap, 0x04, lpf_mxdiv); - if (ret) - goto err; - - ret = regmap_write(dev->regmap, 0x06, lpf_gm); - if (ret) - goto err; - - ret = m88ts2022_cmd(dev, 0x04, 2, 0x26, 0xff, 0x00, &u8tmp); - if (ret) - goto err; - - cap_code = u8tmp & 0x3f; - - ret = regmap_write(dev->regmap, 0x41, 0x09); - if (ret) - goto err; - - ret = m88ts2022_cmd(dev, 0x04, 2, 0x26, 0xff, 0x00, &u8tmp); - if (ret) - goto err; - - u8tmp &= 0x3f; - cap_code = (cap_code + u8tmp) / 2; - - u8tmp = cap_code | 0x80; - ret = regmap_write(dev->regmap, 0x25, u8tmp); - if (ret) - goto err; - - ret = regmap_write(dev->regmap, 0x27, 0x30); - if (ret) - goto err; - - ret = regmap_write(dev->regmap, 0x08, 0x09); - if (ret) - goto err; - - ret = m88ts2022_cmd(dev, 0x01, 20, 0x21, 0xff, 0x00, NULL); - if (ret) - goto err; -err: - if (ret) - dev_dbg(&dev->client->dev, "failed=%d\n", ret); - - return ret; -} - -static int m88ts2022_init(struct dvb_frontend *fe) -{ - struct m88ts2022_dev *dev = fe->tuner_priv; - int ret, i; - u8 u8tmp; - static const struct m88ts2022_reg_val reg_vals[] = { - {0x7d, 0x9d}, - {0x7c, 0x9a}, - {0x7a, 0x76}, - {0x3b, 0x01}, - {0x63, 0x88}, - {0x61, 0x85}, - {0x22, 0x30}, - {0x30, 0x40}, - {0x20, 0x23}, - {0x24, 0x02}, - {0x12, 0xa0}, - }; - - dev_dbg(&dev->client->dev, "\n"); - - ret = regmap_write(dev->regmap, 0x00, 0x01); - if (ret) - goto err; - - ret = regmap_write(dev->regmap, 0x00, 0x03); - if (ret) - goto err; - - switch (dev->cfg.clock_out) { - case M88TS2022_CLOCK_OUT_DISABLED: - u8tmp = 0x60; - break; - case M88TS2022_CLOCK_OUT_ENABLED: - u8tmp = 0x70; - ret = regmap_write(dev->regmap, 0x05, dev->cfg.clock_out_div); - if (ret) - goto err; - break; - case M88TS2022_CLOCK_OUT_ENABLED_XTALOUT: - u8tmp = 0x6c; - break; - default: - goto err; - } - - ret = regmap_write(dev->regmap, 0x42, u8tmp); - if (ret) - goto err; - - if (dev->cfg.loop_through) - u8tmp = 0xec; - else - u8tmp = 0x6c; - - ret = regmap_write(dev->regmap, 0x62, u8tmp); - if (ret) - goto err; - - for (i = 0; i < ARRAY_SIZE(reg_vals); i++) { - ret = regmap_write(dev->regmap, reg_vals[i].reg, reg_vals[i].val); - if (ret) - goto err; - } -err: - if (ret) - dev_dbg(&dev->client->dev, "failed=%d\n", ret); - return ret; -} - -static int m88ts2022_sleep(struct dvb_frontend *fe) -{ - struct m88ts2022_dev *dev = fe->tuner_priv; - int ret; - - dev_dbg(&dev->client->dev, "\n"); - - ret = regmap_write(dev->regmap, 0x00, 0x00); - if (ret) - goto err; -err: - if (ret) - dev_dbg(&dev->client->dev, "failed=%d\n", ret); - return ret; -} - -static int m88ts2022_get_frequency(struct dvb_frontend *fe, u32 *frequency) -{ - struct m88ts2022_dev *dev = fe->tuner_priv; - - dev_dbg(&dev->client->dev, "\n"); - - *frequency = dev->frequency_khz; - return 0; -} - -static int m88ts2022_get_if_frequency(struct dvb_frontend *fe, u32 *frequency) -{ - struct m88ts2022_dev *dev = fe->tuner_priv; - - dev_dbg(&dev->client->dev, "\n"); - - *frequency = 0; /* Zero-IF */ - return 0; -} - -static int m88ts2022_get_rf_strength(struct dvb_frontend *fe, u16 *strength) -{ - struct m88ts2022_dev *dev = fe->tuner_priv; - int ret; - u16 gain, u16tmp; - unsigned int utmp, gain1, gain2, gain3; - - ret = regmap_read(dev->regmap, 0x3d, &utmp); - if (ret) - goto err; - - gain1 = (utmp >> 0) & 0x1f; - gain1 = clamp(gain1, 0U, 15U); - - ret = regmap_read(dev->regmap, 0x21, &utmp); - if (ret) - goto err; - - gain2 = (utmp >> 0) & 0x1f; - gain2 = clamp(gain2, 2U, 16U); - - ret = regmap_read(dev->regmap, 0x66, &utmp); - if (ret) - goto err; - - gain3 = (utmp >> 3) & 0x07; - gain3 = clamp(gain3, 0U, 6U); - - gain = gain1 * 265 + gain2 * 338 + gain3 * 285; - - /* scale value to 0x0000-0xffff */ - u16tmp = (0xffff - gain); - u16tmp = clamp_val(u16tmp, 59000U, 61500U); - - *strength = (u16tmp - 59000) * 0xffff / (61500 - 59000); -err: - if (ret) - dev_dbg(&dev->client->dev, "failed=%d\n", ret); - return ret; -} - -static const struct dvb_tuner_ops m88ts2022_tuner_ops = { - .info = { - .name = "Montage M88TS2022", - .frequency_min = 950000, - .frequency_max = 2150000, - }, - - .init = m88ts2022_init, - .sleep = m88ts2022_sleep, - .set_params = m88ts2022_set_params, - - .get_frequency = m88ts2022_get_frequency, - .get_if_frequency = m88ts2022_get_if_frequency, - .get_rf_strength = m88ts2022_get_rf_strength, -}; - -static int m88ts2022_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct m88ts2022_config *cfg = client->dev.platform_data; - struct dvb_frontend *fe = cfg->fe; - struct m88ts2022_dev *dev; - int ret; - u8 u8tmp; - unsigned int utmp; - static const struct regmap_config regmap_config = { - .reg_bits = 8, - .val_bits = 8, - }; - - dev = kzalloc(sizeof(*dev), GFP_KERNEL); - if (!dev) { - ret = -ENOMEM; - dev_err(&client->dev, "kzalloc() failed\n"); - goto err; - } - - memcpy(&dev->cfg, cfg, sizeof(struct m88ts2022_config)); - dev->client = client; - dev->regmap = devm_regmap_init_i2c(client, ®map_config); - if (IS_ERR(dev->regmap)) { - ret = PTR_ERR(dev->regmap); - goto err; - } - - /* check if the tuner is there */ - ret = regmap_read(dev->regmap, 0x00, &utmp); - if (ret) - goto err; - - if ((utmp & 0x03) == 0x00) { - ret = regmap_write(dev->regmap, 0x00, 0x01); - if (ret) - goto err; - - usleep_range(2000, 50000); - } - - ret = regmap_write(dev->regmap, 0x00, 0x03); - if (ret) - goto err; - - usleep_range(2000, 50000); - - ret = regmap_read(dev->regmap, 0x00, &utmp); - if (ret) - goto err; - - dev_dbg(&dev->client->dev, "chip_id=%02x\n", utmp); - - switch (utmp) { - case 0xc3: - case 0x83: - break; - default: - ret = -ENODEV; - goto err; - } - - switch (dev->cfg.clock_out) { - case M88TS2022_CLOCK_OUT_DISABLED: - u8tmp = 0x60; - break; - case M88TS2022_CLOCK_OUT_ENABLED: - u8tmp = 0x70; - ret = regmap_write(dev->regmap, 0x05, dev->cfg.clock_out_div); - if (ret) - goto err; - break; - case M88TS2022_CLOCK_OUT_ENABLED_XTALOUT: - u8tmp = 0x6c; - break; - default: - ret = -EINVAL; - goto err; - } - - ret = regmap_write(dev->regmap, 0x42, u8tmp); - if (ret) - goto err; - - if (dev->cfg.loop_through) - u8tmp = 0xec; - else - u8tmp = 0x6c; - - ret = regmap_write(dev->regmap, 0x62, u8tmp); - if (ret) - goto err; - - /* sleep */ - ret = regmap_write(dev->regmap, 0x00, 0x00); - if (ret) - goto err; - - dev_info(&dev->client->dev, "Montage M88TS2022 successfully identified\n"); - - fe->tuner_priv = dev; - memcpy(&fe->ops.tuner_ops, &m88ts2022_tuner_ops, - sizeof(struct dvb_tuner_ops)); - - i2c_set_clientdata(client, dev); - return 0; -err: - dev_dbg(&client->dev, "failed=%d\n", ret); - kfree(dev); - return ret; -} - -static int m88ts2022_remove(struct i2c_client *client) -{ - struct m88ts2022_dev *dev = i2c_get_clientdata(client); - struct dvb_frontend *fe = dev->cfg.fe; - - dev_dbg(&client->dev, "\n"); - - memset(&fe->ops.tuner_ops, 0, sizeof(struct dvb_tuner_ops)); - fe->tuner_priv = NULL; - kfree(dev); - - return 0; -} - -static const struct i2c_device_id m88ts2022_id[] = { - {"m88ts2022", 0}, - {} -}; -MODULE_DEVICE_TABLE(i2c, m88ts2022_id); - -static struct i2c_driver m88ts2022_driver = { - .driver = { - .owner = THIS_MODULE, - .name = "m88ts2022", - }, - .probe = m88ts2022_probe, - .remove = m88ts2022_remove, - .id_table = m88ts2022_id, -}; - -module_i2c_driver(m88ts2022_driver); - -MODULE_DESCRIPTION("Montage M88TS2022 silicon tuner driver"); -MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>"); -MODULE_LICENSE("GPL"); diff --git a/drivers/media/tuners/m88ts2022.h b/drivers/media/tuners/m88ts2022.h deleted file mode 100644 index 659fa1b1633a..000000000000 --- a/drivers/media/tuners/m88ts2022.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Montage M88TS2022 silicon tuner driver - * - * Copyright (C) 2013 Antti Palosaari <crope@iki.fi> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef M88TS2022_H -#define M88TS2022_H - -#include "dvb_frontend.h" - -struct m88ts2022_config { - /* - * clock - * 16000000 - 32000000 - */ - u32 clock; - - /* - * RF loop-through - */ - u8 loop_through:1; - - /* - * clock output - */ -#define M88TS2022_CLOCK_OUT_DISABLED 0 -#define M88TS2022_CLOCK_OUT_ENABLED 1 -#define M88TS2022_CLOCK_OUT_ENABLED_XTALOUT 2 - u8 clock_out:2; - - /* - * clock output divider - * 1 - 31 - */ - u8 clock_out_div:5; - - /* - * pointer to DVB frontend - */ - struct dvb_frontend *fe; -}; - -#endif diff --git a/drivers/media/tuners/m88ts2022_priv.h b/drivers/media/tuners/m88ts2022_priv.h deleted file mode 100644 index feeb5ad6beef..000000000000 --- a/drivers/media/tuners/m88ts2022_priv.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Montage M88TS2022 silicon tuner driver - * - * Copyright (C) 2013 Antti Palosaari <crope@iki.fi> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef M88TS2022_PRIV_H -#define M88TS2022_PRIV_H - -#include "m88ts2022.h" -#include <linux/regmap.h> - -struct m88ts2022_dev { - struct m88ts2022_config cfg; - struct i2c_client *client; - struct regmap *regmap; - u32 frequency_khz; -}; - -struct m88ts2022_reg_val { - u8 reg; - u8 val; -}; - -#endif diff --git a/drivers/media/tuners/max2165.h b/drivers/media/tuners/max2165.h index 26e1dc64bb67..5054f01a78fb 100644 --- a/drivers/media/tuners/max2165.h +++ b/drivers/media/tuners/max2165.h @@ -32,7 +32,7 @@ struct max2165_config { u8 osc_clk; /* in MHz, selectable values: 4,16,18,20,22,24,26,28 */ }; -#if IS_ENABLED(CONFIG_MEDIA_TUNER_MAX2165) +#if IS_REACHABLE(CONFIG_MEDIA_TUNER_MAX2165) extern struct dvb_frontend *max2165_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct max2165_config *cfg); diff --git a/drivers/media/tuners/mc44s803.h b/drivers/media/tuners/mc44s803.h index 9aae50aca2b7..b3e614be657d 100644 --- a/drivers/media/tuners/mc44s803.h +++ b/drivers/media/tuners/mc44s803.h @@ -32,7 +32,7 @@ struct mc44s803_config { u8 dig_out; }; -#if IS_ENABLED(CONFIG_MEDIA_TUNER_MC44S803) +#if IS_REACHABLE(CONFIG_MEDIA_TUNER_MC44S803) extern struct dvb_frontend *mc44s803_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mc44s803_config *cfg); #else diff --git a/drivers/media/tuners/mt2060.h b/drivers/media/tuners/mt2060.h index c64fc19cb278..6efed359a24f 100644 --- a/drivers/media/tuners/mt2060.h +++ b/drivers/media/tuners/mt2060.h @@ -30,7 +30,7 @@ struct mt2060_config { u8 clock_out; /* 0 = off, 1 = CLK/4, 2 = CLK/2, 3 = CLK/1 */ }; -#if IS_ENABLED(CONFIG_MEDIA_TUNER_MT2060) +#if IS_REACHABLE(CONFIG_MEDIA_TUNER_MT2060) extern struct dvb_frontend * mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2060_config *cfg, u16 if1); #else static inline struct dvb_frontend * mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2060_config *cfg, u16 if1) diff --git a/drivers/media/tuners/mt2063.h b/drivers/media/tuners/mt2063.h index e1acfc8e7ae3..e55e0a6dd1be 100644 --- a/drivers/media/tuners/mt2063.h +++ b/drivers/media/tuners/mt2063.h @@ -8,7 +8,7 @@ struct mt2063_config { u32 refclock; }; -#if IS_ENABLED(CONFIG_MEDIA_TUNER_MT2063) +#if IS_REACHABLE(CONFIG_MEDIA_TUNER_MT2063) struct dvb_frontend *mt2063_attach(struct dvb_frontend *fe, struct mt2063_config *config, struct i2c_adapter *i2c); diff --git a/drivers/media/tuners/mt20xx.h b/drivers/media/tuners/mt20xx.h index f56241ccaa00..9912362b415e 100644 --- a/drivers/media/tuners/mt20xx.h +++ b/drivers/media/tuners/mt20xx.h @@ -20,7 +20,7 @@ #include <linux/i2c.h> #include "dvb_frontend.h" -#if IS_ENABLED(CONFIG_MEDIA_TUNER_MT20XX) +#if IS_REACHABLE(CONFIG_MEDIA_TUNER_MT20XX) extern struct dvb_frontend *microtune_attach(struct dvb_frontend *fe, struct i2c_adapter* i2c_adap, u8 i2c_addr); diff --git a/drivers/media/tuners/mt2131.h b/drivers/media/tuners/mt2131.h index 837c854b9c65..8267a6ae5d84 100644 --- a/drivers/media/tuners/mt2131.h +++ b/drivers/media/tuners/mt2131.h @@ -30,7 +30,7 @@ struct mt2131_config { u8 clock_out; /* 0 = off, 1 = CLK/4, 2 = CLK/2, 3 = CLK/1 */ }; -#if IS_ENABLED(CONFIG_MEDIA_TUNER_MT2131) +#if IS_REACHABLE(CONFIG_MEDIA_TUNER_MT2131) extern struct dvb_frontend* mt2131_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2131_config *cfg, diff --git a/drivers/media/tuners/mt2266.h b/drivers/media/tuners/mt2266.h index fad6dd657d77..69abefa18c37 100644 --- a/drivers/media/tuners/mt2266.h +++ b/drivers/media/tuners/mt2266.h @@ -24,7 +24,7 @@ struct mt2266_config { u8 i2c_address; }; -#if IS_ENABLED(CONFIG_MEDIA_TUNER_MT2266) +#if IS_REACHABLE(CONFIG_MEDIA_TUNER_MT2266) extern struct dvb_frontend * mt2266_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2266_config *cfg); #else static inline struct dvb_frontend * mt2266_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2266_config *cfg) diff --git a/drivers/media/tuners/mxl5005s.h b/drivers/media/tuners/mxl5005s.h index ae8db885ad87..5764b12c5c7c 100644 --- a/drivers/media/tuners/mxl5005s.h +++ b/drivers/media/tuners/mxl5005s.h @@ -118,7 +118,7 @@ struct mxl5005s_config { u8 AgcMasterByte; }; -#if IS_ENABLED(CONFIG_MEDIA_TUNER_MXL5005S) +#if IS_REACHABLE(CONFIG_MEDIA_TUNER_MXL5005S) extern struct dvb_frontend *mxl5005s_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mxl5005s_config *config); diff --git a/drivers/media/tuners/mxl5007t.h b/drivers/media/tuners/mxl5007t.h index ae7037d681c5..e786d1f23ff1 100644 --- a/drivers/media/tuners/mxl5007t.h +++ b/drivers/media/tuners/mxl5007t.h @@ -77,7 +77,7 @@ struct mxl5007t_config { unsigned int clk_out_enable:1; }; -#if IS_ENABLED(CONFIG_MEDIA_TUNER_MXL5007T) +#if IS_REACHABLE(CONFIG_MEDIA_TUNER_MXL5007T) extern struct dvb_frontend *mxl5007t_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 addr, struct mxl5007t_config *cfg); diff --git a/drivers/media/tuners/qt1010.h b/drivers/media/tuners/qt1010.h index 8ab5d479749f..e3198f23437c 100644 --- a/drivers/media/tuners/qt1010.h +++ b/drivers/media/tuners/qt1010.h @@ -36,7 +36,7 @@ struct qt1010_config { * @param cfg tuner hw based configuration * @return fe pointer on success, NULL on failure */ -#if IS_ENABLED(CONFIG_MEDIA_TUNER_QT1010) +#if IS_REACHABLE(CONFIG_MEDIA_TUNER_QT1010) extern struct dvb_frontend *qt1010_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct qt1010_config *cfg); diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c index 8e040cf9cf13..71159a58860f 100644 --- a/drivers/media/tuners/r820t.c +++ b/drivers/media/tuners/r820t.c @@ -775,6 +775,19 @@ static int r820t_sysfreq_sel(struct r820t_priv *priv, u32 freq, div_buf_cur = 0x30; /* 11, 150u */ filter_cur = 0x40; /* 10, low */ break; + case SYS_DVBC_ANNEX_A: + mixer_top = 0x24; /* mixer top:13 , top-1, low-discharge */ + lna_top = 0xe5; + lna_vth_l = 0x62; + mixer_vth_l = 0x75; + air_cable1_in = 0x60; + cable2_in = 0x00; + pre_dect = 0x40; + lna_discharge = 14; + cp_cur = 0x38; /* 111, auto */ + div_buf_cur = 0x30; /* 11, 150u */ + filter_cur = 0x40; /* 10, low */ + break; default: /* DVB-T 8M */ mixer_top = 0x24; /* mixer top:13 , top-1, low-discharge */ lna_top = 0xe5; /* detect bw 3, lna top:4, predet top:2 */ @@ -957,7 +970,7 @@ static int r820t_set_tv_standard(struct r820t_priv *priv, ext_enable = 0x40; /* r30[6], ext enable; r30[5]:0 ext at lna max */ loop_through = 0x00; /* r5[7], lt on */ lt_att = 0x00; /* r31[7], lt att enable */ - flt_ext_widest = 0x00; /* r15[7]: flt_ext_wide off */ + flt_ext_widest = 0x80; /* r15[7]: flt_ext_wide on */ polyfil_cur = 0x60; /* r25[6:5]:min */ } else if (delsys == SYS_DVBC_ANNEX_A) { if_khz = 5070; @@ -971,6 +984,18 @@ static int r820t_set_tv_standard(struct r820t_priv *priv, lt_att = 0x00; /* r31[7], lt att enable */ flt_ext_widest = 0x00; /* r15[7]: flt_ext_wide off */ polyfil_cur = 0x60; /* r25[6:5]:min */ + } else if (delsys == SYS_DVBC_ANNEX_C) { + if_khz = 4063; + filt_cal_lo = 55000; + filt_gain = 0x10; /* +3db, 6mhz on */ + img_r = 0x00; /* image negative */ + filt_q = 0x10; /* r10[4]:low q(1'b1) */ + hp_cor = 0x6a; /* 1.7m disable, +0cap, 1.0mhz */ + ext_enable = 0x40; /* r30[6]=1 ext enable; r30[5]:1 ext at lna max-1 */ + loop_through = 0x00; /* r5[7], lt on */ + lt_att = 0x00; /* r31[7], lt att enable */ + flt_ext_widest = 0x80; /* r15[7]: flt_ext_wide on */ + polyfil_cur = 0x60; /* r25[6:5]:min */ } else { if (bw <= 6) { if_khz = 3570; @@ -1186,7 +1211,7 @@ static int r820t_read_gain(struct r820t_priv *priv) if (rc < 0) return rc; - return ((data[3] & 0x0f) << 1) + ((data[3] & 0xf0) >> 4); + return ((data[3] & 0x08) << 1) + ((data[3] & 0xf0) >> 4); } #if 0 diff --git a/drivers/media/tuners/r820t.h b/drivers/media/tuners/r820t.h index 48af3548027d..b1e5661af1c7 100644 --- a/drivers/media/tuners/r820t.h +++ b/drivers/media/tuners/r820t.h @@ -42,7 +42,7 @@ struct r820t_config { bool use_predetect; }; -#if IS_ENABLED(CONFIG_MEDIA_TUNER_R820T) +#if IS_REACHABLE(CONFIG_MEDIA_TUNER_R820T) struct dvb_frontend *r820t_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, const struct r820t_config *cfg); diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c index fcf139dfdec6..d74ae26621ca 100644 --- a/drivers/media/tuners/si2157.c +++ b/drivers/media/tuners/si2157.c @@ -244,6 +244,7 @@ static int si2157_set_params(struct dvb_frontend *fe) int ret; struct si2157_cmd cmd; u8 bandwidth, delivery_system; + u32 if_frequency = 5000000; dev_dbg(&client->dev, "delivery_system=%d frequency=%u bandwidth_hz=%u\n", @@ -266,9 +267,11 @@ static int si2157_set_params(struct dvb_frontend *fe) switch (c->delivery_system) { case SYS_ATSC: delivery_system = 0x00; + if_frequency = 3250000; break; case SYS_DVBC_ANNEX_B: delivery_system = 0x10; + if_frequency = 4000000; break; case SYS_DVBT: case SYS_DVBT2: /* it seems DVB-T and DVB-T2 both are 0x20 here */ @@ -302,6 +305,20 @@ static int si2157_set_params(struct dvb_frontend *fe) if (ret) goto err; + /* set if frequency if needed */ + if (if_frequency != dev->if_frequency) { + memcpy(cmd.args, "\x14\x00\x06\x07", 4); + cmd.args[4] = (if_frequency / 1000) & 0xff; + cmd.args[5] = ((if_frequency / 1000) >> 8) & 0xff; + cmd.wlen = 6; + cmd.rlen = 4; + ret = si2157_cmd_execute(client, &cmd); + if (ret) + goto err; + + dev->if_frequency = if_frequency; + } + /* set frequency */ memcpy(cmd.args, "\x41\x00\x00\x00\x00\x00\x00\x00", 8); cmd.args[4] = (c->frequency >> 0) & 0xff; @@ -322,14 +339,17 @@ err: static int si2157_get_if_frequency(struct dvb_frontend *fe, u32 *frequency) { - *frequency = 5000000; /* default value of property 0x0706 */ + struct i2c_client *client = fe->tuner_priv; + struct si2157_dev *dev = i2c_get_clientdata(client); + + *frequency = dev->if_frequency; return 0; } static const struct dvb_tuner_ops si2157_ops = { .info = { .name = "Silicon Labs Si2146/2147/2148/2157/2158", - .frequency_min = 110000000, + .frequency_min = 55000000, .frequency_max = 862000000, }, @@ -360,6 +380,7 @@ static int si2157_probe(struct i2c_client *client, dev->inversion = cfg->inversion; dev->fw_loaded = false; dev->chiptype = (u8)id->driver_data; + dev->if_frequency = 5000000; /* default value of property 0x0706 */ mutex_init(&dev->i2c_mutex); /* check if the tuner is there */ diff --git a/drivers/media/tuners/si2157_priv.h b/drivers/media/tuners/si2157_priv.h index 7aa53bce5593..cd8fa5b25304 100644 --- a/drivers/media/tuners/si2157_priv.h +++ b/drivers/media/tuners/si2157_priv.h @@ -28,6 +28,7 @@ struct si2157_dev { bool fw_loaded; bool inversion; u8 chiptype; + u32 if_frequency; }; #define SI2157_CHIPTYPE_SI2157 0 diff --git a/drivers/media/tuners/tda18218.h b/drivers/media/tuners/tda18218.h index 366410e0cc9a..1eacb4f84e93 100644 --- a/drivers/media/tuners/tda18218.h +++ b/drivers/media/tuners/tda18218.h @@ -30,7 +30,7 @@ struct tda18218_config { u8 loop_through:1; }; -#if IS_ENABLED(CONFIG_MEDIA_TUNER_TDA18218) +#if IS_REACHABLE(CONFIG_MEDIA_TUNER_TDA18218) extern struct dvb_frontend *tda18218_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct tda18218_config *cfg); #else diff --git a/drivers/media/tuners/tda18271.h b/drivers/media/tuners/tda18271.h index 4c418d63f540..0a846333ce57 100644 --- a/drivers/media/tuners/tda18271.h +++ b/drivers/media/tuners/tda18271.h @@ -121,7 +121,7 @@ enum tda18271_mode { TDA18271_DIGITAL, }; -#if IS_ENABLED(CONFIG_MEDIA_TUNER_TDA18271) +#if IS_REACHABLE(CONFIG_MEDIA_TUNER_TDA18271) extern struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr, struct i2c_adapter *i2c, struct tda18271_config *cfg); diff --git a/drivers/media/tuners/tda827x.h b/drivers/media/tuners/tda827x.h index b64292152baf..abf2e2fe5350 100644 --- a/drivers/media/tuners/tda827x.h +++ b/drivers/media/tuners/tda827x.h @@ -51,7 +51,7 @@ struct tda827x_config * @param cfg optional callback function pointers. * @return FE pointer on success, NULL on failure. */ -#if IS_ENABLED(CONFIG_MEDIA_TUNER_TDA827X) +#if IS_REACHABLE(CONFIG_MEDIA_TUNER_TDA827X) extern struct dvb_frontend* tda827x_attach(struct dvb_frontend *fe, int addr, struct i2c_adapter *i2c, struct tda827x_config *cfg); diff --git a/drivers/media/tuners/tda8290.h b/drivers/media/tuners/tda8290.h index cf96e585785e..901b8cac7105 100644 --- a/drivers/media/tuners/tda8290.h +++ b/drivers/media/tuners/tda8290.h @@ -38,7 +38,7 @@ struct tda829x_config { struct tda18271_std_map *tda18271_std_map; }; -#if IS_ENABLED(CONFIG_MEDIA_TUNER_TDA8290) +#if IS_REACHABLE(CONFIG_MEDIA_TUNER_TDA8290) extern int tda829x_probe(struct i2c_adapter *i2c_adap, u8 i2c_addr); extern struct dvb_frontend *tda829x_attach(struct dvb_frontend *fe, diff --git a/drivers/media/tuners/tda9887.h b/drivers/media/tuners/tda9887.h index 37a4a1123e0c..95070eca02ca 100644 --- a/drivers/media/tuners/tda9887.h +++ b/drivers/media/tuners/tda9887.h @@ -21,7 +21,7 @@ #include "dvb_frontend.h" /* ------------------------------------------------------------------------ */ -#if IS_ENABLED(CONFIG_MEDIA_TUNER_TDA9887) +#if IS_REACHABLE(CONFIG_MEDIA_TUNER_TDA9887) extern struct dvb_frontend *tda9887_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c_adap, u8 i2c_addr); diff --git a/drivers/media/tuners/tea5761.h b/drivers/media/tuners/tea5761.h index 933228ffb509..2d624d9919e3 100644 --- a/drivers/media/tuners/tea5761.h +++ b/drivers/media/tuners/tea5761.h @@ -20,7 +20,7 @@ #include <linux/i2c.h> #include "dvb_frontend.h" -#if IS_ENABLED(CONFIG_MEDIA_TUNER_TEA5761) +#if IS_REACHABLE(CONFIG_MEDIA_TUNER_TEA5761) extern int tea5761_autodetection(struct i2c_adapter* i2c_adap, u8 i2c_addr); extern struct dvb_frontend *tea5761_attach(struct dvb_frontend *fe, diff --git a/drivers/media/tuners/tea5767.h b/drivers/media/tuners/tea5767.h index c39101199383..4f6f6c92db78 100644 --- a/drivers/media/tuners/tea5767.h +++ b/drivers/media/tuners/tea5767.h @@ -39,7 +39,7 @@ struct tea5767_ctrl { enum tea5767_xtal xtal_freq; }; -#if IS_ENABLED(CONFIG_MEDIA_TUNER_TEA5767) +#if IS_REACHABLE(CONFIG_MEDIA_TUNER_TEA5767) extern int tea5767_autodetection(struct i2c_adapter* i2c_adap, u8 i2c_addr); extern struct dvb_frontend *tea5767_attach(struct dvb_frontend *fe, diff --git a/drivers/media/tuners/tua9001.h b/drivers/media/tuners/tua9001.h index 26358da1c100..2c3375c7aeb9 100644 --- a/drivers/media/tuners/tua9001.h +++ b/drivers/media/tuners/tua9001.h @@ -51,7 +51,7 @@ struct tua9001_config { #define TUA9001_CMD_RESETN 1 #define TUA9001_CMD_RXEN 2 -#if IS_ENABLED(CONFIG_MEDIA_TUNER_TUA9001) +#if IS_REACHABLE(CONFIG_MEDIA_TUNER_TUA9001) extern struct dvb_frontend *tua9001_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct tua9001_config *cfg); #else diff --git a/drivers/media/tuners/tuner-simple.h b/drivers/media/tuners/tuner-simple.h index ffd12cfe650b..6399b45b0590 100644 --- a/drivers/media/tuners/tuner-simple.h +++ b/drivers/media/tuners/tuner-simple.h @@ -20,7 +20,7 @@ #include <linux/i2c.h> #include "dvb_frontend.h" -#if IS_ENABLED(CONFIG_MEDIA_TUNER_SIMPLE) +#if IS_REACHABLE(CONFIG_MEDIA_TUNER_SIMPLE) extern struct dvb_frontend *simple_tuner_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c_adap, u8 i2c_addr, diff --git a/drivers/media/tuners/tuner-xc2028.h b/drivers/media/tuners/tuner-xc2028.h index 181d087faec4..98e4effca896 100644 --- a/drivers/media/tuners/tuner-xc2028.h +++ b/drivers/media/tuners/tuner-xc2028.h @@ -56,7 +56,7 @@ struct xc2028_config { #define XC2028_RESET_CLK 1 #define XC2028_I2C_FLUSH 2 -#if IS_ENABLED(CONFIG_MEDIA_TUNER_XC2028) +#if IS_REACHABLE(CONFIG_MEDIA_TUNER_XC2028) extern struct dvb_frontend *xc2028_attach(struct dvb_frontend *fe, struct xc2028_config *cfg); #else diff --git a/drivers/media/tuners/xc4000.h b/drivers/media/tuners/xc4000.h index 97c23de5296c..40517860cf67 100644 --- a/drivers/media/tuners/xc4000.h +++ b/drivers/media/tuners/xc4000.h @@ -50,7 +50,7 @@ struct xc4000_config { * it's passed back to a bridge during tuner_callback(). */ -#if IS_ENABLED(CONFIG_MEDIA_TUNER_XC4000) +#if IS_REACHABLE(CONFIG_MEDIA_TUNER_XC4000) extern struct dvb_frontend *xc4000_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct xc4000_config *cfg); diff --git a/drivers/media/tuners/xc5000.c b/drivers/media/tuners/xc5000.c index 2a039de8ab9a..e6e5e90d8d95 100644 --- a/drivers/media/tuners/xc5000.c +++ b/drivers/media/tuners/xc5000.c @@ -1336,7 +1336,10 @@ static int xc5000_release(struct dvb_frontend *fe) if (priv) { cancel_delayed_work(&priv->timer_sleep); - release_firmware(priv->firmware); + if (priv->firmware) { + release_firmware(priv->firmware); + priv->firmware = NULL; + } hybrid_tuner_release_state(priv); } diff --git a/drivers/media/tuners/xc5000.h b/drivers/media/tuners/xc5000.h index 6aa534f17a30..00ba29e21fb9 100644 --- a/drivers/media/tuners/xc5000.h +++ b/drivers/media/tuners/xc5000.h @@ -58,7 +58,7 @@ struct xc5000_config { * it's passed back to a bridge during tuner_callback(). */ -#if IS_ENABLED(CONFIG_MEDIA_TUNER_XC5000) +#if IS_REACHABLE(CONFIG_MEDIA_TUNER_XC5000) extern struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, const struct xc5000_config *cfg); |