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