u32 au_params = BLACKBIRD_AUDIO_BITS_STEREO | 
au_params = BLACKBIRD_AUDIO_BITS_STEREO | 
static void blackbird_set_default_params(struct cx8802_dev *dev){	struct v4l2_mpeg_compression *params = &dev->params;	/* assign stream type */	if( params->st_type >= ARRAY_SIZE(mpeg_stream_types) )		params->st_type = V4L2_MPEG_PS_2;	if( params->st_type == V4L2_MPEG_SS_1 )		params->vi_type = V4L2_MPEG_VI_1;	else		params->vi_type = V4L2_MPEG_VI_2;	blackbird_api_cmd(dev, BLACKBIRD_API_SET_STREAM_TYPE, 1, 0, mpeg_stream_types[params->st_type]);	/* assign framerate */	if( params->vi_frame_rate <= 25 )	{		params->vi_frame_rate = 25;		blackbird_api_cmd(dev, BLACKBIRD_API_SET_FRAMERATE, 1, 0, BLACKBIRD_FRAMERATE_PAL_25);	}	else	{		params->vi_frame_rate = 30;		blackbird_api_cmd(dev, BLACKBIRD_API_SET_FRAMERATE, 1, 0, BLACKBIRD_FRAMERATE_NTSC_30);	}	/* assign aspect ratio */	if( params->vi_aspect_ratio >= ARRAY_SIZE(mpeg_stream_ratios) )		params->vi_aspect_ratio = V4L2_MPEG_ASPECT_4_3;	blackbird_api_cmd(dev, BLACKBIRD_API_SET_ASPECT_RATIO, 1, 0, mpeg_stream_ratios[params->vi_aspect_ratio]);	/* assign gop properties */	blackbird_api_cmd(dev, BLACKBIRD_API_SET_GOP_STRUCTURE, 2, 0, params->vi_frames_per_gop, params->vi_bframes_count+1);	/* assign gop closure */	blackbird_api_cmd(dev, BLACKBIRD_API_SET_GOP_CLOSURE, 1, 0, params->closed_gops);	/* assign 3 2 pulldown */	blackbird_api_cmd(dev, BLACKBIRD_API_SET_3_2_PULLDOWN, 1, 0, params->pulldown);	/* make sure the params are within bounds */	if( params->st_bitrate.mode >= ARRAY_SIZE(mpeg_video_bitrates) )		params->vi_bitrate.mode = V4L2_BITRATE_NONE;	if( params->vi_bitrate.mode >= ARRAY_SIZE(mpeg_video_bitrates) )		params->vi_bitrate.mode = V4L2_BITRATE_NONE;	if( params->au_bitrate.mode >= ARRAY_SIZE(mpeg_video_bitrates) )		params->au_bitrate.mode = V4L2_BITRATE_NONE;	/* assign audio properties */	/* note: it's not necessary to set the samplerate, the mpeg encoder seems to autodetect/adjust */	u32 au_params = BLACKBIRD_AUDIO_BITS_STEREO |			/* BLACKBIRD_AUDIO_BITS_BOUND_4 | */			BLACKBIRD_AUDIO_BITS_EMPHASIS_NONE |			BLACKBIRD_AUDIO_BITS_CRC_OFF |			BLACKBIRD_AUDIO_BITS_COPYRIGHT_OFF |			BLACKBIRD_AUDIO_BITS_COPY |			0;	if( params->au_sample_rate <= 32000 )	{		params->au_sample_rate = 32000;		au_params |= BLACKBIRD_AUDIO_BITS_32000HZ;	}	else if( params->au_sample_rate <= 44100 )	{		params->au_sample_rate = 44100;		au_params |= BLACKBIRD_AUDIO_BITS_44100HZ;	}	else	{		params->au_sample_rate = 48000;		au_params |= BLACKBIRD_AUDIO_BITS_48000HZ;	}	if( params->au_type == V4L2_MPEG_AU_2_I )	{		au_params |= BLACKBIRD_AUDIO_BITS_LAYER_1;	}	else	{		/* TODO: try to handle the other formats more gracefully */		params->au_type = V4L2_MPEG_AU_2_II;		au_params |= BLACKBIRD_AUDIO_BITS_LAYER_2;	}	if( params->au_bitrate.mode )	{		if( params->au_bitrate.mode == V4L2_BITRATE_CBR )			params->au_bitrate.max = params->vi_bitrate.target;		else			params->au_bitrate.target = params->vi_bitrate.max;		int layer = params->au_type;		if( params->au_bitrate.target == 0 )		{			/* TODO: use the minimum possible bitrate instead of 0 ? */			au_params |= 0;		}		else if( params->au_bitrate.target >=		         mpeg_audio_bitrates[BITRATES_SIZE-1].layer[layer].rate )		{			/* clamp the bitrate to the max supported by the standard */			params->au_bitrate.target = mpeg_audio_bitrates[BITRATES_SIZE-1].layer[layer].rate;			params->au_bitrate.max = params->au_bitrate.target;			au_params |= mpeg_audio_bitrates[BITRATES_SIZE-1].layer[layer].bits;		}		else		{			/* round up to the nearest supported bitrate */			int i;			for(i = 1; i < BITRATES_SIZE; i++)			{				if( params->au_bitrate.target > mpeg_audio_bitrates[i-1].layer[layer].rate &&				    params->au_bitrate.target <= mpeg_audio_bitrates[i].layer[layer].rate )				{					params->au_bitrate.target = mpeg_audio_bitrates[i].layer[layer].rate;					params->au_bitrate.max = params->au_bitrate.target;					au_params |= mpeg_audio_bitrates[i].layer[layer].bits;					break;				}			}		}	}	else	{		/* TODO: ??? */		params->au_bitrate.target = params->au_bitrate.max = 0;		au_params |= 0;	}	blackbird_api_cmd(dev, BLACKBIRD_API_SET_AUDIO_PARAMS, 1, 0, au_params );	/* assign bitrates */	if( params->vi_bitrate.mode )	{		/* bitrate is set, let's figure out the cbr/vbr mess */		if( params->vi_bitrate.max < params->vi_bitrate.target )		{			if( params->vi_bitrate.mode == V4L2_BITRATE_CBR )				params->vi_bitrate.max = params->vi_bitrate.target;			else				params->vi_bitrate.target = params->vi_bitrate.max;		}	}	else	{		if( params->st_bitrate.max < params->st_bitrate.target )		{			if( params->st_bitrate.mode == V4L2_BITRATE_VBR )				params->st_bitrate.target = params->st_bitrate.max;			else				params->st_bitrate.max = params->st_bitrate.target;		}		/* calculate vi_bitrate = st_bitrate - au_bitrate */		params->vi_bitrate.max = params->st_bitrate.max - params->au_bitrate.max;		params->vi_bitrate.target = params->st_bitrate.target - params->au_bitrate.target;	}	blackbird_api_cmd(dev, BLACKBIRD_API_SET_VIDEO_BITRATE, 4, 0,				mpeg_video_bitrates[params->vi_bitrate.mode],				params->vi_bitrate.target * 1000, /* kbps -> bps */				params->vi_bitrate.max * 1000 / BLACKBIRD_PEAK_RATE_DIVISOR, /* peak/400 */				BLACKBIRD_MUX_RATE_DEFAULT /*, 0x70*/); /* encoding buffer, ckennedy */	/* TODO: implement the stream ID stuff:		ts_pid_pmt, ts_pid_audio, ts_pid_video, ts_pid_pcr,		ps_size, au_pesid, vi_pesid 	*/}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/c5df599b67b5a061d28a2154a49f9704e0d1040b/cx88-blackbird.c/clean/drivers/media/video/cx88/cx88-blackbird.c