c38245ee15ed9b90ab5189cd12e9b66946c31491
[cascardo/linux.git] / drivers / media / dvb-frontends / drx39xyj / drxj.h
1
2 /*
3   Copyright (c), 2004-2005,2007-2010 Trident Microsystems, Inc.
4   All rights reserved.
5
6   Redistribution and use in source and binary forms, with or without
7   modification, are permitted provided that the following conditions are met:
8
9   * Redistributions of source code must retain the above copyright notice,
10     this list of conditions and the following disclaimer.
11   * Redistributions in binary form must reproduce the above copyright notice,
12     this list of conditions and the following disclaimer in the documentation
13         and/or other materials provided with the distribution.
14   * Neither the name of Trident Microsystems nor Hauppauge Computer Works
15     nor the names of its contributors may be used to endorse or promote
16         products derived from this software without specific prior written
17         permission.
18
19   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29   POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 /**
33 * \file $Id: drxj.h,v 1.132 2009/12/22 12:13:48 danielg Exp $
34 *
35 * \brief DRXJ specific header file
36 *
37 * \author Dragan Savic, Milos Nikolic, Mihajlo Katona, Tao Ding, Paul Janssen
38 */
39
40 #ifndef __DRXJ_H__
41 #define __DRXJ_H__
42 /*-------------------------------------------------------------------------
43 INCLUDES
44 -------------------------------------------------------------------------*/
45
46 #include "drx_driver.h"
47 #include "drx_dap_fasi.h"
48
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52
53 /* Check DRX-J specific dap condition */
54 /* Multi master mode and short addr format only will not work.
55    RMW, CRC reset, broadcast and switching back to single master mode
56    cannot be done with short addr only in multi master mode. */
57 #if ((DRXDAP_SINGLE_MASTER == 0) && (DRXDAPFASI_LONG_ADDR_ALLOWED == 0))
58 #error "Multi master mode and short addressing only is an illegal combination"
59         *;                      /* Generate a fatal compiler error to make sure it stops here,
60                                    this is necesarry because not all compilers stop after a #error. */
61 #endif
62
63 /*-------------------------------------------------------------------------
64 TYPEDEFS
65 -------------------------------------------------------------------------*/
66 /*============================================================================*/
67 /*============================================================================*/
68 /*== code support ============================================================*/
69 /*============================================================================*/
70 /*============================================================================*/
71
72 /*============================================================================*/
73 /*============================================================================*/
74 /*== SCU cmd if  =============================================================*/
75 /*============================================================================*/
76 /*============================================================================*/
77
78         struct drxjscu_cmd {
79                 u16 command;
80                         /**< Command number */
81                 u16 parameter_len;
82                         /**< Data length in byte */
83                 u16 result_len;
84                         /**< result length in byte */
85                 u16 *parameter;
86                         /**< General purpous param */
87                 u16 *result;
88                         /**< General purpous param */};
89
90 /*============================================================================*/
91 /*============================================================================*/
92 /*== CTRL CFG related data structures ========================================*/
93 /*============================================================================*/
94 /*============================================================================*/
95
96 /* extra intermediate lock state for VSB,QAM,NTSC */
97 #define DRXJ_DEMOD_LOCK       (DRX_LOCK_STATE_1)
98
99 /* OOB lock states */
100 #define DRXJ_OOB_AGC_LOCK     (DRX_LOCK_STATE_1)        /* analog gain control lock */
101 #define DRXJ_OOB_SYNC_LOCK    (DRX_LOCK_STATE_2)        /* digital gain control lock */
102
103 /* Intermediate powermodes for DRXJ */
104 #define DRXJ_POWER_DOWN_MAIN_PATH   DRX_POWER_MODE_8
105 #define DRXJ_POWER_DOWN_CORE        DRX_POWER_MODE_9
106 #define DRXJ_POWER_DOWN_PLL         DRX_POWER_MODE_10
107
108 /* supstition for GPIO FNC mux */
109 #define APP_O                 (0x0000)
110
111 /*#define DRX_CTRL_BASE         (0x0000)*/
112
113 #define DRXJ_CTRL_CFG_BASE    (0x1000)
114         enum drxj_cfg_type {
115                 DRXJ_CFG_AGC_RF = DRXJ_CTRL_CFG_BASE,
116                 DRXJ_CFG_AGC_IF,
117                 DRXJ_CFG_AGC_INTERNAL,
118                 DRXJ_CFG_PRE_SAW,
119                 DRXJ_CFG_AFE_GAIN,
120                 DRXJ_CFG_SYMBOL_CLK_OFFSET,
121                 DRXJ_CFG_ACCUM_CR_RS_CW_ERR,
122                 DRXJ_CFG_FEC_MERS_SEQ_COUNT,
123                 DRXJ_CFG_OOB_MISC,
124                 DRXJ_CFG_SMART_ANT,
125                 DRXJ_CFG_OOB_PRE_SAW,
126                 DRXJ_CFG_VSB_MISC,
127                 DRXJ_CFG_RESET_PACKET_ERR,
128
129                 /* ATV (FM) */
130                 DRXJ_CFG_ATV_OUTPUT,    /* also for FM (SIF control) but not likely */
131                 DRXJ_CFG_ATV_MISC,
132                 DRXJ_CFG_ATV_EQU_COEF,
133                 DRXJ_CFG_ATV_AGC_STATUS,        /* also for FM ( IF,RF, audioAGC ) */
134
135                 DRXJ_CFG_MPEG_OUTPUT_MISC,
136                 DRXJ_CFG_HW_CFG,
137                 DRXJ_CFG_OOB_LO_POW,
138
139                 DRXJ_CFG_MAX    /* dummy, never to be used */};
140
141 /**
142 * /struct enum drxj_cfg_smart_ant_io * smart antenna i/o.
143 */
144 enum drxj_cfg_smart_ant_io {
145         DRXJ_SMT_ANT_OUTPUT = 0,
146         DRXJ_SMT_ANT_INPUT
147 };
148
149 /**
150 * /struct struct drxj_cfg_smart_ant * Set smart antenna.
151 */
152         struct drxj_cfg_smart_ant {
153                 enum drxj_cfg_smart_ant_io io;
154                 u16 ctrl_data;
155         };
156
157 /**
158 * /struct DRXJAGCSTATUS_t
159 * AGC status information from the DRXJ-IQM-AF.
160 */
161 struct drxj_agc_status {
162         u16 IFAGC;
163         u16 RFAGC;
164         u16 digital_agc;
165 };
166
167 /* DRXJ_CFG_AGC_RF, DRXJ_CFG_AGC_IF */
168
169 /**
170 * /struct enum drxj_agc_ctrl_mode * Available AGCs modes in the DRXJ.
171 */
172         enum drxj_agc_ctrl_mode {
173                 DRX_AGC_CTRL_AUTO = 0,
174                 DRX_AGC_CTRL_USER,
175                 DRX_AGC_CTRL_OFF};
176
177 /**
178 * /struct struct drxj_cfg_agc * Generic interface for all AGCs present on the DRXJ.
179 */
180         struct drxj_cfg_agc {
181                 enum drx_standard standard;     /* standard for which these settings apply */
182                 enum drxj_agc_ctrl_mode ctrl_mode;      /* off, user, auto          */
183                 u16 output_level;       /* range dependent on AGC   */
184                 u16 min_output_level;   /* range dependent on AGC   */
185                 u16 max_output_level;   /* range dependent on AGC   */
186                 u16 speed;      /* range dependent on AGC   */
187                 u16 top;        /* rf-agc take over point   */
188                 u16 cut_off_current;    /* rf-agc is accelerated if output current
189                                            is below cut-off current                */};
190
191 /* DRXJ_CFG_PRE_SAW */
192
193 /**
194 * /struct struct drxj_cfg_pre_saw * Interface to configure pre SAW sense.
195 */
196         struct drxj_cfg_pre_saw {
197                 enum drx_standard standard;     /* standard to which these settings apply */
198                 u16 reference;  /* pre SAW reference value, range 0 .. 31 */
199                 bool use_pre_saw;       /* true algorithms must use pre SAW sense */};
200
201 /* DRXJ_CFG_AFE_GAIN */
202
203 /**
204 * /struct struct drxj_cfg_afe_gain * Interface to configure gain of AFE (LNA + PGA).
205 */
206         struct drxj_cfg_afe_gain {
207                 enum drx_standard standard;     /* standard to which these settings apply */
208                 u16 gain;       /* gain in 0.1 dB steps, DRXJ range 140 .. 335 */};
209
210 /**
211 * /struct drxjrs_errors
212 * Available failure information in DRXJ_FEC_RS.
213 *
214 * Container for errors that are received in the most recently finished measurment period
215 *
216 */
217         struct drxjrs_errors {
218                 u16 nr_bit_errors;
219                                 /**< no of pre RS bit errors          */
220                 u16 nr_symbol_errors;
221                                 /**< no of pre RS symbol errors       */
222                 u16 nr_packet_errors;
223                                 /**< no of pre RS packet errors       */
224                 u16 nr_failures;
225                                 /**< no of post RS failures to decode */
226                 u16 nr_snc_par_fail_count;
227                                 /**< no of post RS bit erros          */
228         };
229
230 /**
231 * /struct struct drxj_cfg_vsb_misc * symbol error rate
232 */
233         struct drxj_cfg_vsb_misc {
234                 u32 symb_error;
235                               /**< symbol error rate sps */};
236
237 /**
238 * /enum enum drxj_mpeg_output_clock_rate * Mpeg output clock rate.
239 *
240 */
241         enum drxj_mpeg_start_width {
242                 DRXJ_MPEG_START_WIDTH_1CLKCYC,
243                 DRXJ_MPEG_START_WIDTH_8CLKCYC};
244
245 /**
246 * /enum enum drxj_mpeg_output_clock_rate * Mpeg output clock rate.
247 *
248 */
249         enum drxj_mpeg_output_clock_rate {
250                 DRXJ_MPEGOUTPUT_CLOCK_RATE_AUTO,
251                 DRXJ_MPEGOUTPUT_CLOCK_RATE_75973K,
252                 DRXJ_MPEGOUTPUT_CLOCK_RATE_50625K,
253                 DRXJ_MPEGOUTPUT_CLOCK_RATE_37968K,
254                 DRXJ_MPEGOUTPUT_CLOCK_RATE_30375K,
255                 DRXJ_MPEGOUTPUT_CLOCK_RATE_25313K,
256                 DRXJ_MPEGOUTPUT_CLOCK_RATE_21696K};
257
258 /**
259 * /struct DRXJCfgMisc_t
260 * Change TEI bit of MPEG output
261 * reverse MPEG output bit order
262 * set MPEG output clock rate
263 */
264         struct drxj_cfg_mpeg_output_misc {
265                 bool disable_tei_handling;            /**< if true pass (not change) TEI bit */
266                 bool bit_reverse_mpeg_outout;         /**< if true, parallel: msb on MD0; serial: lsb out first */
267                 enum drxj_mpeg_output_clock_rate mpeg_output_clock_rate;
268                                                       /**< set MPEG output clock rate that overwirtes the derived one from symbol rate */
269                 enum drxj_mpeg_start_width mpeg_start_width;  /**< set MPEG output start width */};
270
271 /**
272 * /enum enum drxj_xtal_freq * Supported external crystal reference frequency.
273 */
274         enum drxj_xtal_freq {
275                 DRXJ_XTAL_FREQ_RSVD,
276                 DRXJ_XTAL_FREQ_27MHZ,
277                 DRXJ_XTAL_FREQ_20P25MHZ,
278                 DRXJ_XTAL_FREQ_4MHZ};
279
280 /**
281 * /enum enum drxj_xtal_freq * Supported external crystal reference frequency.
282 */
283         enum drxji2c_speed {
284                 DRXJ_I2C_SPEED_400KBPS,
285                 DRXJ_I2C_SPEED_100KBPS};
286
287 /**
288 * /struct struct drxj_cfg_hw_cfg * Get hw configuration, such as crystal reference frequency, I2C speed, etc...
289 */
290         struct drxj_cfg_hw_cfg {
291                 enum drxj_xtal_freq xtal_freq;
292                                    /**< crystal reference frequency */
293                 enum drxji2c_speed i2c_speed;
294                                    /**< 100 or 400 kbps */};
295
296 /*
297  *  DRXJ_CFG_ATV_MISC
298  */
299         struct drxj_cfg_atv_misc {
300                 s16 peak_filter;        /* -8 .. 15 */
301                 u16 noise_filter;       /* 0 .. 15 */};
302
303 /*
304  *  struct drxj_cfg_oob_misc */
305 #define   DRXJ_OOB_STATE_RESET                                        0x0
306 #define   DRXJ_OOB_STATE_AGN_HUNT                                     0x1
307 #define   DRXJ_OOB_STATE_DGN_HUNT                                     0x2
308 #define   DRXJ_OOB_STATE_AGC_HUNT                                     0x3
309 #define   DRXJ_OOB_STATE_FRQ_HUNT                                     0x4
310 #define   DRXJ_OOB_STATE_PHA_HUNT                                     0x8
311 #define   DRXJ_OOB_STATE_TIM_HUNT                                     0x10
312 #define   DRXJ_OOB_STATE_EQU_HUNT                                     0x20
313 #define   DRXJ_OOB_STATE_EQT_HUNT                                     0x30
314 #define   DRXJ_OOB_STATE_SYNC                                         0x40
315
316 struct drxj_cfg_oob_misc {
317         struct drxj_agc_status agc;
318         bool eq_lock;
319         bool sym_timing_lock;
320         bool phase_lock;
321         bool freq_lock;
322         bool dig_gain_lock;
323         bool ana_gain_lock;
324         u8 state;
325  };
326
327 /*
328  *  Index of in array of coef
329  */
330         enum drxj_cfg_oob_lo_power {
331                 DRXJ_OOB_LO_POW_MINUS0DB = 0,
332                 DRXJ_OOB_LO_POW_MINUS5DB,
333                 DRXJ_OOB_LO_POW_MINUS10DB,
334                 DRXJ_OOB_LO_POW_MINUS15DB,
335                 DRXJ_OOB_LO_POW_MAX};
336
337 /*
338  *  DRXJ_CFG_ATV_EQU_COEF
339  */
340         struct drxj_cfg_atv_equ_coef {
341                 s16 coef0;      /* -256 .. 255 */
342                 s16 coef1;      /* -256 .. 255 */
343                 s16 coef2;      /* -256 .. 255 */
344                 s16 coef3;      /* -256 .. 255 */};
345
346 /*
347  *  Index of in array of coef
348  */
349         enum drxj_coef_array_index {
350                 DRXJ_COEF_IDX_MN = 0,
351                 DRXJ_COEF_IDX_FM,
352                 DRXJ_COEF_IDX_L,
353                 DRXJ_COEF_IDX_LP,
354                 DRXJ_COEF_IDX_BG,
355                 DRXJ_COEF_IDX_DK,
356                 DRXJ_COEF_IDX_I,
357                 DRXJ_COEF_IDX_MAX};
358
359 /*
360  *  DRXJ_CFG_ATV_OUTPUT
361  */
362
363 /**
364 * /enum DRXJAttenuation_t
365 * Attenuation setting for SIF AGC.
366 *
367 */
368         enum drxjsif_attenuation {
369                 DRXJ_SIF_ATTENUATION_0DB,
370                 DRXJ_SIF_ATTENUATION_3DB,
371                 DRXJ_SIF_ATTENUATION_6DB,
372                 DRXJ_SIF_ATTENUATION_9DB};
373
374 /**
375 * /struct struct drxj_cfg_atv_output * SIF attenuation setting.
376 *
377 */
378 struct drxj_cfg_atv_output {
379         bool enable_cvbs_output;        /* true= enabled */
380         bool enable_sif_output; /* true= enabled */
381         enum drxjsif_attenuation sif_attenuation;
382 };
383
384 /*
385    DRXJ_CFG_ATV_AGC_STATUS (get only)
386 */
387 /* TODO : AFE interface not yet finished, subject to change */
388         struct drxj_cfg_atv_agc_status {
389                 u16 rf_agc_gain;        /* 0 .. 877 uA */
390                 u16 if_agc_gain;        /* 0 .. 877  uA */
391                 s16 video_agc_gain;     /* -75 .. 1972 in 0.1 dB steps */
392                 s16 audio_agc_gain;     /* -4 .. 1020 in 0.1 dB steps */
393                 u16 rf_agc_loop_gain;   /* 0 .. 7 */
394                 u16 if_agc_loop_gain;   /* 0 .. 7 */
395                 u16 video_agc_loop_gain;        /* 0 .. 7 */};
396
397 /*============================================================================*/
398 /*============================================================================*/
399 /*== CTRL related data structures ============================================*/
400 /*============================================================================*/
401 /*============================================================================*/
402
403 /* NONE */
404
405 /*============================================================================*/
406 /*============================================================================*/
407
408 /*========================================*/
409 /**
410 * /struct struct drxj_data * DRXJ specific attributes.
411 *
412 * Global data container for DRXJ specific data.
413 *
414 */
415         struct drxj_data {
416                 /* device capabilties (determined during drx_open()) */
417                 bool has_lna;             /**< true if LNA (aka PGA) present */
418                 bool has_oob;             /**< true if OOB supported */
419                 bool has_ntsc;            /**< true if NTSC supported */
420                 bool has_btsc;            /**< true if BTSC supported */
421                 bool has_smatx;   /**< true if mat_tx is available */
422                 bool has_smarx;   /**< true if mat_rx is available */
423                 bool has_gpio;            /**< true if GPIO is available */
424                 bool has_irqn;            /**< true if IRQN is available */
425                 /* A1/A2/A... */
426                 u8 mfx;           /**< metal fix */
427
428                 /* tuner settings */
429                 bool mirror_freq_spect_oob;/**< tuner inversion (true = tuner mirrors the signal */
430
431                 /* standard/channel settings */
432                 enum drx_standard standard;       /**< current standard information                     */
433                 enum drx_modulation constellation;
434                                           /**< current constellation                            */
435                 s32 frequency; /**< center signal frequency in KHz                   */
436                 enum drx_bandwidth curr_bandwidth;
437                                           /**< current channel bandwidth                        */
438                 enum drx_mirror mirror;   /**< current channel mirror                           */
439
440                 /* signal quality information */
441                 u32 fec_bits_desired;     /**< BER accounting period                            */
442                 u16 fec_vd_plen;          /**< no of trellis symbols: VD SER measurement period */
443                 u16 qam_vd_prescale;      /**< Viterbi Measurement Prescale                     */
444                 u16 qam_vd_period;        /**< Viterbi Measurement period                       */
445                 u16 fec_rs_plen;          /**< defines RS BER measurement period                */
446                 u16 fec_rs_prescale;      /**< ReedSolomon Measurement Prescale                 */
447                 u16 fec_rs_period;        /**< ReedSolomon Measurement period                   */
448                 bool reset_pkt_err_acc;   /**< Set a flag to reset accumulated packet error     */
449                 u16 pkt_err_acc_start;    /**< Set a flag to reset accumulated packet error     */
450
451                 /* HI configuration */
452                 u16 hi_cfg_timing_div;    /**< HI Configure() parameter 2                       */
453                 u16 hi_cfg_bridge_delay;          /**< HI Configure() parameter 3                       */
454                 u16 hi_cfg_wake_up_key;   /**< HI Configure() parameter 4                       */
455                 u16 hi_cfg_ctrl;          /**< HI Configure() parameter 5                       */
456                 u16 hi_cfg_transmit;      /**< HI Configure() parameter 6                       */
457
458                 /* UIO configuartion */
459                 enum drxuio_mode uio_sma_rx_mode;/**< current mode of SmaRx pin                        */
460                 enum drxuio_mode uio_sma_tx_mode;/**< current mode of SmaTx pin                        */
461                 enum drxuio_mode uio_gpio_mode; /**< current mode of ASEL pin                         */
462                 enum drxuio_mode uio_irqn_mode; /**< current mode of IRQN pin                         */
463
464                 /* IQM fs frequecy shift and inversion */
465                 u32 iqm_fs_rate_ofs;       /**< frequency shifter setting after setchannel      */
466                 bool pos_image;    /**< Ture: positive image                            */
467                 /* IQM RC frequecy shift */
468                 u32 iqm_rc_rate_ofs;       /**< frequency shifter setting after setchannel      */
469
470                 /* ATV configuartion */
471                 u32 atv_cfg_changed_flags; /**< flag: flags cfg changes */
472                 s16 atv_top_equ0[DRXJ_COEF_IDX_MAX];         /**< shadow of ATV_TOP_EQU0__A */
473                 s16 atv_top_equ1[DRXJ_COEF_IDX_MAX];         /**< shadow of ATV_TOP_EQU1__A */
474                 s16 atv_top_equ2[DRXJ_COEF_IDX_MAX];         /**< shadow of ATV_TOP_EQU2__A */
475                 s16 atv_top_equ3[DRXJ_COEF_IDX_MAX];         /**< shadow of ATV_TOP_EQU3__A */
476                 bool phase_correction_bypass;/**< flag: true=bypass */
477                 s16 atv_top_vid_peak;     /**< shadow of ATV_TOP_VID_PEAK__A */
478                 u16 atv_top_noise_th;     /**< shadow of ATV_TOP_NOISE_TH__A */
479                 bool enable_cvbs_output;  /**< flag CVBS ouput enable */
480                 bool enable_sif_output;   /**< flag SIF ouput enable */
481                  enum drxjsif_attenuation sif_attenuation;
482                                           /**< current SIF att setting */
483                 /* Agc configuration for QAM and VSB */
484                 struct drxj_cfg_agc qam_rf_agc_cfg; /**< qam RF AGC config */
485                 struct drxj_cfg_agc qam_if_agc_cfg; /**< qam IF AGC config */
486                 struct drxj_cfg_agc vsb_rf_agc_cfg; /**< vsb RF AGC config */
487                 struct drxj_cfg_agc vsb_if_agc_cfg; /**< vsb IF AGC config */
488
489                 /* PGA gain configuration for QAM and VSB */
490                 u16 qam_pga_cfg;          /**< qam PGA config */
491                 u16 vsb_pga_cfg;          /**< vsb PGA config */
492
493                 /* Pre SAW configuration for QAM and VSB */
494                 struct drxj_cfg_pre_saw qam_pre_saw_cfg;
495                                           /**< qam pre SAW config */
496                 struct drxj_cfg_pre_saw vsb_pre_saw_cfg;
497                                           /**< qam pre SAW config */
498
499                 /* Version information */
500                 char v_text[2][12];       /**< allocated text versions */
501                 struct drx_version v_version[2]; /**< allocated versions structs */
502                 struct drx_version_list v_list_elements[2];
503                                           /**< allocated version list */
504
505                 /* smart antenna configuration */
506                 bool smart_ant_inverted;
507
508                 /* Tracking filter setting for OOB */
509                 u16 oob_trk_filter_cfg[8];
510                 bool oob_power_on;
511
512                 /* MPEG static bitrate setting */
513                 u32 mpeg_ts_static_bitrate;  /**< bitrate static MPEG output */
514                 bool disable_te_ihandling;  /**< MPEG TS TEI handling */
515                 bool bit_reverse_mpeg_outout;/**< MPEG output bit order */
516                  enum drxj_mpeg_output_clock_rate mpeg_output_clock_rate;
517                                             /**< MPEG output clock rate */
518                  enum drxj_mpeg_start_width mpeg_start_width;
519                                             /**< MPEG Start width */
520
521                 /* Pre SAW & Agc configuration for ATV */
522                 struct drxj_cfg_pre_saw atv_pre_saw_cfg;
523                                           /**< atv pre SAW config */
524                 struct drxj_cfg_agc atv_rf_agc_cfg; /**< atv RF AGC config */
525                 struct drxj_cfg_agc atv_if_agc_cfg; /**< atv IF AGC config */
526                 u16 atv_pga_cfg;          /**< atv pga config    */
527
528                 u32 curr_symbol_rate;
529
530                 /* pin-safe mode */
531                 bool pdr_safe_mode;         /**< PDR safe mode activated      */
532                 u16 pdr_safe_restore_val_gpio;
533                 u16 pdr_safe_restore_val_v_sync;
534                 u16 pdr_safe_restore_val_sma_rx;
535                 u16 pdr_safe_restore_val_sma_tx;
536
537                 /* OOB pre-saw value */
538                 u16 oob_pre_saw;
539                 enum drxj_cfg_oob_lo_power oob_lo_pow;
540
541                 struct drx_aud_data aud_data;
542                                     /**< audio storage                  */};
543
544 /*-------------------------------------------------------------------------
545 Access MACROS
546 -------------------------------------------------------------------------*/
547 /**
548 * \brief Compilable references to attributes
549 * \param d pointer to demod instance
550 *
551 * Used as main reference to an attribute field.
552 * Can be used by both macro implementation and function implementation.
553 * These macros are defined to avoid duplication of code in macro and function
554 * definitions that handle access of demod common or extended attributes.
555 *
556 */
557
558 #define DRXJ_ATTR_BTSC_DETECT(d)                       \
559                         (((struct drxj_data *)(d)->my_ext_attr)->aud_data.btsc_detect)
560
561 /**
562 * \brief Actual access macros
563 * \param d pointer to demod instance
564 * \param x value to set or to get
565 *
566 * SET macros must be used to set the value of an attribute.
567 * GET macros must be used to retrieve the value of an attribute.
568 * Depending on the value of DRX_USE_ACCESS_FUNCTIONS the macro's will be
569 * substituted by "direct-access-inline-code" or a function call.
570 *
571 */
572 #define DRXJ_GET_BTSC_DETECT(d, x)                     \
573    do {                                                  \
574       (x) = DRXJ_ATTR_BTSC_DETECT((d);                 \
575    } while (0)
576
577 #define DRXJ_SET_BTSC_DETECT(d, x)                     \
578    do {                                                  \
579       DRXJ_ATTR_BTSC_DETECT(d) = (x);                  \
580    } while (0)
581
582 /*-------------------------------------------------------------------------
583 DEFINES
584 -------------------------------------------------------------------------*/
585
586 /**
587 * \def DRXJ_NTSC_CARRIER_FREQ_OFFSET
588 * \brief Offset from picture carrier to centre frequency in kHz, in RF domain
589 *
590 * For NTSC standard.
591 * NTSC channels are listed by their picture carrier frequency (Fpc).
592 * The function DRX_CTRL_SET_CHANNEL requires the centre frequency as input.
593 * In case the tuner module is not used the DRX-J requires that the tuner is
594 * tuned to the centre frequency of the channel:
595 *
596 * Fcentre = Fpc + DRXJ_NTSC_CARRIER_FREQ_OFFSET
597 *
598 */
599 #define DRXJ_NTSC_CARRIER_FREQ_OFFSET           ((s32)(1750))
600
601 /**
602 * \def DRXJ_PAL_SECAM_BG_CARRIER_FREQ_OFFSET
603 * \brief Offset from picture carrier to centre frequency in kHz, in RF domain
604 *
605 * For PAL/SECAM - BG standard. This define is needed in case the tuner module
606 * is NOT used. PAL/SECAM channels are listed by their picture carrier frequency (Fpc).
607 * The DRX-J requires that the tuner is tuned to:
608 * Fpc + DRXJ_PAL_SECAM_BG_CARRIER_FREQ_OFFSET
609 *
610 * In case the tuner module is used the drxdriver takes care of this.
611 * In case the tuner module is NOT used the application programmer must take
612 * care of this.
613 *
614 */
615 #define DRXJ_PAL_SECAM_BG_CARRIER_FREQ_OFFSET   ((s32)(2375))
616
617 /**
618 * \def DRXJ_PAL_SECAM_DKIL_CARRIER_FREQ_OFFSET
619 * \brief Offset from picture carrier to centre frequency in kHz, in RF domain
620 *
621 * For PAL/SECAM - DK, I, L standards. This define is needed in case the tuner module
622 * is NOT used. PAL/SECAM channels are listed by their picture carrier frequency (Fpc).
623 * The DRX-J requires that the tuner is tuned to:
624 * Fpc + DRXJ_PAL_SECAM_DKIL_CARRIER_FREQ_OFFSET
625 *
626 * In case the tuner module is used the drxdriver takes care of this.
627 * In case the tuner module is NOT used the application programmer must take
628 * care of this.
629 *
630 */
631 #define DRXJ_PAL_SECAM_DKIL_CARRIER_FREQ_OFFSET ((s32)(2775))
632
633 /**
634 * \def DRXJ_PAL_SECAM_LP_CARRIER_FREQ_OFFSET
635 * \brief Offset from picture carrier to centre frequency in kHz, in RF domain
636 *
637 * For PAL/SECAM - LP standard. This define is needed in case the tuner module
638 * is NOT used. PAL/SECAM channels are listed by their picture carrier frequency (Fpc).
639 * The DRX-J requires that the tuner is tuned to:
640 * Fpc + DRXJ_PAL_SECAM_LP_CARRIER_FREQ_OFFSET
641 *
642 * In case the tuner module is used the drxdriver takes care of this.
643 * In case the tuner module is NOT used the application programmer must take
644 * care of this.
645 */
646 #define DRXJ_PAL_SECAM_LP_CARRIER_FREQ_OFFSET   ((s32)(-3255))
647
648 /**
649 * \def DRXJ_FM_CARRIER_FREQ_OFFSET
650 * \brief Offset from sound carrier to centre frequency in kHz, in RF domain
651 *
652 * For FM standard.
653 * FM channels are listed by their sound carrier frequency (Fsc).
654 * The function DRX_CTRL_SET_CHANNEL requires the Ffm frequency (see below) as
655 * input.
656 * In case the tuner module is not used the DRX-J requires that the tuner is
657 * tuned to the Ffm frequency of the channel.
658 *
659 * Ffm = Fsc + DRXJ_FM_CARRIER_FREQ_OFFSET
660 *
661 */
662 #define DRXJ_FM_CARRIER_FREQ_OFFSET             ((s32)(-3000))
663
664 /* Revision types -------------------------------------------------------*/
665
666 #define DRXJ_TYPE_ID (0x3946000DUL)
667
668 /* Macros ---------------------------------------------------------------*/
669
670 /* Convert OOB lock status to string */
671 #define DRXJ_STR_OOB_LOCKSTATUS(x) ( \
672    (x == DRX_NEVER_LOCK)  ?  "Never"           : \
673    (x == DRX_NOT_LOCKED)  ?  "No"              : \
674    (x == DRX_LOCKED)  ?  "Locked"          : \
675    (x == DRX_LOCK_STATE_1)  ?  "AGC lock"        : \
676    (x == DRX_LOCK_STATE_2)  ?  "sync lock"       : \
677                                              "(Invalid)")
678
679 /*-------------------------------------------------------------------------
680 ENUM
681 -------------------------------------------------------------------------*/
682
683 /*-------------------------------------------------------------------------
684 STRUCTS
685 -------------------------------------------------------------------------*/
686
687 /*-------------------------------------------------------------------------
688 Exported FUNCTIONS
689 -------------------------------------------------------------------------*/
690
691         int drxj_open(struct drx_demod_instance *demod);
692         int drxj_close(struct drx_demod_instance *demod);
693         int drxj_ctrl(struct drx_demod_instance *demod,
694                                      u32 ctrl, void *ctrl_data);
695
696 /*-------------------------------------------------------------------------
697 Exported GLOBAL VARIABLES
698 -------------------------------------------------------------------------*/
699         extern struct drx_access_func drx_dap_drxj_funct_g;
700         extern struct drx_demod_func drxj_functions_g;
701         extern struct drxj_data drxj_data_g;
702         extern struct i2c_device_addr drxj_default_addr_g;
703         extern struct drx_common_attr drxj_default_comm_attr_g;
704         extern struct drx_demod_instance drxj_default_demod_g;
705
706 /*-------------------------------------------------------------------------
707 THE END
708 -------------------------------------------------------------------------*/
709 #ifdef __cplusplus
710 }
711 #endif
712 #endif                          /* __DRXJ_H__ */