annotate vidix/sh_veu_vid.c @ 37150:67efc9d84be2

codecs.conf : map lsvm h263 fourcc, V-codecs/LSV for sample
author compn
date Wed, 06 Aug 2014 13:03:22 +0000
parents 3c5c93a30fb7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27420
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
1 /*
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
2 * VIDIX driver for SuperH Mobile VEU hardware block.
29946
54bacf6a38ca Update the SuperH VEU vidix driver with code that calls fsync() after each
cehoyos
parents: 28019
diff changeset
3 * Copyright (C) 2008, 2009 Magnus Damm
27420
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
4 *
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
5 * Requires a kernel that exposes the VEU hardware block to user space
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
6 * using UIO. Available in upstream linux-2.6.27 or later.
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
7 *
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
8 * Tested using WVGA and QVGA panels with sh7722 VEU and sh7723 VEU2H.
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
9 *
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
10 * This file is part of MPlayer.
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
11 *
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
12 * MPlayer is free software; you can redistribute it and/or modify
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
13 * it under the terms of the GNU General Public License as published by
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
14 * the Free Software Foundation; either version 2 of the License, or
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
15 * (at your option) any later version.
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
16 *
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
17 * MPlayer is distributed in the hope that it will be useful,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
20 * GNU General Public License for more details.
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
21 *
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
22 * You should have received a copy of the GNU General Public License
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
23 * along with MPlayer; if not, write to the Free Software
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
25 */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
26
35905
0989cbea18b4 Add _BSD_SOURCE #define for getpagesize().
diego
parents: 29948
diff changeset
27 #define _BSD_SOURCE
0989cbea18b4 Add _BSD_SOURCE #define for getpagesize().
diego
parents: 29948
diff changeset
28
27420
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
29 #include <stdio.h>
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
30 #include <unistd.h>
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
31 #include <string.h>
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
32 #include <stdlib.h>
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
33 #include <sys/mman.h>
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
34 #include <sys/time.h>
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
35 #include <sys/ioctl.h>
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
36 #include <fcntl.h>
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
37 #include <linux/fb.h>
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
38 #include <inttypes.h>
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
39 #include <unistd.h>
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
40 #include <errno.h>
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
41
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
42 #include "config.h"
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
43 #include "vidix.h"
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
44 #include "fourcc.h"
37107
3c5c93a30fb7 vidix: Replace printf with mp_msg
al
parents: 36634
diff changeset
45 #include "mp_msg.h"
27420
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
46
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
47 #include "dha.h"
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
48
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
49 static int fgets_with_openclose(char *fname, char *buf, size_t maxlen)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
50 {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
51 FILE *fp;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
52
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
53 fp = fopen(fname, "r");
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
54 if (!fp)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
55 return -1;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
56
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
57 fgets(buf, maxlen, fp);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
58 fclose(fp);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
59 return strlen(buf);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
60 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
61
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
62 struct uio_device {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
63 char *name;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
64 char *path;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
65 int fd;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
66 };
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
67
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
68 #define MAXNAMELEN 256
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
69
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
70 static int locate_uio_device(char *name, struct uio_device *udp)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
71 {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
72 char fname[MAXNAMELEN], buf[MAXNAMELEN];
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
73 char *tmp;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
74 int uio_id;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
75
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
76 uio_id = -1;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
77 do {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
78 uio_id++;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
79 snprintf(fname, MAXNAMELEN, "/sys/class/uio/uio%d/name", uio_id);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
80 if (fgets_with_openclose(fname, buf, MAXNAMELEN) < 0)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
81 return -1;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
82
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
83 } while (strncmp(name, buf, strlen(name)));
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
84
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
85 tmp = strchr(buf, '\n');
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
86 if (tmp)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
87 *tmp = '\0';
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
88
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
89 udp->name = strdup(buf);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
90 udp->path = strdup(fname);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
91 udp->path[strlen(udp->path) - 5] = '\0';
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
92
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
93 snprintf(buf, MAXNAMELEN, "/dev/uio%d", uio_id);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
94 udp->fd = open(buf, O_RDWR | O_SYNC);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
95
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
96 if (udp->fd < 0)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
97 return -1;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
98
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
99 return 0;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
100 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
101
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
102 struct uio_map {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
103 unsigned long address;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
104 unsigned long size;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
105 void *iomem;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
106 };
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
107
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
108 static int setup_uio_map(struct uio_device *udp, int nr, struct uio_map *ump)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
109 {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
110 char fname[MAXNAMELEN], buf[MAXNAMELEN];
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
111
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
112 snprintf(fname, MAXNAMELEN, "%s/maps/map%d/addr", udp->path, nr);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
113 if (fgets_with_openclose(fname, buf, MAXNAMELEN) <= 0)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
114 return -1;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
115
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
116 ump->address = strtoul(buf, NULL, 0);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
117
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
118 snprintf(fname, MAXNAMELEN, "%s/maps/map%d/size", udp->path, nr);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
119 if (fgets_with_openclose(fname, buf, MAXNAMELEN) <= 0)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
120 return -1;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
121
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
122 ump->size = strtoul(buf, NULL, 0);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
123 ump->iomem = mmap(0, ump->size,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
124 PROT_READ|PROT_WRITE, MAP_SHARED,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
125 udp->fd, nr * getpagesize());
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
126
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
127 if (ump->iomem == MAP_FAILED)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
128 return -1;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
129
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
130 return 0;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
131 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
132
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
133 struct fb_info {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
134 unsigned long width;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
135 unsigned long height;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
136 unsigned long bpp;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
137 unsigned long line_length;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
138
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
139 unsigned long address;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
140 unsigned long size;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
141 };
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
142
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
143 static int get_fb_info(char *device, struct fb_info *fip)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
144 {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
145 struct fb_var_screeninfo vinfo;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
146 struct fb_fix_screeninfo finfo;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
147 void *iomem;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
148 int fd;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
149
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
150 fd = open(device, O_RDWR);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
151 if (fd < 0) {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
152 perror("open");
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
153 return -1;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
154 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
155
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
156 if (ioctl(fd, FBIOGET_VSCREENINFO, &vinfo) == -1) {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
157 perror("ioctl(FBIOGET_VSCREENINFO)");
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
158 return -1;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
159 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
160
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
161 fip->width = vinfo.xres;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
162 fip->height = vinfo.yres;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
163 fip->bpp = vinfo.bits_per_pixel;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
164
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
165 if (ioctl(fd, FBIOGET_FSCREENINFO, &finfo) == -1) {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
166 perror("ioctl(FBIOGET_FSCREENINFO)");
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
167 return -1;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
168 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
169
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
170 fip->address = finfo.smem_start;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
171 fip->size = finfo.smem_len;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
172 fip->line_length = finfo.line_length;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
173
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
174 iomem = mmap(0, fip->size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
175
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
176 if (iomem == MAP_FAILED) {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
177 perror("mmap");
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
178 return -1;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
179 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
180
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
181 /* clear framebuffer */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
182 memset(iomem, 0, fip->line_length * fip->height);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
183 munmap(iomem, fip->size);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
184
29946
54bacf6a38ca Update the SuperH VEU vidix driver with code that calls fsync() after each
cehoyos
parents: 28019
diff changeset
185 return fd;
27420
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
186 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
187
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
188 #define VESTR 0x00 /* start register */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
189 #define VESWR 0x10 /* src: line length */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
190 #define VESSR 0x14 /* src: image size */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
191 #define VSAYR 0x18 /* src: y/rgb plane address */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
192 #define VSACR 0x1c /* src: c plane address */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
193 #define VBSSR 0x20 /* bundle mode register */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
194 #define VEDWR 0x30 /* dst: line length */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
195 #define VDAYR 0x34 /* dst: y/rgb plane address */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
196 #define VDACR 0x38 /* dst: c plane address */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
197 #define VTRCR 0x50 /* transform control */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
198 #define VRFCR 0x54 /* resize scale */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
199 #define VRFSR 0x58 /* resize clip */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
200 #define VENHR 0x5c /* enhance */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
201 #define VFMCR 0x70 /* filter mode */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
202 #define VVTCR 0x74 /* lowpass vertical */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
203 #define VHTCR 0x78 /* lowpass horizontal */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
204 #define VAPCR 0x80 /* color match */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
205 #define VECCR 0x84 /* color replace */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
206 #define VAFXR 0x90 /* fixed mode */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
207 #define VSWPR 0x94 /* swap */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
208 #define VEIER 0xa0 /* interrupt mask */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
209 #define VEVTR 0xa4 /* interrupt event */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
210 #define VSTAR 0xb0 /* status */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
211 #define VBSRR 0xb4 /* reset */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
212
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
213 #define VMCR00 0x200 /* color conversion matrix coefficient 00 */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
214 #define VMCR01 0x204 /* color conversion matrix coefficient 01 */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
215 #define VMCR02 0x208 /* color conversion matrix coefficient 02 */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
216 #define VMCR10 0x20c /* color conversion matrix coefficient 10 */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
217 #define VMCR11 0x210 /* color conversion matrix coefficient 11 */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
218 #define VMCR12 0x214 /* color conversion matrix coefficient 12 */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
219 #define VMCR20 0x218 /* color conversion matrix coefficient 20 */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
220 #define VMCR21 0x21c /* color conversion matrix coefficient 21 */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
221 #define VMCR22 0x220 /* color conversion matrix coefficient 22 */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
222 #define VCOFFR 0x224 /* color conversion offset */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
223 #define VCBR 0x228 /* color conversion clip */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
224
29948
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
225 #define VRPBR 0xc8 /* resize passband */
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
226
27420
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
227 /* Helper functions for reading registers. */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
228
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
229 static unsigned long read_reg(struct uio_map *ump, int reg_offs)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
230 {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
231 volatile unsigned long *reg = ump->iomem;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
232
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
233 return reg[reg_offs / 4];
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
234 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
235
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
236 static void write_reg(struct uio_map *ump, unsigned long value, int reg_offs)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
237 {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
238 volatile unsigned long *reg = ump->iomem;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
239
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
240 reg[reg_offs / 4] = value;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
241 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
242
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
243 static vidix_capability_t sh_veu_cap = {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
244 "SuperH VEU driver",
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
245 "Magnus Damm",
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
246 TYPE_OUTPUT,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
247 { 0, 0, 0, 0 },
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
248 2560,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
249 1920,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
250 16,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
251 16,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
252 -1,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
253 FLAG_UPSCALER|FLAG_DOWNSCALER,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
254 -1,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
255 -1,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
256 { 0, 0, 0, 0 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
257 };
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
258
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
259 /* global variables yuck */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
260
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
261 static struct fb_info fbi;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
262 static struct uio_device uio_dev;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
263 static struct uio_map uio_mmio, uio_mem;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
264
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
265 struct sh_veu_plane {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
266 unsigned long width;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
267 unsigned long height;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
268 unsigned long stride;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
269 unsigned long pos_x;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
270 unsigned long pos_y;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
271 };
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
272
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
273 static struct sh_veu_plane _src, _dst;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
274 static vidix_playback_t my_info;
29946
54bacf6a38ca Update the SuperH VEU vidix driver with code that calls fsync() after each
cehoyos
parents: 28019
diff changeset
275 static int fb_fd;
27420
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
276
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
277 static int sh_veu_probe(int verbose, int force)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
278 {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
279 int ret;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
280
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
281 ret = get_fb_info("/dev/fb0", &fbi);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
282 if (ret < 0)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
283 return ret;
29946
54bacf6a38ca Update the SuperH VEU vidix driver with code that calls fsync() after each
cehoyos
parents: 28019
diff changeset
284 fb_fd = ret;
27420
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
285
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
286 if (fbi.bpp != 16) {
37107
3c5c93a30fb7 vidix: Replace printf with mp_msg
al
parents: 36634
diff changeset
287 mp_msg(MSGT_VO, MSGL_STATUS, "[sh_veu] only 16bpp supported\n");
27420
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
288 return -1;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
289 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
290
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
291 ret = locate_uio_device("VEU", &uio_dev);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
292 if (ret < 0) {
37107
3c5c93a30fb7 vidix: Replace printf with mp_msg
al
parents: 36634
diff changeset
293 mp_msg(MSGT_VO, MSGL_STATUS, "[sh_veu] unable to locate matching UIO device\n");
27420
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
294 return ret;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
295 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
296
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
297 ret = setup_uio_map(&uio_dev, 0, &uio_mmio);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
298 if (ret < 0) {
37107
3c5c93a30fb7 vidix: Replace printf with mp_msg
al
parents: 36634
diff changeset
299 mp_msg(MSGT_VO, MSGL_STATUS, "[sh_veu] cannot setup MMIO\n");
27420
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
300 return ret;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
301 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
302
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
303 ret = setup_uio_map(&uio_dev, 1, &uio_mem);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
304 if (ret < 0) {
37107
3c5c93a30fb7 vidix: Replace printf with mp_msg
al
parents: 36634
diff changeset
305 mp_msg(MSGT_VO, MSGL_STATUS, "[sh_veu] cannot setup contiguous memory\n");
27420
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
306 return ret;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
307 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
308
37107
3c5c93a30fb7 vidix: Replace printf with mp_msg
al
parents: 36634
diff changeset
309 mp_msg(MSGT_VO, MSGL_STATUS, "[sh_veu] Using %s at %s on %lux%lu %ldbpp /dev/fb0\n",
27420
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
310 uio_dev.name, uio_dev.path,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
311 fbi.width, fbi.height, fbi.bpp);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
312
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
313 return ret;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
314 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
315
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
316 static void sh_veu_wait_irq(vidix_playback_t *info)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
317 {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
318 unsigned long n_pending;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
319
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
320 /* Wait for an interrupt */
28019
f504a06fcf50 Use standard unsigned long type instead of u_long.
diego
parents: 27420
diff changeset
321 read(uio_dev.fd, &n_pending, sizeof(unsigned long));
27420
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
322
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
323 write_reg(&uio_mmio, 0x100, VEVTR); /* ack int, write 0 to bit 0 */
29946
54bacf6a38ca Update the SuperH VEU vidix driver with code that calls fsync() after each
cehoyos
parents: 28019
diff changeset
324
54bacf6a38ca Update the SuperH VEU vidix driver with code that calls fsync() after each
cehoyos
parents: 28019
diff changeset
325 /* flush framebuffer to handle deferred io case */
54bacf6a38ca Update the SuperH VEU vidix driver with code that calls fsync() after each
cehoyos
parents: 28019
diff changeset
326 fsync(fb_fd);
27420
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
327 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
328
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
329 static int sh_veu_is_veu2h(void)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
330 {
29948
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
331 return uio_mmio.size == 0x27c;
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
332 }
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
333
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
334 static int sh_veu_is_veu3f(void)
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
335 {
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
336 return uio_mmio.size == 0xcc;
27420
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
337 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
338
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
339 static unsigned long sh_veu_do_scale(struct uio_map *ump,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
340 int vertical, int size_in,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
341 int size_out, int crop_out)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
342 {
29948
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
343 unsigned long fixpoint, mant, frac, value, rep, vb;
27420
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
344
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
345 /* calculate FRAC and MANT */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
346 do {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
347 rep = mant = frac = 0;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
348
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
349 if (size_in == size_out) {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
350 if (crop_out != size_out)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
351 mant = 1; /* needed for cropping */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
352 break;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
353 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
354
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
355 /* VEU2H special upscale */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
356 if (sh_veu_is_veu2h() && size_out > size_in) {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
357 fixpoint = (4096 * size_in) / size_out;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
358
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
359 mant = fixpoint / 4096;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
360 frac = fixpoint - (mant * 4096);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
361 frac &= ~0x07;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
362
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
363 switch (frac) {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
364 case 0x800:
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
365 rep = 1;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
366 break;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
367 case 0x400:
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
368 rep = 3;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
369 break;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
370 case 0x200:
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
371 rep = 7;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
372 break;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
373 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
374
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
375 if (rep)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
376 break;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
377 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
378
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
379 fixpoint = (4096 * (size_in - 1)) / (size_out + 1);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
380 mant = fixpoint / 4096;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
381 frac = fixpoint - (mant * 4096);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
382
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
383 if (frac & 0x07) {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
384 frac &= ~0x07;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
385 if (size_out > size_in)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
386 frac -= 8; /* round down if scaling up */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
387 else
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
388 frac += 8; /* round up if scaling down */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
389 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
390
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
391 } while (0);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
392
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
393 /* set scale */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
394 value = read_reg(ump, VRFCR);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
395 if (vertical) {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
396 value &= ~0xffff0000;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
397 value |= ((mant << 12) | frac) << 16;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
398 } else {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
399 value &= ~0xffff;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
400 value |= (mant << 12) | frac;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
401 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
402 write_reg(ump, value, VRFCR);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
403
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
404 /* set clip */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
405 value = read_reg(ump, VRFSR);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
406 if (vertical) {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
407 value &= ~0xffff0000;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
408 value |= ((rep << 12) | crop_out) << 16;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
409 } else {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
410 value &= ~0xffff;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
411 value |= (rep << 12) | crop_out;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
412 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
413 write_reg(ump, value, VRFSR);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
414
29948
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
415 /* VEU3F needs additional VRPBR register handling */
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
416 if (sh_veu_is_veu3f()) {
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
417 if (size_out > size_in)
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
418 vb = 64;
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
419 else {
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
420 if ((mant >= 8) && (mant < 16))
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
421 value = 4;
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
422 else if ((mant >= 4) && (mant < 8))
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
423 value = 2;
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
424 else
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
425 value = 1;
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
426
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
427 vb = 64 * 4096 * value;
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
428 vb /= 4096 * mant + frac;
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
429 }
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
430
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
431 /* set resize passband register */
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
432 value = read_reg(ump, VRPBR);
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
433 if (vertical) {
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
434 value &= ~0xffff0000;
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
435 value |= vb << 16;
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
436 } else {
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
437 value &= ~0xffff;
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
438 value |= vb;
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
439 }
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
440 write_reg(ump, value, VRPBR);
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
441 }
20da977f0f3e Update the SuperH VEU vidix driver with experimental support for VEU3F.
cehoyos
parents: 29946
diff changeset
442
27420
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
443 return (((size_in * crop_out) / size_out) + 0x03) & ~0x03;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
444 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
445
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
446 static void sh_veu_setup_planes(vidix_playback_t *info,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
447 struct sh_veu_plane *src,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
448 struct sh_veu_plane *dst)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
449 {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
450 unsigned long addr, real_w, real_h;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
451
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
452 src->width = info->src.w;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
453 src->height = info->src.h;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
454 src->stride = (info->src.w+15) & ~15;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
455
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
456 dst->width = real_w = info->dest.w;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
457 dst->height = real_h = info->dest.h;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
458 dst->stride = fbi.line_length;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
459 dst->pos_x = info->dest.x & ~0x03;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
460 dst->pos_y = info->dest.y;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
461
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
462 if ((dst->width + dst->pos_x) > fbi.width)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
463 dst->width = fbi.width - dst->pos_x;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
464
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
465 if ((dst->height + dst->pos_y) > fbi.height)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
466 dst->height = fbi.height - dst->pos_y;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
467
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
468 addr = fbi.address;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
469 addr += dst->pos_x * (fbi.bpp / 8);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
470 addr += dst->pos_y * dst->stride;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
471
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
472 src->width = sh_veu_do_scale(&uio_mmio, 0, src->width,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
473 real_w, dst->width);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
474 src->height = sh_veu_do_scale(&uio_mmio, 1, src->height,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
475 real_h, dst->height);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
476
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
477 write_reg(&uio_mmio, src->stride, VESWR);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
478 write_reg(&uio_mmio, src->width | (src->height << 16), VESSR);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
479 write_reg(&uio_mmio, 0, VBSSR); /* not using bundle mode */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
480
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
481 write_reg(&uio_mmio, dst->stride, VEDWR);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
482 write_reg(&uio_mmio, addr, VDAYR);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
483 write_reg(&uio_mmio, 0, VDACR); /* unused for RGB */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
484
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
485 write_reg(&uio_mmio, 0x67, VSWPR);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
486 write_reg(&uio_mmio, (6 << 16) | (0 << 14) | 2 | 4, VTRCR);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
487
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
488 if (sh_veu_is_veu2h()) {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
489 write_reg(&uio_mmio, 0x0cc5, VMCR00);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
490 write_reg(&uio_mmio, 0x0950, VMCR01);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
491 write_reg(&uio_mmio, 0x0000, VMCR02);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
492
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
493 write_reg(&uio_mmio, 0x397f, VMCR10);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
494 write_reg(&uio_mmio, 0x0950, VMCR11);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
495 write_reg(&uio_mmio, 0x3ccd, VMCR12);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
496
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
497 write_reg(&uio_mmio, 0x0000, VMCR20);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
498 write_reg(&uio_mmio, 0x0950, VMCR21);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
499 write_reg(&uio_mmio, 0x1023, VMCR22);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
500
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
501 write_reg(&uio_mmio, 0x00800010, VCOFFR);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
502 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
503
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
504 write_reg(&uio_mmio, 1, VEIER); /* enable interrupt in VEU */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
505 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
506
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
507 static void sh_veu_blit(vidix_playback_t *info, int frame)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
508 {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
509 unsigned long enable = 1;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
510 unsigned long addr;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
511
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
512 addr = uio_mem.address + info->offsets[frame];
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
513
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
514 write_reg(&uio_mmio, addr + info->offset.y, VSAYR);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
515 write_reg(&uio_mmio, addr + info->offset.u, VSACR);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
516
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
517 /* Enable interrupt in UIO driver */
28019
f504a06fcf50 Use standard unsigned long type instead of u_long.
diego
parents: 27420
diff changeset
518 write(uio_dev.fd, &enable, sizeof(unsigned long));
27420
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
519
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
520 write_reg(&uio_mmio, 1, VESTR); /* start operation */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
521 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
522
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
523 static int sh_veu_init(void)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
524 {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
525 write_reg(&uio_mmio, 0x100, VBSRR); /* reset VEU */
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
526 return 0;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
527 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
528
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
529 static void sh_veu_destroy(void)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
530 {
29946
54bacf6a38ca Update the SuperH VEU vidix driver with code that calls fsync() after each
cehoyos
parents: 28019
diff changeset
531 close(fb_fd);
27420
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
532 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
533
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
534 static int sh_veu_get_caps(vidix_capability_t *to)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
535 {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
536 memcpy(to, &sh_veu_cap, sizeof(vidix_capability_t));
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
537 return 0;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
538 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
539
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
540 static int sh_veu_query_fourcc(vidix_fourcc_t *to)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
541 {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
542 if (to->fourcc == IMGFMT_NV12) {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
543 to->depth = VID_DEPTH_ALL;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
544 to->flags = VID_CAP_EXPAND | VID_CAP_SHRINK;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
545 return 0;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
546 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
547 return ENOSYS;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
548 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
549
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
550
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
551 static int sh_veu_config_playback(vidix_playback_t *info)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
552 {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
553 unsigned int i, y_pitch;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
554
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
555 switch (info->fourcc) {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
556 case IMGFMT_NV12:
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
557 y_pitch = (info->src.w + 15) & ~15;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
558
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
559 info->offset.y = 0;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
560 info->offset.u = y_pitch * info->src.h;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
561 info->frame_size = info->offset.u + info->offset.u / 2;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
562 break;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
563 default:
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
564 return ENOTSUP;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
565 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
566
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
567 info->num_frames = uio_mem.size / info->frame_size;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
568 if (info->num_frames > VID_PLAY_MAXFRAMES)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
569 info->num_frames = VID_PLAY_MAXFRAMES;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
570
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
571 if (!info->num_frames) {
37107
3c5c93a30fb7 vidix: Replace printf with mp_msg
al
parents: 36634
diff changeset
572 mp_msg(MSGT_VO, MSGL_STATUS, "[sh_veu] %d is not enough memory for %d bytes frame\n",
27420
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
573 (int)uio_mem.size, (int)info->frame_size);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
574 return ENOMEM;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
575 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
576
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
577 info->dga_addr = uio_mem.iomem;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
578 info->dest.pitch.y = info->dest.pitch.u = info->dest.pitch.v = 16;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
579
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
580 for (i = 0; i < info->num_frames; i++)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
581 info->offsets[i] = info->frame_size * i;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
582
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
583 my_info = *info;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
584
37107
3c5c93a30fb7 vidix: Replace printf with mp_msg
al
parents: 36634
diff changeset
585 mp_msg(MSGT_VO, MSGL_STATUS, "[sh_veu] %d frames * %d bytes, total size = %d\n",
27420
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
586 (int)info->num_frames, (int)info->frame_size,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
587 (int)uio_mem.size);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
588
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
589 sh_veu_setup_planes(info, &_src, &_dst);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
590
37107
3c5c93a30fb7 vidix: Replace printf with mp_msg
al
parents: 36634
diff changeset
591 mp_msg(MSGT_VO, MSGL_STATUS, "[sh_veu] %dx%d->%dx%d@%dx%d -> %dx%d->%dx%d@%dx%d \n",
27420
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
592 (int)info->src.w, (int)info->src.h,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
593 (int)info->dest.w, (int)info->dest.h,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
594 (int)info->dest.x, (int)info->dest.y,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
595 (int)_src.width, (int)_src.height,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
596 (int)_dst.width, (int)_dst.height,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
597 (int)_dst.pos_x, (int)_dst.pos_y);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
598 return 0;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
599 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
600
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
601
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
602 static int sh_veu_playback_on(void)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
603 {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
604 return 0;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
605 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
606
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
607 static int sh_veu_playback_off(void)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
608 {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
609 return 0;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
610 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
611
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
612 static int sh_veu_first_frame = 1;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
613
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
614 static int sh_veu_frame_sel(unsigned int frame)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
615 {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
616 if (!sh_veu_first_frame)
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
617 sh_veu_wait_irq(&my_info);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
618
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
619 sh_veu_blit(&my_info, frame);
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
620 sh_veu_first_frame = 0;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
621 return 0;
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
622 }
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
623
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
624 VDXDriver sh_veu_drv = {
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
625 "sh_veu",
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
626 NULL,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
627 .probe = sh_veu_probe,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
628 .get_caps = sh_veu_get_caps,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
629 .query_fourcc = sh_veu_query_fourcc,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
630 .init = sh_veu_init,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
631 .destroy = sh_veu_destroy,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
632 .config_playback = sh_veu_config_playback,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
633 .playback_on = sh_veu_playback_on,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
634 .playback_off = sh_veu_playback_off,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
635 .frame_sel = sh_veu_frame_sel,
917c93c652b0 Add VIDIX driver for SuperH Mobile VEU hardware block.
ben
parents:
diff changeset
636 };