state = vsp1_entity_get_state(&rwpf->entity, sd_state, fmt->which); if (!state) {
ret = -EINVAL; goto done;
}
/* Default to YUV if the requested format is not supported. */ if (fmt->format.code != MEDIA_BUS_FMT_ARGB8888_1X32 &&
fmt->format.code != MEDIA_BUS_FMT_AHSV8888_1X32 &&
fmt->format.code != MEDIA_BUS_FMT_AYUV8_1X32)
fmt->format.code = MEDIA_BUS_FMT_AYUV8_1X32;
format = v4l2_subdev_state_get_format(state, fmt->pad);
/* * The RWPF performs format conversion but can't scale, only the * format code, encoding and quantization can be changed on the * source pad when converting between RGB and YUV.
*/ if (sink_format->code != MEDIA_BUS_FMT_AHSV8888_1X32 &&
fmt->format.code != MEDIA_BUS_FMT_AHSV8888_1X32)
format->code = fmt->format.code; else
format->code = sink_format->code;
/* * Encoding and quantization can only be configured when YCbCr * <-> RGB is enabled. The V4L2 API requires userspace to set * the V4L2_MBUS_FRAMEFMT_SET_CSC flag. If either of these * conditions is not met, use the encoding and quantization * values from the sink pad.
*/
csc = (format->code == MEDIA_BUS_FMT_AYUV8_1X32) !=
(sink_format->code == MEDIA_BUS_FMT_AYUV8_1X32);
/* * Cropping is only supported on the RPF and is implemented on the sink * pad.
*/ if (rwpf->entity.type == VSP1_ENTITY_WPF || sel->pad != RWPF_PAD_SINK) return -EINVAL;
mutex_lock(&rwpf->entity.lock);
state = vsp1_entity_get_state(&rwpf->entity, sd_state, sel->which); if (!state) {
ret = -EINVAL; goto done;
}
switch (sel->target) { case V4L2_SEL_TGT_CROP:
sel->r = *v4l2_subdev_state_get_crop(state, RWPF_PAD_SINK); break;
case V4L2_SEL_TGT_CROP_BOUNDS:
format = v4l2_subdev_state_get_format(state, RWPF_PAD_SINK);
sel->r.left = 0;
sel->r.top = 0;
sel->r.width = format->width;
sel->r.height = format->height; break;
/* * Cropping is only supported on the RPF and is implemented on the sink * pad.
*/ if (rwpf->entity.type == VSP1_ENTITY_WPF || sel->pad != RWPF_PAD_SINK) return -EINVAL;
if (sel->target != V4L2_SEL_TGT_CROP) return -EINVAL;
mutex_lock(&rwpf->entity.lock);
state = vsp1_entity_get_state(&rwpf->entity, sd_state, sel->which); if (!state) {
ret = -EINVAL; goto done;
}
/* Make sure the crop rectangle is entirely contained in the image. */
format = v4l2_subdev_state_get_format(state, RWPF_PAD_SINK);
/* * Restrict the crop rectangle coordinates to multiples of 2 to avoid * shifting the color plane.
*/ if (format->code == MEDIA_BUS_FMT_AYUV8_1X32) {
sel->r.left = ALIGN(sel->r.left, 2);
sel->r.top = ALIGN(sel->r.top, 2);
sel->r.width = round_down(sel->r.width, 2);
sel->r.height = round_down(sel->r.height, 2);
}
/* Propagate the format to the source pad. */
format = v4l2_subdev_state_get_format(state, RWPF_PAD_SOURCE);
format->width = crop->width;
format->height = crop->height;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.