Commit 61cd2b0a authored by Christophe Massiot's avatar Christophe Massiot

* QNX RTOS plug-in by Jon Lech Johansen.

parent 9727b87f
......@@ -127,6 +127,7 @@ N: Jon Lech Johansen
E: jon-vl@nanocrew.net
D: PS input fixes
D: Win32 DVD input port
D: QNX RTOS plug-in
N: Michel Kaempf
E: maxx@via.ecp.fr
......
......@@ -63,6 +63,7 @@ HEAD
* Kludged so that times displayed in the scrollbar are finally correct
for MPEG-2 streams.
* FreeBSD compilation fix by Øyvind Kolbu.
* QNX RTOS plug-in by Jon Lech Johansen.
0.2.80
Tue, 5 Jun 2001 04:41:06 +0200
......
......@@ -74,6 +74,7 @@ LIB_GTK = @LIB_GTK@
LIB_IDCTALTIVEC = @LIB_IDCTALTIVEC@
LIB_KDE = @LIB_KDE@
LIB_MACOSX = @LIB_MACOSX@
LIB_QNX = @LIB_QNX@
LIB_NCURSES = @LIB_NCURSES@
LIB_QT = @LIB_QT@
LIB_TS = @LIB_TS@
......
This diff is collapsed.
......@@ -412,6 +412,18 @@ AC_ARG_ENABLE(macosx,
LIB_SDL="${LIB_SDL} -framework AGL -framework Carbon"
)])
dnl
dnl QNX RTOS module
dnl
AC_ARG_ENABLE(qnx,
[ --disable-qnx QNX RTOS support (default enabled)])
if test x$enable_qnx != xno; then
AC_CHECK_HEADERS(Ph.h, [
PLUGINS="${PLUGINS} qnx"
LIB_QNX="-lasound -lph"
])
fi
dnl
dnl Linux framebuffer module
dnl
......@@ -656,6 +668,7 @@ AC_SUBST(LIB_GTK)
AC_SUBST(LIB_IDCTALTIVEC)
AC_SUBST(LIB_KDE)
AC_SUBST(LIB_MACOSX)
AC_SUBST(LIB_QNX)
AC_SUBST(LIB_NCURSES)
AC_SUBST(LIB_QT)
AC_SUBST(LIB_TS)
......
......@@ -2,7 +2,7 @@
* ioctl.c: DVD ioctl replacement function
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: ioctl.c,v 1.3 2001/06/25 11:34:08 sam Exp $
* $Id: ioctl.c,v 1.4 2001/07/19 11:50:50 massiot Exp $
*
* Authors: Markus Kuespert <ltlBeBoy@beosmail.com>
* Samuel Hocevar <sam@zoy.org>
......@@ -168,6 +168,16 @@ int ioctl_ReadCopyright( int i_fd, int i_layer, int *pi_copyright )
*pi_copyright = p_buffer[ 4 ];
}
#elif defined( __QNXNTO__ )
/*
QNX RTOS currently doesn't have a CAM
interface (they're working on it though).
Assume DVD is not encrypted.
*/
*pi_copyright = 0;
i_ret = 0;
#else
/* DVD ioctls unavailable - do as if the ioctl failed */
i_ret = -1;
......
/* include/defs.h.in. Generated automatically from configure.in by autoheader 2.13. */
/* include/defs.h.in. Generated automatically from configure.in by autoheader. */
/* Define to empty if the keyword does not work. */
#undef const
......@@ -61,6 +61,9 @@
/* Define if you have the <Carbon/Carbon.h> header file. */
#undef HAVE_CARBON_CARBON_H
/* Define if you have the <Ph.h> header file. */
#undef HAVE_PH_H
/* Define if you have the <SDL/SDL.h> header file. */
#undef HAVE_SDL_SDL_H
......
###############################################################################
# vlc (VideoLAN Client) QNX RTOS module Makefile
# (c)2001 VideoLAN
###############################################################################
#
# Objects
#
PLUGIN_C = qnx.o aout_qnx.o vout_qnx.o
BUILTIN_C = $(PLUGIN_C:%.o=BUILTIN_%.o)
ALL_OBJ = $(PLUGIN_C) $(BUILTIN_C)
#
# Virtual targets
#
include ../../Makefile.modules
#
# Real targets
#
../../plugins/qnx.so: $(PLUGIN_C)
$(CC) $(PCFLAGS) -o $@ $^ $(PLCFLAGS) $(LIB_QNX)
../../plugins/qnx.a: $(BUILTIN_C)
ar r $@ $^
/*****************************************************************************
* aout_qnx.c : Alsa functions library
*****************************************************************************
* Copyright (C) 2000 VideoLAN
*
* Authors: Henri Fallon <henri@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#define MODULE_NAME qnx
#include "modules_inner.h"
/*****************************************************************************
* Preamble
*****************************************************************************/
#include "defs.h"
#include <errno.h> /* ENOMEM */
#include <string.h> /* strerror() */
#include <stdio.h> /* "intf_msg.h" */
#include <stdlib.h> /* calloc(), malloc(), free() */
#include <sys/asoundlib.h>
#include "config.h"
#include "common.h" /* boolean_t, byte_t */
#include "threads.h"
#include "mtime.h"
#include "tests.h"
#include "audio_output.h" /* aout_thread_t */
#include "intf_msg.h" /* intf_DbgMsg(), intf_ErrMsg() */
#include "main.h"
#include "modules.h"
#include "modules_export.h"
typedef struct alsa_device_s
{
int i_num;
} alsa_device_t;
typedef struct alsa_card_s
{
int i_num;
} alsa_card_t;
/* here we store plugin dependant informations */
typedef struct aout_sys_s
{
snd_pcm_t * p_alsa_handle;
alsa_device_t s_alsa_device;
alsa_card_t s_alsa_card;
snd_pcm_channel_params_t s_alsa_channel_params;
snd_pcm_format_t s_alsa_format;
} aout_sys_t;
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int aout_Probe ( probedata_t *p_data );
static int aout_Open ( aout_thread_t *p_aout );
static int aout_SetFormat ( aout_thread_t *p_aout );
static long aout_GetBufInfo ( aout_thread_t *p_aout, long l_buffer_info );
static void aout_Play ( aout_thread_t *p_aout,
byte_t *buffer, int i_size );
static void aout_Close ( aout_thread_t *p_aout );
/*****************************************************************************
* Functions exported as capabilities. They are declared as static so that
* we don't pollute the namespace too much.
*****************************************************************************/
void _M( aout_getfunctions )( function_list_t * p_function_list )
{
p_function_list->pf_probe = aout_Probe;
p_function_list->functions.aout.pf_open = aout_Open;
p_function_list->functions.aout.pf_setformat = aout_SetFormat;
p_function_list->functions.aout.pf_getbufinfo = aout_GetBufInfo;
p_function_list->functions.aout.pf_play = aout_Play;
p_function_list->functions.aout.pf_close = aout_Close;
}
/*****************************************************************************
* aout_Probe: probes the audio device and return a score
*****************************************************************************
* This function tries to open the dps and returns a score to the plugin
* manager so that it can make its choice.
*****************************************************************************/
static int aout_Probe( probedata_t *p_data )
{
int i_open_return, i_close_return;
aout_sys_t local_sys;
/* This is the same as the beginning of the aout_Open */
/* Initialize */
local_sys.s_alsa_device.i_num = 0;
local_sys.s_alsa_card.i_num = 0;
/* Open device */
i_open_return = snd_pcm_open( &(local_sys.p_alsa_handle),
local_sys.s_alsa_card.i_num,
local_sys.s_alsa_device.i_num,
SND_PCM_OPEN_PLAYBACK );
if( i_open_return )
{
intf_WarnMsg( 2, "aout info: could not probe ALSA device (%s)",
snd_strerror( i_open_return ) );
return ( 0 );
}
/* Close it */
i_close_return = snd_pcm_close( local_sys.p_alsa_handle );
if( i_close_return )
{
intf_ErrMsg( "aout error: could not close ALSA device (%s)",
snd_strerror( i_close_return ) );
return( 0 );
}
if( TestMethod( AOUT_METHOD_VAR, "qnx" ) )
{
return( 999 );
}
/* And return score */
return( 50 );
}
/*****************************************************************************
* aout_Open : creates a handle and opens an alsa device
*****************************************************************************
* This function opens an alsa device, through the alsa API
*****************************************************************************/
static int aout_Open( aout_thread_t *p_aout )
{
int i_open_returns;
/* Allocate structures */
p_aout->p_sys = malloc( sizeof( aout_sys_t ) );
if( p_aout->p_sys == NULL )
{
intf_ErrMsg( "aout error: failed allocating memory for ALSA (%s)",
strerror(ENOMEM) );
return( 1 );
}
/* Initialize */
p_aout->p_sys->s_alsa_device.i_num = 0;
p_aout->p_sys->s_alsa_card.i_num = 0;
/* FIXME : why not other format ? */
p_aout->i_format = AOUT_FMT_S16_LE;
/* FIXME : why always 2 channels ?*/
p_aout->i_channels = 2;
p_aout->l_rate = main_GetIntVariable( AOUT_RATE_VAR, AOUT_RATE_DEFAULT );
/* Open device */
if( ( i_open_returns = snd_pcm_open( &(p_aout->p_sys->p_alsa_handle),
p_aout->p_sys->s_alsa_card.i_num,
p_aout->p_sys->s_alsa_device.i_num,
SND_PCM_OPEN_PLAYBACK ) ) )
{
intf_ErrMsg( "aout error: could not open ALSA device (%s)",
snd_strerror(i_open_returns) );
return( -1 );
}
intf_DbgMsg( "aout info: ALSA device successfully opened" );
return( 0 );
}
/*****************************************************************************
* aout_SetFormat : sets the alsa output format
*****************************************************************************
* This function prepares the device, sets the rate, format, the mode
* ("play as soon as you have data"), and buffer information.
*****************************************************************************/
static int aout_SetFormat( aout_thread_t *p_aout )
{
int i_set_param_returns;
int i_prepare_playback_returns;
int i_playback_go_returns;
/* Fill with zeros */
memset( &p_aout->p_sys->s_alsa_channel_params, 0,
sizeof( p_aout->p_sys->s_alsa_channel_params ) );
/* Fill the s_alsa_channel_params structure */
/* Tranfer mode and direction*/
p_aout->p_sys->s_alsa_channel_params.channel = SND_PCM_CHANNEL_PLAYBACK ;
p_aout->p_sys->s_alsa_channel_params.mode = SND_PCM_MODE_STREAM;
/* Format and rate */
p_aout->p_sys->s_alsa_channel_params.format.interleave = 1;
if( p_aout->i_format == AOUT_FMT_S16_LE )
{
p_aout->p_sys->s_alsa_channel_params.format.format =
SND_PCM_SFMT_S16_LE;
}
else
{
p_aout->p_sys->s_alsa_channel_params.format.format =
SND_PCM_SFMT_S16_BE;
}
p_aout->p_sys->s_alsa_channel_params.format.rate = p_aout->l_rate;
p_aout->p_sys->s_alsa_channel_params.format.voices = p_aout->i_channels ;
/* When to start playing and when to stop */
p_aout->p_sys->s_alsa_channel_params.start_mode = SND_PCM_START_DATA;
p_aout->p_sys->s_alsa_channel_params.stop_mode = SND_PCM_STOP_STOP;
/* Buffer information . I have chosen the stream mode here
* instead of the block mode. I don't know whether i'm wrong
* but it seemed more logical */
/* TODO : find the best value to put here. Probably depending
* on many parameters */
p_aout->p_sys->s_alsa_channel_params.buf.stream.queue_size = 131072;
p_aout->p_sys->s_alsa_channel_params.buf.stream.fill = SND_PCM_FILL_NONE ;
p_aout->p_sys->s_alsa_channel_params.buf.stream.max_fill = 0 ;
/* Now we pass this to the driver */
i_set_param_returns = snd_pcm_channel_params(
p_aout->p_sys->p_alsa_handle,
&(p_aout->p_sys->s_alsa_channel_params) );
if( i_set_param_returns )
{
intf_ErrMsg( "aout error: unable to set parameters (%s)",
snd_strerror( i_set_param_returns ) );
return( -1 );
}
/* we shall now prepare the channel */
i_prepare_playback_returns =
snd_pcm_playback_prepare( p_aout->p_sys->p_alsa_handle );
if( i_prepare_playback_returns )
{
intf_ErrMsg( "aout error: unable to prepare channel (%s)",
snd_strerror( i_set_param_returns ) );
return( -1 );
}
/* then we may go */
i_playback_go_returns =
snd_pcm_playback_go( p_aout->p_sys->p_alsa_handle );
if( i_playback_go_returns )
{
intf_ErrMsg( "aout error: unable to prepare channel (bis) (%s)",
snd_strerror( i_set_param_returns ) );
return( -1 );
}
p_aout->i_latency = 0;
return( 0 );
}
/*****************************************************************************
* aout_BufInfo: buffer status query
*****************************************************************************
* This function returns the number of used byte in the queue.
* It also deals with errors : indeed if the device comes to run out
* of data to play, it switches to the "underrun" status. It has to
* be flushed and re-prepared
*****************************************************************************/
static long aout_GetBufInfo( aout_thread_t *p_aout, long l_buffer_limit )
{
snd_pcm_channel_status_t alsa_channel_status;
int i_alsa_get_status_returns;
memset( &alsa_channel_status, 0, sizeof( alsa_channel_status ) );
i_alsa_get_status_returns = snd_pcm_channel_status(
p_aout->p_sys->p_alsa_handle, &alsa_channel_status );
if( i_alsa_get_status_returns )
{
intf_ErrMsg( "aout error: failed getting alsa buffer info (%s)",
snd_strerror ( i_alsa_get_status_returns ) );
return( -1 );
}
switch( alsa_channel_status.status )
{
case SND_PCM_STATUS_NOTREADY:
{
intf_ErrMsg( "aout error: status NOT READY" );
break;
}
case SND_PCM_STATUS_UNDERRUN:
{
int i_prepare_returns;
intf_ErrMsg( "aout error: status UNDERRUN ... resetting queue ");
i_prepare_returns = snd_pcm_playback_prepare(
p_aout->p_sys->p_alsa_handle );
if ( i_prepare_returns )
{
intf_ErrMsg( "aout error: could not flush (%s)",
snd_strerror(i_prepare_returns) );
}
break;
}
}
return( alsa_channel_status.count );
}
/*****************************************************************************
* aout_Play : plays a sample
*****************************************************************************
* Plays a sample using the snd_pcm_write function from the alsa API
*****************************************************************************/
static void aout_Play( aout_thread_t *p_aout, byte_t *buffer, int i_size )
{
int i_write_returns;
i_write_returns = (int) snd_pcm_write (
p_aout->p_sys->p_alsa_handle, (void *) buffer, (size_t) i_size );
if( i_write_returns <= 0 )
{
intf_ErrMsg( "aout error: writing blocks failed (%s)",
snd_strerror( i_write_returns ) );
}
}
/*****************************************************************************
* aout_Close : close the Alsa device
*****************************************************************************/
static void aout_Close( aout_thread_t *p_aout )
{
int i_close_returns;
i_close_returns = snd_pcm_close( p_aout->p_sys->p_alsa_handle );
if( i_close_returns )
{
intf_ErrMsg( "aout error: failed closing ALSA device (%s)",
snd_strerror( i_close_returns ) );
}
free( p_aout->p_sys );
intf_DbgMsg( "aout: ALSA device closed" );
}
/*****************************************************************************
* qnx.c : QNX RTOS plugin for vlc
*****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#define MODULE_NAME qnx
#include "modules_inner.h"
/*****************************************************************************
* Preamble
*****************************************************************************/
#include "defs.h"
#include <stdlib.h> /* malloc(), free() */
#include "config.h"
#include "common.h" /* boolean_t, byte_t */
#include "threads.h"
#include "mtime.h"
#include "video.h"
#include "video_output.h"
#include "modules.h"
#include "modules_export.h"
/*****************************************************************************
* Capabilities defined in the other files.
******************************************************************************/
void _M( aout_getfunctions )( function_list_t * p_function_list );
void _M( vout_getfunctions )( function_list_t * p_function_list );
/*****************************************************************************
* Building configuration tree
*****************************************************************************/
MODULE_CONFIG_START
ADD_WINDOW( "Configuration for QNX RTOS module" )
ADD_COMMENT( "For now, the QNX RTOS module cannot be configured" )
MODULE_CONFIG_STOP
MODULE_INIT_START
p_module->psz_longname = "QNX RTOS module";
p_module->i_capabilities = MODULE_CAPABILITY_NULL
| MODULE_CAPABILITY_AOUT
| MODULE_CAPABILITY_VOUT;
MODULE_INIT_STOP
MODULE_ACTIVATE_START
_M( aout_getfunctions )( &p_module->p_functions->aout );
_M( vout_getfunctions )( &p_module->p_functions->vout );
MODULE_ACTIVATE_STOP
MODULE_DEACTIVATE_START
MODULE_DEACTIVATE_STOP
/*****************************************************************************
* vout_qnx.c: QNX RTOS video output display method
*****************************************************************************
* Copyright (C) 2001 VideoLAN
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#define MODULE_NAME qnx
#include "modules_inner.h"
/*****************************************************************************
* Preamble
*****************************************************************************/
#include "defs.h"
#include <errno.h> /* ENOMEM */
#include <stdlib.h> /* free() */
#include <string.h> /* strerror() */
#include <photon/PtWidget.h>
#include <photon/PtWindow.h>
#include <photon/PtLabel.h>
#include <photon/PdDirect.h>
#include "config.h"
#include "common.h"
#include "threads.h"
#include "mtime.h"
#include "tests.h"
#include "video.h"
#include "video_output.h"
#include "interface.h"
#include "intf_msg.h"
#include "main.h"
#include "modules.h"
#include "modules_export.h"
/*****************************************************************************
* vout_sys_t: video output QNX method descriptor
*****************************************************************************
* This structure is part of the video output thread descriptor.
* It describes the QNX specific properties of an output thread. QNX video
* output is performed through regular resizable windows. Windows can be
* dynamically resized to adapt to the size of the streams.
*****************************************************************************/
#define MODE_NORMAL_MEM 0
#define MODE_SHARED_MEM 1
#define MODE_VIDEO_MEM 2
#define MODE_VIDEO_OVERLAY 3
typedef struct vout_sys_s
{
/* video mode */
int i_mode;
/* internal stuff */
PtWidget_t * p_window;
/* [shared] memory blit */
PhImage_t * p_image[2];
int i_img_type;
/* video memory blit */
PdOffscreenContext_t * p_ctx[2];
char * p_buf[2];
/* video overlay */
PgVideoChannel_t * p_channel;
void * p_vc_y[2];
void * p_vc_u[2];
void * p_vc_v[2];
int i_vc_flags;
int i_vc_format;
/* position & dimensions */
PhPoint_t pos;
PhDim_t dim;
PhDim_t old_dim;
PhDim_t screen_dim;
} vout_sys_t;
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int vout_Probe ( probedata_t *p_data );
static int vout_Create ( struct vout_thread_s * );
static int vout_Init ( struct vout_thread_s * );
static void vout_End ( struct vout_thread_s * );
static void vout_Destroy ( struct vout_thread_s * );
static int vout_Manage ( struct vout_thread_s * );
static void vout_Display ( struct vout_thread_s * );
static int QNXCreateWnd ( struct vout_thread_s * );
static int QNXDestroyWnd ( struct vout_thread_s * );
static int QNXInitDisplay ( struct vout_thread_s * );
/*****************************************************************************
* Functions exported as capabilities. They are declared as static so that
* we don't pollute the namespace too much.
*****************************************************************************/
void _M( vout_getfunctions )( function_list_t * p_function_list )
{
p_function_list->pf_probe = vout_Probe;
p_function_list->functions.vout.pf_create = vout_Create;
p_function_list->functions.vout.pf_init = vout_Init;
p_function_list->functions.vout.pf_end = vout_End;
p_function_list->functions.vout.pf_destroy = vout_Destroy;
p_function_list->functions.vout.pf_manage = vout_Manage;
p_function_list->functions.vout.pf_display = vout_Display;
p_function_list->functions.vout.pf_setpalette = NULL;
}
/*****************************************************************************
* vout_Probe: probe the video driver and return a score
*****************************************************************************
* This function tries to initialize SDL and returns a score to the
* plugin manager so that it can select the best plugin.
*****************************************************************************/
static int vout_Probe( probedata_t *p_data )
{
if( TestMethod( VOUT_METHOD_VAR, "qnx" ) )
{
return( 999 );
}
return( 100 );
}
/*****************************************************************************
* vout_Create: allocate QNX video thread output method
*****************************************************************************
* This function allocate and initialize a QNX vout method. It uses some of the
* vout properties to choose the window size, and change them according to the
* actual properties of the display.
*****************************************************************************/
static int vout_Create( vout_thread_t *p_vout )
{
/* init connection to photon */
if( PtInit( "/dev/photon" ) != 0 )
{
intf_ErrMsg( "vout error: unable to connect to photon" );
return( 1 );
}
/* allocate structure */
p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
if( p_vout->p_sys == NULL )
{
intf_ErrMsg( "vout error: %s", strerror( ENOMEM ) );
return( 1 );
}
memset( p_vout->p_sys, 0, sizeof( vout_sys_t ) );
p_vout->b_fullscreen =
main_GetIntVariable( VOUT_FULLSCREEN_VAR, VOUT_FULLSCREEN_DEFAULT );
p_vout->p_sys->i_mode =