kernels/linux-2.4.0/drivers/media/video/buz.c
/* Check a zoran_params struct for correctness, insert default params */
Check a zoran_params struct for correctness, insert default params
Check a zoran_params struct for correctness insert default params
static int zoran_check_params(struct zoran *zr, struct zoran_params *params)
{
	int err = 0, err0 = 0;
	params->major_version = MAJOR_VERSION;
	params->minor_version = MINOR_VERSION;
	if (params->input != 0 && params->input != 1) {
		err++;
	}
	if (params->norm != VIDEO_MODE_PAL && params->norm != VIDEO_MODE_NTSC) {
		err++;
	}
	switch (params->decimation) {
	case 1:
		params->HorDcm = 1;
		params->VerDcm = 1;
		params->TmpDcm = 1;
		params->field_per_buff = 2;
		params->img_x = 0;
		params->img_y = 0;
		params->img_width = 720;
		params->img_height = tvnorms[params->norm].Ha / 2;
		break;
	case 2:
		params->HorDcm = 2;
		params->VerDcm = 1;
		params->TmpDcm = 2;
		params->field_per_buff = 1;
		params->img_x = 8;
		params->img_y = 0;
		params->img_width = 704;
		params->img_height = tvnorms[params->norm].Ha / 2;
		break;
	case 4:
		params->HorDcm = 4;
		params->VerDcm = 2;
		params->TmpDcm = 2;
		params->field_per_buff = 1;
		params->img_x = 8;
		params->img_y = 0;
		params->img_width = 704;
		params->img_height = tvnorms[params->norm].Ha / 2;
		break;
	case 0:
		if (params->HorDcm != 1 && params->HorDcm != 2 && params->HorDcm != 4)
			err0++;
		if (params->VerDcm != 1 && params->VerDcm != 2)
			err0++;
		if (params->TmpDcm != 1 && params->TmpDcm != 2)
			err0++;
		if (params->field_per_buff != 1 && params->field_per_buff != 2)
			err0++;
		if (params->img_x < 0)
			err0++;
		if (params->img_y < 0)
			err0++;
		if (params->img_width < 0)
			err0++;
		if (params->img_height < 0)
			err0++;
		if (params->img_x + params->img_width > 720)
			err0++;
		if (params->img_y + params->img_height > tvnorms[params->norm].Ha / 2)
			err0++;
		if (params->img_width % (16 * params->HorDcm) != 0)
			err0++;
		if (params->img_height % (8 * params->VerDcm) != 0)
			err0++;
		if (err0) {
			err++;
		}
		break;
	default:
		err++;
		break;
	}
	if (params->quality > 100)
		params->quality = 100;
	if (params->quality < 5)
		params->quality = 5;
	if (params->APPn < 0)
		params->APPn = 0;
	if (params->APPn > 15)
		params->APPn = 15;
	if (params->APP_len < 0)
		params->APP_len = 0;
	if (params->APP_len > 60)
		params->APP_len = 60;
	if (params->COM_len < 0)
		params->COM_len = 0;
	if (params->COM_len > 60)
		params->COM_len = 60;
	if (err)
		return -EINVAL;
	return 0;
}
static int zoran_check_params ( struct zoran * zr , struct zoran_params * params ) { int err = 0 , err0 = 0 ; params -> major_version = MAJOR_VERSION ; params -> minor_version = MINOR_VERSION ; if ( params -> input != 0 && params -> input != 1 ) { err ++ ; } if ( params -> norm != VIDEO_MODE_PAL && params -> norm != VIDEO_MODE_NTSC ) { err ++ ; } switch ( params -> decimation ) { case 1 : params -> HorDcm = 1 ; params -> VerDcm = 1 ; params -> TmpDcm = 1 ; params -> field_per_buff = 2 ; params -> img_x = 0 ; params -> img_y = 0 ; params -> img_width = 720 ; params -> img_height = tvnorms [ params -> norm ] . Ha / 2 ; break ; case 2 : params -> HorDcm = 2 ; params -> VerDcm = 1 ; params -> TmpDcm = 2 ; params -> field_per_buff = 1 ; params -> img_x = 8 ; params -> img_y = 0 ; params -> img_width = 704 ; params -> img_height = tvnorms [ params -> norm ] . Ha / 2 ; break ; case 4 : params -> HorDcm = 4 ; params -> VerDcm = 2 ; params -> TmpDcm = 2 ; params -> field_per_buff = 1 ; params -> img_x = 8 ; params -> img_y = 0 ; params -> img_width = 704 ; params -> img_height = tvnorms [ params -> norm ] . Ha / 2 ; break ; case 0 : if ( params -> HorDcm != 1 && params -> HorDcm != 2 && params -> HorDcm != 4 ) err0 ++ ; if ( params -> VerDcm != 1 && params -> VerDcm != 2 ) err0 ++ ; if ( params -> TmpDcm != 1 && params -> TmpDcm != 2 ) err0 ++ ; if ( params -> field_per_buff != 1 && params -> field_per_buff != 2 ) err0 ++ ; if ( params -> img_x < 0 ) err0 ++ ; if ( params -> img_y < 0 ) err0 ++ ; if ( params -> img_width < 0 ) err0 ++ ; if ( params -> img_height < 0 ) err0 ++ ; if ( params -> img_x + params -> img_width > 720 ) err0 ++ ; if ( params -> img_y + params -> img_height > tvnorms [ params -> norm ] . Ha / 2 ) err0 ++ ; if ( params -> img_width % ( 16 * params -> HorDcm ) != 0 ) err0 ++ ; if ( params -> img_height % ( 8 * params -> VerDcm ) != 0 ) err0 ++ ; if ( err0 ) { err ++ ; } break ; default : err ++ ; break ; } if ( params -> quality > 100 ) params -> quality = 100 ; if ( params -> quality < 5 ) params -> quality = 5 ; if ( params -> APPn < 0 ) params -> APPn = 0 ; if ( params -> APPn > 15 ) params -> APPn = 15 ; if ( params -> APP_len < 0 ) params -> APP_len = 0 ; if ( params -> APP_len > 60 ) params -> APP_len = 60 ; if ( params -> COM_len < 0 ) params -> COM_len = 0 ; if ( params -> COM_len > 60 ) params -> COM_len = 60 ; if ( err ) return - EINVAL ; return 0 ; }
Check a zoran_params struct for correctness, insert default params
Check a zoran_params struct for correctness insert default params
/* insert constant params */ /* Check input and norm */ /* Check decimation, set default values for decimation = 1, 2, 4 */ /* We have to check the data the user has set */