aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/ivtv/ivtv-ioctl.c
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2007-08-23 20:15:24 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-10-09 21:06:53 -0400
commit2d4d5f11ecf6df6974579c70461866932f0bd722 (patch)
treee5d3f6c62c27fce3ffb004467bfd919780ae96b4 /drivers/media/video/ivtv/ivtv-ioctl.c
parent559e196a56a5d518181efc1d2fefe0892f4689b4 (diff)
V4L/DVB (6097): ivtv: set correct pixel format and alpha properties
ivtv: set correct pixel format and alpha properties in VIDIOC_G_FBUF Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/ivtv/ivtv-ioctl.c')
-rw-r--r--drivers/media/video/ivtv/ivtv-ioctl.c66
1 files changed, 52 insertions, 14 deletions
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c
index 01215a1c4b82..6d24c6b9a45b 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -699,6 +699,7 @@ static int ivtv_debug_ioctls(struct file *filp, unsigned int cmd, void *arg)
699int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void *arg) 699int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void *arg)
700{ 700{
701 struct ivtv_open_id *id = NULL; 701 struct ivtv_open_id *id = NULL;
702 u32 data[CX2341X_MBOX_MAX_DATA];
702 703
703 if (filp) id = (struct ivtv_open_id *)filp->private_data; 704 if (filp) id = (struct ivtv_open_id *)filp->private_data;
704 705
@@ -1183,22 +1184,59 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
1183 1184
1184 case VIDIOC_G_FBUF: { 1185 case VIDIOC_G_FBUF: {
1185 struct v4l2_framebuffer *fb = arg; 1186 struct v4l2_framebuffer *fb = arg;
1187 int pixfmt;
1188 static u32 pixel_format[16] = {
1189 V4L2_PIX_FMT_RGB332, /* Really RGB Indexed */
1190 V4L2_PIX_FMT_RGB565,
1191 V4L2_PIX_FMT_RGB555,
1192 V4L2_PIX_FMT_RGB444,
1193 V4L2_PIX_FMT_RGB32,
1194 0,
1195 0,
1196 0,
1197 /* Really YUV variants */
1198 V4L2_PIX_FMT_RGB332, /* Really YUV Indexed */
1199 V4L2_PIX_FMT_RGB565,
1200 V4L2_PIX_FMT_RGB555,
1201 V4L2_PIX_FMT_RGB444,
1202 V4L2_PIX_FMT_RGB32,
1203 0,
1204 0,
1205 0,
1206 };
1186 1207
1187 memset(fb, 0, sizeof(*fb)); 1208 memset(fb, 0, sizeof(*fb));
1188 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT_OVERLAY)) 1209 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT_OVERLAY))
1189 return -EINVAL; 1210 return -EINVAL;
1190 fb->capability = V4L2_FBUF_CAP_EXTERNOVERLAY | V4L2_FBUF_CAP_CHROMAKEY | 1211 fb->capability = V4L2_FBUF_CAP_EXTERNOVERLAY | V4L2_FBUF_CAP_CHROMAKEY |
1191 V4L2_FBUF_CAP_LOCAL_ALPHA | V4L2_FBUF_CAP_GLOBAL_ALPHA; 1212 V4L2_FBUF_CAP_GLOBAL_ALPHA;
1192 fb->fmt.pixelformat = itv->osd_pixelformat; 1213 ivtv_vapi_result(itv, data, CX2341X_OSD_GET_STATE, 0);
1214 data[0] |= (read_reg(0x2a00) >> 7) & 0x40;
1215 pixfmt = (data[0] >> 3) & 0xf;
1216 fb->fmt.pixelformat = pixel_format[pixfmt];
1193 fb->fmt.width = itv->osd_rect.width; 1217 fb->fmt.width = itv->osd_rect.width;
1194 fb->fmt.height = itv->osd_rect.height; 1218 fb->fmt.height = itv->osd_rect.height;
1195 fb->base = (void *)itv->osd_video_pbase; 1219 fb->base = (void *)itv->osd_video_pbase;
1196 if (itv->osd_global_alpha_state)
1197 fb->flags |= V4L2_FBUF_FLAG_GLOBAL_ALPHA;
1198 if (itv->osd_local_alpha_state)
1199 fb->flags |= V4L2_FBUF_FLAG_LOCAL_ALPHA;
1200 if (itv->osd_chroma_key_state) 1220 if (itv->osd_chroma_key_state)
1201 fb->flags |= V4L2_FBUF_FLAG_CHROMAKEY; 1221 fb->flags |= V4L2_FBUF_FLAG_CHROMAKEY;
1222 if (itv->osd_global_alpha_state)
1223 fb->flags |= V4L2_FBUF_FLAG_GLOBAL_ALPHA;
1224 pixfmt &= 7;
1225 /* no local alpha for RGB565 or unknown formats */
1226 if (pixfmt == 1 || pixfmt > 4)
1227 break;
1228 /* 16-bit formats have inverted local alpha */
1229 if (pixfmt == 2 || pixfmt == 3)
1230 fb->capability |= V4L2_FBUF_CAP_LOCAL_INV_ALPHA;
1231 else
1232 fb->capability |= V4L2_FBUF_CAP_LOCAL_ALPHA;
1233 if (itv->osd_local_alpha_state) {
1234 /* 16-bit formats have inverted local alpha */
1235 if (pixfmt == 2 || pixfmt == 3)
1236 fb->flags |= V4L2_FBUF_FLAG_LOCAL_INV_ALPHA;
1237 else
1238 fb->flags |= V4L2_FBUF_FLAG_LOCAL_ALPHA;
1239 }
1202 break; 1240 break;
1203 } 1241 }
1204 1242
@@ -1208,7 +1246,8 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
1208 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT_OVERLAY)) 1246 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT_OVERLAY))
1209 return -EINVAL; 1247 return -EINVAL;
1210 itv->osd_global_alpha_state = (fb->flags & V4L2_FBUF_FLAG_GLOBAL_ALPHA) != 0; 1248 itv->osd_global_alpha_state = (fb->flags & V4L2_FBUF_FLAG_GLOBAL_ALPHA) != 0;
1211 itv->osd_local_alpha_state = (fb->flags & V4L2_FBUF_FLAG_LOCAL_ALPHA) != 0; 1249 itv->osd_local_alpha_state =
1250 (fb->flags & (V4L2_FBUF_FLAG_LOCAL_ALPHA|V4L2_FBUF_FLAG_LOCAL_INV_ALPHA)) != 0;
1212 itv->osd_chroma_key_state = (fb->flags & V4L2_FBUF_FLAG_CHROMAKEY) != 0; 1251 itv->osd_chroma_key_state = (fb->flags & V4L2_FBUF_FLAG_CHROMAKEY) != 0;
1213 ivtv_set_osd_alpha(itv); 1252 ivtv_set_osd_alpha(itv);
1214 break; 1253 break;
@@ -1226,7 +1265,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
1226 case VIDIOC_LOG_STATUS: 1265 case VIDIOC_LOG_STATUS:
1227 { 1266 {
1228 int has_output = itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT; 1267 int has_output = itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT;
1229 u32 data[CX2341X_MBOX_MAX_DATA];
1230 struct v4l2_input vidin; 1268 struct v4l2_input vidin;
1231 struct v4l2_audio audin; 1269 struct v4l2_audio audin;
1232 int i; 1270 int i;
@@ -1248,28 +1286,28 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
1248 struct v4l2_output vidout; 1286 struct v4l2_output vidout;
1249 struct v4l2_audioout audout; 1287 struct v4l2_audioout audout;
1250 int mode = itv->output_mode; 1288 int mode = itv->output_mode;
1251 static const char * const output_modes[] = { 1289 static const char * const output_modes[5] = {
1252 "None", 1290 "None",
1253 "MPEG Streaming", 1291 "MPEG Streaming",
1254 "YUV Streaming", 1292 "YUV Streaming",
1255 "YUV Frames", 1293 "YUV Frames",
1256 "Passthrough", 1294 "Passthrough",
1257 }; 1295 };
1258 static const char * const audio_modes[] = { 1296 static const char * const audio_modes[5] = {
1259 "Stereo", 1297 "Stereo",
1260 "Left", 1298 "Left",
1261 "Right", 1299 "Right",
1262 "Mono", 1300 "Mono",
1263 "Swapped" 1301 "Swapped"
1264 }; 1302 };
1265 static const char * const alpha_mode[] = { 1303 static const char * const alpha_mode[4] = {
1266 "None", 1304 "None",
1267 "Global", 1305 "Global",
1268 "Local", 1306 "Local",
1269 "Global and Local" 1307 "Global and Local"
1270 }; 1308 };
1271 static const char * const pixel_format[] = { 1309 static const char * const pixel_format[16] = {
1272 "RGB Indexed", 1310 "ARGB Indexed",
1273 "RGB 5:6:5", 1311 "RGB 5:6:5",
1274 "ARGB 1:5:5:5", 1312 "ARGB 1:5:5:5",
1275 "ARGB 1:4:4:4", 1313 "ARGB 1:4:4:4",
@@ -1277,7 +1315,7 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
1277 "5", 1315 "5",
1278 "6", 1316 "6",
1279 "7", 1317 "7",
1280 "YUV Indexed", 1318 "AYUV Indexed",
1281 "YUV 5:6:5", 1319 "YUV 5:6:5",
1282 "AYUV 1:5:5:5", 1320 "AYUV 1:5:5:5",
1283 "AYUV 1:4:4:4", 1321 "AYUV 1:4:4:4",