devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marco Felsch <m.felsch@pengutronix.de>
To: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Cc: mchehab@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com,
	p.zabel@pengutronix.de, afshin.nasser@gmail.com,
	javierm@redhat.com, sakari.ailus@linux.intel.com,
	laurent.pinchart@ideasonboard.com, linux-media@vger.kernel.org,
	devicetree@vger.kernel.org, kernel@pengutronix.de
Subject: Re: [PATCH 13/22] [media] tvp5150: disable output while signal not locked
Date: Tue, 31 Jul 2018 08:02:40 +0200	[thread overview]
Message-ID: <20180731060240.wd4lexhpje2phb5z@pengutronix.de> (raw)
In-Reply-To: <20180730150058.30563d0f@coco.lan>

Hi Mauro,

thanks for your feedback.

On 18-07-30 15:00, Mauro Carvalho Chehab wrote:
> Em Thu, 28 Jun 2018 18:20:45 +0200
> Marco Felsch <m.felsch@pengutronix.de> escreveu:
> 
> > From: Philipp Zabel <p.zabel@pengutronix.de>
> > 
> > To avoid short frames on stream start, keep output pins at high impedance
> > while we are not properly locked onto the input signal.
> > 
> > Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> > Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> > ---
> >  drivers/media/i2c/tvp5150.c | 39 ++++++++++++++++++++++++++-----------
> >  1 file changed, 28 insertions(+), 11 deletions(-)
> > 
> > diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
> > index d8bdbedd8826..27cfd08be3d2 100644
> > --- a/drivers/media/i2c/tvp5150.c
> > +++ b/drivers/media/i2c/tvp5150.c
> > @@ -60,6 +60,7 @@ struct tvp5150 {
> >  	v4l2_std_id detected_norm;
> >  	u32 input;
> >  	u32 output;
> > +	u32 oe;
> >  	int enable;
> >  	bool lock;
> >  
> > @@ -799,14 +800,20 @@ static irqreturn_t tvp5150_isr(int irq, void *dev_id)
> >  {
> >  	struct tvp5150 *decoder = dev_id;
> >  	struct regmap *map = decoder->regmap;
> > -	unsigned int active = 0, status = 0;
> > +	unsigned int mask, active = 0, status = 0;
> > +
> > +	mask = TVP5150_MISC_CTL_YCBCR_OE | TVP5150_MISC_CTL_SYNC_OE |
> > +	       TVP5150_MISC_CTL_CLOCK_OE;
> >  
> >  	regmap_read(map, TVP5150_INT_STATUS_REG_A, &status);
> >  	if (status) {
> >  		regmap_write(map, TVP5150_INT_STATUS_REG_A, status);
> >  
> > -		if (status & TVP5150_INT_A_LOCK)
> > +		if (status & TVP5150_INT_A_LOCK) {
> >  			decoder->lock = !!(status & TVP5150_INT_A_LOCK_STATUS);
> > +			regmap_update_bits(map, TVP5150_MISC_CTL, mask,
> > +					   decoder->lock ? decoder->oe : 0);
> > +		}
> >  
> >  		return IRQ_HANDLED;
> >  	}
> > @@ -872,10 +879,26 @@ static int tvp5150_enable(struct v4l2_subdev *sd)
> >  	/* Disable autoswitch mode */
> >  	tvp5150_set_std(sd, std);
> >  
> > -	if (decoder->mbus_type == V4L2_MBUS_PARALLEL)
> > +	/*
> > +	 * Enable the YCbCr and clock outputs. In discrete sync mode
> > +	 * (non-BT.656) additionally enable the the sync outputs.
> > +	 */
> > +	switch (decoder->mbus_type) {
> > +	case V4L2_MBUS_PARALLEL:
> >  		/* 8-bit 4:2:2 YUV with discrete sync output */
> >  		regmap_update_bits(decoder->regmap, TVP5150_DATA_RATE_SEL,
> >  				   0x7, 0x0);
> > +		decoder->oe = TVP5150_MISC_CTL_YCBCR_OE |
> > +			      TVP5150_MISC_CTL_CLOCK_OE |
> > +			      TVP5150_MISC_CTL_SYNC_OE;
> > +		break;
> > +	case V4L2_MBUS_BT656:
> > +		decoder->oe = TVP5150_MISC_CTL_YCBCR_OE |
> > +			      TVP5150_MISC_CTL_CLOCK_OE;
> > +		break;
> > +	default:
> > +		return -EINVAL;
> > +	}
> >  
> >  	return 0;
> >  };
> > @@ -1190,14 +1213,8 @@ static int tvp5150_s_stream(struct v4l2_subdev *sd, int enable)
> >  	if (enable) {
> >  		tvp5150_enable(sd);
> >  
> > -		/*
> > -		 * Enable the YCbCr and clock outputs. In discrete sync mode
> > -		 * (non-BT.656) additionally enable the the sync outputs.
> > -		 */
> > -		val = TVP5150_MISC_CTL_YCBCR_OE | TVP5150_MISC_CTL_CLOCK_OE;
> > -		if (decoder->mbus_type == V4L2_MBUS_PARALLEL)
> > -			val |= TVP5150_MISC_CTL_SYNC_OE;
> > -
> > +		/* Enable outputs if decoder is locked */
> > +		val = decoder->lock ? decoder->oe : 0;
> 
> Hmm... this only works if the tvp5150 has the interrupts enabled.
> 
> The code should be, instead:
> 
> 	if (c->irq)
> 		val = decoder->lock ? decoder->oe : 0;
> 	else
> 		val = decoder->oe;

The previous patch "[media] tvp5150: Add sync lock interrupt handling"
adds the look mechanism. As you can see the lock will be always true
if there is no interrupt support during probe():

core->irq = c->irq;
tvp5150_reset(sd, 0);   /* Calls v4l2_ctrl_handler_setup() */
if (c->irq) {
	res = devm_request_threaded_irq(&c->dev, c->irq,
			NULL,
			tvp5150_isr,
			IRQF_TRIGGER_HIGH |
			IRQF_ONESHOT,
			"tvp5150", core);
	if (res)
		return res;
} else {
	core->lock = true;
}

I'am with you that your s_stream version looks a bit nicer but adds the
check again.

Regards,
Marco

> 
> >  		int_val = TVP5150_INT_A_LOCK;
> >  	}
> >  
> 
> 
> 
> Thanks,
> Mauro
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

  parent reply	other threads:[~2018-07-31  6:02 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-28 16:20 [PATCH 00/21] TVP5150 fixes and new features Marco Felsch
2018-06-28 16:20 ` [PATCH 01/22] [media] tvp5150: fix width alignment during set_selection() Marco Felsch
2018-06-28 16:20 ` [PATCH 02/22] [media] tvp5150: fix switch exit in set control handler Marco Felsch
2018-06-28 16:20 ` [PATCH 03/22] [media] tvp5150: convert register access to regmap Marco Felsch
2018-06-28 16:20 ` [PATCH 04/22] [media] tvp5150: make use of regmap_update_bits Marco Felsch
2018-06-28 16:20 ` [PATCH 05/22] [media] v4l2-rect.h: add position and equal helpers Marco Felsch
2018-06-29 14:12   ` Sakari Ailus
2018-06-28 16:20 ` [PATCH 06/22] [media] tvp5150: add FORMAT_TRY support for get/set selection handlers Marco Felsch
2018-07-31  0:01   ` Mauro Carvalho Chehab
2018-06-28 16:20 ` [PATCH 07/22] [media] tvp5150: add default format helper Marco Felsch
2018-06-28 16:20 ` [PATCH 08/22] [media] tvp5150: trigger autodetection on subdev open to reset cropping Marco Felsch
2018-06-28 16:20 ` [PATCH 09/22] [media] tvp5150: fix standard autodetection Marco Felsch
2018-06-28 16:20 ` [PATCH 10/22] [media] tvp5150: split reset/enable routine Marco Felsch
2018-06-28 16:20 ` [PATCH 11/22] [media] tvp5150: remove pin configuration from initialization tables Marco Felsch
2018-06-28 16:20 ` [PATCH 12/22] [media] tvp5150: Add sync lock interrupt handling Marco Felsch
2018-06-28 16:20 ` [PATCH 13/22] [media] tvp5150: disable output while signal not locked Marco Felsch
2018-07-30 18:00   ` Mauro Carvalho Chehab
2018-07-30 18:06     ` Mauro Carvalho Chehab
2018-07-31  6:02     ` Marco Felsch [this message]
2018-06-28 16:20 ` [PATCH 14/22] [media] tvp5150: issue source change events Marco Felsch
2018-06-28 16:20 ` [PATCH 15/22] [media] tvp5150: add sync lock/loss signal debug messages Marco Felsch
2018-06-28 16:20 ` [PATCH 16/22] [media] tvp5150: add querystd Marco Felsch
2018-07-30 18:09   ` Mauro Carvalho Chehab
2018-08-01 13:21     ` Marco Felsch
2018-08-01 14:22       ` Mauro Carvalho Chehab
2018-08-01 14:49         ` Marco Felsch
2018-08-01 15:50           ` Mauro Carvalho Chehab
2018-08-02  8:01             ` Marco Felsch
2018-08-02  9:49               ` Mauro Carvalho Chehab
2018-08-02 10:16                 ` Marco Felsch
2018-08-02 14:38                   ` Mauro Carvalho Chehab
2018-08-02 10:54                 ` Ian Arkver
2018-08-02 11:58                   ` Marco Felsch
2018-06-28 16:20 ` [PATCH 17/22] [media] tvp5150: add g_std callback Marco Felsch
2018-06-28 16:20 ` [PATCH 18/22] partial revert of "[media] tvp5150: add HW input connectors support" Marco Felsch
2018-07-03 23:19   ` Rob Herring
2018-07-30 18:18   ` Mauro Carvalho Chehab
2018-07-31  7:01     ` Marco Felsch
2018-07-31  8:52     ` Javier Martinez Canillas
2018-07-31 10:06       ` Mauro Carvalho Chehab
2018-07-31 11:26         ` Javier Martinez Canillas
2018-07-31 12:36           ` Marco Felsch
2018-07-31 12:52             ` Javier Martinez Canillas
2018-07-31 13:30               ` Marco Felsch
2018-07-31 19:56                 ` Mauro Carvalho Chehab
2018-08-01 12:10                   ` Marco Felsch
2018-08-01 13:32                     ` Mauro Carvalho Chehab
2018-08-01 15:49                 ` Marco Felsch
2018-08-01 16:23                   ` Javier Martinez Canillas
2018-07-31 13:01             ` Mauro Carvalho Chehab
2018-07-31 13:22         ` Mauro Carvalho Chehab
2018-06-28 16:20 ` [PATCH 19/22] [media] tvp5150: add input source selection of_graph support Marco Felsch
2018-07-30 18:29   ` Mauro Carvalho Chehab
2018-08-08 15:29     ` Marco Felsch
2018-08-08 18:52       ` Mauro Carvalho Chehab
2018-08-09 12:55         ` Marco Felsch
2018-08-09 13:36           ` Mauro Carvalho Chehab
2018-08-09 14:35             ` Marco Felsch
2018-08-09 16:04               ` Mauro Carvalho Chehab
2018-08-09 16:34                 ` Marco Felsch
2018-06-28 16:20 ` [PATCH 20/22] [media] tvp5150: Add input port connectors DT bindings Marco Felsch
2018-07-03 23:23   ` Rob Herring
2018-07-11  8:50     ` Marco Felsch
2018-08-03  7:29     ` Marco Felsch
2018-08-03 17:30       ` Mauro Carvalho Chehab
2018-08-04  9:04         ` Marco Felsch
2018-06-28 16:20 ` [PATCH 21/22] [media] tvp5150: initialize subdev before parsing device tree Marco Felsch
2018-06-28 16:20 ` [PATCH 22/22] [media] tvp5150: Change default input source selection behaviour Marco Felsch
2018-06-28 20:57 ` [PATCH 00/21] TVP5150 fixes and new features Javier Martinez Canillas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180731060240.wd4lexhpje2phb5z@pengutronix.de \
    --to=m.felsch@pengutronix.de \
    --cc=afshin.nasser@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=javierm@redhat.com \
    --cc=kernel@pengutronix.de \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mchehab+samsung@kernel.org \
    --cc=mchehab@kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=robh+dt@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).