summaryrefstree
path: root/kernel/drivers/media/tdmb/mtv319/mtv319.h
blob: 3b0535b90a03c97802e35923461a2dc77e6f9c6d (plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*
*
* File name: mtv319.h
*
* Description : MTV319 device driver API header file.
*
* Copyright (C) (2013, RAONTECH)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation version 2.
*
* This program is distributed "as is" WITHOUT ANY WARRANTY of any
* kind, whether express or implied; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
*/

#ifndef __MTV319_H__
#define __MTV319_H__

#ifdef __cplusplus
extern "C"{
#endif

#include "mtv319_port.h"

/*=============================================================================
*
* Common definitions and types.
*
*===========================================================================*/
#define MTV319_CHIP_ID			0xC6
#define MTV319_FIC_BUF_SIZE		(3 * 188)
#define MTV319_SPI_CMD_SIZE		3

#ifndef NULL
	#define NULL		0
#endif

#ifndef FALSE
	#define FALSE		0
#endif

#ifndef TRUE
	#define TRUE		1
#endif

#ifndef MAX
	#define MAX(a, b)	(((a) > (b)) ? (a) : (b))
#endif

#ifndef MIN
	#define MIN(a, b)	(((a) < (b)) ? (a) : (b))
#endif

#ifndef ABS
	#define ABS(x)		(((x) < 0) ? -(x) : (x))
#endif


/* Error codes. */
#define RTV_SUCCESS				0
#define RTV_POWER_ON_CHECK_ERROR		-1
#define RTV_ADC_CLK_UNLOCKED			-2
#define RTV_PLL_UNLOCKED			-3
#define RTV_CHANNEL_NOT_DETECTED		-4
#define RTV_NOT_OPENED_FIC			-5
#define RTV_INVAILD_SUBCHANNEL_ID		-6
#define RTV_NO_MORE_SUBCHANNEL			-7
#define RTV_ALREADY_OPENED_SUBCHANNEL_ID	-8
#define RTV_INVAILD_THRESHOLD_SIZE		-9
#define RTV_OPENING_SERVICE_FULL		-10
#define RTV_INVAILD_SERVICE_TYPE		-11
#define RTV_FIC_READ_TIMEOUT			-12
#define RTV_SHOULD_CLOSE_SUBCHANNELS		-13
#define RTV_SHOULD_CLOSE_FIC			-14
#define RTV_INVALID_FIC_OPEN_STATE		-15
#define RTV_INVALID_FREQENCY			-16


/* Do not modify the value! */
enum E_RTV_SERVICE_TYPE {
	RTV_SERVICE_DMB = 0, /* DMB Video */
	RTV_SERVICE_DAB = 1, /* DAB */
	RTV_SERVICE_DABPLUS = 2 /* DAB+ */
};

/* Cont flag of multi channel header */
enum RTV_MCH_HDR_CONT_FLAG_T {
	RTV_MCH_HDR_CONT_MED = 0,
	RTV_MCH_HDR_CONT_LAST = 1,
	RTV_MCH_HDR_CONT_FIRST = 2,
	RTV_MCH_HDR_CONT_ALONE = 3
};

/* ID flag of multi channel header */
enum RTV_MCH_HDR_ID_FLAG_T {
	RTV_MCH_HDR_ID_DAB = 0,
	RTV_MCH_HDR_ID_DMB = 1,
	RTV_MCH_HDR_ID_FIDC = 2,
	RTV_MCH_HDR_ID_FIC = 3,
	MAX_NUM_MCH_HDR_ID_TYPE
};

#define RTV_MCH_HDR_SIZE	4 /* Size, in bytes,  of MCH header */
#define MAX_MCH_PAYLOAD_SIZE	(RTV_TSP_XFER_SIZE - RTV_MCH_HDR_SIZE)

/*=============================================================================
*
* TDMB definitions, types and APIs.
*
*===========================================================================*/
#define RTV_TDMB_AGC_LOCK_MASK		0x1
#define RTV_TDMB_OFDM_LOCK_MASK		0x2
#define RTV_TDMB_FEC_LOCK_MASK		0x4

#define RTV_TDMB_CHANNEL_LOCK_OK	\
	(RTV_TDMB_AGC_LOCK_MASK|RTV_TDMB_OFDM_LOCK_MASK|RTV_TDMB_FEC_LOCK_MASK)

#define RTV_TDMB_BER_DIVIDER		100000
#define RTV_TDMB_CNR_DIVIDER		1000
#define RTV_TDMB_RSSI_DIVIDER		1000

#if defined(RTV_IF_SPI) || defined(RTV_IF_EBI2)
extern UINT g_nRtvInterruptLevelSize;
static INLINE UINT rtvTDMB_GetInterruptLevelSize(void)
{
	return g_nRtvInterruptLevelSize;
}
#endif

INT rtvTDMB_OpenSubChannelExt(U32 dwChFreqKHz, UINT nSubChID,
		enum E_RTV_SERVICE_TYPE eServiceType, UINT nThresholdSize);

UINT rtvTDMB_GetLockStatus(void);
UINT rtvTDMB_GetAntennaLevel(U32 dwCER);
U32  rtvTDMB_GetFicCER(void);
U32  rtvTDMB_GetCER(void);
U32  rtvTDMB_GetPER(void);
S32  rtvTDMB_GetRSSI(void);
U32  rtvTDMB_GetCNR(void);
U32  rtvTDMB_GetBER(void);
U32  rtvTDMB_GetPreviousFrequency(void);
UINT rtvTDMB_GetOpenedSubChannelCount(void);
void rtvTDMB_CloseAllSubChannels(void);
INT  rtvTDMB_CloseSubChannel(UINT nSubChID);
INT  rtvTDMB_OpenSubChannel(U32 dwChFreqKHz, UINT nSubChID,
		enum E_RTV_SERVICE_TYPE eServiceType, UINT nThresholdSize);
INT  rtvTDMB_ReadFIC(U8 *pbBuf);
void rtvTDMB_CloseFIC(void);
INT  rtvTDMB_OpenFIC(void);
INT  rtvTDMB_ScanFrequency(U32 dwChFreqKHz);
INT  rtvTDMB_Initialize(unsigned long interface);
UINT tdmb_GetOfdmLockStatus(void);

#ifdef __cplusplus
}
#endif

#endif /* __MTV319_H__ */