return NULL;
for (p = end; isspace(*p); ++p);
- *endp = (char *)p;
+ if (endp)
+ *endp = (char *)p;
return &entity->pads[pad];
}
{
char *end;
- for (; isspace(*p); ++p);
+ if (*p++ != '(')
+ return -EINVAL;
crop->left = strtoul(p, &end, 10);
if (*end != ',')
p = end + 1;
crop->top = strtoul(p, &end, 10);
+ if (*end++ != ')')
+ return -EINVAL;
if (*end != '/')
return -EINVAL;
if (*p++ != '[')
return NULL;
- ret = parse_format(format, p, &end);
- if (ret < 0)
- return NULL;
+ if (isalnum(*p)) {
+ ret = parse_format(format, p, &end);
+ if (ret < 0)
+ return NULL;
- for (p = end; isspace(*p); p++);
- if (isdigit(*p)) {
+ for (p = end; isspace(*p); p++);
+ }
+
+ if (*p == '(') {
ret = parse_crop(crop, p, &end);
if (ret < 0)
return NULL;
{
int ret;
+ if (format->width == 0 || format->height == 0)
+ return 0;
+
printf("Setting up format %s %ux%u on pad %s/%u\n",
pixelcode_to_string(format->code), format->width, format->height,
pad->entity->info.name, pad->index);
{
int ret;
+ if (interval->numerator == 0)
+ return 0;
+
printf("Setting up frame interval %u/%u on entity %s\n",
interval->numerator, interval->denominator, entity->info.name);
static int setup_format(struct media_device *media, const char *p, char **endp)
{
- struct v4l2_mbus_framefmt format;
+ struct v4l2_mbus_framefmt format = { 0, 0, 0 };
struct media_entity_pad *pad;
struct v4l2_rect crop = { -1, -1, -1, -1 };
struct v4l2_fract interval = { 0, 0 };
return ret;
}
- if (interval.numerator != 0) {
- ret = set_frame_interval(pad->entity, &interval);
- if (ret < 0) {
- printf("Unable to set frame interval\n");
- return ret;
- }
- }
+ ret = set_frame_interval(pad->entity, &interval);
+ if (ret < 0)
+ return ret;
+
/* If the pad is an output pad, automatically set the same format on
* the remote subdev input pads, if any.
int main(int argc, char **argv)
{
struct media_device *media;
+ int ret = -1;
if (parse_cmdline(argc, argv))
return EXIT_FAILURE;
entity = media_get_entity_by_name(media, media_opts.entity,
strlen(media_opts.entity));
- if (entity != NULL)
- printf("%s\n", entity->devname);
- else
+ if (entity == NULL) {
printf("Entity '%s' not found\n", media_opts.entity);
+ goto out;
+ }
+
+ printf("%s\n", entity->devname);
+ }
+
+ if (media_opts.pad) {
+ struct media_entity_pad *pad;
+
+ pad = parse_pad(media, media_opts.pad, NULL);
+ if (pad == NULL) {
+ printf("Pad '%s' not found\n", media_opts.pad);
+ goto out;
+ }
+
+ v4l2_subdev_print_format(pad->entity, pad->index,
+ V4L2_SUBDEV_FORMAT_ACTIVE);
+ printf("\n");
}
if (media_opts.print || media_opts.print_dot) {
}
}
+ ret = 0;
+
out:
if (media)
media_close(media);
- exit(EXIT_SUCCESS);
+ return ret ? EXIT_FAILURE : EXIT_SUCCESS;
}