diff options
Diffstat (limited to 'drivers/media/usb/uvc/uvc_v4l2.c')
-rw-r--r-- | drivers/media/usb/uvc/uvc_v4l2.c | 62 |
1 files changed, 33 insertions, 29 deletions
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c index fa06bfa174ad..252136cc885c 100644 --- a/drivers/media/usb/uvc/uvc_v4l2.c +++ b/drivers/media/usb/uvc/uvc_v4l2.c @@ -75,8 +75,8 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain, break; default: - uvc_trace(UVC_TRACE_CONTROL, "Unsupported V4L2 control type " - "%u.\n", xmap->v4l2_type); + uvc_dbg(chain->dev, CONTROL, + "Unsupported V4L2 control type %u\n", xmap->v4l2_type); ret = -ENOTTY; goto free_map; } @@ -164,10 +164,10 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream, return -EINVAL; fcc = (u8 *)&fmt->fmt.pix.pixelformat; - uvc_trace(UVC_TRACE_FORMAT, "Trying format 0x%08x (%c%c%c%c): %ux%u.\n", - fmt->fmt.pix.pixelformat, - fcc[0], fcc[1], fcc[2], fcc[3], - fmt->fmt.pix.width, fmt->fmt.pix.height); + uvc_dbg(stream->dev, FORMAT, "Trying format 0x%08x (%c%c%c%c): %ux%u\n", + fmt->fmt.pix.pixelformat, + fcc[0], fcc[1], fcc[2], fcc[3], + fmt->fmt.pix.width, fmt->fmt.pix.height); /* Check if the hardware supports the requested format, use the default * format otherwise. @@ -207,16 +207,17 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream, } if (frame == NULL) { - uvc_trace(UVC_TRACE_FORMAT, "Unsupported size %ux%u.\n", - fmt->fmt.pix.width, fmt->fmt.pix.height); + uvc_dbg(stream->dev, FORMAT, "Unsupported size %ux%u\n", + fmt->fmt.pix.width, fmt->fmt.pix.height); return -EINVAL; } /* Use the default frame interval. */ interval = frame->dwDefaultFrameInterval; - uvc_trace(UVC_TRACE_FORMAT, "Using default frame interval %u.%u us " - "(%u.%u fps).\n", interval/10, interval%10, 10000000/interval, - (100000000/interval)%10); + uvc_dbg(stream->dev, FORMAT, + "Using default frame interval %u.%u us (%u.%u fps)\n", + interval / 10, interval % 10, 10000000 / interval, + (100000000 / interval) % 10); /* Set the format index, frame index and frame interval. */ memset(probe, 0, sizeof(*probe)); @@ -248,7 +249,9 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream, goto done; /* After the probe, update fmt with the values returned from - * negotiation with the device. + * negotiation with the device. Some devices return invalid bFormatIndex + * and bFrameIndex values, in which case we can only assume they have + * accepted the requested format as-is. */ for (i = 0; i < stream->nformats; ++i) { if (probe->bFormatIndex == stream->format[i].index) { @@ -257,11 +260,10 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream, } } - if (i == stream->nformats) { - uvc_trace(UVC_TRACE_FORMAT, "Unknown bFormatIndex %u\n", - probe->bFormatIndex); - return -EINVAL; - } + if (i == stream->nformats) + uvc_dbg(stream->dev, FORMAT, + "Unknown bFormatIndex %u, using default\n", + probe->bFormatIndex); for (i = 0; i < format->nframes; ++i) { if (probe->bFrameIndex == format->frame[i].bFrameIndex) { @@ -270,11 +272,10 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream, } } - if (i == format->nframes) { - uvc_trace(UVC_TRACE_FORMAT, "Unknown bFrameIndex %u\n", - probe->bFrameIndex); - return -EINVAL; - } + if (i == format->nframes) + uvc_dbg(stream->dev, FORMAT, + "Unknown bFrameIndex %u, using default\n", + probe->bFrameIndex); fmt->fmt.pix.width = frame->wWidth; fmt->fmt.pix.height = frame->wHeight; @@ -416,7 +417,7 @@ static int uvc_v4l2_set_streamparm(struct uvc_streaming *stream, interval = uvc_fraction_to_interval(timeperframe.numerator, timeperframe.denominator); - uvc_trace(UVC_TRACE_FORMAT, "Setting frame interval to %u/%u (%u).\n", + uvc_dbg(stream->dev, FORMAT, "Setting frame interval to %u/%u (%u)\n", timeperframe.numerator, timeperframe.denominator, interval); mutex_lock(&stream->mutex); @@ -545,8 +546,8 @@ static int uvc_v4l2_open(struct file *file) struct uvc_fh *handle; int ret = 0; - uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_open\n"); stream = video_drvdata(file); + uvc_dbg(stream->dev, CALLS, "%s\n", __func__); ret = usb_autopm_get_interface(stream->dev->intf); if (ret < 0) @@ -588,7 +589,7 @@ static int uvc_v4l2_release(struct file *file) struct uvc_fh *handle = file->private_data; struct uvc_streaming *stream = handle->stream; - uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_release\n"); + uvc_dbg(stream->dev, CALLS, "%s\n", __func__); /* Only free resources if this is a privileged handle. */ if (uvc_has_privileges(handle)) @@ -1461,7 +1462,10 @@ static long uvc_v4l2_compat_ioctl32(struct file *file, static ssize_t uvc_v4l2_read(struct file *file, char __user *data, size_t count, loff_t *ppos) { - uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_read: not implemented.\n"); + struct uvc_fh *handle = file->private_data; + struct uvc_streaming *stream = handle->stream; + + uvc_dbg(stream->dev, CALLS, "%s: not implemented\n", __func__); return -EINVAL; } @@ -1470,7 +1474,7 @@ static int uvc_v4l2_mmap(struct file *file, struct vm_area_struct *vma) struct uvc_fh *handle = file->private_data; struct uvc_streaming *stream = handle->stream; - uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_mmap\n"); + uvc_dbg(stream->dev, CALLS, "%s\n", __func__); return uvc_queue_mmap(&stream->queue, vma); } @@ -1480,7 +1484,7 @@ static __poll_t uvc_v4l2_poll(struct file *file, poll_table *wait) struct uvc_fh *handle = file->private_data; struct uvc_streaming *stream = handle->stream; - uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_poll\n"); + uvc_dbg(stream->dev, CALLS, "%s\n", __func__); return uvc_queue_poll(&stream->queue, file, wait); } @@ -1493,7 +1497,7 @@ static unsigned long uvc_v4l2_get_unmapped_area(struct file *file, struct uvc_fh *handle = file->private_data; struct uvc_streaming *stream = handle->stream; - uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_get_unmapped_area\n"); + uvc_dbg(stream->dev, CALLS, "%s\n", __func__); return uvc_queue_get_unmapped_area(&stream->queue, pgoff); } |