summaryrefslogtreecommitdiffstats
path: root/drivers/media/usb
diff options
context:
space:
mode:
authorPhilipp Zabel <philipp.zabel@gmail.com>2018-12-14 11:40:26 -0500
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2019-01-16 13:57:12 -0500
commitd4809b778a0899f732e808e60b3a42cfce0b5e40 (patch)
tree547e4b61bf22eba269083bf9e0c8660ca91539ad /drivers/media/usb
parentfc78e0b2471d6efa19f896d7c93a8ecda9913ddd (diff)
downloadlinux-d4809b778a0899f732e808e60b3a42cfce0b5e40.tar.gz
linux-d4809b778a0899f732e808e60b3a42cfce0b5e40.tar.bz2
linux-d4809b778a0899f732e808e60b3a42cfce0b5e40.zip
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: Philipp Zabel <philipp.zabel@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'drivers/media/usb')
-rw-r--r--drivers/media/usb/gspca/gspca.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c
index 13361cfa6903..ac70b36d67b7 100644
--- a/drivers/media/usb/gspca/gspca.c
+++ b/drivers/media/usb/gspca/gspca.c
@@ -926,12 +926,18 @@ static int wxh_to_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;
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; ) {
+ if (width >= gspca_dev->cam.cam_mode[i].width
&& height >= gspca_dev->cam.cam_mode[i].height)
break;
}
@@ -1059,7 +1065,7 @@ static int try_fmt_vid_cap(struct gspca_dev *gspca_dev,
fmt->fmt.pix.pixelformat, w, h);
/* 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 */
if (gspca_dev->cam.cam_mode[mode].pixelformat