1
0
mirror of https://github.com/mpv-player/mpv synced 2025-04-01 00:07:33 +00:00

cosmetics: Reformat some lines to lessen differences to vo_fbdev.c.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27984 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
diego 2008-11-23 12:08:18 +00:00
parent 929dc9a8ac
commit 73fab6a412

View File

@ -73,21 +73,20 @@ static FILE *vt_fp = NULL;
static int vt_doit = 1; static int vt_doit = 1;
static int fb_dev_fd = -1; static int fb_dev_fd = -1;
static int fb_tty_fd = -1; static int fb_tty_fd = -1;
static size_t fb_size;
static uint8_t *frame_buffer; static uint8_t *frame_buffer;
static uint8_t *center; static uint8_t *center;
static struct fb_var_screeninfo fb_orig_vinfo; static struct fb_var_screeninfo fb_orig_vinfo;
static struct fb_var_screeninfo fb_vinfo; static struct fb_var_screeninfo fb_vinfo;
static int fb_line_len; static int fb_line_len;
static size_t fb_size; static int in_width;
static int in_height;
static int in_width, out_width; static int out_width;
static int in_height, out_height; static int out_height;
static int fs; static int fs;
static int static int fb_preinit (int reset)
fb_preinit (int reset)
{ {
static int fb_preinit_done = 0; static int fb_preinit_done = 0;
static int fb_works = 0; static int fb_works = 0;
@ -101,26 +100,18 @@ fb_preinit (int reset)
if (fb_preinit_done) if (fb_preinit_done)
return fb_works; return fb_works;
if ((fb_dev_fd = open (WII_DEV_NAME, O_RDWR)) == -1) if ((fb_dev_fd = open (WII_DEV_NAME, O_RDWR)) == -1) {
{ mp_msg(MSGT_VO, MSGL_ERR, "Can't open %s: %s\n", WII_DEV_NAME, strerror (errno));
mp_msg (MSGT_VO, MSGL_ERR,
"Can't open %s: %s\n", WII_DEV_NAME, strerror (errno));
goto err_out; goto err_out;
} }
if (ioctl (fb_dev_fd, FBIOGET_VSCREENINFO, &fb_vinfo)) {
if (ioctl (fb_dev_fd, FBIOGET_VSCREENINFO, &fb_vinfo)) mp_msg(MSGT_VO, MSGL_ERR, "Can't get VSCREENINFO: %s\n", strerror (errno));
{
mp_msg (MSGT_VO, MSGL_ERR,
"Can't get VSCREENINFO: %s\n", strerror (errno));
goto err_out_fd; goto err_out_fd;
} }
fb_orig_vinfo = fb_vinfo; fb_orig_vinfo = fb_vinfo;
if ((fb_tty_fd = open (TTY_DEV_NAME, O_RDWR)) < 0) if ((fb_tty_fd = open (TTY_DEV_NAME, O_RDWR)) < 0) {
{ mp_msg(MSGT_VO, MSGL_ERR, "notice: Can't open %s: %s\n", TTY_DEV_NAME, strerror (errno));
mp_msg (MSGT_VO, MSGL_ERR,
"Notice: Can't open %s: %s\n", TTY_DEV_NAME, strerror (errno));
goto err_out_fd; goto err_out_fd;
} }
@ -138,8 +129,7 @@ fb_preinit (int reset)
return 0; return 0;
} }
static void static void vt_set_textarea(int u, int l)
vt_set_textarea (int u, int l)
{ {
/* how can I determine the font height? /* how can I determine the font height?
* just use 16 for now * just use 16 for now
@ -147,19 +137,17 @@ vt_set_textarea (int u, int l)
int urow = ((u + 15) / 16) + 1; int urow = ((u + 15) / 16) + 1;
int lrow = l / 16; int lrow = l / 16;
mp_msg (MSGT_VO, MSGL_DBG2, mp_msg(MSGT_VO, MSGL_DBG2, "vt_set_textarea (%d, %d): %d,%d\n", u, l, urow, lrow);
"vt_set_textarea (%d, %d): %d,%d\n", u, l, urow, lrow);
if (vt_fp) if (vt_fp) {
{
fprintf (vt_fp, "\33[%d;%dr\33[%d;%dH", urow, lrow, lrow, 0); fprintf (vt_fp, "\33[%d;%dr\33[%d;%dH", urow, lrow, lrow, 0);
fflush (vt_fp); fflush (vt_fp);
} }
} }
static int static int config(uint32_t width, uint32_t height, uint32_t d_width,
config (uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title,
uint32_t d_height, uint32_t flags, char *title, uint32_t format) uint32_t format)
{ {
struct fb_fix_screeninfo fb_finfo; struct fb_fix_screeninfo fb_finfo;
uint32_t black = 0x00800080; uint32_t black = 0x00800080;
@ -170,8 +158,7 @@ config (uint32_t width, uint32_t height, uint32_t d_width,
if (pre_init_err == -2) if (pre_init_err == -2)
{ {
mp_msg (MSGT_VO, MSGL_ERR, mp_msg(MSGT_VO, MSGL_ERR, "Internal fatal error: config() was called before preinit()\n");
"Internal fatal error: config() was called before preinit()\n");
return -1; return -1;
} }
@ -187,22 +174,16 @@ config (uint32_t width, uint32_t height, uint32_t d_width,
fb_vinfo.xres_virtual = fb_vinfo.xres; fb_vinfo.xres_virtual = fb_vinfo.xres;
fb_vinfo.yres_virtual = fb_vinfo.yres; fb_vinfo.yres_virtual = fb_vinfo.yres;
if (fb_tty_fd >= 0 && ioctl (fb_tty_fd, KDSETMODE, KD_GRAPHICS) < 0) if (fb_tty_fd >= 0 && ioctl (fb_tty_fd, KDSETMODE, KD_GRAPHICS) < 0) {
{ mp_msg(MSGT_VO, MSGL_V, "Can't set graphics mode: %s\n", strerror (errno));
mp_msg (MSGT_VO, MSGL_V,
"Can't set graphics mode: %s\n", strerror (errno));
close (fb_tty_fd); close (fb_tty_fd);
fb_tty_fd = -1; fb_tty_fd = -1;
} }
if (ioctl (fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_vinfo)) if (ioctl (fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_vinfo)) {
{ mp_msg(MSGT_VO, MSGL_ERR, "Can't put VSCREENINFO: %s\n", strerror (errno));
mp_msg (MSGT_VO, MSGL_ERR, if (fb_tty_fd >= 0 && ioctl (fb_tty_fd, KDSETMODE, KD_TEXT) < 0) {
"Can't put VSCREENINFO: %s\n", strerror (errno)); mp_msg(MSGT_VO, MSGL_ERR, "Can't restore text mode: %s\n", strerror (errno));
if (fb_tty_fd >= 0 && ioctl (fb_tty_fd, KDSETMODE, KD_TEXT) < 0)
{
mp_msg (MSGT_VO, MSGL_ERR,
"Can't restore text mode: %s\n", strerror (errno));
} }
return 1; return 1;
} }
@ -213,22 +194,18 @@ config (uint32_t width, uint32_t height, uint32_t d_width,
out_height = fb_vinfo.yres; out_height = fb_vinfo.yres;
} }
if (out_width < in_width || out_height < in_height) if (out_width < in_width || out_height < in_height) {
{ mp_msg(MSGT_VO, MSGL_ERR, "screensize is smaller than video size\n");
mp_msg (MSGT_VO, MSGL_ERR, "Screensize is smaller than video size\n");
return 1; return 1;
} }
if (ioctl (fb_dev_fd, FBIOGET_FSCREENINFO, &fb_finfo)) if (ioctl (fb_dev_fd, FBIOGET_FSCREENINFO, &fb_finfo)) {
{ mp_msg(MSGT_VO, MSGL_ERR, "Can't get FSCREENINFO: %s\n", strerror (errno));
mp_msg (MSGT_VO, MSGL_ERR,
"Can't get FSCREENINFO: %s\n", strerror (errno));
return 1; return 1;
} }
if (fb_finfo.type != FB_TYPE_PACKED_PIXELS) if (fb_finfo.type != FB_TYPE_PACKED_PIXELS) {
{ mp_msg(MSGT_VO, MSGL_ERR, "type %d not supported\n", fb_finfo.type);
mp_msg (MSGT_VO, MSGL_ERR, "Type %d not supported\n", fb_finfo.type);
return 1; return 1;
} }
@ -240,8 +217,7 @@ config (uint32_t width, uint32_t height, uint32_t d_width,
MAP_SHARED, fb_dev_fd, 0); MAP_SHARED, fb_dev_fd, 0);
if (frame_buffer == (uint8_t *) -1) if (frame_buffer == (uint8_t *) -1)
{ {
mp_msg (MSGT_VO, MSGL_ERR, mp_msg(MSGT_VO, MSGL_ERR, "Can't mmap %s: %s\n", WII_DEV_NAME, strerror (errno));
"Can't mmap %s: %s\n", WII_DEV_NAME, strerror (errno));
return 1; return 1;
} }
@ -249,28 +225,23 @@ config (uint32_t width, uint32_t height, uint32_t d_width,
((out_width - in_width) / 2) * FB_PIXEL_SIZE + ((out_width - in_width) / 2) * FB_PIXEL_SIZE +
((out_height - in_height) / 2) * fb_line_len; ((out_height - in_height) / 2) * fb_line_len;
mp_msg (MSGT_VO, MSGL_DBG2, "Frame_buffer @ %p\n", frame_buffer); mp_msg(MSGT_VO, MSGL_DBG2, "frame_buffer @ %p\n", frame_buffer);
mp_msg (MSGT_VO, MSGL_DBG2, "Center @ %p\n", center); mp_msg(MSGT_VO, MSGL_DBG2, "center @ %p\n", center);
mp_msg (MSGT_VO, MSGL_V, mp_msg(MSGT_VO, MSGL_V, "pixel per line: %d\n", fb_line_len / FB_PIXEL_SIZE);
"Pixel per line: %d\n", fb_line_len / FB_PIXEL_SIZE);
/* blanking screen */ /* blanking screen */
for (temp = 0; temp < fb_size; temp += 4) for (temp = 0; temp < fb_size; temp += 4)
memcpy (frame_buffer + temp, (void *) &black, 4); memcpy (frame_buffer + temp, (void *) &black, 4);
vt_fd = open (TTY_DEV_NAME, O_WRONLY); vt_fd = open (TTY_DEV_NAME, O_WRONLY);
if (vt_doit && vt_fd == -1) if (vt_doit && vt_fd == -1) {
{ mp_msg(MSGT_VO, MSGL_ERR, "Can't open %s: %s\n", TTY_DEV_NAME, strerror (errno));
mp_msg (MSGT_VO, MSGL_ERR,
"Can't open %s: %s\n", TTY_DEV_NAME, strerror (errno));
vt_doit = 0; vt_doit = 0;
} }
vt_fp = fdopen (vt_fd, "w"); vt_fp = fdopen (vt_fd, "w");
if (vt_doit && !vt_fp) if (vt_doit && !vt_fp) {
{ mp_msg(MSGT_VO, MSGL_ERR, "Can't fdopen %s: %s\n", TTY_DEV_NAME, strerror (errno));
mp_msg (MSGT_VO, MSGL_ERR,
"Can't fdopen %s: %s\n", TTY_DEV_NAME, strerror (errno));
vt_doit = 0; vt_doit = 0;
} }
@ -280,8 +251,7 @@ config (uint32_t width, uint32_t height, uint32_t d_width,
return 0; return 0;
} }
static int static int query_format(uint32_t format)
query_format (uint32_t format)
{ {
if (!fb_preinit (0)) if (!fb_preinit (0))
return 0; return 0;
@ -292,9 +262,8 @@ query_format (uint32_t format)
return VFCAP_ACCEPT_STRIDE | VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW; return VFCAP_ACCEPT_STRIDE | VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW;
} }
static void static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src,
draw_alpha (int x0, int y0, int w, int h, unsigned char *srca, int stride)
unsigned char *src, unsigned char *srca, int stride)
{ {
unsigned char *dst; unsigned char *dst;
@ -302,22 +271,18 @@ draw_alpha (int x0, int y0, int w, int h,
vo_draw_alpha_yuy2 (w, h, src, srca, stride, dst, fb_line_len); vo_draw_alpha_yuy2 (w, h, src, srca, stride, dst, fb_line_len);
} }
static int static int draw_frame(uint8_t *src[])
draw_frame (uint8_t *src[])
{ {
return 1; return 1;
} }
static int static int draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y)
draw_slice (uint8_t *src[], int stride[], int w, int h, int x, int y)
{ {
uint8_t *d, *s; uint8_t *d, *s;
d = center + fb_line_len * y + FB_PIXEL_SIZE * x; d = center + fb_line_len * y + FB_PIXEL_SIZE * x;
s = src[0]; s = src[0];
while (h) {
while (h)
{
memcpy (d, s, w * FB_PIXEL_SIZE); memcpy (d, s, w * FB_PIXEL_SIZE);
d += fb_line_len; d += fb_line_len;
s += stride[0]; s += stride[0];
@ -327,71 +292,51 @@ draw_slice (uint8_t *src[], int stride[], int w, int h, int x, int y)
return 0; return 0;
} }
static void static void check_events(void)
check_events(void)
{ {
/* unused */
} }
static void static void flip_page(void)
flip_page (void)
{ {
/* unused */
} }
static void static void draw_osd(void)
draw_osd (void)
{ {
vo_draw_text (in_width, in_height, draw_alpha); vo_draw_text (in_width, in_height, draw_alpha);
} }
static void static void uninit(void)
uninit (void)
{ {
if (ioctl (fb_dev_fd, FBIOGET_VSCREENINFO, &fb_vinfo)) if (ioctl (fb_dev_fd, FBIOGET_VSCREENINFO, &fb_vinfo))
mp_msg (MSGT_VO, MSGL_WARN, mp_msg(MSGT_VO, MSGL_WARN, "ioctl FBIOGET_VSCREENINFO: %s\n", strerror (errno));
"ioctl FBIOGET_VSCREENINFO: %s\n", strerror (errno));
fb_orig_vinfo.xoffset = fb_vinfo.xoffset; fb_orig_vinfo.xoffset = fb_vinfo.xoffset;
fb_orig_vinfo.yoffset = fb_vinfo.yoffset; fb_orig_vinfo.yoffset = fb_vinfo.yoffset;
if (ioctl (fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_orig_vinfo)) if (ioctl (fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_orig_vinfo))
mp_msg (MSGT_VO, MSGL_WARN, mp_msg(MSGT_VO, MSGL_WARN, "Can't reset original fb_var_screeninfo: %s\n", strerror (errno));
"Can't reset original fb_var_screeninfo: %s\n", strerror (errno)); if (fb_tty_fd >= 0) {
if (fb_tty_fd >= 0)
{
if (ioctl (fb_tty_fd, KDSETMODE, KD_TEXT) < 0) if (ioctl (fb_tty_fd, KDSETMODE, KD_TEXT) < 0)
mp_msg (MSGT_VO, MSGL_WARN, mp_msg(MSGT_VO, MSGL_WARN, "Can't restore text mode: %s\n", strerror (errno));
"Can't restore text mode: %s\n", strerror (errno));
} }
if (vt_doit) if (vt_doit)
vt_set_textarea (0, fb_orig_vinfo.yres); vt_set_textarea (0, fb_orig_vinfo.yres);
close (fb_tty_fd); close (fb_tty_fd);
close (fb_dev_fd); close (fb_dev_fd);
if (frame_buffer) if (frame_buffer)
munmap (frame_buffer, fb_size); munmap (frame_buffer, fb_size);
frame_buffer = NULL; frame_buffer = NULL;
fb_preinit (1); fb_preinit (1);
} }
static int static int preinit(const char *vo_subdevice)
preinit (const char *vo_subdevice)
{ {
pre_init_err = 0; pre_init_err = 0;
if (!pre_init_err) if (!pre_init_err)
return pre_init_err = (fb_preinit (0) ? 0 : -1); return pre_init_err = (fb_preinit (0) ? 0 : -1);
return -1; return -1;
} }
static uint32_t static uint32_t get_image(mp_image_t *mpi)
get_image(mp_image_t *mpi)
{ {
if (((mpi->type != MP_IMGTYPE_STATIC) && (mpi->type != MP_IMGTYPE_TEMP)) || if (((mpi->type != MP_IMGTYPE_STATIC) && (mpi->type != MP_IMGTYPE_TEMP)) ||
(mpi->flags & MP_IMGFLAG_PLANAR) || (mpi->flags & MP_IMGFLAG_PLANAR) ||
@ -407,8 +352,7 @@ get_image(mp_image_t *mpi)
return VO_TRUE; return VO_TRUE;
} }
static int static int control(uint32_t request, void *data, ...)
control (uint32_t request, void *data, ...)
{ {
if (request == VOCTRL_GET_IMAGE) if (request == VOCTRL_GET_IMAGE)
return get_image (data); return get_image (data);