bsp_tuner.h 7.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
/*
  Copyright (c), 2004-2005,2007-2010 Trident Microsystems, Inc.
  All rights reserved.

  Redistribution and use in source and binary forms, with or without
  modification, are permitted provided that the following conditions are met:

  * Redistributions of source code must retain the above copyright notice,
    this list of conditions and the following disclaimer.
  * Redistributions in binary form must reproduce the above copyright notice,
    this list of conditions and the following disclaimer in the documentation
	and/or other materials provided with the distribution.
  * Neither the name of Trident Microsystems nor Hauppauge Computer Works
    nor the names of its contributors may be used to endorse or promote
	products derived from this software without specific prior written
	permission.

  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  POSSIBILITY OF SUCH DAMAGE.
*/

31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
/**
* \file $Id: bsp_tuner.h,v 1.5 2009/10/19 22:15:13 dingtao Exp $
*
* \brief Tuner dependable type definitions, macro's and functions
*
*/

#ifndef __DRXBSP_TUNER_H__
#define __DRXBSP_TUNER_H__
/*------------------------------------------------------------------------------
INCLUDES
------------------------------------------------------------------------------*/
#include "bsp_types.h"
#include "bsp_i2c.h"

#ifdef __cplusplus
extern "C" {
#endif

/*------------------------------------------------------------------------------
DEFINES
------------------------------------------------------------------------------*/

54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
	/* Sub-mode bits should be adjacent and incremental */
#define TUNER_MODE_SUB0    0x0001	/* for sub-mode (e.g. RF-AGC setting) */
#define TUNER_MODE_SUB1    0x0002	/* for sub-mode (e.g. RF-AGC setting) */
#define TUNER_MODE_SUB2    0x0004	/* for sub-mode (e.g. RF-AGC setting) */
#define TUNER_MODE_SUB3    0x0008	/* for sub-mode (e.g. RF-AGC setting) */
#define TUNER_MODE_SUB4    0x0010	/* for sub-mode (e.g. RF-AGC setting) */
#define TUNER_MODE_SUB5    0x0020	/* for sub-mode (e.g. RF-AGC setting) */
#define TUNER_MODE_SUB6    0x0040	/* for sub-mode (e.g. RF-AGC setting) */
#define TUNER_MODE_SUB7    0x0080	/* for sub-mode (e.g. RF-AGC setting) */

#define TUNER_MODE_DIGITAL 0x0100	/* for digital channel (e.g. DVB-T)   */
#define TUNER_MODE_ANALOG  0x0200	/* for analog channel  (e.g. PAL)     */
#define TUNER_MODE_SWITCH  0x0400	/* during channel switch & scanning   */
#define TUNER_MODE_LOCK    0x0800	/* after tuner has locked             */
#define TUNER_MODE_6MHZ    0x1000	/* for 6MHz bandwidth channels        */
#define TUNER_MODE_7MHZ    0x2000	/* for 7MHz bandwidth channels        */
#define TUNER_MODE_8MHZ    0x4000	/* for 8MHz bandwidth channels        */
71 72 73 74 75 76 77 78 79 80 81

#define TUNER_MODE_SUB_MAX 8
#define TUNER_MODE_SUBALL  (  TUNER_MODE_SUB0 | TUNER_MODE_SUB1 | \
			      TUNER_MODE_SUB2 | TUNER_MODE_SUB3 | \
			      TUNER_MODE_SUB4 | TUNER_MODE_SUB5 | \
			      TUNER_MODE_SUB6 | TUNER_MODE_SUB7 )

/*------------------------------------------------------------------------------
TYPEDEFS
------------------------------------------------------------------------------*/

82 83
	typedef u32 TUNERMode_t;
	typedef u32 *pTUNERMode_t;
84

85 86
	typedef char *TUNERSubMode_t;	/* description of submode */
	typedef TUNERSubMode_t *pTUNERSubMode_t;
87

88
	typedef enum {
89

90 91 92
		TUNER_LOCKED,
		TUNER_NOT_LOCKED
	} TUNERLockStatus_t, *pTUNERLockStatus_t;
93

94
	typedef struct {
95

96
		char *name;	/* Tuner brand & type name */
97 98
		s32 minFreqRF;	/* Lowest  RF input frequency, in kHz */
		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 106
		   initialisation */
		void *selfCheck;	/* gives proof of initialization  */
107 108 109
		bool programmed;	/* only valid if selfCheck is OK  */
		s32 RFfrequency;	/* only valid if programmed       */
		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 118

/*
* Generic functions for DRX devices.
*/
119 120 121 122 123 124 125
	typedef struct TUNERInstance_s *pTUNERInstance_t;

	typedef DRXStatus_t(*TUNEROpenFunc_t) (pTUNERInstance_t tuner);
	typedef DRXStatus_t(*TUNERCloseFunc_t) (pTUNERInstance_t tuner);

	typedef DRXStatus_t(*TUNERSetFrequencyFunc_t) (pTUNERInstance_t tuner,
						       TUNERMode_t mode,
126
						       s32
127 128 129 130
						       frequency);

	typedef DRXStatus_t(*TUNERGetFrequencyFunc_t) (pTUNERInstance_t tuner,
						       TUNERMode_t mode,
131
						       s32 *
132
						       RFfrequency,
133
						       s32 *
134 135 136 137 138 139 140
						       IFfrequency);

	typedef DRXStatus_t(*TUNERLockStatusFunc_t) (pTUNERInstance_t tuner,
						     pTUNERLockStatus_t
						     lockStat);

	typedef DRXStatus_t(*TUNERi2cWriteReadFunc_t) (pTUNERInstance_t tuner,
141
						       struct i2c_device_addr *
142 143
						       wDevAddr, u16 wCount,
						       u8 *wData,
144
						       struct i2c_device_addr *
145 146
						       rDevAddr, u16 rCount,
						       u8 *rData);
147 148 149 150 151 152 153 154 155 156 157 158 159

	typedef struct {
		TUNEROpenFunc_t openFunc;
		TUNERCloseFunc_t closeFunc;
		TUNERSetFrequencyFunc_t setFrequencyFunc;
		TUNERGetFrequencyFunc_t getFrequencyFunc;
		TUNERLockStatusFunc_t lockStatusFunc;
		TUNERi2cWriteReadFunc_t i2cWriteReadFunc;

	} TUNERFunc_t, *pTUNERFunc_t;

	typedef struct TUNERInstance_s {

160
		struct i2c_device_addr myI2CDevAddr;
161 162 163 164 165
		pTUNERCommonAttr_t myCommonAttr;
		void *myExtAttr;
		pTUNERFunc_t myFunct;

	} TUNERInstance_t;
166 167 168 169 170 171 172 173 174 175 176 177 178

/*------------------------------------------------------------------------------
ENUM
------------------------------------------------------------------------------*/

/*------------------------------------------------------------------------------
STRUCTS
------------------------------------------------------------------------------*/

/*------------------------------------------------------------------------------
Exported FUNCTIONS
------------------------------------------------------------------------------*/

179
	DRXStatus_t DRXBSP_TUNER_Open(pTUNERInstance_t tuner);
180

181
	DRXStatus_t DRXBSP_TUNER_Close(pTUNERInstance_t tuner);
182

183 184
	DRXStatus_t DRXBSP_TUNER_SetFrequency(pTUNERInstance_t tuner,
					      TUNERMode_t mode,
185
					      s32 frequency);
186

187 188
	DRXStatus_t DRXBSP_TUNER_GetFrequency(pTUNERInstance_t tuner,
					      TUNERMode_t mode,
189 190
					      s32 *RFfrequency,
					      s32 *IFfrequency);
191

192 193
	DRXStatus_t DRXBSP_TUNER_LockStatus(pTUNERInstance_t tuner,
					    pTUNERLockStatus_t lockStat);
194

195
	DRXStatus_t DRXBSP_TUNER_DefaultI2CWriteRead(pTUNERInstance_t tuner,
196
						     struct i2c_device_addr *wDevAddr,
197 198
						     u16 wCount,
						     u8 *wData,
199
						     struct i2c_device_addr *rDevAddr,
200
						     u16 rCount, u8 *rData);
201 202 203 204 205 206 207

/*------------------------------------------------------------------------------
THE END
------------------------------------------------------------------------------*/
#ifdef __cplusplus
}
#endif
208
#endif				/* __DRXBSP_TUNER_H__ */
209
/* End of file */