aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/video/zoran.h5
-rw-r--r--drivers/media/video/zoran_device.c33
-rw-r--r--drivers/media/video/zoran_driver.c145
3 files changed, 86 insertions, 97 deletions
diff --git a/drivers/media/video/zoran.h b/drivers/media/video/zoran.h
index 8fb4a3414e0a..937c4a616c0e 100644
--- a/drivers/media/video/zoran.h
+++ b/drivers/media/video/zoran.h
@@ -240,11 +240,16 @@ enum gpcs_type {
240 240
241struct zoran_format { 241struct zoran_format {
242 char *name; 242 char *name;
243#ifdef CONFIG_VIDEO_V4L1_COMPAT
243 int palette; 244 int palette;
245#endif
246#ifdef CONFIG_VIDEO_V4L2
244 __u32 fourcc; 247 __u32 fourcc;
245 int colorspace; 248 int colorspace;
249#endif
246 int depth; 250 int depth;
247 __u32 flags; 251 __u32 flags;
252 __u32 vfespfr;
248}; 253};
249/* flags */ 254/* flags */
250#define ZORAN_FORMAT_COMPRESSED 1<<0 255#define ZORAN_FORMAT_COMPRESSED 1<<0
diff --git a/drivers/media/video/zoran_device.c b/drivers/media/video/zoran_device.c
index b0752767ee4f..d9640ec4b9b0 100644
--- a/drivers/media/video/zoran_device.c
+++ b/drivers/media/video/zoran_device.c
@@ -429,8 +429,6 @@ zr36057_set_vfe (struct zoran *zr,
429 reg |= (HorDcm << ZR36057_VFESPFR_HorDcm); 429 reg |= (HorDcm << ZR36057_VFESPFR_HorDcm);
430 reg |= (VerDcm << ZR36057_VFESPFR_VerDcm); 430 reg |= (VerDcm << ZR36057_VFESPFR_VerDcm);
431 reg |= (DispMode << ZR36057_VFESPFR_DispMode); 431 reg |= (DispMode << ZR36057_VFESPFR_DispMode);
432 if (format->palette != VIDEO_PALETTE_YUV422 && format->palette != VIDEO_PALETTE_YUYV)
433 reg |= ZR36057_VFESPFR_LittleEndian;
434 /* RJ: I don't know, why the following has to be the opposite 432 /* RJ: I don't know, why the following has to be the opposite
435 * of the corresponding ZR36060 setting, but only this way 433 * of the corresponding ZR36060 setting, but only this way
436 * we get the correct colors when uncompressing to the screen */ 434 * we get the correct colors when uncompressing to the screen */
@@ -439,36 +437,6 @@ zr36057_set_vfe (struct zoran *zr,
439 if (zr->norm != VIDEO_MODE_NTSC) 437 if (zr->norm != VIDEO_MODE_NTSC)
440 reg |= ZR36057_VFESPFR_ExtFl; // NEEDED!!!!!!! Wolfgang 438 reg |= ZR36057_VFESPFR_ExtFl; // NEEDED!!!!!!! Wolfgang
441 reg |= ZR36057_VFESPFR_TopField; 439 reg |= ZR36057_VFESPFR_TopField;
442 switch (format->palette) {
443
444 case VIDEO_PALETTE_YUYV:
445 case VIDEO_PALETTE_YUV422:
446 reg |= ZR36057_VFESPFR_YUV422;
447 break;
448
449 case VIDEO_PALETTE_RGB555:
450 reg |= ZR36057_VFESPFR_RGB555 | ZR36057_VFESPFR_ErrDif;
451 break;
452
453 case VIDEO_PALETTE_RGB565:
454 reg |= ZR36057_VFESPFR_RGB565 | ZR36057_VFESPFR_ErrDif;
455 break;
456
457 case VIDEO_PALETTE_RGB24:
458 reg |= ZR36057_VFESPFR_RGB888 | ZR36057_VFESPFR_Pack24;
459 break;
460
461 case VIDEO_PALETTE_RGB32:
462 reg |= ZR36057_VFESPFR_RGB888;
463 break;
464
465 default:
466 dprintk(1,
467 KERN_INFO "%s: set_vfe() - unknown color_fmt=%x\n",
468 ZR_DEVNAME(zr), format->palette);
469 return;
470
471 }
472 if (HorDcm >= 48) { 440 if (HorDcm >= 48) {
473 reg |= 3 << ZR36057_VFESPFR_HFilter; /* 5 tap filter */ 441 reg |= 3 << ZR36057_VFESPFR_HFilter; /* 5 tap filter */
474 } else if (HorDcm >= 32) { 442 } else if (HorDcm >= 32) {
@@ -476,6 +444,7 @@ zr36057_set_vfe (struct zoran *zr,
476 } else if (HorDcm >= 16) { 444 } else if (HorDcm >= 16) {
477 reg |= 1 << ZR36057_VFESPFR_HFilter; /* 3 tap filter */ 445 reg |= 1 << ZR36057_VFESPFR_HFilter; /* 3 tap filter */
478 } 446 }
447 reg |= format->vfespfr;
479 btwrite(reg, ZR36057_VFESPFR); 448 btwrite(reg, ZR36057_VFESPFR);
480 449
481 /* display configuration */ 450 /* display configuration */
diff --git a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c
index 06446311564a..ec9ae6c61bd5 100644
--- a/drivers/media/video/zoran_driver.c
+++ b/drivers/media/video/zoran_driver.c
@@ -99,88 +99,103 @@
99 99
100#include <asm/byteorder.h> 100#include <asm/byteorder.h>
101 101
102const struct zoran_format zoran_formats[] = { 102#if defined(CONFIG_VIDEO_V4L2) && defined(CONFIG_VIDEO_V4L1_COMPAT)
103 { 103#define ZFMT(pal, fcc, cs) \
104 .name = "15-bit RGB", 104 .palette = (pal), .fourcc = (fcc), .colorspace = (cs)
105 .palette = VIDEO_PALETTE_RGB555, 105#elif defined(CONFIG_VIDEO_V4L2)
106#ifdef CONFIG_VIDEO_V4L2 106#define ZFMT(pal, fcc, cs) \
107#ifdef __LITTLE_ENDIAN 107 .fourcc = (fcc), .colorspace = (cs)
108 .fourcc = V4L2_PIX_FMT_RGB555,
109#else 108#else
110 .fourcc = V4L2_PIX_FMT_RGB555X, 109#define ZFMT(pal, fcc, cs) \
111#endif 110 .palette = (pal)
112 .colorspace = V4L2_COLORSPACE_SRGB,
113#endif 111#endif
112
113const struct zoran_format zoran_formats[] = {
114 {
115 .name = "15-bit RGB LE",
116 ZFMT(VIDEO_PALETTE_RGB555,
117 V4L2_PIX_FMT_RGB555, V4L2_COLORSPACE_SRGB),
114 .depth = 15, 118 .depth = 15,
115 .flags = ZORAN_FORMAT_CAPTURE | 119 .flags = ZORAN_FORMAT_CAPTURE |
116 ZORAN_FORMAT_OVERLAY, 120 ZORAN_FORMAT_OVERLAY,
121 .vfespfr = ZR36057_VFESPFR_RGB555|ZR36057_VFESPFR_ErrDif|
122 ZR36057_VFESPFR_LittleEndian,
117 }, { 123 }, {
118 .name = "16-bit RGB", 124 .name = "15-bit RGB BE",
119 .palette = VIDEO_PALETTE_RGB565, 125 ZFMT(-1,
120#ifdef CONFIG_VIDEO_V4L2 126 V4L2_PIX_FMT_RGB555X, V4L2_COLORSPACE_SRGB),
121#ifdef __LITTLE_ENDIAN 127 .depth = 15,
122 .fourcc = V4L2_PIX_FMT_RGB565, 128 .flags = ZORAN_FORMAT_CAPTURE |
123#else 129 ZORAN_FORMAT_OVERLAY,
124 .fourcc = V4L2_PIX_FMT_RGB565X, 130 .vfespfr = ZR36057_VFESPFR_RGB555|ZR36057_VFESPFR_ErrDif,
125#endif 131 }, {
126 .colorspace = V4L2_COLORSPACE_SRGB, 132 .name = "16-bit RGB LE",
127#endif 133 ZFMT(VIDEO_PALETTE_RGB565,
134 V4L2_PIX_FMT_RGB565, V4L2_COLORSPACE_SRGB),
128 .depth = 16, 135 .depth = 16,
129 .flags = ZORAN_FORMAT_CAPTURE | 136 .flags = ZORAN_FORMAT_CAPTURE |
130 ZORAN_FORMAT_OVERLAY, 137 ZORAN_FORMAT_OVERLAY,
138 .vfespfr = ZR36057_VFESPFR_RGB565|ZR36057_VFESPFR_ErrDif|
139 ZR36057_VFESPFR_LittleEndian,
140 }, {
141 .name = "16-bit RGB BE",
142 ZFMT(-1,
143 V4L2_PIX_FMT_RGB565, V4L2_COLORSPACE_SRGB),
144 .depth = 16,
145 .flags = ZORAN_FORMAT_CAPTURE |
146 ZORAN_FORMAT_OVERLAY,
147 .vfespfr = ZR36057_VFESPFR_RGB565|ZR36057_VFESPFR_ErrDif,
131 }, { 148 }, {
132 .name = "24-bit RGB", 149 .name = "24-bit RGB",
133 .palette = VIDEO_PALETTE_RGB24, 150 ZFMT(VIDEO_PALETTE_RGB24,
134#ifdef CONFIG_VIDEO_V4L2 151 V4L2_PIX_FMT_BGR24, V4L2_COLORSPACE_SRGB),
135#ifdef __LITTLE_ENDIAN
136 .fourcc = V4L2_PIX_FMT_BGR24,
137#else
138 .fourcc = V4L2_PIX_FMT_RGB24,
139#endif
140 .colorspace = V4L2_COLORSPACE_SRGB,
141#endif
142 .depth = 24, 152 .depth = 24,
143 .flags = ZORAN_FORMAT_CAPTURE | 153 .flags = ZORAN_FORMAT_CAPTURE |
144 ZORAN_FORMAT_OVERLAY, 154 ZORAN_FORMAT_OVERLAY,
155 .vfespfr = ZR36057_VFESPFR_RGB888|ZR36057_VFESPFR_Pack24,
145 }, { 156 }, {
146 .name = "32-bit RGB", 157 .name = "32-bit RGB LE",
147 .palette = VIDEO_PALETTE_RGB32, 158 ZFMT(VIDEO_PALETTE_RGB32,
148#ifdef CONFIG_VIDEO_V4L2 159 V4L2_PIX_FMT_BGR32, V4L2_COLORSPACE_SRGB),
149#ifdef __LITTLE_ENDIAN
150 .fourcc = V4L2_PIX_FMT_BGR32,
151#else
152 .fourcc = V4L2_PIX_FMT_RGB32,
153#endif
154 .colorspace = V4L2_COLORSPACE_SRGB,
155#endif
156 .depth = 32, 160 .depth = 32,
157 .flags = ZORAN_FORMAT_CAPTURE | 161 .flags = ZORAN_FORMAT_CAPTURE |
158 ZORAN_FORMAT_OVERLAY, 162 ZORAN_FORMAT_OVERLAY,
163 .vfespfr = ZR36057_VFESPFR_RGB888|ZR36057_VFESPFR_LittleEndian,
164 }, {
165 .name = "32-bit RGB BE",
166 ZFMT(-1,
167 V4L2_PIX_FMT_RGB32, V4L2_COLORSPACE_SRGB),
168 .depth = 32,
169 .flags = ZORAN_FORMAT_CAPTURE |
170 ZORAN_FORMAT_OVERLAY,
171 .vfespfr = ZR36057_VFESPFR_RGB888,
159 }, { 172 }, {
160 .name = "4:2:2, packed, YUYV", 173 .name = "4:2:2, packed, YUYV",
161 .palette = VIDEO_PALETTE_YUV422, 174 ZFMT(VIDEO_PALETTE_YUV422,
162#ifdef CONFIG_VIDEO_V4L2 175 V4L2_PIX_FMT_YUYV, V4L2_COLORSPACE_SMPTE170M),
163 .fourcc = V4L2_PIX_FMT_YUYV,
164 .colorspace = V4L2_COLORSPACE_SMPTE170M,
165#endif
166 .depth = 16, 176 .depth = 16,
167 .flags = ZORAN_FORMAT_CAPTURE | 177 .flags = ZORAN_FORMAT_CAPTURE |
168 ZORAN_FORMAT_OVERLAY, 178 ZORAN_FORMAT_OVERLAY,
179 .vfespfr = ZR36057_VFESPFR_YUV422,
180 }, {
181 .name = "4:2:2, packed, UYVY",
182 ZFMT(VIDEO_PALETTE_UYVY,
183 V4L2_PIX_FMT_UYVY, V4L2_COLORSPACE_SMPTE170M),
184 .depth = 16,
185 .flags = ZORAN_FORMAT_CAPTURE |
186 ZORAN_FORMAT_OVERLAY,
187 .vfespfr = ZR36057_VFESPFR_YUV422|ZR36057_VFESPFR_LittleEndian,
169 }, { 188 }, {
170 .name = "Hardware-encoded Motion-JPEG", 189 .name = "Hardware-encoded Motion-JPEG",
171 .palette = -1, 190 ZFMT(-1,
172#ifdef CONFIG_VIDEO_V4L2 191 V4L2_PIX_FMT_MJPEG, V4L2_COLORSPACE_SMPTE170M),
173 .fourcc = V4L2_PIX_FMT_MJPEG,
174 .colorspace = V4L2_COLORSPACE_SMPTE170M,
175#endif
176 .depth = 0, 192 .depth = 0,
177 .flags = ZORAN_FORMAT_CAPTURE | 193 .flags = ZORAN_FORMAT_CAPTURE |
178 ZORAN_FORMAT_PLAYBACK | 194 ZORAN_FORMAT_PLAYBACK |
179 ZORAN_FORMAT_COMPRESSED, 195 ZORAN_FORMAT_COMPRESSED,
180 } 196 }
181}; 197};
182static const int zoran_num_formats = 198#define NUM_FORMATS ARRAY_SIZE(zoran_formats)
183 (sizeof(zoran_formats) / sizeof(struct zoran_format));
184 199
185// RJ: Test only - want to test BUZ_USE_HIMEM even when CONFIG_BIGPHYS_AREA is defined 200// RJ: Test only - want to test BUZ_USE_HIMEM even when CONFIG_BIGPHYS_AREA is defined
186 201
@@ -768,13 +783,13 @@ v4l_grab (struct file *file,
768 struct zoran *zr = fh->zr; 783 struct zoran *zr = fh->zr;
769 int res = 0, i; 784 int res = 0, i;
770 785
771 for (i = 0; i < zoran_num_formats; i++) { 786 for (i = 0; i < NUM_FORMATS; i++) {
772 if (zoran_formats[i].palette == mp->format && 787 if (zoran_formats[i].palette == mp->format &&
773 zoran_formats[i].flags & ZORAN_FORMAT_CAPTURE && 788 zoran_formats[i].flags & ZORAN_FORMAT_CAPTURE &&
774 !(zoran_formats[i].flags & ZORAN_FORMAT_COMPRESSED)) 789 !(zoran_formats[i].flags & ZORAN_FORMAT_COMPRESSED))
775 break; 790 break;
776 } 791 }
777 if (i == zoran_num_formats || zoran_formats[i].depth == 0) { 792 if (i == NUM_FORMATS || zoran_formats[i].depth == 0) {
778 dprintk(1, 793 dprintk(1,
779 KERN_ERR 794 KERN_ERR
780 "%s: v4l_grab() - wrong bytes-per-pixel format\n", 795 "%s: v4l_grab() - wrong bytes-per-pixel format\n",
@@ -2107,7 +2122,7 @@ zoran_do_ioctl (struct inode *inode,
2107 vpict->colour, vpict->contrast, vpict->depth, 2122 vpict->colour, vpict->contrast, vpict->depth,
2108 vpict->palette); 2123 vpict->palette);
2109 2124
2110 for (i = 0; i < zoran_num_formats; i++) { 2125 for (i = 0; i < NUM_FORMATS; i++) {
2111 const struct zoran_format *fmt = &zoran_formats[i]; 2126 const struct zoran_format *fmt = &zoran_formats[i];
2112 2127
2113 if (fmt->palette != -1 && 2128 if (fmt->palette != -1 &&
@@ -2116,7 +2131,7 @@ zoran_do_ioctl (struct inode *inode,
2116 fmt->depth == vpict->depth) 2131 fmt->depth == vpict->depth)
2117 break; 2132 break;
2118 } 2133 }
2119 if (i == zoran_num_formats) { 2134 if (i == NUM_FORMATS) {
2120 dprintk(1, 2135 dprintk(1,
2121 KERN_ERR 2136 KERN_ERR
2122 "%s: VIDIOCSPICT - Invalid palette %d\n", 2137 "%s: VIDIOCSPICT - Invalid palette %d\n",
@@ -2220,10 +2235,10 @@ zoran_do_ioctl (struct inode *inode,
2220 ZR_DEVNAME(zr), vbuf->base, vbuf->width, 2235 ZR_DEVNAME(zr), vbuf->base, vbuf->width,
2221 vbuf->height, vbuf->depth, vbuf->bytesperline); 2236 vbuf->height, vbuf->depth, vbuf->bytesperline);
2222 2237
2223 for (i = 0; i < zoran_num_formats; i++) 2238 for (i = 0; i < NUM_FORMATS; i++)
2224 if (zoran_formats[i].depth == vbuf->depth) 2239 if (zoran_formats[i].depth == vbuf->depth)
2225 break; 2240 break;
2226 if (i == zoran_num_formats) { 2241 if (i == NUM_FORMATS) {
2227 dprintk(1, 2242 dprintk(1,
2228 KERN_ERR 2243 KERN_ERR
2229 "%s: VIDIOCSFBUF - invalid fbuf depth %d\n", 2244 "%s: VIDIOCSFBUF - invalid fbuf depth %d\n",
@@ -2672,14 +2687,14 @@ zoran_do_ioctl (struct inode *inode,
2672 return -EINVAL; 2687 return -EINVAL;
2673 } 2688 }
2674 2689
2675 for (i = 0; i < zoran_num_formats; i++) { 2690 for (i = 0; i < NUM_FORMATS; i++) {
2676 if (zoran_formats[i].flags & flag) 2691 if (zoran_formats[i].flags & flag)
2677 num++; 2692 num++;
2678 if (num == fmt->index) 2693 if (num == fmt->index)
2679 break; 2694 break;
2680 } 2695 }
2681 if (fmt->index < 0 /* late, but not too late */ || 2696 if (fmt->index < 0 /* late, but not too late */ ||
2682 i == zoran_num_formats) 2697 i == NUM_FORMATS)
2683 return -EINVAL; 2698 return -EINVAL;
2684 2699
2685 memset(fmt, 0, sizeof(*fmt)); 2700 memset(fmt, 0, sizeof(*fmt));
@@ -2942,11 +2957,11 @@ zoran_do_ioctl (struct inode *inode,
2942 sfmtjpg_unlock_and_return: 2957 sfmtjpg_unlock_and_return:
2943 mutex_unlock(&zr->resource_lock); 2958 mutex_unlock(&zr->resource_lock);
2944 } else { 2959 } else {
2945 for (i = 0; i < zoran_num_formats; i++) 2960 for (i = 0; i < NUM_FORMATS; i++)
2946 if (fmt->fmt.pix.pixelformat == 2961 if (fmt->fmt.pix.pixelformat ==
2947 zoran_formats[i].fourcc) 2962 zoran_formats[i].fourcc)
2948 break; 2963 break;
2949 if (i == zoran_num_formats) { 2964 if (i == NUM_FORMATS) {
2950 dprintk(1, 2965 dprintk(1,
2951 KERN_ERR 2966 KERN_ERR
2952 "%s: VIDIOC_S_FMT - unknown/unsupported format 0x%x (%4.4s)\n", 2967 "%s: VIDIOC_S_FMT - unknown/unsupported format 0x%x (%4.4s)\n",
@@ -3055,10 +3070,10 @@ zoran_do_ioctl (struct inode *inode,
3055 fb->fmt.bytesperline, fb->fmt.pixelformat, 3070 fb->fmt.bytesperline, fb->fmt.pixelformat,
3056 (char *) &printformat); 3071 (char *) &printformat);
3057 3072
3058 for (i = 0; i < zoran_num_formats; i++) 3073 for (i = 0; i < NUM_FORMATS; i++)
3059 if (zoran_formats[i].fourcc == fb->fmt.pixelformat) 3074 if (zoran_formats[i].fourcc == fb->fmt.pixelformat)
3060 break; 3075 break;
3061 if (i == zoran_num_formats) { 3076 if (i == NUM_FORMATS) {
3062 dprintk(1, 3077 dprintk(1,
3063 KERN_ERR 3078 KERN_ERR
3064 "%s: VIDIOC_S_FBUF - format=0x%x (%4.4s) not allowed\n", 3079 "%s: VIDIOC_S_FBUF - format=0x%x (%4.4s) not allowed\n",
@@ -4151,11 +4166,11 @@ zoran_do_ioctl (struct inode *inode,
4151 V4L2_BUF_TYPE_VIDEO_CAPTURE) { 4166 V4L2_BUF_TYPE_VIDEO_CAPTURE) {
4152 int i; 4167 int i;
4153 4168
4154 for (i = 0; i < zoran_num_formats; i++) 4169 for (i = 0; i < NUM_FORMATS; i++)
4155 if (zoran_formats[i].fourcc == 4170 if (zoran_formats[i].fourcc ==
4156 fmt->fmt.pix.pixelformat) 4171 fmt->fmt.pix.pixelformat)
4157 break; 4172 break;
4158 if (i == zoran_num_formats) { 4173 if (i == NUM_FORMATS) {
4159 res = -EINVAL; 4174 res = -EINVAL;
4160 goto tryfmt_unlock_and_return; 4175 goto tryfmt_unlock_and_return;
4161 } 4176 }