-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTVService.lua
162 lines (115 loc) · 4.72 KB
/
TVService.lua
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
local ffi = require "ffi"
local host = require "BcmHost"
local bcm_host_lib = ffi.load("bcm_host")
local vcos_lib = ffi.load("vcos")
local vchi_lib = ffi.load("vchiq_arm")
require "vc_tvservice"
local TVService = {
init = function(initialize_instance, connections, num_connections)
local result = bcm_host_lib.vc_vchi_tv_init(initialise_instance, connections, num_connections );
return result == 0 or false, result;
end,
stop = function()
bcm_host_lib.vc_vchi_tv_stop( void );
return true;
end,
register_callback = function(callback, callback_data)
bcm_host_lib.vc_tv_register_callback(callback, callback_data);
return true;
end,
unregister_callback = function(callback)
bcm_host_lib.vc_tv_unregister_callback(callback);
return true;
end,
enable_copyprotect = function(cp_mode, timeout)
local result = bcm_host_lib.vc_tv_enable_copyprotect(cp_mode, timeout);
return result == 0 or false, result;
end,
disable_copyprotect = function()
local result = bcm_host_lib.vc_tv_disable_copyprotect( );
return result == 0 or false, result;
end,
show_info = function(show)
local result = bcm_host_lib.vc_tv_show_info(show);
return result == 0 or false, result;
end,
get_state = function(tvstate)
local result = bcm_host_lib.vc_tv_get_state(tvstate);
return result == 0 or false, result;
end,
power_off = function()
local result = bcm_host_lib.vc_tv_power_off();
return result == 0 or false, result;
end,
test_mode_start = function(colour, test_mode)
local result = bcm_host_lib.vc_tv_test_mode_start(colour, test_mode);
return result == 0 or false, result;
end,
test_mode_stop = function()
local result = bcm_host_lib.vc_tv_test_mode_stop();
return result == 0 or false, result;
end,
notification_name = function(reason)
local result = bcm_host_lib.vc_tv_notifcation_name(reason);
if result ~= nil then
return ffi.string(result)
end
return false
end,
-- SDTV Specific Routines
sdtv_power_on = function(mode, options)
local status = bcm_host_lib.vc_tv_sdtv_power_on(mode, options);
return result == 0 or false, result;
end,
--[[
// HDMI Specific Routines
int vc_tv_hdmi_power_on_preferred( void );
int vc_tv_hdmi_power_on_preferred_3d( void );
int vc_tv_hdmi_power_on_best(uint32_t width, uint32_t height, uint32_t frame_rate,
HDMI_INTERLACED_T scan_mode, EDID_MODE_MATCH_FLAG_T match_flags);
int vc_tv_hdmi_power_on_best_3d(uint32_t width, uint32_t height, uint32_t frame_rate,
HDMI_INTERLACED_T scan_mode, EDID_MODE_MATCH_FLAG_T match_flags);
int vc_tv_hdmi_power_on_explicit(HDMI_MODE_T mode, HDMI_RES_GROUP_T group, uint32_t code);
int vc_tv_hdmi_get_supported_modes(HDMI_RES_GROUP_T group,
TV_SUPPORTED_MODE_T *supported_modes,
uint32_t max_supported_modes,
HDMI_RES_GROUP_T *preferred_group,
uint32_t *preferred_mode);
int vc_tv_hdmi_mode_supported(HDMI_RES_GROUP_T group, uint32_t mode);
int vc_tv_hdmi_audio_supported(uint32_t audio_format, uint32_t num_channels, EDID_AudioSampleRate fs, uint32_t bitrate);
int vc_tv_hdmi_get_av_latency( void );
int vc_tv_hdmi_set_hdcp_key(const uint8_t *key);
int vc_tv_hdmi_set_hdcp_revoked_list(const uint8_t *list, uint32_t num_keys);
int vc_tv_hdmi_set_spd(const char *manufacturer, const char *description, HDMI_SPD_TYPE_CODE_T type);
int vc_tv_hdmi_set_display_options(HDMI_ASPECT_T aspect, uint32_t left_bar_width, uint32_t right_bar_width, uint32_t top_bar_height, uint32_t bottom_bar_height, uint32_t overscan_flags);
int vc_tv_hdmi_ddc_read(uint32_t offset, uint32_t length, uint8_t *buffer);
int vc_tv_hdmi_set_attached(uint32_t attached);
int vc_tv_hdmi_set_property(uint32_t property, uint32_t param1, uint32_t param2);
int vc_tv_hdmi_get_property(uint32_t property, uint32_t *param1, uint32_t *param2);
--]]
}
local function tvservice_init()
pvchi_instance = ffi.new("VCHI_INSTANCE_T[1]");
pvchi_connections = ffi.new("VCHI_CONNECTION_T *[1]");
-- Assume bcm_host_init() has already been called
-- bcm_host_init();
-- initialise vcos/vchi
--ffi.C.vcos_init();
local result = vchi_lib.vchi_initialise(pvchi_instance)
if result ~= VCHIQ_SUCCESS then
return false, result
end
vchi_instance = pvchi_instance[0];
-- create a vchi connection
result = vchi_lib.vchi_connect( nil, 0, vchi_instance )
if result ~= 0 then
return false, result;
end
-- connect to tvservice
result = vchi_lilb.vc_vchi_tv_init( vchi_instance, pvchi_connections, 1)
if result ~= 0 then
return false, result
end
end
tvservice_init();
return TVService;