linux/drivers/media/dvb-frontends/m88ds3103.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0-or-later */
   2/*
   3 * Montage Technology M88DS3103/M88RS6000 demodulator driver
   4 *
   5 * Copyright (C) 2013 Antti Palosaari <crope@iki.fi>
   6 */
   7
   8#ifndef M88DS3103_H
   9#define M88DS3103_H
  10
  11#include <linux/dvb/frontend.h>
  12
  13/*
  14 * I2C address
  15 * 0x68,
  16 */
  17
  18/**
  19 * enum m88ds3103_ts_mode - TS connection mode
  20 * @M88DS3103_TS_SERIAL:        TS output pin D0, normal
  21 * @M88DS3103_TS_SERIAL_D7:     TS output pin D7
  22 * @M88DS3103_TS_PARALLEL:      TS Parallel mode
  23 * @M88DS3103_TS_CI:            TS CI Mode
  24 */
  25enum m88ds3103_ts_mode {
  26        M88DS3103_TS_SERIAL,
  27        M88DS3103_TS_SERIAL_D7,
  28        M88DS3103_TS_PARALLEL,
  29        M88DS3103_TS_CI
  30};
  31
  32/**
  33 * enum m88ds3103_clock_out
  34 * @M88DS3103_CLOCK_OUT_DISABLED:       Clock output is disabled
  35 * @M88DS3103_CLOCK_OUT_ENABLED:        Clock output is enabled with crystal
  36 *                                      clock.
  37 * @M88DS3103_CLOCK_OUT_ENABLED_DIV2:   Clock output is enabled with half
  38 *                                      crystal clock.
  39 */
  40enum m88ds3103_clock_out {
  41        M88DS3103_CLOCK_OUT_DISABLED,
  42        M88DS3103_CLOCK_OUT_ENABLED,
  43        M88DS3103_CLOCK_OUT_ENABLED_DIV2
  44};
  45
  46/**
  47 * struct m88ds3103_platform_data - Platform data for the m88ds3103 driver
  48 * @clk: Clock frequency.
  49 * @i2c_wr_max: Max bytes I2C adapter can write at once.
  50 * @ts_mode: TS mode.
  51 * @ts_clk: TS clock (KHz).
  52 * @ts_clk_pol: TS clk polarity. 1-active at falling edge; 0-active at rising
  53 *  edge.
  54 * @spec_inv: Input spectrum inversion.
  55 * @agc: AGC configuration.
  56 * @agc_inv: AGC polarity.
  57 * @clk_out: Clock output.
  58 * @envelope_mode: DiSEqC envelope mode.
  59 * @lnb_hv_pol: LNB H/V pin polarity. 0: pin high set to VOLTAGE_18, pin low to
  60 *  set VOLTAGE_13. 1: pin high set to VOLTAGE_13, pin low to set VOLTAGE_18.
  61 * @lnb_en_pol: LNB enable pin polarity. 0: pin high to disable, pin low to
  62 *  enable. 1: pin high to enable, pin low to disable.
  63 * @get_dvb_frontend: Get DVB frontend.
  64 * @get_i2c_adapter: Get I2C adapter.
  65 */
  66struct m88ds3103_platform_data {
  67        u32 clk;
  68        u16 i2c_wr_max;
  69        enum m88ds3103_ts_mode ts_mode;
  70        u32 ts_clk;
  71        enum m88ds3103_clock_out clk_out;
  72        u8 ts_clk_pol:1;
  73        u8 spec_inv:1;
  74        u8 agc;
  75        u8 agc_inv:1;
  76        u8 envelope_mode:1;
  77        u8 lnb_hv_pol:1;
  78        u8 lnb_en_pol:1;
  79
  80        struct dvb_frontend* (*get_dvb_frontend)(struct i2c_client *);
  81        struct i2c_adapter* (*get_i2c_adapter)(struct i2c_client *);
  82
  83/* private: For legacy media attach wrapper. Do not set value. */
  84        u8 attach_in_use:1;
  85};
  86
  87/**
  88 * struct m88ds3103_config - m88ds3102 configuration
  89 *
  90 * @i2c_addr:   I2C address. Default: none, must set. Example: 0x68, ...
  91 * @clock:      Device's clock. Default: none, must set. Example: 27000000
  92 * @i2c_wr_max: Max bytes I2C provider is asked to write at once.
  93 *              Default: none, must set. Example: 33, 65, ...
  94 * @ts_mode:    TS output mode, as defined by &enum m88ds3103_ts_mode.
  95 *              Default: M88DS3103_TS_SERIAL.
  96 * @ts_clk:     TS clk in KHz. Default: 0.
  97 * @ts_clk_pol: TS clk polarity.Default: 0.
  98 *              1-active at falling edge; 0-active at rising edge.
  99 * @spec_inv:   Spectrum inversion. Default: 0.
 100 * @agc_inv:    AGC polarity. Default: 0.
 101 * @clock_out:  Clock output, as defined by &enum m88ds3103_clock_out.
 102 *              Default: M88DS3103_CLOCK_OUT_DISABLED.
 103 * @envelope_mode: DiSEqC envelope mode. Default: 0.
 104 * @agc:        AGC configuration. Default: none, must set.
 105 * @lnb_hv_pol: LNB H/V pin polarity. Default: 0. Values:
 106 *              1: pin high set to VOLTAGE_13, pin low to set VOLTAGE_18;
 107 *              0: pin high set to VOLTAGE_18, pin low to set VOLTAGE_13.
 108 * @lnb_en_pol: LNB enable pin polarity. Default: 0. Values:
 109 *              1: pin high to enable, pin low to disable;
 110 *              0: pin high to disable, pin low to enable.
 111 */
 112struct m88ds3103_config {
 113        u8 i2c_addr;
 114        u32 clock;
 115        u16 i2c_wr_max;
 116        u8 ts_mode;
 117        u32 ts_clk;
 118        u8 ts_clk_pol:1;
 119        u8 spec_inv:1;
 120        u8 agc_inv:1;
 121        u8 clock_out;
 122        u8 envelope_mode:1;
 123        u8 agc;
 124        u8 lnb_hv_pol:1;
 125        u8 lnb_en_pol:1;
 126};
 127
 128#if defined(CONFIG_DVB_M88DS3103) || \
 129                (defined(CONFIG_DVB_M88DS3103_MODULE) && defined(MODULE))
 130/**
 131 * Attach a m88ds3103 demod
 132 *
 133 * @config: pointer to &struct m88ds3103_config with demod configuration.
 134 * @i2c: i2c adapter to use.
 135 * @tuner_i2c: on success, returns the I2C adapter associated with
 136 *              m88ds3103 tuner.
 137 *
 138 * return: FE pointer on success, NULL on failure.
 139 * Note: Do not add new m88ds3103_attach() users! Use I2C bindings instead.
 140 */
 141extern struct dvb_frontend *m88ds3103_attach(
 142                const struct m88ds3103_config *config,
 143                struct i2c_adapter *i2c,
 144                struct i2c_adapter **tuner_i2c);
 145extern int m88ds3103_get_agc_pwm(struct dvb_frontend *fe, u8 *_agc_pwm);
 146#else
 147static inline struct dvb_frontend *m88ds3103_attach(
 148                const struct m88ds3103_config *config,
 149                struct i2c_adapter *i2c,
 150                struct i2c_adapter **tuner_i2c)
 151{
 152        pr_warn("%s: driver disabled by Kconfig\n", __func__);
 153        return NULL;
 154}
 155#define m88ds3103_get_agc_pwm NULL
 156#endif
 157
 158#endif
 159