diff options
Diffstat (limited to 'drivers/media/video/uvc/uvc_video.c')
-rw-r--r-- | drivers/media/video/uvc/uvc_video.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/media/video/uvc/uvc_video.c b/drivers/media/video/uvc/uvc_video.c index 6ce974d7362f..01b633c73480 100644 --- a/drivers/media/video/uvc/uvc_video.c +++ b/drivers/media/video/uvc/uvc_video.c | |||
@@ -65,7 +65,8 @@ static void uvc_fixup_video_ctrl(struct uvc_video_device *video, | |||
65 | struct uvc_streaming_control *ctrl) | 65 | struct uvc_streaming_control *ctrl) |
66 | { | 66 | { |
67 | struct uvc_format *format; | 67 | struct uvc_format *format; |
68 | struct uvc_frame *frame; | 68 | struct uvc_frame *frame = NULL; |
69 | unsigned int i; | ||
69 | 70 | ||
70 | if (ctrl->bFormatIndex <= 0 || | 71 | if (ctrl->bFormatIndex <= 0 || |
71 | ctrl->bFormatIndex > video->streaming->nformats) | 72 | ctrl->bFormatIndex > video->streaming->nformats) |
@@ -73,11 +74,15 @@ static void uvc_fixup_video_ctrl(struct uvc_video_device *video, | |||
73 | 74 | ||
74 | format = &video->streaming->format[ctrl->bFormatIndex - 1]; | 75 | format = &video->streaming->format[ctrl->bFormatIndex - 1]; |
75 | 76 | ||
76 | if (ctrl->bFrameIndex <= 0 || | 77 | for (i = 0; i < format->nframes; ++i) { |
77 | ctrl->bFrameIndex > format->nframes) | 78 | if (format->frame[i].bFrameIndex == ctrl->bFrameIndex) { |
78 | return; | 79 | frame = &format->frame[i]; |
80 | break; | ||
81 | } | ||
82 | } | ||
79 | 83 | ||
80 | frame = &format->frame[ctrl->bFrameIndex - 1]; | 84 | if (frame == NULL) |
85 | return; | ||
81 | 86 | ||
82 | if (!(format->flags & UVC_FMT_FLAG_COMPRESSED) || | 87 | if (!(format->flags & UVC_FMT_FLAG_COMPRESSED) || |
83 | (ctrl->dwMaxVideoFrameSize == 0 && | 88 | (ctrl->dwMaxVideoFrameSize == 0 && |
@@ -1089,7 +1094,7 @@ int uvc_video_init(struct uvc_video_device *video) | |||
1089 | /* Zero bFrameIndex might be correct. Stream-based formats (including | 1094 | /* Zero bFrameIndex might be correct. Stream-based formats (including |
1090 | * MPEG-2 TS and DV) do not support frames but have a dummy frame | 1095 | * MPEG-2 TS and DV) do not support frames but have a dummy frame |
1091 | * descriptor with bFrameIndex set to zero. If the default frame | 1096 | * descriptor with bFrameIndex set to zero. If the default frame |
1092 | * descriptor is not found, use the first avalable frame. | 1097 | * descriptor is not found, use the first available frame. |
1093 | */ | 1098 | */ |
1094 | for (i = format->nframes; i > 0; --i) { | 1099 | for (i = format->nframes; i > 0; --i) { |
1095 | frame = &format->frame[i-1]; | 1100 | frame = &format->frame[i-1]; |