aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/zoran_driver.c
diff options
context:
space:
mode:
authorTrent Piepho <xyzzy@speakeasy.org>2007-07-17 17:29:44 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-07-30 15:26:26 -0400
commit603d6f2c8f9f3604f9c6c1f8903efc2df30a000f (patch)
tree4391bd4db78094e118b2d4da08c115b4f5638ae0 /drivers/media/video/zoran_driver.c
parentbb2e033913f14b2f9f6745e206c3ea5df481b4fd (diff)
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: Trent Piepho <xyzzy@speakeasy.org> Acked-by: Ronald S. Bultje <rbultje@ronald.bitfreak.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/zoran_driver.c')
-rw-r--r--drivers/media/video/zoran_driver.c145
1 files changed, 80 insertions, 65 deletions
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 }