linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] adv7604: add direct interrupt handling
@ 2016-01-13 15:15 Ulrich Hecht
  2016-01-18 11:10 ` Hans Verkuil
  0 siblings, 1 reply; 4+ messages in thread
From: Ulrich Hecht @ 2016-01-13 15:15 UTC (permalink / raw)
  To: linux-media, linux-sh
  Cc: magnus.damm, laurent.pinchart, hans.verkuil, ian.molton, lars,
	william.towle, sergei.shtylyov, Ulrich Hecht

When probed from device tree, the i2c client driver can handle the
interrupt on its own.

Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
v3: uses IRQ_RETVAL

v2: implements the suggested style changes and drops the IRQF_TRIGGER_LOW
flag, which is handled in the device tree.


 drivers/media/i2c/adv7604.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 5bd81bd..ab4cb25 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -31,6 +31,7 @@
 #include <linux/gpio/consumer.h>
 #include <linux/hdmi.h>
 #include <linux/i2c.h>
+#include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/slab.h>
@@ -1971,6 +1972,16 @@ static int adv76xx_isr(struct v4l2_subdev *sd, u32 status, bool *handled)
 	return 0;
 }
 
+static irqreturn_t adv76xx_irq_handler(int irq, void *devid)
+{
+	struct adv76xx_state *state = devid;
+	bool handled;
+
+	adv76xx_isr(&state->sd, 0, &handled);
+
+	return IRQ_RETVAL(handled);
+}
+
 static int adv76xx_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
 {
 	struct adv76xx_state *state = to_state(sd);
@@ -2844,8 +2855,7 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
 		state->pdata.op_656_range = 1;
 	}
 
-	/* Disable the interrupt for now as no DT-based board uses it. */
-	state->pdata.int1_config = ADV76XX_INT1_CONFIG_DISABLED;
+	state->pdata.int1_config = ADV76XX_INT1_CONFIG_ACTIVE_LOW;
 
 	/* Use the default I2C addresses. */
 	state->pdata.i2c_addresses[ADV7604_PAGE_AVLINK] = 0x42;
@@ -3235,6 +3245,16 @@ static int adv76xx_probe(struct i2c_client *client,
 	v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name,
 			client->addr << 1, client->adapter->name);
 
+	if (client->irq) {
+		err = devm_request_threaded_irq(&client->dev,
+						client->irq,
+						NULL, adv76xx_irq_handler,
+						IRQF_ONESHOT,
+						dev_name(&client->dev), state);
+		if (err)
+			goto err_entity;
+	}
+
 	err = v4l2_async_register_subdev(sd);
 	if (err)
 		goto err_entity;
-- 
2.6.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] adv7604: add direct interrupt handling
  2016-01-13 15:15 [PATCH v3] adv7604: add direct interrupt handling Ulrich Hecht
@ 2016-01-18 11:10 ` Hans Verkuil
  2016-02-08  9:24   ` Hans Verkuil
  0 siblings, 1 reply; 4+ messages in thread
From: Hans Verkuil @ 2016-01-18 11:10 UTC (permalink / raw)
  To: Ulrich Hecht, linux-media, linux-sh
  Cc: magnus.damm, laurent.pinchart, hans.verkuil, ian.molton, lars,
	william.towle, sergei.shtylyov

On 01/13/2016 04:15 PM, Ulrich Hecht wrote:
> When probed from device tree, the i2c client driver can handle the
> interrupt on its own.
> 
> Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> v3: uses IRQ_RETVAL
> 
> v2: implements the suggested style changes and drops the IRQF_TRIGGER_LOW
> flag, which is handled in the device tree.
> 
> 
>  drivers/media/i2c/adv7604.c | 24 ++++++++++++++++++++++--
>  1 file changed, 22 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
> index 5bd81bd..ab4cb25 100644
> --- a/drivers/media/i2c/adv7604.c
> +++ b/drivers/media/i2c/adv7604.c
> @@ -31,6 +31,7 @@
>  #include <linux/gpio/consumer.h>
>  #include <linux/hdmi.h>
>  #include <linux/i2c.h>
> +#include <linux/interrupt.h>
>  #include <linux/kernel.h>
>  #include <linux/module.h>
>  #include <linux/slab.h>
> @@ -1971,6 +1972,16 @@ static int adv76xx_isr(struct v4l2_subdev *sd, u32 status, bool *handled)
>  	return 0;
>  }
>  
> +static irqreturn_t adv76xx_irq_handler(int irq, void *devid)
> +{
> +	struct adv76xx_state *state = devid;
> +	bool handled;
> +
> +	adv76xx_isr(&state->sd, 0, &handled);
> +
> +	return IRQ_RETVAL(handled);
> +}
> +
>  static int adv76xx_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
>  {
>  	struct adv76xx_state *state = to_state(sd);
> @@ -2844,8 +2855,7 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
>  		state->pdata.op_656_range = 1;
>  	}
>  
> -	/* Disable the interrupt for now as no DT-based board uses it. */
> -	state->pdata.int1_config = ADV76XX_INT1_CONFIG_DISABLED;
> +	state->pdata.int1_config = ADV76XX_INT1_CONFIG_ACTIVE_LOW;

Hmm, this hardcodes the interrupt to active low. Can you use the DT to determine
whether it should be active low or high?

Regards,

	Hans

>  
>  	/* Use the default I2C addresses. */
>  	state->pdata.i2c_addresses[ADV7604_PAGE_AVLINK] = 0x42;
> @@ -3235,6 +3245,16 @@ static int adv76xx_probe(struct i2c_client *client,
>  	v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name,
>  			client->addr << 1, client->adapter->name);
>  
> +	if (client->irq) {
> +		err = devm_request_threaded_irq(&client->dev,
> +						client->irq,
> +						NULL, adv76xx_irq_handler,
> +						IRQF_ONESHOT,
> +						dev_name(&client->dev), state);
> +		if (err)
> +			goto err_entity;
> +	}
> +
>  	err = v4l2_async_register_subdev(sd);
>  	if (err)
>  		goto err_entity;
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] adv7604: add direct interrupt handling
  2016-01-18 11:10 ` Hans Verkuil
@ 2016-02-08  9:24   ` Hans Verkuil
  2016-02-08  9:29     ` Lars-Peter Clausen
  0 siblings, 1 reply; 4+ messages in thread
From: Hans Verkuil @ 2016-02-08  9:24 UTC (permalink / raw)
  To: Ulrich Hecht, linux-media, linux-sh
  Cc: magnus.damm, laurent.pinchart, hans.verkuil, ian.molton, lars,
	william.towle, sergei.shtylyov

Hi Ulrich,

On 01/18/2016 12:10 PM, Hans Verkuil wrote:
> On 01/13/2016 04:15 PM, Ulrich Hecht wrote:
>> When probed from device tree, the i2c client driver can handle the
>> interrupt on its own.
>>
>> Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>
>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>> ---
>> v3: uses IRQ_RETVAL
>>
>> v2: implements the suggested style changes and drops the IRQF_TRIGGER_LOW
>> flag, which is handled in the device tree.
>>
>>
>>  drivers/media/i2c/adv7604.c | 24 ++++++++++++++++++++++--
>>  1 file changed, 22 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
>> index 5bd81bd..ab4cb25 100644
>> --- a/drivers/media/i2c/adv7604.c
>> +++ b/drivers/media/i2c/adv7604.c
>> @@ -31,6 +31,7 @@
>>  #include <linux/gpio/consumer.h>
>>  #include <linux/hdmi.h>
>>  #include <linux/i2c.h>
>> +#include <linux/interrupt.h>
>>  #include <linux/kernel.h>
>>  #include <linux/module.h>
>>  #include <linux/slab.h>
>> @@ -1971,6 +1972,16 @@ static int adv76xx_isr(struct v4l2_subdev *sd, u32 status, bool *handled)
>>  	return 0;
>>  }
>>  
>> +static irqreturn_t adv76xx_irq_handler(int irq, void *devid)
>> +{
>> +	struct adv76xx_state *state = devid;
>> +	bool handled;
>> +
>> +	adv76xx_isr(&state->sd, 0, &handled);
>> +
>> +	return IRQ_RETVAL(handled);
>> +}
>> +
>>  static int adv76xx_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
>>  {
>>  	struct adv76xx_state *state = to_state(sd);
>> @@ -2844,8 +2855,7 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
>>  		state->pdata.op_656_range = 1;
>>  	}
>>  
>> -	/* Disable the interrupt for now as no DT-based board uses it. */
>> -	state->pdata.int1_config = ADV76XX_INT1_CONFIG_DISABLED;
>> +	state->pdata.int1_config = ADV76XX_INT1_CONFIG_ACTIVE_LOW;
> 
> Hmm, this hardcodes the interrupt to active low. Can you use the DT to determine
> whether it should be active low or high?

Just a reminder: I don't want to accept this patch without this change. In most
cases an interrupt is active on high, not low, so I don't like to see this
hardcoded.

Regards,

	Hans

> 
> Regards,
> 
> 	Hans
> 
>>  
>>  	/* Use the default I2C addresses. */
>>  	state->pdata.i2c_addresses[ADV7604_PAGE_AVLINK] = 0x42;
>> @@ -3235,6 +3245,16 @@ static int adv76xx_probe(struct i2c_client *client,
>>  	v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name,
>>  			client->addr << 1, client->adapter->name);
>>  
>> +	if (client->irq) {
>> +		err = devm_request_threaded_irq(&client->dev,
>> +						client->irq,
>> +						NULL, adv76xx_irq_handler,
>> +						IRQF_ONESHOT,
>> +						dev_name(&client->dev), state);
>> +		if (err)
>> +			goto err_entity;
>> +	}
>> +
>>  	err = v4l2_async_register_subdev(sd);
>>  	if (err)
>>  		goto err_entity;
>>
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] adv7604: add direct interrupt handling
  2016-02-08  9:24   ` Hans Verkuil
@ 2016-02-08  9:29     ` Lars-Peter Clausen
  0 siblings, 0 replies; 4+ messages in thread
From: Lars-Peter Clausen @ 2016-02-08  9:29 UTC (permalink / raw)
  To: Hans Verkuil, Ulrich Hecht, linux-media, linux-sh
  Cc: magnus.damm, laurent.pinchart, hans.verkuil, ian.molton,
	william.towle, sergei.shtylyov

On 02/08/2016 10:24 AM, Hans Verkuil wrote:
> Hi Ulrich,
> 
> On 01/18/2016 12:10 PM, Hans Verkuil wrote:
>> On 01/13/2016 04:15 PM, Ulrich Hecht wrote:
>>> When probed from device tree, the i2c client driver can handle the
>>> interrupt on its own.
>>>
>>> Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>
>>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>>> ---
>>> v3: uses IRQ_RETVAL
>>>
>>> v2: implements the suggested style changes and drops the IRQF_TRIGGER_LOW
>>> flag, which is handled in the device tree.
>>>
>>>
>>>  drivers/media/i2c/adv7604.c | 24 ++++++++++++++++++++++--
>>>  1 file changed, 22 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
>>> index 5bd81bd..ab4cb25 100644
>>> --- a/drivers/media/i2c/adv7604.c
>>> +++ b/drivers/media/i2c/adv7604.c
>>> @@ -31,6 +31,7 @@
>>>  #include <linux/gpio/consumer.h>
>>>  #include <linux/hdmi.h>
>>>  #include <linux/i2c.h>
>>> +#include <linux/interrupt.h>
>>>  #include <linux/kernel.h>
>>>  #include <linux/module.h>
>>>  #include <linux/slab.h>
>>> @@ -1971,6 +1972,16 @@ static int adv76xx_isr(struct v4l2_subdev *sd, u32 status, bool *handled)
>>>  	return 0;
>>>  }
>>>  
>>> +static irqreturn_t adv76xx_irq_handler(int irq, void *devid)
>>> +{
>>> +	struct adv76xx_state *state = devid;
>>> +	bool handled;
>>> +
>>> +	adv76xx_isr(&state->sd, 0, &handled);
>>> +
>>> +	return IRQ_RETVAL(handled);
>>> +}
>>> +
>>>  static int adv76xx_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
>>>  {
>>>  	struct adv76xx_state *state = to_state(sd);
>>> @@ -2844,8 +2855,7 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
>>>  		state->pdata.op_656_range = 1;
>>>  	}
>>>  
>>> -	/* Disable the interrupt for now as no DT-based board uses it. */
>>> -	state->pdata.int1_config = ADV76XX_INT1_CONFIG_DISABLED;
>>> +	state->pdata.int1_config = ADV76XX_INT1_CONFIG_ACTIVE_LOW;
>>
>> Hmm, this hardcodes the interrupt to active low. Can you use the DT to determine
>> whether it should be active low or high?
> 
> Just a reminder: I don't want to accept this patch without this change. In most
> cases an interrupt is active on high, not low, so I don't like to see this
> hardcoded.

I think the important part here is to configure the IRQ here in the same way
as the flags that are passed to request_irq(). Right now it does not pass
any flags to request_irq() which means the result is pretty much
unpredictable and depends on the default configuration of the IRQ chip
(which might change between kernel versions).

>>>  	/* Use the default I2C addresses. */
>>>  	state->pdata.i2c_addresses[ADV7604_PAGE_AVLINK] = 0x42;
>>> @@ -3235,6 +3245,16 @@ static int adv76xx_probe(struct i2c_client *client,
>>>  	v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name,
>>>  			client->addr << 1, client->adapter->name);
>>>  
>>> +	if (client->irq) {
>>> +		err = devm_request_threaded_irq(&client->dev,
>>> +						client->irq,
>>> +						NULL, adv76xx_irq_handler,
>>> +						IRQF_ONESHOT,
>>> +						dev_name(&client->dev), state);
>>> +		if (err)
>>> +			goto err_entity;
>>> +	}
>>> +


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-02-08  9:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-13 15:15 [PATCH v3] adv7604: add direct interrupt handling Ulrich Hecht
2016-01-18 11:10 ` Hans Verkuil
2016-02-08  9:24   ` Hans Verkuil
2016-02-08  9:29     ` Lars-Peter Clausen

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).