Enscript Output

extractedLnx/linux-2.6.26/drivers/media/video/ivtv/ivtv-ioctl.c_ivtv_v4l2_ioctls.c

int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void *arg)
{
	struct ivtv_open_id *id = NULL;
	struct yuv_playback_info *yi = &itv->yuv_info;
	u32 data[CX2341X_MBOX_MAX_DATA];
	int streamtype = 0;

	if (filp) {
		id = (struct ivtv_open_id *)filp->private_data;
		streamtype = id->type;
	}

	switch (cmd) {
	case VIDIOC_G_PRIORITY:
	{
		enum v4l2_priority *p = arg;

		*p = v4l2_prio_max(&itv->prio);
		break;
	}

	case VIDIOC_S_PRIORITY:
	{
		enum v4l2_priority *prio = arg;

		return v4l2_prio_change(&itv->prio, &id->prio, *prio);
	}

	case VIDIOC_QUERYCAP:{
		struct v4l2_capability *vcap = arg;

		memset(vcap, 0, sizeof(*vcap));
		strlcpy(vcap->driver, IVTV_DRIVER_NAME, sizeof(vcap->driver));
		strlcpy(vcap->card, itv->card_name, sizeof(vcap->card));
		strlcpy(vcap->bus_info, pci_name(itv->dev), sizeof(vcap->bus_info));
		vcap->version = IVTV_DRIVER_VERSION; 	    /* version */
		vcap->capabilities = itv->v4l2_cap; 	    /* capabilities */

		/* reserved.. must set to 0! */
		vcap->reserved[0] = vcap->reserved[1] =
			vcap->reserved[2] = vcap->reserved[3] = 0;
		break;
	}

	case VIDIOC_ENUMAUDIO:{
		struct v4l2_audio *vin = arg;

		return ivtv_get_audio_input(itv, vin->index, vin);
	}

	case VIDIOC_G_AUDIO:{
		struct v4l2_audio *vin = arg;

		vin->index = itv->audio_input;
		return ivtv_get_audio_input(itv, vin->index, vin);
	}

	case VIDIOC_S_AUDIO:{
		struct v4l2_audio *vout = arg;

		if (vout->index >= itv->nof_audio_inputs)
			return -EINVAL;
		itv->audio_input = vout->index;
		ivtv_audio_set_io(itv);
		break;
	}

	case VIDIOC_ENUMAUDOUT:{
		struct v4l2_audioout *vin = arg;

		/* set it to defaults from our table */
		return ivtv_get_audio_output(itv, vin->index, vin);
	}

	case VIDIOC_G_AUDOUT:{
		struct v4l2_audioout *vin = arg;

		vin->index = 0;
		return ivtv_get_audio_output(itv, vin->index, vin);
	}

	case VIDIOC_S_AUDOUT:{
		struct v4l2_audioout *vout = arg;

		return ivtv_get_audio_output(itv, vout->index, vout);
	}

	case VIDIOC_ENUMINPUT:{
		struct v4l2_input *vin = arg;

		/* set it to defaults from our table */
		return ivtv_get_input(itv, vin->index, vin);
	}

	case VIDIOC_ENUMOUTPUT:{
		struct v4l2_output *vout = arg;

		return ivtv_get_output(itv, vout->index, vout);
	}

	case VIDIOC_TRY_FMT:
	case VIDIOC_S_FMT: {
		struct v4l2_format *fmt = arg;

		return ivtv_try_or_set_fmt(itv, id->type, fmt, cmd == VIDIOC_S_FMT);
	}

	case VIDIOC_G_FMT: {
		struct v4l2_format *fmt = arg;
		int type = fmt->type;

		memset(fmt, 0, sizeof(*fmt));
		fmt->type = type;
		return ivtv_get_fmt(itv, id->type, fmt);
	}

	case VIDIOC_CROPCAP: {
		struct v4l2_cropcap *cropcap = arg;

		if (cropcap->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
			return -EINVAL;
		cropcap->bounds.top = cropcap->bounds.left = 0;
		cropcap->bounds.width = 720;
		if (cropcap->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
			cropcap->bounds.height = itv->is_50hz ? 576 : 480;
			cropcap->pixelaspect.numerator = itv->is_50hz ? 59 : 10;
			cropcap->pixelaspect.denominator = itv->is_50hz ? 54 : 11;
		} else if (streamtype == IVTV_DEC_STREAM_TYPE_YUV) {
			if (yi->track_osd) {
				cropcap->bounds.width = yi->osd_full_w;
				cropcap->bounds.height = yi->osd_full_h;
			} else {
				cropcap->bounds.width = 720;
				cropcap->bounds.height =
						itv->is_out_50hz ? 576 : 480;
			}
			cropcap->pixelaspect.numerator = itv->is_out_50hz ? 59 : 10;
			cropcap->pixelaspect.denominator = itv->is_out_50hz ? 54 : 11;
		} else {
			cropcap->bounds.height = itv->is_out_50hz ? 576 : 480;
			cropcap->pixelaspect.numerator = itv->is_out_50hz ? 59 : 10;
			cropcap->pixelaspect.denominator = itv->is_out_50hz ? 54 : 11;
		}
		cropcap->defrect = cropcap->bounds;
		return 0;
	}

	case VIDIOC_S_CROP: {
		struct v4l2_crop *crop = arg;

		if (crop->type == V4L2_BUF_TYPE_VIDEO_OUTPUT &&
		    (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) {
			if (streamtype == IVTV_DEC_STREAM_TYPE_YUV) {
				yi->main_rect = crop->c;
				return 0;
			} else {
				if (!ivtv_vapi(itv, CX2341X_OSD_SET_FRAMEBUFFER_WINDOW, 4,
					crop->c.width, crop->c.height, crop->c.left, crop->c.top)) {
					itv->main_rect = crop->c;
					return 0;
				}
			}
			return -EINVAL;
		}
		return -EINVAL;
	}

	case VIDIOC_G_CROP: {
		struct v4l2_crop *crop = arg;

		if (crop->type == V4L2_BUF_TYPE_VIDEO_OUTPUT &&
		    (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) {
			if (streamtype == IVTV_DEC_STREAM_TYPE_YUV)
				crop->c = yi->main_rect;
			else
				crop->c = itv->main_rect;
			return 0;
		}
		return -EINVAL;
	}

	case VIDIOC_ENUM_FMT: {
		static struct v4l2_fmtdesc formats[] = {
			{ 0, 0, 0,
			  "HM12 (YUV 4:2:0)", V4L2_PIX_FMT_HM12,
			  { 0, 0, 0, 0 }
			},
			{ 1, 0, V4L2_FMT_FLAG_COMPRESSED,
			  "MPEG", V4L2_PIX_FMT_MPEG,
			  { 0, 0, 0, 0 }
			}
		};
		struct v4l2_fmtdesc *fmt = arg;
		enum v4l2_buf_type type = fmt->type;

		switch (type) {
		case V4L2_BUF_TYPE_VIDEO_CAPTURE:
			break;
		case V4L2_BUF_TYPE_VIDEO_OUTPUT:
			if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT))
				return -EINVAL;
			break;
		default:
			return -EINVAL;
		}
		if (fmt->index > 1)
			return -EINVAL;
		*fmt = formats[fmt->index];
		fmt->type = type;
		return 0;
	}

	case VIDIOC_G_INPUT:{
		*(int *)arg = itv->active_input;
		break;
	}

	case VIDIOC_S_INPUT:{
		int inp = *(int *)arg;

		if (inp < 0 || inp >= itv->nof_inputs)
			return -EINVAL;

		if (inp == itv->active_input) {
			IVTV_DEBUG_INFO("Input unchanged\n");
			break;
		}
		if (atomic_read(&itv->capturing) > 0) {
			return -EBUSY;
		}
		IVTV_DEBUG_INFO("Changing input from %d to %d\n",
				itv->active_input, inp);

		itv->active_input = inp;
		/* Set the audio input to whatever is appropriate for the
		   input type. */
		itv->audio_input = itv->card->video_inputs[inp].audio_index;

		/* prevent others from messing with the streams until
		   we're finished changing inputs. */
		ivtv_mute(itv);
		ivtv_video_set_io(itv);
		ivtv_audio_set_io(itv);
		ivtv_unmute(itv);
		break;
	}

	case VIDIOC_G_OUTPUT:{
		if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT))
			return -EINVAL;
		*(int *)arg = itv->active_output;
		break;
	}

	case VIDIOC_S_OUTPUT:{
		int outp = *(int *)arg;
		struct v4l2_routing route;

		if (outp >= itv->card->nof_outputs)
			return -EINVAL;

		if (outp == itv->active_output) {
			IVTV_DEBUG_INFO("Output unchanged\n");
			break;
		}
		IVTV_DEBUG_INFO("Changing output from %d to %d\n",
			   itv->active_output, outp);

		itv->active_output = outp;
		route.input = SAA7127_INPUT_TYPE_NORMAL;
		route.output = itv->card->video_outputs[outp].video_output;
		ivtv_saa7127(itv, VIDIOC_INT_S_VIDEO_ROUTING, &route);
		break;
	}

	case VIDIOC_G_FREQUENCY:{
		struct v4l2_frequency *vf = arg;

		if (vf->tuner != 0)
			return -EINVAL;
		ivtv_call_i2c_clients(itv, cmd, arg);
		break;
	}

	case VIDIOC_S_FREQUENCY:{
		struct v4l2_frequency vf = *(struct v4l2_frequency *)arg;

		if (vf.tuner != 0)
			return -EINVAL;

		ivtv_mute(itv);
		IVTV_DEBUG_INFO("v4l2 ioctl: set frequency %d\n", vf.frequency);
		ivtv_call_i2c_clients(itv, cmd, &vf);
		ivtv_unmute(itv);
		break;
	}

	case VIDIOC_ENUMSTD:{
		struct v4l2_standard *vs = arg;
		int idx = vs->index;

		if (idx < 0 || idx >= ARRAY_SIZE(enum_stds))
			return -EINVAL;

		*vs = (enum_stds[idx].std & V4L2_STD_525_60) ?
				ivtv_std_60hz : ivtv_std_50hz;
		vs->index = idx;
		vs->id = enum_stds[idx].std;
		strlcpy(vs->name, enum_stds[idx].name, sizeof(vs->name));
		break;
	}

	case VIDIOC_G_STD:{
		*(v4l2_std_id *) arg = itv->std;
		break;
	}

	case VIDIOC_S_STD: {
		v4l2_std_id std = *(v4l2_std_id *) arg;

		if ((std & V4L2_STD_ALL) == 0)
			return -EINVAL;

		if (std == itv->std)
			break;

		if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags) ||
		    atomic_read(&itv->capturing) > 0 ||
		    atomic_read(&itv->decoding) > 0) {
			/* Switching standard would turn off the radio or mess
			   with already running streams, prevent that by
			   returning EBUSY. */
			return -EBUSY;
		}

		itv->std = std;
		itv->is_60hz = (std & V4L2_STD_525_60) ? 1 : 0;
		itv->params.is_50hz = itv->is_50hz = !itv->is_60hz;
		itv->params.width = 720;
		itv->params.height = itv->is_50hz ? 576 : 480;
		itv->vbi.count = itv->is_50hz ? 18 : 12;
		itv->vbi.start[0] = itv->is_50hz ? 6 : 10;
		itv->vbi.start[1] = itv->is_50hz ? 318 : 273;
		if (itv->hw_flags & IVTV_HW_CX25840) {
			itv->vbi.sliced_decoder_line_size = itv->is_60hz ? 272 : 284;
		}
		IVTV_DEBUG_INFO("Switching standard to %llx.\n", (unsigned long long)itv->std);

		/* Tuner */
		ivtv_call_i2c_clients(itv, VIDIOC_S_STD, &itv->std);

		if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) {
			/* set display standard */
			itv->std_out = std;
			itv->is_out_60hz = itv->is_60hz;
			itv->is_out_50hz = itv->is_50hz;
			ivtv_call_i2c_clients(itv, VIDIOC_INT_S_STD_OUTPUT, &itv->std_out);
			ivtv_vapi(itv, CX2341X_DEC_SET_STANDARD, 1, itv->is_out_50hz);
			itv->main_rect.left = itv->main_rect.top = 0;
			itv->main_rect.width = 720;
			itv->main_rect.height = itv->params.height;
			ivtv_vapi(itv, CX2341X_OSD_SET_FRAMEBUFFER_WINDOW, 4,
				720, itv->main_rect.height, 0, 0);
			yi->main_rect = itv->main_rect;
			if (!itv->osd_info) {
				yi->osd_full_w = 720;
				yi->osd_full_h = itv->is_out_50hz ? 576 : 480;
			}
		}
		break;
	}

	case VIDIOC_S_TUNER: {	/* Setting tuner can only set audio mode */
		struct v4l2_tuner *vt = arg;

		if (vt->index != 0)
			return -EINVAL;

		ivtv_call_i2c_clients(itv, VIDIOC_S_TUNER, vt);
		break;
	}

	case VIDIOC_G_TUNER: {
		struct v4l2_tuner *vt = arg;

		if (vt->index != 0)
			return -EINVAL;

		memset(vt, 0, sizeof(*vt));
		ivtv_call_i2c_clients(itv, VIDIOC_G_TUNER, vt);

		if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags)) {
			strlcpy(vt->name, "ivtv Radio Tuner", sizeof(vt->name));
			vt->type = V4L2_TUNER_RADIO;
		} else {
			strlcpy(vt->name, "ivtv TV Tuner", sizeof(vt->name));
			vt->type = V4L2_TUNER_ANALOG_TV;
		}
		break;
	}

	case VIDIOC_G_SLICED_VBI_CAP: {
		struct v4l2_sliced_vbi_cap *cap = arg;
		int set = itv->is_50hz ? V4L2_SLICED_VBI_625 : V4L2_SLICED_VBI_525;
		int f, l;
		enum v4l2_buf_type type = cap->type;

		memset(cap, 0, sizeof(*cap));
		cap->type = type;
		if (type == V4L2_BUF_TYPE_SLICED_VBI_CAPTURE) {
			for (f = 0; f < 2; f++) {
				for (l = 0; l < 24; l++) {
					if (valid_service_line(f, l, itv->is_50hz)) {
						cap->service_lines[f][l] = set;
					}
				}
			}
			return 0;
		}
		if (type == V4L2_BUF_TYPE_SLICED_VBI_OUTPUT) {
			if (!(itv->v4l2_cap & V4L2_CAP_SLICED_VBI_OUTPUT))
				return -EINVAL;
			if (itv->is_60hz) {
				cap->service_lines[0][21] = V4L2_SLICED_CAPTION_525;
				cap->service_lines[1][21] = V4L2_SLICED_CAPTION_525;
			} else {
				cap->service_lines[0][23] = V4L2_SLICED_WSS_625;
				cap->service_lines[0][16] = V4L2_SLICED_VPS;
			}
			return 0;
		}
		return -EINVAL;
	}

	case VIDIOC_G_ENC_INDEX: {
		struct v4l2_enc_idx *idx = arg;
		struct v4l2_enc_idx_entry *e = idx->entry;
		int entries;
		int i;

		entries = (itv->pgm_info_write_idx + IVTV_MAX_PGM_INDEX - itv->pgm_info_read_idx) %
					IVTV_MAX_PGM_INDEX;
		if (entries > V4L2_ENC_IDX_ENTRIES)
			entries = V4L2_ENC_IDX_ENTRIES;
		idx->entries = 0;
		for (i = 0; i < entries; i++) {
			*e = itv->pgm_info[(itv->pgm_info_read_idx + i) % IVTV_MAX_PGM_INDEX];
			if ((e->flags & V4L2_ENC_IDX_FRAME_MASK) <= V4L2_ENC_IDX_FRAME_B) {
				idx->entries++;
				e++;
			}
		}
		itv->pgm_info_read_idx = (itv->pgm_info_read_idx + idx->entries) % IVTV_MAX_PGM_INDEX;
		break;
	}

	case VIDIOC_ENCODER_CMD:
	case VIDIOC_TRY_ENCODER_CMD: {
		struct v4l2_encoder_cmd *enc = arg;
		int try = cmd == VIDIOC_TRY_ENCODER_CMD;

		memset(&enc->raw, 0, sizeof(enc->raw));
		switch (enc->cmd) {
		case V4L2_ENC_CMD_START:
			IVTV_DEBUG_IOCTL("V4L2_ENC_CMD_START\n");
			enc->flags = 0;
			if (try)
				return 0;
			return ivtv_start_capture(id);

		case V4L2_ENC_CMD_STOP:
			IVTV_DEBUG_IOCTL("V4L2_ENC_CMD_STOP\n");
			enc->flags &= V4L2_ENC_CMD_STOP_AT_GOP_END;
			if (try)
				return 0;
			ivtv_stop_capture(id, enc->flags & V4L2_ENC_CMD_STOP_AT_GOP_END);
			return 0;

		case V4L2_ENC_CMD_PAUSE:
			IVTV_DEBUG_IOCTL("V4L2_ENC_CMD_PAUSE\n");
			enc->flags = 0;
			if (try)
				return 0;
			if (!atomic_read(&itv->capturing))
				return -EPERM;
			if (test_and_set_bit(IVTV_F_I_ENC_PAUSED, &itv->i_flags))
				return 0;
			ivtv_mute(itv);
			ivtv_vapi(itv, CX2341X_ENC_PAUSE_ENCODER, 1, 0);
			break;

		case V4L2_ENC_CMD_RESUME:
			IVTV_DEBUG_IOCTL("V4L2_ENC_CMD_RESUME\n");
			enc->flags = 0;
			if (try)
				return 0;
			if (!atomic_read(&itv->capturing))
				return -EPERM;
			if (!test_and_clear_bit(IVTV_F_I_ENC_PAUSED, &itv->i_flags))
				return 0;
			ivtv_vapi(itv, CX2341X_ENC_PAUSE_ENCODER, 1, 1);
			ivtv_unmute(itv);
			break;
		default:
			IVTV_DEBUG_IOCTL("Unknown cmd %d\n", enc->cmd);
			return -EINVAL;
		}
		break;
	}

	case VIDIOC_G_FBUF: {
		struct v4l2_framebuffer *fb = arg;
		int pixfmt;
		static u32 pixel_format[16] = {
			V4L2_PIX_FMT_PAL8, /* Uses a 256-entry RGB colormap */
			V4L2_PIX_FMT_RGB565,
			V4L2_PIX_FMT_RGB555,
			V4L2_PIX_FMT_RGB444,
			V4L2_PIX_FMT_RGB32,
			0,
			0,
			0,
			V4L2_PIX_FMT_PAL8, /* Uses a 256-entry YUV colormap */
			V4L2_PIX_FMT_YUV565,
			V4L2_PIX_FMT_YUV555,
			V4L2_PIX_FMT_YUV444,
			V4L2_PIX_FMT_YUV32,
			0,
			0,
			0,
		};

		memset(fb, 0, sizeof(*fb));
		if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT_OVERLAY))
			return -EINVAL;
		fb->capability = V4L2_FBUF_CAP_EXTERNOVERLAY | V4L2_FBUF_CAP_CHROMAKEY |
			V4L2_FBUF_CAP_GLOBAL_ALPHA;
		ivtv_vapi_result(itv, data, CX2341X_OSD_GET_STATE, 0);
		data[0] |= (read_reg(0x2a00) >> 7) & 0x40;
		pixfmt = (data[0] >> 3) & 0xf;
		fb->fmt.pixelformat = pixel_format[pixfmt];
		fb->fmt.width = itv->osd_rect.width;
		fb->fmt.height = itv->osd_rect.height;
		fb->base = (void *)itv->osd_video_pbase;
		if (itv->osd_chroma_key_state)
			fb->flags |= V4L2_FBUF_FLAG_CHROMAKEY;
		if (itv->osd_global_alpha_state)
			fb->flags |= V4L2_FBUF_FLAG_GLOBAL_ALPHA;
		pixfmt &= 7;
		/* no local alpha for RGB565 or unknown formats */
		if (pixfmt == 1 || pixfmt > 4)
			break;
		/* 16-bit formats have inverted local alpha */
		if (pixfmt == 2 || pixfmt == 3)
			fb->capability |= V4L2_FBUF_CAP_LOCAL_INV_ALPHA;
		else
			fb->capability |= V4L2_FBUF_CAP_LOCAL_ALPHA;
		if (itv->osd_local_alpha_state) {
			/* 16-bit formats have inverted local alpha */
			if (pixfmt == 2 || pixfmt == 3)
				fb->flags |= V4L2_FBUF_FLAG_LOCAL_INV_ALPHA;
			else
				fb->flags |= V4L2_FBUF_FLAG_LOCAL_ALPHA;
		}
		if (yi->track_osd)
			fb->flags |= V4L2_FBUF_FLAG_OVERLAY;
		break;
	}

	case VIDIOC_S_FBUF: {
		struct v4l2_framebuffer *fb = arg;

		if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT_OVERLAY))
			return -EINVAL;
		itv->osd_global_alpha_state = (fb->flags & V4L2_FBUF_FLAG_GLOBAL_ALPHA) != 0;
		itv->osd_local_alpha_state =
			(fb->flags & (V4L2_FBUF_FLAG_LOCAL_ALPHA|V4L2_FBUF_FLAG_LOCAL_INV_ALPHA)) != 0;
		itv->osd_chroma_key_state = (fb->flags & V4L2_FBUF_FLAG_CHROMAKEY) != 0;
		ivtv_set_osd_alpha(itv);
		yi->track_osd = (fb->flags & V4L2_FBUF_FLAG_OVERLAY) != 0;
		break;
	}

	case VIDIOC_OVERLAY: {
		int *on = arg;

		if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT_OVERLAY))
			return -EINVAL;
		ivtv_vapi(itv, CX2341X_OSD_SET_STATE, 1, *on != 0);
		break;
	}

	case VIDIOC_LOG_STATUS:
	{
		int has_output = itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT;
		struct v4l2_input vidin;
		struct v4l2_audio audin;
		int i;

		IVTV_INFO("=================  START STATUS CARD #%d  =================\n", itv->num);
		IVTV_INFO("Version: %s Card: %s\n", IVTV_VERSION, itv->card_name);
		if (itv->hw_flags & IVTV_HW_TVEEPROM) {
			struct tveeprom tv;

			ivtv_read_eeprom(itv, &tv);
		}
		ivtv_call_i2c_clients(itv, VIDIOC_LOG_STATUS, NULL);
		ivtv_get_input(itv, itv->active_input, &vidin);
		ivtv_get_audio_input(itv, itv->audio_input, &audin);
		IVTV_INFO("Video Input:  %s\n", vidin.name);
		IVTV_INFO("Audio Input:  %s%s\n", audin.name,
			(itv->dualwatch_stereo_mode & ~0x300) == 0x200 ? " (Bilingual)" : "");
		if (has_output) {
			struct v4l2_output vidout;
			struct v4l2_audioout audout;
			int mode = itv->output_mode;
			static const char * const output_modes[5] = {
				"None",
				"MPEG Streaming",
				"YUV Streaming",
				"YUV Frames",
				"Passthrough",
			};
			static const char * const audio_modes[5] = {
				"Stereo",
				"Left",
				"Right",
				"Mono",
				"Swapped"
			};
			static const char * const alpha_mode[4] = {
				"None",
				"Global",
				"Local",
				"Global and Local"
			};
			static const char * const pixel_format[16] = {
				"ARGB Indexed",
				"RGB 5:6:5",
				"ARGB 1:5:5:5",
				"ARGB 1:4:4:4",
				"ARGB 8:8:8:8",
				"5",
				"6",
				"7",
				"AYUV Indexed",
				"YUV 5:6:5",
				"AYUV 1:5:5:5",
				"AYUV 1:4:4:4",
				"AYUV 8:8:8:8",
				"13",
				"14",
				"15",
			};

			ivtv_get_output(itv, itv->active_output, &vidout);
			ivtv_get_audio_output(itv, 0, &audout);
			IVTV_INFO("Video Output: %s\n", vidout.name);
			IVTV_INFO("Audio Output: %s (Stereo/Bilingual: %s/%s)\n", audout.name,
				audio_modes[itv->audio_stereo_mode],
				audio_modes[itv->audio_bilingual_mode]);
			if (mode < 0 || mode > OUT_PASSTHROUGH)
				mode = OUT_NONE;
			IVTV_INFO("Output Mode:  %s\n", output_modes[mode]);
			ivtv_vapi_result(itv, data, CX2341X_OSD_GET_STATE, 0);
			data[0] |= (read_reg(0x2a00) >> 7) & 0x40;
			IVTV_INFO("Overlay:      %s, Alpha: %s, Pixel Format: %s\n",
				data[0] & 1 ? "On" : "Off",
				alpha_mode[(data[0] >> 1) & 0x3],
				pixel_format[(data[0] >> 3) & 0xf]);
		}
		IVTV_INFO("Tuner:  %s\n",
			test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags) ? "Radio" : "TV");
		cx2341x_log_status(&itv->params, itv->name);
		IVTV_INFO("Status flags:    0x%08lx\n", itv->i_flags);
		for (i = 0; i < IVTV_MAX_STREAMS; i++) {
			struct ivtv_stream *s = &itv->streams[i];

			if (s->v4l2dev == NULL || s->buffers == 0)
				continue;
			IVTV_INFO("Stream %s: status 0x%04lx, %d%% of %d KiB (%d buffers) in use\n", s->name, s->s_flags,
					(s->buffers - s->q_free.buffers) * 100 / s->buffers,
					(s->buffers * s->buf_size) / 1024, s->buffers);
		}
		IVTV_INFO("Read MPG/VBI: %lld/%lld bytes\n", (long long)itv->mpg_data_received, (long long)itv->vbi_data_inserted);
		IVTV_INFO("==================  END STATUS CARD #%d  ==================\n", itv->num);
		break;
	}

	default:
		return -EINVAL;
	}
	return 0;
}

Generated by GNU enscript 1.6.4.