]> err.no Git - linux-2.6/blobdiff - drivers/media/video/zoran_driver.c
V4L/DVB (5890): zr36067: Add UYVY, RGB555X, RGB565X, and RGB32 formats
[linux-2.6] / drivers / media / video / zoran_driver.c
index 06446311564a99427952bd3db5cc81d1b0c091c7..ec9ae6c61bd5af7b9823f7f552ed677641ba1364 100644 (file)
 
 #include <asm/byteorder.h>
 
-const struct zoran_format zoran_formats[] = {
-       {
-               .name = "15-bit RGB",
-               .palette = VIDEO_PALETTE_RGB555,
-#ifdef CONFIG_VIDEO_V4L2
-#ifdef __LITTLE_ENDIAN
-               .fourcc = V4L2_PIX_FMT_RGB555,
+#if defined(CONFIG_VIDEO_V4L2) && defined(CONFIG_VIDEO_V4L1_COMPAT)
+#define ZFMT(pal, fcc, cs) \
+       .palette = (pal), .fourcc = (fcc), .colorspace = (cs)
+#elif defined(CONFIG_VIDEO_V4L2)
+#define ZFMT(pal, fcc, cs) \
+       .fourcc = (fcc), .colorspace = (cs)
 #else
-               .fourcc = V4L2_PIX_FMT_RGB555X,
-#endif
-               .colorspace = V4L2_COLORSPACE_SRGB,
+#define ZFMT(pal, fcc, cs) \
+       .palette = (pal)
 #endif
+
+const struct zoran_format zoran_formats[] = {
+       {
+               .name = "15-bit RGB LE",
+               ZFMT(VIDEO_PALETTE_RGB555,
+                    V4L2_PIX_FMT_RGB555, V4L2_COLORSPACE_SRGB),
                .depth = 15,
                .flags = ZORAN_FORMAT_CAPTURE |
                         ZORAN_FORMAT_OVERLAY,
+               .vfespfr = ZR36057_VFESPFR_RGB555|ZR36057_VFESPFR_ErrDif|
+                          ZR36057_VFESPFR_LittleEndian,
        }, {
-               .name = "16-bit RGB",
-               .palette = VIDEO_PALETTE_RGB565,
-#ifdef CONFIG_VIDEO_V4L2
-#ifdef __LITTLE_ENDIAN
-               .fourcc = V4L2_PIX_FMT_RGB565,
-#else
-               .fourcc = V4L2_PIX_FMT_RGB565X,
-#endif
-               .colorspace = V4L2_COLORSPACE_SRGB,
-#endif
+               .name = "15-bit RGB BE",
+               ZFMT(-1,
+                    V4L2_PIX_FMT_RGB555X, V4L2_COLORSPACE_SRGB),
+               .depth = 15,
+               .flags = ZORAN_FORMAT_CAPTURE |
+                        ZORAN_FORMAT_OVERLAY,
+               .vfespfr = ZR36057_VFESPFR_RGB555|ZR36057_VFESPFR_ErrDif,
+       }, {
+               .name = "16-bit RGB LE",
+               ZFMT(VIDEO_PALETTE_RGB565,
+                    V4L2_PIX_FMT_RGB565, V4L2_COLORSPACE_SRGB),
                .depth = 16,
                .flags = ZORAN_FORMAT_CAPTURE |
                         ZORAN_FORMAT_OVERLAY,
+               .vfespfr = ZR36057_VFESPFR_RGB565|ZR36057_VFESPFR_ErrDif|
+                          ZR36057_VFESPFR_LittleEndian,
+       }, {
+               .name = "16-bit RGB BE",
+               ZFMT(-1,
+                    V4L2_PIX_FMT_RGB565, V4L2_COLORSPACE_SRGB),
+               .depth = 16,
+               .flags = ZORAN_FORMAT_CAPTURE |
+                        ZORAN_FORMAT_OVERLAY,
+               .vfespfr = ZR36057_VFESPFR_RGB565|ZR36057_VFESPFR_ErrDif,
        }, {
                .name = "24-bit RGB",
-               .palette = VIDEO_PALETTE_RGB24,
-#ifdef CONFIG_VIDEO_V4L2
-#ifdef __LITTLE_ENDIAN
-               .fourcc = V4L2_PIX_FMT_BGR24,
-#else
-               .fourcc = V4L2_PIX_FMT_RGB24,
-#endif
-               .colorspace = V4L2_COLORSPACE_SRGB,
-#endif
+               ZFMT(VIDEO_PALETTE_RGB24,
+                    V4L2_PIX_FMT_BGR24, V4L2_COLORSPACE_SRGB),
                .depth = 24,
                .flags = ZORAN_FORMAT_CAPTURE |
                         ZORAN_FORMAT_OVERLAY,
+               .vfespfr = ZR36057_VFESPFR_RGB888|ZR36057_VFESPFR_Pack24,
        }, {
-               .name = "32-bit RGB",
-               .palette = VIDEO_PALETTE_RGB32,
-#ifdef CONFIG_VIDEO_V4L2
-#ifdef __LITTLE_ENDIAN
-               .fourcc = V4L2_PIX_FMT_BGR32,
-#else
-               .fourcc = V4L2_PIX_FMT_RGB32,
-#endif
-               .colorspace = V4L2_COLORSPACE_SRGB,
-#endif
+               .name = "32-bit RGB LE",
+               ZFMT(VIDEO_PALETTE_RGB32,
+                    V4L2_PIX_FMT_BGR32, V4L2_COLORSPACE_SRGB),
                .depth = 32,
                .flags = ZORAN_FORMAT_CAPTURE |
                         ZORAN_FORMAT_OVERLAY,
+               .vfespfr = ZR36057_VFESPFR_RGB888|ZR36057_VFESPFR_LittleEndian,
+       }, {
+               .name = "32-bit RGB BE",
+               ZFMT(-1,
+                    V4L2_PIX_FMT_RGB32, V4L2_COLORSPACE_SRGB),
+               .depth = 32,
+               .flags = ZORAN_FORMAT_CAPTURE |
+                        ZORAN_FORMAT_OVERLAY,
+               .vfespfr = ZR36057_VFESPFR_RGB888,
        }, {
                .name = "4:2:2, packed, YUYV",
-               .palette = VIDEO_PALETTE_YUV422,
-#ifdef CONFIG_VIDEO_V4L2
-               .fourcc = V4L2_PIX_FMT_YUYV,
-               .colorspace = V4L2_COLORSPACE_SMPTE170M,
-#endif
+               ZFMT(VIDEO_PALETTE_YUV422,
+                    V4L2_PIX_FMT_YUYV, V4L2_COLORSPACE_SMPTE170M),
                .depth = 16,
                .flags = ZORAN_FORMAT_CAPTURE |
                         ZORAN_FORMAT_OVERLAY,
+               .vfespfr = ZR36057_VFESPFR_YUV422,
+       }, {
+               .name = "4:2:2, packed, UYVY",
+               ZFMT(VIDEO_PALETTE_UYVY,
+                    V4L2_PIX_FMT_UYVY, V4L2_COLORSPACE_SMPTE170M),
+               .depth = 16,
+               .flags = ZORAN_FORMAT_CAPTURE |
+                        ZORAN_FORMAT_OVERLAY,
+               .vfespfr = ZR36057_VFESPFR_YUV422|ZR36057_VFESPFR_LittleEndian,
        }, {
                .name = "Hardware-encoded Motion-JPEG",
-               .palette = -1,
-#ifdef CONFIG_VIDEO_V4L2
-               .fourcc = V4L2_PIX_FMT_MJPEG,
-               .colorspace = V4L2_COLORSPACE_SMPTE170M,
-#endif
+               ZFMT(-1,
+                    V4L2_PIX_FMT_MJPEG, V4L2_COLORSPACE_SMPTE170M),
                .depth = 0,
                .flags = ZORAN_FORMAT_CAPTURE |
                         ZORAN_FORMAT_PLAYBACK |
                         ZORAN_FORMAT_COMPRESSED,
        }
 };
-static const int zoran_num_formats =
-    (sizeof(zoran_formats) / sizeof(struct zoran_format));
+#define NUM_FORMATS ARRAY_SIZE(zoran_formats)
 
 // RJ: Test only - want to test BUZ_USE_HIMEM even when CONFIG_BIGPHYS_AREA is defined
 
@@ -768,13 +783,13 @@ v4l_grab (struct file       *file,
        struct zoran *zr = fh->zr;
        int res = 0, i;
 
-       for (i = 0; i < zoran_num_formats; i++) {
+       for (i = 0; i < NUM_FORMATS; i++) {
                if (zoran_formats[i].palette == mp->format &&
                    zoran_formats[i].flags & ZORAN_FORMAT_CAPTURE &&
                    !(zoran_formats[i].flags & ZORAN_FORMAT_COMPRESSED))
                        break;
        }
-       if (i == zoran_num_formats || zoran_formats[i].depth == 0) {
+       if (i == NUM_FORMATS || zoran_formats[i].depth == 0) {
                dprintk(1,
                        KERN_ERR
                        "%s: v4l_grab() - wrong bytes-per-pixel format\n",
@@ -2107,7 +2122,7 @@ zoran_do_ioctl (struct inode *inode,
                        vpict->colour, vpict->contrast, vpict->depth,
                        vpict->palette);
 
-               for (i = 0; i < zoran_num_formats; i++) {
+               for (i = 0; i < NUM_FORMATS; i++) {
                        const struct zoran_format *fmt = &zoran_formats[i];
 
                        if (fmt->palette != -1 &&
@@ -2116,7 +2131,7 @@ zoran_do_ioctl (struct inode *inode,
                            fmt->depth == vpict->depth)
                                break;
                }
-               if (i == zoran_num_formats) {
+               if (i == NUM_FORMATS) {
                        dprintk(1,
                                KERN_ERR
                                "%s: VIDIOCSPICT - Invalid palette %d\n",
@@ -2220,10 +2235,10 @@ zoran_do_ioctl (struct inode *inode,
                        ZR_DEVNAME(zr), vbuf->base, vbuf->width,
                        vbuf->height, vbuf->depth, vbuf->bytesperline);
 
-               for (i = 0; i < zoran_num_formats; i++)
+               for (i = 0; i < NUM_FORMATS; i++)
                        if (zoran_formats[i].depth == vbuf->depth)
                                break;
-               if (i == zoran_num_formats) {
+               if (i == NUM_FORMATS) {
                        dprintk(1,
                                KERN_ERR
                                "%s: VIDIOCSFBUF - invalid fbuf depth %d\n",
@@ -2672,14 +2687,14 @@ zoran_do_ioctl (struct inode *inode,
                        return -EINVAL;
                }
 
-               for (i = 0; i < zoran_num_formats; i++) {
+               for (i = 0; i < NUM_FORMATS; i++) {
                        if (zoran_formats[i].flags & flag)
                                num++;
                        if (num == fmt->index)
                                break;
                }
                if (fmt->index < 0 /* late, but not too late */  ||
-                   i == zoran_num_formats)
+                   i == NUM_FORMATS)
                        return -EINVAL;
 
                memset(fmt, 0, sizeof(*fmt));
@@ -2942,11 +2957,11 @@ zoran_do_ioctl (struct inode *inode,
                        sfmtjpg_unlock_and_return:
                                mutex_unlock(&zr->resource_lock);
                        } else {
-                               for (i = 0; i < zoran_num_formats; i++)
+                               for (i = 0; i < NUM_FORMATS; i++)
                                        if (fmt->fmt.pix.pixelformat ==
                                            zoran_formats[i].fourcc)
                                                break;
-                               if (i == zoran_num_formats) {
+                               if (i == NUM_FORMATS) {
                                        dprintk(1,
                                                KERN_ERR
                                                "%s: VIDIOC_S_FMT - unknown/unsupported format 0x%x (%4.4s)\n",
@@ -3055,10 +3070,10 @@ zoran_do_ioctl (struct inode *inode,
                        fb->fmt.bytesperline, fb->fmt.pixelformat,
                        (char *) &printformat);
 
-               for (i = 0; i < zoran_num_formats; i++)
+               for (i = 0; i < NUM_FORMATS; i++)
                        if (zoran_formats[i].fourcc == fb->fmt.pixelformat)
                                break;
-               if (i == zoran_num_formats) {
+               if (i == NUM_FORMATS) {
                        dprintk(1,
                                KERN_ERR
                                "%s: VIDIOC_S_FBUF - format=0x%x (%4.4s) not allowed\n",
@@ -4151,11 +4166,11 @@ zoran_do_ioctl (struct inode *inode,
                                   V4L2_BUF_TYPE_VIDEO_CAPTURE) {
                                int i;
 
-                               for (i = 0; i < zoran_num_formats; i++)
+                               for (i = 0; i < NUM_FORMATS; i++)
                                        if (zoran_formats[i].fourcc ==
                                            fmt->fmt.pix.pixelformat)
                                                break;
-                               if (i == zoran_num_formats) {
+                               if (i == NUM_FORMATS) {
                                        res = -EINVAL;
                                        goto tryfmt_unlock_and_return;
                                }