diff options
author | Kuninori Morimoto <morimoto.kuninori@renesas.com> | 2008-12-29 04:04:44 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-12-30 06:40:30 -0500 |
commit | f82a8569bfa10f32a3123ca0b681ec7c3188d2c0 (patch) | |
tree | 48b4ec93dc8e65b63e7defafeaf3b6ecf49abee1 /drivers/media | |
parent | 77fe3d4a44f76653263eb8671d7909ab0fdafd71 (diff) |
V4L/DVB (10098): ov772x: fix try_fmt calculation method
Don't modify driver's state in try_fmt, just verify format acceptability
or adjust it to driver's capabilities.
Signed-off-by: Kuninori Morimoto <morimoto.kuninori@renesas.com>
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/ov772x.c | 55 |
1 files changed, 35 insertions, 20 deletions
diff --git a/drivers/media/video/ov772x.c b/drivers/media/video/ov772x.c index b3346c934bf3..54b736fcc07a 100644 --- a/drivers/media/video/ov772x.c +++ b/drivers/media/video/ov772x.c | |||
@@ -766,6 +766,27 @@ static int ov772x_set_register(struct soc_camera_device *icd, | |||
766 | } | 766 | } |
767 | #endif | 767 | #endif |
768 | 768 | ||
769 | static const struct ov772x_win_size* | ||
770 | ov772x_select_win(u32 width, u32 height) | ||
771 | { | ||
772 | __u32 diff; | ||
773 | const struct ov772x_win_size *win; | ||
774 | |||
775 | /* default is QVGA */ | ||
776 | diff = abs(width - ov772x_win_qvga.width) + | ||
777 | abs(height - ov772x_win_qvga.height); | ||
778 | win = &ov772x_win_qvga; | ||
779 | |||
780 | /* VGA */ | ||
781 | if (diff > | ||
782 | abs(width - ov772x_win_vga.width) + | ||
783 | abs(height - ov772x_win_vga.height)) | ||
784 | win = &ov772x_win_vga; | ||
785 | |||
786 | return win; | ||
787 | } | ||
788 | |||
789 | |||
769 | static int ov772x_set_fmt(struct soc_camera_device *icd, | 790 | static int ov772x_set_fmt(struct soc_camera_device *icd, |
770 | __u32 pixfmt, | 791 | __u32 pixfmt, |
771 | struct v4l2_rect *rect) | 792 | struct v4l2_rect *rect) |
@@ -786,34 +807,28 @@ static int ov772x_set_fmt(struct soc_camera_device *icd, | |||
786 | } | 807 | } |
787 | } | 808 | } |
788 | 809 | ||
810 | /* | ||
811 | * select win | ||
812 | */ | ||
813 | priv->win = ov772x_select_win(rect->width, rect->height); | ||
814 | |||
789 | return ret; | 815 | return ret; |
790 | } | 816 | } |
791 | 817 | ||
792 | static int ov772x_try_fmt(struct soc_camera_device *icd, | 818 | static int ov772x_try_fmt(struct soc_camera_device *icd, |
793 | struct v4l2_format *f) | 819 | struct v4l2_format *f) |
794 | { | 820 | { |
795 | struct v4l2_pix_format *pix = &f->fmt.pix; | 821 | struct v4l2_pix_format *pix = &f->fmt.pix; |
796 | struct ov772x_priv *priv; | 822 | const struct ov772x_win_size *win; |
797 | |||
798 | priv = container_of(icd, struct ov772x_priv, icd); | ||
799 | |||
800 | /* QVGA */ | ||
801 | if (pix->width <= ov772x_win_qvga.width || | ||
802 | pix->height <= ov772x_win_qvga.height) { | ||
803 | priv->win = &ov772x_win_qvga; | ||
804 | pix->width = ov772x_win_qvga.width; | ||
805 | pix->height = ov772x_win_qvga.height; | ||
806 | } | ||
807 | 823 | ||
808 | /* VGA */ | 824 | /* |
809 | else if (pix->width <= ov772x_win_vga.width || | 825 | * select suitable win |
810 | pix->height <= ov772x_win_vga.height) { | 826 | */ |
811 | priv->win = &ov772x_win_vga; | 827 | win = ov772x_select_win(pix->width, pix->height); |
812 | pix->width = ov772x_win_vga.width; | ||
813 | pix->height = ov772x_win_vga.height; | ||
814 | } | ||
815 | 828 | ||
816 | pix->field = V4L2_FIELD_NONE; | 829 | pix->width = win->width; |
830 | pix->height = win->height; | ||
831 | pix->field = V4L2_FIELD_NONE; | ||
817 | 832 | ||
818 | return 0; | 833 | return 0; |
819 | } | 834 | } |