diff options
author | Sakari Ailus <sakari.ailus@iki.fi> | 2011-10-07 18:38:07 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2011-10-08 13:32:17 +0200 |
commit | 2738635d82da5f010bae6a60472a6306df949ea5 (patch) | |
tree | 97ce4c08c0ab6dcc7abd7f78bd2e5965e15c63a3 /src/v4l2subdev.c | |
parent | 879982243998d6ebf7e7ac4e79b2cfc7371aeda2 (diff) |
Add debugging handler
Add debugging handler to media_device that may be used to redirect all debug
formatting to user-supplied function. fprintf will do, and that's what
media-ctl test program will use.
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/v4l2subdev.c')
-rw-r--r-- | src/v4l2subdev.c | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/src/v4l2subdev.c b/src/v4l2subdev.c index 38dcdda..8daab84 100644 --- a/src/v4l2subdev.c +++ b/src/v4l2subdev.c @@ -40,8 +40,9 @@ int v4l2_subdev_open(struct media_entity *entity) entity->fd = open(entity->devname, O_RDWR); if (entity->fd == -1) { - printf("%s: Failed to open subdev device node %s\n", __func__, - entity->devname); + media_dbg(entity->media, + "%s: Failed to open subdev device node %s\n", __func__, + entity->devname); return -errno; } @@ -329,21 +330,25 @@ static int set_format(struct media_pad *pad, if (format->width == 0 || format->height == 0) return 0; - printf("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); + 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) { - printf("Unable to set format: %s (%d)\n", strerror(-ret), ret); + media_dbg(pad->entity->media, + "Unable to set format: %s (%d)\n", + strerror(-ret), ret); return ret; } - printf("Format set: %s %ux%u\n", - v4l2_subdev_pixelcode_to_string(format->code), - format->width, format->height); + media_dbg(pad->entity->media, + "Format set: %s %ux%u\n", + v4l2_subdev_pixelcode_to_string(format->code), + format->width, format->height); return 0; } @@ -355,19 +360,23 @@ static int set_crop(struct media_pad *pad, struct v4l2_rect *crop) if (crop->left == -1 || crop->top == -1) return 0; - printf("Setting up crop rectangle (%u,%u)/%ux%u on pad %s/%u\n", - crop->left, crop->top, crop->width, crop->height, - pad->entity->info.name, pad->index); + media_dbg(pad->entity->media, + "Setting up crop rectangle (%u,%u)/%ux%u on pad %s/%u\n", + crop->left, crop->top, crop->width, crop->height, + pad->entity->info.name, pad->index); ret = v4l2_subdev_set_crop(pad->entity, crop, pad->index, V4L2_SUBDEV_FORMAT_ACTIVE); if (ret < 0) { - printf("Unable to set crop rectangle: %s (%d)\n", strerror(-ret), ret); + media_dbg(pad->entity->media, + "Unable to set crop rectangle: %s (%d)\n", + strerror(-ret), ret); return ret; } - printf("Crop rectangle set: (%u,%u)/%ux%u\n", - crop->left, crop->top, crop->width, crop->height); + media_dbg(pad->entity->media, + "Crop rectangle set: (%u,%u)/%ux%u\n", + crop->left, crop->top, crop->width, crop->height); return 0; } @@ -380,17 +389,21 @@ static int set_frame_interval(struct media_entity *entity, if (interval->numerator == 0) return 0; - printf("Setting up frame interval %u/%u on entity %s\n", - interval->numerator, interval->denominator, entity->info.name); + media_dbg(entity->media, + "Setting up frame interval %u/%u on entity %s\n", + interval->numerator, interval->denominator, + entity->info.name); ret = v4l2_subdev_set_frame_interval(entity, interval); if (ret < 0) { - printf("Unable to set frame interval: %s (%d)", strerror(-ret), ret); + media_dbg(entity->media, + "Unable to set frame interval: %s (%d)", + strerror(-ret), ret); return ret; } - printf("Frame interval set: %u/%u\n", - interval->numerator, interval->denominator); + media_dbg(entity->media, "Frame interval set: %u/%u\n", + interval->numerator, interval->denominator); return 0; } @@ -410,7 +423,7 @@ static int v4l2_subdev_parse_setup_format(struct media_device *media, pad = v4l2_subdev_parse_pad_format(media, &format, &crop, &interval, p, &end); if (pad == NULL) { - printf("Unable to parse format\n"); + media_dbg(media, "Unable to parse format\n"); return -EINVAL; } |