libspark: make cVideo build

Again, make it build -- not work. Lots of stuff simply stubbed out.
This commit is contained in:
Stefan Seyfried
2012-02-05 18:41:52 +01:00
parent 66e1d198a9
commit 7d80781154
3 changed files with 138 additions and 69 deletions

View File

@@ -22,5 +22,6 @@ endif
if BOXTYPE_SPARK if BOXTYPE_SPARK
SUBDIRS += libspark SUBDIRS += libspark
libstb_hal_a_LIBADD += \ libstb_hal_a_LIBADD += \
libspark/audio.o libspark/audio.o \
libspark/video.o
endif endif

View File

@@ -29,11 +29,9 @@
#include <pthread.h> #include <pthread.h>
#include <avs/avs_inf.h> #include <linux/dvb/video.h>
#include <clip/clipinfo.h>
#include "video_lib.h" #include "video_lib.h"
#include <hardware/tddevices.h> #define VIDEO_DEVICE "/dev/dvb/adapter0/video0"
#define VIDEO_DEVICE "/dev/" DEVICE_NAME_VIDEO
#include "lt_debug.h" #include "lt_debug.h"
#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_VIDEO, this, args) #define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_VIDEO, this, args)
#define lt_info(args...) _lt_info(TRIPLE_DEBUG_VIDEO, this, args) #define lt_info(args...) _lt_info(TRIPLE_DEBUG_VIDEO, this, args)
@@ -53,15 +51,14 @@
cVideo * videoDecoder = NULL; cVideo * videoDecoder = NULL;
int system_rev = 0; int system_rev = 0;
#if 0 #define VIDEO_STREAMTYPE_MPEG2 0
/* this would be necessary for the DirectFB implementation of ShowPicture */ #define VIDEO_STREAMTYPE_MPEG4_H264 1
#include <directfb.h> #define VIDEO_STREAMTYPE_VC1 3
#include <tdgfx/stb04gfx.h> #define VIDEO_STREAMTYPE_MPEG4_Part2 4
extern IDirectFB *dfb; #define VIDEO_STREAMTYPE_VC1_SM 5
extern IDirectFBSurface *dfbdest; #define VIDEO_STREAMTYPE_MPEG1 6
#endif
extern struct Ssettings settings;
static pthread_mutex_t stillp_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t stillp_mutex = PTHREAD_MUTEX_INITIALIZER;
/* debugging hacks */ /* debugging hacks */
@@ -75,8 +72,8 @@ cVideo::cVideo(int, void *, void *)
fcntl(fd, F_SETFD, FD_CLOEXEC); fcntl(fd, F_SETFD, FD_CLOEXEC);
playstate = VIDEO_STOPPED; playstate = VIDEO_STOPPED;
croppingMode = VID_DISPMODE_NORM; //croppingMode = VID_DISPMODE_NORM;
outputformat = VID_OUTFMT_RGBC_SVIDEO; //outputformat = VID_OUTFMT_RGBC_SVIDEO;
scartvoltage = -1; scartvoltage = -1;
z[0] = 100; z[0] = 100;
z[1] = 100; z[1] = 100;
@@ -133,6 +130,8 @@ cVideo::~cVideo(void)
int cVideo::setAspectRatio(int aspect, int mode) int cVideo::setAspectRatio(int aspect, int mode)
{ {
return 1;
#if 0
static int _mode = -1; static int _mode = -1;
static int _aspect = -1; static int _aspect = -1;
vidDispSize_t dsize = VID_DISPSIZE_UNKNOWN; vidDispSize_t dsize = VID_DISPSIZE_UNKNOWN;
@@ -236,20 +235,21 @@ int cVideo::setAspectRatio(int aspect, int mode)
} }
close(avsfd); close(avsfd);
return 0; return 0;
#endif
} }
int cVideo::getAspectRatio(void) int cVideo::getAspectRatio(void)
{ {
VIDEOINFO v; unsigned char buffer[2];
/* this memset silences *TONS* of valgrind warnings */ int n, f;
memset(&v, 0, sizeof(v)); int ratio = 0; // 0 = 4:3, 1 = 16:9
ioctl(fd, MPEG_VID_GET_V_INFO, &v); f = open("/proc/stb/vmpeg/0/aspect", O_RDONLY);
if (v.pel_aspect_ratio < VID_DISPSIZE_4x3 || v.pel_aspect_ratio > VID_DISPSIZE_UNKNOWN) n = read(f, buffer, 2);
{ close(f);
lt_info("%s invalid value %d, returning 0/unknown fd: %d", __FUNCTION__, v.pel_aspect_ratio, fd); if (n > 0)
return 0; ratio = atoi((const char*) buffer);
} return ratio;
/* convert to Coolstream api values. Taken from streaminfo2.cpp */ #if 0
switch (v.pel_aspect_ratio) switch (v.pel_aspect_ratio)
{ {
case VID_DISPSIZE_4x3: case VID_DISPSIZE_4x3:
@@ -261,10 +261,13 @@ int cVideo::getAspectRatio(void)
default: default:
return 0; return 0;
} }
#endif
} }
int cVideo::setCroppingMode(vidDispMode_t format) int cVideo::setCroppingMode(int /*vidDispMode_t format*/)
{ {
return 0;
#if 0
croppingMode = format; croppingMode = format;
const char *format_string[] = { "norm", "letterbox", "unknown", "mode_1_2", "mode_1_4", "mode_2x", "scale", "disexp" }; const char *format_string[] = { "norm", "letterbox", "unknown", "mode_1_2", "mode_1_4", "mode_2x", "scale", "disexp" };
const char *f; const char *f;
@@ -274,35 +277,34 @@ int cVideo::setCroppingMode(vidDispMode_t format)
f = "ILLEGAL format!"; f = "ILLEGAL format!";
lt_debug("%s(%d) => %s\n", __FUNCTION__, format, f); lt_debug("%s(%d) => %s\n", __FUNCTION__, format, f);
return fop(ioctl, MPEG_VID_SET_DISPMODE, format); return fop(ioctl, MPEG_VID_SET_DISPMODE, format);
#endif
} }
int cVideo::Start(void * /*PcrChannel*/, unsigned short /*PcrPid*/, unsigned short /*VideoPid*/, void * /*hChannel*/) int cVideo::Start(void * /*PcrChannel*/, unsigned short /*PcrPid*/, unsigned short /*VideoPid*/, void * /*hChannel*/)
{ {
lt_debug("%s playstate=%d\n", __FUNCTION__, playstate); lt_debug("%s playstate=%d\n", __FUNCTION__, playstate);
#if 0
if (playstate == VIDEO_PLAYING) if (playstate == VIDEO_PLAYING)
return 0; return 0;
if (playstate == VIDEO_FREEZED) /* in theory better, but not in practice :-) */ if (playstate == VIDEO_FREEZED) /* in theory better, but not in practice :-) */
fop(ioctl, MPEG_VID_CONTINUE); fop(ioctl, MPEG_VID_CONTINUE);
#endif
playstate = VIDEO_PLAYING; playstate = VIDEO_PLAYING;
fop(ioctl, MPEG_VID_PLAY); fop(ioctl, VIDEO_SELECT_SOURCE, VIDEO_SOURCE_DEMUX);
return fop(ioctl, MPEG_VID_SYNC_ON, VID_SYNC_AUD); return fop(ioctl, VIDEO_PLAY);
} }
int cVideo::Stop(bool blank) int cVideo::Stop(bool blank)
{ {
lt_debug("%s(%d)\n", __FUNCTION__, blank); lt_debug("%s(%d)\n", __FUNCTION__, blank);
if (blank) playstate = blank ? VIDEO_STOPPED : VIDEO_FREEZED;
{ return fop(ioctl, VIDEO_STOP, blank ? 1 : 0);
playstate = VIDEO_STOPPED;
fop(ioctl, MPEG_VID_STOP);
return setBlank(1);
}
playstate = VIDEO_FREEZED;
return fop(ioctl, MPEG_VID_FREEZE);
} }
int cVideo::setBlank(int) int cVideo::setBlank(int)
{ {
return Stop(1);
#if 0
lt_debug("%s\n", __FUNCTION__); lt_debug("%s\n", __FUNCTION__);
/* The TripleDragon has no VIDEO_SET_BLANK ioctl. /* The TripleDragon has no VIDEO_SET_BLANK ioctl.
instead, you write a black still-MPEG Iframe into the decoder. instead, you write a black still-MPEG Iframe into the decoder.
@@ -348,14 +350,18 @@ int cVideo::setBlank(int)
out: out:
pthread_mutex_unlock(&stillp_mutex); pthread_mutex_unlock(&stillp_mutex);
return ret; return ret;
#endif
} }
int cVideo::SetVideoSystem(int video_system, bool remember) int cVideo::SetVideoSystem(int video_system, bool remember)
{ {
lt_info("%s(%d, %d)\n", __FUNCTION__, video_system, remember); lt_info("%s(%d, %d)\n", __func__, video_system, remember);
return 0;
#if 0
if (video_system > VID_DISPFMT_SECAM || video_system < 0) if (video_system > VID_DISPFMT_SECAM || video_system < 0)
video_system = VID_DISPFMT_PAL; video_system = VID_DISPFMT_PAL;
return fop(ioctl, MPEG_VID_SET_DISPFMT, video_system); return fop(ioctl, MPEG_VID_SET_DISPFMT, video_system);
#endif
} }
int cVideo::getPlayState(void) int cVideo::getPlayState(void)
@@ -366,6 +372,7 @@ int cVideo::getPlayState(void)
void cVideo::SetVideoMode(analog_mode_t mode) void cVideo::SetVideoMode(analog_mode_t mode)
{ {
lt_debug("%s(%d)\n", __FUNCTION__, mode); lt_debug("%s(%d)\n", __FUNCTION__, mode);
#if 0
switch(mode) switch(mode)
{ {
case ANALOG_SD_YPRPB_SCART: case ANALOG_SD_YPRPB_SCART:
@@ -379,10 +386,13 @@ void cVideo::SetVideoMode(analog_mode_t mode)
return; return;
} }
fop(ioctl, MPEG_VID_SET_OUTFMT, outputformat); fop(ioctl, MPEG_VID_SET_OUTFMT, outputformat);
#endif
} }
void cVideo::ShowPicture(const char * fname) void cVideo::ShowPicture(const char * fname)
{ {
return;
#if 0
lt_debug("%s(%s)\n", __FUNCTION__, fname); lt_debug("%s(%s)\n", __FUNCTION__, fname);
char destname[512]; char destname[512];
char cmd[512]; char cmd[512];
@@ -442,6 +452,7 @@ void cVideo::ShowPicture(const char * fname)
out: out:
pthread_mutex_unlock(&stillp_mutex); pthread_mutex_unlock(&stillp_mutex);
return; return;
#endif
#if 0 #if 0
/* DirectFB based picviewer: works, but is slow and the infobar /* DirectFB based picviewer: works, but is slow and the infobar
draws in the same plane */ draws in the same plane */
@@ -469,12 +480,15 @@ void cVideo::ShowPicture(const char * fname)
void cVideo::StopPicture() void cVideo::StopPicture()
{ {
#if 0
lt_debug("%s\n", __FUNCTION__); lt_debug("%s\n", __FUNCTION__);
fop(ioctl, MPEG_VID_SELECT_SOURCE, VID_SOURCE_DEMUX); fop(ioctl, MPEG_VID_SELECT_SOURCE, VID_SOURCE_DEMUX);
#endif
} }
void cVideo::Standby(unsigned int bOn) void cVideo::Standby(unsigned int bOn)
{ {
#if 0
lt_debug("%s(%d)\n", __FUNCTION__, bOn); lt_debug("%s(%d)\n", __FUNCTION__, bOn);
if (bOn) if (bOn)
{ {
@@ -484,6 +498,7 @@ void cVideo::Standby(unsigned int bOn)
fop(ioctl, MPEG_VID_SET_OUTFMT, outputformat); fop(ioctl, MPEG_VID_SET_OUTFMT, outputformat);
routeVideo(bOn); routeVideo(bOn);
video_standby = bOn; video_standby = bOn;
#endif
} }
int cVideo::getBlank(void) int cVideo::getBlank(void)
@@ -495,6 +510,8 @@ int cVideo::getBlank(void)
/* set zoom in percent (100% == 1:1) */ /* set zoom in percent (100% == 1:1) */
int cVideo::setZoom(int zoom) int cVideo::setZoom(int zoom)
{ {
return 1;
#if 0
if (zoom == -1) // "auto" reset if (zoom == -1) // "auto" reset
zoom = *zoomvalue; zoom = *zoomvalue;
@@ -562,6 +579,7 @@ int cVideo::setZoom(int zoom)
fop(ioctl, MPEG_VID_SET_DISPMODE, VID_DISPMODE_SCALE); fop(ioctl, MPEG_VID_SET_DISPMODE, VID_DISPMODE_SCALE);
fop(ioctl, MPEG_VID_SCALE_ON); fop(ioctl, MPEG_VID_SCALE_ON);
return fop(ioctl, MPEG_VID_SET_SCALE_POS, &s); return fop(ioctl, MPEG_VID_SET_SCALE_POS, &s);
#endif
} }
#if 0 #if 0
@@ -583,6 +601,7 @@ void cVideo::setZoomAspect(int index)
changed and triggers appropriate actions */ changed and triggers appropriate actions */
void cVideo::VideoParamWatchdog(void) void cVideo::VideoParamWatchdog(void)
{ {
#if 0
static unsigned int _v_info = (unsigned int) -1; static unsigned int _v_info = (unsigned int) -1;
unsigned int v_info; unsigned int v_info;
if (fd == -1) if (fd == -1)
@@ -594,10 +613,12 @@ void cVideo::VideoParamWatchdog(void)
setAspectRatio(-1, -1); setAspectRatio(-1, -1);
} }
_v_info = v_info; _v_info = v_info;
#endif
} }
void cVideo::Pig(int x, int y, int w, int h, int /*osd_w*/, int /*osd_h*/) void cVideo::Pig(int x, int y, int w, int h, int /*osd_w*/, int /*osd_h*/)
{ {
#if 0
/* x = y = w = h = -1 -> reset / "hide" PIG */ /* x = y = w = h = -1 -> reset / "hide" PIG */
if (x == -1 && y == -1 && w == -1 && h == -1) if (x == -1 && y == -1 && w == -1 && h == -1)
{ {
@@ -619,18 +640,40 @@ void cVideo::Pig(int x, int y, int w, int h, int /*osd_w*/, int /*osd_h*/)
fop(ioctl, MPEG_VID_SET_DISPMODE, VID_DISPMODE_SCALE); fop(ioctl, MPEG_VID_SET_DISPMODE, VID_DISPMODE_SCALE);
fop(ioctl, MPEG_VID_SCALE_ON); fop(ioctl, MPEG_VID_SCALE_ON);
fop(ioctl, MPEG_VID_SET_SCALE_POS, &s); fop(ioctl, MPEG_VID_SET_SCALE_POS, &s);
#endif
} }
void cVideo::getPictureInfo(int &width, int &height, int &rate) void cVideo::getPictureInfo(int &width, int &height, int &rate)
{ {
VIDEOINFO v; char buffer[10];
/* this memset silences *TONS* of valgrind warnings */ int n, f;
memset(&v, 0, sizeof(v));
ioctl(fd, MPEG_VID_GET_V_INFO, &v); rate = 0;
/* convert to Coolstream API */ width = 0;
rate = (int)v.frame_rate - 1; height = 0;
width = (int)v.h_size;
height = (int)v.v_size; f = open("/proc/stb/vmpeg/0/framerate", O_RDONLY);
n = read(f, buffer, 10);
close(f);
if (n > 0) {
sscanf(buffer, "%X", &rate);
rate = rate/1000;
}
f = open("/proc/stb/vmpeg/0/xres", O_RDONLY);
n = read(f, buffer, 10);
close(f);
if (n > 0)
sscanf(buffer, "%X", &width);
f = open("/proc/stb/vmpeg/0/yres", O_RDONLY);
n = read(f, buffer, 10);
close(f);
if (n > 0)
sscanf(buffer, "%X", &height);
} }
void cVideo::SetSyncMode(AVSYNC_TYPE Mode) void cVideo::SetSyncMode(AVSYNC_TYPE Mode)
@@ -641,6 +684,7 @@ void cVideo::SetSyncMode(AVSYNC_TYPE Mode)
* { 1, LOCALE_OPTIONS_ON }, * { 1, LOCALE_OPTIONS_ON },
* { 2, LOCALE_AUDIOMENU_AVSYNC_AM } * { 2, LOCALE_AUDIOMENU_AVSYNC_AM }
*/ */
#if 0
switch(Mode) switch(Mode)
{ {
case 0: case 0:
@@ -653,6 +697,7 @@ void cVideo::SetSyncMode(AVSYNC_TYPE Mode)
ioctl(fd, MPEG_VID_SYNC_ON, VID_SYNC_AUD); ioctl(fd, MPEG_VID_SYNC_ON, VID_SYNC_AUD);
break; break;
} }
#endif
}; };
int cVideo::SetStreamType(VIDEO_FORMAT type) int cVideo::SetStreamType(VIDEO_FORMAT type)
@@ -665,13 +710,31 @@ int cVideo::SetStreamType(VIDEO_FORMAT type)
"VIDEO_FORMAT_GIF", "VIDEO_FORMAT_GIF",
"VIDEO_FORMAT_PNG" "VIDEO_FORMAT_PNG"
}; };
int t;
lt_debug("%s type=%s\n", __FUNCTION__, VF[type]); lt_debug("%s type=%s\n", __FUNCTION__, VF[type]);
switch (type)
{
case VIDEO_FORMAT_MPEG4:
t = VIDEO_STREAMTYPE_MPEG4_H264;
break;
case VIDEO_FORMAT_VC1:
t = VIDEO_STREAMTYPE_VC1;
break;
case VIDEO_FORMAT_MPEG2:
default:
t = VIDEO_STREAMTYPE_MPEG2;
break;
}
if (ioctl(fd, VIDEO_SET_STREAMTYPE, t) < 0)
lt_info("%s VIDEO_SET_STREAMTYPE(%d) failed: %m\n", __func__, t);
return 0; return 0;
} }
void cVideo::routeVideo(int standby) void cVideo::routeVideo(int standby)
{ {
#if 0
lt_debug("%s(%d)\n", __FUNCTION__, standby); lt_debug("%s(%d)\n", __FUNCTION__, standby);
int avsfd = open("/dev/stb/tdsystem", O_RDONLY); int avsfd = open("/dev/stb/tdsystem", O_RDONLY);
@@ -704,10 +767,13 @@ void cVideo::routeVideo(int standby)
perror("IOC_AVS_ROUTE_ENC2TV"); perror("IOC_AVS_ROUTE_ENC2TV");
} }
close(avsfd); close(avsfd);
#endif
} }
void cVideo::FastForwardMode(int mode) void cVideo::FastForwardMode(int mode)
{ {
#if 0
lt_debug("%s\n", __FUNCTION__); lt_debug("%s\n", __FUNCTION__);
fop(ioctl, MPEG_VID_FASTFORWARD, mode); fop(ioctl, MPEG_VID_FASTFORWARD, mode);
#endif
} }

View File

@@ -1,22 +1,21 @@
#ifndef _VIDEO_TD_H #ifndef _VIDEO_TD_H
#define _VIDEO_TD_H #define _VIDEO_TD_H
#include <hardware/vid/vid_inf.h> #include <linux/dvb/video.h>
#define video_format_t vidDispSize_t
//#define video_displayformat_t vidDispMode_t
typedef enum { typedef enum {
ANALOG_SD_RGB_SCART = 0x00, ANALOG_SD_RGB_CINCH = 0x00,
ANALOG_SD_YPRPB_SCART,
ANALOG_HD_RGB_SCART,
ANALOG_HD_YPRPB_SCART,
ANALOG_SD_RGB_CINCH = 0x80,
ANALOG_SD_YPRPB_CINCH, ANALOG_SD_YPRPB_CINCH,
ANALOG_HD_RGB_CINCH, ANALOG_HD_RGB_CINCH,
ANALOG_HD_YPRPB_CINCH, ANALOG_HD_YPRPB_CINCH,
ANALOG_SD_RGB_SCART = 0x10,
ANALOG_SD_YPRPB_SCART,
ANALOG_HD_RGB_SCART,
ANALOG_HD_YPRPB_SCART,
ANALOG_SCART_MASK = 0x10
} analog_mode_t; } analog_mode_t;
typedef enum { typedef enum {
VIDEO_FORMAT_MPEG2 = 0, VIDEO_FORMAT_MPEG2 = 0,
VIDEO_FORMAT_MPEG4, VIDEO_FORMAT_MPEG4,
@@ -77,19 +76,22 @@ typedef enum {
} VIDEO_PLAY_MODE; } VIDEO_PLAY_MODE;
typedef enum { typedef enum {
VIDEO_STD_NTSC = VID_DISPFMT_NTSC, /* 0 */ VIDEO_STD_NTSC,
VIDEO_STD_PAL = VID_DISPFMT_PAL, /* 1 */ VIDEO_STD_SECAM,
VIDEO_STD_SECAM = VID_DISPFMT_SECAM, /* 4 */ VIDEO_STD_PAL,
VIDEO_STD_1080I50 = VIDEO_STD_PAL, /* hack, this is used in neutrino settings default */ VIDEO_STD_480P,
VIDEO_STD_MAX = VIDEO_STD_SECAM VIDEO_STD_576P,
VIDEO_STD_720P60,
VIDEO_STD_1080I60,
VIDEO_STD_720P50,
VIDEO_STD_1080I50,
VIDEO_STD_1080P30,
VIDEO_STD_1080P24,
VIDEO_STD_1080P25,
VIDEO_STD_AUTO,
VIDEO_STD_MAX = VIDEO_STD_AUTO
} VIDEO_STD; } VIDEO_STD;
typedef enum {
VIDEO_STOPPED, /* Video is stopped */
VIDEO_PLAYING, /* Video is currently playing */
VIDEO_FREEZED /* Video is freezed */
} video_play_state_t;
/* not used, for dummy functions */ /* not used, for dummy functions */
typedef enum { typedef enum {
VIDEO_HDMI_CEC_MODE_OFF = 0, VIDEO_HDMI_CEC_MODE_OFF = 0,
@@ -116,8 +118,8 @@ class cVideo
/* apparently we cannot query the driver's state /* apparently we cannot query the driver's state
=> remember it */ => remember it */
video_play_state_t playstate; video_play_state_t playstate;
vidDispMode_t croppingMode; int /*vidDispMode_t*/ croppingMode;
vidOutFmt_t outputformat; int /*vidOutFmt_t*/ outputformat;
int scartvoltage; int scartvoltage;
int z[2]; /* zoomvalue for 4:3 (0) and 16:9 (1) in percent */ int z[2]; /* zoomvalue for 4:3 (0) and 16:9 (1) in percent */
int *zoomvalue; int *zoomvalue;
@@ -148,7 +150,7 @@ class cVideo
int setAspectRatio(int aspect, int mode); int setAspectRatio(int aspect, int mode);
/* cropping mode */ /* cropping mode */
int setCroppingMode(vidDispMode_t x = VID_DISPMODE_NORM); int setCroppingMode(int x = 0 /*vidDispMode_t x = VID_DISPMODE_NORM*/);
/* get play state */ /* get play state */
int getPlayState(void); int getPlayState(void);