Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 162 lines (115 sloc) 4.835 kb
ea204947 »
2012-10-21 modified: BcmHost.lua
1
2 local ffi = require "ffi"
3
4 local host = require "BcmHost"
5
6 local bcm_host_lib = ffi.load("bcm_host")
7 local vcos_lib = ffi.load("vcos")
8 local vchi_lib = ffi.load("vchiq_arm")
9
10 require "vc_tvservice"
11
12 local TVService = {
13 init = function(initialize_instance, connections, num_connections)
14 local result = bcm_host_lib.vc_vchi_tv_init(initialise_instance, connections, num_connections );
15 return result == 0 or false, result;
16 end,
17
18 stop = function()
19 bcm_host_lib.vc_vchi_tv_stop( void );
20 return true;
21 end,
22
23 register_callback = function(callback, callback_data)
24 bcm_host_lib.vc_tv_register_callback(callback, callback_data);
25 return true;
26 end,
27
28 unregister_callback = function(callback)
29 bcm_host_lib.vc_tv_unregister_callback(callback);
30 return true;
31 end,
32
33 enable_copyprotect = function(cp_mode, timeout)
34 local result = bcm_host_lib.vc_tv_enable_copyprotect(cp_mode, timeout);
35 return result == 0 or false, result;
36 end,
37
38 disable_copyprotect = function()
39 local result = bcm_host_lib.vc_tv_disable_copyprotect( );
40 return result == 0 or false, result;
41 end,
42
43 show_info = function(show)
44 local result = bcm_host_lib.vc_tv_show_info(show);
45 return result == 0 or false, result;
46 end,
47
48 get_state = function(tvstate)
49 local result = bcm_host_lib.vc_tv_get_state(tvstate);
50 return result == 0 or false, result;
51 end,
52
53 power_off = function()
54 local result = bcm_host_lib.vc_tv_power_off();
55 return result == 0 or false, result;
56 end,
57
58 test_mode_start = function(colour, test_mode)
59 local result = bcm_host_lib.vc_tv_test_mode_start(colour, test_mode);
60 return result == 0 or false, result;
61 end,
62
63 test_mode_stop = function()
64 local result = bcm_host_lib.vc_tv_test_mode_stop();
65 return result == 0 or false, result;
66 end,
67
68 notification_name = function(reason)
69 local result = bcm_host_lib.vc_tv_notifcation_name(reason);
70 if result ~= nil then
71 return ffi.string(result)
72 end
73
74 return false
75 end,
76
77 -- SDTV Specific Routines
78 sdtv_power_on = function(mode, options)
79 local status = bcm_host_lib.vc_tv_sdtv_power_on(mode, options);
80 return result == 0 or false, result;
81 end,
82
83 --[[
84 // HDMI Specific Routines
85 int vc_tv_hdmi_power_on_preferred( void );
86
87 int vc_tv_hdmi_power_on_preferred_3d( void );
88
89 int vc_tv_hdmi_power_on_best(uint32_t width, uint32_t height, uint32_t frame_rate,
90 HDMI_INTERLACED_T scan_mode, EDID_MODE_MATCH_FLAG_T match_flags);
91
92 int vc_tv_hdmi_power_on_best_3d(uint32_t width, uint32_t height, uint32_t frame_rate,
93 HDMI_INTERLACED_T scan_mode, EDID_MODE_MATCH_FLAG_T match_flags);
94
95 int vc_tv_hdmi_power_on_explicit(HDMI_MODE_T mode, HDMI_RES_GROUP_T group, uint32_t code);
96
97 int vc_tv_hdmi_get_supported_modes(HDMI_RES_GROUP_T group,
98 TV_SUPPORTED_MODE_T *supported_modes,
99 uint32_t max_supported_modes,
100 HDMI_RES_GROUP_T *preferred_group,
101 uint32_t *preferred_mode);
102
103
104 int vc_tv_hdmi_mode_supported(HDMI_RES_GROUP_T group, uint32_t mode);
105
106 int vc_tv_hdmi_audio_supported(uint32_t audio_format, uint32_t num_channels, EDID_AudioSampleRate fs, uint32_t bitrate);
107
108 int vc_tv_hdmi_get_av_latency( void );
109
110 int vc_tv_hdmi_set_hdcp_key(const uint8_t *key);
111
112 int vc_tv_hdmi_set_hdcp_revoked_list(const uint8_t *list, uint32_t num_keys);
113
114 int vc_tv_hdmi_set_spd(const char *manufacturer, const char *description, HDMI_SPD_TYPE_CODE_T type);
115
116 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);
117
118 int vc_tv_hdmi_ddc_read(uint32_t offset, uint32_t length, uint8_t *buffer);
119
120 int vc_tv_hdmi_set_attached(uint32_t attached);
121
122 int vc_tv_hdmi_set_property(uint32_t property, uint32_t param1, uint32_t param2);
123
124 int vc_tv_hdmi_get_property(uint32_t property, uint32_t *param1, uint32_t *param2);
125 --]]
126 }
127
128
129
130 local function tvservice_init()
131 pvchi_instance = ffi.new("VCHI_INSTANCE_T[1]");
132 pvchi_connections = ffi.new("VCHI_CONNECTION_T *[1]");
133
134 -- Assume bcm_host_init() has already been called
135 -- bcm_host_init();
136
137 -- initialise vcos/vchi
138 --ffi.C.vcos_init();
139
140 local result = vchi_lib.vchi_initialise(pvchi_instance)
141 if result ~= VCHIQ_SUCCESS then
142 return false, result
143 end
144 vchi_instance = pvchi_instance[0];
145
146 -- create a vchi connection
147 result = vchi_lib.vchi_connect( nil, 0, vchi_instance )
148 if result ~= 0 then
149 return false, result;
150 end
151
152 -- connect to tvservice
153 result = vchi_lilb.vc_vchi_tv_init( vchi_instance, pvchi_connections, 1)
154 if result ~= 0 then
155 return false, result
156 end
157 end
158
159
160 tvservice_init();
161
162 return TVService;
Something went wrong with that request. Please try again.