annotate libvo/vesa_lvo.c @ 17908:dcfaebcdde14

10l (forgot ...)
author michael
date Tue, 21 Mar 2006 22:31:49 +0000
parents 05aa13cdf92f
children 3fe3b2b3a6ce
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2869
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
1 /*
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
2 * vesa_lvo.c
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
3 *
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
4 * Copyright (C) Nick Kurshev <nickols_k@mail.ru> - Oct 2001
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
5 *
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
6 * You can redistribute this file under terms and conditions
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
7 * of GNU General Public licence v2.
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
8 *
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
9 * This file contains vo_vesa interface to Linux Video Overlay.
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
10 * (Partly based on vo_mga.c from mplayer's package)
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
11 */
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
12
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
13 #include <inttypes.h>
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
14 #include <sys/ioctl.h>
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
15 #include <unistd.h>
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
16 #include <fcntl.h>
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
17 #include <sys/mman.h>
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
18 #include <stdio.h>
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
19 #include <stdlib.h>
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
20 #include <string.h>
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
21
3205
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
22 #include "config.h"
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
23
2869
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
24 #include "vesa_lvo.h"
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
25 #include "img_format.h"
13787
e047e70a9767 Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents: 6817
diff changeset
26 #include "drivers/mga_vid.h" /* <- should be changed to "linux/'something'.h" */
2869
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
27 #include "fastmemcpy.h"
3205
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
28 #include "osd.h"
3202
e9b18714e3dc Minor optimization
nick
parents: 3165
diff changeset
29 #include "video_out.h"
15212
05aa13cdf92f replace VO and VF numeric flags with #defined identifiers
henry
parents: 13787
diff changeset
30 #include "libmpcodecs/vfcap.h"
3202
e9b18714e3dc Minor optimization
nick
parents: 3165
diff changeset
31
3165
c9f140f5a34e Direct i420 support for Radeons
nick
parents: 3020
diff changeset
32 #define WIDTH_ALIGN 32 /* should be 16 for rage:422 and 32 for rage:420 */
3266
ff90589b635f Fixed single buffering problems and -vo mga compatibility by number of buffers
nick
parents: 3205
diff changeset
33 #define NUM_FRAMES 10
3205
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
34 #define UNUSED(x) ((void)(x)) /**< Removes warning about unused arguments */
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
35
2869
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
36 static uint8_t *frames[NUM_FRAMES];
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
37
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
38 static int lvo_handler = -1;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
39 static uint8_t *lvo_mem = NULL;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
40 static uint8_t next_frame;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
41 static mga_vid_config_t mga_vid_config;
2974
49199909c939 Ugly YV12 support on Radeon BES. (Only radeon_vid currently work with this stuff :( Sorry!)
nick
parents: 2971
diff changeset
42 static unsigned image_bpp,image_height,image_width,src_format;
2952
91723d82b64f working draw_slice stuff
nick
parents: 2924
diff changeset
43 extern int verbose;
4592
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4493
diff changeset
44 uint32_t vlvo_control(uint32_t request, void *data, ...);
2869
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
45
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
46 #define PIXEL_SIZE() ((video_mode_info.BitsPerPixel+7)/8)
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
47 #define SCREEN_LINE_SIZE(pixel_size) (video_mode_info.XResolution*(pixel_size) )
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
48 #define IMAGE_LINE_SIZE(pixel_size) (image_width*(pixel_size))
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
49
3202
e9b18714e3dc Minor optimization
nick
parents: 3165
diff changeset
50 extern vo_functions_t video_out_vesa;
e9b18714e3dc Minor optimization
nick
parents: 3165
diff changeset
51
2971
56faed773768 Added preinit of lvo stuff
nick
parents: 2964
diff changeset
52 int vlvo_preinit(const char *drvname)
56faed773768 Added preinit of lvo stuff
nick
parents: 2964
diff changeset
53 {
4493
be41ab8c8918 code cleanup
nick
parents: 4372
diff changeset
54 printf("vesa_lvo: This branch is no longer supported.\n"
be41ab8c8918 code cleanup
nick
parents: 4372
diff changeset
55 "vesa_lvo: Please use -vo vesa:vidix instead\n");
be41ab8c8918 code cleanup
nick
parents: 4372
diff changeset
56 return -1;
3017
fb792e58aac5 Verbosing and minor optimization
nick
parents: 2974
diff changeset
57 if(verbose > 1) printf("vesa_lvo: vlvo_preinit(%s) was called\n",drvname);
2971
56faed773768 Added preinit of lvo stuff
nick
parents: 2964
diff changeset
58 lvo_handler = open(drvname,O_RDWR);
56faed773768 Added preinit of lvo stuff
nick
parents: 2964
diff changeset
59 if(lvo_handler == -1)
56faed773768 Added preinit of lvo stuff
nick
parents: 2964
diff changeset
60 {
56faed773768 Added preinit of lvo stuff
nick
parents: 2964
diff changeset
61 printf("vesa_lvo: Couldn't open '%s'\n",drvname);
56faed773768 Added preinit of lvo stuff
nick
parents: 2964
diff changeset
62 return -1;
56faed773768 Added preinit of lvo stuff
nick
parents: 2964
diff changeset
63 }
3202
e9b18714e3dc Minor optimization
nick
parents: 3165
diff changeset
64 /* we are able to tune up this stuff depend on fourcc format */
e9b18714e3dc Minor optimization
nick
parents: 3165
diff changeset
65 video_out_vesa.draw_slice=vlvo_draw_slice;
e9b18714e3dc Minor optimization
nick
parents: 3165
diff changeset
66 video_out_vesa.draw_frame=vlvo_draw_frame;
e9b18714e3dc Minor optimization
nick
parents: 3165
diff changeset
67 video_out_vesa.flip_page=vlvo_flip_page;
e9b18714e3dc Minor optimization
nick
parents: 3165
diff changeset
68 video_out_vesa.draw_osd=vlvo_draw_osd;
4592
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4493
diff changeset
69 video_out_vesa.control=vlvo_control;
2971
56faed773768 Added preinit of lvo stuff
nick
parents: 2964
diff changeset
70 return 0;
56faed773768 Added preinit of lvo stuff
nick
parents: 2964
diff changeset
71 }
56faed773768 Added preinit of lvo stuff
nick
parents: 2964
diff changeset
72
56faed773768 Added preinit of lvo stuff
nick
parents: 2964
diff changeset
73 int vlvo_init(unsigned src_width,unsigned src_height,
2869
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
74 unsigned x_org,unsigned y_org,unsigned dst_width,
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
75 unsigned dst_height,unsigned format,unsigned dest_bpp)
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
76 {
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
77 size_t i,awidth;
4493
be41ab8c8918 code cleanup
nick
parents: 4372
diff changeset
78 printf("vesa_lvo: This branch is no longer supported.\n"
be41ab8c8918 code cleanup
nick
parents: 4372
diff changeset
79 "vesa_lvo: Please use -vo vesa:vidix instead\n");
be41ab8c8918 code cleanup
nick
parents: 4372
diff changeset
80 return -1;
3017
fb792e58aac5 Verbosing and minor optimization
nick
parents: 2974
diff changeset
81 if(verbose > 1) printf("vesa_lvo: vlvo_init() was called\n");
2869
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
82 image_width = src_width;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
83 image_height = src_height;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
84 mga_vid_config.version=MGA_VID_VERSION;
2974
49199909c939 Ugly YV12 support on Radeon BES. (Only radeon_vid currently work with this stuff :( Sorry!)
nick
parents: 2971
diff changeset
85 src_format = mga_vid_config.format=format;
2869
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
86 awidth = (src_width + (WIDTH_ALIGN-1)) & ~(WIDTH_ALIGN-1);
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
87 switch(format){
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
88 case IMGFMT_YV12:
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
89 case IMGFMT_I420:
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
90 case IMGFMT_IYUV:
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
91 image_bpp=16;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
92 mga_vid_config.frame_size = awidth*src_height+(awidth*src_height)/2;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
93 break;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
94 case IMGFMT_YUY2:
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
95 case IMGFMT_UYVY:
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
96 image_bpp=16;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
97 mga_vid_config.frame_size = awidth*src_height*2;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
98 break;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
99 case IMGFMT_RGB15:
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
100 case IMGFMT_BGR15:
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
101 case IMGFMT_RGB16:
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
102 case IMGFMT_BGR16:
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
103 image_bpp=16;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
104 mga_vid_config.frame_size = awidth*src_height*2;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
105 break;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
106 case IMGFMT_RGB24:
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
107 case IMGFMT_BGR24:
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
108 image_bpp=24;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
109 mga_vid_config.frame_size = awidth*src_height*3;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
110 break;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
111 case IMGFMT_RGB32:
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
112 case IMGFMT_BGR32:
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
113 image_bpp=32;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
114 mga_vid_config.frame_size = awidth*src_height*4;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
115 break;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
116 default:
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
117 printf("vesa_lvo: invalid output format %s(%0X)\n",vo_format_name(format),format);
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
118 return -1;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
119 }
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
120 mga_vid_config.colkey_on=0;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
121 mga_vid_config.src_width = src_width;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
122 mga_vid_config.src_height= src_height;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
123 mga_vid_config.dest_width = dst_width;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
124 mga_vid_config.dest_height= dst_height;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
125 mga_vid_config.x_org=x_org;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
126 mga_vid_config.y_org=y_org;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
127 mga_vid_config.num_frames=NUM_FRAMES;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
128 if (ioctl(lvo_handler,MGA_VID_CONFIG,&mga_vid_config))
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
129 {
2971
56faed773768 Added preinit of lvo stuff
nick
parents: 2964
diff changeset
130 perror("vesa_lvo: Error in mga_vid_config ioctl()");
56faed773768 Added preinit of lvo stuff
nick
parents: 2964
diff changeset
131 printf("vesa_lvo: Your fb_vid driver version is incompatible with this MPlayer version!\n");
2869
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
132 return -1;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
133 }
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
134 ioctl(lvo_handler,MGA_VID_ON,0);
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
135
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
136 frames[0] = (char*)mmap(0,mga_vid_config.frame_size*mga_vid_config.num_frames,PROT_WRITE,MAP_SHARED,lvo_handler,0);
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
137 for(i=1;i<NUM_FRAMES;i++)
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
138 frames[i] = frames[i-1] + mga_vid_config.frame_size;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
139 next_frame = 0;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
140 lvo_mem = frames[next_frame];
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
141
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
142 /*clear the buffer*/
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
143 memset(frames[0],0x80,mga_vid_config.frame_size*mga_vid_config.num_frames);
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
144 return 0;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
145 }
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
146
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
147 void vlvo_term( void )
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
148 {
3017
fb792e58aac5 Verbosing and minor optimization
nick
parents: 2974
diff changeset
149 if(verbose > 1) printf("vesa_lvo: vlvo_term() was called\n");
2869
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
150 ioctl( lvo_handler,MGA_VID_OFF,0 );
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
151 munmap(frames[0],mga_vid_config.frame_size*mga_vid_config.num_frames);
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
152 if(lvo_handler != -1) close(lvo_handler);
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
153 }
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
154
3165
c9f140f5a34e Direct i420 support for Radeons
nick
parents: 3020
diff changeset
155 uint32_t vlvo_draw_slice_420(uint8_t *image[], int stride[], int w,int h,int x,int y)
2869
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
156 {
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
157 uint8_t *src;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
158 uint8_t *dest;
3020
e5ebde3ebdd6 Minor fixes with the same results
nick
parents: 3019
diff changeset
159 uint32_t bespitch,bespitch2;
2869
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
160 int i;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
161
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
162 bespitch = (mga_vid_config.src_width + (WIDTH_ALIGN-1)) & ~(WIDTH_ALIGN-1);
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
163 bespitch2 = bespitch/2;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
164
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
165 dest = lvo_mem + bespitch * y + x;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
166 src = image[0];
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
167 for(i=0;i<h;i++){
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
168 memcpy(dest,src,w);
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
169 src+=stride[0];
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
170 dest += bespitch;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
171 }
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
172
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
173 w/=2;h/=2;x/=2;y/=2;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
174
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
175 dest = lvo_mem + bespitch*mga_vid_config.src_height + bespitch2 * y + x;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
176 src = image[1];
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
177 for(i=0;i<h;i++){
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
178 memcpy(dest,src,w);
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
179 src+=stride[1];
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
180 dest += bespitch2;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
181 }
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
182
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
183 dest = lvo_mem + bespitch*mga_vid_config.src_height
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
184 + bespitch*mga_vid_config.src_height / 4
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
185 + bespitch2 * y + x;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
186 src = image[2];
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
187 for(i=0;i<h;i++){
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
188 memcpy(dest,src,w);
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
189 src+=stride[2];
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
190 dest += bespitch2;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
191 }
3020
e5ebde3ebdd6 Minor fixes with the same results
nick
parents: 3019
diff changeset
192 return 0;
e5ebde3ebdd6 Minor fixes with the same results
nick
parents: 3019
diff changeset
193 }
e5ebde3ebdd6 Minor fixes with the same results
nick
parents: 3019
diff changeset
194
e5ebde3ebdd6 Minor fixes with the same results
nick
parents: 3019
diff changeset
195 uint32_t vlvo_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
e5ebde3ebdd6 Minor fixes with the same results
nick
parents: 3019
diff changeset
196 {
e5ebde3ebdd6 Minor fixes with the same results
nick
parents: 3019
diff changeset
197 if(verbose > 1) printf("vesa_lvo: vlvo_draw_slice() was called\n");
3165
c9f140f5a34e Direct i420 support for Radeons
nick
parents: 3020
diff changeset
198 if(src_format == IMGFMT_YV12 || src_format == IMGFMT_I420 || src_format == IMGFMT_IYUV)
3202
e9b18714e3dc Minor optimization
nick
parents: 3165
diff changeset
199 vlvo_draw_slice_420(image,stride,w,h,x,y);
2974
49199909c939 Ugly YV12 support on Radeon BES. (Only radeon_vid currently work with this stuff :( Sorry!)
nick
parents: 2971
diff changeset
200 else
3202
e9b18714e3dc Minor optimization
nick
parents: 3165
diff changeset
201 {
e9b18714e3dc Minor optimization
nick
parents: 3165
diff changeset
202 uint8_t *dst;
e9b18714e3dc Minor optimization
nick
parents: 3165
diff changeset
203 uint8_t bytpp;
e9b18714e3dc Minor optimization
nick
parents: 3165
diff changeset
204 bytpp = (image_bpp+7)/8;
e9b18714e3dc Minor optimization
nick
parents: 3165
diff changeset
205 dst = lvo_mem + (image_width * y + x)*bytpp;
e9b18714e3dc Minor optimization
nick
parents: 3165
diff changeset
206 /* vlvo_draw_slice_422(image,stride,w,h,x,y); just for speed */
e9b18714e3dc Minor optimization
nick
parents: 3165
diff changeset
207 memcpy(dst,image[0],mga_vid_config.frame_size);
e9b18714e3dc Minor optimization
nick
parents: 3165
diff changeset
208 }
2924
8350b8c25c02 Xv stuff
nick
parents: 2869
diff changeset
209 return 0;
2869
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
210 }
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
211
3017
fb792e58aac5 Verbosing and minor optimization
nick
parents: 2974
diff changeset
212 uint32_t vlvo_draw_frame(uint8_t *image[])
2869
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
213 {
3017
fb792e58aac5 Verbosing and minor optimization
nick
parents: 2974
diff changeset
214 /* Note it's very strange but sometime for YUY2 draw_frame is called */
fb792e58aac5 Verbosing and minor optimization
nick
parents: 2974
diff changeset
215 memcpy(lvo_mem,image[0],mga_vid_config.frame_size);
fb792e58aac5 Verbosing and minor optimization
nick
parents: 2974
diff changeset
216 if(verbose > 1) printf("vesa_lvo: vlvo_draw_frame() was called\n");
fb792e58aac5 Verbosing and minor optimization
nick
parents: 2974
diff changeset
217 return 0;
2869
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
218 }
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
219
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
220 void vlvo_flip_page(void)
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
221 {
3017
fb792e58aac5 Verbosing and minor optimization
nick
parents: 2974
diff changeset
222 if(verbose > 1) printf("vesa_lvo: vlvo_flip_page() was called\n");
3266
ff90589b635f Fixed single buffering problems and -vo mga compatibility by number of buffers
nick
parents: 3205
diff changeset
223 if(vo_doublebuffering)
ff90589b635f Fixed single buffering problems and -vo mga compatibility by number of buffers
nick
parents: 3205
diff changeset
224 {
2869
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
225 ioctl(lvo_handler,MGA_VID_FSEL,&next_frame);
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
226 next_frame=(next_frame+1)%mga_vid_config.num_frames;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
227 lvo_mem=frames[next_frame];
3266
ff90589b635f Fixed single buffering problems and -vo mga compatibility by number of buffers
nick
parents: 3205
diff changeset
228 }
2869
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
229 }
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
230
3205
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
231 static void draw_alpha_null(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
232 {
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
233 UNUSED(x0);
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
234 UNUSED(y0);
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
235 UNUSED(w);
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
236 UNUSED(h);
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
237 UNUSED(src);
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
238 UNUSED(srca);
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
239 UNUSED(stride);
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
240 }
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
241
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
242 static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
243 {
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
244 uint32_t bespitch = /*(*/mga_vid_config.src_width;// + 15) & ~15;
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
245 switch(mga_vid_config.format){
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
246 case IMGFMT_BGR15:
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
247 case IMGFMT_RGB15:
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
248 vo_draw_alpha_rgb15(w,h,src,srca,stride,lvo_mem+2*(y0*bespitch+x0),2*bespitch);
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
249 break;
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
250 case IMGFMT_BGR16:
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
251 case IMGFMT_RGB16:
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
252 vo_draw_alpha_rgb16(w,h,src,srca,stride,lvo_mem+2*(y0*bespitch+x0),2*bespitch);
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
253 break;
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
254 case IMGFMT_BGR24:
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
255 case IMGFMT_RGB24:
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
256 vo_draw_alpha_rgb24(w,h,src,srca,stride,lvo_mem+3*(y0*bespitch+x0),3*bespitch);
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
257 break;
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
258 case IMGFMT_BGR32:
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
259 case IMGFMT_RGB32:
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
260 vo_draw_alpha_rgb32(w,h,src,srca,stride,lvo_mem+4*(y0*bespitch+x0),4*bespitch);
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
261 break;
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
262 case IMGFMT_YV12:
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
263 case IMGFMT_IYUV:
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
264 case IMGFMT_I420:
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
265 vo_draw_alpha_yv12(w,h,src,srca,stride,lvo_mem+bespitch*y0+x0,bespitch);
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
266 break;
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
267 case IMGFMT_YUY2:
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
268 vo_draw_alpha_yuy2(w,h,src,srca,stride,lvo_mem+2*(bespitch*y0+x0),bespitch);
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
269 break;
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
270 case IMGFMT_UYVY:
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
271 vo_draw_alpha_yuy2(w,h,src,srca,stride,lvo_mem+2*(bespitch*y0+x0)+1,bespitch);
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
272 break;
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
273 default:
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
274 draw_alpha_null(x0,y0,w,h,src,srca,stride);
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
275 }
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
276 }
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
277
2869
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
278 void vlvo_draw_osd(void)
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
279 {
3017
fb792e58aac5 Verbosing and minor optimization
nick
parents: 2974
diff changeset
280 if(verbose > 1) printf("vesa_lvo: vlvo_draw_osd() was called\n");
2869
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
281 /* TODO: hw support */
3205
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
282 #if 0
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
283 /* disable this stuff until new fbvid.h interface will be implemented
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
284 because in different fourcc radeon_vid and rage128_vid have different
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
285 width alignment */
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
286 vo_draw_text(mga_vid_config.src_width,mga_vid_config.src_height,draw_alpha);
1d2b2885bb8c Minor fixes
nick
parents: 3202
diff changeset
287 #endif
2869
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
288 }
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
289
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
290 uint32_t vlvo_query_info(uint32_t format)
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
291 {
3017
fb792e58aac5 Verbosing and minor optimization
nick
parents: 2974
diff changeset
292 if(verbose > 1) printf("vesa_lvo: query_format was called: %x (%s)\n",format,vo_format_name(format));
15212
05aa13cdf92f replace VO and VF numeric flags with #defined identifiers
henry
parents: 13787
diff changeset
293 return VFCAP_CSP_SUPPORTED;
2869
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents:
diff changeset
294 }
4592
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4493
diff changeset
295
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4493
diff changeset
296 uint32_t vlvo_control(uint32_t request, void *data, ...)
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4493
diff changeset
297 {
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4493
diff changeset
298 switch (request) {
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4493
diff changeset
299 case VOCTRL_QUERY_FORMAT:
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4493
diff changeset
300 return vlvo_query_info(*((uint32_t*)data));
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4493
diff changeset
301 }
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4493
diff changeset
302 return VO_NOTIMPL;
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4493
diff changeset
303 }