Thomas Gleixner | 74ba920 | 2019-05-20 09:19:02 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 2 | /* |
| 3 | tda18271.h - header for the Philips / NXP TDA18271 silicon tuner |
| 4 | |
Michael Krufky | 59067f7 | 2008-01-02 01:58:26 -0300 | [diff] [blame] | 5 | Copyright (C) 2007, 2008 Michael Krufky <mkrufky@linuxtv.org> |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 6 | |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #ifndef __TDA18271_H__ |
| 10 | #define __TDA18271_H__ |
| 11 | |
| 12 | #include <linux/i2c.h> |
Mauro Carvalho Chehab | fada193 | 2017-12-28 13:03:51 -0500 | [diff] [blame] | 13 | #include <media/dvb_frontend.h> |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 14 | |
Michael Krufky | f21e0d7 | 2008-01-02 03:01:54 -0300 | [diff] [blame] | 15 | struct tda18271_std_map_item { |
Michael Krufky | 2ba65d5 | 2008-01-03 01:17:45 -0300 | [diff] [blame] | 16 | u16 if_freq; |
Michael Krufky | 7f7203d | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 17 | |
| 18 | /* EP3[4:3] */ |
| 19 | unsigned int agc_mode:2; |
| 20 | /* EP3[2:0] */ |
| 21 | unsigned int std:3; |
| 22 | /* EP4[7] */ |
Michael Krufky | c293d0a | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 23 | unsigned int fm_rfn:1; |
Michael Krufky | 14c74b2 | 2008-04-22 14:46:21 -0300 | [diff] [blame] | 24 | /* EP4[4:2] */ |
| 25 | unsigned int if_lvl:3; |
Michael Krufky | c0dc0c1 | 2008-04-22 14:46:22 -0300 | [diff] [blame] | 26 | /* EB22[6:0] */ |
| 27 | unsigned int rfagc_top:7; |
Michael Krufky | f21e0d7 | 2008-01-02 03:01:54 -0300 | [diff] [blame] | 28 | }; |
| 29 | |
| 30 | struct tda18271_std_map { |
Michael Krufky | c353f42 | 2008-01-08 10:38:10 -0300 | [diff] [blame] | 31 | struct tda18271_std_map_item fm_radio; |
Michael Krufky | f21e0d7 | 2008-01-02 03:01:54 -0300 | [diff] [blame] | 32 | 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 Chehab | ce0e93a | 2011-12-21 08:07:52 -0300 | [diff] [blame] | 44 | struct tda18271_std_map_item qam_7; |
Michael Krufky | f21e0d7 | 2008-01-02 03:01:54 -0300 | [diff] [blame] | 45 | struct tda18271_std_map_item qam_8; |
| 46 | }; |
| 47 | |
Michael Krufky | 868f5cc | 2008-04-22 14:46:23 -0300 | [diff] [blame] | 48 | enum tda18271_role { |
| 49 | TDA18271_MASTER = 0, |
| 50 | TDA18271_SLAVE, |
| 51 | }; |
| 52 | |
Michael Krufky | e435f95 | 2007-12-09 22:23:30 -0300 | [diff] [blame] | 53 | enum tda18271_i2c_gate { |
| 54 | TDA18271_GATE_AUTO = 0, |
| 55 | TDA18271_GATE_ANALOG, |
| 56 | TDA18271_GATE_DIGITAL, |
| 57 | }; |
| 58 | |
Michael Krufky | 4240b46 | 2009-08-29 16:25:37 -0300 | [diff] [blame] | 59 | enum tda18271_output_options { |
Mauro Carvalho Chehab | dda1bb4 | 2019-02-18 14:29:02 -0500 | [diff] [blame] | 60 | /* slave tuner output & loop through & xtal oscillator always on */ |
Michael Krufky | 4240b46 | 2009-08-29 16:25:37 -0300 | [diff] [blame] | 61 | TDA18271_OUTPUT_LT_XT_ON = 0, |
Michael Krufky | 81259f2 | 2008-05-11 12:46:52 -0300 | [diff] [blame] | 62 | |
Mauro Carvalho Chehab | dda1bb4 | 2019-02-18 14:29:02 -0500 | [diff] [blame] | 63 | /* slave tuner output loop through off */ |
Michael Krufky | 4240b46 | 2009-08-29 16:25:37 -0300 | [diff] [blame] | 64 | TDA18271_OUTPUT_LT_OFF = 1, |
Michael Krufky | 81259f2 | 2008-05-11 12:46:52 -0300 | [diff] [blame] | 65 | |
Michael Krufky | 4240b46 | 2009-08-29 16:25:37 -0300 | [diff] [blame] | 66 | /* xtal oscillator off */ |
| 67 | TDA18271_OUTPUT_XT_OFF = 2, |
Michael Krufky | 81259f2 | 2008-05-11 12:46:52 -0300 | [diff] [blame] | 68 | }; |
| 69 | |
Michael Krufky | 1724c8f | 2009-10-23 02:47:49 -0300 | [diff] [blame] | 70 | enum tda18271_small_i2c { |
| 71 | TDA18271_39_BYTE_CHUNK_INIT = 0, |
Mauro Carvalho Chehab | e350d44 | 2010-09-26 22:58:28 -0300 | [diff] [blame] | 72 | TDA18271_16_BYTE_CHUNK_INIT = 16, |
| 73 | TDA18271_08_BYTE_CHUNK_INIT = 8, |
| 74 | TDA18271_03_BYTE_CHUNK_INIT = 3, |
Michael Krufky | 1724c8f | 2009-10-23 02:47:49 -0300 | [diff] [blame] | 75 | }; |
| 76 | |
Michael Krufky | f21e0d7 | 2008-01-02 03:01:54 -0300 | [diff] [blame] | 77 | struct tda18271_config { |
Michael Krufky | 0e1fab9 | 2008-01-03 01:40:47 -0300 | [diff] [blame] | 78 | /* override default if freq / std settings (optional) */ |
Michael Krufky | f21e0d7 | 2008-01-02 03:01:54 -0300 | [diff] [blame] | 79 | struct tda18271_std_map *std_map; |
Michael Krufky | 0e1fab9 | 2008-01-03 01:40:47 -0300 | [diff] [blame] | 80 | |
Michael Krufky | 868f5cc | 2008-04-22 14:46:23 -0300 | [diff] [blame] | 81 | /* master / slave tuner: master uses main pll, slave uses cal pll */ |
| 82 | enum tda18271_role role; |
| 83 | |
Michael Krufky | 0e1fab9 | 2008-01-03 01:40:47 -0300 | [diff] [blame] | 84 | /* use i2c gate provided by analog or digital demod */ |
Michael Krufky | f21e0d7 | 2008-01-02 03:01:54 -0300 | [diff] [blame] | 85 | enum tda18271_i2c_gate gate; |
Michael Krufky | 5555309 | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 86 | |
Michael Krufky | 4240b46 | 2009-08-29 16:25:37 -0300 | [diff] [blame] | 87 | /* output options that can be disabled */ |
| 88 | enum tda18271_output_options output_opt; |
Michael Krufky | 81259f2 | 2008-05-11 12:46:52 -0300 | [diff] [blame] | 89 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 90 | /* some i2c providers can't write all 39 registers at once */ |
Michael Krufky | 1724c8f | 2009-10-23 02:47:49 -0300 | [diff] [blame] | 91 | enum tda18271_small_i2c small_i2c; |
| 92 | |
Michael Krufky | 81016b4 | 2009-08-27 16:58:06 -0300 | [diff] [blame] | 93 | /* force rf tracking filter calibration on startup */ |
| 94 | unsigned int rf_cal_on_startup:1; |
| 95 | |
Michael Krufky | 6b82e0c | 2012-10-01 23:50:37 -0300 | [diff] [blame] | 96 | /* 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 Krufky | adcc4b3 | 2009-03-04 19:42:06 -0300 | [diff] [blame] | 101 | /* interface to saa713x / tda829x */ |
| 102 | unsigned int config; |
| 103 | }; |
| 104 | |
| 105 | #define TDA18271_CALLBACK_CMD_AGC_ENABLE 0 |
| 106 | |
| 107 | enum tda18271_mode { |
| 108 | TDA18271_ANALOG = 0, |
| 109 | TDA18271_DIGITAL, |
Michael Krufky | f21e0d7 | 2008-01-02 03:01:54 -0300 | [diff] [blame] | 110 | }; |
| 111 | |
Arnd Bergmann | 9b17452 | 2015-02-18 14:12:42 -0300 | [diff] [blame] | 112 | #if IS_REACHABLE(CONFIG_MEDIA_TUNER_TDA18271) |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 113 | extern struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr, |
Michael Krufky | e435f95 | 2007-12-09 22:23:30 -0300 | [diff] [blame] | 114 | struct i2c_adapter *i2c, |
Michael Krufky | f21e0d7 | 2008-01-02 03:01:54 -0300 | [diff] [blame] | 115 | struct tda18271_config *cfg); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 116 | #else |
| 117 | static inline struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, |
| 118 | u8 addr, |
Michael Krufky | e435f95 | 2007-12-09 22:23:30 -0300 | [diff] [blame] | 119 | struct i2c_adapter *i2c, |
Michael Krufky | f21e0d7 | 2008-01-02 03:01:54 -0300 | [diff] [blame] | 120 | struct tda18271_config *cfg) |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 121 | { |
Harvey Harrison | 271ddbf | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 122 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 123 | return NULL; |
| 124 | } |
| 125 | #endif |
| 126 | |
| 127 | #endif /* __TDA18271_H__ */ |