Commit 603d6f2c authored by Trent Piepho's avatar Trent Piepho Committed by Mauro Carvalho Chehab

V4L/DVB (5890): zr36067: Add UYVY, RGB555X, RGB565X, and RGB32 formats

Add support for the UYVY and the other big endian output formats.  The
driver was naming formats based on the host endianess.  This is different
that all the other drivers appear to work and not what software appears
to expect.

Use ARRAY_SIZE() to find the the size of the zoran_formats array.

Change the way the driver handles setting the video format register.  Rather
than use some if and switch statements to set to register by looking at the
format id, the format list simply has a field with the proper bits to set.

Adds a bit of ifdef to make a driver without V4L1 support more possible.
Also create a macro for defining formats that handles vl41 and/or vl42
support to avoid repeated ifdefs in the format list.
Signed-off-by: default avatarTrent Piepho <xyzzy@speakeasy.org>
Acked-by: default avatarRonald S. Bultje <rbultje@ronald.bitfreak.net>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent bb2e0339
...@@ -240,11 +240,16 @@ enum gpcs_type { ...@@ -240,11 +240,16 @@ enum gpcs_type {
struct zoran_format { struct zoran_format {
char *name; char *name;
#ifdef CONFIG_VIDEO_V4L1_COMPAT
int palette; int palette;
#endif
#ifdef CONFIG_VIDEO_V4L2
__u32 fourcc; __u32 fourcc;
int colorspace; int colorspace;
#endif
int depth; int depth;
__u32 flags; __u32 flags;
__u32 vfespfr;
}; };
/* flags */ /* flags */
#define ZORAN_FORMAT_COMPRESSED 1<<0 #define ZORAN_FORMAT_COMPRESSED 1<<0
......
...@@ -429,8 +429,6 @@ zr36057_set_vfe (struct zoran *zr, ...@@ -429,8 +429,6 @@ zr36057_set_vfe (struct zoran *zr,
reg |= (HorDcm << ZR36057_VFESPFR_HorDcm); reg |= (HorDcm << ZR36057_VFESPFR_HorDcm);
reg |= (VerDcm << ZR36057_VFESPFR_VerDcm); reg |= (VerDcm << ZR36057_VFESPFR_VerDcm);
reg |= (DispMode << ZR36057_VFESPFR_DispMode); reg |= (DispMode << ZR36057_VFESPFR_DispMode);
if (format->palette != VIDEO_PALETTE_YUV422 && format->palette != VIDEO_PALETTE_YUYV)
reg |= ZR36057_VFESPFR_LittleEndian;
/* RJ: I don't know, why the following has to be the opposite /* RJ: I don't know, why the following has to be the opposite
* of the corresponding ZR36060 setting, but only this way * of the corresponding ZR36060 setting, but only this way
* we get the correct colors when uncompressing to the screen */ * we get the correct colors when uncompressing to the screen */
...@@ -439,36 +437,6 @@ zr36057_set_vfe (struct zoran *zr, ...@@ -439,36 +437,6 @@ zr36057_set_vfe (struct zoran *zr,
if (zr->norm != VIDEO_MODE_NTSC) if (zr->norm != VIDEO_MODE_NTSC)
reg |= ZR36057_VFESPFR_ExtFl; // NEEDED!!!!!!! Wolfgang reg |= ZR36057_VFESPFR_ExtFl; // NEEDED!!!!!!! Wolfgang
reg |= ZR36057_VFESPFR_TopField; reg |= ZR36057_VFESPFR_TopField;
switch (format->palette) {
case VIDEO_PALETTE_YUYV:
case VIDEO_PALETTE_YUV422:
reg |= ZR36057_VFESPFR_YUV422;
break;
case VIDEO_PALETTE_RGB555:
reg |= ZR36057_VFESPFR_RGB555 | ZR36057_VFESPFR_ErrDif;
break;
case VIDEO_PALETTE_RGB565:
reg |= ZR36057_VFESPFR_RGB565 | ZR36057_VFESPFR_ErrDif;
break;
case VIDEO_PALETTE_RGB24:
reg |= ZR36057_VFESPFR_RGB888 | ZR36057_VFESPFR_Pack24;
break;
case VIDEO_PALETTE_RGB32:
reg |= ZR36057_VFESPFR_RGB888;
break;
default:
dprintk(1,
KERN_INFO "%s: set_vfe() - unknown color_fmt=%x\n",
ZR_DEVNAME(zr), format->palette);
return;
}
if (HorDcm >= 48) { if (HorDcm >= 48) {
reg |= 3 << ZR36057_VFESPFR_HFilter; /* 5 tap filter */ reg |= 3 << ZR36057_VFESPFR_HFilter; /* 5 tap filter */
} else if (HorDcm >= 32) { } else if (HorDcm >= 32) {
...@@ -476,6 +444,7 @@ zr36057_set_vfe (struct zoran *zr, ...@@ -476,6 +444,7 @@ zr36057_set_vfe (struct zoran *zr,
} else if (HorDcm >= 16) { } else if (HorDcm >= 16) {
reg |= 1 << ZR36057_VFESPFR_HFilter; /* 3 tap filter */ reg |= 1 << ZR36057_VFESPFR_HFilter; /* 3 tap filter */
} }
reg |= format->vfespfr;
btwrite(reg, ZR36057_VFESPFR); btwrite(reg, ZR36057_VFESPFR);
/* display configuration */ /* display configuration */
......
...@@ -99,88 +99,103 @@ ...@@ -99,88 +99,103 @@
#include <asm/byteorder.h> #include <asm/byteorder.h>
const struct zoran_format zoran_formats[] = { #if defined(CONFIG_VIDEO_V4L2) && defined(CONFIG_VIDEO_V4L1_COMPAT)
{ #define ZFMT(pal, fcc, cs) \
.name = "15-bit RGB", .palette = (pal), .fourcc = (fcc), .colorspace = (cs)
.palette = VIDEO_PALETTE_RGB555, #elif defined(CONFIG_VIDEO_V4L2)
#ifdef CONFIG_VIDEO_V4L2 #define ZFMT(pal, fcc, cs) \
#ifdef __LITTLE_ENDIAN .fourcc = (fcc), .colorspace = (cs)
.fourcc = V4L2_PIX_FMT_RGB555,
#else #else
.fourcc = V4L2_PIX_FMT_RGB555X, #define ZFMT(pal, fcc, cs) \
#endif .palette = (pal)
.colorspace = V4L2_COLORSPACE_SRGB,
#endif #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, .depth = 15,
.flags = ZORAN_FORMAT_CAPTURE | .flags = ZORAN_FORMAT_CAPTURE |
ZORAN_FORMAT_OVERLAY, ZORAN_FORMAT_OVERLAY,
.vfespfr = ZR36057_VFESPFR_RGB555|ZR36057_VFESPFR_ErrDif|
ZR36057_VFESPFR_LittleEndian,
}, { }, {
.name = "16-bit RGB", .name = "15-bit RGB BE",
.palette = VIDEO_PALETTE_RGB565, ZFMT(-1,
#ifdef CONFIG_VIDEO_V4L2 V4L2_PIX_FMT_RGB555X, V4L2_COLORSPACE_SRGB),
#ifdef __LITTLE_ENDIAN .depth = 15,
.fourcc = V4L2_PIX_FMT_RGB565, .flags = ZORAN_FORMAT_CAPTURE |
#else ZORAN_FORMAT_OVERLAY,
.fourcc = V4L2_PIX_FMT_RGB565X, .vfespfr = ZR36057_VFESPFR_RGB555|ZR36057_VFESPFR_ErrDif,
#endif }, {
.colorspace = V4L2_COLORSPACE_SRGB, .name = "16-bit RGB LE",
#endif ZFMT(VIDEO_PALETTE_RGB565,
V4L2_PIX_FMT_RGB565, V4L2_COLORSPACE_SRGB),
.depth = 16, .depth = 16,
.flags = ZORAN_FORMAT_CAPTURE | .flags = ZORAN_FORMAT_CAPTURE |
ZORAN_FORMAT_OVERLAY, 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", .name = "24-bit RGB",
.palette = VIDEO_PALETTE_RGB24, ZFMT(VIDEO_PALETTE_RGB24,
#ifdef CONFIG_VIDEO_V4L2 V4L2_PIX_FMT_BGR24, V4L2_COLORSPACE_SRGB),
#ifdef __LITTLE_ENDIAN
.fourcc = V4L2_PIX_FMT_BGR24,
#else
.fourcc = V4L2_PIX_FMT_RGB24,
#endif
.colorspace = V4L2_COLORSPACE_SRGB,
#endif
.depth = 24, .depth = 24,
.flags = ZORAN_FORMAT_CAPTURE | .flags = ZORAN_FORMAT_CAPTURE |
ZORAN_FORMAT_OVERLAY, ZORAN_FORMAT_OVERLAY,
.vfespfr = ZR36057_VFESPFR_RGB888|ZR36057_VFESPFR_Pack24,
}, { }, {
.name = "32-bit RGB", .name = "32-bit RGB LE",
.palette = VIDEO_PALETTE_RGB32, ZFMT(VIDEO_PALETTE_RGB32,
#ifdef CONFIG_VIDEO_V4L2 V4L2_PIX_FMT_BGR32, V4L2_COLORSPACE_SRGB),
#ifdef __LITTLE_ENDIAN
.fourcc = V4L2_PIX_FMT_BGR32,
#else
.fourcc = V4L2_PIX_FMT_RGB32,
#endif
.colorspace = V4L2_COLORSPACE_SRGB,
#endif
.depth = 32, .depth = 32,
.flags = ZORAN_FORMAT_CAPTURE | .flags = ZORAN_FORMAT_CAPTURE |
ZORAN_FORMAT_OVERLAY, 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", .name = "4:2:2, packed, YUYV",
.palette = VIDEO_PALETTE_YUV422, ZFMT(VIDEO_PALETTE_YUV422,
#ifdef CONFIG_VIDEO_V4L2 V4L2_PIX_FMT_YUYV, V4L2_COLORSPACE_SMPTE170M),
.fourcc = V4L2_PIX_FMT_YUYV,
.colorspace = V4L2_COLORSPACE_SMPTE170M,
#endif
.depth = 16, .depth = 16,
.flags = ZORAN_FORMAT_CAPTURE | .flags = ZORAN_FORMAT_CAPTURE |
ZORAN_FORMAT_OVERLAY, 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", .name = "Hardware-encoded Motion-JPEG",
.palette = -1, ZFMT(-1,
#ifdef CONFIG_VIDEO_V4L2 V4L2_PIX_FMT_MJPEG, V4L2_COLORSPACE_SMPTE170M),
.fourcc = V4L2_PIX_FMT_MJPEG,
.colorspace = V4L2_COLORSPACE_SMPTE170M,
#endif
.depth = 0, .depth = 0,
.flags = ZORAN_FORMAT_CAPTURE | .flags = ZORAN_FORMAT_CAPTURE |
ZORAN_FORMAT_PLAYBACK | ZORAN_FORMAT_PLAYBACK |
ZORAN_FORMAT_COMPRESSED, ZORAN_FORMAT_COMPRESSED,
} }
}; };
static const int zoran_num_formats = #define NUM_FORMATS ARRAY_SIZE(zoran_formats)
(sizeof(zoran_formats) / sizeof(struct zoran_format));
// RJ: Test only - want to test BUZ_USE_HIMEM even when CONFIG_BIGPHYS_AREA is defined // 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, ...@@ -768,13 +783,13 @@ v4l_grab (struct file *file,
struct zoran *zr = fh->zr; struct zoran *zr = fh->zr;
int res = 0, i; 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 && if (zoran_formats[i].palette == mp->format &&
zoran_formats[i].flags & ZORAN_FORMAT_CAPTURE && zoran_formats[i].flags & ZORAN_FORMAT_CAPTURE &&
!(zoran_formats[i].flags & ZORAN_FORMAT_COMPRESSED)) !(zoran_formats[i].flags & ZORAN_FORMAT_COMPRESSED))
break; break;
} }
if (i == zoran_num_formats || zoran_formats[i].depth == 0) { if (i == NUM_FORMATS || zoran_formats[i].depth == 0) {
dprintk(1, dprintk(1,
KERN_ERR KERN_ERR
"%s: v4l_grab() - wrong bytes-per-pixel format\n", "%s: v4l_grab() - wrong bytes-per-pixel format\n",
...@@ -2107,7 +2122,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2107,7 +2122,7 @@ zoran_do_ioctl (struct inode *inode,
vpict->colour, vpict->contrast, vpict->depth, vpict->colour, vpict->contrast, vpict->depth,
vpict->palette); 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]; const struct zoran_format *fmt = &zoran_formats[i];
if (fmt->palette != -1 && if (fmt->palette != -1 &&
...@@ -2116,7 +2131,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2116,7 +2131,7 @@ zoran_do_ioctl (struct inode *inode,
fmt->depth == vpict->depth) fmt->depth == vpict->depth)
break; break;
} }
if (i == zoran_num_formats) { if (i == NUM_FORMATS) {
dprintk(1, dprintk(1,
KERN_ERR KERN_ERR
"%s: VIDIOCSPICT - Invalid palette %d\n", "%s: VIDIOCSPICT - Invalid palette %d\n",
...@@ -2220,10 +2235,10 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2220,10 +2235,10 @@ zoran_do_ioctl (struct inode *inode,
ZR_DEVNAME(zr), vbuf->base, vbuf->width, ZR_DEVNAME(zr), vbuf->base, vbuf->width,
vbuf->height, vbuf->depth, vbuf->bytesperline); 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) if (zoran_formats[i].depth == vbuf->depth)
break; break;
if (i == zoran_num_formats) { if (i == NUM_FORMATS) {
dprintk(1, dprintk(1,
KERN_ERR KERN_ERR
"%s: VIDIOCSFBUF - invalid fbuf depth %d\n", "%s: VIDIOCSFBUF - invalid fbuf depth %d\n",
...@@ -2672,14 +2687,14 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2672,14 +2687,14 @@ zoran_do_ioctl (struct inode *inode,
return -EINVAL; return -EINVAL;
} }
for (i = 0; i < zoran_num_formats; i++) { for (i = 0; i < NUM_FORMATS; i++) {
if (zoran_formats[i].flags & flag) if (zoran_formats[i].flags & flag)
num++; num++;
if (num == fmt->index) if (num == fmt->index)
break; break;
} }
if (fmt->index < 0 /* late, but not too late */ || if (fmt->index < 0 /* late, but not too late */ ||
i == zoran_num_formats) i == NUM_FORMATS)
return -EINVAL; return -EINVAL;
memset(fmt, 0, sizeof(*fmt)); memset(fmt, 0, sizeof(*fmt));
...@@ -2942,11 +2957,11 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2942,11 +2957,11 @@ zoran_do_ioctl (struct inode *inode,
sfmtjpg_unlock_and_return: sfmtjpg_unlock_and_return:
mutex_unlock(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
} else { } else {
for (i = 0; i < zoran_num_formats; i++) for (i = 0; i < NUM_FORMATS; i++)
if (fmt->fmt.pix.pixelformat == if (fmt->fmt.pix.pixelformat ==
zoran_formats[i].fourcc) zoran_formats[i].fourcc)
break; break;
if (i == zoran_num_formats) { if (i == NUM_FORMATS) {
dprintk(1, dprintk(1,
KERN_ERR KERN_ERR
"%s: VIDIOC_S_FMT - unknown/unsupported format 0x%x (%4.4s)\n", "%s: VIDIOC_S_FMT - unknown/unsupported format 0x%x (%4.4s)\n",
...@@ -3055,10 +3070,10 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3055,10 +3070,10 @@ zoran_do_ioctl (struct inode *inode,
fb->fmt.bytesperline, fb->fmt.pixelformat, fb->fmt.bytesperline, fb->fmt.pixelformat,
(char *) &printformat); (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) if (zoran_formats[i].fourcc == fb->fmt.pixelformat)
break; break;
if (i == zoran_num_formats) { if (i == NUM_FORMATS) {
dprintk(1, dprintk(1,
KERN_ERR KERN_ERR
"%s: VIDIOC_S_FBUF - format=0x%x (%4.4s) not allowed\n", "%s: VIDIOC_S_FBUF - format=0x%x (%4.4s) not allowed\n",
...@@ -4151,11 +4166,11 @@ zoran_do_ioctl (struct inode *inode, ...@@ -4151,11 +4166,11 @@ zoran_do_ioctl (struct inode *inode,
V4L2_BUF_TYPE_VIDEO_CAPTURE) { V4L2_BUF_TYPE_VIDEO_CAPTURE) {
int i; int i;
for (i = 0; i < zoran_num_formats; i++) for (i = 0; i < NUM_FORMATS; i++)
if (zoran_formats[i].fourcc == if (zoran_formats[i].fourcc ==
fmt->fmt.pix.pixelformat) fmt->fmt.pix.pixelformat)
break; break;
if (i == zoran_num_formats) { if (i == NUM_FORMATS) {
res = -EINVAL; res = -EINVAL;
goto tryfmt_unlock_and_return; goto tryfmt_unlock_and_return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment