Mercurial > mplayer.hg
annotate libvo/vo_zr2.c @ 11390:32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
currently supported. Testing:
mplayer file.avi -vc zrmjpeg -vo zr2 -v
author | rik |
---|---|
date | Tue, 04 Nov 2003 20:05:47 +0000 |
parents | |
children | af8c66f215cf |
rev | line source |
---|---|
11390
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
1 /* |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
2 * vo_zr2.c - playback on zoran cards |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
3 * Based on vo_zr.c,v 1.27 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
4 * Copyright (C) Rik Snel 2001-2003, License GNU GPL v2 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
5 */ |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
6 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
7 /* $Id$ */ |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
8 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
9 #include <stdio.h> |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
10 #include <stdlib.h> |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
11 #include <string.h> |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
12 #include <unistd.h> |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
13 #include <fcntl.h> |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
14 #include <errno.h> |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
15 #include <sys/stat.h> |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
16 #include <sys/types.h> |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
17 #include <sys/time.h> |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
18 #include <sys/mman.h> |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
19 #include <sys/ioctl.h> |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
20 #include <linux/types.h> |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
21 #include <linux/videodev.h> |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
22 #include "videodev_mjpeg.h" |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
23 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
24 #include "config.h" |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
25 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
26 #include "video_out.h" |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
27 #include "video_out_internal.h" |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
28 #include "../mp_msg.h" |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
29 #include "fastmemcpy.h" |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
30 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
31 static vo_info_t info = { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
32 "Zoran ZR360[56]7/ZR36060 Driver (DC10(+)/buz/lml33/MatroxRR)", |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
33 "zr2", |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
34 "Rik Snel <snel@phys.uu.nl>", |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
35 "" |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
36 }; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
37 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
38 LIBVO_EXTERN(zr2) |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
39 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
40 typedef struct { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
41 /* information for (and about) the zoran card */ |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
42 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
43 unsigned char *buf; /* the JPEGs will be placed here */ |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
44 struct mjpeg_requestbuffers zrq; /* info about this buffer */ |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
45 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
46 int vdes; /* file descriptor of card */ |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
47 int playing; /* 0 or 1 */ |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
48 int frame, sync, queue; /* buffer management */ |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
49 struct mjpeg_sync zs; /* state information */ |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
50 struct mjpeg_params zp; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
51 struct video_capability vc; /* max resolution and so on */ |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
52 } vo_zr2_priv_t; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
53 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
54 static vo_zr2_priv_t priv; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
55 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
56 #define ZR2_MJPEG_NBUFFERS 2 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
57 #define ZR2_MJPEG_SIZE 1024*256 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
58 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
59 /* some convenient #define's, is this portable enough? */ |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
60 #define VERBOSE(...) mp_msg(MSGT_VO, MSGL_V, "vo_zr2: " __VA_ARGS__) |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
61 #define ERROR(...) mp_msg(MSGT_VO, MSGL_ERR, "vo_zr2: " __VA_ARGS__) |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
62 #define WARNING(...) mp_msg(MSGT_VO, MSGL_WARN, "vo_zr2: " __VA_ARGS__) |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
63 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
64 static void stop_playing(vo_zr2_priv_t *p) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
65 if (p->playing) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
66 p->frame = -1; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
67 if (ioctl(p->vdes, MJPIOC_QBUF_PLAY, &p->frame) < 0) |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
68 ERROR("error stopping playback\n"); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
69 p->playing = 0; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
70 p->sync = 0; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
71 p->queue = 0; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
72 p->frame = 0; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
73 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
74 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
75 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
76 static char *guess_device(char *suggestion) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
77 struct stat vstat; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
78 char *devs[] = { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
79 "/dev/video", |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
80 "/dev/video0", |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
81 "/dev/v4l/video0", |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
82 "/dev/v4l0", |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
83 "/dev/v4l", |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
84 NULL |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
85 }; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
86 char **dev = devs; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
87 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
88 if (suggestion) return suggestion; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
89 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
90 while (*(++dev) != NULL) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
91 if ((stat(*dev, &vstat) == 0) && S_ISCHR(vstat.st_mode)) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
92 VERBOSE("guessed video device %s\n", *dev); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
93 return *dev; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
94 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
95 dev++; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
96 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
97 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
98 ERROR("unable to find video device\n"); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
99 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
100 return NULL; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
101 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
102 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
103 static uint32_t query_format(uint32_t format) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
104 if (format==IMGFMT_ZRMJPEGNI || |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
105 format==IMGFMT_ZRMJPEGIT || |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
106 format==IMGFMT_ZRMJPEGIB) |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
107 return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
108 return 0; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
109 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
110 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
111 static uint32_t draw_image(mp_image_t *mpi) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
112 vo_zr2_priv_t *p = &priv; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
113 int size = (int)mpi->planes[1]; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
114 if (size > p->zrq.size) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
115 ERROR("incoming JPEG image (size=%d) doesn't fit in buffer\n", |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
116 size); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
117 return VO_FALSE; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
118 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
119 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
120 /* looking for free buffer */ |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
121 if (p->queue - p->sync < p->zrq.count) p->frame = p->queue; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
122 else { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
123 if (ioctl(p->vdes, MJPIOC_SYNC, &p->zs) < 0) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
124 ERROR("error waiting for buffer to become free\n"); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
125 return VO_FALSE; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
126 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
127 p->frame = p->zs.frame; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
128 p->sync++; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
129 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
130 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
131 /* copy the jpeg image to the buffer which we acquired */ |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
132 memcpy(p->buf + p->zrq.size*p->frame, mpi->planes[0], size); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
133 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
134 return VO_TRUE; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
135 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
136 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
137 static uint32_t preinit(const char *arg) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
138 char *dev; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
139 vo_zr2_priv_t *p = &priv; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
140 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
141 VERBOSE("preinit() called\n"); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
142 memset(p, 0, sizeof(*p)); /* set defaults */ |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
143 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
144 if (arg) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
145 ERROR("no subdevice parameters supported yet: %s\n",arg); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
146 return 1; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
147 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
148 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
149 dev = guess_device(NULL); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
150 if (!dev) return 1; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
151 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
152 p->vdes = open(dev, O_RDWR); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
153 if (p->vdes < 0) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
154 ERROR("error opening %s: %s\n", dev, strerror(errno)); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
155 return 1; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
156 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
157 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
158 /* check if we really are dealing with a zoran card */ |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
159 if (ioctl(p->vdes, MJPIOC_G_PARAMS, &p->zp) < 0) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
160 ERROR("%s probably is not a DC10(+)/buz/lml33\n", dev); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
161 return 1; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
162 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
163 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
164 VERBOSE("kernel driver version %d.%d, current norm is %s\n", |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
165 p->zp.major_version, p->zp.minor_version, |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
166 p->zp.norm == VIDEO_MODE_PAL ? "PAL" : "NTSC"); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
167 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
168 /* gather useful information */ |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
169 if (ioctl(p->vdes, VIDIOCGCAP, &p->vc) < 0) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
170 ERROR("error getting video capabilities from %s\n", dev); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
171 return 1; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
172 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
173 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
174 VERBOSE("card reports maxwidth=%d, maxheight=%d\n", |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
175 p->vc.maxwidth, p->vc.maxheight); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
176 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
177 p->zrq.count = ZR2_MJPEG_NBUFFERS; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
178 p->zrq.size = ZR2_MJPEG_SIZE; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
179 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
180 if (ioctl(p->vdes, MJPIOC_REQBUFS, &p->zrq)) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
181 ERROR("error requesting %d buffers of size %d\n", |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
182 ZR2_MJPEG_NBUFFERS, ZR2_MJPEG_NBUFFERS); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
183 return 1; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
184 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
185 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
186 VERBOSE("got %ld buffers of size %ld (wanted %d buffers of size %d)\n", |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
187 p->zrq.count, p->zrq.size, ZR2_MJPEG_NBUFFERS, |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
188 ZR2_MJPEG_SIZE); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
189 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
190 p->buf = (unsigned char*)mmap(0, p->zrq.count*p->zrq.size, |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
191 PROT_READ|PROT_WRITE, MAP_SHARED, p->vdes, 0); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
192 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
193 if (p->buf == MAP_FAILED) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
194 ERROR("error mapping requested buffers: %s", strerror(errno)); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
195 return 1; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
196 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
197 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
198 return 0; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
199 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
200 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
201 static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
202 uint32_t d_height, uint32_t flags, char *title, uint32_t format) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
203 int fields = 1, top_first = 1, err = 0; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
204 int stretchx = 1, stretchy = 1; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
205 struct mjpeg_params zptmp; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
206 vo_zr2_priv_t *p = &priv; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
207 VERBOSE("config() called\n"); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
208 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
209 /* paranoia check */ |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
210 if (!query_format(format)) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
211 ERROR("called with wrong format, should be impossible\n"); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
212 return 1; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
213 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
214 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
215 if ((int)height > p->vc.maxheight) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
216 ERROR("input height %d is too large, maxheight=%d\n", |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
217 height, p->vc.maxheight); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
218 err = 1; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
219 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
220 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
221 if (format != IMGFMT_ZRMJPEGNI) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
222 fields = 2; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
223 if (format == IMGFMT_ZRMJPEGIB) |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
224 top_first = 0; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
225 } else if ((int)height > p->vc.maxheight/2) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
226 ERROR("input is too high (%d) for non-interlaced playback" |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
227 "max=%d\n", height, p->vc.maxheight); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
228 err = 1; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
229 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
230 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
231 if (width%16 != 0) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
232 ERROR("input width=%d, must be multiple of 16\n", width); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
233 err = 1; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
234 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
235 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
236 if (height%(fields*8) != 0) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
237 ERROR("input height=%d, must be multiple of %d\n", |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
238 height, 2*fields); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
239 err = 1; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
240 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
241 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
242 /* we assume sample_aspect = 1 */ |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
243 if (fields == 1) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
244 if (2*d_width <= p->vc.maxwidth) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
245 VERBOSE("stretching x direction to preserve aspect\n"); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
246 d_width *= 2; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
247 } else VERBOSE("unable to preserve aspect, screen width " |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
248 "too small\n"); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
249 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
250 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
251 if (d_width == width) stretchx = 1; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
252 else if (d_width == 2*width) stretchx = 2; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
253 #if 0 /* do minimal stretching for now */ |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
254 else if (d_width == 4*width) stretchx = 4; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
255 else WARNING("d_width must be {1,2,4}*width, using defaults\n"); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
256 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
257 if (d_height == height) stretchy = 1; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
258 else if (d_height == 2*height) stretchy = 2; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
259 else if (d_height == 4*height) stretchy = 4; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
260 else WARNING("d_height must be {1,2,4}*height, using defaults\n"); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
261 #endif |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
262 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
263 if (stretchx*width > p->vc.maxwidth) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
264 ERROR("movie to be played is too wide, width=%d>maxwidth=%d", |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
265 width*stretchx, p->vc.maxwidth); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
266 err = 1; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
267 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
268 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
269 if (stretchy*height > p->vc.maxheight) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
270 ERROR("movie to be played is too heigh, height=%d>maxheight=%d", |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
271 height*stretchy, p->vc.maxheight); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
272 err = 1; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
273 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
274 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
275 if (err == 1) return 1; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
276 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
277 /* some video files (eg. concatenated MPEG files), make MPlayer |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
278 * call config() during playback while no parameters have changed. |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
279 * We make configuration changes to a temporary params structure, |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
280 * compare it with the old params structure and only apply the new |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
281 * config if it is different from the old one. */ |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
282 memcpy(&zptmp, &p->zp, sizeof(zptmp)); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
283 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
284 /* translate the configuration to zoran understandable format */ |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
285 zptmp.decimation = 0; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
286 zptmp.HorDcm = stretchx; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
287 zptmp.VerDcm = stretchy; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
288 zptmp.TmpDcm = 1; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
289 zptmp.field_per_buff = fields; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
290 zptmp.odd_even = top_first; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
291 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
292 /* center the image on screen */ |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
293 zptmp.img_x = (p->vc.maxwidth - width*stretchx)/2; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
294 zptmp.img_y = (p->vc.maxheight - height*stretchy*(3-fields))/4; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
295 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
296 zptmp.img_width = stretchx*width; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
297 zptmp.img_height = stretchy*height/fields; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
298 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
299 VERBOSE("tv: %dx%d, out: %dx%d+%d+%d, in: %ux%u %s%s%s\n", |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
300 p->vc.maxwidth, p->vc.maxheight, |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
301 zptmp.img_width, 2*zptmp.img_height, |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
302 zptmp.img_x, zptmp.img_y*(fields - 3), |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
303 width, height, (fields == 1) ? "non-interlaced" : "", |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
304 (fields == 2 && top_first == 1) |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
305 ? "interlaced top first" : "", |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
306 (fields == 2 && top_first == 0) |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
307 ? "interlaced bottom first" : ""); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
308 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
309 if (memcmp(&zptmp, &p->zp, sizeof(zptmp))) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
310 /* config differs, we must update */ |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
311 memcpy(&p->zp, &zptmp, sizeof(zptmp)); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
312 stop_playing(p); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
313 if (ioctl(p->vdes, MJPIOC_S_PARAMS, &p->zp) < 0) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
314 ERROR("error writing display params to card\n"); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
315 return 1; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
316 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
317 VERBOSE("successfully written display parameters to card\n"); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
318 } else VERBOSE("config didn't change, no need to write it to card\n"); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
319 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
320 return 0; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
321 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
322 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
323 static uint32_t control(uint32_t request, void *data, ...) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
324 switch (request) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
325 case VOCTRL_QUERY_FORMAT: |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
326 return query_format(*((uint32_t*)data)); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
327 case VOCTRL_DRAW_IMAGE: |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
328 return draw_image(data); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
329 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
330 return VO_NOTIMPL; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
331 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
332 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
333 static uint32_t draw_frame(uint8_t *src[]) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
334 return 0; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
335 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
336 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
337 static uint32_t draw_slice(uint8_t *image[], int stride[], |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
338 int w, int h, int x, int y) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
339 return 0; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
340 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
341 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
342 static void draw_osd(void) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
343 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
344 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
345 static void flip_page(void) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
346 vo_zr2_priv_t *p = &priv; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
347 /* queueing the buffer for playback */ |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
348 /* queueing the first buffer automatically starts playback */ |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
349 if (p->playing == 0) p->playing = 1; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
350 if (ioctl(p->vdes, MJPIOC_QBUF_PLAY, &p->frame) < 0) |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
351 ERROR("error queueing buffer for playback\n"); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
352 else p->queue++; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
353 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
354 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
355 static void check_events(void) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
356 } |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
357 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
358 static void uninit(void) { |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
359 vo_zr2_priv_t *p = &priv; |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
360 VERBOSE("uninit() called\n"); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
361 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
362 stop_playing(p); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
363 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
364 if (munmap(p->buf, p->zrq.size*p->zrq.count)) |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
365 ERROR("error munmapping buffer: %s\n", strerror(errno)); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
366 |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
367 close(p->vdes); |
32eb3dfe44c9
new zoran driver as discussed on the CVS list. Hardware passthrough is
rik
parents:
diff
changeset
|
368 } |