static int set_format(struct media_pad *pad, struct v4l2_mbus_framefmt *format) { int ret; if (format->width == 0 || format->height == 0) return 0; media_dbg(pad->entity->media, "Setting up format %s %ux%u on pad %s/%u\n", v4l2_subdev_pixelcode_to_string(format->code), format->width, format->height, pad->entity->info.name, pad->index); ret = v4l2_subdev_set_format(pad->entity, format, pad->index, V4L2_SUBDEV_FORMAT_ACTIVE); if (ret < 0) { media_dbg(pad->entity->media, "Unable to set format: %s (%d)\n", strerror(-ret), ret); return ret; } media_dbg(pad->entity->media, "Format set: %s %ux%u\n", v4l2_subdev_pixelcode_to_string(format->code), format->width, format->height); return 0; }
static void v4l2_subdev_print_format(struct media_entity *entity, unsigned int pad, enum v4l2_subdev_format_whence which) { struct v4l2_mbus_framefmt format; struct v4l2_rect rect; int ret; ret = v4l2_subdev_get_format(entity, &format, pad, which); if (ret != 0) return; printf("\t\t[fmt:%s/%ux%u", v4l2_subdev_pixelcode_to_string(format.code), format.width, format.height); ret = v4l2_subdev_get_selection(entity, &rect, pad, V4L2_SEL_TGT_CROP_BOUNDS, which); if (ret == 0) printf("\n\t\t crop.bounds:(%u,%u)/%ux%u", rect.left, rect.top, rect.width, rect.height); ret = v4l2_subdev_get_selection(entity, &rect, pad, V4L2_SEL_TGT_CROP, which); if (ret == 0) printf("\n\t\t crop:(%u,%u)/%ux%u", rect.left, rect.top, rect.width, rect.height); ret = v4l2_subdev_get_selection(entity, &rect, pad, V4L2_SEL_TGT_COMPOSE_BOUNDS, which); if (ret == 0) printf("\n\t\t compose.bounds:(%u,%u)/%ux%u", rect.left, rect.top, rect.width, rect.height); ret = v4l2_subdev_get_selection(entity, &rect, pad, V4L2_SEL_TGT_COMPOSE, which); if (ret == 0) printf("\n\t\t compose:(%u,%u)/%ux%u", rect.left, rect.top, rect.width, rect.height); printf("]\n"); }