diff options
-rw-r--r-- | linux/drivers/media/video/cx88/cx88-blackbird.c | 14 | ||||
-rw-r--r-- | linux/drivers/media/video/cx88/cx88.h | 1 | ||||
-rw-r--r-- | linux/drivers/media/video/ivtv/ivtv-cards.h | 2 | ||||
-rw-r--r-- | linux/drivers/media/video/ivtv/ivtv-firmware.c | 4 | ||||
-rw-r--r-- | linux/drivers/media/video/ivtv/ivtv-ioctl.c | 72 | ||||
-rw-r--r-- | linux/include/linux/videodev2.h | 7 | ||||
-rw-r--r-- | v4l2-apps/util/v4l2-ctl.cpp | 380 | ||||
-rw-r--r-- | v4l2-apps/util/v4l2-dbg.cpp | 2 |
8 files changed, 302 insertions, 180 deletions
diff --git a/linux/drivers/media/video/cx88/cx88-blackbird.c b/linux/drivers/media/video/cx88/cx88-blackbird.c index 3eb6c8e28..9103d9567 100644 --- a/linux/drivers/media/video/cx88/cx88-blackbird.c +++ b/linux/drivers/media/video/cx88/cx88-blackbird.c @@ -59,8 +59,7 @@ MODULE_PARM_DESC(debug,"enable debug messages [blackbird]"); /* ------------------------------------------------------------------ */ -#define OLD_BLACKBIRD_FIRM_IMAGE_SIZE 262144 -#define BLACKBIRD_FIRM_IMAGE_SIZE 376836 +#define BLACKBIRD_FIRM_IMAGE_SIZE 376836 /* defines below are from ivtv-driver.h */ @@ -411,7 +410,7 @@ static int blackbird_find_mailbox(struct cx8802_dev *dev) u32 value; int i; - for (i = 0; i < dev->fw_size; i++) { + for (i = 0; i < BLACKBIRD_FIRM_IMAGE_SIZE; i++) { memory_read(dev->core, i, &value); if (value == signature[signaturecnt]) signaturecnt++; @@ -464,15 +463,12 @@ static int blackbird_load_firmware(struct cx8802_dev *dev) return -1; } - if ((firmware->size != BLACKBIRD_FIRM_IMAGE_SIZE) && - (firmware->size != OLD_BLACKBIRD_FIRM_IMAGE_SIZE)) { - dprintk(0, "ERROR: Firmware size mismatch (have %zd, expected %d or %d)\n", - firmware->size, BLACKBIRD_FIRM_IMAGE_SIZE, - OLD_BLACKBIRD_FIRM_IMAGE_SIZE); + if (firmware->size != BLACKBIRD_FIRM_IMAGE_SIZE) { + dprintk(0, "ERROR: Firmware size mismatch (have %zd, expected %d)\n", + firmware->size, BLACKBIRD_FIRM_IMAGE_SIZE); release_firmware(firmware); return -1; } - dev->fw_size = firmware->size; if (0 != memcmp(firmware->data, magic, 8)) { dprintk(0, "ERROR: Firmware magic mismatch, wrong file?\n"); diff --git a/linux/drivers/media/video/cx88/cx88.h b/linux/drivers/media/video/cx88/cx88.h index 144c40410..63371fa9b 100644 --- a/linux/drivers/media/video/cx88/cx88.h +++ b/linux/drivers/media/video/cx88/cx88.h @@ -495,7 +495,6 @@ struct cx8802_dev { u32 mailbox; int width; int height; - int fw_size; #if defined(CONFIG_VIDEO_BUF_DVB) || defined(CONFIG_VIDEO_BUF_DVB_MODULE) /* for dvb only */ diff --git a/linux/drivers/media/video/ivtv/ivtv-cards.h b/linux/drivers/media/video/ivtv/ivtv-cards.h index 15012f88b..91e9e90c1 100644 --- a/linux/drivers/media/video/ivtv/ivtv-cards.h +++ b/linux/drivers/media/video/ivtv/ivtv-cards.h @@ -86,7 +86,7 @@ V4L2_CAP_AUDIO | V4L2_CAP_READWRITE | V4L2_CAP_VBI_CAPTURE | \ V4L2_CAP_SLICED_VBI_CAPTURE) #define IVTV_CAP_DECODER (V4L2_CAP_VBI_OUTPUT | V4L2_CAP_VIDEO_OUTPUT | \ - V4L2_CAP_SLICED_VBI_OUTPUT | V4L2_CAP_VIDEO_OUTPUT_OVERLAY | V4L2_CAP_VIDEO_OUTPUT_POS) + V4L2_CAP_SLICED_VBI_OUTPUT | V4L2_CAP_VIDEO_OUTPUT_OVERLAY) struct ivtv_card_video_input { u8 video_type; /* video input type */ diff --git a/linux/drivers/media/video/ivtv/ivtv-firmware.c b/linux/drivers/media/video/ivtv/ivtv-firmware.c index d4c910b78..2b6208a6a 100644 --- a/linux/drivers/media/video/ivtv/ivtv-firmware.c +++ b/linux/drivers/media/video/ivtv/ivtv-firmware.c @@ -56,9 +56,7 @@ retry: volatile u32 __iomem *dst = (volatile u32 __iomem *)mem; const u32 *src = (const u32 *)fw->data; - /* temporarily allow 256 KB encoding firmwares as well for - compatibility with blackbird cards */ - if (fw->size != size && fw->size != 256 * 1024) { + if (fw->size != size) { /* Due to race conditions in firmware loading (esp. with udev <0.95) the wrong file was sometimes loaded. So we check filesizes to see if at least the right-sized file was loaded. If not, then we diff --git a/linux/drivers/media/video/ivtv/ivtv-ioctl.c b/linux/drivers/media/video/ivtv/ivtv-ioctl.c index 5b799f016..8e7bd439c 100644 --- a/linux/drivers/media/video/ivtv/ivtv-ioctl.c +++ b/linux/drivers/media/video/ivtv/ivtv-ioctl.c @@ -362,12 +362,6 @@ static int ivtv_get_fmt(struct ivtv *itv, int streamtype, struct v4l2_format *fm case V4L2_BUF_TYPE_VIDEO_OUTPUT: if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) return -EINVAL; -#if 0 - /* Temporarily removed until a better solution is in place that does not - break the ABI */ - fmt->fmt.pix.left = itv->main_rect.left; - fmt->fmt.pix.top = itv->main_rect.top; -#endif fmt->fmt.pix.width = itv->main_rect.width; fmt->fmt.pix.height = itv->main_rect.height; fmt->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; @@ -406,12 +400,6 @@ static int ivtv_get_fmt(struct ivtv *itv, int streamtype, struct v4l2_format *fm break; case V4L2_BUF_TYPE_VIDEO_CAPTURE: -#if 0 - /* Temporarily removed until a better solution is in place that does not - break the ABI */ - fmt->fmt.pix.left = 0; - fmt->fmt.pix.top = 0; -#endif fmt->fmt.pix.width = itv->params.width; fmt->fmt.pix.height = itv->params.height; fmt->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; @@ -506,26 +494,13 @@ static int ivtv_try_or_set_fmt(struct ivtv *itv, int streamtype, if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) return -EINVAL; field = fmt->fmt.pix.field; -#if 0 - /* Temporarily removed until a better solution is in place that does not - break the ABI */ - r.top = fmt->fmt.pix.top; - r.left = fmt->fmt.pix.left; -#else r.top = 0; r.left = 0; -#endif r.width = fmt->fmt.pix.width; r.height = fmt->fmt.pix.height; ivtv_get_fmt(itv, streamtype, fmt); if (itv->output_mode != OUT_UDMA_YUV) { /* TODO: would setting the rect also be valid for this mode? */ -#if 0 - /* Temporarily removed until a better solution is in place that does not - break the ABI */ - fmt->fmt.pix.top = r.top; - fmt->fmt.pix.left = r.left; -#endif fmt->fmt.pix.width = r.width; fmt->fmt.pix.height = r.height; } @@ -557,11 +532,6 @@ static int ivtv_try_or_set_fmt(struct ivtv *itv, int streamtype, itv->yuv_info.yuv_forced_update = 1; return 0; } - if (!ivtv_vapi(itv, CX2341X_OSD_SET_FRAMEBUFFER_WINDOW, 4, - r.width, r.height, r.left, r.top)) - itv->main_rect = r; - else - return -EINVAL; } return 0; } @@ -830,9 +800,39 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void return ivtv_get_fmt(itv, id->type, fmt); } + case VIDIOC_CROPCAP: { + struct v4l2_cropcap *cropcap = arg; + + if (cropcap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && + cropcap->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) + return -EINVAL; + cropcap->bounds.top = cropcap->bounds.left = 0; + cropcap->bounds.width = 720; + if (cropcap->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { + cropcap->bounds.height = itv->is_50hz ? 576 : 480; + cropcap->pixelaspect.numerator = itv->is_50hz ? 59 : 10; + cropcap->pixelaspect.denominator = itv->is_50hz ? 54 : 11; + } else { + cropcap->bounds.height = itv->is_out_50hz ? 576 : 480; + cropcap->pixelaspect.numerator = itv->is_out_50hz ? 59 : 10; + cropcap->pixelaspect.denominator = itv->is_out_50hz ? 54 : 11; + } + cropcap->defrect = cropcap->bounds; + return 0; + } + case VIDIOC_S_CROP: { struct v4l2_crop *crop = arg; + if (crop->type == V4L2_BUF_TYPE_VIDEO_OUTPUT && + (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) { + if (!ivtv_vapi(itv, CX2341X_OSD_SET_FRAMEBUFFER_WINDOW, 4, + crop->c.width, crop->c.height, crop->c.left, crop->c.top)) { + itv->main_rect = crop->c; + return 0; + } + return -EINVAL; + } if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) return -EINVAL; return itv->video_dec_func(itv, VIDIOC_S_CROP, arg); @@ -841,6 +841,11 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void case VIDIOC_G_CROP: { struct v4l2_crop *crop = arg; + if (crop->type == V4L2_BUF_TYPE_VIDEO_OUTPUT && + (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) { + crop->c = itv->main_rect; + return 0; + } if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) return -EINVAL; return itv->video_dec_func(itv, VIDIOC_G_CROP, arg); @@ -1172,12 +1177,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void fb->fmt.pixelformat = itv->osd_pixelformat; fb->fmt.width = itv->osd_rect.width; fb->fmt.height = itv->osd_rect.height; -#if 0 - /* Temporarily removed until a better solution is in place that does not - break the ABI */ - fb->fmt.left = itv->osd_rect.left; - fb->fmt.top = itv->osd_rect.top; -#endif fb->base = (void *)itv->osd_video_pbase; if (itv->osd_global_alpha_state) fb->flags |= V4L2_FBUF_FLAG_GLOBAL_ALPHA; @@ -1498,6 +1497,7 @@ static int ivtv_v4l2_do_ioctl(struct inode *inode, struct file *filp, case VIDIOC_S_FMT: case VIDIOC_TRY_FMT: case VIDIOC_ENUM_FMT: + case VIDIOC_CROPCAP: case VIDIOC_G_CROP: case VIDIOC_S_CROP: case VIDIOC_G_FREQUENCY: diff --git a/linux/include/linux/videodev2.h b/linux/include/linux/videodev2.h index 8e46a2029..dc4fb4588 100644 --- a/linux/include/linux/videodev2.h +++ b/linux/include/linux/videodev2.h @@ -243,8 +243,7 @@ struct v4l2_capability #define V4L2_CAP_SLICED_VBI_CAPTURE 0x00000040 /* Is a sliced VBI capture device */ #define V4L2_CAP_SLICED_VBI_OUTPUT 0x00000080 /* Is a sliced VBI output device */ #define V4L2_CAP_RDS_CAPTURE 0x00000100 /* RDS data capture */ -#define V4L2_CAP_VIDEO_OUTPUT_POS 0x00000200 /* Video output can have x,y coords */ -#define V4L2_CAP_VIDEO_OUTPUT_OVERLAY 0x00000400 /* Can do video output overlay */ +#define V4L2_CAP_VIDEO_OUTPUT_OVERLAY 0x00000200 /* Can do video output overlay */ #define V4L2_CAP_TUNER 0x00010000 /* has a tuner */ #define V4L2_CAP_AUDIO 0x00020000 /* has audio support */ @@ -616,12 +615,16 @@ struct v4l2_framebuffer #define V4L2_FBUF_CAP_BITMAP_CLIPPING 0x0008 #define V4L2_FBUF_CAP_LOCAL_ALPHA 0x0010 #define V4L2_FBUF_CAP_GLOBAL_ALPHA 0x0020 +#define V4L2_FBUF_CAP_LOCAL_INV_ALPHA 0x0040 +#define V4L2_FBUF_CAP_GLOBAL_INV_ALPHA 0x0080 /* Flags for the 'flags' field. */ #define V4L2_FBUF_FLAG_PRIMARY 0x0001 #define V4L2_FBUF_FLAG_OVERLAY 0x0002 #define V4L2_FBUF_FLAG_CHROMAKEY 0x0004 #define V4L2_FBUF_FLAG_LOCAL_ALPHA 0x0008 #define V4L2_FBUF_FLAG_GLOBAL_ALPHA 0x0010 +#define V4L2_FBUF_FLAG_LOCAL_INV_ALPHA 0x0020 +#define V4L2_FBUF_FLAG_GLOBAL_INV_ALPHA 0x0040 struct v4l2_clip { diff --git a/v4l2-apps/util/v4l2-ctl.cpp b/v4l2-apps/util/v4l2-ctl.cpp index 35d9f466b..cc6819971 100644 --- a/v4l2-apps/util/v4l2-ctl.cpp +++ b/v4l2-apps/util/v4l2-ctl.cpp @@ -99,14 +99,24 @@ enum Option { OptGetSlicedVbiOutCap, OptGetFBuf, OptSetFBuf, - OptGetVideoCrop, - OptSetVideoCrop, + OptGetCrop, + OptSetCrop, + OptGetOutputCrop, + OptSetOutputCrop, + OptGetOverlayCrop, + OptSetOverlayCrop, + OptGetOutputOverlayCrop, + OptSetOutputOverlayCrop, OptGetAudioInput, OptSetAudioInput, OptGetAudioOutput, OptSetAudioOutput, OptListAudioOutputs, OptListAudioInputs, + OptGetCropCap, + OptGetOutputCropCap, + OptGetOverlayCropCap, + OptGetOutputOverlayCropCap, OptLast = 256 }; @@ -143,12 +153,10 @@ static const flag_def service_def[] = { }; /* fmts specified */ -#define FmtTop (1L<<0) -#define FmtLeft (1L<<1) -#define FmtWidth (1L<<2) -#define FmtHeight (1L<<3) -#define FmtChromaKey (1L<<4) -#define FmtGlobalAlpha (1L<<5) +#define FmtWidth (1L<<0) +#define FmtHeight (1L<<1) +#define FmtChromaKey (1L<<2) +#define FmtGlobalAlpha (1L<<3) /* crop specified */ #define CropWidth (1L<<0) @@ -206,8 +214,18 @@ static struct option long_options[] = { {"get-sliced-vbi-out-cap", no_argument, 0, OptGetSlicedVbiOutCap}, {"get-fbuf", no_argument, 0, OptGetFBuf}, {"set-fbuf", required_argument, 0, OptSetFBuf}, - {"get-crop-video", no_argument, 0, OptGetVideoCrop}, - {"set-crop-video", required_argument, 0, OptSetVideoCrop}, + {"get-cropcap", no_argument, 0, OptGetCropCap}, + {"get-crop", no_argument, 0, OptGetCrop}, + {"set-crop", required_argument, 0, OptSetCrop}, + {"get-cropcap-output", no_argument, 0, OptGetOutputCropCap}, + {"get-crop-output", no_argument, 0, OptGetOutputCrop}, + {"set-crop-output", required_argument, 0, OptSetOutputCrop}, + {"get-cropcap-overlay", no_argument, 0, OptGetOverlayCropCap}, + {"get-crop-overlay", no_argument, 0, OptGetOverlayCrop}, + {"set-crop-overlay", required_argument, 0, OptSetOverlayCrop}, + {"get-cropcap-output-overlay", no_argument, 0, OptGetOutputOverlayCropCap}, + {"get-crop-output-overlay", no_argument, 0, OptGetOutputOverlayCrop}, + {"set-crop-output-overlay", required_argument, 0, OptSetOutputOverlayCrop}, {0, 0, 0, 0} }; @@ -275,7 +293,7 @@ static void usage(void) printf("Uncommon options:\n"); printf(" --get-fmt-video-out\n"); printf(" query the video output format [VIDIOC_G_FMT]\n"); - printf(" --set-fmt-video-out=left=<x>,top=<y>,width=<w>,height=<h>\n"); + printf(" --set-fmt-video-out=width=<w>,height=<h>\n"); printf(" set the video output format [VIDIOC_S_FMT]\n"); printf(" --get-fmt-overlay\n"); printf(" query the video overlay format [VIDIOC_G_FMT]\n"); @@ -300,12 +318,29 @@ static void usage(void) printf(" --get-fmt-vbi query the VBI capture format [VIDIOC_G_FMT]\n"); printf(" --get-fmt-vbi-out query the VBI output format [VIDIOC_G_FMT]\n"); printf(" --get-fbuf query the overlay framebuffer data [VIDIOC_G_FBUF]\n"); - printf(" --set-fbuf=chromakey=<0/1>,global_alpha=<0/1>,local_alpha=<0/1>\n"); + printf(" --set-fbuf=chromakey=<0/1>,global_alpha=<0/1>,local_alpha=<0/1>,\n"); + printf(" global_inv_alpha=<0/1>,local_inv_alpha=<0/1>\n"); printf(" set the overlay framebuffer [VIDIOC_S_FBUF]\n"); - printf(" --get-crop-video\n"); - printf(" query the video capture crop window [VIDIOC_G_CROP]\n"); - printf(" --set-crop-video=top=<x>,left=<y>,width=<w>,height=<h>\n"); + printf(" --get-cropcap query the crop capabilities [VIDIOC_CROPCAP]\n"); + printf(" --get-crop query the video capture crop window [VIDIOC_G_CROP]\n"); + printf(" --set-crop=top=<x>,left=<y>,width=<w>,height=<h>\n"); printf(" set the video capture crop window [VIDIOC_S_CROP]\n"); + printf(" --get-cropcap-output\n"); + printf(" query the crop capabilities for video output [VIDIOC_CROPCAP]\n"); + printf(" --get-crop-output query the video output crop window [VIDIOC_G_CROP]\n"); + printf(" --set-crop-output=top=<x>,left=<y>,width=<w>,height=<h>\n"); + printf(" set the video output crop window [VIDIOC_S_CROP]\n"); + printf(" --get-cropcap-overlay\n"); + printf(" query the crop capabilities for video overlay [VIDIOC_CROPCAP]\n"); + printf(" --get-crop-overlay query the video overlay crop window [VIDIOC_G_CROP]\n"); + printf(" --set-crop-overlay=top=<x>,left=<y>,width=<w>,height=<h>\n"); + printf(" set the video overlay crop window [VIDIOC_S_CROP]\n"); + printf(" --get-cropcap-output-overlay\n"); + printf(" query the crop capabilities for video output overlays [VIDIOC_CROPCAP]\n"); + printf(" --get-crop-output-overlay\n"); + printf(" query the video output overlay crop window [VIDIOC_G_CROP]\n"); + printf(" --set-crop-output-overlay=top=<x>,left=<y>,width=<w>,height=<h>\n"); + printf(" set the video output overlay crop window [VIDIOC_S_CROP]\n"); printf(" --get-audio-input query the audio input [VIDIOC_G_AUDIO]\n"); printf(" --set-audio-input=<num>\n"); printf(" set the audio input to <num> [VIDIOC_S_AUDIO]\n"); @@ -608,18 +643,22 @@ static std::string fbufcap2s(unsigned cap) std::string s; if (cap & V4L2_FBUF_CAP_EXTERNOVERLAY) - s += "\t\tExtern Overlay\n"; + s += "\t\t\tExtern Overlay\n"; if (cap & V4L2_FBUF_CAP_CHROMAKEY) - s += "\t\tChromakey\n"; + s += "\t\t\tChromakey\n"; if (cap & V4L2_FBUF_CAP_GLOBAL_ALPHA) - s += "\t\tGlobal Alpha\n"; + s += "\t\t\tGlobal Alpha\n"; if (cap & V4L2_FBUF_CAP_LOCAL_ALPHA) - s += "\t\tLocal Alpha\n"; + s += "\t\t\tLocal Alpha\n"; + if (cap & V4L2_FBUF_CAP_GLOBAL_INV_ALPHA) + s += "\t\t\tGlobal Inverted Alpha\n"; + if (cap & V4L2_FBUF_CAP_LOCAL_INV_ALPHA) + s += "\t\t\tLocal Inverted Alpha\n"; if (cap & V4L2_FBUF_CAP_LIST_CLIPPING) - s += "\t\tClipping List\n"; + s += "\t\t\tClipping List\n"; if (cap & V4L2_FBUF_CAP_BITMAP_CLIPPING) - s += "\t\tClipping Bitmap\n"; - if (s.empty()) s += "\t\t\n"; + s += "\t\t\tClipping Bitmap\n"; + if (s.empty()) s += "\t\t\t\n"; return s; } @@ -628,16 +667,20 @@ static std::string fbufflags2s(unsigned fl) std::string s; if (fl & V4L2_FBUF_FLAG_PRIMARY) - s += "\t\tPrimary Graphics Surface\n"; + s += "\t\t\tPrimary Graphics Surface\n"; if (fl & V4L2_FBUF_FLAG_OVERLAY) - s += "\t\tOverlay Matches Capture/Output Size\n"; + s += "\t\t\tOverlay Matches Capture/Output Size\n"; if (fl & V4L2_FBUF_FLAG_CHROMAKEY) - s += "\t\tChromakey\n"; + s += "\t\t\tChromakey\n"; if (fl & V4L2_FBUF_FLAG_GLOBAL_ALPHA) - s += "\t\tGlobal Alpha\n"; + s += "\t\t\tGlobal Alpha\n"; if (fl & V4L2_FBUF_FLAG_LOCAL_ALPHA) - s += "\t\tLocal Alpha\n"; - if (s.empty()) s += "\t\t\n"; + s += "\t\t\tLocal Alpha\n"; + if (fl & V4L2_FBUF_FLAG_GLOBAL_INV_ALPHA) + s += "\t\t\tGlobal Inverted Alpha\n"; + if (fl & V4L2_FBUF_FLAG_LOCAL_INV_ALPHA) + s += "\t\t\tLocal Inverted Alpha\n"; + if (s.empty()) s += "\t\t\t\n"; return s; } @@ -645,19 +688,20 @@ static void printfbuf(const struct v4l2_framebuffer &fb) { int is_ext = fb.capability & V4L2_FBUF_CAP_EXTERNOVERLAY; - printf("Capability : %s", fbufcap2s(fb.capability).c_str() + 2); - printf("Flags : %s", fbufflags2s(fb.flags).c_str() + 2); + printf("Framebuffer Format:\n"); + printf("\tCapability : %s", fbufcap2s(fb.capability).c_str() + 3); + printf("\tFlags : %s", fbufflags2s(fb.flags).c_str() + 3); if (fb.base) - printf("Base : 0x%p\n", fb.base); - printf("Width : %d\n", fb.fmt.width); - printf("Height : %d\n", fb.fmt.height); - printf("Pixel Format : %s\n", fcc2s(fb.fmt.pixelformat).c_str()); + printf("\tBase : 0x%p\n", fb.base); + printf("\tWidth : %d\n", fb.fmt.width); + printf("\tHeight : %d\n", fb.fmt.height); + printf("\tPixel Format : %s\n", fcc2s(fb.fmt.pixelformat).c_str()); if (!is_ext) { - printf("Bytes per Line: %d\n", fb.fmt.bytesperline); - printf("Size image : %d\n", fb.fmt.sizeimage); - printf("Colorspace : %s\n", colorspace2s(fb.fmt.colorspace).c_str()); + printf("\tBytes per Line: %d\n", fb.fmt.bytesperline); + printf("\tSize image : %d\n", fb.fmt.sizeimage); + printf("\tColorspace : %s\n", colorspace2s(fb.fmt.colorspace).c_str()); if (fb.fmt.priv) - printf("Custom Info : %08x\n", fb.fmt.priv); + printf("\tCustom Info : %08x\n", fb.fmt.priv); } } @@ -667,6 +711,16 @@ static void printcrop(const struct v4l2_crop &crop) crop.c.left, crop.c.top, crop.c.width, crop.c.height); } +static void printcropcap(const struct v4l2_cropcap &cropcap) +{ + printf("Crop Capability %s:\n", buftype2s(cropcap.type).c_str()); + printf("\tBounds : Left %d, Top %d, Width %d, Height %d\n", + cropcap.bounds.left, cropcap.bounds.top, cropcap.bounds.width, cropcap.bounds.height); + printf("\tDefault : Left %d, Top %d, Width %d, Height %d\n", + cropcap.defrect.left, cropcap.defrect.top, cropcap.defrect.width, cropcap.defrect.height); + printf("\tPixel Aspect: %u/%u\n", cropcap.pixelaspect.numerator, cropcap.pixelaspect.denominator); +} + static int printfmt(struct v4l2_format vfmt) { const flag_def vbi_def[] = { @@ -674,32 +728,22 @@ static int printfmt(struct v4l2_format vfmt) { V4L2_VBI_INTERLACED, "interlaced" }, { 0, NULL } }; - printf("Format:\n"); + printf("Format %s:\n", buftype2s(vfmt.type).c_str()); switch (vfmt.type) { case V4L2_BUF_TYPE_VIDEO_CAPTURE: case V4L2_BUF_TYPE_VIDEO_OUTPUT: - printf("\tType : %s\n", buftype2s(vfmt.type).c_str()); printf("\tWidth/Height : %u/%u\n", vfmt.fmt.pix.width, vfmt.fmt.pix.height); printf("\tPixel Format : %s\n", fcc2s(vfmt.fmt.pix.pixelformat).c_str()); printf("\tField : %s\n", field2s(vfmt.fmt.pix.field).c_str()); printf("\tBytes per Line: %u\n", vfmt.fmt.pix.bytesperline); printf("\tSize Image : %u\n", vfmt.fmt.pix.sizeimage); printf("\tColorspace : %s\n", colorspace2s(vfmt.fmt.pix.colorspace).c_str()); -#if 0 - /* Comment out until ABI breakage is resolved */ - if (vfmt.type == V4L2_BUF_TYPE_VIDEO_OUTPUT && - (capabilities & V4L2_CAP_VIDEO_OUTPUT_POS)) { - printf("\tLeft/Top : %d/%d\n", - vfmt.fmt.pix.left, vfmt.fmt.pix.top); - } -#endif if (vfmt.fmt.pix.priv) printf("\tCustom Info : %08x\n", vfmt.fmt.pix.priv); break; case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: case V4L2_BUF_TYPE_VIDEO_OVERLAY: - printf("\tType : %s\n", buftype2s(vfmt.type).c_str()); printf("\tLeft/Top : %d/%d\n", vfmt.fmt.win.w.left, vfmt.fmt.win.w.top); printf("\tWidth/Height: %d/%d\n", @@ -712,7 +756,6 @@ static int printfmt(struct v4l2_format vfmt) break; case V4L2_BUF_TYPE_VBI_CAPTURE: case V4L2_BUF_TYPE_VBI_OUTPUT: - printf("\tType : %s\n", buftype2s(vfmt.type).c_str()); printf("\tSampling Rate : %u Hz\n", vfmt.fmt.vbi.sampling_rate); printf("\tOffset : %u samples (%g secs after leading edge)\n", vfmt.fmt.vbi.offset, @@ -728,7 +771,6 @@ static int printfmt(struct v4l2_format vfmt) break; case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: - printf("\tType : %s\n", buftype2s(vfmt.type).c_str()); printf("\tService Set : %s\n", flags2s(vfmt.fmt.sliced.service_set, service_def).c_str()); for (int i = 0; i < 24; i++) { @@ -739,10 +781,8 @@ static int printfmt(struct v4l2_format vfmt) printf("\tI/O Size : %u\n", vfmt.fmt.sliced.io_size); break; case V4L2_BUF_TYPE_PRIVATE: - printf("\tType: %s\n", buftype2s(vfmt.type).c_str()); break; default: - printf("\tType: %s\n", buftype2s(vfmt.type).c_str()); return -1; } return 0; @@ -860,8 +900,6 @@ static std::string cap2s(unsigned cap) s += "\t\tSliced VBI Output\n"; if (cap & V4L2_CAP_RDS_CAPTURE) s += "\t\tRDS Capture\n"; - if (cap & V4L2_CAP_VIDEO_OUTPUT_POS) - s += "\t\tVideo Output Position\n"; if (cap & V4L2_CAP_TUNER) s += "\t\tTuner\n"; if (cap & V4L2_CAP_AUDIO) @@ -1031,6 +1069,62 @@ static void print_std(const char *prefix, const char *stds[], unsigned long long printf("\n"); } +static void do_crop(int fd, unsigned int set_crop, struct v4l2_rect &vcrop, v4l2_buf_type type) +{ + struct v4l2_crop in_crop; + + in_crop.type = type; + if (ioctl(fd, VIDIOC_G_CROP, &in_crop) < 0) + fprintf(stderr, "ioctl: VIDIOC_G_CROP failed\n"); + else { + if (set_crop & CropWidth) + in_crop.c.width = vcrop.width; + if (set_crop & CropHeight) + in_crop.c.height = vcrop.height; + if (set_crop & CropLeft) + in_crop.c.left = vcrop.left; + if (set_crop & CropTop) + in_crop.c.top = vcrop.top; + if (ioctl(fd, VIDIOC_S_CROP, &in_crop) < 0) + fprintf(stderr, "ioctl: VIDIOC_S_CROP failed\n"); + } +} + +static void parse_crop(char *optarg, unsigned int &set_crop, v4l2_rect &vcrop) +{ + char *value; + char *subs = optarg; + + while (*subs != '\0') { + static char *const subopts[] = { + "left", + "top", + "width", + "height", + NULL + }; + + switch (parse_subopt(&subs, subopts, &value)) { + case 0: + vcrop.left = strtol(value, 0L, 0); + set_crop |= CropLeft; + break; + case 1: + vcrop.top = strtol(value, 0L, 0); + set_crop |= CropTop; + break; + case 2: + vcrop.width = strtol(value, 0L, 0); + set_crop |= CropWidth; + break; + case 3: + vcrop.height = strtol(value, 0L, 0); + set_crop |= CropHeight; + break; + } + } +} + int main(int argc, char **argv) { char *value, *subs; @@ -1042,6 +1136,9 @@ int main(int argc, char **argv) unsigned int set_fmts = 0; unsigned int set_fmts_out = 0; unsigned int set_crop = 0; + unsigned int set_crop_out = 0; + unsigned int set_crop_overlay = 0; + unsigned int set_crop_out_overlay = 0; unsigned int set_fbuf = 0; unsigned int set_overlay_fmt_out = 0; @@ -1064,6 +1161,9 @@ int main(int argc, char **argv) struct v4l2_audio vaudio; /* list audio inputs */ struct v4l2_audioout vaudout; /* audio outputs */ struct v4l2_rect vcrop; /* crop rect */ + struct v4l2_rect vcrop_out; /* crop rect */ + struct v4l2_rect vcrop_overlay; /* crop rect */ + struct v4l2_rect vcrop_out_overlay; /* crop rect */ struct v4l2_framebuffer fbuf; /* fbuf */ int input; /* set_input/get_input */ int output; /* set_output/get_output */ @@ -1088,6 +1188,9 @@ int main(int argc, char **argv) memset(&vaudio, 0, sizeof(vaudio)); memset(&vaudout, 0, sizeof(vaudout)); memset(&vcrop, 0, sizeof(vcrop)); + memset(&vcrop_out, 0, sizeof(vcrop_out)); + memset(&vcrop_overlay, 0, sizeof(vcrop_overlay)); + memset(&vcrop_out_overlay, 0, sizeof(vcrop_out_overlay)); memset(&vf, 0, sizeof(vf)); memset(&vs, 0, sizeof(vs)); memset(&fbuf, 0, sizeof(fbuf)); @@ -1150,30 +1253,17 @@ int main(int argc, char **argv) subs = optarg; while (*subs != '\0') { static char *const subopts[] = { - "top", - "left", "width", "height", NULL }; switch (parse_subopt(&subs, subopts, &value)) { -#if 0 - /* Comment out until ABI breakage is resolved */ case 0: - vfmt_out.fmt.pix.top = strtol(value, 0L, 0); - set_fmts_out |= FmtTop; - break; - case 1: - vfmt_out.fmt.pix.left = strtol(value, 0L, 0); - set_fmts_out |= FmtLeft; - break; -#endif - case 2: vfmt_out.fmt.pix.width = strtol(value, 0L, 0); set_fmts_out |= FmtWidth; break; - case 3: + case 1: vfmt_out.fmt.pix.height = strtol(value, 0L, 0); set_fmts_out |= FmtHeight; break; @@ -1208,6 +1298,8 @@ int main(int argc, char **argv) "chromakey", "global_alpha", "local_alpha", + "global_inv_alpha", + "local_inv_alpha", NULL }; @@ -1224,40 +1316,29 @@ int main(int argc, char **argv) fbuf.flags |= strtol(value, 0L, 0) ? V4L2_FBUF_FLAG_LOCAL_ALPHA : 0; set_fbuf |= V4L2_FBUF_FLAG_LOCAL_ALPHA; break; - } - } - break; - case OptSetVideoCrop: - subs = optarg; - while (*subs != '\0') { - static char *const subopts[] = { - "left", - "top", - "width", - "height", - NULL - }; - - switch (parse_subopt(&subs, subopts, &value)) { - case 0: - vcrop.left = strtol(value, 0L, 0); - set_crop |= CropLeft; - break; - case 1: - vcrop.top = strtol(value, 0L, 0); - set_crop |= CropTop; - break; - case 2: - vcrop.width = strtol(value, 0L, 0); - set_crop |= CropWidth; - break; case 3: - vcrop.height = strtol(value, 0L, 0); - set_crop |= CropHeight; + fbuf.flags |= strtol(value, 0L, 0) ? V4L2_FBUF_FLAG_GLOBAL_INV_ALPHA : 0; + set_fbuf |= V4L2_FBUF_FLAG_GLOBAL_INV_ALPHA; + break; + case 4: + fbuf.flags |= strtol(value, 0L, 0) ? V4L2_FBUF_FLAG_LOCAL_INV_ALPHA : 0; + set_fbuf |= V4L2_FBUF_FLAG_LOCAL_INV_ALPHA; break; } } break; + case OptSetCrop: + parse_crop(optarg, set_crop, vcrop); + break; + case OptSetOutputCrop: + parse_crop(optarg, set_crop_out, vcrop_out); + break; + case OptSetOverlayCrop: + parse_crop(optarg, set_crop_overlay, vcrop_overlay); + break; + case OptSetOutputOverlayCrop: + parse_crop(optarg, set_crop_out_overlay, vcrop_out_overlay); + break; case OptSetInput: input = strtol(optarg, 0L, 0); break; @@ -1434,7 +1515,7 @@ int main(int argc, char **argv) if (options[OptAll]) { options[OptGetVideoFormat] = 1; - options[OptGetVideoCrop] = 1; + options[OptGetCrop] = 1; options[OptGetVideoOutFormat] = 1; options[OptGetDriverInfo] = 1; options[OptGetInput] = 1; @@ -1451,12 +1532,14 @@ int main(int argc, char **argv) options[OptGetSlicedVbiFormat] = 1; options[OptGetSlicedVbiOutFormat] = 1; options[OptGetFBuf] = 1; + options[OptGetCropCap] = 1; + options[OptGetOutputCropCap] = 1; } /* Information Opts */ if (options[OptGetDriverInfo]) { - printf("Driver info:\n"); + printf("Driver Info:\n"); printf("\tDriver name : %s\n", vcap.driver); printf("\tCard type : %s\n", vcap.card); printf("\tBus info : %s\n", vcap.bus_info); @@ -1558,13 +1641,6 @@ int main(int argc, char **argv) if (ioctl(fd, VIDIOC_G_FMT, &in_vfmt) < 0) fprintf(stderr, "ioctl: VIDIOC_G_FMT failed\n"); else { -#if 0 - /* Comment out until ABI breakage is resolved */ - if (set_fmts_out & FmtTop) - in_vfmt.fmt.pix.top = vfmt_out.fmt.pix.top; - if (set_fmts_out & FmtLeft) - in_vfmt.fmt.pix.left = vfmt_out.fmt.pix.left; -#endif if (set_fmts_out & FmtWidth) in_vfmt.fmt.pix.width = vfmt_out.fmt.pix.width; if (set_fmts_out & FmtHeight) @@ -1626,24 +1702,20 @@ int main(int argc, char **argv) } } - if (options[OptSetVideoCrop]) { - struct v4l2_crop in_crop; + if (options[OptSetCrop]) { + do_crop(fd, set_crop, vcrop, V4L2_BUF_TYPE_VIDEO_CAPTURE); + } - in_crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - if (ioctl(fd, VIDIOC_G_CROP, &in_crop) < 0) - fprintf(stderr, "ioctl: VIDIOC_G_CROP failed\n"); - else { - if (set_crop & CropWidth) - in_crop.c.width = vcrop.width; - if (set_crop & CropHeight) - in_crop.c.height = vcrop.height; - if (set_crop & CropLeft) - in_crop.c.left = vcrop.left; - if (set_crop & CropTop) - in_crop.c.top = vcrop.top; - if (ioctl(fd, VIDIOC_S_CROP, &in_crop) < 0) - fprintf(stderr, "ioctl: VIDIOC_S_CROP failed\n"); - } + if (options[OptSetOutputCrop]) { + do_crop(fd, set_crop_out, vcrop_out, V4L2_BUF_TYPE_VIDEO_OUTPUT); + } + + if (options[OptSetOverlayCrop]) { + do_crop(fd, set_crop_overlay, vcrop_overlay, V4L2_BUF_TYPE_VIDEO_OVERLAY); + } + + if (options[OptSetOutputOverlayCrop]) { + do_crop(fd, set_crop_out_overlay, vcrop_out_overlay, V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY); } if (options[OptSetCtrl] && !set_ctrls.empty()) { @@ -1765,7 +1837,39 @@ int main(int argc, char **argv) printfbuf(fb); } - if (options[OptGetVideoCrop]) { + if (options[OptGetCropCap]) { + struct v4l2_cropcap cropcap; + + cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + if (doioctl(fd, VIDIOC_CROPCAP, &cropcap, "VIDIOC_CROPCAP") == 0) + printcropcap(cropcap); + } + + if (options[OptGetOutputCropCap]) { + struct v4l2_cropcap cropcap; + + cropcap.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; + if (doioctl(fd, VIDIOC_CROPCAP, &cropcap, "VIDIOC_CROPCAP") == 0) + printcropcap(cropcap); + } + + if (options[OptGetOverlayCropCap]) { + struct v4l2_cropcap cropcap; + + cropcap.type = V4L2_BUF_TYPE_VIDEO_OVERLAY; + if (doioctl(fd, VIDIOC_CROPCAP, &cropcap, "VIDIOC_CROPCAP") == 0) + printcropcap(cropcap); + } + + if (options[OptGetOutputOverlayCropCap]) { + struct v4l2_cropcap cropcap; + + cropcap.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY; + if (doioctl(fd, VIDIOC_CROPCAP, &cropcap, "VIDIOC_CROPCAP") == 0) + printcropcap(cropcap); + } + + if (options[OptGetCrop]) { struct v4l2_crop crop; crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; @@ -1773,6 +1877,30 @@ int main(int argc, char **argv) printcrop(crop); } + if (options[OptGetOutputCrop]) { + struct v4l2_crop crop; + + crop.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; + if (doioctl(fd, VIDIOC_G_CROP, &crop, "VIDIOC_G_CROP") == 0) + printcrop(crop); + } + + if (options[OptGetOverlayCrop]) { + struct v4l2_crop crop; + + crop.type = V4L2_BUF_TYPE_VIDEO_OVERLAY; + if (doioctl(fd, VIDIOC_G_CROP, &crop, "VIDIOC_G_CROP") == 0) + printcrop(crop); + } + + if (options[OptGetOutputOverlayCrop]) { + struct v4l2_crop crop; + + crop.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY; + if (doioctl(fd, VIDIOC_G_CROP, &crop, "VIDIOC_G_CROP") == 0) + printcrop(crop); + } + if (options[OptGetInput]) { if (doioctl(fd, VIDIOC_G_INPUT, &input, "VIDIOC_G_INPUT") == 0) { printf("Video input : %d", input); @@ -1836,7 +1964,7 @@ int main(int argc, char **argv) NULL }; - printf("Video standard = 0x%08llx\n", (unsigned long long)std); + printf("Video Standard = 0x%08llx\n", (unsigned long long)std); if (std & 0xfff) { print_std("PAL", pal, std); } diff --git a/v4l2-apps/util/v4l2-dbg.cpp b/v4l2-apps/util/v4l2-dbg.cpp index 6f373281e..10c9a8927 100644 --- a/v4l2-apps/util/v4l2-dbg.cpp +++ b/v4l2-apps/util/v4l2-dbg.cpp @@ -160,8 +160,6 @@ static std::string cap2s(unsigned cap) s += "\t\tSliced VBI Output\n"; if (cap & V4L2_CAP_RDS_CAPTURE) s += "\t\tRDS Capture\n"; - if (cap & V4L2_CAP_VIDEO_OUTPUT_POS) - s += "\t\tVideo Output Position\n"; if (cap & V4L2_CAP_TUNER) s += "\t\tTuner\n"; if (cap & V4L2_CAP_AUDIO) |