2002-07-18 14:59:55 +00:00
|
|
|
/*
|
2009-02-08 03:27:30 +00:00
|
|
|
* DXR3/H+ video output
|
2001-11-03 02:38:10 +00:00
|
|
|
*
|
2003-01-12 19:32:56 +00:00
|
|
|
* Copyright (C) 2002-2003 David Holm <david@realityrift.com>
|
2001-11-03 02:38:10 +00:00
|
|
|
*
|
2009-02-08 03:27:30 +00:00
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer 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.
|
|
|
|
*
|
|
|
|
* MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2001-11-03 02:38:10 +00:00
|
|
|
*/
|
|
|
|
|
2001-11-16 08:31:18 +00:00
|
|
|
#include <linux/em8300.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/types.h>
|
2002-02-13 00:38:23 +00:00
|
|
|
#include <sys/select.h>
|
2002-01-11 22:30:28 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2001-11-16 08:31:18 +00:00
|
|
|
#include <fcntl.h>
|
2001-11-03 02:38:10 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <time.h>
|
2002-11-02 01:18:54 +00:00
|
|
|
#include <math.h>
|
2001-11-03 02:38:10 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
2006-04-24 04:23:53 +00:00
|
|
|
#include "mp_msg.h"
|
|
|
|
#include "help_mp.h"
|
2002-01-11 22:30:28 +00:00
|
|
|
#include "fastmemcpy.h"
|
|
|
|
|
2001-11-03 02:38:10 +00:00
|
|
|
#include "video_out.h"
|
|
|
|
#include "video_out_internal.h"
|
2002-02-13 00:38:23 +00:00
|
|
|
#include "aspect.h"
|
2002-04-04 16:11:09 +00:00
|
|
|
#include "spuenc.h"
|
2002-08-22 13:58:38 +00:00
|
|
|
#include "sub.h"
|
2008-08-04 06:16:23 +00:00
|
|
|
#ifdef CONFIG_X11
|
2002-11-02 01:18:54 +00:00
|
|
|
#include "x11_common.h"
|
|
|
|
#endif
|
2007-07-05 22:01:07 +00:00
|
|
|
#include "libavutil/avstring.h"
|
2002-03-13 14:15:00 +00:00
|
|
|
|
2002-07-05 14:26:37 +00:00
|
|
|
#define SPU_SUPPORT
|
2001-11-03 02:38:10 +00:00
|
|
|
|
2009-07-06 23:26:13 +00:00
|
|
|
static const vo_info_t info =
|
2002-07-05 14:26:37 +00:00
|
|
|
{
|
|
|
|
"DXR3/H+ video out",
|
|
|
|
"dxr3",
|
|
|
|
"David Holm <dholm@iname.com>",
|
|
|
|
""
|
2002-03-26 18:47:42 +00:00
|
|
|
};
|
2007-12-02 14:39:15 +00:00
|
|
|
const LIBVO_EXTERN (dxr3)
|
2001-11-03 02:38:10 +00:00
|
|
|
|
2002-01-11 22:30:28 +00:00
|
|
|
/* Resolutions and positions */
|
|
|
|
static int v_width, v_height;
|
|
|
|
static int s_width, s_height;
|
|
|
|
static int osd_w, osd_h;
|
2003-01-02 21:45:13 +00:00
|
|
|
static int img_format;
|
2001-12-04 23:14:31 +00:00
|
|
|
|
2002-11-03 20:05:39 +00:00
|
|
|
/* Configuration values
|
2009-07-06 23:26:13 +00:00
|
|
|
* Don't declare these static, they
|
2002-11-03 20:05:39 +00:00
|
|
|
* should be accessible from the gui.
|
|
|
|
*/
|
|
|
|
int dxr3_prebuf = 0;
|
|
|
|
int dxr3_newsync = 0;
|
|
|
|
int dxr3_overlay = 0;
|
|
|
|
int dxr3_device_num = 0;
|
2002-12-24 12:45:32 +00:00
|
|
|
int dxr3_norm = 0;
|
2002-11-03 20:05:39 +00:00
|
|
|
|
2004-06-25 16:49:53 +00:00
|
|
|
#define MAX_STR_SIZE 80 /* length for the static strings */
|
|
|
|
|
2002-01-11 22:30:28 +00:00
|
|
|
/* File descriptors */
|
2001-11-16 08:31:18 +00:00
|
|
|
static int fd_control = -1;
|
|
|
|
static int fd_video = -1;
|
|
|
|
static int fd_spu = -1;
|
2004-06-25 16:49:53 +00:00
|
|
|
static char fdv_name[MAX_STR_SIZE];
|
|
|
|
static char fds_name[MAX_STR_SIZE];
|
2002-01-11 22:30:28 +00:00
|
|
|
|
2002-07-05 14:26:37 +00:00
|
|
|
#ifdef SPU_SUPPORT
|
2002-04-04 16:11:09 +00:00
|
|
|
/* on screen display/subpics */
|
2003-01-02 21:45:13 +00:00
|
|
|
static char *osdpicbuf;
|
2002-04-04 16:11:09 +00:00
|
|
|
static int osdpicbuf_w;
|
|
|
|
static int osdpicbuf_h;
|
2003-01-02 21:45:13 +00:00
|
|
|
static int disposd;
|
2002-04-04 16:11:09 +00:00
|
|
|
static encodedata *spued;
|
2002-10-29 01:38:42 +00:00
|
|
|
static encodedata *spubuf;
|
2002-07-05 14:26:37 +00:00
|
|
|
#endif
|
2002-04-04 16:11:09 +00:00
|
|
|
|
2002-11-02 01:18:54 +00:00
|
|
|
|
2002-01-11 22:30:28 +00:00
|
|
|
/* Static variable used in ioctl's */
|
2003-01-02 21:45:13 +00:00
|
|
|
static int ioval;
|
|
|
|
static int prev_pts;
|
|
|
|
static int pts_offset;
|
2003-01-02 18:54:16 +00:00
|
|
|
static int old_vmode = -1;
|
2001-11-03 02:38:10 +00:00
|
|
|
|
2002-11-02 01:18:54 +00:00
|
|
|
|
|
|
|
/* Begin overlay.h */
|
|
|
|
/*
|
|
|
|
Simple analog overlay API for DXR3/H+ linux driver.
|
|
|
|
|
|
|
|
Henrik Johansson
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/* Pattern drawing callback used by the calibration functions.
|
|
|
|
The function is expected to:
|
|
|
|
Clear the entire screen.
|
|
|
|
Fill the screen with color bgcol (0xRRGGBB)
|
|
|
|
Draw a rectangle at (xpos,ypos) of size (width,height) in fgcol (0xRRGGBB)
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef int (*pattern_drawer_cb)(int fgcol, int bgcol,
|
|
|
|
int xpos, int ypos, int width, int height, void *arg);
|
|
|
|
|
|
|
|
struct coeff {
|
|
|
|
float k,m;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int dev;
|
|
|
|
|
|
|
|
int xres, yres,depth;
|
|
|
|
int xoffset,yoffset,xcorr;
|
|
|
|
int jitter;
|
|
|
|
int stability;
|
|
|
|
int keycolor;
|
|
|
|
struct coeff colcal_upper[3];
|
|
|
|
struct coeff colcal_lower[3];
|
|
|
|
float color_interval;
|
|
|
|
|
|
|
|
pattern_drawer_cb draw_pattern;
|
|
|
|
void *dp_arg;
|
|
|
|
} overlay_t;
|
|
|
|
|
|
|
|
|
2002-11-03 20:59:04 +00:00
|
|
|
static overlay_t *overlay_init(int dev);
|
|
|
|
static int overlay_release(overlay_t *);
|
|
|
|
|
|
|
|
static int overlay_read_state(overlay_t *o, char *path);
|
|
|
|
static int overlay_write_state(overlay_t *o, char *path);
|
|
|
|
|
|
|
|
static int overlay_set_screen(overlay_t *o, int xres, int yres, int depth);
|
|
|
|
static int overlay_set_mode(overlay_t *o, int mode);
|
|
|
|
static int overlay_set_attribute(overlay_t *o, int attribute, int val);
|
|
|
|
static int overlay_set_keycolor(overlay_t *o, int color);
|
|
|
|
static int overlay_set_window(overlay_t *o, int xpos,int ypos,int width,int height);
|
|
|
|
static int overlay_set_bcs(overlay_t *o, int brightness, int contrast, int saturation);
|
|
|
|
|
|
|
|
static int overlay_autocalibrate(overlay_t *o, pattern_drawer_cb pd, void *arg);
|
|
|
|
static void overlay_update_params(overlay_t *o);
|
|
|
|
static int overlay_signalmode(overlay_t *o, int mode);
|
2002-11-02 01:18:54 +00:00
|
|
|
/* End overlay.h */
|
|
|
|
|
|
|
|
|
2008-08-04 06:16:23 +00:00
|
|
|
#ifdef CONFIG_X11
|
2002-11-02 01:18:54 +00:00
|
|
|
#define KEY_COLOR 0x80a040
|
|
|
|
static XWindowAttributes xwin_attribs;
|
|
|
|
static overlay_t *overlay_data;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2002-11-03 20:59:04 +00:00
|
|
|
/* Functions for working with the em8300's internal clock */
|
|
|
|
/* End of internal clock functions */
|
|
|
|
|
2008-04-02 16:38:34 +00:00
|
|
|
static int control(uint32_t request, void *data)
|
2002-02-09 00:47:26 +00:00
|
|
|
{
|
|
|
|
switch (request) {
|
2002-11-03 20:05:39 +00:00
|
|
|
case VOCTRL_SET_SPU_PALETTE:
|
|
|
|
if (ioctl(fd_spu, EM8300_IOCTL_SPU_SETPALETTE, data) < 0) {
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_DXR3] Unable to load new SPU palette!\n");
|
2002-11-03 20:05:39 +00:00
|
|
|
return VO_ERROR;
|
|
|
|
}
|
|
|
|
return VO_TRUE;
|
2008-08-04 06:16:23 +00:00
|
|
|
#ifdef CONFIG_X11
|
2003-11-30 16:36:10 +00:00
|
|
|
case VOCTRL_ONTOP:
|
|
|
|
vo_x11_ontop();
|
|
|
|
return VO_TRUE;
|
2002-11-02 01:18:54 +00:00
|
|
|
case VOCTRL_FULLSCREEN:
|
2002-11-03 20:05:39 +00:00
|
|
|
if (dxr3_overlay) {
|
2002-11-02 01:18:54 +00:00
|
|
|
vo_x11_fullscreen();
|
2005-11-06 21:15:53 +00:00
|
|
|
overlay_signalmode(overlay_data,
|
|
|
|
vo_fs ? EM8300_OVERLAY_SIGNAL_ONLY :
|
|
|
|
EM8300_OVERLAY_SIGNAL_WITH_VGA);
|
2002-11-02 01:18:54 +00:00
|
|
|
return VO_TRUE;
|
|
|
|
}
|
|
|
|
return VO_FALSE;
|
|
|
|
#endif
|
2002-02-18 17:34:20 +00:00
|
|
|
case VOCTRL_RESUME:
|
2002-11-03 20:05:39 +00:00
|
|
|
if (dxr3_newsync) {
|
|
|
|
ioctl(fd_control, EM8300_IOCTL_SCR_GET, &ioval);
|
|
|
|
pts_offset = vo_pts - (ioval << 1);
|
|
|
|
if (pts_offset < 0) {
|
|
|
|
pts_offset = 0;
|
|
|
|
}
|
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-11-03 20:05:39 +00:00
|
|
|
if (dxr3_prebuf) {
|
2002-02-18 17:34:20 +00:00
|
|
|
ioval = EM8300_PLAYMODE_PLAY;
|
|
|
|
if (ioctl(fd_control, EM8300_IOCTL_SET_PLAYMODE, &ioval) < 0) {
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Unable to set playmode!\n");
|
2002-02-18 17:34:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return VO_TRUE;
|
|
|
|
case VOCTRL_PAUSE:
|
2002-11-03 20:05:39 +00:00
|
|
|
if (dxr3_prebuf) {
|
2002-02-18 17:34:20 +00:00
|
|
|
ioval = EM8300_PLAYMODE_PAUSED;
|
|
|
|
if (ioctl(fd_control, EM8300_IOCTL_SET_PLAYMODE, &ioval) < 0) {
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Unable to set playmode!\n");
|
2002-02-18 17:34:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return VO_TRUE;
|
2002-02-09 00:47:26 +00:00
|
|
|
case VOCTRL_RESET:
|
2002-11-03 20:05:39 +00:00
|
|
|
if (dxr3_prebuf) {
|
2002-02-09 11:35:24 +00:00
|
|
|
close(fd_video);
|
|
|
|
fd_video = open(fdv_name, O_WRONLY);
|
2002-04-06 07:30:28 +00:00
|
|
|
close(fd_spu);
|
|
|
|
fd_spu = open(fds_name, O_WRONLY);
|
2002-02-09 14:44:09 +00:00
|
|
|
fsync(fd_video);
|
2002-04-06 07:30:28 +00:00
|
|
|
fsync(fd_spu);
|
2002-02-09 11:35:24 +00:00
|
|
|
}
|
2002-02-09 00:47:26 +00:00
|
|
|
return VO_TRUE;
|
|
|
|
case VOCTRL_QUERY_FORMAT:
|
2002-07-05 14:26:37 +00:00
|
|
|
{
|
|
|
|
uint32_t flag = 0;
|
|
|
|
|
|
|
|
if (*((uint32_t*)data) != IMGFMT_MPEGPES)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
flag = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_SPU;
|
2002-11-03 20:05:39 +00:00
|
|
|
if (dxr3_prebuf)
|
2002-07-05 14:26:37 +00:00
|
|
|
flag |= VFCAP_TIMER;
|
|
|
|
return flag;
|
|
|
|
}
|
2002-07-25 13:23:44 +00:00
|
|
|
case VOCTRL_SET_EQUALIZER:
|
2002-07-05 14:26:37 +00:00
|
|
|
{
|
2002-07-25 13:23:44 +00:00
|
|
|
em8300_bcs_t bcs;
|
2008-04-02 15:51:38 +00:00
|
|
|
struct voctrl_set_equalizer_args *args = data;
|
2002-07-25 13:23:44 +00:00
|
|
|
|
|
|
|
if (ioctl(fd_control, EM8300_IOCTL_GETBCS, &bcs) < 0)
|
|
|
|
return VO_FALSE;
|
2008-04-02 15:51:38 +00:00
|
|
|
if (!strcasecmp(args->name, "brightness"))
|
|
|
|
bcs.brightness = (args->value+100)*5;
|
|
|
|
else if (!strcasecmp(args->name, "contrast"))
|
|
|
|
bcs.contrast = (args->value+100)*5;
|
|
|
|
else if (!strcasecmp(args->name, "saturation"))
|
|
|
|
bcs.saturation = (args->value+100)*5;
|
2002-08-27 08:33:05 +00:00
|
|
|
else return VO_FALSE;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-07-25 13:23:44 +00:00
|
|
|
if (ioctl(fd_control, EM8300_IOCTL_SETBCS, &bcs) < 0)
|
|
|
|
return VO_FALSE;
|
|
|
|
return VO_TRUE;
|
|
|
|
}
|
|
|
|
case VOCTRL_GET_EQUALIZER:
|
|
|
|
{
|
|
|
|
em8300_bcs_t bcs;
|
2008-04-02 15:51:38 +00:00
|
|
|
struct voctrl_get_equalizer_args *args = data;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-07-25 13:23:44 +00:00
|
|
|
if (ioctl(fd_control, EM8300_IOCTL_GETBCS, &bcs) < 0)
|
|
|
|
return VO_FALSE;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2008-04-02 15:51:38 +00:00
|
|
|
if (!strcasecmp(args->name, "brightness"))
|
|
|
|
*args->valueptr = (bcs.brightness/5)-100;
|
|
|
|
else if (!strcasecmp(args->name, "contrast"))
|
|
|
|
*args->valueptr = (bcs.contrast/5)-100;
|
|
|
|
else if (!strcasecmp(args->name, "saturation"))
|
|
|
|
*args->valueptr = (bcs.saturation/5)-100;
|
2002-08-27 08:33:05 +00:00
|
|
|
else return VO_FALSE;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-07-05 14:26:37 +00:00
|
|
|
return VO_TRUE;
|
|
|
|
}
|
2002-02-09 00:47:26 +00:00
|
|
|
}
|
|
|
|
return VO_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2002-11-02 01:18:54 +00:00
|
|
|
void calculate_cvals(unsigned long mask, int *shift, int *prec)
|
|
|
|
{
|
|
|
|
/* Calculate shift and precision */
|
|
|
|
(*shift) = 0;
|
|
|
|
(*prec) = 0;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-11-02 01:18:54 +00:00
|
|
|
while (!(mask & 0x1)) {
|
|
|
|
(*shift)++;
|
|
|
|
mask >>= 1;
|
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-11-02 01:18:54 +00:00
|
|
|
while (mask & 0x1) {
|
|
|
|
(*prec)++;
|
|
|
|
mask >>= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-05 01:24:37 +00:00
|
|
|
static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format)
|
2001-11-03 02:38:10 +00:00
|
|
|
{
|
2002-02-18 17:34:20 +00:00
|
|
|
int tmp1, tmp2, size;
|
Added new syncengine thanks to a new previously undocumented feature of the em8300, this might fix playback on both slow and fast machines (more testing needed). This also requires users to get the em8300 driver from cvs until the next version is released (will probably happen this weekend)
Added lots of comments, should be pretty easy to understand most of the internals now
Added lots of brackets to if's for's while's etc, this is not a cosmetical thing but rather due to the fact I got some very odd bugs with else's since I didn't properly use brackets (and it's the K&R standard to have brackets everywhere)
Fixed some bugs that would occur when disabling libmp1e
Switched to default to the new naming scheme of device nodes, the driver will slowly switch over to this state, if it can't find devices under the new name it will try the old naming scheme
I stopped opening devices in non-blocking mode, it would break the new syncengine which tries to burst data to the device (alot of times meaning it will fill the fifo pretty fast which would previously result in jerkyness on fast machines)
The device now sets the initial state of the pts and speed (probably not needed, but assumption is the mother of all fuckups =)
Keep the control interface open during the entire duration of the libvo device, we might need this to flush video buffers on seeking (currently not implemented, therefore seeking is broken)
This is beta stuff to the driver, I will get some users to test it for me and do my best to fix seeking as soon as possible...
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4219 b3059339-0415-0410-9bf9-f77b7e298cf2
2002-01-17 10:33:47 +00:00
|
|
|
em8300_register_t reg;
|
2002-07-18 14:59:55 +00:00
|
|
|
|
2002-02-13 00:38:23 +00:00
|
|
|
/* Softzoom turned on, downscale */
|
Added new syncengine thanks to a new previously undocumented feature of the em8300, this might fix playback on both slow and fast machines (more testing needed). This also requires users to get the em8300 driver from cvs until the next version is released (will probably happen this weekend)
Added lots of comments, should be pretty easy to understand most of the internals now
Added lots of brackets to if's for's while's etc, this is not a cosmetical thing but rather due to the fact I got some very odd bugs with else's since I didn't properly use brackets (and it's the K&R standard to have brackets everywhere)
Fixed some bugs that would occur when disabling libmp1e
Switched to default to the new naming scheme of device nodes, the driver will slowly switch over to this state, if it can't find devices under the new name it will try the old naming scheme
I stopped opening devices in non-blocking mode, it would break the new syncengine which tries to burst data to the device (alot of times meaning it will fill the fifo pretty fast which would previously result in jerkyness on fast machines)
The device now sets the initial state of the pts and speed (probably not needed, but assumption is the mother of all fuckups =)
Keep the control interface open during the entire duration of the libvo device, we might need this to flush video buffers on seeking (currently not implemented, therefore seeking is broken)
This is beta stuff to the driver, I will get some users to test it for me and do my best to fix seeking as soon as possible...
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4219 b3059339-0415-0410-9bf9-f77b7e298cf2
2002-01-17 10:33:47 +00:00
|
|
|
/* This activates the subpicture processor, you can safely disable this and still send */
|
|
|
|
/* broken subpics to the em8300, if it's enabled and you send broken subpics you will end */
|
|
|
|
/* up in a lockup */
|
2002-01-15 00:23:16 +00:00
|
|
|
ioval = EM8300_SPUMODE_ON;
|
2002-01-11 22:30:28 +00:00
|
|
|
if (ioctl(fd_control, EM8300_IOCTL_SET_SPUMODE, &ioval) < 0) {
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Unable to set subpicture mode!\n");
|
2002-01-11 22:30:28 +00:00
|
|
|
uninit();
|
|
|
|
return -1;
|
|
|
|
}
|
2001-11-16 08:31:18 +00:00
|
|
|
|
2002-01-11 22:30:28 +00:00
|
|
|
/* Set the playmode to play (just in case another app has set it to something else) */
|
|
|
|
ioval = EM8300_PLAYMODE_PLAY;
|
Added new syncengine thanks to a new previously undocumented feature of the em8300, this might fix playback on both slow and fast machines (more testing needed). This also requires users to get the em8300 driver from cvs until the next version is released (will probably happen this weekend)
Added lots of comments, should be pretty easy to understand most of the internals now
Added lots of brackets to if's for's while's etc, this is not a cosmetical thing but rather due to the fact I got some very odd bugs with else's since I didn't properly use brackets (and it's the K&R standard to have brackets everywhere)
Fixed some bugs that would occur when disabling libmp1e
Switched to default to the new naming scheme of device nodes, the driver will slowly switch over to this state, if it can't find devices under the new name it will try the old naming scheme
I stopped opening devices in non-blocking mode, it would break the new syncengine which tries to burst data to the device (alot of times meaning it will fill the fifo pretty fast which would previously result in jerkyness on fast machines)
The device now sets the initial state of the pts and speed (probably not needed, but assumption is the mother of all fuckups =)
Keep the control interface open during the entire duration of the libvo device, we might need this to flush video buffers on seeking (currently not implemented, therefore seeking is broken)
This is beta stuff to the driver, I will get some users to test it for me and do my best to fix seeking as soon as possible...
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4219 b3059339-0415-0410-9bf9-f77b7e298cf2
2002-01-17 10:33:47 +00:00
|
|
|
if (ioctl(fd_control, EM8300_IOCTL_SET_PLAYMODE, &ioval) < 0) {
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Unable to set playmode!\n");
|
Added new syncengine thanks to a new previously undocumented feature of the em8300, this might fix playback on both slow and fast machines (more testing needed). This also requires users to get the em8300 driver from cvs until the next version is released (will probably happen this weekend)
Added lots of comments, should be pretty easy to understand most of the internals now
Added lots of brackets to if's for's while's etc, this is not a cosmetical thing but rather due to the fact I got some very odd bugs with else's since I didn't properly use brackets (and it's the K&R standard to have brackets everywhere)
Fixed some bugs that would occur when disabling libmp1e
Switched to default to the new naming scheme of device nodes, the driver will slowly switch over to this state, if it can't find devices under the new name it will try the old naming scheme
I stopped opening devices in non-blocking mode, it would break the new syncengine which tries to burst data to the device (alot of times meaning it will fill the fifo pretty fast which would previously result in jerkyness on fast machines)
The device now sets the initial state of the pts and speed (probably not needed, but assumption is the mother of all fuckups =)
Keep the control interface open during the entire duration of the libvo device, we might need this to flush video buffers on seeking (currently not implemented, therefore seeking is broken)
This is beta stuff to the driver, I will get some users to test it for me and do my best to fix seeking as soon as possible...
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4219 b3059339-0415-0410-9bf9-f77b7e298cf2
2002-01-17 10:33:47 +00:00
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
Added new syncengine thanks to a new previously undocumented feature of the em8300, this might fix playback on both slow and fast machines (more testing needed). This also requires users to get the em8300 driver from cvs until the next version is released (will probably happen this weekend)
Added lots of comments, should be pretty easy to understand most of the internals now
Added lots of brackets to if's for's while's etc, this is not a cosmetical thing but rather due to the fact I got some very odd bugs with else's since I didn't properly use brackets (and it's the K&R standard to have brackets everywhere)
Fixed some bugs that would occur when disabling libmp1e
Switched to default to the new naming scheme of device nodes, the driver will slowly switch over to this state, if it can't find devices under the new name it will try the old naming scheme
I stopped opening devices in non-blocking mode, it would break the new syncengine which tries to burst data to the device (alot of times meaning it will fill the fifo pretty fast which would previously result in jerkyness on fast machines)
The device now sets the initial state of the pts and speed (probably not needed, but assumption is the mother of all fuckups =)
Keep the control interface open during the entire duration of the libvo device, we might need this to flush video buffers on seeking (currently not implemented, therefore seeking is broken)
This is beta stuff to the driver, I will get some users to test it for me and do my best to fix seeking as soon as possible...
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4219 b3059339-0415-0410-9bf9-f77b7e298cf2
2002-01-17 10:33:47 +00:00
|
|
|
/* Start em8300 prebuffering and sync engine */
|
|
|
|
reg.microcode_register = 1;
|
|
|
|
reg.reg = 0;
|
2002-11-29 21:40:37 +00:00
|
|
|
reg.val = MVCOMMAND_SYNC;
|
Added new syncengine thanks to a new previously undocumented feature of the em8300, this might fix playback on both slow and fast machines (more testing needed). This also requires users to get the em8300 driver from cvs until the next version is released (will probably happen this weekend)
Added lots of comments, should be pretty easy to understand most of the internals now
Added lots of brackets to if's for's while's etc, this is not a cosmetical thing but rather due to the fact I got some very odd bugs with else's since I didn't properly use brackets (and it's the K&R standard to have brackets everywhere)
Fixed some bugs that would occur when disabling libmp1e
Switched to default to the new naming scheme of device nodes, the driver will slowly switch over to this state, if it can't find devices under the new name it will try the old naming scheme
I stopped opening devices in non-blocking mode, it would break the new syncengine which tries to burst data to the device (alot of times meaning it will fill the fifo pretty fast which would previously result in jerkyness on fast machines)
The device now sets the initial state of the pts and speed (probably not needed, but assumption is the mother of all fuckups =)
Keep the control interface open during the entire duration of the libvo device, we might need this to flush video buffers on seeking (currently not implemented, therefore seeking is broken)
This is beta stuff to the driver, I will get some users to test it for me and do my best to fix seeking as soon as possible...
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4219 b3059339-0415-0410-9bf9-f77b7e298cf2
2002-01-17 10:33:47 +00:00
|
|
|
ioctl(fd_control, EM8300_IOCTL_WRITEREG, ®);
|
2002-07-02 13:32:08 +00:00
|
|
|
|
2002-02-09 14:27:24 +00:00
|
|
|
/* Clean buffer by syncing it */
|
2002-02-09 14:44:09 +00:00
|
|
|
ioval = EM8300_SUBDEVICE_VIDEO;
|
|
|
|
ioctl(fd_control, EM8300_IOCTL_FLUSH, &ioval);
|
|
|
|
ioval = EM8300_SUBDEVICE_AUDIO;
|
|
|
|
ioctl(fd_control, EM8300_IOCTL_FLUSH, &ioval);
|
2002-07-02 13:32:08 +00:00
|
|
|
|
2002-10-29 01:38:42 +00:00
|
|
|
/* Sync the video device to make sure the buffers are empty
|
|
|
|
* and set the playback speed to normal. Also reset the
|
|
|
|
* em8300 internal clock.
|
|
|
|
*/
|
2002-02-03 14:55:27 +00:00
|
|
|
fsync(fd_video);
|
2002-10-29 01:38:42 +00:00
|
|
|
ioval = 0x900;
|
|
|
|
ioctl(fd_control, EM8300_IOCTL_SCR_SETSPEED, &ioval);
|
Added new syncengine thanks to a new previously undocumented feature of the em8300, this might fix playback on both slow and fast machines (more testing needed). This also requires users to get the em8300 driver from cvs until the next version is released (will probably happen this weekend)
Added lots of comments, should be pretty easy to understand most of the internals now
Added lots of brackets to if's for's while's etc, this is not a cosmetical thing but rather due to the fact I got some very odd bugs with else's since I didn't properly use brackets (and it's the K&R standard to have brackets everywhere)
Fixed some bugs that would occur when disabling libmp1e
Switched to default to the new naming scheme of device nodes, the driver will slowly switch over to this state, if it can't find devices under the new name it will try the old naming scheme
I stopped opening devices in non-blocking mode, it would break the new syncengine which tries to burst data to the device (alot of times meaning it will fill the fifo pretty fast which would previously result in jerkyness on fast machines)
The device now sets the initial state of the pts and speed (probably not needed, but assumption is the mother of all fuckups =)
Keep the control interface open during the entire duration of the libvo device, we might need this to flush video buffers on seeking (currently not implemented, therefore seeking is broken)
This is beta stuff to the driver, I will get some users to test it for me and do my best to fix seeking as soon as possible...
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4219 b3059339-0415-0410-9bf9-f77b7e298cf2
2002-01-17 10:33:47 +00:00
|
|
|
|
|
|
|
/* Store some variables statically that we need later in another scope */
|
2002-01-11 22:30:28 +00:00
|
|
|
img_format = format;
|
2002-02-13 00:38:23 +00:00
|
|
|
v_width = width;
|
|
|
|
v_height = height;
|
2002-01-11 22:30:28 +00:00
|
|
|
|
2002-03-23 15:27:47 +00:00
|
|
|
/* Set monitor_aspect to avoid jitter */
|
|
|
|
monitor_aspect = (float) width / (float) height;
|
2003-01-02 18:54:16 +00:00
|
|
|
|
|
|
|
if (ioctl(fd_control, EM8300_IOCTL_GET_VIDEOMODE, &old_vmode) < 0) {
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Unable to get TV norm!\n");
|
2003-01-02 18:54:16 +00:00
|
|
|
old_vmode = -1;
|
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-12-24 12:45:32 +00:00
|
|
|
/* adjust TV norm */
|
|
|
|
if (dxr3_norm != 0) {
|
|
|
|
if (dxr3_norm == 5) {
|
|
|
|
ioval = EM8300_VIDEOMODE_NTSC;
|
|
|
|
} else if (dxr3_norm == 4) {
|
|
|
|
ioval = EM8300_VIDEOMODE_PAL60;
|
|
|
|
} else if (dxr3_norm == 3) {
|
|
|
|
ioval = EM8300_VIDEOMODE_PAL;
|
|
|
|
} else if (dxr3_norm == 2) {
|
|
|
|
if (vo_fps > 28) {
|
|
|
|
ioval = EM8300_VIDEOMODE_PAL60;
|
|
|
|
} else {
|
|
|
|
ioval = EM8300_VIDEOMODE_PAL;
|
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Auto-selected TV norm by framerate: ");
|
2006-04-24 04:23:53 +00:00
|
|
|
ioval == EM8300_VIDEOMODE_PAL60 ? mp_msg(MSGT_VO,MSGL_INFO, "PAL-60") : mp_msg(MSGT_VO,MSGL_INFO, "PAL");
|
2009-07-06 23:26:13 +00:00
|
|
|
printf(".\n");
|
2003-01-02 18:54:16 +00:00
|
|
|
} else {
|
2002-12-24 12:45:32 +00:00
|
|
|
if (vo_fps > 28) {
|
|
|
|
ioval = EM8300_VIDEOMODE_NTSC;
|
|
|
|
} else {
|
|
|
|
ioval = EM8300_VIDEOMODE_PAL;
|
|
|
|
}
|
|
|
|
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Auto-selected TV norm by framerate: ");
|
2006-04-24 04:23:53 +00:00
|
|
|
ioval == EM8300_VIDEOMODE_NTSC ? mp_msg(MSGT_VO,MSGL_INFO, "NTSC") : mp_msg(MSGT_VO,MSGL_INFO, "PAL");
|
2009-07-06 23:26:13 +00:00
|
|
|
printf(".\n");
|
2002-12-24 12:45:32 +00:00
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2003-01-02 18:54:16 +00:00
|
|
|
if (old_vmode != ioval) {
|
|
|
|
if (ioctl(fd_control, EM8300_IOCTL_SET_VIDEOMODE, &ioval) < 0) {
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Unable to set TV norm!\n");
|
2003-01-02 18:54:16 +00:00
|
|
|
}
|
|
|
|
}
|
2002-12-24 12:45:32 +00:00
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
|
|
|
|
2002-02-13 00:38:23 +00:00
|
|
|
/* libavcodec requires a width and height that is x|16 */
|
2002-03-23 18:16:22 +00:00
|
|
|
aspect_save_orig(width, height);
|
2002-02-13 00:38:23 +00:00
|
|
|
aspect_save_prescale(d_width, d_height);
|
|
|
|
ioctl(fd_control, EM8300_IOCTL_GET_VIDEOMODE, &ioval);
|
|
|
|
if (ioval == EM8300_VIDEOMODE_NTSC) {
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Setting up for NTSC.\n");
|
2002-03-13 14:39:24 +00:00
|
|
|
aspect_save_screenres(352, 240);
|
2002-02-13 00:38:23 +00:00
|
|
|
} else {
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Setting up for PAL/SECAM.\n");
|
2002-03-13 14:39:24 +00:00
|
|
|
aspect_save_screenres(352, 288);
|
2002-02-13 00:38:23 +00:00
|
|
|
}
|
|
|
|
aspect(&s_width, &s_height, A_ZOOM);
|
2002-03-13 14:15:00 +00:00
|
|
|
s_width -= s_width % 16;
|
2002-03-23 18:16:22 +00:00
|
|
|
s_height -= s_height % 16;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-01-11 22:30:28 +00:00
|
|
|
/* Try to figure out whether to use widescreen output or not */
|
Added new syncengine thanks to a new previously undocumented feature of the em8300, this might fix playback on both slow and fast machines (more testing needed). This also requires users to get the em8300 driver from cvs until the next version is released (will probably happen this weekend)
Added lots of comments, should be pretty easy to understand most of the internals now
Added lots of brackets to if's for's while's etc, this is not a cosmetical thing but rather due to the fact I got some very odd bugs with else's since I didn't properly use brackets (and it's the K&R standard to have brackets everywhere)
Fixed some bugs that would occur when disabling libmp1e
Switched to default to the new naming scheme of device nodes, the driver will slowly switch over to this state, if it can't find devices under the new name it will try the old naming scheme
I stopped opening devices in non-blocking mode, it would break the new syncengine which tries to burst data to the device (alot of times meaning it will fill the fifo pretty fast which would previously result in jerkyness on fast machines)
The device now sets the initial state of the pts and speed (probably not needed, but assumption is the mother of all fuckups =)
Keep the control interface open during the entire duration of the libvo device, we might need this to flush video buffers on seeking (currently not implemented, therefore seeking is broken)
This is beta stuff to the driver, I will get some users to test it for me and do my best to fix seeking as soon as possible...
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4219 b3059339-0415-0410-9bf9-f77b7e298cf2
2002-01-17 10:33:47 +00:00
|
|
|
/* Anamorphic widescreen modes makes this a pain in the ass */
|
2002-02-13 00:38:23 +00:00
|
|
|
tmp1 = abs(d_height - ((d_width / 4) * 3));
|
|
|
|
tmp2 = abs(d_height - (int) (d_width / 2.35));
|
2002-01-11 22:30:28 +00:00
|
|
|
if (tmp1 < tmp2) {
|
|
|
|
ioval = EM8300_ASPECTRATIO_4_3;
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Setting aspect ratio to 4:3.\n");
|
2002-01-11 22:30:28 +00:00
|
|
|
} else {
|
|
|
|
ioval = EM8300_ASPECTRATIO_16_9;
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Setting aspect ratio to 16:9.\n");
|
2001-11-29 17:31:58 +00:00
|
|
|
}
|
2002-01-11 22:30:28 +00:00
|
|
|
ioctl(fd_control, EM8300_IOCTL_SET_ASPECTRATIO, &ioval);
|
2002-03-26 18:47:42 +00:00
|
|
|
|
2002-07-05 14:26:37 +00:00
|
|
|
#ifdef SPU_SUPPORT
|
2008-08-07 10:36:07 +00:00
|
|
|
#ifdef CONFIG_FREETYPE
|
2003-01-12 19:32:56 +00:00
|
|
|
if (ioval == EM8300_ASPECTRATIO_16_9) {
|
2003-02-18 23:22:44 +00:00
|
|
|
s_width *= d_height*1.78/s_height*(d_width*1.0/d_height)/2.35;
|
2003-01-12 19:32:56 +00:00
|
|
|
} else {
|
|
|
|
s_width *= 0.84;
|
|
|
|
}
|
2003-02-18 23:22:44 +00:00
|
|
|
//printf("VO: [dxr3] sw/sh:dw/dh ->%i,%i,%i,%i\n",s_width,s_height,d_width,d_height);
|
2002-08-29 23:15:24 +00:00
|
|
|
#else
|
2002-08-22 13:58:38 +00:00
|
|
|
s_width*=2;
|
|
|
|
s_height*=2;
|
2002-08-29 23:15:24 +00:00
|
|
|
#endif
|
2002-08-22 13:58:38 +00:00
|
|
|
|
|
|
|
osdpicbuf = calloc( 1,s_width * s_height);
|
2002-07-05 14:26:37 +00:00
|
|
|
if (osdpicbuf == NULL) {
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_DXR3] out of memory\n");
|
2002-07-05 14:26:37 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
spued = (encodedata *) malloc(sizeof(encodedata));
|
|
|
|
if (spued == NULL) {
|
2002-08-22 13:58:38 +00:00
|
|
|
free( osdpicbuf );
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_DXR3] out of memory\n");
|
2002-08-22 13:58:38 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2002-10-29 01:38:42 +00:00
|
|
|
spubuf = (encodedata *) malloc(sizeof(encodedata));
|
|
|
|
if (spubuf == NULL) {
|
2002-08-22 13:58:38 +00:00
|
|
|
free( osdpicbuf );
|
|
|
|
free( spued );
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_DXR3] out of memory\n");
|
2002-07-05 14:26:37 +00:00
|
|
|
return -1;
|
2001-11-29 17:31:58 +00:00
|
|
|
}
|
2002-07-05 14:26:37 +00:00
|
|
|
osd_w = s_width;
|
|
|
|
osd_h = s_height;
|
|
|
|
osdpicbuf_w = s_width;
|
|
|
|
osdpicbuf_h = s_height;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-10-29 01:38:42 +00:00
|
|
|
spubuf->count=0;
|
|
|
|
pixbuf_encode_rle( 0,0,osdpicbuf_w,osdpicbuf_h - 1,osdpicbuf,osdpicbuf_w,spubuf );
|
2002-08-22 13:58:38 +00:00
|
|
|
|
2002-07-05 14:26:37 +00:00
|
|
|
#endif
|
2001-11-08 21:51:28 +00:00
|
|
|
|
2008-08-04 06:16:23 +00:00
|
|
|
#ifdef CONFIG_X11
|
2002-11-03 20:05:39 +00:00
|
|
|
if (dxr3_overlay) {
|
2002-11-02 01:18:54 +00:00
|
|
|
XVisualInfo vinfo;
|
|
|
|
XSetWindowAttributes xswa;
|
|
|
|
XSizeHints hint;
|
|
|
|
unsigned long xswamask;
|
|
|
|
Colormap cmap;
|
|
|
|
XColor key_color;
|
|
|
|
Window junkwindow;
|
|
|
|
Screen *scr;
|
|
|
|
int depth, red_shift, red_prec, green_shift, green_prec, blue_shift, blue_prec, acq_color;
|
|
|
|
em8300_overlay_screen_t ovlscr;
|
|
|
|
em8300_attribute_t ovlattr;
|
|
|
|
|
2002-11-02 11:24:53 +00:00
|
|
|
vo_dx = (vo_screenwidth - d_width) / 2;
|
|
|
|
vo_dy = (vo_screenheight - d_height) / 2;
|
|
|
|
vo_dwidth = d_width;
|
|
|
|
vo_dheight = d_height;
|
2002-11-02 01:18:54 +00:00
|
|
|
{
|
|
|
|
XGetWindowAttributes(mDisplay, DefaultRootWindow(mDisplay), &xwin_attribs);
|
|
|
|
depth = xwin_attribs.depth;
|
|
|
|
if (depth != 15 && depth != 16 && depth != 24 && depth != 32) {
|
|
|
|
depth = 24;
|
|
|
|
}
|
|
|
|
XMatchVisualInfo(mDisplay, mScreen, depth, TrueColor, &vinfo);
|
2007-06-27 10:26:13 +00:00
|
|
|
vo_x11_create_vo_window(&vinfo, vo_dx, vo_dy,
|
|
|
|
d_width, d_height, flags,
|
|
|
|
CopyFromParent, "Viewing Window", title);
|
2002-11-02 01:18:54 +00:00
|
|
|
xswa.background_pixel = KEY_COLOR;
|
|
|
|
xswa.border_pixel = 0;
|
|
|
|
xswamask = CWBackPixel | CWBorderPixel;
|
2007-06-27 10:26:13 +00:00
|
|
|
XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xswa);
|
2002-11-02 01:18:54 +00:00
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-11-02 01:18:54 +00:00
|
|
|
/* Start setting up overlay */
|
|
|
|
XGetWindowAttributes(mDisplay, mRootWin, &xwin_attribs);
|
|
|
|
overlay_set_screen(overlay_data, xwin_attribs.width, xwin_attribs.height, xwin_attribs.depth);
|
|
|
|
overlay_read_state(overlay_data, NULL);
|
|
|
|
|
|
|
|
/* Allocate keycolor */
|
|
|
|
cmap = vo_x11_create_colormap(&vinfo);
|
|
|
|
calculate_cvals(vinfo.red_mask, &red_shift, &red_prec);
|
|
|
|
calculate_cvals(vinfo.green_mask, &green_shift, &green_prec);
|
|
|
|
calculate_cvals(vinfo.blue_mask, &blue_shift, &blue_prec);
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-11-02 01:18:54 +00:00
|
|
|
key_color.red = ((KEY_COLOR >> 16) & 0xff) * 256;
|
|
|
|
key_color.green = ((KEY_COLOR >> 8) & 0xff) * 256;
|
|
|
|
key_color.blue = (KEY_COLOR & 0xff) * 256;
|
|
|
|
key_color.pixel = (((key_color.red >> (16 - red_prec)) << red_shift) +
|
|
|
|
((key_color.green >> (16 - green_prec)) << green_shift) +
|
|
|
|
((key_color.blue >> (16 - blue_prec)) << blue_shift));
|
|
|
|
key_color.flags = DoRed | DoGreen | DoBlue;
|
|
|
|
if (!XAllocColor(mDisplay, cmap, &key_color)) {
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_DXR3] Unable to allocate keycolor!\n");
|
2002-11-02 01:18:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-11-02 01:18:54 +00:00
|
|
|
acq_color = ((key_color.red / 256) << 16) | ((key_color.green / 256) << 8) | key_color.blue;
|
2002-11-02 11:24:53 +00:00
|
|
|
if (key_color.pixel != KEY_COLOR) {
|
2009-07-06 23:26:13 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Unable to allocate exact keycolor, using closest match (0x%lx).\n", key_color.pixel);
|
2002-11-02 01:18:54 +00:00
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-11-02 01:18:54 +00:00
|
|
|
/* Set keycolor and activate overlay */
|
2002-11-02 11:24:53 +00:00
|
|
|
XSetWindowBackground(mDisplay, vo_window, key_color.pixel);
|
|
|
|
XClearWindow(mDisplay, vo_window);
|
|
|
|
overlay_set_keycolor(overlay_data, key_color.pixel);
|
2002-11-02 01:18:54 +00:00
|
|
|
overlay_set_mode(overlay_data, EM8300_OVERLAY_MODE_OVERLAY);
|
|
|
|
overlay_set_mode(overlay_data, EM8300_OVERLAY_MODE_RECTANGLE);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-07-05 14:26:37 +00:00
|
|
|
return 0;
|
2001-11-03 02:38:10 +00:00
|
|
|
}
|
|
|
|
|
2002-02-09 10:43:11 +00:00
|
|
|
static void draw_alpha(int x, int y, int w, int h, unsigned char* src, unsigned char *srca, int srcstride)
|
2001-11-03 02:38:10 +00:00
|
|
|
{
|
2002-07-05 14:26:37 +00:00
|
|
|
#ifdef SPU_SUPPORT
|
|
|
|
unsigned char *buf = &osdpicbuf[(y * osdpicbuf_w) + x];
|
2002-08-22 13:58:38 +00:00
|
|
|
int by = 0;
|
|
|
|
register int lx, ly;
|
|
|
|
register int stride = 0;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
|
|
|
for (ly = 0; ly < h - 1; ly++)
|
2002-08-22 13:58:38 +00:00
|
|
|
{
|
|
|
|
for(lx = 0; lx < w; lx++ )
|
|
|
|
if ( ( srca[stride + lx] )&&( src[stride + lx] >= 128 ) ) buf[by + lx] = 3;
|
|
|
|
by+=osdpicbuf_w;
|
|
|
|
stride+=srcstride;
|
2002-04-04 16:11:09 +00:00
|
|
|
}
|
2002-07-05 14:26:37 +00:00
|
|
|
pixbuf_encode_rle(x, y, osdpicbuf_w, osdpicbuf_h - 1, osdpicbuf, osdpicbuf_w, spued);
|
|
|
|
#endif
|
2001-11-03 02:38:10 +00:00
|
|
|
}
|
|
|
|
|
2002-08-22 13:58:38 +00:00
|
|
|
extern int vo_osd_changed_flag;
|
|
|
|
extern mp_osd_obj_t* vo_osd_list;
|
|
|
|
|
2001-11-03 02:38:10 +00:00
|
|
|
static void draw_osd(void)
|
|
|
|
{
|
2002-07-05 14:26:37 +00:00
|
|
|
#ifdef SPU_SUPPORT
|
2002-08-22 13:58:38 +00:00
|
|
|
static int cleared = 0;
|
|
|
|
int changed = 0;
|
|
|
|
|
2009-07-06 23:26:13 +00:00
|
|
|
if ((disposd % 15) == 0)
|
2002-08-22 13:58:38 +00:00
|
|
|
{
|
|
|
|
{
|
|
|
|
mp_osd_obj_t* obj = vo_osd_list;
|
|
|
|
vo_update_osd( osd_w,osd_h );
|
|
|
|
while( obj )
|
|
|
|
{
|
|
|
|
if ( obj->flags & OSDFLAG_VISIBLE ) { changed=1; break; }
|
|
|
|
obj=obj->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( changed )
|
|
|
|
{
|
|
|
|
vo_draw_text(osd_w, osd_h, draw_alpha);
|
|
|
|
memset(osdpicbuf, 0, s_width * s_height);
|
|
|
|
cleared=0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( !cleared )
|
|
|
|
{
|
2002-10-29 01:38:42 +00:00
|
|
|
spued->count=spubuf->count;
|
2007-06-05 14:27:54 +00:00
|
|
|
fast_memcpy( spued->data,spubuf->data,DATASIZE );
|
2002-08-22 13:58:38 +00:00
|
|
|
cleared=1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-05 14:26:37 +00:00
|
|
|
|
2002-04-04 16:11:09 +00:00
|
|
|
/* could stand some check here to see if the subpic hasn't changed
|
|
|
|
* as if it hasn't and we re-send it it will "blink" as the last one
|
|
|
|
* is turned off, and the new one (same one) is turned on
|
|
|
|
*/
|
2002-07-18 14:59:55 +00:00
|
|
|
/* Subpics are not stable yet =(
|
2002-08-22 13:58:38 +00:00
|
|
|
expect lockups if you enable */
|
|
|
|
#if 1
|
|
|
|
write(fd_spu, spued->data, spued->count);
|
|
|
|
#endif
|
Added new syncengine thanks to a new previously undocumented feature of the em8300, this might fix playback on both slow and fast machines (more testing needed). This also requires users to get the em8300 driver from cvs until the next version is released (will probably happen this weekend)
Added lots of comments, should be pretty easy to understand most of the internals now
Added lots of brackets to if's for's while's etc, this is not a cosmetical thing but rather due to the fact I got some very odd bugs with else's since I didn't properly use brackets (and it's the K&R standard to have brackets everywhere)
Fixed some bugs that would occur when disabling libmp1e
Switched to default to the new naming scheme of device nodes, the driver will slowly switch over to this state, if it can't find devices under the new name it will try the old naming scheme
I stopped opening devices in non-blocking mode, it would break the new syncengine which tries to burst data to the device (alot of times meaning it will fill the fifo pretty fast which would previously result in jerkyness on fast machines)
The device now sets the initial state of the pts and speed (probably not needed, but assumption is the mother of all fuckups =)
Keep the control interface open during the entire duration of the libvo device, we might need this to flush video buffers on seeking (currently not implemented, therefore seeking is broken)
This is beta stuff to the driver, I will get some users to test it for me and do my best to fix seeking as soon as possible...
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4219 b3059339-0415-0410-9bf9-f77b7e298cf2
2002-01-17 10:33:47 +00:00
|
|
|
}
|
2002-07-05 14:26:37 +00:00
|
|
|
disposd++;
|
|
|
|
#endif
|
2001-11-03 02:38:10 +00:00
|
|
|
}
|
|
|
|
|
2002-04-04 16:11:09 +00:00
|
|
|
|
2005-08-05 01:24:37 +00:00
|
|
|
static int draw_frame(uint8_t * src[])
|
2001-11-03 02:38:10 +00:00
|
|
|
{
|
2002-07-05 14:26:37 +00:00
|
|
|
vo_mpegpes_t *p = (vo_mpegpes_t *) src[0];
|
2002-11-02 01:18:54 +00:00
|
|
|
|
2002-07-05 14:26:37 +00:00
|
|
|
#ifdef SPU_SUPPORT
|
|
|
|
if (p->id == 0x20) {
|
|
|
|
write(fd_spu, p->data, p->size);
|
|
|
|
} else
|
2001-12-10 14:41:44 +00:00
|
|
|
#endif
|
2002-07-05 14:26:37 +00:00
|
|
|
write(fd_video, p->data, p->size);
|
|
|
|
return 0;
|
2001-11-03 02:38:10 +00:00
|
|
|
}
|
|
|
|
|
2002-01-11 22:30:28 +00:00
|
|
|
static void flip_page(void)
|
2001-11-03 02:38:10 +00:00
|
|
|
{
|
2008-08-04 06:16:23 +00:00
|
|
|
#ifdef CONFIG_X11
|
2002-11-03 20:05:39 +00:00
|
|
|
if (dxr3_overlay) {
|
2002-11-02 01:18:54 +00:00
|
|
|
int event = vo_x11_check_events(mDisplay);
|
|
|
|
if (event & VO_EVENT_RESIZE) {
|
|
|
|
Window junkwindow;
|
|
|
|
XGetWindowAttributes(mDisplay, vo_window, &xwin_attribs);
|
|
|
|
XTranslateCoordinates(mDisplay, vo_window, mRootWin, -xwin_attribs.border_width, -xwin_attribs.border_width, &xwin_attribs.x, &xwin_attribs.y, &junkwindow);
|
|
|
|
overlay_set_window(overlay_data, xwin_attribs.x, xwin_attribs.y, xwin_attribs.width, xwin_attribs.height);
|
|
|
|
}
|
|
|
|
if (event & VO_EVENT_EXPOSE) {
|
|
|
|
Window junkwindow;
|
|
|
|
XSetWindowBackground(mDisplay, vo_window, KEY_COLOR);
|
|
|
|
XClearWindow(mDisplay, vo_window);
|
|
|
|
XGetWindowAttributes(mDisplay, vo_window, &xwin_attribs);
|
|
|
|
XTranslateCoordinates(mDisplay, vo_window, mRootWin, -xwin_attribs.border_width, -xwin_attribs.border_width, &xwin_attribs.x, &xwin_attribs.y, &junkwindow);
|
|
|
|
overlay_set_window(overlay_data, xwin_attribs.x, xwin_attribs.y, xwin_attribs.width, xwin_attribs.height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-11-03 20:05:39 +00:00
|
|
|
if (dxr3_newsync) {
|
2002-10-29 01:38:42 +00:00
|
|
|
ioctl(fd_control, EM8300_IOCTL_SCR_GET, &ioval);
|
|
|
|
ioval <<= 1;
|
|
|
|
if (vo_pts == 0) {
|
|
|
|
ioval = 0;
|
|
|
|
ioctl(fd_control, EM8300_IOCTL_SCR_SET, &ioval);
|
|
|
|
pts_offset = 0;
|
|
|
|
} else if ((vo_pts - pts_offset) < (ioval - 7200) || (vo_pts - pts_offset) > (ioval + 7200)) {
|
|
|
|
ioval = (vo_pts + pts_offset) >> 1;
|
|
|
|
ioctl(fd_control, EM8300_IOCTL_SCR_SET, &ioval);
|
|
|
|
ioctl(fd_control, EM8300_IOCTL_SCR_GET, &ioval);
|
|
|
|
pts_offset = vo_pts - (ioval << 1);
|
|
|
|
if (pts_offset < 0) {
|
|
|
|
pts_offset = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ioval = vo_pts + pts_offset;
|
|
|
|
ioctl(fd_video, EM8300_IOCTL_SPU_SETPTS, &ioval);
|
|
|
|
ioctl(fd_video, EM8300_IOCTL_VIDEO_SETPTS, &ioval);
|
|
|
|
prev_pts = vo_pts;
|
2002-11-03 20:05:39 +00:00
|
|
|
} else if (dxr3_prebuf) {
|
2002-10-29 01:38:42 +00:00
|
|
|
ioctl(fd_spu, EM8300_IOCTL_SPU_SETPTS, &vo_pts);
|
2002-02-18 18:23:14 +00:00
|
|
|
ioctl(fd_video, EM8300_IOCTL_VIDEO_SETPTS, &vo_pts);
|
|
|
|
}
|
2001-11-03 02:38:10 +00:00
|
|
|
}
|
|
|
|
|
2005-08-05 01:24:37 +00:00
|
|
|
static int draw_slice(uint8_t *srcimg[], int stride[], int w, int h, int x0, int y0)
|
2001-11-03 02:38:10 +00:00
|
|
|
{
|
2002-01-11 22:30:28 +00:00
|
|
|
return -1;
|
2001-11-03 02:38:10 +00:00
|
|
|
}
|
|
|
|
|
2001-11-29 19:18:48 +00:00
|
|
|
static void uninit(void)
|
2001-11-03 02:38:10 +00:00
|
|
|
{
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Uninitializing.\n");
|
2008-08-04 06:16:23 +00:00
|
|
|
#ifdef CONFIG_X11
|
2002-11-03 20:05:39 +00:00
|
|
|
if (dxr3_overlay) {
|
2002-11-02 01:18:54 +00:00
|
|
|
overlay_set_mode(overlay_data, EM8300_OVERLAY_MODE_OFF);
|
|
|
|
overlay_release(overlay_data);
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-11-02 01:18:54 +00:00
|
|
|
vo_x11_uninit();
|
2002-11-03 20:05:39 +00:00
|
|
|
|
2002-11-02 01:18:54 +00:00
|
|
|
}
|
|
|
|
#endif
|
2003-01-02 18:54:16 +00:00
|
|
|
if (old_vmode != -1) {
|
|
|
|
if (ioctl(fd_control, EM8300_IOCTL_SET_VIDEOMODE, &old_vmode) < 0) {
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Failed restoring TV norm!\n");
|
2003-01-02 18:54:16 +00:00
|
|
|
}
|
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
Added new syncengine thanks to a new previously undocumented feature of the em8300, this might fix playback on both slow and fast machines (more testing needed). This also requires users to get the em8300 driver from cvs until the next version is released (will probably happen this weekend)
Added lots of comments, should be pretty easy to understand most of the internals now
Added lots of brackets to if's for's while's etc, this is not a cosmetical thing but rather due to the fact I got some very odd bugs with else's since I didn't properly use brackets (and it's the K&R standard to have brackets everywhere)
Fixed some bugs that would occur when disabling libmp1e
Switched to default to the new naming scheme of device nodes, the driver will slowly switch over to this state, if it can't find devices under the new name it will try the old naming scheme
I stopped opening devices in non-blocking mode, it would break the new syncengine which tries to burst data to the device (alot of times meaning it will fill the fifo pretty fast which would previously result in jerkyness on fast machines)
The device now sets the initial state of the pts and speed (probably not needed, but assumption is the mother of all fuckups =)
Keep the control interface open during the entire duration of the libvo device, we might need this to flush video buffers on seeking (currently not implemented, therefore seeking is broken)
This is beta stuff to the driver, I will get some users to test it for me and do my best to fix seeking as soon as possible...
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4219 b3059339-0415-0410-9bf9-f77b7e298cf2
2002-01-17 10:33:47 +00:00
|
|
|
if (fd_video) {
|
2002-01-11 22:30:28 +00:00
|
|
|
close(fd_video);
|
Added new syncengine thanks to a new previously undocumented feature of the em8300, this might fix playback on both slow and fast machines (more testing needed). This also requires users to get the em8300 driver from cvs until the next version is released (will probably happen this weekend)
Added lots of comments, should be pretty easy to understand most of the internals now
Added lots of brackets to if's for's while's etc, this is not a cosmetical thing but rather due to the fact I got some very odd bugs with else's since I didn't properly use brackets (and it's the K&R standard to have brackets everywhere)
Fixed some bugs that would occur when disabling libmp1e
Switched to default to the new naming scheme of device nodes, the driver will slowly switch over to this state, if it can't find devices under the new name it will try the old naming scheme
I stopped opening devices in non-blocking mode, it would break the new syncengine which tries to burst data to the device (alot of times meaning it will fill the fifo pretty fast which would previously result in jerkyness on fast machines)
The device now sets the initial state of the pts and speed (probably not needed, but assumption is the mother of all fuckups =)
Keep the control interface open during the entire duration of the libvo device, we might need this to flush video buffers on seeking (currently not implemented, therefore seeking is broken)
This is beta stuff to the driver, I will get some users to test it for me and do my best to fix seeking as soon as possible...
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4219 b3059339-0415-0410-9bf9-f77b7e298cf2
2002-01-17 10:33:47 +00:00
|
|
|
}
|
|
|
|
if (fd_spu) {
|
2002-01-11 22:30:28 +00:00
|
|
|
close(fd_spu);
|
Added new syncengine thanks to a new previously undocumented feature of the em8300, this might fix playback on both slow and fast machines (more testing needed). This also requires users to get the em8300 driver from cvs until the next version is released (will probably happen this weekend)
Added lots of comments, should be pretty easy to understand most of the internals now
Added lots of brackets to if's for's while's etc, this is not a cosmetical thing but rather due to the fact I got some very odd bugs with else's since I didn't properly use brackets (and it's the K&R standard to have brackets everywhere)
Fixed some bugs that would occur when disabling libmp1e
Switched to default to the new naming scheme of device nodes, the driver will slowly switch over to this state, if it can't find devices under the new name it will try the old naming scheme
I stopped opening devices in non-blocking mode, it would break the new syncengine which tries to burst data to the device (alot of times meaning it will fill the fifo pretty fast which would previously result in jerkyness on fast machines)
The device now sets the initial state of the pts and speed (probably not needed, but assumption is the mother of all fuckups =)
Keep the control interface open during the entire duration of the libvo device, we might need this to flush video buffers on seeking (currently not implemented, therefore seeking is broken)
This is beta stuff to the driver, I will get some users to test it for me and do my best to fix seeking as soon as possible...
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4219 b3059339-0415-0410-9bf9-f77b7e298cf2
2002-01-17 10:33:47 +00:00
|
|
|
}
|
|
|
|
if (fd_control) {
|
|
|
|
close(fd_control);
|
|
|
|
}
|
2002-07-05 14:26:37 +00:00
|
|
|
#ifdef SPU_SUPPORT
|
2002-04-04 16:11:09 +00:00
|
|
|
if(osdpicbuf) {
|
|
|
|
free(osdpicbuf);
|
|
|
|
}
|
|
|
|
if(spued) {
|
|
|
|
free(spued);
|
|
|
|
}
|
2002-07-05 14:26:37 +00:00
|
|
|
#endif
|
2001-11-03 02:38:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void check_events(void)
|
|
|
|
{
|
|
|
|
}
|
2002-01-26 16:01:26 +00:00
|
|
|
|
2005-08-05 01:24:37 +00:00
|
|
|
static int preinit(const char *arg)
|
2002-01-26 16:01:26 +00:00
|
|
|
{
|
2004-06-25 16:49:53 +00:00
|
|
|
char devname[MAX_STR_SIZE];
|
2002-02-09 11:35:24 +00:00
|
|
|
int fdflags = O_WRONLY;
|
2002-03-15 17:24:27 +00:00
|
|
|
|
2002-10-29 01:38:42 +00:00
|
|
|
/* Parse commandline */
|
|
|
|
while (arg) {
|
2002-11-03 20:05:39 +00:00
|
|
|
if (!strncmp("prebuf", arg, 6) && !dxr3_prebuf) {
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Enabling prebuffering.\n");
|
2002-11-03 20:05:39 +00:00
|
|
|
dxr3_prebuf = 1;
|
|
|
|
} else if (!strncmp("sync", arg, 4) && !dxr3_newsync) {
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Using new sync engine.\n");
|
2002-11-03 20:05:39 +00:00
|
|
|
dxr3_newsync = 1;
|
|
|
|
} else if (!strncmp("overlay", arg, 7) && !dxr3_overlay) {
|
2008-08-04 06:16:23 +00:00
|
|
|
#ifdef CONFIG_X11
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Using overlay.\n");
|
2002-11-03 20:05:39 +00:00
|
|
|
dxr3_overlay = 1;
|
2002-11-02 01:18:54 +00:00
|
|
|
#else
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Error: Overlay requires compiling with X11 libs/headers installed.\n");
|
2002-11-02 01:18:54 +00:00
|
|
|
#endif
|
2002-12-24 12:45:32 +00:00
|
|
|
} else if (!strncmp("norm=", arg, 5)) {
|
|
|
|
arg += 5;
|
|
|
|
// dxr3_norm is 0 (-> don't change norm) by default
|
|
|
|
// but maybe someone changes this in the future
|
|
|
|
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Will set TV norm to: ");
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-12-24 12:45:32 +00:00
|
|
|
if (*arg == '5') {
|
|
|
|
dxr3_norm = 5;
|
2006-04-24 04:23:53 +00:00
|
|
|
mp_msg(MSGT_VO,MSGL_INFO, "NTSC");
|
2002-12-24 12:45:32 +00:00
|
|
|
} else if (*arg == '4') {
|
|
|
|
dxr3_norm = 4;
|
2006-04-24 04:23:53 +00:00
|
|
|
mp_msg(MSGT_VO,MSGL_INFO, "PAL-60");
|
2002-12-24 12:45:32 +00:00
|
|
|
} else if (*arg == '3') {
|
|
|
|
dxr3_norm = 3;
|
2006-04-24 04:23:53 +00:00
|
|
|
mp_msg(MSGT_VO,MSGL_INFO, "PAL");
|
2002-12-24 12:45:32 +00:00
|
|
|
} else if (*arg == '2') {
|
|
|
|
dxr3_norm = 2;
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_INFO, "auto-adjust to movie framerate (PAL/PAL-60)");
|
2002-12-24 12:45:32 +00:00
|
|
|
} else if (*arg == '1') {
|
|
|
|
dxr3_norm = 1;
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_INFO, "auto-adjust to movie framerate (PAL/NTSC)");
|
2002-12-24 12:45:32 +00:00
|
|
|
} else if (*arg == '0') {
|
|
|
|
dxr3_norm = 0;
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_INFO, "Use current norm.");
|
2002-12-24 12:45:32 +00:00
|
|
|
} else {
|
|
|
|
dxr3_norm = 0;
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_INFO, "Unknown norm supplied. Use current norm.");
|
2002-12-24 12:45:32 +00:00
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2006-04-24 04:23:53 +00:00
|
|
|
mp_msg(MSGT_VO,MSGL_INFO, ".\n");
|
2002-10-29 01:38:42 +00:00
|
|
|
} else if (arg[0] == '0' || arg[0] == '1' || arg[0] == '2' || arg[0] == '3') {
|
2002-11-03 20:05:39 +00:00
|
|
|
dxr3_device_num = arg[0];
|
2002-10-29 01:38:42 +00:00
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-03-28 15:05:51 +00:00
|
|
|
arg = strchr(arg, ':');
|
|
|
|
if (arg) {
|
|
|
|
arg++;
|
|
|
|
}
|
2002-02-16 12:51:33 +00:00
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-03-26 18:47:42 +00:00
|
|
|
|
2002-10-29 01:38:42 +00:00
|
|
|
/* Open the control interface */
|
2002-11-03 20:05:39 +00:00
|
|
|
sprintf(devname, "/dev/em8300-%d", dxr3_device_num);
|
2002-02-03 14:55:27 +00:00
|
|
|
fd_control = open(devname, fdflags);
|
|
|
|
if (fd_control < 1) {
|
|
|
|
/* Fall back to old naming scheme */
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Error opening %s for writing, trying /dev/em8300 instead.\n", devname);
|
2002-02-03 14:55:27 +00:00
|
|
|
sprintf(devname, "/dev/em8300");
|
|
|
|
fd_control = open(devname, fdflags);
|
|
|
|
if (fd_control < 1) {
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_DXR3] Error opening /dev/em8300 for writing as well!\nBailing out.\n");
|
2002-02-03 14:55:27 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2002-11-03 20:05:39 +00:00
|
|
|
} else {
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Opened: %s.\n", devname);
|
2002-02-03 14:55:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Open the video interface */
|
2002-11-03 20:05:39 +00:00
|
|
|
sprintf(devname, "/dev/em8300_mv-%d", dxr3_device_num);
|
2002-02-03 14:55:27 +00:00
|
|
|
fd_video = open(devname, fdflags);
|
|
|
|
if (fd_video < 0) {
|
|
|
|
/* Fall back to old naming scheme */
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Error opening %s for writing, trying /dev/em8300_mv instead.\n", devname);
|
2002-02-03 14:55:27 +00:00
|
|
|
sprintf(devname, "/dev/em8300_mv");
|
|
|
|
fd_video = open(devname, fdflags);
|
|
|
|
if (fd_video < 0) {
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_DXR3] Error opening /dev/em8300_mv for writing as well!\nBailing out.\n");
|
2002-02-03 14:55:27 +00:00
|
|
|
uninit();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
} else {
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Opened: %s.\n", devname);
|
2002-02-03 14:55:27 +00:00
|
|
|
}
|
2002-02-09 10:43:11 +00:00
|
|
|
strcpy(fdv_name, devname);
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-02-03 14:55:27 +00:00
|
|
|
/* Open the subpicture interface */
|
2002-11-03 20:05:39 +00:00
|
|
|
sprintf(devname, "/dev/em8300_sp-%d", dxr3_device_num);
|
2002-02-03 14:55:27 +00:00
|
|
|
fd_spu = open(devname, fdflags);
|
|
|
|
if (fd_spu < 0) {
|
|
|
|
/* Fall back to old naming scheme */
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Error opening %s for writing, trying /dev/em8300_sp instead.\n", devname);
|
2002-02-03 14:55:27 +00:00
|
|
|
sprintf(devname, "/dev/em8300_sp");
|
|
|
|
fd_spu = open(devname, fdflags);
|
|
|
|
if (fd_spu < 0) {
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_DXR3] Error opening /dev/em8300_sp for writing as well!\nBailing out.\n");
|
2002-02-03 14:55:27 +00:00
|
|
|
uninit();
|
|
|
|
return -1;
|
|
|
|
}
|
2002-11-03 20:05:39 +00:00
|
|
|
} else {
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Opened: %s.\n", devname);
|
2002-02-03 14:55:27 +00:00
|
|
|
}
|
2002-04-06 07:30:28 +00:00
|
|
|
strcpy(fds_name, devname);
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2008-08-04 06:16:23 +00:00
|
|
|
#ifdef CONFIG_X11
|
2002-11-03 20:05:39 +00:00
|
|
|
if (dxr3_overlay) {
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-11-02 01:18:54 +00:00
|
|
|
/* Fucked up hack needed to enable overlay.
|
|
|
|
* Will be removed as soon as I figure out
|
|
|
|
* how to make it work like it should
|
|
|
|
*/
|
|
|
|
Display *dpy;
|
|
|
|
overlay_t *ov;
|
|
|
|
XWindowAttributes attribs;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-11-02 01:18:54 +00:00
|
|
|
dpy = XOpenDisplay(NULL);
|
|
|
|
if (!dpy) {
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_DXR3] Unable to open display during overlay hack setup!\n");
|
2002-11-02 01:18:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
XGetWindowAttributes(dpy, RootWindow(dpy, DefaultScreen(dpy)), &attribs);
|
2002-11-02 11:24:53 +00:00
|
|
|
ov = overlay_init(fd_control);
|
2002-11-02 01:18:54 +00:00
|
|
|
overlay_set_screen(ov, attribs.width, attribs.height, PlanesOfScreen(ScreenOfDisplay(dpy, 0)));
|
|
|
|
overlay_read_state(ov, NULL);
|
|
|
|
overlay_set_keycolor(ov, KEY_COLOR);
|
|
|
|
overlay_set_mode(ov, EM8300_OVERLAY_MODE_OVERLAY);
|
|
|
|
overlay_set_mode(ov, EM8300_OVERLAY_MODE_RECTANGLE);
|
|
|
|
overlay_release(ov);
|
|
|
|
XCloseDisplay(dpy);
|
|
|
|
/* End of fucked up hack */
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-11-02 01:18:54 +00:00
|
|
|
/* Initialize overlay and X11 */
|
|
|
|
overlay_data = overlay_init(fd_control);
|
|
|
|
if (!vo_init()) {
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_DXR3] Unable to init X11!\n");
|
2002-11-02 01:18:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-11-03 20:05:39 +00:00
|
|
|
if (dxr3_newsync) {
|
|
|
|
ioctl(fd_control, EM8300_IOCTL_SCR_GET, &ioval);
|
|
|
|
pts_offset = vo_pts - (ioval << 1);
|
|
|
|
if (pts_offset < 0) {
|
|
|
|
pts_offset = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-02 01:18:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Begin overlay.c */
|
|
|
|
static int update_parameters(overlay_t *o)
|
|
|
|
{
|
|
|
|
overlay_set_attribute(o, EM9010_ATTRIBUTE_XOFFSET, o->xoffset);
|
|
|
|
overlay_set_attribute(o, EM9010_ATTRIBUTE_YOFFSET, o->yoffset);
|
|
|
|
overlay_set_attribute(o, EM9010_ATTRIBUTE_XCORR, o->xcorr);
|
|
|
|
overlay_set_attribute(o, EM9010_ATTRIBUTE_STABILITY, o->stability);
|
|
|
|
overlay_set_attribute(o, EM9010_ATTRIBUTE_JITTER, o->jitter);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-11-03 20:59:04 +00:00
|
|
|
static int overlay_set_attribute(overlay_t *o, int attribute, int value)
|
2002-11-02 01:18:54 +00:00
|
|
|
{
|
|
|
|
em8300_attribute_t attr;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-11-02 01:18:54 +00:00
|
|
|
attr.attribute = attribute;
|
|
|
|
attr.value = value;
|
|
|
|
if (ioctl(o->dev, EM8300_IOCTL_OVERLAY_SET_ATTRIBUTE, &attr)==-1)
|
|
|
|
{
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Failed setting overlay attribute.\n");
|
2002-11-02 01:18:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-11-03 20:59:04 +00:00
|
|
|
static overlay_t *overlay_init(int dev)
|
2002-11-02 01:18:54 +00:00
|
|
|
{
|
|
|
|
overlay_t *o;
|
|
|
|
|
|
|
|
o = (overlay_t *) malloc(sizeof(overlay_t));
|
|
|
|
|
|
|
|
if(!o)
|
|
|
|
return NULL;
|
|
|
|
|
2005-03-31 22:06:34 +00:00
|
|
|
memset(o,0,sizeof(overlay_t));
|
2002-11-02 01:18:54 +00:00
|
|
|
|
|
|
|
o->dev = dev;
|
|
|
|
o->xres = 1280; o->yres=1024; o->xcorr=1000;
|
|
|
|
o->color_interval=10;
|
|
|
|
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
2002-11-03 20:59:04 +00:00
|
|
|
static int overlay_release(overlay_t *o)
|
2002-11-02 01:18:54 +00:00
|
|
|
{
|
|
|
|
if(o)
|
|
|
|
free(o);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#define TYPE_INT 1
|
|
|
|
#define TYPE_XINT 2
|
|
|
|
#define TYPE_COEFF 3
|
|
|
|
#define TYPE_FLOAT 4
|
|
|
|
|
|
|
|
struct lut_entry {
|
|
|
|
char *name;
|
|
|
|
int type;
|
|
|
|
void *ptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct lut_entry *new_lookuptable(overlay_t *o)
|
|
|
|
{
|
|
|
|
struct lut_entry m[] = {
|
|
|
|
{"xoffset", TYPE_INT, &o->xoffset},
|
|
|
|
{"yoffset", TYPE_INT, &o->yoffset},
|
|
|
|
{"xcorr", TYPE_INT, &o->xcorr},
|
|
|
|
{"jitter", TYPE_INT, &o->jitter},
|
|
|
|
{"stability", TYPE_INT, &o->stability},
|
|
|
|
{"keycolor", TYPE_XINT, &o->keycolor},
|
|
|
|
{"colcal_upper", TYPE_COEFF, &o->colcal_upper[0]},
|
|
|
|
{"colcal_lower", TYPE_COEFF, &o->colcal_lower[0]},
|
|
|
|
{"color_interval", TYPE_FLOAT, &o->color_interval},
|
|
|
|
{0,0,0}
|
|
|
|
},*p;
|
|
|
|
|
|
|
|
p = malloc(sizeof(m));
|
2007-06-05 15:09:49 +00:00
|
|
|
memcpy(p,m,sizeof(m));
|
2002-11-02 01:18:54 +00:00
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2002-11-03 20:59:04 +00:00
|
|
|
static int lookup_parameter(overlay_t *o, struct lut_entry *lut, char *name, void **ptr, int *type) {
|
2002-11-02 01:18:54 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i=0; lut[i].name; i++) {
|
|
|
|
if(!strcmp(name,lut[i].name)) {
|
|
|
|
*ptr = lut[i].ptr;
|
|
|
|
*type = lut[i].type;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-11-03 20:59:04 +00:00
|
|
|
static int overlay_read_state(overlay_t *o, char *p)
|
2002-11-02 01:18:54 +00:00
|
|
|
{
|
|
|
|
char *a,*tok;
|
|
|
|
char path[128],fname[128],tmp[128],line[256];
|
|
|
|
FILE *fp;
|
|
|
|
struct lut_entry *lut;
|
|
|
|
void *ptr;
|
|
|
|
int type;
|
|
|
|
int j;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-11-02 01:18:54 +00:00
|
|
|
if(!p) {
|
2007-07-05 22:01:07 +00:00
|
|
|
av_strlcpy(fname, getenv("HOME"), sizeof( fname ));
|
2009-07-06 23:26:13 +00:00
|
|
|
av_strlcat(fname,"/.overlay", sizeof( fname ));
|
2002-11-02 01:18:54 +00:00
|
|
|
} else
|
2007-07-05 22:01:07 +00:00
|
|
|
av_strlcpy(fname, p, sizeof( fname ));
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-11-02 01:18:54 +00:00
|
|
|
sprintf(tmp,"/res_%dx%dx%d",o->xres,o->yres,o->depth);
|
2007-07-05 22:01:07 +00:00
|
|
|
av_strlcat(fname, tmp, sizeof( fname ));
|
2002-11-02 01:18:54 +00:00
|
|
|
|
|
|
|
if(!(fp=fopen(fname,"r")))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
lut = new_lookuptable(o);
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-11-02 01:18:54 +00:00
|
|
|
while(!feof(fp)) {
|
|
|
|
if(!fgets(line,256,fp))
|
|
|
|
break;
|
|
|
|
tok=strtok(line," ");
|
|
|
|
if(lookup_parameter(o,lut,tok,&ptr,&type)) {
|
|
|
|
tok=strtok(NULL," ");
|
|
|
|
switch(type) {
|
|
|
|
case TYPE_INT:
|
|
|
|
sscanf(tok,"%d",(int *)ptr);
|
|
|
|
break;
|
|
|
|
case TYPE_XINT:
|
|
|
|
sscanf(tok,"%x",(int *)ptr);
|
|
|
|
break;
|
|
|
|
case TYPE_FLOAT:
|
|
|
|
sscanf(tok,"%f",(float *)ptr);
|
|
|
|
break;
|
|
|
|
case TYPE_COEFF:
|
|
|
|
for(j=0;j<3;j++) {
|
|
|
|
sscanf(tok,"%f",&((struct coeff *)ptr)[j].k);
|
|
|
|
tok=strtok(NULL," ");
|
|
|
|
sscanf(tok,"%f",&((struct coeff *)ptr)[j].m);
|
|
|
|
tok=strtok(NULL," ");
|
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
break;
|
2002-11-02 01:18:54 +00:00
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
|
|
|
}
|
2002-11-02 01:18:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
update_parameters(o);
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-11-02 01:18:54 +00:00
|
|
|
free(lut);
|
|
|
|
fclose(fp);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-11-03 20:59:04 +00:00
|
|
|
static void overlay_update_params(overlay_t *o) {
|
2002-11-02 01:18:54 +00:00
|
|
|
update_parameters(o);
|
|
|
|
}
|
|
|
|
|
2009-07-06 23:26:13 +00:00
|
|
|
static int overlay_write_state(overlay_t *o, char *p)
|
2002-11-02 01:18:54 +00:00
|
|
|
{
|
|
|
|
char *a;
|
|
|
|
char path[128],fname[128],tmp[128];
|
|
|
|
FILE *fp;
|
|
|
|
char line[256],*tok;
|
|
|
|
struct lut_entry *lut;
|
|
|
|
int i,j;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-11-02 01:18:54 +00:00
|
|
|
if(!p) {
|
2007-07-05 22:01:07 +00:00
|
|
|
av_strlcpy(fname, getenv("HOME"), sizeof( fname ));
|
2009-07-06 23:26:13 +00:00
|
|
|
av_strlcat(fname,"/.overlay", sizeof( fname ));
|
2002-11-02 01:18:54 +00:00
|
|
|
} else
|
2007-07-05 22:01:07 +00:00
|
|
|
av_strlcpy(fname, p, sizeof( fname ));
|
2002-11-02 01:18:54 +00:00
|
|
|
|
|
|
|
if(access(fname, W_OK|X_OK|R_OK)) {
|
|
|
|
if(mkdir(fname,0766))
|
|
|
|
return -1;
|
2009-07-06 23:26:13 +00:00
|
|
|
}
|
|
|
|
|
2002-11-02 01:18:54 +00:00
|
|
|
sprintf(tmp,"/res_%dx%dx%d",o->xres,o->yres,o->depth);
|
2007-07-05 22:01:07 +00:00
|
|
|
av_strlcat(fname, tmp, sizeof( fname ));
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-11-02 01:18:54 +00:00
|
|
|
if(!(fp=fopen(fname,"w")))
|
|
|
|
return -1;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-11-02 01:18:54 +00:00
|
|
|
lut = new_lookuptable(o);
|
|
|
|
|
2009-07-06 23:26:13 +00:00
|
|
|
for(i=0; lut[i].name; i++) {
|
2002-11-02 01:18:54 +00:00
|
|
|
fprintf(fp,"%s ",lut[i].name);
|
|
|
|
switch(lut[i].type) {
|
|
|
|
case TYPE_INT:
|
|
|
|
fprintf(fp,"%d\n",*(int *)lut[i].ptr);
|
|
|
|
break;
|
|
|
|
case TYPE_XINT:
|
|
|
|
fprintf(fp,"%06x\n",*(int *)lut[i].ptr);
|
|
|
|
break;
|
|
|
|
case TYPE_FLOAT:
|
|
|
|
fprintf(fp,"%f\n",*(float *)lut[i].ptr);
|
|
|
|
break;
|
|
|
|
case TYPE_COEFF:
|
2009-07-06 23:26:13 +00:00
|
|
|
for(j=0;j<3;j++)
|
2002-11-02 01:18:54 +00:00
|
|
|
fprintf(fp,"%f %f ",((struct coeff *)lut[i].ptr)[j].k,
|
|
|
|
((struct coeff *)lut[i].ptr)[j].m);
|
|
|
|
fprintf(fp,"\n");
|
2009-07-06 23:26:13 +00:00
|
|
|
break;
|
2002-11-02 01:18:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-11-03 20:59:04 +00:00
|
|
|
static int overlay_set_screen(overlay_t *o, int xres, int yres, int depth)
|
2002-11-02 01:18:54 +00:00
|
|
|
{
|
|
|
|
em8300_overlay_screen_t scr;
|
|
|
|
|
|
|
|
o->xres = xres;
|
|
|
|
o->yres = yres;
|
|
|
|
o->depth = depth;
|
|
|
|
|
|
|
|
scr.xsize = xres;
|
|
|
|
scr.ysize = yres;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-11-02 01:18:54 +00:00
|
|
|
if (ioctl(o->dev, EM8300_IOCTL_OVERLAY_SETSCREEN, &scr)==-1)
|
|
|
|
{
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Failed setting overlay screen!\nExiting.\n");
|
2002-11-02 01:18:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-11-03 20:59:04 +00:00
|
|
|
static int overlay_set_mode(overlay_t *o, int mode)
|
2002-11-02 01:18:54 +00:00
|
|
|
{
|
|
|
|
if (ioctl(o->dev, EM8300_IOCTL_OVERLAY_SETMODE, &mode)==-1) {
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Failed enabling overlay!\nExiting.\n");
|
2002-11-02 01:18:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-11-03 20:59:04 +00:00
|
|
|
static int overlay_set_window(overlay_t *o, int xpos,int ypos,int width,int height)
|
2002-11-02 01:18:54 +00:00
|
|
|
{
|
|
|
|
em8300_overlay_window_t win;
|
|
|
|
win.xpos = xpos;
|
|
|
|
win.ypos = ypos;
|
|
|
|
win.width = width;
|
|
|
|
win.height = height;
|
|
|
|
|
|
|
|
if (ioctl(o->dev, EM8300_IOCTL_OVERLAY_SETWINDOW, &win)==-1)
|
|
|
|
{
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Failed resizing overlay window!\n");
|
2002-11-02 01:18:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-11-03 20:59:04 +00:00
|
|
|
static int overlay_set_bcs(overlay_t *o, int brightness, int contrast, int saturation)
|
2002-11-02 01:18:54 +00:00
|
|
|
{
|
|
|
|
em8300_bcs_t bcs;
|
|
|
|
bcs.brightness = brightness;
|
|
|
|
bcs.contrast = contrast;
|
|
|
|
bcs.saturation = saturation;
|
|
|
|
|
|
|
|
if (ioctl(o->dev, EM8300_IOCTL_GETBCS, &bcs)==-1)
|
|
|
|
{
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Failed setting overlay bcs!\n");
|
2002-11-02 01:18:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int col_interp(float x, struct coeff c)
|
|
|
|
{
|
|
|
|
float y;
|
|
|
|
y = x*c.k + c.m;
|
|
|
|
if(y > 255)
|
|
|
|
y = 255;
|
|
|
|
if(y < 0)
|
|
|
|
y = 0;
|
|
|
|
return rint(y);
|
|
|
|
}
|
|
|
|
|
2002-11-03 20:59:04 +00:00
|
|
|
static int overlay_set_keycolor(overlay_t *o, int color) {
|
2002-11-02 01:18:54 +00:00
|
|
|
int r = (color & 0xff0000) >> 16;
|
|
|
|
int g = (color & 0x00ff00) >> 8;
|
|
|
|
int b = (color & 0x0000ff);
|
|
|
|
float ru,gu,bu;
|
|
|
|
float rl,gl,bl;
|
|
|
|
int upper,lower;
|
|
|
|
|
|
|
|
ru = r+o->color_interval;
|
|
|
|
gu = g+o->color_interval;
|
|
|
|
bu = b+o->color_interval;
|
|
|
|
|
|
|
|
rl = r-o->color_interval;
|
|
|
|
gl = g-o->color_interval;
|
|
|
|
bl = b-o->color_interval;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-11-02 01:18:54 +00:00
|
|
|
upper = (col_interp(ru, o->colcal_upper[0]) << 16) |
|
|
|
|
(col_interp(gu, o->colcal_upper[1]) << 8) |
|
|
|
|
(col_interp(bu, o->colcal_upper[2]));
|
|
|
|
|
|
|
|
lower = (col_interp(rl, o->colcal_lower[0]) << 16) |
|
|
|
|
(col_interp(gl, o->colcal_lower[1]) << 8) |
|
|
|
|
(col_interp(bl, o->colcal_lower[2]));
|
|
|
|
|
|
|
|
//printf("0x%06x 0x%06x\n",upper,lower);
|
|
|
|
overlay_set_attribute(o,EM9010_ATTRIBUTE_KEYCOLOR_UPPER,upper);
|
|
|
|
overlay_set_attribute(o,EM9010_ATTRIBUTE_KEYCOLOR_LOWER,lower);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void least_sq_fit(int *x, int *y, int n, float *k, float *m)
|
|
|
|
{
|
|
|
|
float sx=0,sy=0,sxx=0,sxy=0;
|
|
|
|
float delta,b;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i=0; i < n; i++) {
|
|
|
|
sx=sx+x[i];
|
|
|
|
sy=sy+y[i];
|
|
|
|
sxx=sxx+x[i]*x[i];
|
|
|
|
sxy=sxy+x[i]*y[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
delta=sxx*n-sx*sx;
|
|
|
|
|
|
|
|
*m=(sxx*sy-sx*sxy)/delta;
|
|
|
|
*k=(sxy*n-sx*sy)/delta;
|
|
|
|
}
|
|
|
|
|
2002-11-03 20:59:04 +00:00
|
|
|
static int overlay_autocalibrate(overlay_t *o, pattern_drawer_cb pd, void *arg)
|
2002-11-02 01:18:54 +00:00
|
|
|
{
|
|
|
|
em8300_overlay_calibrate_t cal;
|
|
|
|
em8300_overlay_window_t win;
|
|
|
|
int x[256],r[256],g[256],b[256],n;
|
|
|
|
float k,m;
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
o->draw_pattern=pd;
|
|
|
|
o->dp_arg = arg;
|
|
|
|
|
|
|
|
overlay_set_mode(o, EM8300_OVERLAY_MODE_OVERLAY);
|
|
|
|
overlay_set_screen(o, o->xres, o->yres, o->depth);
|
|
|
|
|
|
|
|
/* Calibrate Y-offset */
|
|
|
|
|
|
|
|
o->draw_pattern(0x0000ff, 0, 0, 0, 355, 1, o->dp_arg);
|
|
|
|
|
|
|
|
cal.cal_mode = EM8300_OVERLAY_CALMODE_YOFFSET;
|
|
|
|
if (ioctl(o->dev, EM8300_IOCTL_OVERLAY_CALIBRATE, &cal))
|
|
|
|
{
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Failed getting overlay Y-offset values!\nExiting.\n");
|
2002-11-02 01:18:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
o->yoffset = cal.result;
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Yoffset: %d.\n",cal.result);
|
2002-11-02 01:18:54 +00:00
|
|
|
|
|
|
|
/* Calibrate X-offset */
|
|
|
|
|
|
|
|
o->draw_pattern(0x0000ff, 0, 0, 0, 2, 288, o->dp_arg);
|
|
|
|
|
|
|
|
cal.cal_mode = EM8300_OVERLAY_CALMODE_XOFFSET;
|
|
|
|
if (ioctl(o->dev, EM8300_IOCTL_OVERLAY_CALIBRATE, &cal))
|
|
|
|
{
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Failed getting overlay X-offset values!\nExiting.\n");
|
2002-11-02 01:18:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
o->xoffset = cal.result;
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Xoffset: %d.\n",cal.result);
|
2002-11-02 01:18:54 +00:00
|
|
|
|
|
|
|
/* Calibrate X scale correction */
|
|
|
|
|
|
|
|
o->draw_pattern(0x0000ff, 0, 355, 0, 2, 288, o->dp_arg);
|
|
|
|
|
|
|
|
cal.cal_mode = EM8300_OVERLAY_CALMODE_XCORRECTION;
|
|
|
|
if (ioctl(o->dev, EM8300_IOCTL_OVERLAY_CALIBRATE, &cal))
|
|
|
|
{
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Failed getting overlay X scale correction!\nExiting.\n");
|
2002-11-02 01:18:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Xcorrection: %d.\n",cal.result);
|
2002-11-02 01:18:54 +00:00
|
|
|
o->xcorr = cal.result;
|
|
|
|
|
|
|
|
win.xpos = 10;
|
|
|
|
win.ypos = 10;
|
|
|
|
win.width = o->xres-20;
|
|
|
|
win.height = o->yres-20;
|
|
|
|
if (ioctl(o->dev, EM8300_IOCTL_OVERLAY_SETWINDOW, &win)==-1) {
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_DXR3] Failed resizing overlay window!\n");
|
2002-11-02 01:18:54 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Calibrate key color upper limit */
|
|
|
|
|
|
|
|
for(i=128,n=0; i <= 0xff; i+=4) {
|
|
|
|
o->draw_pattern(i | (i << 8) | (i << 16), 0,
|
|
|
|
(o->xres-200)/2,0,200,o->yres,o->dp_arg);
|
|
|
|
|
|
|
|
cal.arg = i;
|
|
|
|
cal.arg2 = 1;
|
|
|
|
cal.cal_mode = EM8300_OVERLAY_CALMODE_COLOR;
|
|
|
|
|
|
|
|
if (ioctl(o->dev, EM8300_IOCTL_OVERLAY_CALIBRATE, &cal))
|
|
|
|
{
|
|
|
|
return -1 ;
|
|
|
|
}
|
|
|
|
|
|
|
|
x[n] = i;
|
|
|
|
r[n] = (cal.result>>16)&0xff;
|
|
|
|
g[n] = (cal.result>>8)&0xff;
|
|
|
|
b[n] = (cal.result)&0xff;
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
|
|
|
|
least_sq_fit(x,r,n,&o->colcal_upper[0].k,&o->colcal_upper[0].m);
|
|
|
|
least_sq_fit(x,g,n,&o->colcal_upper[1].k,&o->colcal_upper[1].m);
|
|
|
|
least_sq_fit(x,b,n,&o->colcal_upper[2].k,&o->colcal_upper[2].m);
|
|
|
|
|
|
|
|
/* Calibrate key color lower limit */
|
|
|
|
|
|
|
|
for(i=128,n=0; i <= 0xff; i+=4) {
|
|
|
|
o->draw_pattern(i | (i << 8) | (i << 16), 0xffffff,
|
|
|
|
(o->xres-200)/2,0,200,o->yres, o->dp_arg);
|
|
|
|
|
|
|
|
cal.arg = i;
|
|
|
|
cal.arg2 = 2;
|
|
|
|
cal.cal_mode = EM8300_OVERLAY_CALMODE_COLOR;
|
|
|
|
|
|
|
|
if (ioctl(o->dev, EM8300_IOCTL_OVERLAY_CALIBRATE, &cal))
|
|
|
|
{
|
|
|
|
return -1 ;
|
|
|
|
}
|
|
|
|
x[n] = i;
|
|
|
|
r[n] = (cal.result>>16)&0xff;
|
|
|
|
g[n] = (cal.result>>8)&0xff;
|
|
|
|
b[n] = (cal.result)&0xff;
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
|
|
|
|
least_sq_fit(x,r,n,&o->colcal_lower[0].k,&o->colcal_lower[0].m);
|
|
|
|
least_sq_fit(x,g,n,&o->colcal_lower[1].k,&o->colcal_lower[1].m);
|
|
|
|
least_sq_fit(x,b,n,&o->colcal_lower[2].k,&o->colcal_lower[2].m);
|
|
|
|
|
|
|
|
overlay_set_mode(o, EM8300_OVERLAY_MODE_OFF);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-11-03 20:59:04 +00:00
|
|
|
static int overlay_signalmode(overlay_t *o, int mode) {
|
2002-11-02 01:18:54 +00:00
|
|
|
if(ioctl(o->dev, EM8300_IOCTL_OVERLAY_SIGNALMODE, &mode) ==-1) {
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Failed to set signal mix!\n");
|
2002-11-02 01:18:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2002-02-02 18:09:35 +00:00
|
|
|
return 0;
|
2002-01-26 16:01:26 +00:00
|
|
|
}
|
2002-11-02 01:18:54 +00:00
|
|
|
/* End overlay.c */
|