comparison libvo/vo_mga.c @ 1:3b5f5d1c5041

Initial revision
author arpi_esp
date Sat, 24 Feb 2001 20:28:24 +0000
parents
children 1fc618eba830
comparison
equal deleted inserted replaced
0:c1bb2c071d63 1:3b5f5d1c5041
1
2 //#define memcpy(a,b,c)
3
4 /*
5 * video_out_mga.c
6 *
7 * Copyright (C) Aaron Holtzman - Aug 1999
8 *
9 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
10 *
11 * mpeg2dec is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2, or (at your option)
14 * any later version.
15 *
16 * mpeg2dec is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with GNU Make; see the file COPYING. If not, write to
23 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 */
26
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30
31 #include "config.h"
32 #include "video_out.h"
33 #include "video_out_internal.h"
34
35 LIBVO_EXTERN(mga)
36
37 #include <sys/ioctl.h>
38 #include <unistd.h>
39 #include <fcntl.h>
40 #include <sys/mman.h>
41
42 #include "drivers/mga_vid.h"
43
44 static vo_info_t vo_info =
45 {
46 "Matrox G200/G400 overlay (/dev/mga_vid)",
47 "mga",
48 "Aaron Holtzman <aholtzma@ess.engr.uvic.ca>",
49 ""
50 };
51
52 static mga_vid_config_t mga_vid_config;
53 static uint8_t *vid_data, *frame0, *frame1;
54 static int next_frame = 0;
55 static int f;
56
57 #include "mga_common.c"
58
59 static uint32_t
60 init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format)
61 {
62 char *frame_mem;
63 uint32_t frame_size;
64
65 f = open("/dev/mga_vid",O_RDWR);
66
67 if(f == -1)
68 {
69 fprintf(stderr,"Couldn't open /dev/mga_vid\n");
70 return(-1);
71 }
72
73 switch(format){
74 case IMGFMT_YV12:
75 mga_vid_config.format=MGA_VID_FORMAT_YV12; break;
76 case IMGFMT_YUY2:
77 mga_vid_config.format=MGA_VID_FORMAT_YUY2; break;
78 default:
79 fprintf(stderr,"mga: invalid output format %0X\n",format);
80 return (-1);
81 }
82
83 mga_vid_config.src_width = width;
84 mga_vid_config.src_height= height;
85 // mga_vid_config.dest_width = width;
86 // mga_vid_config.dest_height= height;
87 mga_vid_config.dest_width = d_width;
88 // (width<704)?704:width; // HACK
89 mga_vid_config.dest_height= d_height;
90 // (height<576)?576:height; // HACK
91 mga_vid_config.x_org= 0; // (720-mga_vid_config.dest_width)/2;
92 mga_vid_config.y_org= 0; // (576-mga_vid_config.dest_height)/2;
93
94 if (ioctl(f,MGA_VID_CONFIG,&mga_vid_config))
95 {
96 perror("Error in mga_vid_config ioctl");
97 }
98 ioctl(f,MGA_VID_ON,0);
99
100 frame_size = ((width + 31) & ~31) * height + (((width + 31) & ~31) * height) / 2;
101 frame_mem = (char*)mmap(0,frame_size*2,PROT_WRITE,MAP_SHARED,f,0);
102 frame0 = frame_mem;
103 frame1 = frame_mem + frame_size;
104 vid_data = frame0;
105 next_frame = 0;
106
107 //clear the buffer
108 memset(frame_mem,0x80,frame_size*2);
109
110 return 0;
111 }
112
113 static const vo_info_t*
114 get_info(void)
115 {
116 return &vo_info;
117 }
118
119 static void
120 uninit(void)
121 {
122 ioctl( f,MGA_VID_OFF,0 );
123 printf("vo: uninit!\n");
124 }
125
126
127