blob: 38006b34116a0d1678d2c290ddf6f78713bc55cf [file] [log] [blame]
Thomas Gleixner74ba9202019-05-20 09:19:02 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Michael Krufky5bea1cd2007-10-22 09:56:38 -03002/*
3 tda18271.h - header for the Philips / NXP TDA18271 silicon tuner
4
Michael Krufky59067f72008-01-02 01:58:26 -03005 Copyright (C) 2007, 2008 Michael Krufky <mkrufky@linuxtv.org>
Michael Krufky5bea1cd2007-10-22 09:56:38 -03006
Michael Krufky5bea1cd2007-10-22 09:56:38 -03007*/
8
9#ifndef __TDA18271_H__
10#define __TDA18271_H__
11
12#include <linux/i2c.h>
Mauro Carvalho Chehabfada1932017-12-28 13:03:51 -050013#include <media/dvb_frontend.h>
Michael Krufky5bea1cd2007-10-22 09:56:38 -030014
Michael Krufkyf21e0d72008-01-02 03:01:54 -030015struct tda18271_std_map_item {
Michael Krufky2ba65d52008-01-03 01:17:45 -030016 u16 if_freq;
Michael Krufky7f7203d2008-04-22 14:46:06 -030017
18 /* EP3[4:3] */
19 unsigned int agc_mode:2;
20 /* EP3[2:0] */
21 unsigned int std:3;
22 /* EP4[7] */
Michael Krufkyc293d0a2008-04-22 14:46:06 -030023 unsigned int fm_rfn:1;
Michael Krufky14c74b22008-04-22 14:46:21 -030024 /* EP4[4:2] */
25 unsigned int if_lvl:3;
Michael Krufkyc0dc0c12008-04-22 14:46:22 -030026 /* EB22[6:0] */
27 unsigned int rfagc_top:7;
Michael Krufkyf21e0d72008-01-02 03:01:54 -030028};
29
30struct tda18271_std_map {
Michael Krufkyc353f422008-01-08 10:38:10 -030031 struct tda18271_std_map_item fm_radio;
Michael Krufkyf21e0d72008-01-02 03:01:54 -030032 struct tda18271_std_map_item atv_b;
33 struct tda18271_std_map_item atv_dk;
34 struct tda18271_std_map_item atv_gh;
35 struct tda18271_std_map_item atv_i;
36 struct tda18271_std_map_item atv_l;
37 struct tda18271_std_map_item atv_lc;
38 struct tda18271_std_map_item atv_mn;
39 struct tda18271_std_map_item atsc_6;
40 struct tda18271_std_map_item dvbt_6;
41 struct tda18271_std_map_item dvbt_7;
42 struct tda18271_std_map_item dvbt_8;
43 struct tda18271_std_map_item qam_6;
Mauro Carvalho Chehabce0e93a2011-12-21 08:07:52 -030044 struct tda18271_std_map_item qam_7;
Michael Krufkyf21e0d72008-01-02 03:01:54 -030045 struct tda18271_std_map_item qam_8;
46};
47
Michael Krufky868f5cc2008-04-22 14:46:23 -030048enum tda18271_role {
49 TDA18271_MASTER = 0,
50 TDA18271_SLAVE,
51};
52
Michael Krufkye435f952007-12-09 22:23:30 -030053enum tda18271_i2c_gate {
54 TDA18271_GATE_AUTO = 0,
55 TDA18271_GATE_ANALOG,
56 TDA18271_GATE_DIGITAL,
57};
58
Michael Krufky4240b462009-08-29 16:25:37 -030059enum tda18271_output_options {
Mauro Carvalho Chehabdda1bb42019-02-18 14:29:02 -050060 /* slave tuner output & loop through & xtal oscillator always on */
Michael Krufky4240b462009-08-29 16:25:37 -030061 TDA18271_OUTPUT_LT_XT_ON = 0,
Michael Krufky81259f22008-05-11 12:46:52 -030062
Mauro Carvalho Chehabdda1bb42019-02-18 14:29:02 -050063 /* slave tuner output loop through off */
Michael Krufky4240b462009-08-29 16:25:37 -030064 TDA18271_OUTPUT_LT_OFF = 1,
Michael Krufky81259f22008-05-11 12:46:52 -030065
Michael Krufky4240b462009-08-29 16:25:37 -030066 /* xtal oscillator off */
67 TDA18271_OUTPUT_XT_OFF = 2,
Michael Krufky81259f22008-05-11 12:46:52 -030068};
69
Michael Krufky1724c8f2009-10-23 02:47:49 -030070enum tda18271_small_i2c {
71 TDA18271_39_BYTE_CHUNK_INIT = 0,
Mauro Carvalho Chehabe350d442010-09-26 22:58:28 -030072 TDA18271_16_BYTE_CHUNK_INIT = 16,
73 TDA18271_08_BYTE_CHUNK_INIT = 8,
74 TDA18271_03_BYTE_CHUNK_INIT = 3,
Michael Krufky1724c8f2009-10-23 02:47:49 -030075};
76
Michael Krufkyf21e0d72008-01-02 03:01:54 -030077struct tda18271_config {
Michael Krufky0e1fab92008-01-03 01:40:47 -030078 /* override default if freq / std settings (optional) */
Michael Krufkyf21e0d72008-01-02 03:01:54 -030079 struct tda18271_std_map *std_map;
Michael Krufky0e1fab92008-01-03 01:40:47 -030080
Michael Krufky868f5cc2008-04-22 14:46:23 -030081 /* master / slave tuner: master uses main pll, slave uses cal pll */
82 enum tda18271_role role;
83
Michael Krufky0e1fab92008-01-03 01:40:47 -030084 /* use i2c gate provided by analog or digital demod */
Michael Krufkyf21e0d72008-01-02 03:01:54 -030085 enum tda18271_i2c_gate gate;
Michael Krufky55553092008-04-22 14:46:06 -030086
Michael Krufky4240b462009-08-29 16:25:37 -030087 /* output options that can be disabled */
88 enum tda18271_output_options output_opt;
Michael Krufky81259f22008-05-11 12:46:52 -030089
Lucas De Marchi25985ed2011-03-30 22:57:33 -030090 /* some i2c providers can't write all 39 registers at once */
Michael Krufky1724c8f2009-10-23 02:47:49 -030091 enum tda18271_small_i2c small_i2c;
92
Michael Krufky81016b42009-08-27 16:58:06 -030093 /* force rf tracking filter calibration on startup */
94 unsigned int rf_cal_on_startup:1;
95
Michael Krufky6b82e0c2012-10-01 23:50:37 -030096 /* prevent any register access during attach(),
97 * delaying both IR & RF calibration until init()
98 * module option 'cal' overrides this delay */
99 unsigned int delay_cal:1;
100
Michael Krufkyadcc4b32009-03-04 19:42:06 -0300101 /* interface to saa713x / tda829x */
102 unsigned int config;
103};
104
105#define TDA18271_CALLBACK_CMD_AGC_ENABLE 0
106
107enum tda18271_mode {
108 TDA18271_ANALOG = 0,
109 TDA18271_DIGITAL,
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300110};
111
Arnd Bergmann9b174522015-02-18 14:12:42 -0300112#if IS_REACHABLE(CONFIG_MEDIA_TUNER_TDA18271)
Michael Krufky5bea1cd2007-10-22 09:56:38 -0300113extern struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr,
Michael Krufkye435f952007-12-09 22:23:30 -0300114 struct i2c_adapter *i2c,
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300115 struct tda18271_config *cfg);
Michael Krufky5bea1cd2007-10-22 09:56:38 -0300116#else
117static inline struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe,
118 u8 addr,
Michael Krufkye435f952007-12-09 22:23:30 -0300119 struct i2c_adapter *i2c,
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300120 struct tda18271_config *cfg)
Michael Krufky5bea1cd2007-10-22 09:56:38 -0300121{
Harvey Harrison271ddbf2008-04-08 23:20:00 -0300122 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
Michael Krufky5bea1cd2007-10-22 09:56:38 -0300123 return NULL;
124}
125#endif
126
127#endif /* __TDA18271_H__ */