diff options
Diffstat (limited to 'drivers/media/video/zoran/zoran_card.c')
-rw-r--r-- | drivers/media/video/zoran/zoran_card.c | 63 |
1 files changed, 45 insertions, 18 deletions
diff --git a/drivers/media/video/zoran/zoran_card.c b/drivers/media/video/zoran/zoran_card.c index 18834b18435b..774717bf43cc 100644 --- a/drivers/media/video/zoran/zoran_card.c +++ b/drivers/media/video/zoran/zoran_card.c | |||
@@ -835,7 +835,8 @@ zoran_unregister_i2c (struct zoran *zr) | |||
835 | 835 | ||
836 | int | 836 | int |
837 | zoran_check_jpg_settings (struct zoran *zr, | 837 | zoran_check_jpg_settings (struct zoran *zr, |
838 | struct zoran_jpg_settings *settings) | 838 | struct zoran_jpg_settings *settings, |
839 | int try) | ||
839 | { | 840 | { |
840 | int err = 0, err0 = 0; | 841 | int err = 0, err0 = 0; |
841 | 842 | ||
@@ -900,35 +901,61 @@ zoran_check_jpg_settings (struct zoran *zr, | |||
900 | /* We have to check the data the user has set */ | 901 | /* We have to check the data the user has set */ |
901 | 902 | ||
902 | if (settings->HorDcm != 1 && settings->HorDcm != 2 && | 903 | if (settings->HorDcm != 1 && settings->HorDcm != 2 && |
903 | (zr->card.type == DC10_new || settings->HorDcm != 4)) | 904 | (zr->card.type == DC10_new || settings->HorDcm != 4)) { |
905 | settings->HorDcm = clamp(settings->HorDcm, 1, 2); | ||
904 | err0++; | 906 | err0++; |
905 | if (settings->VerDcm != 1 && settings->VerDcm != 2) | 907 | } |
908 | if (settings->VerDcm != 1 && settings->VerDcm != 2) { | ||
909 | settings->VerDcm = clamp(settings->VerDcm, 1, 2); | ||
906 | err0++; | 910 | err0++; |
907 | if (settings->TmpDcm != 1 && settings->TmpDcm != 2) | 911 | } |
912 | if (settings->TmpDcm != 1 && settings->TmpDcm != 2) { | ||
913 | settings->TmpDcm = clamp(settings->TmpDcm, 1, 2); | ||
908 | err0++; | 914 | err0++; |
915 | } | ||
909 | if (settings->field_per_buff != 1 && | 916 | if (settings->field_per_buff != 1 && |
910 | settings->field_per_buff != 2) | 917 | settings->field_per_buff != 2) { |
918 | settings->field_per_buff = clamp(settings->field_per_buff, 1, 2); | ||
911 | err0++; | 919 | err0++; |
912 | if (settings->img_x < 0) | 920 | } |
921 | if (settings->img_x < 0) { | ||
922 | settings->img_x = 0; | ||
913 | err0++; | 923 | err0++; |
914 | if (settings->img_y < 0) | 924 | } |
925 | if (settings->img_y < 0) { | ||
926 | settings->img_y = 0; | ||
915 | err0++; | 927 | err0++; |
916 | if (settings->img_width < 0) | 928 | } |
929 | if (settings->img_width < 0 || settings->img_width > BUZ_MAX_WIDTH) { | ||
930 | settings->img_width = clamp(settings->img_width, 0, (int)BUZ_MAX_WIDTH); | ||
917 | err0++; | 931 | err0++; |
918 | if (settings->img_height < 0) | 932 | } |
933 | if (settings->img_height < 0 || settings->img_height > BUZ_MAX_HEIGHT / 2) { | ||
934 | settings->img_height = clamp(settings->img_height, 0, BUZ_MAX_HEIGHT / 2); | ||
919 | err0++; | 935 | err0++; |
920 | if (settings->img_x + settings->img_width > BUZ_MAX_WIDTH) | 936 | } |
937 | if (settings->img_x + settings->img_width > BUZ_MAX_WIDTH) { | ||
938 | settings->img_x = BUZ_MAX_WIDTH - settings->img_width; | ||
939 | err0++; | ||
940 | } | ||
941 | if (settings->img_y + settings->img_height > BUZ_MAX_HEIGHT / 2) { | ||
942 | settings->img_y = BUZ_MAX_HEIGHT / 2 - settings->img_height; | ||
921 | err0++; | 943 | err0++; |
922 | if (settings->img_y + settings->img_height > BUZ_MAX_HEIGHT / 2) | 944 | } |
945 | if (settings->img_width % (16 * settings->HorDcm) != 0) { | ||
946 | settings->img_width -= settings->img_width % (16 * settings->HorDcm); | ||
947 | if (settings->img_width == 0) | ||
948 | settings->img_width = 16 * settings->HorDcm; | ||
949 | err0++; | ||
950 | } | ||
951 | if (settings->img_height % (8 * settings->VerDcm) != 0) { | ||
952 | settings->img_height -= settings->img_height % (8 * settings->VerDcm); | ||
953 | if (settings->img_height == 0) | ||
954 | settings->img_height = 8 * settings->VerDcm; | ||
923 | err0++; | 955 | err0++; |
924 | if (settings->HorDcm && settings->VerDcm) { | ||
925 | if (settings->img_width % (16 * settings->HorDcm) != 0) | ||
926 | err0++; | ||
927 | if (settings->img_height % (8 * settings->VerDcm) != 0) | ||
928 | err0++; | ||
929 | } | 956 | } |
930 | 957 | ||
931 | if (err0) { | 958 | if (!try && err0) { |
932 | dprintk(1, | 959 | dprintk(1, |
933 | KERN_ERR | 960 | KERN_ERR |
934 | "%s: check_jpg_settings() - error in params for decimation = 0\n", | 961 | "%s: check_jpg_settings() - error in params for decimation = 0\n", |
@@ -1018,7 +1045,7 @@ zoran_open_init_params (struct zoran *zr) | |||
1018 | sizeof(zr->jpg_settings.jpg_comp.COM_data)); | 1045 | sizeof(zr->jpg_settings.jpg_comp.COM_data)); |
1019 | zr->jpg_settings.jpg_comp.jpeg_markers = | 1046 | zr->jpg_settings.jpg_comp.jpeg_markers = |
1020 | JPEG_MARKER_DHT | JPEG_MARKER_DQT; | 1047 | JPEG_MARKER_DHT | JPEG_MARKER_DQT; |
1021 | i = zoran_check_jpg_settings(zr, &zr->jpg_settings); | 1048 | i = zoran_check_jpg_settings(zr, &zr->jpg_settings, 0); |
1022 | if (i) | 1049 | if (i) |
1023 | dprintk(1, | 1050 | dprintk(1, |
1024 | KERN_ERR | 1051 | KERN_ERR |