#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/i2c.h>
#include <linux/kernel.h>
#include <linux/math64.h>
#include <linux/max2175.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-device.h>
#include "max2175.h"
#define DRIVER_NAME …
#define mxm_dbg(ctx, fmt, arg...) …
#define mxm_err(ctx, fmt, arg...) …
struct max2175_rxmode { … };
struct max2175_reg_map { … };
static const struct max2175_rxmode eu_rx_modes[] = …;
static const struct max2175_rxmode na_rx_modes[] = …;
static const u8 full_fm_eu_1p0[] = …;
static const u8 full_fm_na_1p0[] = …;
static const struct max2175_reg_map dab12_map[] = …;
static const struct max2175_reg_map fmeu1p2_map[] = …;
static const struct max2175_reg_map fmna1p0_map[] = …;
static const struct max2175_reg_map fmna2p0_map[] = …;
static const u16 ch_coeff_dab1[] = …;
static const u16 ch_coeff_fmeu[] = …;
static const u16 eq_coeff_fmeu1_ra02_m6db[] = …;
static const u16 ch_coeff_fmna[] = …;
static const u16 eq_coeff_fmna1_ra02_m6db[] = …;
static const u8 adc_presets[2][23] = …;
static const struct v4l2_frequency_band eu_bands_rf = …;
static const struct v4l2_frequency_band na_bands_rf = …;
static const struct regmap_range max2175_regmap_volatile_range[] = …;
static const struct regmap_access_table max2175_volatile_regs = …;
static const struct reg_default max2175_reg_defaults[] = …;
static const struct regmap_config max2175_regmap_config = …;
struct max2175 { … };
static inline struct max2175 *max2175_from_sd(struct v4l2_subdev *sd)
{ … }
static inline struct max2175 *max2175_from_ctrl_hdl(struct v4l2_ctrl_handler *h)
{ … }
static inline u8 max2175_get_bitval(u8 val, u8 msb, u8 lsb)
{ … }
static int max2175_read(struct max2175 *ctx, u8 idx, u8 *val)
{ … }
static int max2175_write(struct max2175 *ctx, u8 idx, u8 val)
{ … }
static u8 max2175_read_bits(struct max2175 *ctx, u8 idx, u8 msb, u8 lsb)
{ … }
static int max2175_write_bits(struct max2175 *ctx, u8 idx,
u8 msb, u8 lsb, u8 newval)
{ … }
static int max2175_write_bit(struct max2175 *ctx, u8 idx, u8 bit, u8 newval)
{ … }
static int max2175_poll_timeout(struct max2175 *ctx, u8 idx, u8 msb, u8 lsb,
u8 exp_bitval, u32 timeout_us)
{ … }
static int max2175_poll_csm_ready(struct max2175 *ctx)
{ … }
#define MAX2175_IS_BAND_AM(ctx) …
#define MAX2175_IS_BAND_VHF(ctx) …
#define MAX2175_IS_FM_MODE(ctx) …
#define MAX2175_IS_FMHD_MODE(ctx) …
#define MAX2175_IS_DAB_MODE(ctx) …
static int max2175_band_from_freq(u32 freq)
{ … }
static void max2175_i2s_enable(struct max2175 *ctx, bool enable)
{ … }
static void max2175_set_filter_coeffs(struct max2175 *ctx, u8 m_sel,
u8 bank, const u16 *coeffs)
{ … }
static void max2175_load_fmeu_1p2(struct max2175 *ctx)
{ … }
static void max2175_load_dab_1p2(struct max2175 *ctx)
{ … }
static void max2175_load_fmna_1p0(struct max2175 *ctx)
{ … }
static void max2175_load_fmna_2p0(struct max2175 *ctx)
{ … }
static void max2175_set_bbfilter(struct max2175 *ctx)
{ … }
static int max2175_set_csm_mode(struct max2175 *ctx,
enum max2175_csm_mode new_mode)
{ … }
static int max2175_csm_action(struct max2175 *ctx,
enum max2175_csm_mode action)
{ … }
static int max2175_set_lo_freq(struct max2175 *ctx, u32 lo_freq)
{ … }
static inline s64 max2175_round_closest(s64 dividend, s32 divisor)
{ … }
static int max2175_set_nco_freq(struct max2175 *ctx, s32 nco_freq)
{ … }
static int max2175_set_rf_freq_non_am_bands(struct max2175 *ctx, u64 freq,
u32 lo_pos)
{ … }
static int max2175_set_rf_freq(struct max2175 *ctx, u64 freq, u32 lo_pos)
{ … }
static int max2175_tune_rf_freq(struct max2175 *ctx, u64 freq, u32 hsls)
{ … }
static void max2175_set_hsls(struct max2175 *ctx, u32 lo_pos)
{ … }
static void max2175_set_eu_rx_mode(struct max2175 *ctx, u32 rx_mode)
{ … }
static void max2175_set_na_rx_mode(struct max2175 *ctx, u32 rx_mode)
{ … }
static int max2175_set_rx_mode(struct max2175 *ctx, u32 rx_mode)
{ … }
static int max2175_rx_mode_from_freq(struct max2175 *ctx, u32 freq, u32 *mode)
{ … }
static bool max2175_freq_rx_mode_valid(struct max2175 *ctx,
u32 mode, u32 freq)
{ … }
static void max2175_load_adc_presets(struct max2175 *ctx)
{ … }
static int max2175_init_power_manager(struct max2175 *ctx)
{ … }
static int max2175_recalibrate_adc(struct max2175 *ctx)
{ … }
static u8 max2175_read_rom(struct max2175 *ctx, u8 row)
{ … }
static void max2175_load_from_rom(struct max2175 *ctx)
{ … }
static void max2175_load_full_fm_eu_1p0(struct max2175 *ctx)
{ … }
static void max2175_load_full_fm_na_1p0(struct max2175 *ctx)
{ … }
static int max2175_core_init(struct max2175 *ctx, u32 refout_bits)
{ … }
static void max2175_s_ctrl_rx_mode(struct max2175 *ctx, u32 rx_mode)
{ … }
static int max2175_s_ctrl(struct v4l2_ctrl *ctrl)
{ … }
static u32 max2175_get_lna_gain(struct max2175 *ctx)
{ … }
static int max2175_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
{
struct max2175 *ctx = max2175_from_ctrl_hdl(ctrl->handler);
switch (ctrl->id) {
case V4L2_CID_RF_TUNER_LNA_GAIN:
ctrl->val = max2175_get_lna_gain(ctx);
break;
case V4L2_CID_RF_TUNER_IF_GAIN:
ctrl->val = max2175_read_bits(ctx, 49, 4, 0);
break;
case V4L2_CID_RF_TUNER_PLL_LOCK:
ctrl->val = (max2175_read_bits(ctx, 60, 7, 6) == 3);
break;
}
return 0;
};
static int max2175_set_freq_and_mode(struct max2175 *ctx, u32 freq)
{ … }
static int max2175_s_frequency(struct v4l2_subdev *sd,
const struct v4l2_frequency *vf)
{ … }
static int max2175_g_frequency(struct v4l2_subdev *sd,
struct v4l2_frequency *vf)
{ … }
static int max2175_enum_freq_bands(struct v4l2_subdev *sd,
struct v4l2_frequency_band *band)
{ … }
static int max2175_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
{ … }
static int max2175_s_tuner(struct v4l2_subdev *sd, const struct v4l2_tuner *vt)
{ … }
static const struct v4l2_subdev_tuner_ops max2175_tuner_ops = …;
static const struct v4l2_subdev_ops max2175_ops = …;
static const struct v4l2_ctrl_ops max2175_ctrl_ops = …;
static const struct v4l2_ctrl_config max2175_i2s_en = …;
static const struct v4l2_ctrl_config max2175_hsls = …;
static const char * const max2175_ctrl_eu_rx_modes[] = …;
static const char * const max2175_ctrl_na_rx_modes[] = …;
static const struct v4l2_ctrl_config max2175_eu_rx_mode = …;
static const struct v4l2_ctrl_config max2175_na_rx_mode = …;
static int max2175_refout_load_to_bits(struct i2c_client *client, u32 load,
u32 *bits)
{ … }
static int max2175_probe(struct i2c_client *client)
{ … }
static void max2175_remove(struct i2c_client *client)
{ … }
static const struct i2c_device_id max2175_id[] = …;
MODULE_DEVICE_TABLE(i2c, max2175_id);
static const struct of_device_id max2175_of_ids[] = …;
MODULE_DEVICE_TABLE(of, max2175_of_ids);
static struct i2c_driver max2175_driver = …;
module_i2c_driver(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;
MODULE_AUTHOR(…) …;