Skip to content
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...
1 parent 204845a commit ea20494721bb904f7a9c0d0f6f3a572b15e0111e @Wiladams committed Oct 21, 2012
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
8 BcmHost.lua
@@ -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
29 DisplayManX.lua
@@ -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
162 TVService.lua
@@ -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
6 bcm_host.lua
@@ -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
15 interface/vc_tvservice.lua
@@ -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
30 interface/vcgencmd.lua
@@ -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,
View
76 interface/vchi.lua
@@ -165,31 +165,31 @@ typedef struct service_info_tag {
--]]
ffi.cdef[[
-extern VCHI_CONNECTION_T * vchi_create_connection( const VCHI_CONNECTION_API_T * function_table,
+VCHI_CONNECTION_T * vchi_create_connection( const VCHI_CONNECTION_API_T * function_table,
const VCHI_MESSAGE_DRIVER_T * low_level);
// Routine used to initialise the vchi on both local + remote connections
-extern int32_t vchi_initialise( VCHI_INSTANCE_T *instance_handle );
+int32_t vchi_initialise( VCHI_INSTANCE_T *instance_handle );
-extern int32_t vchi_exit( void );
+int32_t vchi_exit( void );
-extern int32_t vchi_connect( VCHI_CONNECTION_T **connections,
+int32_t vchi_connect( VCHI_CONNECTION_T **connections,
const uint32_t num_connections,
VCHI_INSTANCE_T instance_handle );
//When this is called, ensure that all services have no data pending.
//Bulk transfers can remain 'queued'
-extern int32_t vchi_disconnect( VCHI_INSTANCE_T instance_handle );
+int32_t vchi_disconnect( VCHI_INSTANCE_T instance_handle );
// Global control over bulk CRC checking
-extern int32_t vchi_crc_control( VCHI_CONNECTION_T *connection,
+int32_t vchi_crc_control( VCHI_CONNECTION_T *connection,
VCHI_CRC_CONTROL_T control );
// helper functions
-extern void * vchi_allocate_buffer(VCHI_SERVICE_HANDLE_T handle, uint32_t *length);
-extern void vchi_free_buffer(VCHI_SERVICE_HANDLE_T handle, void *address);
-extern uint32_t vchi_current_time(VCHI_INSTANCE_T instance_handle);
+void * vchi_allocate_buffer(VCHI_SERVICE_HANDLE_T handle, uint32_t *length);
+void vchi_free_buffer(VCHI_SERVICE_HANDLE_T handle, void *address);
+uint32_t vchi_current_time(VCHI_INSTANCE_T instance_handle);
]]
ffi.cdef[[
@@ -280,39 +280,39 @@ ffi.cdef[[
*****************************************************************************/
// Routine to get the address of a held message
-extern void *vchi_held_msg_ptr( const VCHI_HELD_MSG_T *message );
+void *vchi_held_msg_ptr( const VCHI_HELD_MSG_T *message );
// Routine to get the size of a held message
-extern int32_t vchi_held_msg_size( const VCHI_HELD_MSG_T *message );
+int32_t vchi_held_msg_size( const VCHI_HELD_MSG_T *message );
// Routine to get the transmit timestamp as written into the header by the peer
-extern uint32_t vchi_held_msg_tx_timestamp( const VCHI_HELD_MSG_T *message );
+uint32_t vchi_held_msg_tx_timestamp( const VCHI_HELD_MSG_T *message );
// Routine to get the reception timestamp, written as we parsed the header
-extern uint32_t vchi_held_msg_rx_timestamp( const VCHI_HELD_MSG_T *message );
+uint32_t vchi_held_msg_rx_timestamp( const VCHI_HELD_MSG_T *message );
// Routine to release a held message after it has been processed
-extern int32_t vchi_held_msg_release( VCHI_HELD_MSG_T *message );
+int32_t vchi_held_msg_release( VCHI_HELD_MSG_T *message );
// Indicates whether the iterator has a next message.
-extern vcos_bool_t vchi_msg_iter_has_next( const VCHI_MSG_ITER_T *iter );
+vcos_bool_t vchi_msg_iter_has_next( const VCHI_MSG_ITER_T *iter );
// Return the pointer and length for the next message and advance the iterator.
-extern int32_t vchi_msg_iter_next( VCHI_MSG_ITER_T *iter,
+int32_t vchi_msg_iter_next( VCHI_MSG_ITER_T *iter,
void **data,
uint32_t *msg_size );
// Remove the last message returned by vchi_msg_iter_next.
// Can only be called once after each call to vchi_msg_iter_next.
-extern int32_t vchi_msg_iter_remove( VCHI_MSG_ITER_T *iter );
+int32_t vchi_msg_iter_remove( VCHI_MSG_ITER_T *iter );
// Hold the last message returned by vchi_msg_iter_next.
// Can only be called once after each call to vchi_msg_iter_next.
-extern int32_t vchi_msg_iter_hold( VCHI_MSG_ITER_T *iter,
+int32_t vchi_msg_iter_hold( VCHI_MSG_ITER_T *iter,
VCHI_HELD_MSG_T *message );
// Return information for the next message, and hold it, advancing the iterator.
-extern int32_t vchi_msg_iter_hold_next( VCHI_MSG_ITER_T *iter,
+int32_t vchi_msg_iter_hold_next( VCHI_MSG_ITER_T *iter,
void **data, // } may be NULL
uint32_t *msg_size, // }
VCHI_HELD_MSG_T *message );
@@ -324,7 +324,7 @@ ffi.cdef[[
*****************************************************************************/
// Routine to prepare interface for a transfer from the other side
-extern int32_t vchi_bulk_queue_receive( VCHI_SERVICE_HANDLE_T handle,
+int32_t vchi_bulk_queue_receive( VCHI_SERVICE_HANDLE_T handle,
void *data_dst,
uint32_t data_size,
VCHI_FLAGS_T flags,
@@ -340,7 +340,7 @@ int32_t vchi_bulk_queue_receive_reloc( const VCHI_SERVICE_HANDLE_T handle,
void * const bulk_handle );
// Routine to queue up data ready for transfer to the other (once they have signalled they are ready)
-extern int32_t vchi_bulk_queue_transmit( VCHI_SERVICE_HANDLE_T handle,
+int32_t vchi_bulk_queue_transmit( VCHI_SERVICE_HANDLE_T handle,
const void *data_src,
uint32_t data_size,
VCHI_FLAGS_T flags,
@@ -353,7 +353,7 @@ ffi.cdef[[
*****************************************************************************/
// function prototypes for the different mid layers (the state info gives the different physical connections)
-extern const VCHI_CONNECTION_API_T *single_get_func_table( void );
+const VCHI_CONNECTION_API_T *single_get_func_table( void );
//extern const VCHI_CONNECTION_API_T *local_server_get_func_table( void );
//extern const VCHI_CONNECTION_API_T *local_client_get_func_table( void );
@@ -362,37 +362,15 @@ const VCHI_MESSAGE_DRIVER_T *vchi_mphi_message_driver_func_table( void );
]]
ffi.cdef[[
-extern int32_t vchi_bulk_queue_transmit_reloc( VCHI_SERVICE_HANDLE_T handle,
+int32_t vchi_bulk_queue_transmit_reloc( VCHI_SERVICE_HANDLE_T handle,
VCHI_MEM_HANDLE_T h_src,
uint32_t offset,
uint32_t data_size,
VCHI_FLAGS_T flags,
void *transfer_handle );
]]
---[[
-Copyright (c) 2012, Broadcom Europe Ltd
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- * Neither the name of the copyright holder nor the
- names of its contributors may be used to endorse or promote products
- derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
-DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---]]
+
+return {
+ Lib = ffi.load("vchiq_arm"),
+}
View
3 interface/vcos.lua
@@ -56,7 +56,8 @@ require "../vcos/vcos_cmd.h"
local vcos_Lib = ffi.load("vcos");
-vcos_Lib.vcos_init();
+local result = vcos_Lib.vcos_init();
+print("VCOS INIT: ", result);
return {
Lib = vcos_Lib;
View
2 libc.lua
@@ -2,9 +2,11 @@ local ffi = require "ffi"
ffi.cdef[[
int sleep(int millis);
+//int nanosleep(const struct timespec *req, struct timespec *rem);
int open(const char *path, int flags, int mode);
int close(int fd);
+size_t write(int fildes, const void *buf, size_t nbytes);
void *mmap(void *addr, size_t length, int prot, int flags, int fd, size_t ofs);
int munmap(void *addr, size_t length);
View
3 rpiui.lua
@@ -4,6 +4,8 @@ local ffi = require "ffi"
local BCMHost = require "BcmHost"
+local vchiq_arm_Lib = ffi.load("vchiq_arm");
+
--[[
GLESv2 must be loaded before EGL or there will be
an error:
@@ -22,7 +24,6 @@ local OpenVG = require "OpenVG_Utils";
--local mmal_Lib = ffi.load("mmal");
--local openmaxil_Lib = ffi.load("openmaxil");
---local vchiq_arm_Lib = ffi.load("vchiq_arm");
--local WFC_Lib = ffi.load("WFC");
View
2 test_dispmanx.lua
@@ -50,7 +50,7 @@ FillRect( pbuff, 40, 40, width - 80, height - 80, 0x001F );
-- local alpha = VC_DISPMANX_ALPHA_T( bor(ffi.C.DISPMANX_FLAGS_ALPHA_FROM_SOURCE, ffi.C.DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS), 120, 0 );
-local mainView = DMX.DMXView.new(Display, (info.width - width ) / 2, ( info.height - height ) / 2, width, height);
+mainView = Display:CreateView(width, height, 0, info.height-height, nil, nil, 0.5);
mainView:CopyPixelBuffer(pbuff, 0, 0, width, height);
ffi.C.sleep( 2 )
View
53 test_picast.lua
@@ -0,0 +1,53 @@
+
+local ffi = require "ffi"
+local DMX = require "DisplayManX"
+
+local Display = DMXDisplay();
+local screenWidth, screenHeight = Display:GetSize();
+local ratio = screenWidth / screenHeight;
+local displayHeight = 70;
+local displayWidth = displayHeight * ratio;
+
+
+-- Create the view that will display the snapshot
+local displayView = Display:CreateView(displayWidth, displayHeight, 0, screenHeight-displayHeight-1)
+
+
+
+local function WritePPM(filename, pixbuff)
+ local r, c, val;
+
+ local fp = io.open(filename, "wb")
+ if not fp then
+ return false
+ end
+
+ local header = string.format("P6\n%d %d\n255\n", pixbuff.Width, pixbuff.Height)
+ fp:write(header);
+
+ local data = ffi.string(pixbuff.Data, pixbuff.Width*pixbuff.Height * 3);
+ fp:write(data);
+
+
+--[[
+ for r = 0, pixbuff.Height-1 do
+ for c = 0, pixbuff.Width-1 do
+ local offset = (r*pixbuff.Width)+c
+ local pix = pixbuff.Data[offset]:ToArray();
+ fp:write(pix);
+ end
+ end
+--]]
+
+ fp:close();
+end
+
+-- Do the snapshot
+displayView:Hide();
+Display:Snapshot(displayView.Resource);
+displayView:Show();
+
+ffi.C.sleep(5);
+
+--WritePPM("desktop_"..i..".ppm", pixmap);
+
View
26 test_snapshot.lua
@@ -3,25 +3,21 @@ local ffi = require "ffi"
local DMX = require "DisplayManX"
local Display = DMXDisplay();
+local screenWidth, screenHeight = Display:GetSize();
+local ratio = screenWidth / screenHeight;
+local displayHeight = 70;
+local displayWidth = displayHeight * ratio;
-local width = 640;
-local height = 480;
-local layer = 0; -- keep the snapshot view on top
--- Create a resource to copy image into
-local pixmap = DMX.DMXResource(width,height);
+-- Create the view that will display the snapshot
+local displayView = Display:CreateView(displayWidth, displayHeight, 0, screenHeight-displayHeight-1)
--- create a view with the snapshot as
--- the backing store
-local mainView = DMX.DMXView.new(Display, 200, 200, width, height, layer, pformat, pixmap);
-for i=1,20 do
- -- Do the snapshot
- mainView:Hide();
- Display:Snapshot(pixmap);
- mainView:Show();
+-- Do the snapshot
+displayView:Hide();
+Display:Snapshot(displayView.Resource);
+displayView:Show();
- ffi.C.sleep(1);
+ffi.C.sleep(5);
-end
View
0 test_tv_service.lua
No changes.

0 comments on commit ea20494

Please sign in to comment.
Something went wrong with that request. Please try again.