Permalink
Browse files

modified: BcmHost.lua

	modified:   DisplayManX.lua
	new file:   TVService.lua
	modified:   bcm_host.lua
	modified:   interface/vc_tvservice.lua
	modified:   interface/vcgencmd.lua
	modified:   interface/vchi.lua
	modified:   interface/vcos.lua
	modified:   libc.lua
	modified:   rpiui.lua
	modified:   test_dispmanx.lua
	new file:   test_picast.lua
	modified:   test_snapshot.lua
	new file:   test_tv_service.lua
  • Loading branch information...
Wiladams committed Oct 22, 2012
1 parent 204845a commit ea20494721bb904f7a9c0d0f6f3a572b15e0111e
Showing with 315 additions and 100 deletions.
  1. +5 −3 BcmHost.lua
  2. +25 −4 DisplayManX.lua
  3. +162 −0 TVService.lua
  4. +5 −1 bcm_host.lua
  5. +6 −9 interface/vc_tvservice.lua
  6. +14 −16 interface/vcgencmd.lua
  7. +27 −49 interface/vchi.lua
  8. +2 −1 interface/vcos.lua
  9. +2 −0 libc.lua
  10. +2 −1 rpiui.lua
  11. +1 −1 test_dispmanx.lua
  12. +53 −0 test_picast.lua
  13. +11 −15 test_snapshot.lua
  14. 0 test_tv_service.lua
View
@@ -1,10 +1,10 @@
local ffi = require "ffi"
-require "bcm_host"
+local host = require "bcm_host"
-local lib = ffi.load("bcm_host");
+local bcm_host_lib = ffi.load("bcm_host");
--[[
The bcm_host_init() function must be called
@@ -14,7 +14,7 @@ local lib = ffi.load("bcm_host");
require "bcm_host"
--]]
-lib.bcm_host_init();
+bcm_host_lib.bcm_host_init();
@@ -36,7 +36,9 @@ local GetDisplaySize = function(display_number)
end
return {
+ -- Libraries
Lib = lib,
+ bcm_host_lib = bcm_host_lib,
GetDisplaySize = GetDisplaySize,
}
View
@@ -4,6 +4,7 @@ local bit = require "bit"
local lshift = bit.lshift
local rshift = bit.rshift
local band = bit.band
+local bor = bit.bor
local bnot = bit.bnot
-- Display manager service API
@@ -327,6 +328,18 @@ DMXDisplay_mt = {
return element
end,
+ CreateView = function(self, width, height, x, y, level, pFormat, opacity)
+ x = x or 0
+ y = y or 0
+ level = level or 0
+ pformat = pformat or ffi.C.VC_IMAGE_RGB565
+
+ resource = resource or DMXResource(width, height, pformat);
+
+ local win = DisplayManX.DMXView.new(self, x, y, width, height, layer, pformat, resource, opacity)
+
+ return win;
+ end,
GetInfo = function(self)
return DisplayManX.get_info(self.Handle);
@@ -515,12 +528,13 @@ local DMXView_mt = {
__index = DMXView,
}
-DMXView.new = function(display, x, y, width, height, layer, pformat, resource)
+DMXView.new = function(display, x, y, width, height, layer, pformat, resource, opacity)
x = x or 0
y = y or 0
layer = layer or 0
pformat = pformat or ffi.C.VC_IMAGE_RGB565
resource = resource or DMXResource(width, height, pformat);
+ opacity = opacity or 1.0;
local obj = {
X = x;
@@ -530,6 +544,7 @@ DMXView.new = function(display, x, y, width, height, layer, pformat, resource)
Resource = resource;
Layer = layer;
Display = display;
+ Opacity = opacity;
}
setmetatable(obj, DMXView_mt);
@@ -553,9 +568,15 @@ DMXView.Hide = function(self)
end
DMXView.Show = function(self)
- local dst_rect = VC_RECT_T(self.X, self.Y, self.Width, self.Height);
- local src_rect = VC_RECT_T( 0, 0, lshift(self.Width, 16), lshift(self.Height, 16) );
- self.Surface = self.Display:CreateElement(dst_rect, self.Resource, src_rect, self.Layer, DISPMANX_PROTECTION_NONE, alpha);
+ local dst_rect = VC_RECT_T(self.X, self.Y, self.Width, self.Height);
+ local src_rect = VC_RECT_T( 0, 0, lshift(self.Width, 16), lshift(self.Height, 16) );
+
+ local alpha = nil;
+ if self.Opacity and self.Opacity >= 0 and self.Opacity < 1.0 then
+ alpha = VC_DISPMANX_ALPHA_T( bor(ffi.C.DISPMANX_FLAGS_ALPHA_FROM_SOURCE, ffi.C.DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS), self.Opacity * 255, 0 );
+ end
+
+ self.Surface = self.Display:CreateElement(dst_rect, self.Resource, src_rect, self.Layer, DISPMANX_PROTECTION_NONE, alpha);
end
View
@@ -0,0 +1,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;
View
@@ -10,15 +10,19 @@ int32_t graphics_get_display_size( const uint16_t display_number, uint32_t *widt
]]
require "libc"
+
require "interface/vc_dispmanx"
require "interface/vc_tvservice"
+require "interface/vcgencmd"
--[[
require "interface/vmcs_host/vc_cec"
require "interface/vmcs_host/vc_cecservice"
-require "interface/vmcs_host/vcgencmd"
--]]
+return {
+
+}
View
@@ -70,21 +70,18 @@ int vc_tv_hdmi_power_on_best_3d(uint32_t width, uint32_t height, uint32_t frame_
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);
+ 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_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_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);
View
@@ -4,25 +4,23 @@
local ffi = require "ffi"
-
-#include "interface/vmcs_host/vchi_local/vchost_config.h"
-#include "interface/vchi/vchi.h"
+require "vchi"
ffi.cdef[[
-VCHPRE_ void VCHPOST_ vc_vchi_gencmd_init(VCHI_INSTANCE_T initialise_instance, VCHI_CONNECTION_T **connections, uint32_t num_connections );
+void vc_vchi_gencmd_init(VCHI_INSTANCE_T initialise_instance, VCHI_CONNECTION_T **connections, uint32_t num_connections );
/* Initialise general command service. Returns it's interface number. This initialises
the host side of the interface, it does not send anything to VideoCore. */
-VCHPRE_ int VCHPOST_ vc_gencmd_init(void);
+int vc_gencmd_init(void);
/* Stop the service from being used. */
-VCHPRE_ void VCHPOST_ vc_gencmd_stop(void);
+void vc_gencmd_stop(void);
/* Return the service number (-1 if not running). */
-VCHPRE_ int VCHPOST_ vc_gencmd_inum(void);
+int vc_gencmd_inum(void);
/******************************************************************************
Send commands to VideoCore.
@@ -32,37 +30,37 @@ sent.
******************************************************************************/
/* send command to general command serivce */
-VCHPRE_ int VCHPOST_ vc_gencmd_send( const char *format, ... );
+int vc_gencmd_send( const char *format, ... );
/* get resonse from general command serivce */
-VCHPRE_ int VCHPOST_ vc_gencmd_read_response(char *response, int maxlen);
+int vc_gencmd_read_response(char *response, int maxlen);
/* convenience function to send command and receive the response */
-VCHPRE_ int VCHPOST_ vc_gencmd(char *response, int maxlen, const char *format, ...);
+int vc_gencmd(char *response, int maxlen, const char *format, ...);
/* read part of a response from the general command service */
-VCHPRE_ int VCHPOST_ vc_gencmd_read_response_partial(char *response, int nbytes);
+int vc_gencmd_read_response_partial(char *response, int nbytes);
/* if reading with vc_gencmd_read_response_partial end response reads with this */
-VCHPRE_ int VCHPOST_ vc_gencmd_close_response_partial(void);
+int vc_gencmd_close_response_partial(void);
/* get state of reading of response */
-VCHPRE_ int VCHPOST_ vc_gencmd_read_partial_state(void);
+int vc_gencmd_read_partial_state(void);
/******************************************************************************
Utilities to help interpret the responses.
******************************************************************************/
/* Read the value of a property=value type pair from a string (typically VideoCore's
response to a general command). Return non-zero if found. */
-VCHPRE_ int VCHPOST_ vc_gencmd_string_property(char *text, const char *property, char **value, int *length);
+int vc_gencmd_string_property(char *text, const char *property, char **value, int *length);
/* Read the numeric value of a property=number field from a response string. Return
non-zero if found. */
-VCHPRE_ int VCHPOST_ vc_gencmd_number_property(char *text, const char *property, int *number);
+int vc_gencmd_number_property(char *text, const char *property, int *number);
/* Send a command until the desired response is received, the error message is detected, or the timeout */
-VCHPRE_ int VCHPOST_ vc_gencmd_until( char *cmd,
+int vc_gencmd_until( char *cmd,
const char *property,
char *value,
const char *error_string,
Oops, something went wrong.

0 comments on commit ea20494

Please sign in to comment.