3b9adf90703339be6a2850193bf7133930d4bcaf
[deliverable/linux.git] / drivers / media / dvb-frontends / drx39xyj / bsp_tuner.h
1 /*
2 Copyright (c), 2004-2005,2007-2010 Trident Microsystems, Inc.
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7
8 * Redistributions of source code must retain the above copyright notice,
9 this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright notice,
11 this list of conditions and the following disclaimer in the documentation
12 and/or other materials provided with the distribution.
13 * Neither the name of Trident Microsystems nor Hauppauge Computer Works
14 nor the names of its contributors may be used to endorse or promote
15 products derived from this software without specific prior written
16 permission.
17
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 /**
32 * \file $Id: bsp_tuner.h,v 1.5 2009/10/19 22:15:13 dingtao Exp $
33 *
34 * \brief Tuner dependable type definitions, macro's and functions
35 *
36 */
37
38 #ifndef __DRXBSP_TUNER_H__
39 #define __DRXBSP_TUNER_H__
40 /*------------------------------------------------------------------------------
41 INCLUDES
42 ------------------------------------------------------------------------------*/
43 #include "bsp_types.h"
44 #include "bsp_i2c.h"
45
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49
50 /*------------------------------------------------------------------------------
51 DEFINES
52 ------------------------------------------------------------------------------*/
53
54 /* Sub-mode bits should be adjacent and incremental */
55 #define TUNER_MODE_SUB0 0x0001 /* for sub-mode (e.g. RF-AGC setting) */
56 #define TUNER_MODE_SUB1 0x0002 /* for sub-mode (e.g. RF-AGC setting) */
57 #define TUNER_MODE_SUB2 0x0004 /* for sub-mode (e.g. RF-AGC setting) */
58 #define TUNER_MODE_SUB3 0x0008 /* for sub-mode (e.g. RF-AGC setting) */
59 #define TUNER_MODE_SUB4 0x0010 /* for sub-mode (e.g. RF-AGC setting) */
60 #define TUNER_MODE_SUB5 0x0020 /* for sub-mode (e.g. RF-AGC setting) */
61 #define TUNER_MODE_SUB6 0x0040 /* for sub-mode (e.g. RF-AGC setting) */
62 #define TUNER_MODE_SUB7 0x0080 /* for sub-mode (e.g. RF-AGC setting) */
63
64 #define TUNER_MODE_DIGITAL 0x0100 /* for digital channel (e.g. DVB-T) */
65 #define TUNER_MODE_ANALOG 0x0200 /* for analog channel (e.g. PAL) */
66 #define TUNER_MODE_SWITCH 0x0400 /* during channel switch & scanning */
67 #define TUNER_MODE_LOCK 0x0800 /* after tuner has locked */
68 #define TUNER_MODE_6MHZ 0x1000 /* for 6MHz bandwidth channels */
69 #define TUNER_MODE_7MHZ 0x2000 /* for 7MHz bandwidth channels */
70 #define TUNER_MODE_8MHZ 0x4000 /* for 8MHz bandwidth channels */
71
72 #define TUNER_MODE_SUB_MAX 8
73 #define TUNER_MODE_SUBALL (TUNER_MODE_SUB0 | TUNER_MODE_SUB1 | \
74 TUNER_MODE_SUB2 | TUNER_MODE_SUB3 | \
75 TUNER_MODE_SUB4 | TUNER_MODE_SUB5 | \
76 TUNER_MODE_SUB6 | TUNER_MODE_SUB7)
77
78 /*------------------------------------------------------------------------------
79 TYPEDEFS
80 ------------------------------------------------------------------------------*/
81
82 typedef u32 TUNERMode_t;
83 typedef u32 *pTUNERMode_t;
84
85 typedef char *TUNERSubMode_t; /* description of submode */
86 typedef TUNERSubMode_t *pTUNERSubMode_t;
87
88 typedef enum {
89
90 TUNER_LOCKED,
91 TUNER_NOT_LOCKED
92 } TUNERLockStatus_t, *pTUNERLockStatus_t;
93
94 typedef struct {
95
96 char *name; /* Tuner brand & type name */
97 s32 minFreqRF; /* Lowest RF input frequency, in kHz */
98 s32 maxFreqRF; /* Highest RF input frequency, in kHz */
99
100 u8 subMode; /* Index to sub-mode in use */
101 pTUNERSubMode_t subModeDescriptions; /* Pointer to description of sub-modes */
102 u8 subModes; /* Number of available sub-modes */
103
104 /* The following fields will be either 0, NULL or false and do not need
105 initialisation */
106 void *selfCheck; /* gives proof of initialization */
107 bool programmed; /* only valid if selfCheck is OK */
108 s32 RFfrequency; /* only valid if programmed */
109 s32 IFfrequency; /* only valid if programmed */
110
111 void *myUserData; /* pointer to associated demod instance */
112 u16 myCapabilities; /* value for storing application flags */
113
114 } TUNERCommonAttr_t, *pTUNERCommonAttr_t;
115
116 /*
117 * Generic functions for DRX devices.
118 */
119 typedef struct TUNERInstance_s *pTUNERInstance_t;
120
121 typedef DRXStatus_t(*TUNEROpenFunc_t) (pTUNERInstance_t tuner);
122 typedef DRXStatus_t(*TUNERCloseFunc_t) (pTUNERInstance_t tuner);
123
124 typedef DRXStatus_t(*TUNERSetFrequencyFunc_t) (pTUNERInstance_t tuner,
125 TUNERMode_t mode,
126 s32
127 frequency);
128
129 typedef DRXStatus_t(*TUNERGetFrequencyFunc_t) (pTUNERInstance_t tuner,
130 TUNERMode_t mode,
131 s32 *
132 RFfrequency,
133 s32 *
134 IFfrequency);
135
136 typedef DRXStatus_t(*TUNERLockStatusFunc_t) (pTUNERInstance_t tuner,
137 pTUNERLockStatus_t
138 lockStat);
139
140 typedef DRXStatus_t(*TUNERi2cWriteReadFunc_t) (pTUNERInstance_t tuner,
141 struct i2c_device_addr *
142 wDevAddr, u16 wCount,
143 u8 *wData,
144 struct i2c_device_addr *
145 rDevAddr, u16 rCount,
146 u8 *rData);
147
148 typedef struct {
149 TUNEROpenFunc_t openFunc;
150 TUNERCloseFunc_t closeFunc;
151 TUNERSetFrequencyFunc_t setFrequencyFunc;
152 TUNERGetFrequencyFunc_t getFrequencyFunc;
153 TUNERLockStatusFunc_t lockStatusFunc;
154 TUNERi2cWriteReadFunc_t i2cWriteReadFunc;
155
156 } TUNERFunc_t, *pTUNERFunc_t;
157
158 typedef struct TUNERInstance_s {
159
160 struct i2c_device_addr myI2CDevAddr;
161 pTUNERCommonAttr_t myCommonAttr;
162 void *myExtAttr;
163 pTUNERFunc_t myFunct;
164
165 } TUNERInstance_t;
166
167 /*------------------------------------------------------------------------------
168 ENUM
169 ------------------------------------------------------------------------------*/
170
171 /*------------------------------------------------------------------------------
172 STRUCTS
173 ------------------------------------------------------------------------------*/
174
175 /*------------------------------------------------------------------------------
176 Exported FUNCTIONS
177 ------------------------------------------------------------------------------*/
178
179 DRXStatus_t DRXBSP_TUNER_Open(pTUNERInstance_t tuner);
180
181 DRXStatus_t DRXBSP_TUNER_Close(pTUNERInstance_t tuner);
182
183 DRXStatus_t DRXBSP_TUNER_SetFrequency(pTUNERInstance_t tuner,
184 TUNERMode_t mode,
185 s32 frequency);
186
187 DRXStatus_t DRXBSP_TUNER_GetFrequency(pTUNERInstance_t tuner,
188 TUNERMode_t mode,
189 s32 *RFfrequency,
190 s32 *IFfrequency);
191
192 DRXStatus_t DRXBSP_TUNER_LockStatus(pTUNERInstance_t tuner,
193 pTUNERLockStatus_t lockStat);
194
195 DRXStatus_t DRXBSP_TUNER_DefaultI2CWriteRead(pTUNERInstance_t tuner,
196 struct i2c_device_addr *wDevAddr,
197 u16 wCount,
198 u8 *wData,
199 struct i2c_device_addr *rDevAddr,
200 u16 rCount, u8 *rData);
201
202 /*------------------------------------------------------------------------------
203 THE END
204 ------------------------------------------------------------------------------*/
205 #ifdef __cplusplus
206 }
207 #endif
208 #endif /* __DRXBSP_TUNER_H__ */
209 /* End of file */
This page took 0.034985 seconds and 4 git commands to generate.