-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathem2874-core.hpp
74 lines (55 loc) · 1.49 KB
/
em2874-core.hpp
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
// EM2874 core
#ifndef _EM2874CORE_HPP_
#define _EM2874CORE_HPP_
#include <boost/thread.hpp>
#include <inttypes.h>
#include <iostream>
#include "IoThread.hpp"
#define EM28XX_REG_I2C_CLK 0x06
#define EM2874_REG_TS_ENABLE 0x5F
#define EM28XX_REG_GPIO 0x80
#define EM2874_EP_TS1 0x84
#define DEMOD_ADDR 0x20
#define EEPROM_ADDR 0xa0
#define TUNER_ADDR 0xc0
/* EM2874 TS Enable Register (0x5f) */
#define EM2874_TS1_CAPTURE_ENABLE 0x01
#define EM2874_TS1_FILTER_ENABLE 0x02
#define EM2874_TS1_NULL_DISCARD 0x04
class EM2874Device
{
public:
EM2874Device ();
~EM2874Device ();
static void setLog(std::ostream *plog) {
log = plog;
};
bool openDevice (const char *devfile);
static EM2874Device* AllocDevice();
bool initDevice2 ();
uint8_t readReg (const uint8_t idx);
int readReg (const uint8_t idx, uint8_t *val);
int writeReg (const uint8_t idx, const uint8_t val);
bool readI2C (const uint8_t addr, const uint16_t size, uint8_t *data, const bool isStop);
bool writeI2C (const uint8_t addr, const uint16_t size, uint8_t *data, const bool isStop);
bool resetICC ();
bool writeICC (const size_t size, const void *data);
bool readICC (size_t *size, void *data);
int waitICC();
int getCardStatus();
int getDeviceID();
bool isCardReady;
void startStream();
void stopStream();
int getStream(const void **ptr);
private:
bool resetICC_1 ();
bool resetICC_2 ();
static std::ostream *log;
int fd;
uint8_t cardPCB;
bool isStream;
TsIoThread *ts_func;
boost::thread* ts_thread;
};
#endif