Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c5874c92 authored by Ian Armstrong's avatar Ian Armstrong Committed by Mauro Carvalho Chehab
Browse files

[media] ivtv: Internally separate encoder & decoder standard setting



Internally separates the setting of the broadcast standard for the encoder &
decoder. Externally there's no change in functionality.

[awalls@md.metrocast.net: Edited to fix a checkpatch gripe about multiple
assignment and to remove a now unused DEFINE_WAIT() due to this patch]

Signed-off-by: default avatarIan Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: default avatarAndy Walls <awalls@md.metrocast.net>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 6600cc30
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -1328,6 +1328,8 @@ int ivtv_init_on_first_open(struct ivtv *itv)
	if (!itv->has_cx23415)
		write_reg_sync(0x03, IVTV_REG_DMACONTROL);

	ivtv_s_std_enc(itv, &itv->tuner_std);

	/* Default interrupts enabled. For the PVR350 this includes the
	   decoder VSYNC interrupt, which is always on. It is not only used
	   during decoding but also by the OSD.
@@ -1336,12 +1338,10 @@ int ivtv_init_on_first_open(struct ivtv *itv)
	if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) {
		ivtv_clear_irq_mask(itv, IVTV_IRQ_MASK_INIT | IVTV_IRQ_DEC_VSYNC);
		ivtv_set_osd_alpha(itv);
	}
	else
		ivtv_s_std_dec(itv, &itv->tuner_std);
	} else {
		ivtv_clear_irq_mask(itv, IVTV_IRQ_MASK_INIT);

	/* For cards with video out, this call needs interrupts enabled */
	ivtv_s_std(NULL, &fh, &itv->tuner_std);
	}

	/* Setup initial controls */
	cx2341x_handler_setup(&itv->cxhdl);
+7 −4
Original line number Diff line number Diff line
@@ -280,8 +280,6 @@ int ivtv_firmware_restart(struct ivtv *itv)
{
	int rc = 0;
	v4l2_std_id std;
	struct ivtv_open_id fh;
	fh.itv = itv;

	if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)
		/* Display test image during restart */
@@ -301,14 +299,19 @@ int ivtv_firmware_restart(struct ivtv *itv)
	/* Allow settings to reload */
	ivtv_mailbox_cache_invalidate(itv);

	/* Restore video standard */
	/* Restore encoder video standard */
	std = itv->std;
	itv->std = 0;
	ivtv_s_std(NULL, &fh, &std);
	ivtv_s_std_enc(itv, &std);

	if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) {
		ivtv_init_mpeg_decoder(itv);

		/* Restore decoder video standard */
		std = itv->std_out;
		itv->std_out = 0;
		ivtv_s_std_dec(itv, &std);

		/* Restore framebuffer if active */
		if (itv->ivtvfb_restore)
			itv->ivtvfb_restore(itv);
+70 −59
Original line number Diff line number Diff line
@@ -1071,28 +1071,8 @@ static int ivtv_g_std(struct file *file, void *fh, v4l2_std_id *std)
	return 0;
}

int ivtv_s_std(struct file *file, void *fh, v4l2_std_id *std)
void ivtv_s_std_enc(struct ivtv *itv, v4l2_std_id *std)
{
	DEFINE_WAIT(wait);
	struct ivtv *itv = fh2id(fh)->itv;
	struct yuv_playback_info *yi = &itv->yuv_info;
	int f;

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

	if (*std == itv->std)
		return 0;

	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->is_50hz = !itv->is_60hz;
@@ -1106,16 +1086,20 @@ int ivtv_s_std(struct file *file, void *fh, v4l2_std_id *std)
	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_all(itv, core, s_std, itv->std);
}

void ivtv_s_std_dec(struct ivtv *itv, v4l2_std_id *std)
{
	struct yuv_playback_info *yi = &itv->yuv_info;
	DEFINE_WAIT(wait);
	int f;

	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;
	itv->is_out_60hz = (*std & V4L2_STD_525_60) ? 1 : 0;
	itv->is_out_50hz = !itv->is_out_60hz;
	ivtv_call_all(itv, video, s_std_output, itv->std_out);

	/*
@@ -1137,9 +1121,10 @@ int ivtv_s_std(struct file *file, void *fh, v4l2_std_id *std)
		IVTV_WARN("Mode change failed to sync to decoder\n");

	ivtv_vapi(itv, CX2341X_DEC_SET_STANDARD, 1, itv->is_out_50hz);
		itv->main_rect.left = itv->main_rect.top = 0;
	itv->main_rect.left = 0;
	itv->main_rect.top = 0;
	itv->main_rect.width = 720;
		itv->main_rect.height = itv->cxhdl.height;
	itv->main_rect.height = itv->is_out_50hz ? 576 : 480;
	ivtv_vapi(itv, CX2341X_OSD_SET_FRAMEBUFFER_WINDOW, 4,
		720, itv->main_rect.height, 0, 0);
	yi->main_rect = itv->main_rect;
@@ -1148,6 +1133,32 @@ int ivtv_s_std(struct file *file, void *fh, v4l2_std_id *std)
		yi->osd_full_h = itv->is_out_50hz ? 576 : 480;
	}
}

int ivtv_s_std(struct file *file, void *fh, v4l2_std_id *std)
{
	struct ivtv *itv = fh2id(fh)->itv;

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

	if (*std == itv->std)
		return 0;

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

	IVTV_DEBUG_INFO("Switching standard to %llx.\n",
		(unsigned long long)itv->std);

	ivtv_s_std_enc(itv, std);
	if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)
		ivtv_s_std_dec(itv, std);

	return 0;
}

+2 −1
Original line number Diff line number Diff line
@@ -27,7 +27,8 @@ u16 ivtv_get_service_set(struct v4l2_sliced_vbi_format *fmt);
void ivtv_set_osd_alpha(struct ivtv *itv);
int ivtv_set_speed(struct ivtv *itv, int speed);
void ivtv_set_funcs(struct video_device *vdev);
int ivtv_s_std(struct file *file, void *fh, v4l2_std_id *std);
void ivtv_s_std_enc(struct ivtv *itv, v4l2_std_id *std);
void ivtv_s_std_dec(struct ivtv *itv, v4l2_std_id *std);
int ivtv_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf);
int ivtv_s_input(struct file *file, void *fh, unsigned int inp);
long ivtv_v4l2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
+1 −1
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ static void ivtv_set_wss(struct ivtv *itv, int enabled, int mode)
	   Turning this signal on and off can confuse certain
	   TVs. As far as I can tell there is no reason not to
	   transmit this signal. */
	if ((itv->std & V4L2_STD_625_50) && !enabled) {
	if ((itv->std_out & V4L2_STD_625_50) && !enabled) {
		enabled = 1;
		mode = 0x08;  /* 4x3 full format */
	}
Loading