Hi Guennadi,
I don't know if you are the right person to ask this query (since
it is also related to GPIO stuff), but here goes:
Our board has a I2C controlled camera sensor whose Chip Enable (CE)
pin is driven via a GPIO. This GPIO is made available by a I2C-to-GPIO
expander chip (STMPE801, see user manual [1])
Now, when we implement the 's_power' routines as specified by the soc-camera
framework, a peculiar issue arises:
The 's_power' routine simply toggles the CE of the sensor as per the power-on/off
command received from the framework/bridge driver. And this works absolutely fine
in normal cases. As we have a GPIO on a external chip (STMPE801) we need to use
*_cansleep variants of the gpio_set/get routines (see [2] for reference) to toggle
the GPIO values to power-on/off the sensor chip.
Now, when we terminate a user application (a standard application like 'capture'
available as a reference v4l2 test application) which was capturing a large
number of frames from the sensor, using 'ctrl-c', I see that 's_power' is
correctly called with a power-off argument. However, the I2C controller driver
(we use the standard SYNOPSYS designware device driver present in mainline,
see [3]) returns -ERESTARTSYS in response to the write command we had requested
for putting the sensor to power-off state (as it has received the <ctrl-c> kill
signal).
But as the gpio_set_val_* variants are inherently 'void' implementations, we have
no mechanism to use and handle the -ERESTARTSYS value in the 's_power' implementation.
I also found that the standard 'soc_camera.c' does not check the return value in
'soc_camera_power_off' routines, but that is a easily fixable issue.
Now, I want your opinions on how to get out of this mess.
Perhaps changes in GPIO implementations? Or am I missing
something here.
References:
[1] http://www.st.com/internet/analog/product/154542.jsp
[2] http://lxr.linux.no/linux+v3.1.5/Documentation/gpio.txt#L195
[3] http://lxr.linux.no/linux+v3.1.5/drivers/i2c/busses/i2c-designware.c
Regards,
Bhupesh
On Wed, Feb 1, 2012 at 6:01 AM, Bhupesh SHARMA <[email protected]> wrote:
> Our board has a I2C controlled camera sensor whose Chip Enable (CE)
> pin is driven via a GPIO. This GPIO is made available by a I2C-to-GPIO
> expander chip (STMPE801, see user manual [1])
(...)
> the I2C controller driver
> (we use the standard SYNOPSYS designware device driver present in mainline,
> see [3]) returns -ERESTARTSYS in response to the write command we had requested
> for putting the sensor to power-off state (as it has received the <ctrl-c> kill
> signal).
So what happens if you go into the I2C driver and replace all things
that look like this:
ret = wait_for_completion_interruptible_timeout(&dev->cmd_complete, HZ);
With this:
ret = wait_for_completion_timeout(&dev->cmd_complete, HZ);
(Non-interruptible.)
This is usually the problem.
Yours,
Linus Walleij