Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 137968
b: refs/heads/master
c: 0ba514d
h: refs/heads/master
v: v3
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Mar 30, 2009
1 parent a0c5c91 commit 1c43de8
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 25 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7f37cc9bae7aa29d567460c3ac8178d587f710bc
refs/heads/master: 0ba514d5d39d017e320ffba6d2a98563b829d37c
63 changes: 45 additions & 18 deletions trunk/drivers/media/video/zoran/zoran_card.c
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,8 @@ zoran_unregister_i2c (struct zoran *zr)

int
zoran_check_jpg_settings (struct zoran *zr,
struct zoran_jpg_settings *settings)
struct zoran_jpg_settings *settings,
int try)
{
int err = 0, err0 = 0;

Expand Down Expand Up @@ -900,35 +901,61 @@ zoran_check_jpg_settings (struct zoran *zr,
/* We have to check the data the user has set */

if (settings->HorDcm != 1 && settings->HorDcm != 2 &&
(zr->card.type == DC10_new || settings->HorDcm != 4))
(zr->card.type == DC10_new || settings->HorDcm != 4)) {
settings->HorDcm = clamp(settings->HorDcm, 1, 2);
err0++;
if (settings->VerDcm != 1 && settings->VerDcm != 2)
}
if (settings->VerDcm != 1 && settings->VerDcm != 2) {
settings->VerDcm = clamp(settings->VerDcm, 1, 2);
err0++;
if (settings->TmpDcm != 1 && settings->TmpDcm != 2)
}
if (settings->TmpDcm != 1 && settings->TmpDcm != 2) {
settings->TmpDcm = clamp(settings->TmpDcm, 1, 2);
err0++;
}
if (settings->field_per_buff != 1 &&
settings->field_per_buff != 2)
settings->field_per_buff != 2) {
settings->field_per_buff = clamp(settings->field_per_buff, 1, 2);
err0++;
if (settings->img_x < 0)
}
if (settings->img_x < 0) {
settings->img_x = 0;
err0++;
if (settings->img_y < 0)
}
if (settings->img_y < 0) {
settings->img_y = 0;
err0++;
if (settings->img_width < 0)
}
if (settings->img_width < 0 || settings->img_width > BUZ_MAX_WIDTH) {
settings->img_width = clamp(settings->img_width, 0, (int)BUZ_MAX_WIDTH);
err0++;
if (settings->img_height < 0)
}
if (settings->img_height < 0 || settings->img_height > BUZ_MAX_HEIGHT / 2) {
settings->img_height = clamp(settings->img_height, 0, BUZ_MAX_HEIGHT / 2);
err0++;
if (settings->img_x + settings->img_width > BUZ_MAX_WIDTH)
}
if (settings->img_x + settings->img_width > BUZ_MAX_WIDTH) {
settings->img_x = BUZ_MAX_WIDTH - settings->img_width;
err0++;
}
if (settings->img_y + settings->img_height > BUZ_MAX_HEIGHT / 2) {
settings->img_y = BUZ_MAX_HEIGHT / 2 - settings->img_height;
err0++;
if (settings->img_y + settings->img_height > BUZ_MAX_HEIGHT / 2)
}
if (settings->img_width % (16 * settings->HorDcm) != 0) {
settings->img_width -= settings->img_width % (16 * settings->HorDcm);
if (settings->img_width == 0)
settings->img_width = 16 * settings->HorDcm;
err0++;
}
if (settings->img_height % (8 * settings->VerDcm) != 0) {
settings->img_height -= settings->img_height % (8 * settings->VerDcm);
if (settings->img_height == 0)
settings->img_height = 8 * settings->VerDcm;
err0++;
if (settings->HorDcm && settings->VerDcm) {
if (settings->img_width % (16 * settings->HorDcm) != 0)
err0++;
if (settings->img_height % (8 * settings->VerDcm) != 0)
err0++;
}

if (err0) {
if (!try && err0) {
dprintk(1,
KERN_ERR
"%s: check_jpg_settings() - error in params for decimation = 0\n",
Expand Down Expand Up @@ -1018,7 +1045,7 @@ zoran_open_init_params (struct zoran *zr)
sizeof(zr->jpg_settings.jpg_comp.COM_data));
zr->jpg_settings.jpg_comp.jpeg_markers =
JPEG_MARKER_DHT | JPEG_MARKER_DQT;
i = zoran_check_jpg_settings(zr, &zr->jpg_settings);
i = zoran_check_jpg_settings(zr, &zr->jpg_settings, 0);
if (i)
dprintk(1,
KERN_ERR
Expand Down
3 changes: 2 additions & 1 deletion trunk/drivers/media/video/zoran/zoran_card.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ extern int zr36067_debug;
extern struct video_device zoran_template;

extern int zoran_check_jpg_settings(struct zoran *zr,
struct zoran_jpg_settings *settings);
struct zoran_jpg_settings *settings,
int try);
extern void zoran_open_init_params(struct zoran *zr);
extern void zoran_vdev_release(struct video_device *vdev);

Expand Down
21 changes: 16 additions & 5 deletions trunk/drivers/media/video/zoran/zoran_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1797,7 +1797,7 @@ static long zoran_default(struct file *file, void *__fh, int cmd, void *arg)

/* Check the params first before overwriting our
* nternal values */
if (zoran_check_jpg_settings(zr, &settings)) {
if (zoran_check_jpg_settings(zr, &settings, 0)) {
res = -EINVAL;
goto sparams_unlock_and_return;
}
Expand Down Expand Up @@ -2205,7 +2205,7 @@ static int zoran_try_fmt_vid_out(struct file *file, void *__fh,
settings.field_per_buff = 1;

/* check */
res = zoran_check_jpg_settings(zr, &settings);
res = zoran_check_jpg_settings(zr, &settings, 1);
if (res)
goto tryfmt_unlock_and_return;

Expand All @@ -2231,6 +2231,7 @@ static int zoran_try_fmt_vid_cap(struct file *file, void *__fh,
{
struct zoran_fh *fh = __fh;
struct zoran *zr = fh->zr;
int bpp;
int i;

if (fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_MJPEG)
Expand All @@ -2247,6 +2248,8 @@ static int zoran_try_fmt_vid_cap(struct file *file, void *__fh,
return -EINVAL;
}

bpp = (zoran_formats[i].depth + 7) / 8;
fmt->fmt.pix.width &= ~((bpp == 2) ? 1 : 3);
if (fmt->fmt.pix.width > BUZ_MAX_WIDTH)
fmt->fmt.pix.width = BUZ_MAX_WIDTH;
if (fmt->fmt.pix.width < BUZ_MIN_WIDTH)
Expand Down Expand Up @@ -2334,8 +2337,16 @@ static int zoran_s_fmt_vid_out(struct file *file, void *__fh,
else
settings.field_per_buff = 1;

if (settings.HorDcm > 1) {
settings.img_x = (BUZ_MAX_WIDTH == 720) ? 8 : 0;
settings.img_width = (BUZ_MAX_WIDTH == 720) ? 704 : BUZ_MAX_WIDTH;
} else {
settings.img_x = 0;
settings.img_width = BUZ_MAX_WIDTH;
}

/* check */
res = zoran_check_jpg_settings(zr, &settings);
res = zoran_check_jpg_settings(zr, &settings, 0);
if (res)
goto sfmtjpg_unlock_and_return;

Expand Down Expand Up @@ -3216,7 +3227,7 @@ static int zoran_s_crop(struct file *file, void *__fh, struct v4l2_crop *crop)
settings.img_height = crop->c.height;

/* check validity */
res = zoran_check_jpg_settings(zr, &settings);
res = zoran_check_jpg_settings(zr, &settings, 0);
if (res)
goto scrop_unlock_and_return;

Expand Down Expand Up @@ -3278,7 +3289,7 @@ static int zoran_s_jpegcomp(struct file *file, void *__fh,
goto sjpegc_unlock_and_return;
}

res = zoran_check_jpg_settings(zr, &settings);
res = zoran_check_jpg_settings(zr, &settings, 0);
if (res)
goto sjpegc_unlock_and_return;
if (!fh->jpg_buffers.allocated)
Expand Down

0 comments on commit 1c43de8

Please sign in to comment.