summaryrefslogtreecommitdiffstats
path: root/api/xc4000_control.h
blob: 70e97ce8276c7263ce7ff658e785873058f1f82a (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
//
// C header file for control of the XC4000 via the i2c interface.
//
// Filename : xc4000_control.h
// Generated : 1/22/2007 4:41:24 PM
//
// (c) 2007, Xceive Corporation
//
//
// Disclaimer:
//
// Xceive assumes no responsibility for any consequences arising from the use
// of this computer code, nor from any infringement of patents or the rights of
// third parties that may result from its use. No license is granted by
// implication or otherwise under any patent or other rights of Xceive. The
// customer is responsible for assuring that proper design and operating
// safeguards are observed to minimize inherent and procedural hazards. Xceive
// assumes no responsibility for applications assistance or customer product
// design.
// The present computer code is not authorized for use in medical, life-support
// equipment, or any other application involving a potential risk of severe
// property or environmental damage, personal injury, or death without prior
// express written approval of Xceive.  Any such use is understood to be
// entirely at the user's risk.
//
//

#ifndef __XC4000_CONTROL_H
#define __XC4000_CONTROL_H

/* *********************************************************************** */
/* Defines                                                                 */
/* *********************************************************************** */

#define XC_MAX_I2C_WRITE_LENGTH                     52

#define XC_RESULT_SUCCESS                           0
#define XC_RESULT_RESET_FAILURE                     1
#define XC_RESULT_I2C_WRITE_FAILURE                 2
#define XC_RESULT_I2C_READ_FAILURE                  3
#define XC_RESULT_OUT_OF_RANGE                      5

/* *********************************************************************** */
/* Type Declarations                                                       */
/* *********************************************************************** */

/*
   This represents an I2C firmware file encoded as a string of unsigned char.
   Format is as follows:

   char[0  ]=len0_MSB  -> len = len_MSB * 256 + len_LSB
   char[1  ]=len0_LSB  -> length of first write transaction
   char[2  ]=data0 -> first byte to be sent
   char[3  ]=data1
   char[4  ]=data2
   char[   ]=...
   char[M  ]=dataN  -> last byte to be sent
   char[M+1]=len1_MSB  -> len = len_MSB * 256 + len_LSB
   char[M+2]=len1_LSB  -> length of second write transaction
   char[M+3]=data0
   char[M+4]=data1
   ...
   etc.

   The [len] value should be interpreted as follows:

   len= len_MSB _ len_LSB
   len=1111_1111_1111_1111   : End of I2C_SEQUENCE
   len=0000_0000_0000_0000   : Reset command: Do hardware reset
   len=0NNN_NNNN_NNNN_NNNN   : Normal transaction: number of bytes = {1:32767)
   len=1WWW_WWWW_WWWW_WWWW   : Wait command: wait for {1:32767} ms

   For the RESET and WAIT commands, the two following bytes will contain
   immediately the length of the following transaction.

*/
typedef struct {
  char *Name;
  unsigned char *ConfFile;
  unsigned short VideoMode;
  unsigned short AudioMode;
  double         SCode;
} XC_TV_STANDARD;

typedef unsigned char XC4000_SCODE_TABLE[16][13];

// Download firmware
int xc_load_i2c_sequence(unsigned char i2c_sequence[]);

// Perform calibration and initialize default parameter
int xc_initialize();

// Initialize device according to supplied tv mode.
int xc_SetTVStandard(unsigned short int VideoMode, unsigned short int AudioMode);

int xc_set_RF_frequency(long frequency_in_hz);

int xc_set_dcode( int dcode);

//int xc_set_IF_frequency(long frequency_in_hz);

// Power-down device.
int xc_shutdown();

// enter direct-setting-mode
int xc_enter_directsitting_mode();

// exit direct-setting-mode
int xc_exit_directsitting_mode();

// set RF signal source
int xc_rf_mode(int mode);


// Get ADC envelope value.
int xc_get_ADC_Envelope(unsigned short int *adc_envelope);

// Get current frequency error.
int xc_get_frequency_error(long *frequency_error_mhz);

// Get lock status.
int xc_get_lock_status(unsigned short int *lock_status);

// Get device version information.
int xc_get_version( unsigned char* hw_majorversion,unsigned char* hw_minorversion,
                        unsigned char* fw_majorversion, unsigned char* fw_minorversion);

// Get device product ID.
int xc_get_product_id(unsigned short int *product_id);

// Get horizontal sync frequency.
int xc_get_hsync_freq(int *hsync_freq_hz);

// Get number of lines per frame.
int xc_get_frame_lines(unsigned short int *frame_lines);

// Get quality estimate.
int xc_get_quality(unsigned short int *quality);

// Tune a channel
int xc_tune_channel(long chnl_freq); //for Linux

#endif