Commit d4809b77 authored by Philipp Zabel's avatar Philipp Zabel Committed by Mauro Carvalho Chehab

media: gspca: support multiple pixel formats in TRY_FMT

If a driver supports multiple pixel formats with the same frame size,
TRY_FMT will currently always return the first pixel format.
Fix this by adding pixelformat support to wxh_to_nearest_mode().
Signed-off-by: default avatarPhilipp Zabel <philipp.zabel@gmail.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent fc78e0b2
...@@ -926,10 +926,16 @@ static int wxh_to_mode(struct gspca_dev *gspca_dev, ...@@ -926,10 +926,16 @@ static int wxh_to_mode(struct gspca_dev *gspca_dev,
} }
static int wxh_to_nearest_mode(struct gspca_dev *gspca_dev, static int wxh_to_nearest_mode(struct gspca_dev *gspca_dev,
int width, int height) int width, int height, u32 pixelformat)
{ {
int i; int i;
for (i = gspca_dev->cam.nmodes; --i > 0; ) {
if (width >= gspca_dev->cam.cam_mode[i].width
&& height >= gspca_dev->cam.cam_mode[i].height
&& pixelformat == gspca_dev->cam.cam_mode[i].pixelformat)
return i;
}
for (i = gspca_dev->cam.nmodes; --i > 0; ) { for (i = gspca_dev->cam.nmodes; --i > 0; ) {
if (width >= gspca_dev->cam.cam_mode[i].width if (width >= gspca_dev->cam.cam_mode[i].width
&& height >= gspca_dev->cam.cam_mode[i].height) && height >= gspca_dev->cam.cam_mode[i].height)
...@@ -1059,7 +1065,7 @@ static int try_fmt_vid_cap(struct gspca_dev *gspca_dev, ...@@ -1059,7 +1065,7 @@ static int try_fmt_vid_cap(struct gspca_dev *gspca_dev,
fmt->fmt.pix.pixelformat, w, h); fmt->fmt.pix.pixelformat, w, h);
/* search the nearest mode for width and height */ /* search the nearest mode for width and height */
mode = wxh_to_nearest_mode(gspca_dev, w, h); mode = wxh_to_nearest_mode(gspca_dev, w, h, fmt->fmt.pix.pixelformat);
/* OK if right palette */ /* OK if right palette */
if (gspca_dev->cam.cam_mode[mode].pixelformat if (gspca_dev->cam.cam_mode[mode].pixelformat
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment