Make dhasetup more verbose based on code by
[mplayer/greg.git] / vidix / vidixlib.c
blob19c9ea3090c5a9a34c22d73ade0b91a759db17a4
1 /*
2 * VIDIX - VIDeo Interface for *niX.
3 * Copyright (C) 2002 Nick Kurshev
4 * Copyright (C) 2007 Benjamin Zores <ben@geexbox.org>
6 * This file is part of MPlayer.
8 * MPlayer is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * MPlayer is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with MPlayer; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 * This interface is introduced as universal one to MPEG decoder,
23 * Back End Scaler (BES) and YUV2RGB hw accelerators.
25 * In the future it may be expanded up to capturing and audio things.
26 * Main goal of this this interface imlpementation is providing DGA
27 * everywhere where it's possible (unlike X11 and other).
29 * This interface is based on v4l2, fbvid.h, mga_vid.h projects
30 * and personally my ideas.
32 * NOTE: This interface is introduces as driver interface.
35 #include <stdlib.h>
36 #include <stdio.h>
37 #include <errno.h>
38 #include <string.h>
40 #include "vidixlib.h"
41 #include "drivers.h"
42 #include "config.h"
43 #include "libavutil/common.h"
44 #include "mpbswap.h"
46 extern unsigned int vdlGetVersion( void )
48 return VIDIX_VERSION;
51 VDL_HANDLE vdlOpen(const char *path,const char *name,unsigned cap,int verbose)
53 VDXContext *ctx;
55 if (!(ctx = malloc (sizeof (VDXContext))))
56 return NULL;
57 memset (ctx, 0, sizeof (VDXContext));
59 /* register all drivers */
60 vidix_register_all_drivers ();
62 if (!vidix_find_driver (ctx, name, cap, verbose))
64 free (ctx);
65 return NULL;
68 if (verbose)
69 printf ("vidixlib: will use %s driver\n", ctx->drv->name);
71 if (!ctx->drv || !ctx->drv->init)
73 if (verbose)
74 printf ("vidixlib: Can't init driver\n");
75 free (ctx);
76 return NULL;
79 if (verbose)
80 printf ("vidixlib: Attempt to initialize driver at: %p\n",
81 ctx->drv->init);
83 if (ctx->drv->init () !=0)
85 if (verbose)
86 printf ("vidixlib: Can't init driver\n");
87 free (ctx);
88 return NULL;
91 if (verbose)
92 printf("vidixlib: '%s'successfully loaded\n", ctx->drv->name);
94 return ctx;
97 void vdlClose(VDL_HANDLE ctx)
99 if (ctx->drv->destroy)
100 ctx->drv->destroy ();
102 memset (ctx, 0, sizeof (VDXContext)); /* <- it's not stupid */
103 free (ctx);
106 int vdlGetCapability(VDL_HANDLE ctx, vidix_capability_t *cap)
108 return ctx->drv->get_caps (cap);
111 #define MPLAYER_IMGFMT_RGB (('R'<<24)|('G'<<16)|('B'<<8))
112 #define MPLAYER_IMGFMT_BGR (('B'<<24)|('G'<<16)|('R'<<8))
113 #define MPLAYER_IMGFMT_RGB_MASK 0xFFFFFF00
115 static uint32_t normalize_fourcc(uint32_t fourcc)
117 if((fourcc & MPLAYER_IMGFMT_RGB_MASK) == (MPLAYER_IMGFMT_RGB|0) ||
118 (fourcc & MPLAYER_IMGFMT_RGB_MASK) == (MPLAYER_IMGFMT_BGR|0))
119 return bswap_32(fourcc);
120 else return fourcc;
123 int vdlQueryFourcc(VDL_HANDLE ctx,vidix_fourcc_t *f)
125 f->fourcc = normalize_fourcc(f->fourcc);
126 return ctx->drv->query_fourcc (f);
129 int vdlConfigPlayback(VDL_HANDLE ctx,vidix_playback_t *p)
131 p->fourcc = normalize_fourcc(p->fourcc);
132 return ctx->drv->config_playback (p);
135 int vdlPlaybackOn(VDL_HANDLE ctx)
137 return ctx->drv->playback_on ();
140 int vdlPlaybackOff(VDL_HANDLE ctx)
142 return ctx->drv->playback_off ();
145 int vdlPlaybackFrameSelect(VDL_HANDLE ctx, unsigned frame_idx )
147 return ctx->drv->frame_sel ? ctx->drv->frame_sel (frame_idx) : ENOSYS;
150 int vdlPlaybackGetEq(VDL_HANDLE ctx, vidix_video_eq_t * e)
152 return ctx->drv->get_eq ? ctx->drv->get_eq (e) : ENOSYS;
155 int vdlPlaybackSetEq(VDL_HANDLE ctx, const vidix_video_eq_t * e)
157 return ctx->drv->set_eq ? ctx->drv->set_eq (e) : ENOSYS;
160 int vdlPlaybackCopyFrame(VDL_HANDLE ctx, const vidix_dma_t * f)
162 return ctx->drv->copy_frame ? ctx->drv->copy_frame (f) : ENOSYS;
165 int vdlGetGrKeys(VDL_HANDLE ctx, vidix_grkey_t * k)
167 return ctx->drv->get_gkey ? ctx->drv->get_gkey (k) : ENOSYS;
170 int vdlSetGrKeys(VDL_HANDLE ctx, const vidix_grkey_t * k)
172 return ctx->drv->set_gkey ? ctx->drv->set_gkey (k) : ENOSYS;
175 int vdlPlaybackGetDeint(VDL_HANDLE ctx, vidix_deinterlace_t * d)
177 return ctx->drv->get_deint ? ctx->drv->get_deint (d) : ENOSYS;
180 int vdlPlaybackSetDeint(VDL_HANDLE ctx, const vidix_deinterlace_t * d)
182 return ctx->drv->set_deint ? ctx->drv->set_deint (d) : ENOSYS;
185 int vdlQueryNumOemEffects(VDL_HANDLE ctx, unsigned * number )
187 return ctx->drv->get_num_fx ? ctx->drv->get_num_fx (number) : ENOSYS;
190 int vdlGetOemEffect(VDL_HANDLE ctx, vidix_oem_fx_t * f)
192 return ctx->drv->get_fx ? ctx->drv->get_fx (f) : ENOSYS;
195 int vdlSetOemEffect(VDL_HANDLE ctx, const vidix_oem_fx_t * f)
197 return ctx->drv->set_fx ? ctx->drv->set_fx (f) : ENOSYS;