- rename lt_debug => hal_debug; it's not only libtriple debugging

Signed-off-by: Thilo Graf <dbt@novatux.de>

- debuglevel fixed
This commit is contained in:
svenhoefer
2018-12-26 00:34:00 +01:00
committed by Thilo Graf
parent 8d4a39566a
commit 3da91b1463
48 changed files with 1380 additions and 1388 deletions

View File

@@ -37,17 +37,17 @@
#include "video_td.h"
#include <hardware/tddevices.h>
#define VIDEO_DEVICE "/dev/" DEVICE_NAME_VIDEO
#include "lt_debug.h"
#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_VIDEO, this, args)
#define lt_info(args...) _lt_info(TRIPLE_DEBUG_VIDEO, this, args)
#include "hal_debug.h"
#define hal_debug(args...) _hal_debug(HAL_DEBUG_VIDEO, this, args)
#define hal_info(args...) _hal_info(HAL_DEBUG_VIDEO, this, args)
#define fop(cmd, args...) ({ \
int _r; \
if (fd >= 0) { \
if ((_r = ::cmd(fd, args)) < 0) \
lt_info(#cmd"(fd, "#args")\n"); \
hal_info(#cmd"(fd, "#args")\n"); \
else \
lt_debug(#cmd"(fd, "#args")\n");\
hal_debug(#cmd"(fd, "#args")\n");\
} \
else { _r = fd; } \
_r; \
@@ -72,9 +72,9 @@ static bool noscart = false;
cVideo::cVideo(int, void *, void *, unsigned int)
{
lt_debug("%s\n", __FUNCTION__);
hal_debug("%s\n", __FUNCTION__);
if ((fd = open(VIDEO_DEVICE, O_RDWR)) < 0)
lt_info("%s cannot open %s: %m\n", __FUNCTION__, VIDEO_DEVICE);
hal_info("%s cannot open %s: %m\n", __FUNCTION__, VIDEO_DEVICE);
fcntl(fd, F_SETFD, FD_CLOEXEC);
playstate = VIDEO_STOPPED;
@@ -95,7 +95,7 @@ cVideo::cVideo(int, void *, void *, unsigned int)
blankfd = open(blanknames[i], O_RDONLY);
if (blankfd < 0)
{
lt_info("%s cannot open %s: %m", __FUNCTION__, blanknames[i]);
hal_info("%s cannot open %s: %m", __FUNCTION__, blanknames[i]);
continue;
}
if (fstat(blankfd, &st) != -1 && st.st_size > 0)
@@ -103,10 +103,10 @@ cVideo::cVideo(int, void *, void *, unsigned int)
blank_size[i] = st.st_size;
blank_data[i] = malloc(blank_size[i]);
if (! blank_data[i])
lt_info("%s malloc failed (%m)\n", __FUNCTION__);
hal_info("%s malloc failed (%m)\n", __FUNCTION__);
else if (read(blankfd, blank_data[i], blank_size[i]) != blank_size[i])
{
lt_info("%s short read (%m)\n", __FUNCTION__);
hal_info("%s short read (%m)\n", __FUNCTION__);
free(blank_data[i]); /* don't leak... */
blank_data[i] = NULL;
}
@@ -121,7 +121,7 @@ cVideo::cVideo(int, void *, void *, unsigned int)
video_standby = 0;
noscart = (getenv("TRIPLE_NOSCART") != NULL);
if (noscart)
lt_info("%s TRIPLE_NOSCART variable prevents SCART switching\n", __FUNCTION__);
hal_info("%s TRIPLE_NOSCART variable prevents SCART switching\n", __FUNCTION__);
}
cVideo::~cVideo(void)
@@ -152,7 +152,7 @@ int cVideo::setAspectRatio(int aspect, int mode)
_aspect = aspect;
if (mode != -1)
_mode = mode;
lt_info("%s(%d, %d)_(%d, %d) v_ar %d\n", __FUNCTION__, aspect, mode, _aspect, _mode, v_ar);
hal_info("%s(%d, %d)_(%d, %d) v_ar %d\n", __FUNCTION__, aspect, mode, _aspect, _mode, v_ar);
/* values are hardcoded in neutrino_menue.cpp, "2" is 14:9 -> not used */
if (_aspect != -1)
@@ -208,7 +208,7 @@ int cVideo::setAspectRatio(int aspect, int mode)
}
s.des.vert_off = (576 - s.des.vert_size) / 2;
s.des.hori_off = (720 - s.des.hori_size) / 2;
lt_debug("PANSCAN2: %d%% src: %d:%d:%d:%d dst: %d:%d:%d:%d\n", zoom,
hal_debug("PANSCAN2: %d%% src: %d:%d:%d:%d dst: %d:%d:%d:%d\n", zoom,
s.src.hori_off,s.src.vert_off,s.src.hori_size,s.src.vert_size,
s.des.hori_off,s.des.vert_off,s.des.hori_size,s.des.vert_size);
fop(ioctl, MPEG_VID_SCALE_ON);
@@ -227,7 +227,7 @@ int cVideo::setAspectRatio(int aspect, int mode)
d = ds[dsize];
else
d = "invalid!";
lt_debug("%s dispsize(%d) (%s)\n", __FUNCTION__, dsize, d);
hal_debug("%s dispsize(%d) (%s)\n", __FUNCTION__, dsize, d);
fop(ioctl, MPEG_VID_SET_DISPSIZE, dsize);
int avsfd = open("/dev/stb/tdsystem", O_RDONLY);
@@ -238,7 +238,7 @@ int cVideo::setAspectRatio(int aspect, int mode)
}
if (!noscart && scartvoltage > 0 && video_standby == 0)
{
lt_info("%s set SCART_PIN_8 to %dV\n", __FUNCTION__, scartvoltage);
hal_info("%s set SCART_PIN_8 to %dV\n", __FUNCTION__, scartvoltage);
if (ioctl(avsfd, IOC_AVS_SCART_PIN8_SET, scartvoltage) < 0)
perror("IOC_AVS_SCART_PIN8_SET");
}
@@ -254,7 +254,7 @@ int cVideo::getAspectRatio(void)
ioctl(fd, MPEG_VID_GET_V_INFO, &v);
if (v.pel_aspect_ratio < VID_DISPSIZE_4x3 || v.pel_aspect_ratio > VID_DISPSIZE_UNKNOWN)
{
lt_info("%s invalid value %d, returning 0/unknown fd: %d", __FUNCTION__, v.pel_aspect_ratio, fd);
hal_info("%s invalid value %d, returning 0/unknown fd: %d", __FUNCTION__, v.pel_aspect_ratio, fd);
return 0;
}
/* convert to Coolstream api values. Taken from streaminfo2.cpp */
@@ -280,13 +280,13 @@ int cVideo::setCroppingMode(vidDispMode_t format)
f = format_string[format];
else
f = "ILLEGAL format!";
lt_debug("%s(%d) => %s\n", __FUNCTION__, format, f);
hal_debug("%s(%d) => %s\n", __FUNCTION__, format, f);
return fop(ioctl, MPEG_VID_SET_DISPMODE, format);
}
int cVideo::Start(void * /*PcrChannel*/, unsigned short /*PcrPid*/, unsigned short /*VideoPid*/, void * /*hChannel*/)
{
lt_debug("%s playstate=%d\n", __FUNCTION__, playstate);
hal_debug("%s playstate=%d\n", __FUNCTION__, playstate);
if (playstate == VIDEO_PLAYING)
return 0;
if (playstate == VIDEO_FREEZED) /* in theory better, but not in practice :-) */
@@ -298,7 +298,7 @@ int cVideo::Start(void * /*PcrChannel*/, unsigned short /*PcrPid*/, unsigned sho
int cVideo::Stop(bool blank)
{
lt_debug("%s(%d)\n", __FUNCTION__, blank);
hal_debug("%s(%d)\n", __FUNCTION__, blank);
if (blank)
{
playstate = VIDEO_STOPPED;
@@ -311,7 +311,7 @@ int cVideo::Stop(bool blank)
int cVideo::setBlank(int)
{
lt_debug("%s\n", __FUNCTION__);
hal_debug("%s\n", __FUNCTION__);
/* The TripleDragon has no VIDEO_SET_BLANK ioctl.
instead, you write a black still-MPEG Iframe into the decoder.
The original software uses different files for 4:3 and 16:9 and
@@ -327,7 +327,7 @@ int cVideo::setBlank(int)
if ((v.v_size % 240) == 0) /* NTSC */
{
lt_info("%s NTSC format detected", __FUNCTION__);
hal_info("%s NTSC format detected", __FUNCTION__);
index = 1;
}
@@ -360,7 +360,7 @@ int cVideo::setBlank(int)
int cVideo::SetVideoSystem(int video_system, bool remember)
{
lt_info("%s(%d, %d)\n", __FUNCTION__, video_system, remember);
hal_info("%s(%d, %d)\n", __FUNCTION__, video_system, remember);
if (video_system > VID_DISPFMT_SECAM || video_system < 0)
video_system = VID_DISPFMT_PAL;
return fop(ioctl, MPEG_VID_SET_DISPFMT, video_system);
@@ -373,7 +373,7 @@ int cVideo::getPlayState(void)
void cVideo::SetVideoMode(analog_mode_t mode)
{
lt_debug("%s(%d)\n", __FUNCTION__, mode);
hal_debug("%s(%d)\n", __FUNCTION__, mode);
switch(mode)
{
case ANALOG_SD_YPRPB_SCART:
@@ -383,7 +383,7 @@ void cVideo::SetVideoMode(analog_mode_t mode)
outputformat = VID_OUTFMT_RGBC_SVIDEO;
break;
default:
lt_info("%s unknown mode %d\n", __FUNCTION__, mode);
hal_info("%s unknown mode %d\n", __FUNCTION__, mode);
return;
}
fop(ioctl, MPEG_VID_SET_OUTFMT, outputformat);
@@ -391,7 +391,7 @@ void cVideo::SetVideoMode(analog_mode_t mode)
void cVideo::ShowPicture(const char * fname)
{
lt_debug("%s(%s)\n", __FUNCTION__, fname);
hal_debug("%s(%s)\n", __FUNCTION__, fname);
char destname[512];
char cmd[512];
char *p;
@@ -401,7 +401,7 @@ void cVideo::ShowPicture(const char * fname)
strcpy(destname, "/var/cache");
if (stat(fname, &st2))
{
lt_info("%s: could not stat %s (%m)\n", __func__, fname);
hal_info("%s: could not stat %s (%m)\n", __func__, fname);
return;
}
mkdir(destname, 0755);
@@ -434,16 +434,16 @@ void cVideo::ShowPicture(const char * fname)
mfd = open(destname, O_RDONLY);
if (mfd < 0)
{
lt_info("%s cannot open %s: %m", __FUNCTION__, destname);
hal_info("%s cannot open %s: %m", __FUNCTION__, destname);
goto out;
}
if (fstat(mfd, &st) != -1 && st.st_size > 0)
{
data = malloc(st.st_size);
if (! data)
lt_info("%s malloc failed (%m)\n", __FUNCTION__);
hal_info("%s malloc failed (%m)\n", __FUNCTION__);
else if (read(mfd, data, st.st_size) != st.st_size)
lt_info("%s short read (%m)\n", __FUNCTION__);
hal_info("%s short read (%m)\n", __FUNCTION__);
else
{
BUFINFO buf;
@@ -485,13 +485,13 @@ void cVideo::ShowPicture(const char * fname)
void cVideo::StopPicture()
{
lt_debug("%s\n", __FUNCTION__);
hal_debug("%s\n", __FUNCTION__);
fop(ioctl, MPEG_VID_SELECT_SOURCE, VID_SOURCE_DEMUX);
}
void cVideo::Standby(unsigned int bOn)
{
lt_debug("%s(%d)\n", __FUNCTION__, bOn);
hal_debug("%s(%d)\n", __FUNCTION__, bOn);
if (bOn)
{
setBlank(1);
@@ -511,7 +511,7 @@ int cVideo::getBlank(void)
* setBlank() puts a 24fps black mpeg into the decoder...
* regular broadcast does not have 24fps, so if it is still
* there, video did not decode... */
lt_debug("%s: %hu (blank = 2)\n", __func__, v.frame_rate);
hal_debug("%s: %hu (blank = 2)\n", __func__, v.frame_rate);
return (v.frame_rate == 2);
}
@@ -579,7 +579,7 @@ int cVideo::setZoom(int zoom)
s.des.vert_off = (576 - s.des.vert_size) / 2;
}
*/
lt_debug("%s %d%% src: %d:%d:%d:%d dst: %d:%d:%d:%d\n", __FUNCTION__, zoom,
hal_debug("%s %d%% src: %d:%d:%d:%d dst: %d:%d:%d:%d\n", __FUNCTION__, zoom,
s.src.hori_off,s.src.vert_off,s.src.hori_size,s.src.vert_size,
s.des.hori_off,s.des.vert_off,s.des.hori_size,s.des.vert_size);
fop(ioctl, MPEG_VID_SET_DISPMODE, VID_DISPMODE_SCALE);
@@ -613,7 +613,7 @@ void cVideo::VideoParamWatchdog(void)
ioctl(fd, MPEG_VID_GET_V_INFO_RAW, &v_info);
if (_v_info != v_info)
{
lt_debug("%s params changed. old: %08x new: %08x\n", __FUNCTION__, _v_info, v_info);
hal_debug("%s params changed. old: %08x new: %08x\n", __FUNCTION__, _v_info, v_info);
setAspectRatio(-1, -1);
}
_v_info = v_info;
@@ -636,7 +636,7 @@ void cVideo::Pig(int x, int y, int w, int h, int /*osd_w*/, int /*osd_h*/)
s.des.vert_off = y;
s.des.hori_size = w;
s.des.vert_size = h;
lt_debug("%s src: %d:%d:%d:%d dst: %d:%d:%d:%d", __FUNCTION__,
hal_debug("%s src: %d:%d:%d:%d dst: %d:%d:%d:%d", __FUNCTION__,
s.src.hori_off,s.src.vert_off,s.src.hori_size,s.src.vert_size,
s.des.hori_off,s.des.vert_off,s.des.hori_size,s.des.vert_size);
fop(ioctl, MPEG_VID_SET_DISPMODE, VID_DISPMODE_SCALE);
@@ -658,7 +658,7 @@ void cVideo::getPictureInfo(int &width, int &height, int &rate)
void cVideo::SetSyncMode(AVSYNC_TYPE Mode)
{
lt_debug("%s %d\n", __FUNCTION__, Mode);
hal_debug("%s %d\n", __FUNCTION__, Mode);
/*
* { 0, LOCALE_OPTIONS_OFF },
* { 1, LOCALE_OPTIONS_ON },
@@ -689,13 +689,13 @@ int cVideo::SetStreamType(VIDEO_FORMAT type)
"VIDEO_FORMAT_PNG"
};
lt_debug("%s type=%s\n", __FUNCTION__, VF[type]);
hal_debug("%s type=%s\n", __FUNCTION__, VF[type]);
return 0;
}
void cVideo::routeVideo(int standby)
{
lt_debug("%s(%d)\n", __FUNCTION__, standby);
hal_debug("%s(%d)\n", __FUNCTION__, standby);
int avsfd = open("/dev/stb/tdsystem", O_RDONLY);
if (avsfd < 0)
@@ -708,7 +708,7 @@ void cVideo::routeVideo(int standby)
to configure this, we can think more about this... */
if (standby)
{
lt_info("%s set fastblank and pin8 to follow VCR SCART, route VCR to TV\n", __FUNCTION__);
hal_info("%s set fastblank and pin8 to follow VCR SCART, route VCR to TV\n", __FUNCTION__);
if (ioctl(avsfd, IOC_AVS_FASTBLANK_SET, (unsigned char)3) < 0)
perror("IOC_AVS_FASTBLANK_SET, 3");
/* TODO: should probably depend on aspect ratio setting */
@@ -718,7 +718,7 @@ void cVideo::routeVideo(int standby)
perror("IOC_AVS_ROUTE_VCR2TV");
} else {
unsigned char fblk = 1;
lt_info("%s set fastblank=%d pin8=%dV, route encoder to TV\n", __FUNCTION__, fblk, scartvoltage);
hal_info("%s set fastblank=%d pin8=%dV, route encoder to TV\n", __FUNCTION__, fblk, scartvoltage);
if (ioctl(avsfd, IOC_AVS_FASTBLANK_SET, fblk) < 0)
perror("IOC_AVS_FASTBLANK_SET, fblk");
if (!noscart && ioctl(avsfd, IOC_AVS_SCART_PIN8_SET, scartvoltage) < 0)
@@ -731,7 +731,7 @@ void cVideo::routeVideo(int standby)
void cVideo::FastForwardMode(int mode)
{
lt_debug("%s\n", __FUNCTION__);
hal_debug("%s\n", __FUNCTION__);
fop(ioctl, MPEG_VID_FASTFORWARD, mode);
}
@@ -921,29 +921,29 @@ static const int yuv2rgbtable_bv[256] = {
/* TODO: aspect ratio correction and PIP */
bool cVideo::GetScreenImage(unsigned char * &video, int &xres, int &yres, bool get_video, bool get_osd, bool /*scale_to_video*/)
{
lt_info("%s: get_video: %d get_osd: %d\n", __func__, get_video, get_osd);
hal_info("%s: get_video: %d get_osd: %d\n", __func__, get_video, get_osd);
uint8_t *map;
int mfd = open("/dev/mem", O_RDWR);
if (mfd < 0) {
lt_info("%s: cannot open open /dev/mem (%m)\n", __func__);
hal_info("%s: cannot open open /dev/mem (%m)\n", __func__);
return false;
}
/* this hints at incorrect usage */
if (video != NULL)
lt_info("%s: WARNING, video != NULL?\n", __func__);
hal_info("%s: WARNING, video != NULL?\n", __func__);
if (get_video)
{
map = (uint8_t *)mmap(NULL, VIDEO_SIZE, PROT_READ, MAP_SHARED, mfd, VIDEO_MEM);
if (map == MAP_FAILED) {
lt_info("%s: cannot mmap /dev/mem vor VIDEO (%m)\n", __func__);
hal_info("%s: cannot mmap /dev/mem vor VIDEO (%m)\n", __func__);
close(mfd);
return false;
}
uint16_t w = *(uint16_t *)(map + WIDTH_OFF);
uint16_t h = *(uint16_t *)(map + HEIGHT_OFF);
if (w > 720 || h > 576) {
lt_info("%s: unhandled resolution %dx%d, is the tuner locked?\n", __func__, w, h);
hal_info("%s: unhandled resolution %dx%d, is the tuner locked?\n", __func__, w, h);
munmap(map, VIDEO_SIZE);
close(mfd);
return false;
@@ -954,7 +954,7 @@ bool cVideo::GetScreenImage(unsigned char * &video, int &xres, int &yres, bool g
int chromasize = needmem - lumasize;
uint8_t *buf = (uint8_t *)malloc(needmem);
if (!buf) {
lt_info("%s: cannot allocate %d bytes (%m)\n", __func__, needmem);
hal_info("%s: cannot allocate %d bytes (%m)\n", __func__, needmem);
munmap(map, VIDEO_SIZE);
close(mfd);
return false;
@@ -978,7 +978,7 @@ bool cVideo::GetScreenImage(unsigned char * &video, int &xres, int &yres, bool g
}
video = (unsigned char *)malloc(xres * yres * 4);
if (!video) {
lt_info("%s: cannot allocate %d bytes for video buffer (%m)\n", __func__, yres * yres * 4);
hal_info("%s: cannot allocate %d bytes for video buffer (%m)\n", __func__, yres * yres * 4);
free(buf);
close(mfd);
return false;
@@ -990,7 +990,7 @@ bool cVideo::GetScreenImage(unsigned char * &video, int &xres, int &yres, bool g
int Y, U, V, y, x, out1, pos, RU, GU, GV, BV, rgbstride, i;
// yuv2rgb conversion (4:2:0)
lt_info("%s: converting Video from YUV to RGB color space\n", __func__);
hal_info("%s: converting Video from YUV to RGB color space\n", __func__);
out1 = pos = 0;
rgbstride = w * 4;
@@ -1047,7 +1047,7 @@ bool cVideo::GetScreenImage(unsigned char * &video, int &xres, int &yres, bool g
}
}
}
lt_info("%s: Video-Size: %d x %d\n", __func__, xres, yres);
hal_info("%s: Video-Size: %d x %d\n", __func__, xres, yres);
free(buf);
}
if (get_osd)
@@ -1060,7 +1060,7 @@ bool cVideo::GetScreenImage(unsigned char * &video, int &xres, int &yres, bool g
video = (unsigned char *)calloc(xres * yres, 4);
if (!video)
{
lt_info("%s: cannot allocate %d bytes for video buffer (%m)\n", __func__, yres * yres * 4);
hal_info("%s: cannot allocate %d bytes for video buffer (%m)\n", __func__, yres * yres * 4);
close(mfd);
return false;
}
@@ -1068,7 +1068,7 @@ bool cVideo::GetScreenImage(unsigned char * &video, int &xres, int &yres, bool g
/* we don't need the framebufferdevice, we know where the FB is located */
map = (uint8_t *)mmap(NULL, GFXFB_SIZE, PROT_READ, MAP_SHARED, mfd, GFXFB_MEM);
if (map == MAP_FAILED) {
lt_info("%s: cannot mmap /dev/mem for GFXFB (%m)\n", __func__);
hal_info("%s: cannot mmap /dev/mem for GFXFB (%m)\n", __func__);
close(mfd);
return false;
}
@@ -1101,5 +1101,5 @@ bool cVideo::GetScreenImage(unsigned char * &video, int &xres, int &yres, bool g
void cVideo::SetDemux(cDemux *)
{
lt_debug("%s: not implemented yet\n", __func__);
hal_debug("%s: not implemented yet\n", __func__);
}